

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

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

/*function blabla () {
	debugContainer = new Element("div");
	debugContainer.style.position = "absolute";
	debugContainer.style.width = "300px";
	debugContainer.style.width = "500px";
	debugContainer.style.overflow = "auto";
	debugContainer.style.backgroundColor = "#eeeeee";
	debugContainer.style.zIndex = "50000";
	debugContainer.style.top = "0px";
	debugContainer.style.left = "0px";
	
	var bodyContainer = ($("bodyContainer")) ? $("bodyContainer") : $(document.getElementsByTagName("BODY")[0]);	
	bodyContainer.appendChild(debugContainer);
	
	
}*/

function debug(txt)
{
	if(!debugModus || typeof(console) != "object") { /*debugContainer.innerHTML = debugContainer.innerHTML+"<br />"+txt;*/return; }
	else { console.log(txt); }
}

debug("debugModus = true");
//window.addEvent("domready", blabla);




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

// get Elements by Name

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


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



/*################################################################################
	openWindow / closeWindow (popups)
################################################################################*/

function openWindow()
{
	document.getElementById(openWindow.arguments[0]).style.display = "block";
	positionInfoBox();
	var count = 1;
	while (openWindow.arguments[count])
	{
		document.getElementById(openWindow.arguments[count]).style.display = openWindow.arguments[count+1];
		count +=2;
	}
	
}


function closeWindow()
{
	document.getElementById(closeWindow.arguments[0]).style.display = "none";
	var count = 1;
	while (closeWindow.arguments[count])
	{
		document.getElementById(closeWindow.arguments[count]).style.display = closeWindow.arguments[count+1];
		count +=2;
	}
}


/*################################################################################
	infoBox positionieren
################################################################################*/
function positionInfoBox() {
	var infoBox = $$('.infoBox');
	infoBox.each(function(el)
	{
		el.style.left = (window.getSize().size.x/2) - (el.getSize().size.x/2) + "px";
	})
}

window.addEvent("resize",positionInfoBox);


/*################################################################################
	showAnswer (Ratenabsicherung, Haeufige Fragen) & changeLinkClass
################################################################################*/


var activeContent = null;
	function showAnswer(id)
	{
		if(activeContent) {
			$(activeContent).style.display = "none";
			setSmile();
		}
		if(activeContent == id) { activeContent = null; }
		else {
			$(id).style.display = "block";
			activeContent = id; 
			setSmile();
		}
	}
		
var activeLink = null;
	function changeLinkClass(id) 
	{ 
		if(activeLink) $(activeLink).style.backgroundImage = "url(../../../pix/main/pfeil.png)";
		if(activeLink == id) { activeLink = null; }
		else {
			$(id).style.backgroundImage = "url(../../../pix/main/pfeil_active.png)"; 
			activeLink = id; 
		}
	} 
	
	
/*======================================================================================
 * setSmile
/*====================================================================================*/

function setSmile()
{
		
	var mainElement = $('Main');	
	var contentElement = $('Content');
	var mannElement = $('maennchen');
	
	// Standardhöhe MainContainer
	var standardHeight = 475;
	// Main mit Content ohne Header
	var mainHeight = 350;
	
	var contentHeight =	contentElement.offsetHeight;
	var dif = contentHeight - mainHeight;
	
	if (mannElement) {
		var mannPosition = 	mannElement.getPosition();
		var mannYPos = mannPosition.y;
		
		var mannZwischen = mannYPos - 125;
		var mannZwischenDif = mainHeight - mannZwischen; 
		var mannHeight =	mannElement.offsetHeight;
		var mannDif = mannHeight - mannZwischenDif;
				
		// wenn Maennchen hoeher als Content ist
		if (mannDif > dif) {
			mainElement.style.height = standardHeight + mannDif + "px";	
		} else {
			if (contentHeight > mainHeight) {
			var newHeight = standardHeight + dif + "px";
			mainElement.style.height = newHeight;
		}	else {
			mainElement.style.height = standardHeight + "px";
		}
				
		}
		
	} else {
		
		if (contentHeight > mainHeight) {
			var newHeight = standardHeight + dif + "px";
			mainElement.style.height = newHeight;
			//alert ("NEUE: "+newHeight);
		}	else {
			mainElement.style.height = standardHeight + "px";
			//alert ("STANDAD: "+standardHeight);
		}
	}
		
}

window.addEvent("load",setSmile);
	
	
// iframe mit googlemap laden

function loadMap()
{
	$('mapFrame').src = "http://maps.google.ch/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=budgetkredit.ch&amp;sll=47.433495,8.846232&amp;sspn=0.010828,0.018475&amp;ie=UTF8&amp;t=h&amp;cid=3327870892268345983&amp;ll=47.507055,8.730268&amp;spn=0.023191,0.042915&amp;z=14&amp;iwloc=A&amp;output=embed";
}	