/*###########################################################################################################
	correctPNG
###########################################################################################################*/

function correctPNG()
{
	// Correctly handle PNG transparency in Win IE 5.5 or higher.
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		var sizMethod = null;
		// sizingMethod for IE
		if (img.className == "stretchBoxHGB") { sizMethod = "scale"; }
		else { sizMethod = "image"; }
		
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID		= (img.id) ? "id='" + img.id + "' " : "";
			var imgName		= (img.name) ? "name='" + img.name + "' " : "";
			var imgClass	= (img.className) ? "class='" + img.className + "' " : "";
			var imgTitle	= (img.title) ? "title='" + img.title + "' " : "";
			var imgOver		= (img.onmouseover) ? "onmouseover='hossa(this);' " : ""
			var imgStyle	= "display:inline-block;" + img.style.cssText;
			
			if (img.align == "left")	imgStyle = "float:left;" + imgStyle;
			if (img.align == "right")	imgStyle = "float:right;" + imgStyle;
			//var imgOver = "onmouseover='hossa(this);'";

			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
			var strNewHTML = "<span " + imgOver + imgID + imgName + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='" + sizMethod + "');" + "\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}

/*###########################################################################################################
	$
###########################################################################################################*/

function $(obj) { return document.getElementById(obj); }

/*###########################################################################################################
	browserCheck
###########################################################################################################*/

function browserCheck()
{
	var agent = navigator.userAgent;
	if (agent.indexOf("MSIE") > -1) {
		var anfang = agent.indexOf("MSIE");
		var ende = agent.lastIndexOf(";");
		var version = parseInt(agent.substring(anfang+5,ende-2));
		return "IE" + version;
	}
	else { return "MO"; }
}

var browser = browserCheck();

/*###########################################################################################################
	showLayer
###########################################################################################################*/

function showLayer(id, status) { document.getElementById(id).style.visibility = status; }

/*###########################################################################################################
	showCallBackContainer
###########################################################################################################*/

function showCallBackContainer()
{
	$("callBackContainer").style.visibility = "visible";
	function startResizeCallBackContainer() { resizeCallBackContainer('callBackContent', 4, 275) }
	window.setTimeout('resizeCallBackContainer("callBackContent", 4, 275)', 300);
}

/*###########################################################################################################
	resizeCallBackContainer
###########################################################################################################*/

function resizeCallBackContainer(id, speed, end_height)
{
	var element = $(id);
	element.style.height = 0;
	var oldDiff_height = 0;
	var startStretch = setInterval(stretch, 40);
	function stretch() {
		var elHeight = parseInt(element.style.height.substr(0, element.style.height.length-2));
		var diff_height = end_height - elHeight;
		var h = diff_height / speed;
		elHeight += h;
		element.style.height = Math.round(elHeight) + "px";
		
		if (oldDiff_height == diff_height) {
			element.style.height = end_height + "px";
			clearInterval(startStretch);
		} else { oldDiff_height = diff_height; }
	}	
}

/*###########################################################################################################
	setOKbutton
###########################################################################################################*/

function setXbutton(bt)
{
	bt.src="/pix/callBack/CallBack_x_hover.gif";
	bt.onmouseover	= function() { this.src="/pix/callBack/CallBack_x_hover.gif"; }
	bt.onmouseout	= function() { this.src="/pix/callBack/CallBack_x_normal.gif"; }
	bt.onmousedown	= function() { this.src="/pix/callBack/CallBack_x_click.gif"; }
	bt.onmouseup	= function() { this.src="/pix/callBack/CallBack_x_normal.gif"; this.parentNode.parentNode.style.visibility="hidden"; $("callBackContent").style.height="0px"; }
}

/*###########################################################################################################
	setOKbutton
###########################################################################################################*/

function setOKbutton(bt)
{
	bt.src="/pix/errorBox/errorBox_bt_hover.gif";
	bt.onmouseover	= function() { this.src="/pix/errorBox/errorBox_bt_hover.gif"; }
	bt.onmouseout	= function() { this.src="/pix/errorBox/errorBox_bt_normal.gif"; }
	bt.onmousedown	= function() { this.src="/pix/errorBox/errorBox_bt_click.gif"; }
	bt.onmouseup	= function() { this.src="/pix/errorBox/errorBox_bt_normal.gif"; this.parentNode.parentNode.parentNode.style.visibility="hidden"; }
}

/*###########################################################################################################
	preloadPic
###########################################################################################################*/

function preloadPic()
{
	if(document.images) {
		if(!document.aPics) document.aPics = new Array();
		var i,j = document.aPics.length, argumente = preloadPic.arguments;
		for(i=0; i<argumente.length; i++) {
			if (argumente[i].indexOf("#")!=0) {
				document.aPics[j] = new Image;
				document.aPics[j++].src = argumente[i];
			}
		}
	}
}

/*###########################################################################################################
	setsubNavi
###########################################################################################################*/

function setsubNavi(target, reference)
{
	// target = Ziel-Element Änderung der Höhe
	// reference = Element welches die Höhe liefert.
	$(target).style.height = $(reference).offsetHeight + "px";
}

/*###########################################################################################################
	setContainerHeight
###########################################################################################################*/

function setContainerHeight()
{
	if(!$("contLeft") || !$("contRight")) { return; }
	var ctL		= $("contLeft");
	var ctR		= $("contRight");
	var ctL_oh	= ctL.offsetHeight;
	var ctR_oh	= ctR.offsetHeight;
	
	if (ctR_oh > ctL_oh) { ctL.style.height = ctR_oh + "px"; }
	else if (ctL_oh > ctR_oh) { ctR.style.height = ctL_oh + "px"; }
}

/*###########################################################################################################
	S T A R T
###########################################################################################################*/

start = function()
{
	if (browser == "IE6") { correctPNG(); }
	setContainerHeight();
}
/*--------------------------*/
	window.onload=start;
/*--------------------------*/