// v2.6 vom 7. 8. 2006 (FW)

var ready = 0;

function declareReady()		{ ready = 1; }
function runScript(fkt) 	{ if (ready) { document.getElementById('bgapplet').runScript(fkt); } }
function startPlay() 		{ runScript("bg:startAutoPan(0.5,0,1);"); }
function startPlayScript()  { runScript("bg:startScript();"); }
function stopPlay() 		{ runScript("bg:stopAutoPan();"); }
function zoomIn()			{ runScript("bg:startAutoPan(0,0,0.97);"); }
function zoomOut()			{ runScript("bg:startAutoPan(0,0,1.03);"); }
function toggleSpots()		{ runScript("bg:toggleLinks();"); }
function gotoPano(id)		{ curAct = -1; runScript("bg:gotoPano(" + id + ");"); }
function gotoPanoScript(id,script_id) { curAct = -1; runScript("bg:gotoPano(" + id + "," + script_id + ");"); }
function actSpot(panoID)	{ runScript("bg:activateSpot(" + panoID + ");") }
function deactSpot(panoID)	{ runScript("bg:deactivateSpot(" + panoID + ");") }
function showMapImg(id)		{ runScript("bg:showMapImg(" + id + ");") }
function hideMapImg()		{ runScript("bg:hideMapImg();") }
function viewCone(id)		{ runScript("bg:viewCone(" + id + ");") }
function viewMapSpots(id)	{ runScript("bg:viewMapSpots(" + id + ");") }
function showPatch(id)		{ runScript("bg:enablePatch(" + id + ");") }
function hidePatch(id)		{ runScript("bg:disablePatch(" + id + ");") }

// --- S Y N C --- //

var lastDetail = "";
var marker = 0;
var activ = window.setInterval("cycle()",200);

function cycle(){
   if (marker == 1 && lastDetail != ""){
      marker = 2;
      loc_detail = lastDetail;
      lastDetail = "";
      showDetail(loc_detail);
   }
   if (marker == 0 && lastDetail != ""){  // neuzugang, warten auf abarbeitung
      marker = 1;
   }
}

function showDetail(detail) { viewCone(0); viewMapSpots(0); showMapImg(detail); }
function hideDetail() 		{ if (marker == 2) { viewCone(1); viewMapSpots(1); hideMapImg(); } marker = 0; lastDetail = ""; }
function prepareDetail(detail)	{ lastDetail = detail; marker = 0; }

// --- S Y N C 2 --- //

function actSpot(panoID)	{ if (ready) _nhl = panoID; }
function deactSpot(panoID)	{ if (ready) _nhl = -1; };

var activ2 = window.setInterval("cycle2()",150);
var _chl = -1;   // current highlight
var _nhl = -1;   // new highlight
var chl = -1;   // current highlight local
var nhl = -1;   // new highlight local

function cycle2(){
   chl = _chl; // to prevent changes during cycle from evants...
   nhl = _nhl;
   if (chl == nhl){  // same spot, do nothing...
      return;
   }
   if (chl != -1){  // left the spot, deactivate current...
      var fkt = "bg:deactivateSpot(" + chl + ");";
      runScript(fkt);
      _chl = -1;
   }
   if (nhl != -1){
      var fkt = "bg:activateSpot(" + nhl + ");";
      runScript(fkt);
      _chl = nhl;
   }
}

//---- Layer-Steuerung

function zeige(gruppe, nummer, hoechst)
{
	var gruppe, nummer, hoechst;
	var schalten = String(gruppe + nummer);
	if (nummer)
	{
		if (!document.getElementById(schalten)) return;
		else document.getElementById(schalten).style.visibility='visible';
	}
	for (i=1; i<=hoechst; i++)
	{	if (i != nummer)
		{	schalten = String(gruppe + i);
			document.getElementById(schalten).style.visibility='hidden';
	}	}
}

function ptitel(beschreibung)
{
	if (!document.getElementById('ptitel')) return;
	document.getElementById('ptitel').firstChild.nodeValue = beschreibung;
}

function includeApplet(typ, key, breite, hoehe)
{
	var typ, key, breite, hoehe;
	if (typ=="pano")
	{
		typ="applet";
		var javahinweis = '<table width="'+breite+'" height="'+hoehe+'" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"><tr valign="middle"><td align="center">'+
			'<table width="'+breite+'" height="'+hoehe+'" border="0" cellpadding="0" cellspacing="0" style="color:#000000;"><tr><td height="'+hoehe+'">'+
			'<a href="http://www.java.com" target="_blank"><img src="java.gif" alt="Download Sun Java" width="51" height="95" hspace="6" border="0"></a></td>'+
			'<td align="left"><br><br><p align="left" style="padding-left:10px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight:normal; color:#000000">'+
			'Sie ben&ouml;tigen <b>JAVA</b>, um diese<br>Seite anzuzeigen. Bitte installieren<br>Sie das kostenlose Java-Plugin und<br>laden Sie die Seite dann erneut.'+
			'<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt; <a href="http://www.java.com" target="_blank"><font color="#006699"><b>JAVA-Download</b></font></a>'+
			'<br><br><font color="#555555">You need <b>JAVA</b> to view this page.<br>Please install the free Sun Micro-<br>systems Java plugin and reload.</font></p></td></tr></table></td></tr></table>';
	}
	else var javahinweis='<table border="0" cellpadding="0" cellspacing="0"><tr><td width="'+breite+'" height="'+hoehe+'" bgcolor="#FFFFFF">&nbsp;</td></tr></table>';
	document.write('<applet name="bg'+typ+'" id="bg'+typ+'" code="begehung.bg_'+typ+'.class" archive="bg.jar" width="'+breite+'" height="'+hoehe+'" hspace="0" vspace="0" mayscript="true">\n');
	document.write(javahinweis+'<param name="key" value="'+key+'"></applet>\n');
}
