
function showElement(layer){
	var myLayer = document.getElementById(layer);
	if(myLayer.style.display=="block"){
		myLayer.style.display="none";
	} else {
		myLayer.style.display="block";
		myLayer.backgroundPosition="top";
	}
}
	
var ourInterval;
var scrollSpeed = 50;
var scrollHeight = 5;
	
function scrollUp(which){
	// SET THE SCROLL TOP
	document.getElementById(which).scrollTop = document.getElementById(which).scrollTop - scrollHeight;
}

function scrollDown(which){
	// SET THE SCROLL TOP
	document.getElementById(which).scrollTop = document.getElementById(which).scrollTop + scrollHeight;
}
	
function scrollStart(direction, divID, elementID){
	// REPEATED CALL EITHER scrollUp OR scrollDown
	ourInterval = setInterval("scroll"+direction+"('"+divID+"')", scrollSpeed);
}

function scrollEnd(which){
	// STOP CALLING THE SCROLL FUNCTION
	clearInterval(ourInterval);
}

//Funktion auf http://jbscdev.blogspot.com/2007/08/automatic-iframe-height-sizing-using.html
function sizeIFrame() {
	//if($("iframe:not(iframe[class*=ad])").length != 0){
	//	var theFrame = $("iframe:not(iframe[class*=ad])");
	//	var innerDoc = (theFrame.get(0).contentDocument) ? theFrame.get(0).contentDocument : theFrame.get(0).contentWindow.document;
	//	theFrame.height(innerDoc.body.scrollHeight + 35);
	//}
}


$(document).ready(function(){
	
	//JAVASCRIPT-LAYOUT-HACKS
	//Klassen mit Browser-Versionen an das body-Element anh�ngen:
	jQuery.each(jQuery.browser, function(i, val) {
	  if (val && i!="version") $("body").addClass("browser-"+i).addClass("browser-"+i+"-"+parseInt(($.browser.version.substr(0,3)=="1.9")?"3":$.browser.version));
    });
	
	//IE-Pseudo-Klassen mit Klassen simulieren
	$("body.browser-msie").find("li:first-child").addClass("first-child");
	$("body.browser-msie").find("li:last-child").addClass("last-child");
	
	$("body.browser-msie").find("form > table tr td:first-child").addClass("first-child");
	
	

	
	//Formularfelder mit Autoclear:
	jQuery.fn.extend({ 
		autoclear: function() { 
			return this.each(function(){
				if($(this).val()==""&&$(this).attr("title")!=""){
					$(this).val($(this).attr("title"));
					$(this).focus(function(){
						$(this).addClass("focus");
						if($(this).val()==this.title) $(this).val("");
					});
					$(this).blur(function(){
						$(this).removeClass("focus");
						$(this).autoclear();
					});
				}
			}); 
		} 
	});
	$(".autoclear").autoclear();
	$(".autoclear").parents("form").submit(function(){
		$(this).find(".autoclear").each(function(){
			if($(this).val()==$(this).attr("title")) {
				$(this).val("");
			}
		});
		return true;
	});

	$(".jcarousel-skin-custom a.moreInfo").hover(
		function(e){
			var theHTML = $(this).next("div").html();
			if(theHTML != "") {
				$("#moreInfoPlaceholder").html(theHTML);
				$("#moreInfoPlaceholder").css("display","block");
				$("#moreInfoPlaceholder").bind("click",{theLink : $(this)},function(){
					location = theLink.attr('href');
				});
				$("#moreInfoPlaceholder").css("left",e.pageX -30);
				$("#moreInfoPlaceholder").css("top",$(this).offset().top +170);
			}
		},
		function(){
			$("#moreInfoPlaceholder").unbind("click");
			$("#moreInfoPlaceholder").css("display","none");
			$("#moreInfoPlaceholder").html("");
		}
	);
	
	
	//LISTENER
	//Funktion beim Hovern �ber den News-Block auf der Startseite
	$(".newsblock-teaser").hover(
		function(){
			//<img id="fortschrittsbalken" src="images/fortschrittsbalken.gif" width="40" height="12" alt="Inhalt wird geladen" />
			var currID = "#" + $(".topnews").attr("id");
			var theLoadingID = "#topnews_"  + $(this).attr("id")
			if(theLoadingID != currID){
				var newsToLoad = "ajax/topnews.html " + theLoadingID;
				$('#newsplaceholder').load(newsToLoad,function(){
					$(theLoadingID).fadeIn();
				});
			}
		},
		function(){}
	);
	//$("#newslist > div:first-child").mouseenter();
	
	//Funktion beim Anklicken eines Listenelementes der Suchergebnisliste
	$(".jQueryClickable li").click(function(){
		//
		location = $(this).find('a').attr('href');
	});
	
});
