function sbtLoadCarData(dealerSForm,divDealer){
	readAllSBToolsCookies();
	var inputsHtml = "";
	
	if (!isEmptyString(sbToolsCookies['sbtzipcode']) && !isEmptyString(sbToolsCookies['sbtzipproximity'])) {
		updateSBTCookie('sbtSearchType', '0', 30);
		inputsHtml += "<input type='hidden' name='postalCode' value='"+sbToolsCookies['sbtzipcode']+"'>";
		inputsHtml += "<input type='hidden' name='proximity' value='"+sbToolsCookies['sbtzipproximity']+"'>";
		inputsHtml += "<input type='hidden' name='SLBrand' value='"+sbToolsCookies['myselectedbrand']+"'>";
	}
	if ((!isEmptyString(sbToolsCookies['sbtcityname']) && !isEmptyString(sbToolsCookies['sbtcitystate']) && !isEmptyString(sbToolsCookies['sbtcityproximity']))) {
		updateSBTCookie('sbtSearchType', '1', 30);
		inputsHtml += "<input type='hidden' name='cityState' value='"+sbToolsCookies['sbtcityname']+"'>";
		inputsHtml += "<input type='hidden' name='selectState' value='"+sbToolsCookies['sbtcitystate']+"'>";
		inputsHtml += "<input type='hidden' name='mileSelectState' value='"+sbToolsCookies['sbtcityproximity']+"'>";
		inputsHtml += "<input type='hidden' name='searchCity' value='"+sbToolsCookies['sbtcityname']+"'>";
		inputsHtml += "<input type='hidden' name='searchState' value='"+sbToolsCookies['sbtcitystate']+"'>";
		inputsHtml += "<input type='hidden' name='proximity' value='"+sbToolsCookies['sbtcityproximity']+"'>";
		inputsHtml += "<input type='hidden' name='SLBrand' value='"+sbToolsCookies['myselectedbrand']+"'>";
	}
	if ((!isEmptyString(sbToolsCookies['sbtsearchdealername']) && !isEmptyString(sbToolsCookies['sbtcitynamedealer']) && !isEmptyString(sbToolsCookies['sbtcitystatedealer']))) {
		updateSBTCookie('sbtSearchType', '4', 30);
		inputsHtml += "<input type='hidden' name='SearchByVendorVendorName' value='"+sbToolsCookies['sbtsearchdealername']+"'>";
		inputsHtml += "<input type='hidden' name='SearchByVendorCityName' value='"+sbToolsCookies['sbtcitynamedealer']+"'>";
		inputsHtml += "<input type='hidden' name='SearchByVendorStateName' value='"+sbToolsCookies['sbtcitystatedealer']+"'>";
		inputsHtml += "<input type='hidden' name='SLBrand' value='"+sbToolsCookies['myselectedbrand']+"'>";
	}
	
	if (carCookiesPresent()) {
		inputsHtml += "<input type='hidden' name='maximumCount' value='30'>";
		<!-- /Modify for divisional implementation -->
		inputsHtml += "<input type='hidden' name='vendorId' value='"+sbToolsCookies['sbtbac']+"'>";
		inputsHtml += "<input type='hidden' name='MMC' value='"+sbToolsCookies['myselectedtype']+"'>";
		inputsHtml += "<input type='hidden' name='modelDesignator' value='"+sbToolsCookies['sbtmodeldesignator']+"'>";
		inputsHtml += "<input type='hidden' name='searchCountry' value='"+sbToolsCookies['sbtsearchcountry']+"'>";
		inputsHtml += "<input type='hidden' name='searchType' value='"+sbToolsCookies['sbtsearchtype']+"'>";
		inputsHtml += "<input type='hidden' name='year' value='"+sbToolsCookies['myselectedyear']+"'>";
		if ((toolName == "RAQ")||(toolName == "RAT")){
			inputsHtml += "<input type='hidden' name='make' value='"+sbToolsCookies['sbtbrand']+"'>";
		}
		else {
			inputsHtml += "<input type='hidden' name='make' value='"+sbToolsCookies['myselectedbrand']+"'>";
		}
		inputsHtml += "<input type='hidden' name='makeDesc' value='"+sbToolsCookies['myselectedbrand']+"'>";
		inputsHtml += "<input type='hidden' name='brand' value='"+sbToolsCookies['sbtbrand']+"'>";		inputsHtml += "<input type='hidden' name='modelCode' value='"+sbToolsCookies['sbtmodelcode']+"'>";
		inputsHtml += "<input type='hidden' name='subModelCode' value='"+sbToolsCookies['sbtsubmodelcode']+"'>";
		inputsHtml += "<input type='hidden' name='cabType' value='"+sbToolsCookies['sbtcabtype']+"'>";
		inputsHtml += "<input type='hidden' name='driveType' value='"+sbToolsCookies['sbtdrivetype']+"'>";
		inputsHtml += "<input type='hidden' name='model' value='"+sbToolsCookies['sbtmodel']+"'>";
		inputsHtml += "<input type='hidden' name='price' value='"+formatPrice(sbToolsCookies['sbtmsrprice'])+"'>";
		inputsHtml += "<input type='hidden' name='image' value='"+sbToolsCookies['sbtimage']+"'>";
		inputsHtml += "<input type='hidden' name='proximityUnitOfMeasure' value='miles'>";
		inputsHtml += "<input type='hidden' name='isbp' value='true'>";
		<!---->

		if(trimCookiesPresent()){
			inputsHtml += "<input type='hidden' name='pvc' value='"+sbToolsCookies['myselectedstyle']+"'>";
			inputsHtml += "<input type='hidden' name='msrPrice' value='"+formatPrice(sbToolsCookies['sbtmsrprice'])+"'>";
			inputsHtml += "<input type='hidden' name='trimName' value='"+sbToolsCookies['sbttrimname']+"'>";

			document.getElementById(divDealer).innerHTML = inputsHtml;
			if ((toolName == "RAQ")||(toolName == "RAT")){
				document.getElementById(dealerSForm).action = '/messaging/saab/senddealer.jsp';
				}else{
					document.getElementById(dealerSForm).action = '/vehiclelocator/locateVehicle.do';
				}
			document.getElementById(dealerSForm).submit();
			}else{
				document.getElementById(divDealer).innerHTML = inputsHtml;
				if ((toolName == "RAQ")||(toolName == "RAT")){
					document.getElementById(dealerSForm).action = '/messaging/saab/newSelectTrim_result.jsp';
					}else{
						document.getElementById(dealerSForm).action = '/vehiclelocator/saab/vl_SelectTrim_result.jsp';
					}
				document.getElementById(dealerSForm).submit();
		}
	}else{
		if ((toolName == "RAQ")||(toolName == "RAT")){
			document.getElementById(dealerSForm).action = '/messaging/saab/newSelectV_result.jsp';
			}else{
				document.getElementById(dealerSForm).action = '/vehiclelocator/saab/vl_SelectV_result.jsp';
			}
		document.getElementById(dealerSForm).submit();
	}
}

//Create cookies required for the Dealer search for GMC, Chevrolet and Multibrand sites
function createCookiesDealerGCMSites(){
	createSBTCookie("sbtDealerTypeCode",document.SearchByDealer.dealerTypeCode.value,30);
	createSBTCookie("sbtAgreementTypeCode",document.SearchByDealer.agreementTypeCode.value,30);
	createSBTCookie("sbtProgramCode",document.SearchByDealer.programCode.value,30);
	createSBTCookie("sbtProgramICON",document.SearchByDealer.ProgramICON.value,30);
}

function loadStartPageCookies(){
		if (useSearchCookies != "false") {
			readAllSBToolsCookies();
			
			if ((sbToolsCookies['sbtzipcode'] != "") && (sbToolsCookies['sbtzipproximity'] != "")){
				document.SearchByZipCode.SearchByPostalCodePostalCode.value = sbToolsCookies['sbtzipcode'];
				document.SearchByZipCode.SearchByPostalCodeProximity.value = sbToolsCookies['sbtzipproximity'];
				document.forms["SearchByZipCode"].submit();
			}
			
			if (((sbToolsCookies['sbtcityname'] != "") && (sbToolsCookies['sbtcitystate'] != "") && (sbToolsCookies['sbtcityproximity'] != ""))){
				document.SearchBycityState.SearchByCityStateCityName.value = sbToolsCookies['sbtcityname'];
				document.SearchBycityState.SearchByCityStateStateName.value = sbToolsCookies['sbtcitystate'];
				document.SearchBycityState.SearchByCityStateProximity.value = sbToolsCookies['sbtcityproximity'];
				document.forms["SearchBycityState"].submit();
			}
			
			if (((sbToolsCookies['sbtsearchdealername'] != "") && (sbToolsCookies['sbtcitynamedealer'] != "") && (sbToolsCookies['sbtcitystatedealer'] != ""))){
				document.SearchByDealer.SearchByVendorVendorName.value = sbToolsCookies['sbtsearchdealername'];
				document.SearchByDealer.SearchByVendorCityName.value = sbToolsCookies['sbtcitynamedealer'];
				document.SearchByDealer.SearchByVendorStateName.value = sbToolsCookies['sbtcitystatedealer'];
				document.forms["SearchByDealer"].submit();
			}
		}
		else {
			eraseCookies();
		}
}

//Cookies for the dealer information
function createCookiesDealerInfo(formName){
	createSBTCookie("sbtBAC",document.getElementById(formName).BAC.value,30);
	createSBTCookie("sbtDealerName",document.getElementById(formName).dealerName.value,30);
	createSBTCookie("sbtDealerDistance",document.getElementById(formName).dealerDistance.value,30);
	createSBTCookie("sbtGmbpManager",document.getElementById(formName).gmbpManagerName.value,30);
	createSBTCookie("sbtDealerStreet",document.getElementById(formName).dealerAddress.value,30);
	createSBTCookie("sbtDealerCity",document.getElementById(formName).dealerCity.value,30);
	createSBTCookie("sbtDealerState",document.getElementById(formName).dealerState.value,30);
	createSBTCookie("sbtDealerPostalCode",document.getElementById(formName).dealerZipCode.value,30);
	createSBTCookie("sbtDealerPhone",document.getElementById(formName).dealerPhoneNumber.value,30);
	createSBTCookie("sbtDealerFax",document.getElementById(formName).dealerFax.value,30);
	createSBTCookie("sbtDealerWebsite",document.getElementById(formName).dealerWebSite.value,30);
	createSBTCookie("sbtDealerMap",document.getElementById(formName).dealerMap.value,30);
	createSBTCookie("sbtDealerDirections",document.getElementById(formName).dealerDirections.value,30);
}

//Functions to load, delete and erase cookies 

function eraseCookies(){
	eraseSBTCookie("sbtZipCode");
	eraseSBTCookie("sbtZipProximity");
	eraseSBTCookie("sbtCityName");
	eraseSBTCookie("sbtCityState");
	eraseSBTCookie("sbtCityProximity");
	eraseSBTCookie("sbtDealerName");
	eraseSBTCookie("sbtCityNameDealer");
	eraseSBTCookie("sbtCityStateDealer");
}

function createCookiesZipCode(){
	eraseCookies();
	
	createSBTCookie("sbtZipCode",document.SearchByZipCode.SearchByPostalCodePostalCode.value,30);
	createSBTCookie("sbtZipProximity",document.SearchByZipCode.SearchByPostalCodeProximity.options[document.SearchByZipCode.SearchByPostalCodeProximity.selectedIndex].value,30);
	
	//required for Locate GMC Commercial Dealers
	if((brandId == "GMC")&&(displayDealer == true)){
		createCookiesZIPCodeGCMSites();
	}
	
	//required only for Chevrolet
	if(brandId == "CHEVROLET"){
		createCookiesZIPCodeGCMSites();
	}
	
	//required only for Multibrand
	if(multiBrandEnabled){
		createCookiesZIPCodeGCMSites();
	}
}

//Create cookies required for the Zip Code search for GMC, Chevrolet and Multibrand sites
function createCookiesZIPCodeGCMSites(){
	createSBTCookie("sbtDealerTypeCode",document.SearchByZipCode.dealerTypeCode.value,30);
	createSBTCookie("sbtAgreementTypeCode",document.SearchByZipCode.agreementTypeCode.value,30);
	createSBTCookie("sbtProgramCode",document.SearchByZipCode.programCode.value,30);
	createSBTCookie("sbtProgramICON",document.SearchByZipCode.ProgramICON.value,30);
}

function createCookiesCityState(){
	eraseCookies();
	
	createSBTCookie("sbtCityName",document.SearchBycityState.SearchByCityStateCityName.value,30);
	createSBTCookie("sbtCityState",document.SearchBycityState.SearchByCityStateStateName.value,30);
	createSBTCookie("sbtCityProximity",document.SearchBycityState.SearchByCityStateProximity.value,30);
	
	//required for Locate GMC Commercial Dealers
	if((brandId == "GMC")&&(displayDealer == true)){
		createCookiesCityStateGCMSites();
	}
	
	//required only for Chevrolet
	if(brandId == "CHEVROLET"){		
		createCookiesCityStateGCMSites();
	}
	
	//required only for Multibrand
	if(multiBrandEnabled){
		createCookiesCityStateGCMSites();
	}
}

//Create cookies required for the City State search for GMC, Chevrolet and Multibrand sites
function createCookiesCityStateGCMSites(){
	createSBTCookie("sbtDealerTypeCode",document.SearchBycityState.dealerTypeCode.value,30);
	createSBTCookie("sbtAgreementTypeCode",document.SearchBycityState.agreementTypeCode.value,30);
	createSBTCookie("sbtProgramCode",document.SearchBycityState.programCode.value,30);
	createSBTCookie("sbtProgramICON",document.SearchBycityState.ProgramICON.value,30);
}

function createCookiesDealer(){
	eraseCookies();	
	
	createSBTCookie("sbtSearchDealerName",document.SearchByDealer.SearchByVendorVendorName.value,30);
	createSBTCookie("sbtCityNameDealer",document.SearchByDealer.SearchByVendorCityName.value,30);
	createSBTCookie("sbtCityStateDealer",document.SearchByDealer.SearchByVendorStateName.value,30);
	
	//required for Locate GMC Commercial Dealers
	if((brandId == "GMC")&&(displayDealer == true)){
		createCookiesDealerGCMSites();
	}
	
	//required only for Chevrolet
	if(brandId == "CHEVROLET"){
		createCookiesDealerGCMSites();
	}
	
	//required only for Multibrand
	if(multiBrandEnabled){
		createCookiesDealerGCMSites();
	}
}


//Update the cookies if the customer click on Update 
function updateSearchCookies(){
	if(document.forms["SearchRangeDL"].SearchType.value == "ByPostalCode"){
		updateSBTCookie("sbtZipCode",document.SearchRangeDL.SearchByPostalCodePostalCode.value,30);
		updateSBTCookie("sbtZipProximity",document.SearchRangeDL.SearchByPostalCodeProximity.value,30);
		}else if (document.forms["SearchRangeDL"].SearchType.value == "ByCityState"){
			updateSBTCookie("sbtCityName",document.SearchRangeDL.SearchByCityStateCityName.value,30);
			updateSBTCookie("sbtCityState",document.SearchRangeDL.SearchByCityStateStateName.value,30);
			updateSBTCookie("sbtCityProximity",document.SearchRangeDL.SearchByCityStateProximity.value,30);
			}else{
				updateSBTCookie("sbtSearchDealerName",document.SearchRangeDL.SearchByVendorVendorName.value,30);
				updateSBTCookie("sbtCityNameDealer",document.SearchRangeDL.SearchByVendorCityName.value,30);
				updateSBTCookie("sbtCityStateDealer",document.SearchRangeDL.SearchByVendorStateName.value,30);
				}
}

// Manages the Omniture Clicks
function clickTrack2(oArgs){
	for (var q in oArgs){
		if (window[q] != undefined) {
			window[q] = oArgs[q];
		}
	}
	// s_gs(s_account);
}

function manageClickDealerIndex(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | LOCATE DEALER | INDEX',s_prop1: 'DIVISIONAL', s_prop2: 'LOCATE DEALER', s_prop3: 'DIVISIONAL | LOCATE DEALER', s_prop11: 'INDEX', s_prop12: 'LOCATE DEALER | INDEX', s_prop13: 'DIVISIONAL | LOCATE DEALER | INDEX', s_prop25: brandId  });	
}

function manageClickDealer(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | LOCATE DEALER | DEALER LIST',s_prop1: 'DIVISIONAL', s_prop2: 'LOCATE DEALER', s_prop3: 'DIVISIONAL | LOCATE DEALER', s_prop11: 'DEALER LIST', s_prop12: 'LOCATE DEALER | DEALER LIST', s_prop13: 'DIVISIONAL | LOCATE DEALER | DEALER LIST', s_prop25: brandId  });	
}

function manageClickSI(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | LOCATE VEHICLE | SELECT VEHICLE',s_prop1: 'DIVISIONAL', s_prop2: 'LOCATE VEHICLE', s_prop3: 'DIVISIONAL | LOCATE VEHICLE', s_prop11: 'SELECT VEHICLE', s_prop12: 'LOCATE VEHICLE | SELECT VEHICLE', s_prop13: 'DIVISIONAL | LOCATE VEHICLE | SELECT VEHICLE', s_prop25: brandId  });		
}

function manageClickRQ(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | RAQ | SELECT VEHICLE',s_prop1: 'DIVISIONAL', s_prop2: 'RAQ', s_prop3: 'DIVISIONAL | RAQ', s_prop11: 'SELECT VEHICLE', s_prop12: 'RAQ | SELECT VEHICLE', s_prop13: 'DIVISIONAL | RAQ | SELECT VEHICLE', s_prop25: brandId  });		
}

function manageClickSATD(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | RAT | SELECT VEHICLE',s_prop1: 'DIVISIONAL', s_prop2: 'RAT', s_prop3: 'DIVISIONAL | RAT', s_prop11: 'SELECT VEHICLE', s_prop12: 'RAT | SELECT VEHICLE', s_prop13: 'DIVISIONAL | RAT | SELECT VEHICLE', s_prop25: brandId  });			
}

//Omniture when customer select a dealer which takes them to Select a Vehicle
function manageClickDVL(brandId){
	clickTrack2({s_pageName: brandId + ' | DIVISIONAL | LOCATE VEHICLE | SELECT VEHICLE',s_prop1: 'DIVISIONAL', s_prop2: 'LOCATE VEHICLE', s_prop3: 'DIVISIONAL | LOCATE VEHICLE', s_prop11: 'SELECT VEHICLE', s_prop12: 'LOCATE VEHICLE | SELECT VEHICLE', s_prop13: 'DIVISIONAL | LOCATE VEHICLE | SELECT VEHICLE', s_prop25: brandId  });			
}