$().ready(function() {
		
	/* Intro */
	if ($('body').hasClass('welcome') == true) {
		
		$("#newsticker").css("display","block");		
		$("#newsticker").newsticker();
		$('#ssh').css("display","none");

		$('#ersatzhead').remove();

		test = ""; 
		function onBefore() { 
//			alert(this.id);	
			//alert($("div#bauwerk"));		
			
			if ($("div#bauwerk").css("display") == "none"
			 && $("div#fliesen").css("display") == "none"
			 && $("div#estrich").css("display") == "none"
			 && $("div#gala").css("display") == "none") {	
				if (test != "") { 			
					$('li.scn' + test).removeClass(test + 'aktiv'); 
				} 
				test = this.id;			
				$('li.scn' + this.id).addClass(this.id + 'aktiv');	
			}
		}
				
			
		$('#headerpic').cycle({ 
			fx: 'fade',
			speed: 'slow',
			timeout:'8000',
			pager: '#contentnavi',
			pagerEvent: 'mouseover', 
    		pauseOnPagerHover: true,
	        before: onBefore
	    });
	} else {
		$('#ssh').css("display","block");
	}
	
	if ($('body').hasClass('produktdetailseite') == true
	 || $('body').hasClass('systemedetailseite') == true) {
		$('#headerpic').css("display","none");
		$('#headerspacer').css("display","block");
	}
	
	/* Navigation */
	
	$("#navigation > ul > li").each(function() {
		$(this).mouseover(function(){					
			$(this).children("div").css("display","block");	
			$(this).addClass("aktiv");
		});
		$(this).mouseout(function(){					
			$(this).children("div").css("display","none");
			$(this).removeClass("aktiv");
		});
	});
	
$("div#sprachauswahl").hover(
  function () {
		$(this).children("div#sprachauswahldd").css("display","block");
		$(this).addClass("saaktiv");
  }, 
  function () {
		$(this).children("div#sprachauswahldd").css("display","none");
		$(this).removeClass("saaktiv");		
		$("ul.switch").css("display","none");
  }
);
	
	/*$("div#sprachauswahl").mouseover(function(){
		$(this).children("div#sprachauswahldd").css("display","block");
		$(this).addClass("saaktiv");	
	});
	
	$("div#sprachauswahl").mouseout(function(){		
		$(this).children("div#sprachauswahldd").css("display","none");
		$(this).removeClass("saaktiv");		
		$("ul.switch").css("display","none");
	});*/
	
	/* Content Navigation */
	
	if ($("body").hasClass("welcome")) {
	
		$("#contentnavi > ul > li").each(function() {
			$(this).mouseover(function(){					
				$(this).children("div.subcontentnavi").css("display","block");	
				if ($(this).attr("class") == "first scnblau") {
					$(this).addClass("blauaktiv");
				}
				else if ($(this).attr("class") == "scnrot") {
					$(this).addClass("rotaktiv");
				}
				else if ($(this).attr("class") == "scngruen") {
					$(this).addClass("gruenaktiv");
				}
				else if ($(this).attr("class") == "scngelb") {
					$(this).addClass("gelbaktiv");
				}
			});
			$(this).mouseout(function(){					
				$(this).children("div.subcontentnavi").css("display","none");
				if ($(this).attr("class") == "first scnblau blauaktiv") {
					$(this).removeClass("blauaktiv");
				}
				else if ($(this).attr("class") == "scnrot rotaktiv") {
					$(this).removeClass("rotaktiv");
				}
				else if ($(this).attr("class") == "scngruen gruenaktiv") {
					$(this).removeClass("gruenaktiv");
				}
				else if ($(this).attr("class") == "scngelb gelbaktiv") {
					$(this).removeClass("gelbaktiv");
				}
			});
		});
	
	} else {
	
		$("#contentnavi > ul > li > a").each(function() {
			$(this).click(function(){			
				removeall();
			
				if ( $(this).parent("li").children("div.subcontentnavi").attr("style") == "display: block;" ) {
					$(this).parent("li").children("div.subcontentnavi").css("display","none");
				}
				else {
					$("#contentnavi > ul > li").children("div.subcontentnavi").css("display","none");
				
					$(this).parent("li").children("div.subcontentnavi").css("display","block");	
				
					if ($(this).parent("li").attr("class") == "first scnblau") {
						$(this).parent("li").addClass("blauaktiv");
					}
					else if ($(this).parent("li").attr("class") == "scnrot") {
						$(this).parent("li").addClass("rotaktiv");
					}
					else if ($(this).parent("li").attr("class") == "scngruen") {
						$(this).parent("li").addClass("gruenaktiv");
					}
					else if ($(this).parent("li").attr("class") == "scngelb") {
						$(this).parent("li").addClass("gelbaktiv");
					}
				}
				return false;
			});
			
			function removeall() {			
				// $("#contentnavi > ul > li").children("div.subcontentnavi").css("display","none");
				$("#contentnavi > ul > li").removeClass("blauaktiv");
				$("#contentnavi > ul > li").removeClass("rotaktiv");
				$("#contentnavi > ul > li").removeClass("gruenaktiv");
				$("#contentnavi > ul > li").removeClass("gelbaktiv");				
			}	
			
			$(this).siblings("div.subcontentnavi").hover(function(){
			  //$(this).addClass("hover");
			},function(){
				removeall();
			 	$(this).parent("li").children("div.subcontentnavi").css("display","none");
			});
			
		});
	
	}

	
	/* Infobox Links*/
	$("div.infobox > h4.iblink").each(function() {
		$(this).css("cursor","pointer");
	
		$(this).toggle(function(){
			$(this).parent("div").children("div.zusatzinfo").css("display","block");
			$(this).addClass("iblinkaktiv");
		},function(){
			$(this).parent("div").children("div.zusatzinfo").css("display","none");
			$(this).removeClass("iblinkaktiv");
		});
	});

	/* Infobox Links*/
	$("div.infobox > div#zi-downloads > div.datenblaetter > a").each(function() {
		$(this).css("cursor","pointer");
	
		$(this).toggle(function(){
			$(this).parent("div").children("div.zusatzinfo").css("display","block");
			$(this).addClass("iblinkaktiv");
		},function(){
			$(this).parent("div").children("div.zusatzinfo").css("display","none");
			$(this).removeClass("iblinkaktiv");
		});
		
	});
	

	/* Sprachswitch */
	
	$("#switch-sprache ul").hide();
	
	$("#switch-sprache").click(function(){
		if ($("#switch-sprache ul").is(":visible")) {
			$("#switch-sprache ul").fadeOut("slow");
		}
		else {
			$("#switch-sprache ul").fadeIn("slow");
		}
		
		return false;
	});

	$("#switch-land ul").hide();

	$("#switch-land").click(function(){
		if ($("#switch-land ul").is(":visible")) {
			$("#switch-land ul").fadeOut("slow");
		}
		else {
			$("#switch-land ul").fadeIn("slow");
		}
		
		return false;
	});
	
	$("#switch-sprache ul li").each(function() {
		$(this).click(function(){
			// alert($(this).children("a").attr("class"));
			$("#switch-sprache > li > a").removeClass()
			$("#switch-sprache > li > a").addClass($(this).children("a").attr("class"));
			$("#switch-sprache > li > a").text($(this).children("a").text());			
		});
	});
	
	$("#switch-land ul li").each(function() {
		$(this).click(function(){
			// alert($(this).children("a").attr("class"));
			$("#switch-land > li > a").removeClass()
			$("#switch-land > li > a").addClass($(this).children("a").attr("class"));
			$("#switch-land > li > a").text($(this).children("a").text());			
		});
	});	
	
	/* Contentreiter */
	
	function hideall() {
		$('.cr-innercontent>div').css({ display: "none"});
		$('.cr-unternavi>ul>li').removeClass("aktiv");
		$('.cr-unternavi>ul>li>a').removeClass("aktiv");
		$('.cr-unternavi>ul>li').css({ backgroundColor: ""});
		$('.cr-unternavi>ul>li').css({ backgroundImage: "url(../images/relaunch/thermolut/pfeil-white.gif)"});
	}	
	hideall();	
	
	$('#crun1').css({ display: "block"});	
	$('.crun1').addClass("aktiv");	
	$('.crun1 > a').addClass("aktiv");	
	$('.crun1').css({ backgroundColor: "#dfd3c8"});
	$('.crun1').css({ backgroundImage: "url(../images/relaunch/thermolut/pfeil-brown.gif)"});
	
	$('.cr-unternavi>ul>li').click(function(){		
		hideall();	
		$foo = $(this).attr("class");		
		$('#'+$foo).fadeIn("slow",function(){});		
		$('.'+$foo).addClass("aktiv");
		$('.'+$foo+'>a').addClass("aktiv");
		$('.'+$foo).css({ backgroundColor: "#dfd3c8"});
		$('.'+$foo).css({ backgroundImage: "url(../images/relaunch/thermolut/pfeil-brown.gif)"});
		return false;
	});
	
	$('.cr-unternavi>ul>li').mouseover(function(){
		$foo = $(this).attr("class");
		$('.'+$foo).css({ backgroundColor: "#dfd3c8"});
		$('.'+$foo).css({ backgroundImage: "url(../images/relaunch/thermolut/pfeil-brown.gif)"});
	});
	
	$('.cr-unternavi>ul>li').mouseout(function(){
		$foo = $(this).attr("class");
		$('.'+$foo).css({ backgroundColor: ""});
		$('.'+$foo).css({ backgroundImage: "url(../images/relaunch/thermolut/pfeil-white.gif)"});
	});
	
	/*Routenplanerfunktion*/
	$('#routerechnen').click(function(){
		window.open("http://maps.google.de/maps?saddr="+$('#saddr').attr("value")+"&daddr="+$('#daddr').attr("value"));	
	});
	
	/*L�nderauswahl bei der weltkarte*/
	$('#select_laender').change(function(){
		if ($("#select_laender option[@selected]").attr('value') != 0) {
			document.location.href = $("#select_laender option[@selected]").attr('value');
		} else {
			$(this).selectedIndex = 0;
		}
	});
	
	$('#btn_schnelleinstieg').click(function(){
		if ($("#select_schnelleinstieg option[@selected]").attr('value') != 0) {
			document.location.href = $("#select_schnelleinstieg option[@selected]").attr('value');
		} else {
			$(this).selectedIndex = 0;
		}
	});
	
	$('#suche_btn').click(function(){
		$("form#suchform").submit();
	});
	
	/*H�ndlersuche*/
	$('#haendler_suche').click(function(){	
		document.location.href = "Haendlersuche.html?query="+document.getElementById('haendler_query').value;
	});
	
	$("#subcontentnavi_linie").click(function(){
		if ($(this).parent("li").children("div.subcontentnavi").attr("style") == "display: block;" ) {
			$(this).parent("li").children("div.subcontentnavi").css("display","none");
		}
		else {
			$(this).parent("li").children("div.subcontentnavi").css("display","block");	
		}
	});
});


/*Historie.....noch �berarbeiten*/
var linkactiv="";

function hison(var1, showpic) {
	if (linkactiv != "") {
		document.getElementById("link"+linkactiv).style.fontWeight = 'normal';
		document.getElementById("div"+linkactiv).style.visibility = 'hidden';
		document.getElementById("hispic").src = '../images/bobbles185x120_blau.jpg';
		}

	document.getElementById("link"+var1).style.fontWeight = 'bold';
	document.getElementById("div"+var1).style.visibility = 'visible';
	if (showpic) {
		document.getElementById("hispic").src = '../images/leftpic_historie'+var1+'.jpg';
	} else {
		document.getElementById("hispic").src = '../images/bobbles185x120_blau.jpg';
	}

	linkactiv = var1;
}	

function WeltkarteHover(nmode,srcname) {
   if (nmode == 'over') {
      document.getElementById('Weltkarte').src = '../images/kontinente/' + srcname + '.gif';
   } else {
      document.getElementById('Weltkarte').src = '../images/standorte_weltkarte.gif';
   }
}

function LaenderHover(titel, id, mode, src) {
	document.getElementById('current_land_'+id).innerHTML = titel;
	
	if (mode == 'over') {
	   document.getElementById('land_'+id).src = '../images/kontinente/laender/'+ id +'/'+ src +'.gif';
	} else {
	   document.getElementById('land_'+id).src = '../images/kontinente/'+id+'_einzeln.gif';
	}
}

function showAdresse (land, titel, id) {
	last = document.getElementById('last_land_'+id).innerHTML;
	if (last != "") {
		document.getElementById(last+' '+id).style.display = 'none';
	} 
	document.getElementById('land_name_'+id).innerHTML = '';
	
	if (document.getElementById(land+' '+id)) {
		last = land;		
		document.getElementById(land+' '+id).style.display = "";
		document.getElementById('land_name_'+id).innerHTML = titel;		
		document.getElementById('last_land_'+id).innerHTML = last;
	}
}

function imagepopup (imageurl, width, height, title) {
	w = window.open('', 'big','location=no, menubar=no, status=no, toolbar=no, width='+width+', height='+height);
	w.document.write("<html><head><link rel=\"stylesheet\" href=\"../css/imagepopup.css\" type=\"text/css\"/><script language=\"javascript\" type=\"text/javascript\" src=\"../js/tools.js\"></script><title>"+title+"</title></head><body onload=\"imagepopup_onload();\"><a href=\"javascript:void;\" onclick=\"self.close();\"><img id=\"bild\" src=\""+imageurl+"\"></a><br/><a href=\"javascript:void;\" onclick=\"self.close();\" class=\"popuplink\">[Fenster schlie&szlig;en]</a></body></html>");
	w.document.close();
}

function imagepopup_onload() {
	node = document.getElementById("bild");
	if (node) {
		x=node.width;
		y=node.height;
		window.resizeTo(x+30, y+90);
	}
}

function showAnzeige(id) {
	window.open("anzeige"+id+".html","Anzeige","width=610,height=680,scrollbars=yes,resizable=yes");
}

function showAnmeldung() {
	window.open("http://anmeldeformular.schomburg.de","Anmeldeformular","width=600,height=650,scrollbars=yes,resizable=no");
}

function newsletterwindow(adresse, lang) {
	link = "http://newsletter.schomburg.de/"+lang+"/index.php?lia_page=newsletter&email=" + adresse;
	//link = "http://webdev.louis-net.de/schomburg_newsletter/"+lang+"/index.php?lia_page=newsletter&email=" + adresse;
	window.open(link,"newsletter","width=450,height=350,scrollbars=no");
}


function showFarbe(bild) {
	document.getElementById("farbbild").src = bild;
	document.getElementById("farbbild").style.border = "2px solid #dddddd";
}