var tireOffer = false;
var rdoOffers = "tir";
function centerDiv(){

	var divCenter = document.getElementById("frameReport");

	var width = 0;
	var height = 0;
	var scrollTop = 0;
	var scrollLeft = 0;

	if (typeof  window.innerWidth == "undefined"){
		// Internet Explorer 7
		width= parseInt(document.body.clientWidth);
		height= parseInt(document.body.clientHeight);
		scrollTop = document.documentElement.scrollTop;
		scrollLeft = document.documentElement.scrollLeft;
	}
	else {
		//Fire Fox
		width= parseInt(window.innerWidth);
		height= parseInt(window.innerHeight);

		scrollTop = window.pageYOffset;
		scrollLeft = window.pageXOffset;
	}

	var leftValue = parseInt(width/2 - divCenter.offsetWidth/2) + scrollLeft;
	var topValue =  parseInt(height/2 - divCenter.offsetHeight/2) + scrollTop;

	if (leftValue < 0){
		leftValue = 0;
	}
	if (topValue < 0){
		topValue = 0;
	}
	divCenter.style.left = leftValue+"px";
	if (tireOffer == true ){
		divCenter.style.top =  topValue+"px";
	}
}

function showReport(){
	var myObj = document.getElementById('SearchByPostalCodePostalCodePopup');
	var cookieVal = GetCookie('dealerZip');

	if(cookieVal == null){
			myObj.value = 'Enter Zip Code';
	}
	else
		myObj.value = cookieVal;

	var overlay = document.getElementById("overlay");
	var frameReport = document.getElementById("frameReport");

	overlay.style.display = "block";
	frameReport.style.display = "block";

	centerDiv(tireOffer);
}


function showReportFromMastHead(){
	rdoOffers = "all";
	showReport();
}


function closeReport(){
	var overlay = document.getElementById("overlay");
	var frameReport = document.getElementById("frameReport");

	frameReport.style.display = "none";
	overlay.style.display = "none";
}
function setFuntions(tireOffervalue){
	if (tireOffervalue != null)
		tireOffer = tireOffervalue;
	window.onscroll = centerDiv;
	window.onresize = centerDiv;
}

// show and hide the div with id = divId
function showHideDiv(divId){
	var divObj = null;
	divObj = document.getElementById(divId);

	if(divObj.style.display == "block"){
		divObj.style.display = "none";
	}
	else{
		divObj.style.display = "block";

	}
}

function showDiv (divId){
	var divObj = null;
	divObj = document.getElementById(divId);

	if(divObj != null){
		if(divObj.style.display != "block"){
			divObj.style.display = "block";
		}
	}
}

function hideDiv (divId){
	var divObj = null;
	divObj = document.getElementById(divId);

	if(divObj != null){
		if(divObj.style.display != "none"){
			divObj.style.display = "none";
		}
	}
}

function clearCriteria(searchOption){

	if(searchOption == "zipcode" || searchOption == "dealername"){
		/*clear by city*/
		document.getElementById("SearchByCityStateCityName").value = "Enter City";
		document.getElementById("state").value = "";
		document.getElementById("SearchByCityStateProximity").value = "25";
	}
	if(searchOption == "city" || searchOption == "dealername"){
		/*clear by zip code*/
		document.getElementById("SearchByPostalCodePostalCode").value = "Enter zip code";
		document.getElementById("SearchByPostalCodeProximity").value = "25";
	}
	if(searchOption == "city" || searchOption == "zipcode"){
		/*clear by dealer name*/
		document.getElementById("SearchByVendorVendorName").value = "Enter Dealer Name";
		document.getElementById("dealerstate").value = "";

	}


}
//Show image
function changeImage(divImageId, show, hide){
	var imageObj = document.getElementById(divImageId);

	var imageName=imageObj.src;

	if (imageName.indexOf(show+".") > 0){
		 imageName = imageName.replace(show+".", hide+".");
	}
	else {
		imageName = imageName.replace(hide+".", show+".");
	}
	imageObj.src= imageName;
}

//OPEN POP WARNING
function closeOpen(){
	myRef = window.open("../pop.jsp?url=http://www.goodyeartires.com/cfmx/web/gytires/promotions/GM/index.cfm ",'mywin','left=20,top=20,width=360,height=181,toolbar=0,resizable=0');
}


function expandTopNav(){
	var topNav = document.getElementById("inner_wrap");
	topNav.style.height="500px";
	topNav.style.zIndex="10000";
	//alert('expand');
}

function contractTopNav(){
	var topNav = document.getElementById("inner_wrap");
	topNav.style.height= Topbanner;
	topNav.style.zIndex="0";
	//alert('contract');
}

// SHOW, HIDE TWO BETWEEN TWO TABS
function switchTab(show, hide){
	var showObj = document.getElementById(show);
	var hideObj = document.getElementById(hide);

	showObj.style.display = "block";
	hideObj.style.display = "none";
}
