﻿/**
 * [include panorama]
 * Flash<->Javascript interaction for panorama-images
 */
var handleToWin = null;

function renderPanoWindow(theURL,winName,features, myWidth, myHeight, isCenter, baseurl) {
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	
	handleToWin = window.open('',winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
	handleToWin.document.open();
		handleToWin.document.write('<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">');
		handleToWin.document.write('<html xmlns=\"http://www.w3.org/1999/xhtml\">');
		handleToWin.document.write('<head>');
		handleToWin.document.write('<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />');
		handleToWin.document.write('<title>Stift Göttweig - Panorama</title>');
		handleToWin.document.write('</head>');
		handleToWin.document.write('<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">');
		handleToWin.document.write('<applet name=\"ptviewer\" archive=images/pano/res/ptviewer.jar  code=ptviewer.class width=450 height=330>');
		handleToWin.document.write('<param name=file        value=\"'+baseurl+'/images/pano/pic/'+theURL+'.jpg\">');
		handleToWin.document.write('<param name=frame       value=\"images/pano/res/control.gif\">');
		handleToWin.document.write('<param name=wait        value=\"images/pano/res/wait.gif\">');
		handleToWin.document.write('<param name=bar_x       value=\"54\">');
		handleToWin.document.write('<param name=bar_y       value=\"195\">');
		handleToWin.document.write('<param name=bar_width   value=\"343\">');
		handleToWin.document.write('<param name=bar_height  value=\"11\">');
		handleToWin.document.write('<param name=barcolor    value=\"FFFFFF\">');
		handleToWin.document.write('<param name=fov         value=\"99\">');
		handleToWin.document.write('<param name=fovmax      value=\"100\">');
		handleToWin.document.write('<param name=fovmin      value=\"70\">');
		handleToWin.document.write('<param name=tilt        value=\"-5\">');
		handleToWin.document.write('<param name=pan         value=\"100\">');
		handleToWin.document.write('<param name=quality     value=\"3\">');
		handleToWin.document.write('<param name=auto        value=\"0.2\">');
		handleToWin.document.write('<param name=cursor      value=\"MOVE\">');
		handleToWin.document.write('</applet>');
		handleToWin.document.write('</body>');
		handleToWin.document.write('</html>');
	handleToWin.document.close();
	handleToWin.focus();

	if (theURL == "pano_brunnensaal") {
		activeTitle = "Brunnensaal";
	} else if (theURL == "pano_kaiserstiege") {
		activeTitle = "Kaiserstiege";
	} else if (theURL == "pano_kirche") {
		activeTitle = "Kirche";
	} else if (theURL == "pano_sommerrefektorium") {
		activeTitle = "Sommerrefektorium";
	} else if (theURL == "pano_restaurant") {
		activeTitle = "Restaurant Terrasse";
	} else if (theURL == "pano_klosterinnenhof") {
		activeTitle = "Klosterinnenhof";
	}
	
	panoActiveTitle(activeTitle);
	closeMyWindow();
	return(true);
}

function closeMyWindow() {
	var flashPanoObject = getFlashMovieObject("flashPano");
	if (!handleToWin || handleToWin.closed) {
		document.getElementById("panoActiveTitle").innerHTML="";
		flashPanoObject.SetVariable("windowClosed", "isTrue");
	} else {
		setTimeout("closeMyWindow()",500);
	}
}

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  } else { // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    return document.getElementById(movieName);
  }
}

function panoOpenWindow(panoUrl, baseurl) {
	handleToWin = null;
	renderPanoWindow(panoUrl,'panoramaBilder','status=yes','450','330','true', baseurl);
}

function panoShowTitle(panoTitle) {
	document.getElementById("panoTitle").innerHTML=panoTitle;
}

function panoActiveTitle(panoTitle) {
	document.getElementById("panoActiveTitle").innerHTML=panoTitle;
}
