/*################################################################################
	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;
}


/*################################################################################
	F U N C T I O N S
################################################################################*/




/*################################################################################
	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().x/2) - (el.getSize().x/2) + "px";
	})
}

window.addEvent("resize",positionInfoBox);


/*################################################################################
	showAnswer (Ratenabsicherung, Haeufige Fragen) & changeLinkClass
################################################################################*/


var activeContent = null;
	function showAnswer(id)
	{
		if(activeContent) {
			$(activeContent).style.display = "none";
		}
		if(activeContent == id) { activeContent = null; }
		else {
			$(id).style.display = "block";
			activeContent = id; 
		}
	}
		
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/pfeilActive.png)"; 
			activeLink = id; 
		}
	} 
	
	

/*################################################################################
	showLayer
################################################################################*/

function showLayer(id) {
	var layerState = $(id).getStyle('display');
	
	if(layerState == "block") {
		$(id).setStyle('display', 'none');
	} else {
		$(id).setStyle('display', 'block');
	}
}


	
// iframe mit googlemap laden

function loadMap()
{
	//$('mapFrame').src = "https://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";
}	
