/**
 * Hotspot Funktionen
 */
 
 
function openHS(objnr) {
	objektnr=objnr;
	if (bCounter) counter(objektnr);
	if (thickbox) {
		tb_show('Hotspot','popup.html?keepThis=true&TB_iframe=true&width=' + (objekt[objektnr]["size-x"] ) + '&height=' + (objekt[objektnr]["size-y"] ) + '&modal=true','');
	} else {
		popupwindow = window.open('popup.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + (objekt[objektnr]["size-x"] ) + ',height=' + (objekt[objektnr]["size-y"] ) + ',');
	}
}

function openPDF(objnr) {
	objektnr=objnr;
	if (bCounter) counter(objektnr);
	popupwindow = window.open("pdfs/" + objekt[objektnr]["pdf"],'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,');
}

function openPage(objnr) {
	objektnr=objnr;
	if (bCounter) counter(objektnr);
	if (parent.opener == null || parent.opener.closed) {
		window.open(objekt[objektnr]["link"],'Produktinformationen','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=' + (objekt[objektnr]["size-x"] ) + ',height=' + (objekt[objektnr]["size-y"] ) + ',');
	} else {	
		parent.opener.location.href=objekt[objektnr]["link"];
	}
}

function openANIM(objnr) {
	objektnr=objnr;
	if (bCounter) counter(objektnr);
	popupwindow = window.open('anim' + objektnr +  '.html','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + (objekt[objektnr]["size-x"] ) + ',height=' + (objekt[objektnr]["size-y"] ) + ',');
}

function openForm() {
//	produkt  = false;
//	objektnr = false;
	popupwindow = window.open('form.php','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=571');
}

/**
 * Player-Controls
 */
function getPano(s) {
	if (is.macie) {
		parent.curr_spin = s;
		location.reload();		// lädt die Seite neu im Falle von MacIE
	} else {
		loaded    = false;
		old_spin  = curr_spin;
		curr_spin = s;
		
		writeFlashCode();
		
	}
	if(bMenuType == 2 || bMenuType == 3) showHotspots(curr_spin);
	if(bGrundriss == true) setCurrent();
	if(bCounter) writeCounterScript('spin'+s);
}


function getPage(s) {
	// if (bCounter) counter(s);
	curr_spin = s;
	eval('document.location.href = "spin' + (s) + '.html";');
}


function mousehs(n) {
	if(bMouseHs == true) {
		showImage(n);
	}
}

function hotspot(hsnr) {
	if (loaded || is.macie || spinplayer == "flash") {
		if(flash=="6") {
		
			var panangle = Math.round(spin[curr_spin-1]['hotspot'][hsnr-1]['pos_x'] );
			if (panangle==0) {panangle=1;}
			var tilt     = Math.round(spin[curr_spin-1]['hotspot'][hsnr-1]['pos_y'] );
			var fov      = spin[curr_spin-1]['fov'];
			target = spin[curr_spin-1]['hotspot'][hsnr-1]['target'];
			
			if (navigator.appName.indexOf("Netscape") == -1) {
				document.getElementById('flashspin').SetVariable("_root.angle",panangle);
				document.getElementById('flashspin').SetVariable("_root.hs",hsnr-1);
				document.getElementById('flashspin').GotoFrame(1);
			} else {
				document.flashspin.SetVariable("_root.angle",panangle);
				document.flashspin.SetVariable("_root.hs",hsnr-1);
				document.flashspin.TGotoLabel("_root","moveTo");
			}
			if(target.match(/getPano/) && cachHS) {
				var searchNumber = /(\d+)/;
				searchNumber.exec(target);
				pano = RegExp.$1;
				
				var nTarget = spin[pano-1]['hotspot'][cachHS-1]['target'];
				eval(nTarget);
			}
		} else {
			

			var panangle = Math.round(spin[curr_spin-1]['hotspot'][hsnr-1]['pos_x'] );
			var tilt     = Math.round(spin[curr_spin-1]['hotspot'][hsnr-1]['pos_y'] );
			target = spin[curr_spin-1]['hotspot'][hsnr-1]['target'];
			window.document.pano.tunefulExternalPanoExecute('pano.pan='+panangle+',200');
			window.document.pano.tunefulExternalPanoExecute('pano.tilt='+tilt+',200');
			setTimeout("eval(target);",900);
		}
		
	}
}

function callFromFlash() {
	eval(target);
}
	

/**
 * Misc
 */
function writeInto(obj, text, win) {
	if(!obj || typeof obj != "string") return;
	
	obj = getById(obj, win);
	
	if(typeof obj == "undefined" || obj == null) return;
	
	if(typeof obj.innerHTML != 'undefined') {
  		obj.innerHTML = text;
	} else if(typeof document.layers != 'undefined') {
		obj.document.open('text/html');
	    	obj.document.write(text);
	     	obj.document.close();
	}
}

function getById(id, win) {
	if(typeof id == "undefined" || id == null) return null;
	
	var doc = (win) ? win.document : document;
	var obj  = null;

	if(document.getElementById) obj = doc.getElementById(id);
	else if(typeof document.layers != 'undefined')  obj = _findObj_(id, doc);
	else if(document.all) obj = doc.all[id];
	
	return obj;
}

function anleitung() {
	tb_show('','images/anleitung.html?keepThis=true&TB_iframe=true&width=308&height=328&modal=true','');
}


function extLink(link) {
	 var re = new RegExp ("mailto:", "i");
	 if (re.test(link)) {
	 	document.location.href = link;
	 } else {
	 	window.open(link, 'newWindow');
	 }
}




/**
 * Schreiben des Players
 */
 function writeCodeAfterWait() {
		writeFlashCode();
}

function writeFlashCode() {
	if(!flash6) {
		var so = new SWFObject("pano.swf", "pano", spin[0]['size_x'], spin[0]['size_y'], "9.0.28");
		so.addVariable("panoName", "images/scene"+curr_spin);
		so.addVariable("xml_text", panodata[curr_spin-1]);
		so.addParam("allowFullScreen","true");
		so.addParam("scale", "noscale");
		so.addParam("menu", "false");
		
		if(!so.write("spinid")) { 				//Wenn flash 9 nicht installiert ist
			writeFlashCodeOld();
		} else {
			flash="9";
		}
		
	} else {
		writeFlashCodeOld();
	}
}

function writeFlashCodeOld() {
		var path =  curr_lang+"/";
		path += "spin.swf?initscene=scene"+curr_spin;
		path += "&multilang="+curr_lang;
	
		var so = new SWFObject(path, "flashspin", spin[0]['size_x'], spin[0]['size_y'], "6");
		so.addParam("id","flashspin");
		so.addParam("wmode","transparent");
		so.addParam("allowFullScreen","true");
		so.addParam("scale", "noscale");
		so.write("spinid");
		
		if (flash=="") {
			tb_show('flash 9','flash.html?keepThis=true&TB_iframe=true&width=320&height=150&modal=true','');
		}
		flash="6";
}


function writeNotSupported() {
}
