var displayedOverlay;
var curLocation;
var modelArray = ['CSX', 'TSX', 'TL', 'RL', 'ZDX', 'RDX', 'MDX'];

function testDrive(submitform){
	window.open('blank.html', 'newTarget', 'height=650,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=740');
	tempForm= document.getElementById(submitform);
	tempForm.submit();
}
function backgroundInit() {var backgroundObj = document.getElementById('overlays');if(backgroundObj){ backgroundObj.style.height = document.body.scrollHeight + 'px';}}
window.onresize = backgroundInit;window.onload = backgroundInit;

function newWindow(url,name,features){
   var newWin = window.open(url,name,features);
	newWin.focus();
}
function openPreowned(lang) {
	newWindow('http://cuv.acura.ca/inventory/search?L='+lang,'preowned','width=800,height=600,scrollbars=yes,resizable=yes');
}

/* function openFinanceCalc(lang, lprovince, model, year) {
	if (lprovince==undefined || lprovince=='') lprovince=province;
	lang=(lang=='fr'?'F':'E');
	if (model==undefined || model=='') model='CSX';
	if (year==undefined || year=='') year='2009';

	newWindow('http://www.acura.ca/Acura2006/Financing/LeaseCalculator?modelname='+model+'&yr='+year+'&province='+lprovince +'&L='+lang,'calc','width=750,height=580,status=0,directories=0,scrollbars=0');
} */

function openFinanceCalc(lang, lprovince, model, year) {
	//if (lprovince==undefined || lprovince=='') var lprovince=province;
	//if (model==undefined || model=='') var model='CSX';
	//if (year==undefined || year=='') var year='2011';
	if (lang=='fr') {
		var href = 'http://www.acura.ca/location-financement/calculateur-de-paiements';
	}
	else {
		var href = 'http://www.acura.ca/lease-and-finance/payment-calculator';
	}
	window.open(href,'width=750,height=580,status=0,directories=0,scrollbars=yes');
	return false;
} 

function openGoogle(url) {
	newWindow(url,'google','width=750,height=580,status=0,directories=0,scrollbars=0');
}

function openBuildIt(url) {
	newWindow(url,'http://www.buildyouracura.ca','width=750,height=580,status=0,directories=0,scrollbars=yes');
}
function showModelInfo(selectedModel) {
	resetModelInfo();
	document.getElementById('close_popup').style.display='block';
	document.getElementById(selectedModel).style.display="block";
}
function resetModelInfo() {
	for( var i=0; i< modelArray.length; i++){
		document.getElementById(modelArray[i]).style.display='none'; 
	}
		document.getElementById('close_popup').style.display='none';
}
function resetDetailOfferOverDivs (currentOffer, totalOfferCount) {
	for (var i=1;i < totalOfferCount;i++) {
		lookupDiv='itemRollOverDiv'+i;	
		document.getElementById(lookupDiv).style.display='none';	
	}
		document.getElementById('itemRollOverDiv'+currentOffer).style.display='block';	
}

function closeOverlay(overlay) {
	document.getElementById('hero_offer').style.display='block';
	document.getElementById(overlay).style.display='none';
	document.getElementById('overlays').style.display='none';
	/*document.getElementById(curLocation).focus(); */
}

function showOverlay(overlay) {
	document.getElementById('hero_offer').style.display='none';
	document.getElementById(overlay).style.display='block';
	document.getElementById('overlays').style.display='block'
	newWin = overlay;
}

