var VEHICLES_STYLE_IDS = new Array();
//2008
//g8
VEHICLES_STYLE_IDS['G82008'] = "17508~293264"
VEHICLES_STYLE_IDS['G82008GT'] = "17508~293265"
//g5
VEHICLES_STYLE_IDS['G52008'] = "16952~289083"
VEHICLES_STYLE_IDS['G52008GT'] = "16952~289084"
//g6 convertible
VEHICLES_STYLE_IDS['G6Conv2008'] = "16947~289065"
//g6 coupe
VEHICLES_STYLE_IDS['G6Coupe2008GT'] = "16947~289063"
VEHICLES_STYLE_IDS['G6Coupe2008GXP'] = "16947~289064"
//g6 sedan
VEHICLES_STYLE_IDS['G6Sedan2008GT'] = "16947~289068"
VEHICLES_STYLE_IDS['G6Sedan2008GXP'] = "16947~289069"
VEHICLES_STYLE_IDS['G6Sedan2008'] = "16947~289067"
VEHICLES_STYLE_IDS['G6Sedan2008ValueLeader'] = "16947~289066"
//grand prix
VEHICLES_STYLE_IDS['GrandPrix2008GXP'] = "16948~289071"
VEHICLES_STYLE_IDS['GrandPrix2008'] = "16948~289070"
//solstice
VEHICLES_STYLE_IDS['Solstice2008'] = "16953~289100"
VEHICLES_STYLE_IDS['Solstice2008GXP'] = "16953~289101"
//torrent
VEHICLES_STYLE_IDS['Torrent2008AWD'] = "16949~289073"
VEHICLES_STYLE_IDS['Torrent2008FWD'] = "16949~289072"
VEHICLES_STYLE_IDS['Torrent2008AWDGXP'] = "16949~289075"
VEHICLES_STYLE_IDS['Torrent2008FWDGXP'] = "16949~289074"
//vibe
VEHICLES_STYLE_IDS['Vibe2008'] = "16946~289062"
/**************************************/
//2009
//g8
VEHICLES_STYLE_IDS['G82009'] = "18103~297487"
VEHICLES_STYLE_IDS['G82009GT'] = "18103~297488"
VEHICLES_STYLE_IDS['G82009GXP'] = "18103~308408"
//g5
VEHICLES_STYLE_IDS['G52009'] = "18246~300825"
VEHICLES_STYLE_IDS['G52009GT'] = "18246~300826"
//g3
VEHICLES_STYLE_IDS['G32009'] = "18838~308111"
//new g6 sedan
VEHICLES_STYLE_IDS['NewG6Sedan2009'] = "18097~308433"
VEHICLES_STYLE_IDS['NewG6Sedan2009ValueLeader'] = "18097~309314"
VEHICLES_STYLE_IDS['NewG6Sedan2009GT'] = "18097~308434"
VEHICLES_STYLE_IDS['NewG6Sedan2009GXP'] = "18097~308435"
//new g6 coupe
VEHICLES_STYLE_IDS['NewG6Coupe2009'] = "18097~308429"
VEHICLES_STYLE_IDS['NewG6Coupe2009GT'] = "18097~308430"
VEHICLES_STYLE_IDS['NewG6Coupe2009GXP'] = "18097~308431"
//new g6 convertible
VEHICLES_STYLE_IDS['NewG6Conv2009'] = "18097~308432"
//solstice
VEHICLES_STYLE_IDS['Solstice2009Conv'] = "18247~301025"
VEHICLES_STYLE_IDS['Solstice2009ConvGXP'] = "18247~301026"
VEHICLES_STYLE_IDS['Solstice2009Cpe'] = "18247~308406"
VEHICLES_STYLE_IDS['Solstice2009CpeGXP'] = "18247~308407"
//torrent
VEHICLES_STYLE_IDS['Torrent2009FWD'] = "18248~300858"
VEHICLES_STYLE_IDS['Torrent2009AWD'] = "18248~300860"
VEHICLES_STYLE_IDS['Torrent2009FWDGXP'] = "18248~300861"
VEHICLES_STYLE_IDS['Torrent2009AWDGXP'] = "18248~300859"
//vibe
VEHICLES_STYLE_IDS['Vibe20091.8L'] = "17664~295026"
VEHICLES_STYLE_IDS['Vibe20092.4L'] = "17664~297341"
VEHICLES_STYLE_IDS['Vibe2009GT'] = "17664~295027"
VEHICLES_STYLE_IDS['Vibe2009GXP'] = "17664~295028"
VEHICLES_STYLE_IDS['Vibe2009AWD'] = "17664~295026"
//g6 sedan
VEHICLES_STYLE_IDS['G6Sedan2009'] = "18097~297453"
VEHICLES_STYLE_IDS['G6Sedan2009GT'] = "18097~297454"
VEHICLES_STYLE_IDS['G6Sedan2009GXP'] = "18097~297455"
//g6 coupe
VEHICLES_STYLE_IDS['G6Coupe2009'] = "18097~297450"
VEHICLES_STYLE_IDS['G6Coupe2009GXP'] = "18097~297451"
//g6 convertible
VEHICLES_STYLE_IDS['G6Conv2009'] = "18097~297452"
/**************************************/
//2010
//vibe
VEHICLES_STYLE_IDS['Vibe20101.8L'] = "18913~308484"
VEHICLES_STYLE_IDS['Vibe20102.4L'] = "18913~308485"
VEHICLES_STYLE_IDS['Vibe2010GT'] = "18913~308486"
VEHICLES_STYLE_IDS['Vibe2010AWD'] = "18913~308487"


var OPTION_FEATURED_TAB_ON = "optionFeaturedTabOn";
var OPTION_FEATURED_TAB_OFF = "optionFeaturedTabOff";
var OPTION_INCENTIVES_TAB_ON = "optionIncentivesTabOn";
var OPTION_INCENTIVES_TAB_OFF = "optionIncentivesTabOff";
var OPTION_FEATURED_OFFERS = "optionFeatured";
var OPTION_REGIONAL_INCENTIVES = "optionIncentives";
var OPTION_FEATURED_TAB = "featuredTab";
var OPTION_INCENTIVES_TAB = "incentivesTab";
/*----------------------------------------------------------------------------------------------------*/

function showTab(ClickedID){
	ClassValue = ClickedID.className;
	//if option1 is clicked
	if (ClassValue == OPTION_FEATURED_TAB_ON || ClassValue == OPTION_FEATURED_TAB_OFF){
		//changes the class Activ if the tab clicked
		tabOption = $(OPTION_FEATURED_OFFERS);
		$(OPTION_FEATURED_OFFERS).blur();
		tabOption.className = OPTION_FEATURED_TAB_ON;
		//changes the class Inactive
		tabOption = $(OPTION_REGIONAL_INCENTIVES);
		tabOption.className = OPTION_INCENTIVES_TAB_OFF;
		//show the conteiner information for each tab select
		myObje = $(OPTION_INCENTIVES_TAB);
		myObje.style.display = 'none';
		myObje = $(OPTION_FEATURED_TAB);
		myObje.style.display = 'block';
		$('regionHeader').style.display = 'none';
		$('regionHeader').blur();
	}
	//if option2 is clicked
	else if (ClassValue == OPTION_INCENTIVES_TAB_ON || ClassValue == OPTION_INCENTIVES_TAB_OFF){
		//changes the class Activ if the tab clicked
		tabOption = $(OPTION_FEATURED_OFFERS);
		$(OPTION_REGIONAL_INCENTIVES).blur();
		tabOption.className = OPTION_FEATURED_TAB_OFF;
		//changes the class Inactive
		tabOption = $(OPTION_REGIONAL_INCENTIVES);
		tabOption.className = OPTION_INCENTIVES_TAB_ON;
		//show the conteiner information for each tab select
		myObje = $(OPTION_FEATURED_TAB);
		myObje.style.display = 'none';
		myObje = $(OPTION_INCENTIVES_TAB);
		myObje.style.display = 'block';
		$('regionHeader').style.display = 'block';
		$('regionHeader').blur();
	}
	reloadLists();
}

function str_replace(cadena, cambia_esto, por_esto) {
	return cadena.split(cambia_esto).join(por_esto);
}

function changeImg() {
	var floatimg = $("buttonZip");
	floatimg.src="../pontiac/content/en/images/pricing/currentOffersPage/BuyingGuide/btn_update.gif";
}

/*FUNCTION TO ADD COUNTIES TO THE DROPDOWN*/
function addOption(zip, year, regionName, countyName){
	var countiesSelect = $("cmbCounties");
	var control = 0;
	for(var i=0;i<countiesSelect.length;i++){
		if (countiesSelect.options[i].text == textToLowerCase(countyName)){
			control = 1;
			if ((countiesSelect.options[i].value).indexOf(regionName)==-1)
				countiesSelect.options[i].value = countiesSelect.options[i].value+","+regionName;
		}
	}
	if(control == 0){
		var y = document.createElement("option");
		y.id = countyName+" - "+regionName;
		y.text = textToLowerCase(countyName);
		y.value = regionName;
		try{
			$("cmbCounties").add(y,null);
		}
		catch(ex){
			$("cmbCounties").add(y);
		}
	}
}

function textToLowerCase(text){
	var s1 = text;
	var arr = new Array();
	if(s1.split(" - ").length > 1){
		arr = s1.split(" - ");
		switch(s1.split(" - ").length){
			case 2:
				if(arr[0].split(" ").length > 1){
					var arrSub = new Array();
					arrSub = arr[0].split(" ");
					arr[0] = arrSub[0].substring(0,1)+""+arrSub[0].substring(1,arrSub[0].length).toLowerCase()+" "+arrSub[1].substring(0,1)+""+arrSub[1].substring(1,arr[0].length).toLowerCase();
				}else{
					arr[0] = arr[0].substring(0,1)+""+arr[0].substring(1,arr[0].length).toLowerCase();
				}
				if(arr[1].split(" ").length > 1){
					var arrSub = new Array();
					arrSub = arr[1].split(" ");
					arr[1] = arrSub[0].substring(0,1)+""+arrSub[0].substring(1,arrSub[0].length).toLowerCase()+" "+arrSub[1].substring(0,1)+""+arrSub[1].substring(1,arr[1].length).toLowerCase();
				}else{
					arr[1] = arr[1].substring(0,1)+""+arr[1].substring(1,arr[1].length).toLowerCase();
				}
				return(arr[0]+" - "+arr[1]);
				break;
			case 3:
				arr[0] = arr[0].substring(0,1)+""+arr[0].substring(1,arr[0].length).toLowerCase();
				if(arr[1].split(" ").length > 1){
					var arrSub = new Array();
					arrSub = arr[1].split(" ");
					arr[1] = arrSub[0].substring(0,1)+""+arrSub[0].substring(1,arrSub[0].length).toLowerCase()+" "+arrSub[1].substring(0,1)+""+arrSub[1].substring(1,arr[1].length).toLowerCase();
				}else{
					arr[1] = arr[1].substring(0,1)+""+arr[1].substring(1,arr[1].length).toLowerCase();
				}
				arr[2] = arr[2].substring(0,1)+""+arr[2].substring(1,arr[1].length).toLowerCase();
				return(arr[0]+" - "+arr[1]+" "+arr[2]);
				break;
		}
	}
	else if(s1.split(" ").length > 1) {
		arr = s1.split(" ");
		arr[0] = arr[0].substring(0,1)+""+arr[0].substring(1,arr[0].length).toLowerCase();
		arr[1] = arr[1].substring(0,1)+""+arr[1].substring(1,arr[1].length).toLowerCase();
		return(arr[0]+" "+arr[1]);
	}else{
		s1 = s1.substring(0,1)+""+s1.substring(1,s1.length).toLowerCase();
		return(s1);
	}
}

/*FUNCTION TO ADD COUNTIES TO THE DROPDOWN*/
function setAction(select){
	var selectedVal = select.value;
	if(selectedVal != "Select County" && $("zip").value != ""){
		document.regionSelectionForm.county.value = select.options[select.selectedIndex].innerHTML;
		if (selectedVal == "WESTERN" || selectedVal == "SOUTH CENTRAL" || selectedVal == "SOUTHEAST" || selectedVal == "NORTHEAST" || selectedVal == "NORTH CENTRAL - EAST" || selectedVal == "NORTH CENTRAL - WEST"){
			document.regionSelectionForm.region.value = selectedVal;
			$("regionSelectionForm").action = "/showCurrentOffersResults.do";
		}else{
			var regions =  new Array();
			regions = selectedVal.split(",");
			document.regionSelectionForm.region.value = regions[0];
			for(var j=0; j< regions.length; j++){
				if (document.regionSelectionForm.regions.value == ""){
					document.regionSelectionForm.regions.value = regions[j];
				}
				else{
					document.regionSelectionForm.regions.value = document.regionSelectionForm.regions.value+","+regions[j];
				}
			}
			$("regionSelectionForm").action = "/showCurrentOffersResults.do";
		}
	}
}

/*FUNCTION TO CHECK FOR REGIONS ALREADY ADDED IN MULTI REGIONS ZIP CODES*/
function isRegionAlreadyAdded(region){
	var flag=false;
	for(var i=0; i<regionsArray.length && flag==false; ++i){
		if(regionsArray[i] == region){
			flag=true;
		}
	}
	if(flag==false){
		regionsArray[regionsArray.length] = region;
	}
	return flag;
}

function writeURL(zip, region, regions, year, county){
	var passedRegions =  new Array();
	var url = "";
	var yearLink = "";
	var current = "incentives";
	passedRegions = regions.split(",");
	for(var j=0; j < passedRegions.length; j++){
		if (!isRegionAlreadyAdded(passedRegions[j])){
			if(currentRegion == passedRegions[j]){
				if (j==0){
					url = url + "<span>"+passedRegions[j]+"</span>";
					currentRegion = "";
				}
				else{
					url = url + " | "+"<span class='currentRegion'>"+passedRegions[j]+"</span>";					currentRegion = "";
				}
			}
			else{
				if (j == 0)
					url = url + "<a href='showCurrentOffersResults.do?zip="+zip+"&year="+year+"&region="+passedRegions[j]+"&regions="+regions+"&county="+county+"&current="+current+"'>"+passedRegions[j]+"</a>";
				else
					url = url + " | "+ "<a href='showCurrentOffersResults.do?zip="+zip+"&year="+year+"&region="+passedRegions[j]+"&regions="+regions+"&county="+county+"&current="+current+"'>"+passedRegions[j]+"</a>";
			}
		}
	}
	$("regionHeader").innerHTML = url;
}

/*FUNCTIONS FOR OFFER DETAILS POPUP WINDOW*/
function show(show){
	$(show).style.visibility = 'visible';
}

function hide(hide){
	$(hide).style.visibility = 'hidden';
}

/*FUNCTION TO SHOW/HIDE THE BODY STYLE*/
function showBodyStyle(select){
	switch(select.value){
		case "crossovers":
			$("crossovers").style.display = "block";
			$("Cars").style.display = "none";
			break;
		case "cars":
			$("crossovers").style.display = "none";
			$("Cars").style.display = "block";
			break;
		default:
			$("crossovers").style.display = "block";
			$("Cars").style.display = "block";
			break;
	}
}

function showElements(action){
	if (action){
		$('offerRegion').style.display = 'block';
		$('Menu').style.display = 'block';
		$('regionHeader').style.display = 'none';
		$(OPTION_FEATURED_TAB).style.display = 'block';
	}
	else{
		$('offerRegion').style.display = 'none';
		$('Menu').style.display = 'none';
		$(OPTION_FEATURED_TAB).style.display = 'none';
		$(OPTION_INCENTIVES_TAB).style.display = 'none';
	}
}

/*FUNCTION TO CHANGE THE YEAR OF THE INCENTIVES*/
function changeYear(select){
	var selectedUrl = select.value;
	setTimeout ("location.href='" + selectedUrl + "'", 500);
}

var dmaArray = new Array();
var dmaCount=0;
function addToDMAArray(dmaCode){
	var flag=false;
	for(var i=0; i<dmaArray.length && flag == false; ++i)
	{
		if(dmaArray[i] == dmaCode){
			flag=true;
		}
	}
	if(flag==false){
		dmaArray[dmaArray.length] = dmaCode;
	}
	return flag;
}

/*FUNCTION TO INCLUDE THE DMA CODE PAGE*/
function callDMAPage(id, DMA){
	var page = false;
	if (window.XMLHttpRequest) {// if Mozilla, Safari etc
		page = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){ //IE
		try {
			page = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){ // old version of IE
			try{
				page = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	else{
		return false;
	}
	var urlToDma = "./content/en/jsp/pricing/OffersData/"+DMA+".html";
	page.onreadystatechange=function(){ // Response function
		loadPage(page , id);
	}
	page.open('GET', urlToDma , true); // asignament of the open and sent methods
	page.send(null);
}

function loadPage(page, id){
	if (page.readyState == 4 && (page.status == 200 || window.location.href.indexOf("http") == -1)){
		$(id).innerHTML = page.responseText;
		/*show features content 1 time*/
		changeHrefToLDAndRAQ(ZIP);
	}
	if (page.readyState == 4 && (page.status == 404 || window.location.href.indexOf("http") == -1)){
		hideFeatureOffers();
	}
}

function hideFeatureOffers(){
	$(OPTION_FEATURED_TAB).style.display = "none";
	$(OPTION_FEATURED_OFFERS).className = OPTION_FEATURED_TAB_OFF;
	$(OPTION_FEATURED_OFFERS).style.display = "none";
}

function showFeatureOffers(){
	$(OPTION_FEATURED_TAB).style.display = "block";
	$(OPTION_FEATURED_OFFERS).style.display = "block";
	$(OPTION_FEATURED_OFFERS).className = OPTION_FEATURED_TAB_ON;
}

function showRegionalIncentives(){
	$(OPTION_REGIONAL_INCENTIVES).className = OPTION_INCENTIVES_TAB_ON;
	$(OPTION_REGIONAL_INCENTIVES).style.display = "block";
	$(OPTION_INCENTIVES_TAB).style.display = "block";
	$("regionHeader").style.display = "block";
}

function hideRegionalIncentives(){
	$(OPTION_REGIONAL_INCENTIVES).className = OPTION_INCENTIVES_TAB_OFF;
	$(OPTION_INCENTIVES_TAB).style.display = "none";
	$("regionHeader").style.display = "none";
}

function showSection(sectionOn, sectionOff){
	if (sectionOn == OPTION_REGIONAL_INCENTIVES){
		$(OPTION_FEATURED_TAB).style.display = "block";
		$(OPTION_INCENTIVES_TAB).style.display = "none";
		$(sectionOn).style.display = "block";
		$(sectionOn).className = OPTION_FEATURED_TAB_ON;
		$(sectionOff).className = OPTION_INCENTIVES_TAB_OFF;
	}
	else{
		$(OPTION_FEATURED_TAB).style.display = "none";
		$(OPTION_INCENTIVES_TAB).style.display = "block";
		$("regionHeader").style.display = "block";
		$(sectionOn).style.display = "block";
		$(sectionOn).className = OPTION_INCENTIVES_TAB_ON;
		$(sectionOff).className = OPTION_FEATURED_TAB_OFF;
	}
}

function showSelectedYear(year){
	if(year == ""){
		year = "2009";
	}
	yearSelect = $("cmbYear");
	for(var i=0;i<yearSelect.length;i++){
		if (yearSelect.options[i].text == year){
			yearSelect.options[i].selected = true;
		}
	}
}

function showSelectedOption(optionName, selectName){
	cmbSelect = $(selectName);
	for(var i=0;i<cmbSelect.length;i++){
		if (cmbSelect.options[i].text == optionName){
			cmbSelect.options[i].selected = true;
		}
	}
}

function hideAllB(){
	$(OPTION_FEATURED_TAB).style.display = "none";
	$(OPTION_INCENTIVES_TAB).style.display = "none";
	$(OPTION_REGIONAL_INCENTIVES).style.display = "none";
	$(OPTION_FEATURED_OFFERS).style.display = "none";
}

function hideTabs(){
	$(OPTION_REGIONAL_INCENTIVES).style.display = "none";
	$(OPTION_FEATURED_OFFERS).style.display = "none";
}

function changeHrefToLDAndRAQ(zip){
	var innerHMTL = "";
	var firstToken = "";
	var secondToken = "";
	var completeString = "";
	var anchors = document.getElementsByTagName('a');
	var vehicleId= "";
	for(var i=0; i < anchors.length; ++i){
		if(anchors[i].className == "details"){
			anchors[i].innerHTML = "Read Full Offer Details";
		}
		//Dealer Apply Features
	    if(anchors[i].href.indexOf('dealerLocaterLink') > 0){
	    	anchors[i].href = "dealerLocatorSearch.do?searchType=ByPostalCode&searchByPostalCodeProximity=25&searchByPostalCodePostalCode="+ zip +"&BRANDID=pg&desiredCount=25";
	    	anchors[i].className = "dealerLocatorLink_off";
	    	addEventOver(anchors[i]);
			addEventOut(anchors[i]);
	    }
	    //Request a Quote
	    if(anchors[i].href.indexOf('requestQuoteLink') > 0){
	    	var parentObj = anchors[i].parentNode;
			for(var k=0; k < parentObj.childNodes.length; ++k){
				if(parentObj.childNodes[k].className == "gmdotcom"){
					vehicleTitle = parentObj.childNodes[k].innerHTML;
					vehicleId = verifyStyleId(vehicleTitle);
				}
			}
			anchors[i].href = BASE_CONTEXT + "/getRAQSelectedVehicle.do?scratchListId="	+ vehicleId.split('~')[1] + "|4534534545&filePathAndName=c:&orderavailability=Retail&userId=GMBP&regionId=30&colorConfigPage=false&modelId=" + vehicleId.split('~')[0] + "&postalCode=" + zip +  "&unitMeasure=MILES&proximity=25&desiredCount=100&webSiteId=pg&vendorId=164506.0&selectingDealer=true&selectingVehicle=false&vehicleSelected=true&dealerRelativeDistance=&OperationCode=0&ClosestDealersPrefilled=false";
			anchors[i].className = "requesQuoteLink_off";
			addEventOver(anchors[i]);
			addEventOut(anchors[i]);
		}
	}
}

function addEventOver(elemento){
    // IE
    if (elemento.attachEvent){
        elemento.attachEvent('onmouseover',function(){Over(elemento);});
        return true;
    }else{   // The DOM Standard
        if (elemento.addEventListener){
            elemento.addEventListener('mouseover',function(){Over(elemento);}, false);
            return true;
        }else
            return false;
	}
}

function addEventOut(elemento){
    // IE
    if (elemento.attachEvent){
        elemento.attachEvent('onmouseout',function(){Out(elemento);});
        return true;
    }else{   // The DOM Standard
        if (elemento.addEventListener){
            elemento.addEventListener('mouseout',function(){Out(elemento);}, false);
            return true;
        }else {
            return false;
		}
	}
}

/*FUNCTION VERIFY THE VEHICLE STYLE ID AND ADD IT TO THE RAQ LINKS*/
function verifyStyleId(vehicleTitle){
	var styleId = "";
	/*NOTE*/
	//Please use always the first trim as default to avoid errors.
	/*2008 Cars*/
	if(vehicleTitle.lastIndexOf('2008') != -1){
		/*G8*/
		if(vehicleTitle.lastIndexOf('G8') != -1){
			styleId = VEHICLES_STYLE_IDS['G82008'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G82008GT'];
			}
		}/*G5*/
		else if(vehicleTitle.lastIndexOf('G5') != -1){
			styleId = VEHICLES_STYLE_IDS['G52008'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G52008GT'];
			}
		}/*G6 Convertible*/
		else if(vehicleTitle.lastIndexOf('G6-Conv') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Conv2008'];
		}/*G6 Coupe*/
		else if(vehicleTitle.lastIndexOf('G6-Coupe') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Coupe2008GT'];
			if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Coupe2008GXP'];
			}
		}/*G6 Sedan*/
		else if(vehicleTitle.lastIndexOf('G6-Sedan') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Sedan2008'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Sedan2008GT'];
			}else if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Sedan2008GXP'];
			}
		}else if(vehicleTitle.lastIndexOf('G6-VALUE') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Sedan2008ValueLeader'];
		}/*G6*/
		else if(vehicleTitle.lastIndexOf('G6') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Sedan2008'];
		}/*Grand Prix*/
		else if(vehicleTitle.lastIndexOf('GRANDPRIX') != -1){
			styleId = VEHICLES_STYLE_IDS['GrandPrix2008'];
			if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['GrandPrix2008GXP'];
			}
		}/*Solstice*/
		else if(vehicleTitle.lastIndexOf('SOLSTICE') != -1){
			styleId = VEHICLES_STYLE_IDS['Solstice2008'];
			if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Solstice2008GXP'];
			}
		}/*Torrent*/
		else if(vehicleTitle.lastIndexOf('TORRENT') != -1){
			styleId = VEHICLES_STYLE_IDS['Torrent2008FWD'];
			if(vehicleTitle.lastIndexOf('AWD') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2008AWD'];
			}else if(vehicleTitle.lastIndexOf('AWD-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2008AWDGXP'];
			}else if(vehicleTitle.lastIndexOf('FWD-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2008FWDGXP'];
			}
		}/*Vibe*/
		else if(vehicleTitle.lastIndexOf('TORRENT') != -1){
			styleId = VEHICLES_STYLE_IDS['Vibe2008'];
		}
	}/*2009 Cars*/
	if(vehicleTitle.lastIndexOf('2009') != -1){
		/*G8*/
		if(vehicleTitle.lastIndexOf('G8') != -1){
			styleId = VEHICLES_STYLE_IDS['G82009'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G82009GT'];
			}else if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G82009GXP'];
			}
		}/*G5*/
		else if(vehicleTitle.lastIndexOf('G5') != -1){
			styleId = VEHICLES_STYLE_IDS['G52009'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G52009GT'];
			}
		}/*G3*/
		else if(vehicleTitle.lastIndexOf('G3') != -1){
			styleId = VEHICLES_STYLE_IDS['G32009'];
		}/*NEW G6 Sedan*/
		else if(vehicleTitle.lastIndexOf('NEWG6-Sedan') != -1){
			styleId = VEHICLES_STYLE_IDS['NewG6Sedan2009'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['NewG6Sedan2009GT'];
			}else if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['NewG6Sedan2009GXP'];
			}
		}else if(vehicleTitle.lastIndexOf('NEWG6-VALUE') != -1){
			styleId = VEHICLES_STYLE_IDS['NewG6Sedan2009ValueLeader'];
		}/*NEW G6 Coupe*/
		else if(vehicleTitle.lastIndexOf('NEWG6-Coupe') != -1){
			styleId = VEHICLES_STYLE_IDS['NewG6Coupe2009'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Coupe2009GT'];
			}else if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Coupe2009GXP'];
			}
		}/*NEW G6 Convertible*/
		else if(vehicleTitle.lastIndexOf('NEWG6-Conv') != -1){
			styleId = VEHICLES_STYLE_IDS['NewG6Conv2009'];
		}/*NEW G6*/
		else if(vehicleTitle.lastIndexOf('NEWG6') != -1){
			styleId = VEHICLES_STYLE_IDS['NewG6Sedan2009'];
		}/*Solstice*/
		else if(vehicleTitle.lastIndexOf('SOLSTICE') != -1){
			styleId = VEHICLES_STYLE_IDS['Solstice2009Conv'];
			if(vehicleTitle.lastIndexOf('CONVERTIBLE-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Solstice2009GXP'];
			}else if(vehicleTitle.lastIndexOf('COUPE') != -1){
				styleId = VEHICLES_STYLE_IDS['Solstice2009Cpe'];
			}else if(vehicleTitle.lastIndexOf('COUPE-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Solstice2009CpeGXP'];
			}
		}/*Torrent*/
		else if(vehicleTitle.lastIndexOf('TORRENT') != -1){
			styleId = VEHICLES_STYLE_IDS['Torrent2009FWD'];
			if(vehicleTitle.lastIndexOf('AWD') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2009AWD'];
			}else if(vehicleTitle.lastIndexOf('AWD-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2009AWDGXP'];
			}else if(vehicleTitle.lastIndexOf('FWD-GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['Torrent2009FWDGXP'];
			}
		}/*Vibe*/
		else if(vehicleTitle.lastIndexOf('VIBE') != -1){
			styleId = VEHICLES_STYLE_IDS['Vibe20091.8L'];
			if(vehicleTitle.lastIndexOf('2.4L') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe20092.4L'];
			}else if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe2009GT'];
			}else if(vehicleTitle.lastIndexOf('AWD') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe2009AWD'];
			}
		}/*G6 Sedan*/
		else if(vehicleTitle.lastIndexOf('G6-Sedan') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Sedan2009'];
			if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Sedan2009GT'];
			}else if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Sedan2009GXP'];
			}
		}/*G6 Coupe*/
		else if(vehicleTitle.lastIndexOf('G6-Coupe') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Coupe2009'];
			if(vehicleTitle.lastIndexOf('GXP') != -1){
				styleId = VEHICLES_STYLE_IDS['G6Coupe2009GXP'];
			}
		}/*G6 Convertible*/
		else if(vehicleTitle.lastIndexOf('G6-Conv') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Conv2009'];
		}/*G6*/
		else if(vehicleTitle.lastIndexOf('G6') != -1){
			styleId = VEHICLES_STYLE_IDS['G6Sedan2009'];
		}
	}/*2010 Cars*/
	if(vehicleTitle.lastIndexOf('2010') != -1){
		if(vehicleTitle.lastIndexOf('VIBE') != -1){
			styleId = VEHICLES_STYLE_IDS['Vibe20101.8L'];
			if(vehicleTitle.lastIndexOf('2.4L') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe20102.4L'];
			}else if(vehicleTitle.lastIndexOf('GT') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe2010GT'];
			}else if(vehicleTitle.lastIndexOf('AWD') != -1){
				styleId = VEHICLES_STYLE_IDS['Vibe2010AWD'];
			}
		}
	}
	return styleId;
}

/*FUNCTION TO PUT THE CURRENT ZIP CODE INTO THE REQUEST A QUOTE LINK */
function changeHrefToRAQ(zip){
	var anchors = document.getElementsByTagName('a');
	var tempHref = "";
	for(var i=0; i < anchors.length; ++i){
	    if(anchors[i].href.indexOf('ZipCodeToReplace') > 0){
	    	tempHref = anchors[i].href;
	    	anchors[i].href = tempHref.replace(/ZipCodeToReplace/, zip);
	    }
	}
}

/*FUNCTION TO SET THE DEFAULT IMAGE WHEN CAR IMAGE IS NOT AVAILABLE  */
function changeImageDefault( id){
	$(id).src = BASE_CONTEXT +  "/content/en/images/pricing/currentOffers/box_pontiac.gif";
}

AttachEvent(window, "load", function() {
     fillZipFields('zip');
  }
);