function wrahmen(){
	var hoehe = document.documentElement.clientHeight;
	var breite = document.documentElement.clientWidth;

	if(hoehe < 778){
		document.getElementById("rahmen_fuer_alles").style.border = "none";
		document.getElementById("rahmen_fuer_alles").style.marginTop = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingTop = "0px";
	}

	if(breite < 1024){
		document.getElementById("rahmen_fuer_alles").style.border = "none";
		document.getElementById("rahmen_fuer_alles").style.marginLeft = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingLeft = "0px";
		document.getElementById("rahmen_fuer_alles").style.marginRight = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingRight = "0px";
	}

	if(breite < 1024 && hoehe < 778){
		document.getElementById("rahmen_fuer_alles").style.border = "none";
		document.getElementById("rahmen_fuer_alles").style.marginTop = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingTop = "0px";
		document.getElementById("rahmen_fuer_alles").style.marginLeft = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingLeft = "0px";
		document.getElementById("rahmen_fuer_alles").style.marginRight = "0px";
		document.getElementById("rahmen_fuer_alles").style.paddingRight = "0px";
	}

}

window.addEvent('domready', function() {

	var emo = $('emotion');
	var source = $('emotionSource');
	if(emo){
		if(source){
			if(source.value != ""){
				emo.src = "kompotherm_images_inhalte/emotionsbilder/"+source.value;
			}
		}
	}

	var b1 = $('home_left');
	var b1t = $('button1_txt');
	if (b1) {
		var b1FX = new Fx.Style(b1t,'opacity', {duration: 500,wait:true});
		b1.addEvent('mouseover', function(){
			b1FX.stop();
			b1t.style.backgroundColor = "white";
			b1t.style.color = "#09305B";
			b1FX.start(0.5);
		});
		b1.addEvent('mouseout', function(){
			b1FX.stop();
			b1t.style.backgroundColor = "transparent";
			b1t.style.color = "white";
			b1FX.start(1);
		});
	}

	var b2 = $('button2');
	var b2t = $('button2_txt');
	if (b2) {
		var b2FX = new Fx.Style(b2t,'opacity', {duration: 500,wait:true});
		b2.addEvent('mouseover', function(){
			b2FX.stop();
			b2t.style.backgroundColor = "white";
			b2t.style.color = "#09305B";
			b2FX.start(0.5);
		});
		b2.addEvent('mouseout', function(){
			b2FX.stop();
			b2t.style.backgroundColor = "transparent";
			b2t.style.color = "white";
			b2FX.start(1);
		});
	}

	var b3 = $('button3');
	var b3t = $('button3_txt');
	if (b3) {
		var b3FX = new Fx.Style(b3t,'opacity', {duration: 500,wait:true});
		b3.addEvent('mouseover', function(){
			b3FX.stop();
			b3t.style.backgroundColor = "white";
			b3t.style.color = "#09305B";
			b3FX.start(0.5);
		});
		b3.addEvent('mouseout', function(){
			b3FX.stop();
			b3t.style.backgroundColor = "transparent";
			b3t.style.color = "white";
			b3FX.start(1);
		});
	}

	var b4 = $('button4');
	var b4t = $('button4_txt');
	if (b4) {
		var b4FX = new Fx.Style(b4t,'opacity', {duration: 500,wait:true});
		b4.addEvent('mouseover', function(){
			b4FX.stop();
			b4t.style.backgroundColor = "white";
			b4t.style.color = "#09305B";
			b4FX.start(0.5);
		});
		b4.addEvent('mouseout', function(){
			b4FX.stop();
			b4t.style.backgroundColor = "transparent";
			b4t.style.color = "white";
			b4FX.start(1);
		});
	}

	var laenge;
	var tmp2 = null;
	$$('a.link_menu_kLeft_sub1').each( function( elem ){
			
		elem.addEvents({
			'mouseenter': function(elem) {
				if(this.parentNode.id != tmp2 || tmp2 == null){
					this.parentNode.style.height = "auto";
					if(tmp2 != null){
						$(tmp2).style.height = "18px";
					}
				}
			},
			'mouseleave': function(elem) {
				tmp2 = this.parentNode.id;
			}
		});

	});

	if($("active")){
		if($("active").parentNode.parentNode.parentNode && $("active").parentNode.parentNode.parentNode.className != "lvl"){
			$("active").parentNode.parentNode.parentNode.getElements("a")[0].style.backgroundColor = "#6E85A9";
		}
		$("active").parentNode.parentNode.parentNode.style.height = "auto";
		if($("active").parentNode.parentNode){
			$("active").parentNode.parentNode.style.height = "100%";
			$("active").parentNode.parentNode.style.display = "block";
		}
		if($("active").parentNode.className == "lvl_sub1"){
			$("active").parentNode.style.height = "auto";
		}
	}

});

function bild_wechsel_vors(filename,bildname,menge,milieu,tData,thW,link){	
	document.getElementById("gross_freituer").src = "kompotherm_images/"+filename;
	document.getElementById("bild_gross_image").src = "kompotherm_images/"+milieu;
	document.getElementById("tdTitle").innerHTML = bildname;
	document.getElementById("tdTxt").innerHTML = tData;
	if(document.getElementById("stLink")){
		document.getElementById("stLink").href = link;
	}
}

function bild_wechsel_2(filename,bildname,menge,freibild,glasbild,thW,thH){
	document.getElementById("bild_gross_image").src = "kompotherm_images/"+filename;
	if(document.getElementById("gross_freituer")){
		document.getElementById("gross_freituer").src = "kompotherm_images/"+freibild;
		if(glasbild != "" && freibild != ""){
			document.getElementById("in_glDetail").src = "kompotherm_images/"+glasbild;
			document.getElementById("in_detail").style.display = "block";
		}else{
			document.getElementById("in_detail").style.display = "none";
		}
	}
	if(bildname != "" && document.getElementById("tdTitle")){
		document.getElementById("tdTitle").innerHTML = bildname;
	}
	if(document.getElementById("tdaten_"+menge).value != ""){
		document.getElementById("tdTxt").innerHTML = document.getElementById("tdaten_"+menge).value;
	}
	
	document.getElementById("zoomLink").href = "kompotherm_images/"+filename;
	document.getElementById("zoomLink").title = bildname;
	Shadowbox.clearCache();
	Shadowbox.setup();
	Shadowbox.init(); 
}

function hand_wechsel(filename,bildname,milieu,menge,br,ho){
	document.getElementById("kommentartitel").innerHTML = bildname;
	document.getElementById("comment").innerHTML = document.getElementById("tdaten_"+menge).value;
	document.getElementById('img_hand_big').style.marginTop = "0px";
	
	if(milieu != ""){
		document.getElementById('img_hand_big').src = 'kompotherm_images/'+milieu;
		document.getElementById('imgHandDetail').src = 'kompotherm_images/'+filename;
	}else{
		document.getElementById('img_hand_big').src = 'kompotherm_images/'+filename;
		if(document.getElementById('imgHandDetail')){
			document.getElementById('imgHandDetail').style.display = 'none';
		}
		var ratio_orig = br/ho;
		var w = 245;
		var h = 436;
		if (w/h > ratio_orig) {
		   w = parseInt( (h*ratio_orig),10);
		} else {
		   h = parseInt( (w/ratio_orig),10);
		}
		document.getElementById('img_hand_big').width = w;
		document.getElementById('img_hand_big').height = h;
	}
}

function gross(){

	if(document.getElementById('bild_gross_image').style.height == '434px'){

		document.getElementById('zoombutton').style.top = '309px';
		document.getElementById('zoomi').value = '+ zoom';
		document.getElementById('bild_gross_image').style.height = '331px';			
		document.getElementById('bild_gross_image').height = '331';
		document.getElementById('bild_gross').style.width = '530px';
		document.getElementById('bild_gross').style.height = '335px';
		document.getElementById('links').style.width = '530px';

		var browser = navigator.userAgent.toLowerCase();
		var ie6 = browser.search(/msie 6.0.+/)
		var ie7 = browser.search(/msie 7.0.+/)
		if(ie7 != -1){
			document.getElementById('rechts').style.display = "inline";
			document.getElementById('rechts').style.zoom = "1";
			document.getElementById('freitueren').style.display = "inline";
			document.getElementById('freitueren').style.zoom = "1";
		}else if(ie6 != -1){
			document.getElementById('rechts').style.display = "inline";
			document.getElementById('rechts').style.zoom = "1";
			document.getElementById('freitueren').style.display = "inline";
			document.getElementById('freitueren').style.zoom = "1";
		}else{
			document.getElementById('rechts').style.display = "inline-block";
			document.getElementById('freitueren').style.display = "inline-block";
		}

	} else {

		document.getElementById('links').style.width = '694px';
		document.getElementById('bild_gross').style.width = '694px';
		document.getElementById('bild_gross').style.height = '438px';
		document.getElementById('bild_gross_image').style.height = '434px';
		document.getElementById('bild_gross_image').height = '434';
		document.getElementById('zoombutton').style.top = '412px';
		document.getElementById('zoomi').value = '- zoom';
		document.getElementById('rechts').style.display = "none";
		document.getElementById('freitueren').style.display = "none";

	}
}

function bild_wechsel_freituer(tdaten,name,filename,breite,lang){

	Shadowbox.init({
    // skip the automatic setup again, we do this later manually
    skipSetup: true
	});
	var bbrr = new Number(breite);
	var nBreite = (bbrr+240);
	var details = "Details";
	if(lang == "French (Fr)"){
		details = "Détails"; 
	}

	Shadowbox.open({
        content:    '<div id="bild_freituer_div"><div id="frei_bild" style="width: '+bbrr+'px;"><img id="bild_freituer_image" height="450" src="kompotherm_images/'+filename+'" onload="Javascript: prefrzoom();" style="display: none;"/><div id="bild_freituer_image_pre" style="display: inline; height: 50px; width: 50px; position: relative; margin-left: auto; margin-right: auto; margin-top: 100px; padding-top: 50px; font-family: Arial; font-size: 18px; color: white; text-decoration: blink;">Lade...</div></div><div class="frei_txt"><div class="frei_title">'+name+'</div><br>'+tdaten+'</div></div>',
        player:     "html",
        title:      "&nbsp;&nbsp;"+details+" - "+name+'<a class="printbut" href="Javascript: printSelection(document.getElementById(\'bild_freituer_div\'));"><img src="kompotherm_images_icons/printbutton.png" titel="Print" alt="Print" width="24" align="left" border="0" /></a>',
        width:      nBreite,
		height:		475
    });

}

function tuervideo(link,titel){
	Shadowbox.init({
	    skipSetup: true
	});
	Shadowbox.open({
        content:    link,
        player:     "flv",
        title:      titel,
        width:      700,
		height:		394
    });
}

var xx = 0;
function scroll_links(menge) {
	if (xx < 0 ) {
		xx = xx + 113;
		document.getElementById("scrollleiste_innen").style.left= xx+"px";
	}
}
function scroll_rechts(menge) {
	if(document.getElementById("scrollleiste_innen").style.left.replace('px','') >= (-113*(menge)+530)  ){  
		xx = xx - 113;
	}
	document.getElementById("scrollleiste_innen").style.left= xx+"px";
}

var vv = 0;
function scr_lv(laenge) {
	if (vv < 0 ) {
		vv = vv + 100;
	}
	document.getElementById("scrollleiste_innenVor").style.left = vv+"px";
}
function scr_rv(laenge) {
	//alert(laenge);
	if( document.getElementById("scrollleiste_innenVor").offsetLeft >= (-1*laenge) ){  
		vv = vv - 100;
	}else{
		vv = vv;
	}
	document.getElementById("scrollleiste_innenVor").style.left= vv+"px";
}

function glaskatalog(){
	$("FlippingPages").style.display = "block";
}

function printSelection(node){
        var content=node.innerHTML;
        var pwin=window.open('','print_content','width=600,height=700');
        var writeMe = '<html><body onload="window.print()"><img src="http://www.kompotherm.de/kompothermAktuell/kompotherm_images_inhalte/logos/kompologo.png" alt="KOMPOtherm" titel="KOMPOtherm" border="0" /><br/><br/>'+content+'';
       
        pwin.document.open();
        pwin.document.write(writeMe);
        pwin.document.close();
       
        setTimeout(function(){pwin.close();},1000);
}
