/*################################################################################
	D E B U G
################################################################################*/

var debugModus = 0	; // Debugmodus EIN = 1 || AUS = 0

function debug(txt)
{
	if(!debugModus || typeof(console) != "object") { return; }
	else { console.log(txt); }
}
debug("debugModus = true");


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

// get Elements by Name

function $$$(obj)
{
	var obj = document.getElementsByName(obj);
	obj = (obj.length==1)?obj[0]:obj;
	return obj;
}

/*################################################################################
CMS Alert
################################################################################*/

function cmsAlert(title, content, close){
	Alert({
		title: title,
		content: '<p>'+content+'</p><a class="Right" style="display:block"'
	    				+' href="javascript:overlay.hide()">'
	    				+close+'</a>'
	});
}


/*################################################################################
	F U N C T I O N S
################################################################################*/

/*===============================================================================
	clearValue
=================================================================================*/
function clearValue(field) {
	field.defValue = field.value;
	field.onfocus = function() { 
		if(this.value == this.defValue) this.value = ""; 
	}
	field.onblur = function() {
		if(this.value == "") this.value = this.defValue;
	}
	field.onfocus();
}

/*===============================================================================
	changeColor
=================================================================================*/
function changeColor(tableRow,url) {
 	tableRow.style.cursor = "pointer";
	tableRow.url = url;
	tableRow.onmouseover = function() { this.style.backgroundColor = "#efc7a6"; }
	tableRow.onmouseout = function() { this.style.backgroundColor =""; }
	tableRow.onclick = function() { if(this.url) window.location.href = this.url; }
	tableRow.onmouseover();
}

/*========================================================================================
	setBackgroundContainerHeight
========================================================================================*/

// Fensterhöhe ausmessen

function setBackgroundContainerHeight() {
	var windowHeight = window.getSize().y;
	if($type($('center')) != "element") {
		$("backgroundContainer").style.height = ($("content").getSize().y > windowHeight) ? "auto" : windowHeight + "px";	
	} else {
		var centerHeight = $("center").getSize().y;
		var leftHeight = $('left').getSize().y;
		if(leftHeight > centerHeight) {
			$("backgroundContainer").style.height = (($("left").getSize().y + 180) > windowHeight) ? leftHeight + 180 + "px" : windowHeight + "px";
		} else if (leftHeight < centerHeight) {
			$("backgroundContainer").style.height = (($("center").getSize().y + 180) > windowHeight) ? centerHeight + 180 + "px" : windowHeight + "px";	
		}
	}
}

window.addEvent("load", setBackgroundContainerHeight);
window.addEvent("resize", setBackgroundContainerHeight);


/*========================================================================================
	showNavi
========================================================================================*/

// Startnavi ein-/ausblenden

function showNavi(sparte) {
	var status = $(sparte).style.display;
	
	$('berufsbildung').style.display 	= "none";
	$('berufsbildungTrigger').src = "/pix/main/icons/berufsbildungClosed.gif";
	$('hoehereFachschulen').style.display 	= "none";
	$('hoehereFachschulenTrigger').src = "/pix/main/icons/hoehereFachschulenClosed.gif";
	$('weiterbildung').style.display 	= "none";
	$('weiterbildungTrigger').src = "/pix/main/icons/weiterbildungClosed.gif";
	
	if(status == "none") {
		$(sparte).style.display = "block";
		$(sparte + 'Trigger').src = "/pix/main/icons/" + sparte + "Opened.gif";
	} else {
		$(sparte).style.display = "none";
		$(sparte + 'Trigger').src = "/pix/main/icons/" + sparte + "Closed.gif";	
	}
}


function showNavi2(sparte) {
	var status = $(sparte).style.display;
	
	$('berufsbildung').style.display 	= "none";
	$('berufsbildungTrigger').src = "/pix/main/icons/varianten/berufsbildungClosed.gif";
	$('hoehereFachschulen').style.display 	= "none";
	$('hoehereFachschulenTrigger').src = "/pix/main/icons/varianten/hoehereFachschulenClosed.gif";
	$('weiterbildung').style.display 	= "none";
	$('weiterbildungTrigger').src = "/pix/main/icons/varianten/weiterbildungClosed.gif";
	
	if(status == "none") {
		$(sparte).style.display = "block";
		$(sparte + 'Trigger').src = "/pix/main/icons/varianten/" + sparte + "Opened.gif";
	} else {
		$(sparte).style.display = "none";
		$(sparte + 'Trigger').src = "/pix/main/icons/varianten/" + sparte + "Closed.gif";	
	}
}


/*========================================================================================
	showInfo
========================================================================================*/

function showInfo(button,sparte)
{
	button.onmouseout = function()
	{
		$(sparte + "Info").style.display = "none";
		$(sparte + 'InfoTrigger').src = "/pix/main/icons/" + sparte + "Info.gif";
	}
	button.onmouseover = function()
	{
		$(sparte + "Info").style.display = "block";
		$(sparte + 'InfoTrigger').src = "/pix/main/icons/" + sparte + "InfoOver.gif";
	}
	button.onmouseover();
}

function showInfo2(button,sparte)
{
	button.onmouseout = function()
	{
		$(sparte + "Info").style.display = "none";
	}
	button.onmouseover = function()
	{
		$(sparte + "Info").style.display = "block";
	}
	button.onmouseover();
}


/*========================================================================================
	bottomImage
========================================================================================*/


	window.addEvent("load", function() {
		if($('bottomImage')) {
			$('bottomImage').style.visibility = "visible";
		} else if($('innerBottomImage')){
			$('innerBottomImage').style.visibility = "visible";
		}
	} );




/*========================================================================================
	setServiceNavi
========================================================================================*/

function setServiceNavi() {
	if($('serviceNavi')){
		$('serviceNavi').style.left = $('content').offsetLeft + "px";
		$('serviceNavi').style.visibility = "visible";
	}
}
window.addEvent("load", setServiceNavi);
window.addEvent("resize", setServiceNavi);


/*========================================================================================
	showIndividualNavi
========================================================================================*/

function initAccordion() {
	var id = 0;
	var activeId = null;
	$$('.toggler').each(function(el)
	{
		if(el.hasClass("togglerNaviActive")) { activeId = id; }
		id++;
	});
	activeId = (activeId === null) ? -1 : activeId;
	var accordionNavi = new Accordion($$('.toggler'), $$('.element'),{
		opacity: false,
		alwaysHide: true,
		show: activeId,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#000000');
			element.setStyle('borderBottom', '1px solid #CCCCCC');
			element.setStyle('padding', '6px 6px 3px');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#54616e');
			element.setStyle('borderBottom', '0px solid #CCCCCC');
			element.setStyle('padding', '0px');
		}
	});
	/* $('mainNavigation').height = "auto";
	$('mainNavigation').overflow = "visible";
	$('mainNavigation').zoom = "1"; */
	if($('naviAccordion')){
		setTimeout(function() { $('naviAccordion').style.visibility = "visible"; }, 100);
	}
}
window.addEvent('domready', initAccordion);

/*========================================================================================
	showVideo
========================================================================================*/

function showVideo() {
	
	/* var posX = $('videoTarget').offsetLeft;
	var posY = $('videoTarget').offsetTop;
	
	$('spot').style.left 	= posX + "px";
	$('spot').style.top 	= posY + "px"; */
	$('spot').style.display = "block";

}

function hideVideo() {
	$('spot').style.display = "none";
}



/*========================================================================================
	showMember(id)
========================================================================================*/
/*
var activeMember = "wicki";
	function showMember(id)
	{
		if(activeMember) {
			$(activeMember).style.visibility = "hidden";
				}
		if(activeMember == id) { activeMember = null; }
		else {
			$(id).style.visibility = "visible";
			activeMember = id; 
				}
	}
	
var activeLink = "wickiLink";
	function changeLinkClass(id) 
	{ 
		if(activeLink) $(activeLink).style.color = "#333";
		if(activeLink == id) { activeLink = null; }
		else {
			$(id).style.color = "#003399"; 
			activeLink = id; 
		}
	} 
*/



