/* TechDesign WEBSITE JAVASCRIPT FUNCTIONS */
/* (c) 2006 ph.schellworth www.schellworth.de */



/* MENU + SUBMENU FUNCTIONS */
/* fill in each number of sub links for every sub menu */

var sl = new Array(6);
sl[0] = 0;					/* home page (always 0 sub links) */
sl[1] = 3;					/* Wir über uns */
sl[2] = 5;					/* Projekte */
sl[3] = 0;					/* Unsere Kunden */
sl[4] = 2;					/* Kontakt */

function initState() {
	var url = window.location.href;
	expression = /.*\/..(_e)\.html/;  /* (_e/) (uri[1]) */
	var uri = url.match(expression); /* datei name vom rest extrahieren */
	
	for (var sn = 1; sn <= 4; sn++) {  /* sn= start of menue = 1; sn <= X (last menue */
		if (uri && uri[1] == '_e') {
			parent.document.getElementById("am"+sn).src="bilder/"+sn+"e_p.png";					/* reset menue img */
		} else {
			parent.document.getElementById("am"+sn).src="bilder/"+sn+"_p.png";					/* reset menue img */
		}
		parent.document.getElementById("subnav"+sn+"").style.visibility="hidden";			/* hide all subnavs */
		k = sl[sn];
		for (var j = 1; j <= k; j++) {
			parent.document.getElementById("au"+sn+j).style.color="black";					/* reset submenue color */
		}
	}
}
function showLayers(layer1, layer2) { 
	initState();
	var url = window.location.href;
	expression = /.*\/..(_e)\.html/;  /* (_e/) (uri[1]) */
	var uri = url.match(expression); /* datei name vom rest extrahieren */
	if (layer1 != 0) {
		if (uri && uri[1] == '_e') {
			parent.document.getElementById("am"+layer1).src="bilder/"+layer1+"e_a.png";			/* show aktiv menue img */
		} else {
			parent.document.getElementById("am"+layer1).src="bilder/"+layer1+"_a.png";			/* show aktiv menue img */
		}
		parent.document.getElementById("subnav"+layer1).style.visibility="visible";			/* show subnav */
	}
	if (layer2 != 0) {
		parent.document.getElementById("au"+layer1+layer2).style.color="#73D0E9";			/* highlight link */
	}
}


/* Flash tauschen */
var wir ='<object data="c.swf?path=bilder/highlight_wir.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_wir.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_wir.png" width="720" height="175" alt="" /></object>';
var projekte ='<object data="c.swf?path=bilder/highlight_projekte.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte.png" width="720" height="175" alt="" /></object>';
var kunden ='<object data="c.swf?path=bilder/highlight_kunden.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_kunden.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_kunden.png" width="720" height="175" alt="" /></object>';
var kontakt ='<object data="c.swf?path=bilder/highlight_kontakt.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_kontakt.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_kontakt.png" width="720" height="175" alt="" /></object>';
var start ='<object data="c.swf?path=bilder/highlight_start.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_start.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_start.png" width="720" height="175" alt="" /></object>';
var projekteA ='<object data="c.swf?path=bilder/highlight_projekte_21.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte_21.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte_21.png" width="720" height="175" alt="" /></object>';
var projekteB ='<object data="c.swf?path=bilder/highlight_projekte_22.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte_22.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte_22.png" width="720" height="175" alt="" /></object>';
var projekteC ='<object data="c.swf?path=bilder/highlight_projekte_23.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte_23.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte_23.png" width="720" height="175" alt="" /></object>';
var projekteD ='<object data="c.swf?path=bilder/highlight_projekte_24.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte_24.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte_24.png" width="720" height="175" alt="" /></object>';
var projekteE ='<object data="c.swf?path=bilder/highlight_projekte_25.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_projekte_25.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_projekte_25.png" width="720" height="175" alt="" /></object>';
var buero ='<object data="c.swf?path=bilder/highlight_buero.swf" type="application/x-shockwave-flash" width="720" height="175"><param name="movie" value="c.swf?path=bilder/highlight_buero.swf" /><param name="swLiveConnect" value="true" /><param name="bgcolor" value="#F5FCFD" /><img src="bilder/highlight_buero.png" width="720" height="175" alt="" /></object>';
function flashSwap(theValue) {
	if (theValue == 1) {
		parent.document.getElementById("highlights").innerHTML = wir;
	} else if  (theValue == 2) {
		parent.document.getElementById("highlights").innerHTML = projekte;
	} else if (theValue == 3) {
		parent.document.getElementById("highlights").innerHTML = kunden;
	} else if (theValue == 4) {
		parent.document.getElementById("highlights").innerHTML = kontakt;
	} else if (theValue == 5) {
		parent.document.getElementById("highlights").innerHTML = start;
	} else if (theValue == 21) {
		parent.document.getElementById("highlights").innerHTML = projekteA;
	} else if (theValue == 22) {
		parent.document.getElementById("highlights").innerHTML = projekteB;
	} else if (theValue == 23) {
		parent.document.getElementById("highlights").innerHTML = projekteC;
	} else if (theValue == 24) {
		parent.document.getElementById("highlights").innerHTML = projekteD;
	} else if (theValue == 25) {
		parent.document.getElementById("highlights").innerHTML = projekteE;
	} else if (theValue == 13) {
		parent.document.getElementById("highlights").innerHTML = buero;
	}
}

/* FRAME FIX /*
/* GET WINDOW (BODY) HEIGHT */
function getWindowHeight() {
	var windowHeight=0;
	if (self.innerHeight != null) {
		windowHeight=parent.self.innerHeight; // all except Explorer
	} else if (parent.document.documentElement && parent.document.documentElement.clientHeight) {
		windowHeight=parent.document.documentElement.clientHeight; // Explorer 6 Strict Mode
	} else if (parent.document.body && parent.document.body.clientHeight) {
		windowHeight=parent.document.body.clientHeight; // other Explorer
	}
	return windowHeight;	
}

/* RESIZE CONTENT TO BODY HEIGHT & WIDTH */
function contentH() {
	var windowHeight=getWindowHeight();
	parent.document.getElementById("iframe").style.height=(windowHeight-355)+"px";
	parent.document.getElementById("content").style.height=(windowHeight-355)+"px";
}


/* Wenn der Contetn direkt Aufgerufen wird, Navigation nachladen */
function forward(template) { 
	if ( window == window.top ) {
		window.location = template+"?src=" + window.location;
	}
	checkState();
}

/* If Site Forwared, Highlight Menue */
function checkState() {
	//url=getQueryVariable('src');
	var url=parent.iframe.location.href;
	expression = /.*\/((.)(.)).*\.html/;  /* (http://www.xxxx.de/) (uri[1]) */
	var uri = url.match(expression); /* datei name vom rest extrahieren */
	if (uri != null) {
		showLayers(uri[2],uri[3]); 
		if (uri[3] >= 1) {
			flashSwap(uri[2]+uri[3]);
		} else {
			flashSwap(uri[2]);
		}
	} else {
		showLayers(0,0); 
		flashSwap('0');
	}
}

/* Get Qeuery Variable */
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  /* alert('Query Variable ' + variable + ' not found'); */
}


// Switch to an other language
function switchLang(lang) {
	url=parent.iframe.location.href;
	if (typeof(url) != "undefined") { 
		expression = /.*\/((.)(.)).*\.html/;  /* (http://www.xxxx.de/) (uri[1]) */
		var uri = url.match(expression); /* datei name vom rest extrahieren */
		if (lang == 'e' && uri != null) {
			top.location.href = uri[2]+uri[3]+"_e.html";
		} else if (lang == 'd') {
			top.location.href = uri[2]+uri[3]+".html";
		}
	} else {
		if (lang == 'e') {
			top.location.href = "index_e.php";
		} else if (lang == 'd') {
			top.location.href = "index.php";
		}
	}
	
}
