// v3.1 vom 08. 11. 2006 (TM)

var ready = 0;

function declareReady()		{ ready = 1; }
function runScript(fkt) 	{ if (ready) { document.getElementById('bgapplet').runScript(fkt); } }
function startPlay() 		{ runScript("bg:startAutoPan(10,0,0);"); }
function startPlayScript()  { runScript("bg:startScript();"); }
function stopPlay() 		{ runScript("bg:stopAutoPan();"); }
function zoomIn()			{ runScript("bg:startAutoPan(0,0,-10);"); }
function zoomOut()			{ runScript("bg:startAutoPan(0,0,10);"); }
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)	{ if (ready) _nhl = panoID; runScript("bg:activateSpot(" + panoID + ");") }
function deactSpot(panoID)	{ if (ready) _nhl = -1; 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:showPatch(" + id + ");") }
function hidePatch(id)		{ runScript("bg:hidePatch(" + 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!="") 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 --- //

var activ2 = window.setInterval("cycle2()",150);
var _chl = -1, _nhl = -1, chl = -1, nhl = -1;

function cycle2() {
   chl=_chl; nhl=_nhl;
   if (chl == nhl) return;
   if (chl != -1){ var fkt = "bg:deactivateSpot("+chl+");"; runScript(fkt); _chl = -1; }
   if (nhl != -1){ var fkt = "bg:activateSpot("+nhl+");"; runScript(fkt); _chl = nhl; }
}

//---- Patch-Steuerung

patch_status = new Array();

function initPatches(pano_id, init_string) {
	patch_status[pano_id] = String(init_string);
}

function refreshPatches(pano_id) {
	for (i=1; i<=patch_status[pano_id].length; i++) {
		if (patch_status[pano_id].charAt(i-1)>="1") showPatch(i);
		else hidePatch(i);
	}
}

function togglePatch(pano_id, patch_id) {
	var pano_id, patch_id;
	if (patch_status[pano_id].charAt(patch_id-1)>="1") { hidePatch(patch_id); neu='0'; }
	else { showPatch(patch_id); neu='1'; }
	patch_status[pano_id] = patch_status[pano_id].substr(0,patch_id-1) + neu + patch_status[pano_id].substr(patch_id);
}

function setRemotePatch(pano_id, patch_id, zustand) {
	patch_status[pano_id] = patch_status[pano_id].substr(0,patch_id-1) + String(zustand) + patch_status[pano_id].substr(patch_id);
}

//---- 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 hilfe(h_text) {
	if (!h_text) document.getElementById('hilfe').style.visibility='hidden';
	else {
	document.getElementById('hilfe').firstChild.nodeValue=h_text;
	document.getElementById('hilfe').style.visibility='visible';
	}
}

function includeApplet(bgversion, typ, key, breite, hoehe, bgc) {
	var bgversion, typ, key, breite, hoehe, bgc, cls = typ;
	if (typ=="pano")
	{
		typ="applet"; cls="scene";
		var javahinweis = '<table width="'+breite+'" height="'+hoehe+'" cellpadding="0" cellspacing="0" border="0"><tr><td align="center">'+
		'<table cellpadding="0" cellspacing="0" border="0" style="color:#000000;"><tr><td height="'+hoehe+'">'+
		'<a href="http://www.java.com" target="_blank"><img src="java.gif" alt="Sun Java" width="51" height="95" hspace="15" border="0"></a></td>'+
		'<td><p align="left" style="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_'+cls+'.class" archive="bg'+bgversion+'.jar" width="'+breite+'" height="'+hoehe+'" hspace="0" vspace="0" mayscript="true">\n');
	document.write(javahinweis+'<param name="key" value="'+key+'"><param name="bgc" value="'+bgc+'"></applet>\n');
}