/* Steuerdatei zum Aufruf von JavaScript-Funktionen aus den Alpentouren heraus. */

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Browserabfrage */
if(navigator.appCodeName == "Mozilla") { // wenn Mozilla (oder Netscape oder Internet Explorer)
	if(navigator.appName == "Netscape") {
//		if(navigator.appVersion.substring(0,1) < 4) {document.location.href = "noscript.htm";}
		if(navigator.appVersion.substring(0,1) == 4) {Browser = 1;} // Netscape Layers
		if(navigator.appVersion.substring(0,1) > 4) {Browser = 2;} // Netscape DOM
	}
	if(navigator.appName == "Microsoft Internet Explorer") {
//		if(navigator.appVersion.substring(22,23) < 5) {document.location.href = "noscript.htm";}
		if(navigator.appVersion.substring(22,23) >= 5) {Browser = 2;} //IE DOM
	}
}
else {
//	document.location.href = "noscript.htm";
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt eine Laka mit dem Namen 'y' an der Imagearray-Indexposition 'x' in der aufrufenden Datei an.*/
function Img(x,y){
	document.images[(x)].src="../../lakas/" + y + ".jpg";
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt ein Pictogramm mit dem Namen 'y' an der Imagearray-Indexposition 'x' in der aufrufenden Datei an.*/
function Img1(x,y){
	document.images[(x)].src="../pictogr/" + y + ".gif";
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt ein Bild mit dem Namen 'obj' an der Imagearray-Indexposition 'nr' in der aufrufenden Datei an.*/
function Img2(nr,obj){
	if (complete==1) {
		window.document.images[(nr)].src = obj.src;
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion arbeitet mit der Funktion Img2() zusammen und resetet die Anzeige bei onMouseout imt Titel der jahresseiten */
function Out(x) {
	if (x==1 && window.document.images[('bilds')].src==die_s.src && window.document.images[('bildi')].src==die_i.src){
		Img2('bilds',die_s1);
		Img2('bildi',die_i1);
	}
	if (x==2 && window.document.images[('bildt')].src==die_t.src && window.document.images[('bildi')].src==die_i.src){
		Img2('bildt',die_t1);
		Img2('bildi',die_i1);
	}
	if (x==3 && window.document.images[('bildt')].src==die_t.src && window.document.images[('bilds')].src==die_s.src){
		Img2('bildt',die_t1);
		Img2('bilds',die_s1);
	}
}

//function Out() {
//	if (window.document.images[('bildt')].src==die_t.src&&window.document.images[('bilds')].src==die_s.src&&window.document.images[('bildi')].src==die_i.src){
//		Img2('bildt',die_t1);
//		Img2('bilds',die_s1);
//		Img2('bildi',die_i1);
//	}
//}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt ein Vorschaubild mit dem Namen 'y' an der Imagearray-Indexposition 'x' in Chronik-Dateien an.*/
function Img3(x,y){
	document.images[(x)].src="../../fotos/" + y + ".gif";
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion oeffnet ein Fenster und zeigt als Inhalt die Datei 'alpen00.htm' bzw. 'alpen01.htm'. Der anzuspringende Anker bei 'alpen01.htm' wird mit der Variable 'code' uebertragen. */
function Alpen(code){
	if (code=="000"){
		alpeninfo = window.open("../html/alpen00.htm","Alpeninfo","width=500,height=465,toolbar=no,scrollbars=yes,left="+SetPos(500,0)+",top="+SetPos(465,1));
		alpeninfo.focus();
	}
	else{
		alpeninfo = window.open("../html/alpen01.htm#" + code,"Alpeninfo","width=500,height=465,toolbar=no,scrollbars=yes,left="+SetPos(500,0)+",top="+SetPos(465,1));
		alpeninfo.focus();
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Gleiche Funktion wie oben, von den Alpenstrassenseiten aus*/
function AlpenAS(code){
	if (code=="000"){
		alpeninfo = window.open("../../html/alpen00.htm","Alpeninfo","width=500,height=465,toolbar=no,scrollbars=yes,left="+SetPos(500,0)+",top="+SetPos(465,1));
		alpeninfo.focus();
	}
	else{
		alpeninfo = window.open("../../html/alpen01.htm#" + code,"Alpeninfo","width=500,height=465,toolbar=no,scrollbars=yes,left="+SetPos(500,0)+",top="+SetPos(465,1));
		alpeninfo.focus();
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion oeffnet ein Fenster und zeigt als Inhalt die Datei 'tips.htm'. Der anzuspringende Anker wird mit der Variable 'code' uebertragen.*/
function Hinweis(code){
	infofenster = window.open("tips.htm#" + code,"Infofenster","width=400,height=300,toolbar=no,scrollbars=yes,resizable=no,left="+SetPos(400,0)+",top="+SetPos(300,1));
	infofenster.focus();
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Gleiche Funktion wie oben, von den Alpenstrassenseiten aus*/
function HinweisAS(code){
	infofenster = window.open("../tips.htm#" + code,"Infofenster","width=400,height=300,toolbar=no,scrollbars=yes,resizable=no,left="+SetPos(400,0)+",top="+SetPos(300,1));
	infofenster.focus();
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion oeffnet ein Fenster und zeigt als Inhalt die Datei 'suchlade.htm'.*/
function Suche(){
	suchfenster = window.open("../suche/suche.htm","Suchmaschine","width=420,height=500,toolbar=no,scrollbars=no,resizable=no");
	suchfenster.focus();
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion aendert zwei Frames gleichzeitig (bei Spruengen von Extratouren und zurueck) */
function ZweiFrames(url1,fr1,url2,fr2){
	parent.frames[fr1].location.href=url1;
//	parent.frames[fr1].location.replace(url1);
	parent.frames[fr2].location.href=url2;
//	parent.frames[fr2].location.replace(url2);
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion verzögert die Anzeige der Navigationsleisten */
function navin(x){
	var info = "navinfo('" + x + "')";
	delaytime = window.setTimeout(info,1);
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion setzt die Verzögerungszeit der Anzeige der Navigationsleisten zurück */
function navout(){
//	window.clearTimeout(delaytime);
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt den Inhalt der Navigationsleiste */
function navinfo(x){
	infostring = document.relnav.elements[(x)][(document.relnav.elements[(x)].selectedIndex)].value;
	infoarray = infostring.split(",");
	diff = infoarray[0];
	file = document.relnav.elements[(x)][(document.relnav.elements[(x)].selectedIndex)].text;
	ziel = infoarray[1];
//	if (x == "alpha") {document.relnav.DiffAlpha.value = diff;}
	if (x == "num") {document.relnav.DiffNum.value = diff;}
	if (x == "chrono") {document.relnav.DiffChrono.value = diff;}
	if (x == "geo") {document.relnav.DiffGeo.value = diff + "km Luftlinie";}
	if (Browser == 1) {
		document.LinkNS.document.open(); 
		if (ziel) {
			if (x == "chrono") {
				document.LinkNS.document.write("<font size='2' face='arial'><a href='as" + ziel + ".htm' tabindex='6'>" + file + "</a> (Erstbefahrung)</font>");
			}
			else {
				document.LinkNS.document.write("<font size='2' face='arial'><a href='as" + ziel + ".htm' tabindex='6'>" + file + "</a></font>");
			}
		}
		else {
			document.LinkNS.document.write("<font size='2' face='arial'>" + file + "</font>");
		}
		document.LinkNS.document.close(); 
	}
	if (Browser == 2) {
		if (ziel) {
			if (x == "chrono") {
				document.getElementById("LinkIE").innerHTML = "<span class='infotext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='as" + ziel + ".htm' tabindex='6'>" + file + "</a> (Erstbefahrung)</span>";
			}
			else {
				document.getElementById("LinkIE").innerHTML = "<span class='infotext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='as" + ziel + ".htm' tabindex='6'>" + file + "</a></span>";
			}
		}
		else {
			document.getElementById("LinkIE").innerHTML = "<span class='infotext'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + file + "</span>";
		}
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt die Differenzen der Navigationsleiste an */
//function navshow(){
//	document.relnav.alpha.focus();
//	document.relnav.num.focus();
//	document.relnav.chrono.focus();
//	document.relnav.geo.focus();
//	window.focus();
//}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion löscht die Linkanzeige */
//function navdel(){
//	if (Browser == 1) {
//		document.LinkNS.document.open(); 
//		document.LinkNS.document.write("");
//		document.LinkNS.document.close(); 
//	}
//	if (Browser == 2) {
//		document.getElementById("LinkIE").innerHTML = "";
//	}
//}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion setzt die Linkanzeige zurück */
//function navres(w,x,y,z){
//	document.relnav.alpha.selectedIndex = w;
//	document.relnav.num.selectedIndex = x;
//	document.relnav.chrono.selectedIndex = y;
//	document.relnav.geo.selectedIndex = z;
//	navshow();
//	window.setTimeout("navdel()",10);
//}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion leitet eine als Einzelframe aufgerufene Seite auf die zugehoerige Framesetseite um */
function framecheck(x){
	var hrefstring = document.location.href;
	hrefstring = hrefstring.substring(hrefstring.length-10,hrefstring.length);
	if(!parent.Hauptfenster) {
//	if(!parent.Hauptfenster && window.name != "Fenster1") {
		if (hrefstring=="inhalt.htm") {
			location.href = "../start.htm";
		}
		else {
			check = confirm("Die Seite '" + document.location.href + "' gehört zum Projekt 'Die Alpentouren'.\nUm das komplette Projekt zu sehen, bitte auf OK klicken.\n'Abbrechen' zeigt nur die gewählte Seite, ohne weitere Navigationsmöglichkeit.");//
			if (check == true){//
				var up = "";
				if (x == 1){
					up = "../";
				}
				location.href = up + "../start.htm?" + location.pathname;
			}//
		}
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion setzt wenn ein Querystring vorhanden ist, die zugehoerige Seite in den frame */
function framelink() {
	var hrefstring = frames.Hauptfenster.location.href;
	hrefstring = hrefstring.substring(hrefstring.length-11,hrefstring.length);
	if (hrefstring=="jserror.htm"){
		var qstring = location.search;
		if (qstring) {
			qstring = qstring.replace(/:/,"#");
			frames.Hauptfenster.location.replace(qstring.substring(1,qstring.length));
		}
		else {
			frames.Hauptfenster.location.href = "html/titel.htm";
		}
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion druckt eine Seite aus*/
function druck() {
	if (window.print) {self.print();}
	if (document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
		var OLECMDID_PRINT = 6;
		var OLECMDEXECOPT_DONTPROMPTUSER = 2;
		var OLECMDEXECOPT_PROMPTUSER = 1;
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
		WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
		WebBrowser1.outerHTML = '';
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion laedt bei Bedarf zu einer ET-Seite die richtige Inhaltsseite*/
function checkInhalt() {
	var hrefstring = top.frames[0].location.href;
	hrefstring = hrefstring.substring(hrefstring.length-10,hrefstring.length);
	if (hrefstring!="inhaltex.htm"){
		top.frames[0].location.href = "../inhaltex.htm";
	}
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Die Funktion zeigt ein Bild in einem separaten, angepassten Fenster an*/
function ShowPic(n,m,x,y,z){ // Bildname, Fenstertitel, Fensterbreite, Fensterhoehe, Ruecksprungebenen
	var rs;
	m = m.replace(/ /g,"_0");
	m = m.replace(/-/g,"_1");
	m = m.replace(/\./g,"_2");
	m = m.replace(/\u00c4/g,"A2");
	m = m.replace(/\u00e4/g,"a3");
	m = m.replace(/\u00d6/g,"O4");
	m = m.replace(/\u00f6/g,"o5");
	m = m.replace(/\u00dc/g,"U6");
	m = m.replace(/\u00fc/g,"u7");
	m = m.replace(/\u00df/g,"s8");

	for (a=0;a<=z;a++) {rs+="../";}
	f1 = window.open("../"+rs+"html/bild.htm?"+n,m,"width="+x+",height="+y+",left="+SetPos(x,0)+",top="+SetPos(y,1));
	f1.focus();
}

/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Setzt Positionen (x -> Breite/Hoehe, y=0 -> horizontal, y=1 -> vertikal)*/
function SetPos(x,y) {
	var value;
	if (y==0) {value = (screen.availWidth-x)/2;}
	else {value = (screen.availHeight-x)/2;}
	return value;
}
