var $rotateright = true;
var $rotateon = true;

var $Xds = new Array();
var $Xviews = 0;

function pressStateButton(obj, name) {
	for (i=0; i<document.images.length; i++)
		{
		if (document.images[i].name == name){
			document.images[i].src = 'images2/' + name+'_on.jpg';
			}
		else{
			if (document.images[i].name == 'zoomin'){
				document.images[i].src = 'images2/' + 'zoomin.jpg';
				} 
 			if (document.images[i].name == 'zoomout'){
		 		document.images[i].src = 'images2/' + 'zoomout.jpg';
				} 	
			}	
		}
	if (name == 'zoomin')
		{ obj.ZoomIn(); }
	if (name == 'zoomout')
		{ obj.ZoomOut(); }
};

function ResetThis(obj)	{
	document.images['zoomin'].src = 'images2/' + 'zoomin.jpg';
	document.images['zoomout'].src = 'images2/' + 'zoomout.jpg';		
	document.images['rotate'].src = 'images2/' + 'rotate_on.jpg';
	document.images['rotateleft'].src = 'images2/' + 'rotateleft.jpg';		
	document.images['rotateright'].src = 'images2/' + 'rotateright.jpg';
	document.images['pause'].src = 'images2/' + 'pause.jpg';		
	RotateRight(obj);
	$rotateright = true;
	$rotateon = true;
};
		
function Pause(obj)	{
	obj.stopAutoPan();
	$rotateon = false;
	for (i=0; i<document.images.length; i++)
		{
		if (document.images[i].name == 'rotateleft') document.images[i].src = 'images2/' + 'rotateleft.jpg';
		if (document.images[i].name == 'rotateright') document.images[i].src = 'images2/' + 'rotateright.jpg';
		if (document.images[i].name == 'pause') document.images[i].src = 'images2/' + 'pause_on.jpg';									
		if (document.images[i].name == 'rotate') document.images[i].src = 'images2/' + 'rotate.jpg';									
		}
};

function Rotate(obj)	{
	if ($rotateon)
		{ return; }
	$rotateon = true;
	for (i=0; i<document.images.length; i++)
		{
		if (document.images[i].name == 'rotateleft') document.images[i].src = 'images2/' + 'rotateleft.jpg';
		if (document.images[i].name == 'rotateright') document.images[i].src = 'images2/' + 'rotateright.jpg';
		if (document.images[i].name == 'pause') document.images[i].src = 'images2/' + 'pause.jpg';									
		if (document.images[i].name == 'rotate') document.images[i].src = 'images2/' + 'rotate_on.jpg';									
		}
	if ($rotateright)
		{ RotateRight(obj); }
	else
		{ RotateLeft(obj); }
};	

function RotateLeft(obj)	{
	if (!$rotateon)
		{ obj.panLeft();
		  return;
		}
	$rotateright = false;
	obj.startAutoPan(-0.25,0,1);
	for (i=0; i<document.images.length; i++)
		{
		if (document.images[i].name == 'rotateleft') document.images[i].src = 'images2/' + 'rotateleft_on.jpg';
		if (document.images[i].name == 'rotateright') document.images[i].src = 'images2/' + 'rotateright.jpg';
		if (document.images[i].name == 'pause') document.images[i].src = 'images2/' + 'pause.jpg';									
		}
};	

function RotateRight(obj)	{
	if (!$rotateon)
		{ obj.panRight();
		  return;
		}
	$rotateright = true;
	obj.startAutoPan(0.25,0,1);
	for (i=0; i<document.images.length; i++)
		{
		if (document.images[i].name == 'rotateleft') document.images[i].src = 'images2/' + 'rotateleft.jpg';
		if (document.images[i].name == 'rotateright') document.images[i].src = 'images2/' + 'rotateright_on.jpg';
		if (document.images[i].name == 'pause') document.images[i].src = 'images2/' + 'pause.jpg';									
		}
};	

var $Pathx = "";

function SetPtvParams(listnum,views,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12)
  {
	$Pathx = "images/"+listnum+"/T"+listnum;
	addPTViewerParameter("file",$Pathx+"_1.JPG");
	addPTViewerParameter("cursor","MOVE");
	addPTViewerParameter("barcolor","1111aa");
	addPTViewerParameter("auto",".20");
	addPTViewerParameter("tilt"," 0");
	addPTViewerParameter("bar_height","8");
	addPTViewerParameter("bgcolor","ffffff");
	addPTViewerParameter("wait","controlimages/waita.gif");
	addPTViewerParameter("view_height","360");
	addPTViewerParameter("preload","file="+$Pathx+"_1.JPG,"+$Pathx+"_2.JPG,"+$Pathx+"_3.JPG,"+$Pathx+"_4.JPG,"+$Pathx+"_5.JPG,"+$Pathx+"_6.JPG");

	if (views >= 1)
		{
		addPTViewerParameter("pano0","{file="+$Pathx+"_1.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 2)
		{
		addPTViewerParameter("pano1","{file="+$Pathx+"_2.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 3)
		{
		addPTViewerParameter("pano2","{file="+$Pathx+"_3.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 4)
		{
		addPTViewerParameter("pano3","{file="+$Pathx+"_4.JPG}{pan=0}{fov=95}{auto=.20}{tilt=30}");
		}
	if (views >= 5)
		{
		addPTViewerParameter("pano4","{file="+$Pathx+"_5.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 6)
		{
		addPTViewerParameter("pano5","{file="+$Pathx+"_6.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 7)
		{
		addPTViewerParameter("pano6","{file="+$Pathx+"_7.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 8)
		{
		addPTViewerParameter("pano7","{file="+$Pathx+"_8.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 9)
		{
		addPTViewerParameter("pano8","{file="+$Pathx+"_9.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 10)
		{
		addPTViewerParameter("pano9","{file="+$Pathx+"_10.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 11)
		{
		addPTViewerParameter("pano10","{file="+$Pathx+"_11.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}
	if (views >= 12)
		{
		addPTViewerParameter("pano11","{file="+$Pathx+"_12.JPG}{pan=0}{fov=95}{auto=.20}{tilt= -5}");
		}


	InsertPTVApplet("viewer1",490,326);

	$Xviews = views;
	$Xds[0] = d1;	
	$Xds[1] = d2;
	$Xds[2] = d3;
	$Xds[3] = d4;
	$Xds[4] = d5;
	$Xds[5] = d6;
	$Xds[6] = d7;
	$Xds[7] = d8;
	$Xds[8] = d9;
	$Xds[9] = d10;
	$Xds[10] = d11;
	$Xds[11] = d12;
};

function SetCtrlIcons()	{
	document.write('<a href=\"#\" onClick=\"pressStateButton(document.viewer1, \'zoomin\')\"><img src=\"images2/zoomin.jpg\" width=\"24\" height=\"25\" border=\"0\" name=\"zoomin\" alt=\"Zoom In\"></a>');
	document.write('<a href=\"#\" onClick=\"pressStateButton(document.viewer1, \'zoomout\')\"><img src=\"images2/zoomout.jpg\" width=\"24\" height=\"25\" border=\"0\" name=\"zoomout\" alt=\"Zoom Out\"></a>');
	document.write('<a href=\"#\" onClick=\"RotateLeft(document.viewer1)\"><img src=\"images2/rotateleft.jpg\" width=\"24\" height=\"25\" border=\"0\" name=\"rotateleft\"  alt=\"Rotate Left\"></a>');
	document.write('<a href=\"#\" onClick=\"Rotate(document.viewer1)\"><img src=\"images2/rotate_on.jpg\" height=\"25\" border=\"0\" name=\"rotate\" alt=\"Rotate\"></a>');
	document.write('<a href=\"#\" onClick=\"Pause(document.viewer1)\"><img src=\"images2/pause.jpg\" width=\"24\" height=\"25\" border=\"0\"  name=\"pause\"  alt=\"Pause\"></a>');
	document.write('<a href=\"#\" onClick=\"RotateRight(document.viewer1)\"><img src=\"images2/rotateright_on.jpg\" width=\"24\" height=\"25\" border=\"0\" name=\"rotateright\" alt=\"Rotate Right\"></a>');
};

function setStyle(sel) {
	document.write('<style type=\"text/css\">');
	document.write('body \{ margin-top: 0; margin-left: 0; font-size: 15px; font-family: verdana, arial, serif; background-color: #ffffff; color: #000000; text-align: left; \}');
	document.write('.ptable \{ width: 775; align: center \}');
	document.write('a \{text-decoration: none; color: #ffffff; \}');
	document.write('a:hover \{text-decoration: none; color: #ffff00; \}');
	document.write('a:active {text-decoration: none; color: #0000ff; \}');
	document.write('</style>');

	if (sel == 1)
		{
		document.write('<script>');
		document.write('document.onselectstart = function() {return false;};');
		document.write('</script>');
		}
};

function WJsetView(obj, view) {
	obj.Set_file(view);
	obj.ResetApplet();
};

function WjNewPTview(view) {
	document.viewer1.newPanoFromList(view);
};
/*
function SetControlLinks(lim1, lim2, lim3, lim4) {
	ns = 0;
	MakeLinks(ns, lim1);
	if (lim2 != 0)
		{
		ns = (ns + lim1);
		MakeLinks(ns, (ns + lim2));
		}
	if (lim3 != 0)
		{
		ns = (ns + lim2);
		MakeLinks(ns, (ns + lim3));
		}
	if (lim4 != 0)
		{
		ns = (ns + lim3);
		MakeLinks(ns, (ns + lim4));
		}
	if (lim4 == 0)
		document.write('\n\t<br>');
	if (lim3 == 0)
		document.write('\n\t<br>');
	if (lim2 == 0)
		document.write('\n\t<br>');
};
*/
/*
function MakeLinks(start, lim) {
	for(nj = start; nj < lim; nj ++)
		{
		if (nj != start)
			document.write('&nbsp&nbsp&nbsp');
		document.write('\n\t<a href=\"#\" onClick=\'WjNewPTview('+nj+')\'>'+$Xds[nj]+'</a>\n');
		}
	document.write('\n\t<br>');
};
*/



