function getElement(psID) {
   if(document.all) {
      return document.all[psID];
   } else {
      return document.getElementById(psID);
   }
}

/* BRAND LIST PAGE - FIRST PAGE */
function toggleLists(){
	var elm = getElement("ListList");
	if(elm.className=="hidden"){
		getElement("ListDropDown").className="hidden";
		elm.className="";
		getElement("showcase_switch_label").innerHTML = "Condense View";
	} else {
		getElement("ListDropDown").className="";
		elm.className="hidden";
		getElement("showcase_switch_label").innerHTML = "Expand View";
	}
}

function typeFilter(type){
	xmlhttpPost_showcase("controls/Showcase/Subpage/Main_TypeFilter.aspx", "", "Type=" + type, "typeFilter");
}

function updateMainPage(response) {
  var element = getElement("ShowcaseWrapper");
  if(element!=null) {
	element.innerHTML = response;
  }
  toggleLoad(0);
}

/* PRODUCT LIST PAGE - SECOND PAGE */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function showTab(idName){
	hideAll("singleType");
	unhighlightAll("infoList");
	getElement(idName).style.display='';
	getElement(idName+"_li").className = "activeTab";
}
function hideAll(className){
	var el = getElementsByClass(className);
	for(var x in el) if(el[x]!=null) el[x].style.display='none';
}
function unhighlightAll(parentName){
	var el = getElement(parentName);
	for(var i=0; i<el.childNodes.length; i++) {
		if(el.childNodes[i].nodeType==1)
			el.childNodes[i].className = '';
	}
}
/* SINGLE PRODUCT PAGE - THIRD PAGE */
function showpay() {
	if ((document.calc.loan.value == null || document.calc.loan.value.length == 0) || (document.calc.months.value == null || document.calc.months.value.length == 0) || (document.calc.rate.value == null || document.calc.rate.value.length == 0)) {
		var details = "";
		if(document.calc.loan.value == null || document.calc.loan.value.length == 0) details = "Loan amount";
		if(document.calc.months.value == null || document.calc.months.value.length == 0) details += ((details!="")?", " : "") + "Loan length";
		if(document.calc.rate.value == null || document.calc.rate.value.length == 0) details += ((details!="")?", " : "") + "Interest rate";
		alert(details + " field" + ((details.indexOf(",")>-1) ? "s have" : " has") + " not been completely filled out. Please verify that all fields are complete.");
	} else {
		var princ = (document.calc.loan.value>0) ? document.calc.loan.value : 1;
		var term  = (document.calc.months.value>0) ? document.calc.months.value : 1;
		var intr  = (document.calc.rate.value>0) ? document.calc.rate.value / 1200 : 0;
		document.calc.pay.value = (intr>0) ? Math.round(princ * intr / (1 - (Math.pow(1/(1 + intr), term)))) : Math.round(princ/term);
		document.calc.annualpay.value = (intr>0) ? (Math.round(princ * intr / (1 - (Math.pow(1/(1 + intr), term)))) *12) : Math.round(princ/(term/12));
	}
}
function show_info(showme){
	hideAll("ShowCaseContentChunk");
	unhighlightAll("infoList");
	getElement(showme).style.display='block';
	getElement(showme + "_li").className='activeTab';
}

function toggleViewThumbs(showAll){
	getElement("ShowcaseHeroThumbs").className = ((showAll) ? 'contactSheet' : 'scrolling');
	getElement("viewAll").style.display = ((showAll) ? 'none' : 'block');
	getElement("hideAll").style.display = ((showAll) ? 'block' : 'none');
}

function show_full(image, imgsource){
	getElement('LargeHeroLink').href = image;
	getElement('LargeHero').src = image;
	getElement('photoSource').innerHTML = imgsource;
}

function show_fullImage(imagea, imagesrc, imgsource){
	getElement('LargeHeroLink').href = imagea;
	getElement('LargeHero').src = imagesrc;
	getElement('photoSource').innerHTML = imgsource;
}

function viewAll(toggle){
	getElement('ShowcaseProductsDD').style.display = ((toggle) ? 'none' : '');
	getElement('ShowcaseProductsList').style.display = ((toggle) ? '' : 'none');
	getElement('viewToggle').innerHTML = "<a href=\"#\" onclick=\"viewAll(" + ((toggle) ? "0" : "1") + "); return false;\">" + ((toggle) ? "Condense View" : "View All") + "</a>";
}

var lastNote = '';
function showNote(name) {
	if(name == lastNote) { hideNote(name); return; }
	if(lastNote != '') { hideNote(lastNote); }
	lastNote = name;
	var body = getElement(name + '_body');
	body.className = 'notevisible';
	getElement("IEFRAMEFIX").style.display = 'block';
	checkScroll(body);
	forceDropDownWidths();
	//window.scrollTo(0,0);
}
function hideNote(name) {
	var body = getElement(name + '_body');
	body.className = 'notehidden';
	getElement("IEFRAMEFIX").style.display = 'none';
	lastNote = '';
}

var pageWrapperOffsetTop = 0;
function getOffsetTop(body) {
	if(pageWrapperOffsetTop==0){
		var node = body;
		while(node.parentNode.nodeName.toLowerCase()!='html') {
			pageWrapperOffsetTop += node.offsetTop;
			node = node.parentNode;
		}
	}
	return pageWrapperOffsetTop;
}
function checkScroll(body) {
	var scrollToTop = 0;
	var IEFRAMEFIX = getElement("IEFRAMEFIX");
	var wrapperBody = getElement("ShowcaseWrapper");
	if( typeof( window.innerWidth ) == 'number' ) {
		scrollToTop = window.pageYOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		scrollToTop = document.body.scrollTop;
		if(scrollToTop==0) scrollToTop = document.documentElement.scrollTop;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		scrollToTop = document.body.scrollTop;
		if(scrollToTop==0) scrollToTop = document.documentElement.scrollTop;
	}
	//var offsetTop = getOffsetTop(wrapperBody);
	var offsetTop = wrapperBody.offsetTop;
	var topval = (scrollToTop - offsetTop >= 0) ? scrollToTop - offsetTop: 0;
	var leftval = Math.round((wrapperBody.clientWidth/2)-(body.clientWidth/2));
	body.style.top = (topval+30) + "px";
	body.style.left = (leftval>30) ? leftval + "px" : "30px";
	IEFRAMEFIX.style.top = (topval+30) + "px";
	IEFRAMEFIX.style.left = (leftval>30) ? leftval + "px" : "30px";
	IEFRAMEFIX.style.height = body.offsetHeight;
}

function loadCheckBody(body) {
	var scrollToTop = 0;
	var wrapperBody = getElement("ShowcaseWrapper");
	if( typeof( window.innerWidth ) == 'number' ) {
		scrollToTop = window.pageYOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		scrollToTop = document.body.scrollTop;
		if(scrollToTop==0) scrollToTop = document.documentElement.scrollTop;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		scrollToTop = document.body.scrollTop;
		if(scrollToTop==0) scrollToTop = document.documentElement.scrollTop;
	}

	//var offsetTop = getOffsetTop(wrapperBody);
	//var topval = (Math.round(scrollToTop + 200) - offsetTop >= 0) ? Math.round(scrollToTop + 200) - offsetTop : 0;
	var offsetTop = wrapperBody.offsetTop;
	var topval = (scrollToTop - offsetTop >= 0) ? scrollToTop - offsetTop: 0;
	var leftval = Math.round((wrapperBody.clientWidth/2)-20);
	body.style.top = (topval + 200) + "px";
	body.style.left = (leftval>50) ? leftval + "px" : "50px";
}

function touchFrame(){
	var IEFRAMEFIX = getElement("IEFRAMEFIX");
	if(IEFRAMEFIX!=null){
		if(IEFRAMEFIX.style.display=='block'){
			IEFRAMEFIX.style.display = 'none';
			IEFRAMEFIX.style.display = 'block';
		} else {
			IEFRAMEFIX.style.display = 'none';
		}
	}
}

window.onscroll = touchFrame;


/* XMLPOST */
function xmlhttpPost_showcase(strURL, caller, query, transfer) {
	toggleLoad(1);
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (transfer=='productList')
			if (self.xmlHttpReq.readyState == 4) updateProductListPage(self.xmlHttpReq.responseText, caller);
		if (transfer=='comparefeatures')
			if (self.xmlHttpReq.readyState == 4) updateCompareFeatures_showcase(self.xmlHttpReq.responseText);
		if (transfer=='compare')
			if (self.xmlHttpReq.readyState == 4) updateCompare_showcase(self.xmlHttpReq.responseText, caller);
		if (transfer=='regions')
			if (self.xmlHttpReq.readyState == 4) updatePage_showcase(self.xmlHttpReq.responseText, caller);
		if (transfer=='raq')
			if (self.xmlHttpReq.readyState == 4) imbeddedFormSubmitReturn(self.xmlHttpReq.responseText, caller);
		if (transfer=='typeFilter')
			if (self.xmlHttpReq.readyState == 4) updateMainPage(self.xmlHttpReq.responseText);
	}
	self.xmlHttpReq.send('sid=' + Math.random() + "&" + query);
}

function comparativeFeatureValueChanged(productOwnerId, value, caller, elementToUpdate, hasOptionsFlag){
	if(value!="-1"){
		var lastDigitOfElement = elementToUpdate.substring(elementToUpdate.length-1,elementToUpdate.length);
		if(caller=="showcase_compare_year") xmlhttpPost_showcase("controls/Showcase/Subpage/Compare_GetProductOwners.aspx", elementToUpdate, "id=" + productOwnerId + "&year=" + value, "compare");
		var year = getElement("showcase_compare_year_" + lastDigitOfElement);
		if(caller=="showcase_compare_po" && (year!=null || hasOptionsFlag==1)) xmlhttpPost_showcase("controls/Showcase/Subpage/Compare_GetStyles.aspx", elementToUpdate, "id=" + productOwnerId + "&year=" + ((year!=null) ? year.value : "") + "&poId=" + value, "compare");
		var po = getElement("showcase_compare_po_" + lastDigitOfElement);
		if(caller=="showcase_compare_style" && (year!=null || hasOptionsFlag==1) && po!=null) xmlhttpPost_showcase("controls/Showcase/Subpage/Compare_GetModels.aspx", elementToUpdate, "id=" + productOwnerId + "&year=" + ((year!=null) ? year.value : "") + "&poId=" + po.value + "&styleId=" + value, "compare");
		if(caller=="showcase_compare_model") xmlhttpPost_showcase("controls/Showcase/Subpage/Compare_GetOptions.aspx", elementToUpdate, "id=" + value, "compare");
	}
}

var strIds = "";
var compareType = "";
function showfeatures(id, type) {
	compareType = type;
	var areOptions = (type=="option");
	var id0 = getElement("showcase_compare_option_0");
	var id1 = getElement("showcase_compare_" + type + "_1");
	var id2 = getElement("showcase_compare_" + type + "_2");
	if(areOptions && id0!=null && id0.value=="-1") id0.selectedIndex = 1;
	strIds = ((id0!=null && id0.value!="-1") ? id0.value : id) + ((id1!=null && id1.value!="-1") ? "," + id1.value : "") + ((id2!=null && id2.value!="-1") ? "," + id2.value : "");
	if(strIds!=id) {
		xmlhttpPost_showcase("controls/Showcase/Subpage/Compare_GetFeatures.aspx", "", "products=" + strIds + "&areOptions=" + areOptions, "comparefeatures");
	}
	var element = getElement("showcase_compare_print_link");
	element.onclick = showCompareModelsPopup;
}

function showCompareModelsPopup() {
	var areOptions = (compareType=="option");
	var popup = window.open('showcaseprintprodcompare.htm?products=' + strIds + '&areOptions=' + areOptions, '_blank');
	popup.focus();
	return false;
}

function updateCompareFeatures_showcase(response) {
	var element = getElement("showcase_compare_features");
	if(element!=null) {
		element.innerHTML = response;
	}
	toggleLoad(0);
}

function updateCompare_showcase(response, caller){
	var element = getElement(caller);
	var yElement = getElement("showcase_compare_year_1");
	if(yElement==null) yElement = getElement("showcase_compare_po_1");
	var myWidth = yElement.offsetWidth;
	innerHTMLSelectFix(element,response);
	element.style.width = myWidth + 'px';
	$('#' + caller).selectbox();
	toggleLoad(0);
}

function getRegions_showcase(country, caller) {
	xmlhttpPost_showcase("controls/Showcase/Subpage/SinglePage_GetRegions.aspx", caller, "country_name=" + country, "regions");
}

function forceDropDownWidths(){
	var rb_txtFirstName = getElement("rb_txtFirstName");
	if(rb_txtFirstName!=null){
		var rb_offsetWidth = rb_txtFirstName.offsetWidth;
		var rb_cmbCountry = getElement("rb_cmbCountry");
		if(rb_cmbCountry!=null) rb_cmbCountry.style.width = rb_offsetWidth + 'px';
		var rb_cmbRegion = getElement("rb_cmbRegion");
		if(rb_cmbRegion!=null) rb_cmbRegion.style.width = rb_offsetWidth + 'px';
	}
	var rq_txtFirstName = getElement("rq_txtFirstName");
	if(rq_txtFirstName!=null){
		var rq_offsetWidth = rq_txtFirstName.offsetWidth;
		var rq_cmbCountries = getElement("rq_cmbCountries");
		if(rq_cmbCountries!=null) rq_cmbCountries.style.width = rq_offsetWidth + 'px';
		var rq_cmbRegions = getElement("rq_cmbRegions");
		if(rq_cmbRegions!=null) rq_cmbRegions.style.width = rq_offsetWidth + 'px';
	}
}

function updatePage_showcase(response, caller) {
	var element = getElement(caller);
	var compareSize = (caller.indexOf("rb_")>-1) ? getElement("rb_txtFirstName") : getElement("rq_txtFirstName");
	var myWidth = compareSize.offsetWidth;
	//element.innerHTML = response;
	innerHTMLSelectFix(element,response);
	element.style.width = myWidth + 'px';
	toggleLoad(0);
}

/* PRE-VALIDATE */
function trim(input) {
	return input.replace(/^\s*/, "").replace(/\s*$/, "");
}

function clearOnClose(caller){
	if(caller=="raqs"){
		var allElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtConfirmEmail", "rq_txtColor", "rq_txtDayPhone", "rq_txtEveningPhone", "rq_txtComments", "rq_cmbTimeframeToPurchase", "rq_checkIncludeExtendedWarranty", "rq_checkWithTrade", "rq_txtTradeManufacturer", "rq_txtTradeModel", "rq_txtTradeUse", "rq_txtTradeYear", "rq_cmbTradeCondition", "rq_txtPostalCode", "rq_txtVehicleYear", "rq_txtVehicleMake", "rq_txtVehicleModel", "rq_txtVehicleStyle", "rq_txtTireSize", "rq_txtAddress1", "rq_txtAddress2", "rq_txtCity", "rq_cmbRegions", "rq_stockNumber");
	} else {
		var allElements=new Array("rb_txtFirstName", "rb_txtLastName", "rb_txtEmailAddress", "rb_txtEmailAddressConfirmation", "rb_txtAddress1", "rb_txtAddress2", "rb_txtCity", "rb_txtPostalCode");
	}
	var element = null;
	for(var x in allElements) {
		element = getElement(allElements[x]);
		if(element!=null) {
			if(element.type!="checkbox") {
				if(x!="rq_cmbRegions") {
					element.value = "";
				} else {
					element.selectedIndex = 0;
				}
			} else element.checked = false;
		}
	}
	toggleWithTrade(false);
}

function preValidateForm(caller, year, brand, name, productType) {
	var hasErrors = false;
	var EmptyElements = "";
	if(caller.id.indexOf("rq")>-1){
		if(getElement("rq_checkWithTrade")!=null && getElement("rq_checkWithTrade").checked) {
			var requiredElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtConfirmEmail", "rq_txtDayPhone", "rq_txtTradeManufacturer", "rq_txtTradeModel", "rq_txtTradeUse", "rq_txtTradeYear");
			var requiredElmNames=new Array("First Name", "Last Name", "Email", "Confirmation Email", "Phone", "Trade Manufacturer", "Trade Model", "Years Owned", "Trade Year");
		} else if(getElement("rq_txtVehicleYear")!=null) {
			var requiredElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtConfirmEmail", "rq_txtDayPhone", "rq_txtVehicleYear", "rq_txtVehicleMake", "rq_txtVehicleModel", "rq_txtVehicleStyle");
			var requiredElmNames=new Array("First Name", "Last Name", "Email", "Confirmation Email", "Phone", "Vehicle Year", "Vehicle Manufacturer", "Vehicle Model", "Vehicle Style");
		} else {
			var requiredElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtConfirmEmail", "rq_txtDayPhone");
			var requiredElmNames=new Array("First Name", "Last Name", "Email", "Confirmation Email", "Phone");
		}
		var allElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtColor", "rq_txtDayPhone", "rq_txtComments", "rq_cmbTimeframeToPurchase", "rq_checkIncludeExtendedWarranty", "rq_checkWithTrade", "rq_txtTradeManufacturer", "rq_txtTradeModel", "rq_txtTradeUse", "rq_txtTradeYear", "rq_cmbTradeCondition", "rq_txtVehicleYear", "rq_txtVehicleMake", "rq_txtVehicleModel", "rq_txtVehicleStyle", "rq_txtTireSize", "rq_txtAddress1", "rq_txtAddress2", "rq_txtCity", "rq_cmbRegions", "rq_cmbCountries", "rq_txtPostalCode", "rq_stockNumber");
		var urlString = "controls/Showcase/Subpage/SinglePage_SendQuoteRequest.aspx";
		var email = getElement("rq_txtEmail");
		var confirmEmail = getElement("rq_txtConfirmEmail");
	} else {
		var requiredElements=new Array("rb_txtFirstName", "rb_txtLastName", "rb_txtEmailAddress", "rb_txtEmailAddressConfirmation", "rb_txtAddress1", "rb_txtCity", "rb_txtPostalCode");
		var requiredElmNames=new Array("First Name", "Last Name", "Email", "Confirmation Email", "Address", "City", "Postal Code");
		var allElements=new Array("rb_txtFirstName", "rb_txtLastName", "rb_txtEmailAddress", "rb_txtAddress1", "rb_txtAddress2", "rb_txtCity", "rb_cmbRegion", "rb_cmbCountry", "rb_txtPostalCode");
		var urlString = "controls/Showcase/Subpage/SinglePage_SendBrochureRequest.aspx";
		var email = getElement("rb_txtEmailAddress");
		var confirmEmail = getElement("rb_txtEmailAddressConfirmation");
	}
	var element = null;
	for(var x in requiredElements) {
		element = getElement(requiredElements[x]);
		if(element!=null && trim(element.value)=="") {
			hasErrors = true;
			EmptyElements += ((EmptyElements!="") ? ", " : "") + requiredElmNames[x];
		}
	}
	if(!hasErrors) {
		if(brand==undefined || brand=="" || name==undefined || name=="") {
			alert("Brand, and/or Product Name are empty.  Please reload the page.");
		} else {
			if(email!=null && confirmEmail!=null && email.value.toLowerCase()==confirmEmail.value.toLowerCase()) {
				if(caller.id.indexOf("rq")>-1){
					var queryString = "rq_year=" + escape(year) + "&rq_brand=" + escape(brand) + "&rq_name=" + escape(name) + "&" + "rq_productType=" + ((productType!=undefined && productType!="") ? productType : "new") + "&";
				} else {
					var queryString = "rb_year=" + escape(year) + "&rb_brand=" + escape(brand) + "&rb_name=" + escape(name) + "&" + "rb_productType=" + ((productType!=undefined && productType!="") ? productType : "new") + "&";
				}
				for(var x in allElements) {
					element = getElement(allElements[x]);
					if(element!=null) {
						queryString += element.id + "=" + ((element.type!="checkbox") ? escape(element.value) : element.checked) + "&";
					}
				}
				xmlhttpPost_showcase(urlString, caller.id, queryString, "raq");
			} else {
				alert("Email addresses do not match, please verify that they are correct and submit the form again.");
			}
		}
	} else {
		alert(EmptyElements + ((EmptyElements.indexOf(",")>-1)? " are empty. These fields are" : " is empty. This field is") + " required, please double check your form and submit it again.");
	}
}

function imbeddedFormSubmitReturn (response, caller) {
	if(response.substring(0,2)=="1:") {
		alert(response.substring(2));
	} else {
		if(caller.indexOf("rq_")>-1){
			var allElements=new Array("rq_txtFirstName", "rq_txtLastName", "rq_txtEmail", "rq_txtConfirmEmail", "rq_txtColor", "rq_txtDayPhone", "rq_txtEveningPhone", "rq_txtComments", "rq_cmbTimeframeToPurchase", "rq_checkIncludeExtendedWarranty", "rq_checkWithTrade", "rq_txtTradeManufacturer", "rq_txtTradeModel", "rq_txtTradeUse", "rq_txtTradeYear", "rq_cmbTradeCondition", "rq_txtPostalCode", "rq_txtVehicleYear", "rq_txtVehicleMake", "rq_txtVehicleModel", "rq_txtVehicleStyle", "rq_txtTireSize", "rq_txtAddress1", "rq_txtAddress2", "rq_txtCity", "rq_cmbRegions", "rq_stockNumber");
		} else {
			var allElements=new Array("rb_txtFirstName", "rb_txtLastName", "rb_txtEmailAddress", "rb_txtEmailAddressConfirmation", "rb_txtAddress1", "rb_txtAddress2", "rb_txtCity", "rb_txtPostalCode");
		}
		hideNote(((caller.indexOf("rq_")>-1) ? "raqs" : "rab"));
		var element = getElement("response_body_contents");
		element.innerHTML = response;
		showNote("response");
		for(var x in allElements) {
			element = getElement(allElements[x]);
			if(element!=null) {
				if(element.type!="checkbox") element.value = "";
				else element.checked = false;
			}
		}
	}
	toggleLoad(0);
}

function toggleWithTrade(value) {
	var element = getElement("rq_withTradeRow");
	element.style.display = ((value) ? "" : "none");
}


/* IE INNER HTML BUG FIX */
function innerHTMLSelectFix(element,innerHTML){
	element.innerHTML = "";
	//creating phantom element to receive temp innerHTML
	var selTemp = document.createElement("micoxselect");
	var opt;
	selTemp.id="micoxselect1";
	document.body.appendChild(selTemp);
	selTemp = document.getElementById("micoxselect1");
	selTemp.style.display="none";
	if(innerHTML.toLowerCase().indexOf("<option")<0){
		innerHTML = "<option>" + innerHTML + "</option>";
	}
	innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span");
	selTemp.innerHTML = innerHTML;
	for(var i=0;i<selTemp.childNodes.length;i++){
		if(selTemp.childNodes[i].tagName){
			opt = document.createElement("OPTION");
			for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
				opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true));
			}
			opt.value = selTemp.childNodes[i].getAttribute("value");
			opt.text = selTemp.childNodes[i].innerHTML.replace("&nbsp;", " ");
			opt.text = selTemp.childNodes[i].innerHTML.replace("&amp;", "&");
			if(document.all){ //IEca
				element.add(opt);
			}else{
				element.appendChild(opt);
			}
		}
	}
	document.body.removeChild(selTemp);
	selTemp = null;
}

/* Product list page, get tabs - pulled out to eliminate load times */
//showcaseProductListFieldset
function showTabs(brand, type, year, hash){
	//hideAll("singleType");
	//unhighlightAll("infoList");
	//getElement(idName).style.display='';
	//getElement(idName+"_li").className = "activeTab";
	//CALL METHOD TO ASPX FILE TO LOAD NEW CONTENT
	xmlhttpPost_showcase("controls/Showcase/Subpage/ProductList_GetTab.aspx", ((hash!="") ? hash : type), "Brand=" + brand + "&Type=" + type + "&Year=" + year, "productList");
}

function updateProductListPage(response, hash) {
	var element = getElement("showcaseProductListFieldset");
	if(element!=null) element.innerHTML = response;
	if(hash!="") {
		if(hash.toString().indexOf("#")>-1) {
			location.hash = hash.toString();
		} else {
			var quicksearchElm = getElement("quicksearch_type");
			if(quicksearchElm!=null && hash!=-1) {
				var indexOfType = -1;
				for(var x = 0; x < quicksearchElm.options.length; x++) {
					if(quicksearchElm.options[x]!=null && quicksearchElm.options[x].value == hash) {
						indexOfType = x;
						break;
					}
				}
				if(indexOfType!=-1) {
					quicksearchElm.selectedIndex = indexOfType;
				}
			}
		}
	}
	toggleLoad(0);
}

function toggleLoad(value){
	var elm = getElement("load");
	if(elm!=null) {
		elm.style.display = (elm.style.display=='none' || value==1) ? 'block' : 'none';
		if(value==1) loadCheckBody(elm);
	}
}