/* GLOBAL VARS */
var objDivLastShown; // used for to switch off last shown divs
var objFindDiv; // right background layer

/* simple dom constructor */
function getRef(id) {
	return (document.getElementById ? document.getElementById(id) : document.all[id]); 
}

/* initialize variables and objects */
function homeInit() {
	objFindDiv = getRef("findTop");
	objDivLastShown = null;
	// set empty cookie to clear the dealer search results pagination value
	set_cookie('dlr_page',1);
}


/* display the selected tire locator div */
function homeFindDiv(id) {
	
	switch (id) {
		case "findVhc":
			// display disabled select boxes and button
			dis_select('make');
			dis_select('model');
			dis_select('year');
			dis_select('option');
			dis_button("by-vehicle-btn");
			
			if (make.length>0 && model.length>0 && year.length>0 && option.length>0) {
				// prepopulate boxes with vehicle data
				show_items_preselected();
			}else{
				// populate the 'make' select box
				show_items('year','years');
			}
			break;
		case "findTsz":
			// display disabled select boxes and button
			dis_select('tireSizeType');
			dis_select('tireSectionWidth');
			dis_select('tireAspectRatio');
			dis_select('tireRimDiameter');
			dis_button("tire-size-btn");
			// populate the 'tireSectionWidth' select box
			//show_items('tireSectionWidth','widths');
			show_items('tireSizeType','types');
			break;
		case "findTnm":
			// display disabled select boxes and button
			dis_select('prodId');
			dis_button("tire-name-btn");
			// populate the 'prodId' select box
			show_tire_names('prodId');
			break;
	}
	
	var objTheDiv = getRef(id);
		
	// turn off the last shown div if exists
	if (objDivLastShown != null) {
		objDivLastShown.style.visibility = "hidden";
	}
	objDivLastShown = objTheDiv; // div to hide on next pass		
	
	objFindDiv.style.visibility = "visible";
	objTheDiv.style.visibility = "visible";
}


/* hide the currently displayed tire locator div */
function slideOff() {
	objDivLastShown.style.visibility = "hidden";
	objFindDiv.style.visibility = "hidden";
}


/* load the specified iframe with the specified source */
function loadTireFrame(theIframe, thePage) {
	var theFrame = getRef(theIframe);
	theFrame.src = thePage;
}