// JavaScript Document

function changepano() 
{
	var selectedVideo=1;
	var soundon=false;
	var elementid = document.getElementById("choice");
	var temp = elementid[elementid.selectedIndex].value;
	var temp2 = temp.split(",");

	if (temp2[0] == "pano")
	{

		document.getElementById("panodiv").style.visibility = "visible";
		document.getElementById("ptviewer").newPanoFromList(parseInt(temp2[1]));
		startpano();
	}
	if (temp2[0] == "still")
	{
		stoppano();
		stopflashvideo();
		startsoundplayer();
		hideflashvideo();
		hidestills();
		document.getElementById("panodiv").style.visibility = "hidden";
		document.getElementById("slideshow").style.visibility = "hidden";
		document.getElementById("stilldiv" + temp2[1]).style.visibility = "visible";
		
		document.getElementById("textdiv").innerHTML = temp2[2];
		document.getElementById("textTitle").innerHTML = temp2[3];
	}
	if (temp2[0] == "video")
	{
	try{
	
		if(temp2[4]=="true")
		{

			startsoundplayer();
		}
		else
		{
			stopsoundplayer();
			
		}
	}
	catch(e)
	{}
	
		stoppano();		

		stopflashvideo();
		hideflashvideo();
		selectedVideo = temp2[1];
		document.getElementById("panodiv").style.visibility = "hidden";
		document.getElementById("slideshow").style.visibility = "hidden";
		startflashvideo(selectedVideo);
		document.getElementById("viddiv"+selectedVideo).style.visibility = "visible";
		document.getElementById("textdiv").innerHTML = temp2[2];
		document.getElementById("textTitle").innerHTML = temp2[3];
	}
	if(temp2[0] == "slideshow")
	{
		stoppano();
		hidestills();	
		stopflashvideo();
		hideflashvideo();
		startsoundplayer();
		document.getElementById("panodiv").style.visibility = "hidden";
		document.getElementById("viddiv1").style.visibility = "hidden";
		document.getElementById("slideshow").style.visibility = "visible";
		document.getElementById("textdiv").innerHTML = temp2[2];
		document.getElementById("textTitle").innerHTML = temp2[3];
	}
	
}

function stoppano() 
{
	document.getElementById("ptviewer").stopAutoPan();
}

function startpano() 
{
	document.getElementById("ptviewer").startAutoPan( 0.2, 0.0, 1.0 );
}

function still_visible() 
{
	document.getElementById("stilldiv"+ temp2[1]).style.visibility = "visible";
	document.getElementById("panodiv").style.visibility = "hidden";
}

function pano_visible() 
{
	//hidestills();
	//externalLinks();
	externalLinks();
	document.getElementById("panodiv").style.visibility = "visible";
	//hideflashvideos()
}
function video_visible()
{
	selectedVideo = 1;
	stopsoundplayer();
	hidestills();
	document.getElementById("panodiv").style.visibility = "hidden";
	document.getElementById("viddiv"+selectedVideo).style.visibility = "visible";
	startflashvideo(selectedVideo);
}

function stopvideo()
{
	document.mediaPlayer.stop();
}

function startvideo()
{
	document.mediaPlayer.play();
}
function stopflashvideo()
{  
		if (navigator.userAgent.indexOf("Opera")==-1)
		{		
			try
			{
				for(i=1;i<3;i++)
				{
					var movie  = 
					
					eval("this.document.video"+i);
					movie.GotoFrame(2);
					movie.StopPlay();
				}
			}
			catch(e)
			{
				alert("Errro");
			}
			
		}
}


function startflashvideo(invidnumber)
{
	try
	{
			var movie = eval("document."+"video" + invidnumber);
			movie.Play();
			if(movie.isPlaying){echo("Hello");}
	}
	catch(e){}
}


function stopsoundplayer()
{
try
{
	soundon=false;
	if (navigator.userAgent.indexOf("Opera")==-1)
	{

		var sound=document.sound;
		sound.GotoFrame(2);
	}
}
catch(e){}
}
function startsoundplayer()
{	
	try
	{
		var sound=document.sound;
		if(!soundon)
		{
			soundon=true;
			if (navigator.userAgent.indexOf("Opera")==-1)
			{
				sound.Rewind();
			}
		}

	}
	catch(e)
	{}
}
function hidestills()
{
		try
		{
			for(i=1;i<3;i++)
			{
				document.getElementById("stilldiv" + i).style.visibility = "hidden";
			}
		}
		catch(e)
		{}
}
function hideflashvideo()
{
		try
		{
				for(i=1;i<3;i++)
				{
						
					document.getElementById("viddiv" + i).style.visibility = "hidden";
			}
		}
		catch(e)
		{}
		
}
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 

} 