/*
************************************************************************************************
************************************************************************************************
************************************************************************************************
3DROTATOR PRODUCT VIEWER ADVANCED FEATURES API www.3DRotator.com

	Make a link on your page cause the 3DRotator viewer to rotate or zoom. Great for pointing out a feature on your product or teaching.
	OR Integrate with your flash movie allowing it to control the 3DRotator viewer in real time

		function MoveTo(xdegree, ydegree, xpan, ypan, zoom, time, relative, sharpen, callbackfunctionname)
			- where 
				xdegree and ydegree are in degrees, set to -1 for no change (double)
				xpan	and ypan are in percent, a value of 50 means centered, set to -1 for no change for absolute mode (double)
				zoom 	is how far zoomed in, from 1 to 10 times, set to -1 for no change for absolute mode (double)
				time 	is for rotation in milliseconds, can be = 0 for jump (double)
				relative is true or false, if true - values are change from current, false=values are absolute (boolean)
				sharpen is true or false, if true - the image is sharpened after rotation (boolean)
				callbackfunctionname is string name of javascript function to receive current displayed position of object. leave '' (blank) for no call back (string)

			- examples
				to zoom out, then rotate, then zoom back in to an absolute position use:
					<a onClick="RotatorMoveTo('RotatorViewer',180,60,50,50,5,100,false,true,'RotatorDisplayPosition');" href="javascript:void(0);" onMouseOver="window.status='See this part of the object';return true;">See This Part of the object</a>

				to rotate 20 degrees to the left while keeping the current zoom level, do not sharpen after
					<a onClick="RotatorMoveTo('RotatorViewer',-20,0,0,0,0,0,true,false,'');" href="javascript:void(0);" onMouseOver="window.status='Rotate 20 degrees to left';return true;">Rotate 20 degrees to left</a>

				to zoom to a new spot without rotating
					<a onClick="RotatorMoveTo('RotatorViewer',-1,-1,30,20,2,100,false,true,'');" href="javascript:void(0);" onMouseOver="window.status='Zoom to a particular spot';return true;">zoom to a particular spot</a>

				to zoom out from the current zoom without panning or rotating
					<a onClick="RotatorMoveTo('RotatorViewer',0,0,0,0,-1,100,true,true,'');" href="javascript:void(0);" onMouseOver="window.status='Zoom out';return true;">Zoom out</a>

				to pan diagonally without rotating or zooming
					<a onClick="RotatorMoveTo('RotatorViewer',0,0,-10,10,0,100,true,true,'');" href="javascript:void(0);" onMouseOver="window.status='Pan up-right';return true;">Pan up-right</a>
************************************************************************************************
************************************************************************************************
************************************************************************************************
*/




if (RotatorViewerNamed == null){ var RotatorViewerNamed = new Array(10);}



function RotatorViewerLoaded(rotatorId, viewerWidth, viewerHeight){
	/*
	this function gets called when applet started.
	required before RotatorMove() function call from a button on your webpage
	also allows you to start your own animation
	gets rid of error if applet does not exist. or is not ready
	simplifies/improves compatibility of opera and IE when calling the MoveTo function
	now can use RotatorMove() function defined below
 	*/

	if (document.getElementById){
		 RotatorViewerNamed[rotatorId] = document.getElementById(rotatorId);
	}// end if document.getElementById


		// now can use a line like this without having to specify document.applet.RotatorViewerapplet.Move(...)  which works in Opera but IE needs document.RotatorViewerApplet.Move(...)
		//if (RotatorViewerNamed[rotatorId] != null) RotatorViewerNamed[rotatorId].setAngle(xdegree,'abs',ydegree,'abs');

		// but with the RotatorMove function defined below this is simpler
		//	RotatorMove('RotatorViewer',180,60,50,50,5,100,'sharpen','RotatorDisplayPosition');


		if (RotatorViewerNamed[rotatorId] != null) RotatorViewerNamed[rotatorId].setActionCallBack('RotatorDisplayPosition');



} // end function RotatorViewerLoaded


var useragentstring = " " + navigator.userAgent +" ";
if (useragentstring.indexOf('Safari',1) > 0) // if is safari then guess there is only one standard named viewer, this doesn't seem to be required
if (document.getElementById){
	 RotatorViewerNamed['RotatorViewer'] = document.getElementById('RotatorViewer');
}// end if document.getElementById



function RotatorMove(rotatorId, xdegree, ydegree, xpan, ypan, zoom, time, sharpen, callbackfunctionname){
	if (RotatorViewerNamed[rotatorId] != null){

		RotatorViewerNamed[rotatorId].setAngle(xdegree,'abs',ydegree,'abs');
		RotatorViewerNamed[rotatorId].setPan(xpan,'abs',ypan,'abs');
		RotatorViewerNamed[rotatorId].setZoom(zoom,'abs');
		RotatorViewerNamed[rotatorId].setSpeed(time);
		RotatorViewerNamed[rotatorId].setSharpenMode(sharpen);
		RotatorViewerNamed[rotatorId].move(callbackfunctionname);
	} 
} // end function RotatorMoveTo



function RotatorShowDemo(rotatorId, tool, interupt){
		RotatorViewerNamed[rotatorId].showDemo(tool, interupt);
} // end function RotatorShowDemo




function RotatorDisplayPosition(rotatorId, xdegrees, ydegrees, xpan, ypan, zoom){
	/*
	A function like this one is called after every user move with RotatorViewerNamed[rotatorId].setActionCallBack('RotatorDisplayPosition');
		-useful for finding the preset viewer positions to use in a RotatorMove(...); command from a link on your page.
	A function like this one is called after the RotatorMove(...); command completes all motion.
		- specify your function name in the last variable passed to RotatorMove();
		- leave '' (blank) if you do not want any function called.
	This function receives the current position of the object in the viewer.
	It also is an indication that all movement is complete.
		-useful for creating your own complex animations through javascript controling the 3DRotator Viewer
			once a Move has completed, you can send another Move command with the next position
			tip: set the time variable to zero to control your own smooth zooming
	*/


	/* in this example, a form text box displays the recieved values
	   assumes your html page has a form named "ViewerPosition", and an input box named "Display" like: 
			<form name=ViewerPosition>
			<input name=Display type=box value="" size=80 >
			</form>

	*/


   document.ViewerPosition.Display.value = "RotatorMove('" + rotatorId + "'," + xdegrees + "," + ydegrees + "," + xpan + "," + ypan + "," + zoom + ",100,'','');";

} // end function RotatorDisplayPosition




