
//====================================================================================================================================
//	D E B U G
//====================================================================================================================================



var debugModus = 1; // Debugmodus für Firebug
function debug(txt)
{
	if(!debugModus || typeof(console) != "object") { return; }
	console.log(txt);
}
debug("debugModus = true");

/*#######################################################################
	swapPNG
#######################################################################*/

function swapPNG(img,hoverPath)
{
	var defaultPath	= (window.ie6)?img.filters["DXImageTransform.Microsoft.AlphaImageLoader"].src:img.src;
	if(window.ie6) { img.filters["DXImageTransform.Microsoft.AlphaImageLoader"].sizingMethod = "crop"; }
	
	img.onmouseout = function() {
		this.src = defaultPath;
		if(window.IE6) document.recalc();
	}
	img.onmouseover = function() {
		this.src = hoverPath;
		if(window.IE6) document.recalc();
	}
	img.onmouseover();
}

/*#######################################################################
	changePNG
#######################################################################*/

function changePNG(img,hoverPath)
{
	img.src = hoverPath;
	if(window.IE6) document.recalc();
}

/*#######################################################################
	preloadImages
#######################################################################*/

function preloadImages()
{
	document.preload = new Array();
	if(document.images)
	{
		var path = preloadImages.arguments[0];
		for(var i = 1; i < preloadImages.arguments.length; i++) {
			document.preload[i] = new Image();
			document.preload[i].src = path+preloadImages.arguments[i];
		}
	}
}

//---------------------------------------------------------------------
//	initImagePreloader
//---------------------------------------------------------------------

//function initImagePreloader()
//{
//	preloadImages('/pix/navigation/',
//					'show-0-trans.png',
//					'show-1-trans.png',
//					'mitwirkende-0-trans.png',
//					'mitwirkende-1-trans.png',
//					'partner-0-trans.png',
//					'partner-1-trans.png',
//					'tickets-0-trans.png',
//					'tickets-1-trans.png',
//					'theater-0-trans.png',
//					'theater-1-trans.png',
//					'presse-0-trans.png',
//					'presse-1-trans.png',
//					'newsletter-0-trans.png',
//					'newsletter-1-trans.png',
//					'kontakt-0-trans.png',
//					'kontakt-1-trans.png');
//}
//window.addEvent('domready', initImagePreloader);

/*#######################################################################
	initNaviElement
#######################################################################*/

function setHoverImage(img,hoverPath)
{
	img.defaultSRC = (window.ie6)?img.filters["DXImageTransform.Microsoft.AlphaImageLoader"].src:img.src;
	img.hoverSRC = hoverPath;
}

function initNaviElement(bt,imageName)
{
	setHoverImage(bt,"/pix/navigation/"+imageName)
	
	// Sucht nach Subnavigation
	var aTag = bt.parentNode;
	var subNav = aTag.nextSibling;
	while(subNav) {
		if(subNav.className == "subNaviNode") { break; }
		else {
			if(subNav.className == "naviNode" || !subNav) { subNav = null; break; }
			else { subNav = subNav.nextSibling; }
		}
	}
	if(subNav) {
		bt.subNaviElement = subNav;
		bt.subNaviElement.style.left = aTag.offsetLeft+"px";
	}
	
	// Setzt Handler
	bt.onmouseout = function() {
		this.src = this.defaultSRC;
		if(window.IE6) document.recalc();
		if(this.subNaviElement && !section) {
			this.style.paddingBottom = "0px";
			this.subNaviElement.style.display="none";
			var hgb = this.subNaviElement.hgb;
			hgb.style.display = "none";
		}
	}
	bt.onmouseover = function() {
		this.src = this.hoverSRC;
		if(window.IE6) document.recalc();
		
		// Falls Subnavigation vorhanden
		if(this.subNaviElement && !section) {
			if(window.ie6) { this.filters["DXImageTransform.Microsoft.AlphaImageLoader"].sizingMethod = "crop"; }
			this.style.paddingBottom = "20px";
			var sn				= this.subNaviElement;
			sn.onmouseover		= function() { this.style.display="block"; this.hgb.style.display ="block"; }
			sn.onmouseout		= function() { this.style.display="none"; this.hgb.style.display ="none"; }
			sn.style.display	="block";
			
			//--> Initialisierung der Hinergrund "DIV" --> createSubnaviHGB()
			
			var hgb				= sn.hgb;
			hgb.style.top		= sn.offsetTop + "px";
			hgb.style.left		= sn.offsetLeft + "px";
			hgb.style.width		= sn.offsetWidth + "px";
			hgb.style.height	= sn.offsetHeight + "px";
			hgb.style.display	="block";
			
		}
	}
	bt.onmouseover();
}

/*#######################################################################
	createSubnaviHGB
#######################################################################*/

// Erstellt transparenten Hintergrund-DIV für Subnavigation

var transparenz = 0.8;

function createSubnaviHGB()
{
	if($$(".subNaviNodeActive") || $$(".subNaviNode")) {
		var uI		= $$(".subNaviNode");
		var uA		= $$(".subNaviNodeActive");
		var subNav	= new Array();
		for(u=0;u<uI.length;u++) { subNav.push(uI[u]); }
		for(a=0;a<uA.length;a++) { subNav.push(uA[a]); }
		
		subNav.each(function(naviList, id) {
			var hgb						= document.createElement("div");
			hgb.id						= "navHGB" + id;
			hgb.style.backgroundColor	= "#002141";
			hgb.style.position			= "absolute";
			
			// Ist Subnavi aktiv wird DIV angezeigt...
			//hgb.style.display			= (naviList.className == "subNaviNodeActive")?"block":"none";
			hgb.style.display			= "none";
			
			hgb.style.zIndex			= "4999";
			hgb.style.top				= naviList.offsetTop + "px";
			hgb.style.left				= naviList.offsetLeft + "px";
			hgb.style.width				= naviList.offsetWidth + "px";
			hgb.style.height			= naviList.offsetHeight + "px";
			
			$("navigation").appendChild(hgb);
			$("navHGB"+id).setOpacity(0.5);
			naviList.hgb = hgb;
		});
	}
}
//window.addEvent('load',createSubnaviHGB);

/*#######################################################################
	startScroll
#######################################################################*/

var scrollButton = null;

function initScroller(bt,container,scrlPos)
{
	bt.scrollSpeed = 22;
	
	bt.scrollPos		= scrlPos; // 1 || 0
	bt.scrollCont		= document.getElementById(container);
	bt.scrollInterval	= null;
	
	bt.scrollStart = function() {
		if(scrollButton.scrollPos) { scrollButton.scrollCont.scrollTop += scrollButton.scrollSpeed; }
		else { scrollButton.scrollCont.scrollTop -= scrollButton.scrollSpeed; }
	}
	
	bt.scrollStop		= function() { clearInterval(this.scrollInterval); }
	bt.onmouseup		= function() { this.scrollStop(); }
	bt.onmouseout		= function() { this.scrollStop(); }
	bt.onmousedown		= function() { scrollButton = this; this.scrollInterval = setInterval(this.scrollStart,80); }
	bt.onmouseover		= function() {}
	bt.onmouseover();
}

/*#######################################################################
	checkScroller
#######################################################################*/

function checkScroller()
{
	if($("scrollContent")) {
		var c	= $("content");
		var sc	= $("scrollContent");
		var cH	= c.offsetHeight-19-22;
		var scH	= sc.getSize().scrollSize.y;
		if(scH <= cH) {
			$("scrollButtonUp").style.display = "none";
			$("scrollButtonDn").style.display = "none";
		}
	}
}

//window.addEvent('load',checkScroller);

/*#######################################################################
	setMainContainer
#######################################################################*/

function setMainContainer()
{
	var mc			= $("mainContainer");
	var l			= (window.getWidth() / 2) - (mc.offsetWidth / 2);
	var t			= (window.getHeight() / 2) - (mc.offsetHeight / 2);
	mc.style.top	= t + "px";
	mc.style.left	= l + "px";
}

//window.addEvent('domready',setMainContainer);
//window.addEvent('resize',setMainContainer);

/*#######################################################################
	setZoomBackgroundImage
#######################################################################*/

function setZoomBackgroundImage()
{
	$("zoomBackgroundImage").style.height = window.getSize().size.y + "px";
}
window.addEvent("resize",setZoomBackgroundImage);
//window.addEvent("load",setZoomBackgroundImage);

/*#######################################################################
	openWindow
#######################################################################*/

function openWindow(path,w,h)
{
	var o = window.open(path, 'BLEU_MAN_GROUP', 'width='+w+',height='+h+',left=0,top=0');
}


window.addEvent("domready",function()
{
	setMainContainer();
	initImagePreloader();
});

window.addEvent("load",function()
{
	setZoomBackgroundImage();
	setMainContainer();
	createSubnaviHGB();
	checkScroller();
});


