//=========================================
//functions for crossbox
//=========================================

var inactiveEntry = '';
var activeEntry = '';
var activeEntryContent = '';
tabArray = new Array();

function switchBox(whichBox) {
	
	if (activeEntry) {
		document.getElementById(activeEntry).style.visibility = "hidden";
		document.getElementById(activeEntry).style.display = "none";
		document.getElementById(activeEntryContent).style.visibility = "hidden";
		document.getElementById(activeEntryContent).style.display = "none";
		if (activeEntry.indexOf("worldwide")!= -1) {
			document.getElementById('crossbox_world').style.visibility = "hidden";
			document.getElementById('crossbox_world').style.display = "none";
		}
		document.getElementById(inactiveEntry).style.visibility = "visible";
		document.getElementById(inactiveEntry).style.display = "block";
		if (navigator.appVersion.indexOf("MSIE") == -1) {
			document.getElementById(inactiveEntry).style.height = 17 + "px";
			document.getElementById(inactiveEntry).style.borderTop = "solid 1px #262626";
			document.getElementById(inactiveEntry).style.paddingTop = "2px";
		}
	}
	var myEntry = whichBox + "_a";
	var myEntryContent = whichBox + "_b";
	activeEntry = myEntry;
	activeEntryContent = myEntryContent;
	inactiveEntry = whichBox;
	if (navigator.appVersion.indexOf("MSIE") == -1) {
		document.getElementById(whichBox).style.height = 0 + "px";
		document.getElementById(whichBox).style.border = 0 + "px";
		document.getElementById(whichBox).style.padding = 0 + "px";
	} else {
		document.getElementById(whichBox).style.visibility = "hidden";
		document.getElementById(whichBox).style.display = "none";   
	}
	document.getElementById(activeEntry).style.visibility = "visible";
	document.getElementById(activeEntry).style.display = "block";
	document.getElementById(activeEntryContent).style.visibility = "visible";
	document.getElementById(activeEntryContent).style.display = "block";
	document.getElementById(activeEntryContent).style.height = 67 + "px";
	if (whichBox.indexOf("worldwide")!= -1) {
		document.getElementById('crossbox_world').style.visibility = "visible";
		document.getElementById('crossbox_world').style.display = "block";
	}
}
var crossboxInitialized = false;

function initCrossbox(whichCB) {
	var CBnum = tabArray.length;
	for (i=0;i<CBnum;i++) {
		var myEntry = tabArray[i] + "_a";
		var myEntryContent = tabArray[i] + "_b";
		document.getElementById(myEntry).style.visibility = "hidden";
		document.getElementById(myEntry).style.display = "none";
		document.getElementById(myEntryContent).style.visibility = "hidden";
		document.getElementById(myEntryContent).style.display = "none"; 
	}

	if (document.getElementById(whichCB)) {
		var myEntry = whichCB + "_a";
		var myEntryContent = whichCB + "_b";
		activeEntry = myEntry;
		activeEntryContent = myEntryContent;
		inactiveEntry = whichCB;
		document.getElementById(whichCB).style.visibility = "hidden";
		document.getElementById(whichCB).style.display = "none";
		document.getElementById(activeEntry).style.visibility = "visible";
		document.getElementById(activeEntry).style.display = "block";
		document.getElementById(activeEntryContent).style.visibility = "visible";
		document.getElementById(activeEntryContent).style.display = "block";
	}
	crossboxInitialized = true;  
}

//counting tabs for default ibox display
function countTab(whichTab) {
	tabArray[tabArray.length] = whichTab;
}



function crossboxopenRoute() {
	var oObj=document.getElementById("HaendlerID"), HaenderlID='';
	if(oObj){HaenderlID=oObj.value;}
	//return openRoute('http://194.25.187.67/Audi/eingabe.asp',HaenderlID,'Straße','PLZ','Stadt',true);
	return openRoute('http://www.audi.de/audi/de/de2/tools/partnersearch.popup.html',HaenderlID,'Straße','PLZ','Stadt',true);
}



/**

 * Functions for the route tab of the crossbox.

 */

function openRoute(pURL, pPartnerID, pStreetDummy, pZipDummy, pCityDummy, pNewWindow) {
	var street	= document.forms["routeform"]["street"].value;
	var zip		= document.forms["routeform"]["zip"].value;
	var city	= document.forms["routeform"]["city"].value;
	if (street == pStreetDummy) street = "";
	if (zip == pZipDummy) zip = "";
	if (city == pCityDummy) city = "";
	var params = "ID=" + pPartnerID;
	if (street || zip || city) {
		params += "&ZS=" + street;
		params += "&ZP=" + zip;
		params += "&ZO=" + city;
		params += "&BUTTON=SEARCH";
	}
	var targetUrl = pURL;
	if (targetUrl.indexOf("?") > 0)
		{targetUrl += "&" + params;}
	else
		{targetUrl += "?" + params;}

	if (pNewWindow)
	{
		fenster=window.open(targetUrl,"Anfahrtsroute","width=660,height=750,top=120,left=210,scrollbars=yes");
		if (typeof(fenster.focus) == "function" || typeof(fenster.focus) == "object"){
			fenster.focus();
		}
	}
	else
		{window.location = targetUrl;}
}


