
document.addEvent('domready', function() {
	$$('.boxToggler').each( function(el){
		new boxToggler(el, 'h3');
	})
})

function boxToggler(container, openers){
	$(container).getElements(openers).each( function(el){
		el.addEvent('click', function(){
			closeAllShow(el);
		})
		el.getNext().style.display = 'none';
	})
	function closeAllShow(showEl){
		$(container).getElements(openers).each( function(el){
			if(el === showEl && el.getNext().style.display == 'none' ){
				el.getNext().style.display = 'block';
				el.addClass('active');
			} else {
				el.getNext().style.display = 'none';
				el.removeClass('active');
			}
		})
	}
}






var browser = new Browser();

/*##################################################################
	displaySubNavigation
##################################################################*/

function displaySubNavigation(li)
{
	var i = 0;
	while(subN = li.childNodes[i])
	{
		if(subN.tagName == "A") {
			if(subN.href == window.location || subN.href == window.location+"#") {
				subN.onclick = function() { return false; }
			}
		}
		if(subN.tagName == "UL") {
			li.onmouseout = function() { subN.style.display="none"; }
			subN.style.display="block";
			break;
		}
		i++;
	}
}

/*##################################################################
	displayRollover
##################################################################*/

function displayRollover(li)
{
	var i = 0;
	while(rollO = li.childNodes[i])
	{
		if(rollO.tagName == "A") {
			if(rollO.href == window.location || rollO.href == window.location+"#") {
				rollO.onclick = function() { return false; }
			}
		}
		if(rollO.tagName == "UL") {
			li.onmouseout = function() { rollO.style.display="none"; }
			rollO.style.display="block";
			break;
		}
		i++;
	}
}


/*##################################################################
	setHeight
##################################################################*/

function setHeight()
{
	var l = $("links");
	var m = $("mitte");
	var r = $("rechts");
	
	if(r.offsetHeight > l.offsetHeight) {
		l.style.height = r.offsetHeight + "px";
		m && (m.style.height = r.offsetHeight + "px");
	}
}

/*##################################################################
	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;
			
			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
		}
	}
}

/*##################################################################
	showBlase
##################################################################*/

var blaseActive = null;
function showBlase(bt,id)
{
	if(blaseActive) blaseActive.style.visibility="hidden";
	blaseActive = $(id);
	var clName = blaseActive.className.toString();
	
	if(clName.indexOf("blLeft") > -1) {
		blaseActive.style.left = (bt.offsetLeft-145) + "px";
	} else { blaseActive.style.left = bt.offsetLeft + "px"; }
	
	blaseActive.style.top = bt.offsetTop + "px";
	blaseActive.style.visibility = "visible";
}

/*##################################################################
	start
##################################################################*/

function start()
{
	if(browser.type == "IE" && browser.version < "7") { correctPNG(); }
	if($("rechts")) { setHeight(); }
}
window.onload = start;
