
mytabs=new Array(); 
mytabs[0]="airfares"; /*Flights */
mytabs[1]="hotels"; /*Hotels */
mytabs[2]="holidays"; /*Holidays */
mytabs[3]="cruises"; /*Cruises */
mytabs[4]="insurance"; /*Insurance */
mytabs[5]="enquire"; /*Enquire */

function dehighlightAllTabs() {
	for(i=0;i<mytabs.length;i++) {
		document.getElementById(mytabs[i]).className = mytabs[i];
	}
};

function highlightTab (tabName){
	dehighlightAllTabs();
	document.getElementById(tabName).className = tabName+'down';

	};


function SwitchMenu(pos2, origin){
	dehighlightAllTabs();
	document.getElementById(tabName).className = tabName+'down';
};

function wcmCloseAll() {
	var wcmArea = document.getElementById("WCMBookingTabText");
	if (wcmArea!=null) {
		allDiv = wcmArea.getElementsByTagName("div");
		for (i=0; i < allDiv.length; i++) {
			if (allDiv[i].style.display=="block" && allDiv[i].id.indexOf("WCMBookingTab")>-1)
				allDiv[i].style.display="none";
		}
	}
	var wcmArea = document.getElementById("WCMBookingTabTextBottom");
	if (wcmArea!=null) {
		allDiv = wcmArea.getElementsByTagName("div");
		for (i=0; i < allDiv.length; i++) {
			if (allDiv[i].style.display=="block" && allDiv[i].id.indexOf("WCMBookingTab")>-1)
				allDiv[i].style.display="none";
		}
	}	
};

function showWCM(tabName) {
	wcmCloseAll();
	if ( document.getElementById("WCMBookingTab" + tabName) != null) {
		var wcmContent = document.getElementById("WCMBookingTab" + tabName);
		if (wcmContent!=null) wcmContent.style.display="block";
	}	
	if ( document.getElementById("WCMBookingTab" + tabName + "Bottom") != null) {
		var wcmContent = document.getElementById("WCMBookingTab" + tabName + "Bottom");
		if (wcmContent!=null) wcmContent.style.display="block";
	}
	
	if(tabName=="cruises") {
	
	document.getElementById("scb-cruises").innerHTML='<iframe src="http://cruises.flightcentre.co.nz/fcsearch.php" marginheight="0" marginwidth="0" name="search_iframe" frameborder="0" height="198" scrolling="no" width="492" style="z-index: 8;margin:0 0 0 8px;" id="cruiseFrame"></iframe>';
	document.getElementById("cruiseFrame").src="http://cruises.flightcentre.co.nz/fcsearch.php";

	}
	if(tabName=="insurance") {
		frameSrc=document.getElementById("travelSureiFrame").src;
		if(frameSrc.indexOf("/images/bullet_grey.gif")>-1) {
			document.getElementById("travelSureiFrame").src="http://b2b.travelsure.co.nz?alpha=flz1259";
		}
	}
};

function showForm(formAreaName) {
	if ($("#DomdestInt").attr("checked") && formAreaName=="scb-flights-domestic") formAreaName="scb-flights-international";
	document.getElementById("scb-flights-domestic").style.display="none";
	document.getElementById("scb-flights-international").style.display="none";	
	document.getElementById("scb-holidays").style.display="none";
	document.getElementById("frameControl").style.display="none";
	document.getElementById("scb-hotels").style.display="none";
	document.getElementById("scb-cruises").style.display="none";
	document.getElementById("scb-insurance").style.display="none";
	document.getElementById("scb-enquire").style.display="none";
	document.getElementById(formAreaName).style.display="block";
	
};

function setDefaultTab()
{
	prevUrlHash=urlHash;
	urlHash=document.location.hash;
	docURL=document.URL;
	var URLPrefix="/webapp/wcs/stores/servlet/";
	if (prevUrlHash!=urlHash) {
		if (urlHash=='#flightsDom' || docURL.indexOf("flights")>-1 ){
			highlightTab("airfares");
			showWCM('flights');
			if ($("#DomdestInt").attr("checked")) {
				showForm("scb-flights-international");
			} else {
				showForm("scb-flights-domestic");
			}
		} else if (urlHash=='#flightsInt'){
			highlightTab("airfares");
			showWCM('flights');
			showForm("scb-flights-international");
		} else if (urlHash=='#hotels' || docURL.indexOf("hotels")>-1){
			highlightTab("hotels");
			showWCM('hotels');
			showForm("scb-hotels");
		} else if(urlHash=='#holidays' || docURL.indexOf("holidays")>-1){
			highlightTab("holidays");
			showWCM('holidays');
			showForm("scb-holidays");
		} else if(urlHash=='#cruises' || docURL.indexOf("cruises")>-1){
			highlightTab("cruises");
			showWCM('cruises');
			showForm("scb-cruises");
			document.getElementById("scb-cruises").innerHTML='<iframe src="http://cruises.flightcentre.co.nz/fcsearch.php" marginheight="0" marginwidth="0" name="search_iframe" frameborder="0" height="198" scrolling="no" width="492" style="z-index: 8;margin:0 0 0 8px;" id="cruiseFrame"></iframe>';
		} else if (urlHash=='#insurance' || docURL.indexOf("insurance")>-1){
			highlightTab("insurance");
			showWCM('insurance');
			showForm("scb-insurance")

		} else if (urlHash=='#404error'){
			highlightTab("airfares");
			showWCM("404Error");
			showForm("scb-flights-domestic");		
		} else {
			highlightTab("airfares");
			showWCM('flights');
			if ($("#DomdestInt").attr("checked")) {
				showForm("scb-flights-international");
			} else {
				showForm("scb-flights-domestic");
			}
		}
	}
	setTimeout("setDefaultTab()",100);
}


function setIntFlight() {
	var redirectTo="";
	classVal=document.getElementById('IntclassField').value;
	flightToVal=document.getElementById('IntflightTo').value;
	switch (flightToVal) {
		case "Australia": redirectTo="/cheap/cheap-flights/australia-flights";break;
		case "South Pacific":redirectTo="/cheap/cheap-flights/south-pacific-flights";break;
		case "Asia":redirectTo="/cheap/cheap-flights/asia-flights";break;
		case "UK & Europe":redirectTo="/cheap/cheap-flights/uk-flights-europe-flights";break;
		case "USA & Canada":redirectTo="/cheap/cheap-flights/usa-flights-canada-flights";break;
		case "South & Central America":redirectTo="/cheap/cheap-flights/south-america-flights";break;
		case "Africa & Middle East":redirectTo="/cheap/cheap-flights/africa-flights-middle-east-flights";break;
		default :redirectTo="/cheap/cheap-flights/cheap-airfares";
	}
	if (classVal=="Business") redirectTo="/cheap/cheap-flights/business-class-flights"
	if (redirectTo != "") 	window.location=redirectTo;
}

function setDomesticFlight() {
	window.location="/cheap/cheap-flights/flights-new-zealand";
}
