/*
$Date: 2007-10-18 21:17:15 +0200 (Do, 18 Okt 2007) $
$Revision: 14 $
*/

var ready = 0;

function declareReady()		{ ready = 1; }
function runScript(fkt)		{ if (ready) { document.getElementById('bgapplet').runScript(fkt); } }
function runScriptTrg(fkt,trg)	{ if (ready) { document.getElementById('bgapplet').runScript(fkt,trg); } }
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 showLinks()		{ runScript("bg:showLinks();"); }
function hideLinks()		{ runScript("bg:hideLinks();"); }
function toggleSpots()		{ runScript("bg:toggleLinks();"); }
function gotoPano(id)		{ curAct = -1; runScript("bg:gotoPano(" + id + ");"); }
function gotoPanoParm(id,yaw,pitch,fov)	{ curAct = -1; runScript("bg:gotoPano(" + id + "," + yaw + "," + pitch + "," + fov + ");"); }
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 resetMap()			{ runScript("bg:resetSpots();"); }
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 + ");") }
function fullscreen3D()		{ runScript("bg:fullscreen3D();") }

//---- 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) {
	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 schalten = String(gruppe + nummer);
	/* "schalten" wird sichtbar */
	if (nummer)	{
		if (!document.getElementById(schalten)) return;
		else document.getElementById(schalten).className = 'active';
	}
	/* alle anderen werden unsichtbar */
	for (var i=1; i<=hoechst; i++) {
		if (i != nummer) {
			schalten = String(gruppe + i);
			if ( document.getElementById(schalten) )
				document.getElementById(schalten).className = ' ';
		}
	}
}

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 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');
}
