function isDealer(temp){		
	if(temp == "dealer")
		document.getElementById("toolButtons").style.display = "none";				
}

function changeTab(option, brand){
	switch(option){
		case 'vanUpfits':
			document.getElementById("vanContent"+brand).style.display = "block";
			document.getElementById("fullTruckContent"+brand).style.display = "none";
			document.getElementById("midTruckContent"+brand).style.display = "none";
		break;
		case 'fullTruckUpfits':
			document.getElementById("fullTruckContent"+brand).style.display = "block";
			document.getElementById("vanContent"+brand).style.display = "none";
			document.getElementById("midTruckContent"+brand).style.display = "none";
		break;
		case 'midTruckUpfits':
			document.getElementById("midTruckContent"+brand).style.display = "block";
			document.getElementById("vanContent"+brand).style.display = "none";
			document.getElementById("fullTruckContent"+brand).style.display = "none";
		break;
		default:
			document.getElementById("vanContent"+brand).style.display = "block";
			document.getElementById("fullTruckContent"+brand).style.display = "none";
			document.getElementById("midTruckContent"+brand).style.display = "none";
		break;
	}
	highlightTab(option, brand);
}

function highlightTab(option, brand){
		switch(option){
		case 'vanUpfits':
			document.getElementById("vanUpfits"+brand).className = "vanUpfitsOn"+brand;
			document.getElementById("fullTruckUpfits"+brand).className = "fullTruckUpfitsOff"+brand;
			document.getElementById("midTruckUpfits"+brand).className = "midTruckUpfitsOff"+brand;
		break;
		case 'fullTruckUpfits':
			document.getElementById("vanUpfits"+brand).className = "vanUpfitsOff"+brand;
			document.getElementById("fullTruckUpfits"+brand).className = "fullTruckUpfitsOn"+brand;			
			document.getElementById("midTruckUpfits"+brand).className = "midTruckUpfitsOff"+brand;
		break;
		case 'midTruckUpfits':			
			document.getElementById("vanUpfits"+brand).className = "vanUpfitsOff"+brand;
			document.getElementById("fullTruckUpfits"+brand).className = "fullTruckUpfitsOff"+brand;
			document.getElementById("midTruckUpfits"+brand).className = "midTruckUpfitsOn"+brand;
		break;
		default:
			document.getElementById("vanUpfits"+brand).className = "vanUpfitsOn"+brand;
			document.getElementById("fullTruckUpfits"+brand).className = "fullTruckUpfitsOff"+brand;
			document.getElementById("midTruckUpfits"+brand).className = "midTruckUpfitsOff"+brand;
		break;
	}
}

function changeCashTab(option){
	switch(option){
		case 'vanTab':
			document.getElementById("toolButtons").style.marginBottom = "40px";
			document.getElementById("cashContent").style.marginBottom = "20px";
			document.getElementById("vanCashContent").style.display = "block";
			document.getElementById("truckCashContent").style.display = "none";
			document.getElementById("hhrCashContent").style.display = "none";
		break;
		case 'truckTab':
			document.getElementById("toolButtons").style.marginBottom = "10px";
			document.getElementById("cashContent").style.marginBottom = "5px";
			document.getElementById("truckCashContent").style.display = "block";
			document.getElementById("vanCashContent").style.display = "none";
			document.getElementById("hhrCashContent").style.display = "none";
		break;
		case 'hhrTab':
			document.getElementById("toolButtons").style.marginBottom = "40px";
			document.getElementById("hhrCashContent").style.display = "block";
			document.getElementById("vanCashContent").style.display = "none";
			document.getElementById("truckCashContent").style.display = "none";
		break;
		default:
			document.getElementById("vanCashContent").style.display = "block";
			document.getElementById("cashContent").style.marginBottom = "20px";
			document.getElementById("truckCashContent").style.display = "none";
			document.getElementById("hhrCashContent").style.display = "none";
		break;
	}
	highlightCashTab(option);
}

function highlightCashTab(option){
		switch(option){
		case 'vanTab':
			document.getElementById("vanTab").className = "vanTabOn";
			document.getElementById("truckTab").className = "truckTabOff";
			document.getElementById("hhrTab").className = "hhrTabOff";
		break;
		case 'truckTab':
			document.getElementById("vanTab").className = "vanTabOff";
			document.getElementById("truckTab").className = "truckTabOn";
			document.getElementById("hhrTab").className = "hhrTabOff";
		break;
		case 'hhrTab':			
			document.getElementById("vanTab").className = "vanTabOff";
			document.getElementById("truckTab").className = "truckTabOff";
			document.getElementById("hhrTab").className = "hhrTabOn";
		break;
		default:
			document.getElementById("vanTab").className = "vanTabOn";
			document.getElementById("truckTab").className = "truckTabOff";
			document.getElementById("hhrTab").className = "hhrTabOff";
		break;
	}
}

function loadFlash(container,swfFile,width,height,type){		

	document.getElementById(container).style.visibility = "visible";
	var brand = getBrand();
	var page = getPage();
	var dealer = "false";
	if(type == "dealer")
		dealer = "true";

	var so = new SWFObject("/flash/" + swfFile, "businessChoiceSwf", width, height, "8", "#FFFFFF");

	so.addParam("menu","false");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addVariable("config","/flash/businessChoice/swf/businessChoice.xml");
	so.addVariable("txt0","/xml/trackingConfiguration.xml");
	if(brand != null)
		so.addVariable("brand",brand);
	
	so.addVariable("dealer",dealer);
	so.addVariable("activeBtn",page);
		
	so.write(container);
}

function loadFlashTracking(container){		

	var so = new SWFObject("/flash/TrackingManager.swf", "businessChoiceSwf", "1", "1", "8", "#FFFFFF");

	so.addParam("menu","false");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addVariable("txt0","/xml/trackingConfiguration.xml");
		
	so.write(container);
}

function getPage(){
	var url = window.location.href;
	var page = "";
	if(url.indexOf("upfitPackages") > -1)
		page = "truck_van";
		
	if(url.indexOf("upfitCash") > -1)
		page = "upfit_cash";
		
	if(url.indexOf("lowesCard") > -1)
		page = "gift_card";
		
	if(url.indexOf("gmBusinessCard") > -1)
		page = "gm_business";
		
	return page;
}

function getBrand(){
	var url = window.location.href;
	var brand = "";
	if(url.indexOf("/businessChoice/chevy/") > -1){
		brand = "chevy";
	}
	if(url.indexOf("/businessChoice/gmc/") > -1){
		brand = "gmc";
	}
	if(url.indexOf("/businessChoice/gmfleet/") > -1){
		return null;
	}
	return brand;
}

function changePage(selectedBrand,temp){
	var aux = brand;
	if(brand != selectedBrand){	
		if(brand == "chevy")
			aux = "gmc";	
		else
			aux = "chevy";
	}
	if(temp != "false")
		location.href = "/businessChoice/"+aux+"/"+pageType+".jsp?type="+temp;	
	else
		location.href = "/businessChoice/"+aux+"/"+pageType+".jsp";	
}


function showPopup(msg){		
	switch(msg){
		case 'program':
			popUpWindow('/businessChoice/popup/aboutProgram.jsp','eligible','width=650,height=500,scrollbars=yes');
		break;
		case 'vehicles':
			popUpWindow('/businessChoice/popup/eligibleVehiclesChevy.jsp','eligible','width=900,height=700,scrollbars=yes');
		break;
		case 'eligible':
			popUpWindow('/businessChoice/popup/eligible.jsp','eligible','width=722,height=500,scrollbars=yes');
		break;
		default:break;
	}
}


function expandMenu(){
	document.getElementById("businessChoiceSwf").height = "620px";
}

function collapseMenu(){
	document.getElementById("businessChoiceSwf").height = "220px";
}

function Resize(number) { 
//window.alert(document.getElementById("SWFComp").height); 
try {  
	document.getElementById("mainFlash").style.height = number; 	
	document.getElementById("mainFlash").style.salign = 'top'; 
} catch(ex) { 
} 
document.getElementById("main").style.height = number; 
document.getElementById("main").style.salign = 'top'; 

} 

/*function moveToolButtons(theId){	

var newName = theId+"C";

//For IE6 and IE7
if (window.ActiveXObject){
	document.getElementById("toolButtons").style.marginTop="-110px";	
//For Safari and FF		
	}else{
		//To detect Safari
		var nav=navigator.userAgent;
		if(nav.indexOf('Safari') != -1){
				switch(newName){
				case 'vanPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="700px";										
				break;
				case 'truckPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="945px";					
				break;
				case 'midTruckPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="595px";					
				break;
				case 'vanPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="900px";							
				break;
				case 'truckPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="945px";					
				break;
				case 'midTruckPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="597px";					
				break;
				default:		
					document.getElementById("toolButtons").style.marginTop="725px";
				break;
			}		
		}else{
			switch(newName){
				case 'vanPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="725px";									
				break;
				case 'truckPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="955px";					
				break;
				case 'midTruckPackagesGMCC':
					document.getElementById("toolButtons").style.marginTop="595px";					
				break;
				case 'vanPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="940px";							
				break;
				case 'truckPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="955px";					
				break;
				case 'midTruckPackagesChevyC':
					document.getElementById("toolButtons").style.marginTop="610px";					
				break;
				default:		
					document.getElementById("toolButtons").style.marginTop="725px";
				break;
			}		
		}	    
	}		
}*/

function initPopup(removeAnchor){
	var isDealer= removeAnchor;
	var previousPage=opener.location.href;
	if(previousPage.indexOf("dealer") > -1 || isDealer=="true"){
		document.getElementById('contentDealer').className="displayTable";
		document.getElementById('contentVehicles').className="nonDisplayTable";
		document.getElementById('buttonsBrands').innerHTML= "<a id='chevyOn' href='/businessChoice/popup/eligibleVehiclesChevy.jsp?type=dealer'></a><a id='gmcOff' href='/businessChoice/popup/eligibleVehiclesGMC.jsp?type=dealer'></a><br /><p class='onclick'>Click to choose</p>";
		document.getElementById('mapArea').href = "javascript:superPopup({url:'/businessChoice/gmfleet/index.jsp?type=dealer', type:'_blank', width:screen.width, height:screen.height}); close();";
	}else{
		 document.getElementById('contentVehicles').className="displayTable";
		 document.getElementById('contentDealer').className="nonDisplayTable";
		 }	
}

function initSingleBrandPopup(removeAnchor, element){
	var isDealer= removeAnchor;
	var previousPage=opener.location.href;
	if(previousPage.indexOf("dealer") > -1 || isDealer=="true"){
		document.getElementById(element).href = "javascript:superPopup({url:'/businessChoice/gmfleet/index.jsp?type=dealer', type:'_blank', width:screen.width, height:screen.height}); close();";
	}	
}

function fixTools(){
	var url = window.location.href;		
	if(url.indexOf("gmc/upfitPackages") > -1){
		if (window.ActiveXObject){	
			document.getElementById("toolButtons").style.marginTop="-110px";
		}else{
			var nav=navigator.userAgent;
			if(nav.indexOf('Safari') != -1){
				document.getElementById("toolButtons").style.marginTop="700px";
			}else{
				document.getElementById("toolButtons").style.marginTop="725px";
			}			
		}
	}
}