var lastGoodQty = '';
var imageNum = 1;
var skuPhotoSelected = -1;
var borderFade = 0;
var borderFadeDelay = 5;
var borderFadeSteps = 5;
var hiLiteVarient = '';
var varientSelected = false;
var leftBoxHeight = 0;
var skuIndex = -1;

function productDetailOnLoad() {
	document.getElementById("tabs").style.display = "block";
	initAltText();
	if(productCombo) {updatedata();}
	if (dailySpecial) {countDown();}
	leftBoxHeight = parseInt(document.getElementById('leftBox').offsetHeight);
	matchBoxHeight('des');
	if (document.images) {
		preload_400 = new Array();
		preload_1200 = new Array();
		for (i=1;i<photoName.length;i++) {
			preload_400[i] = new Image();
			preload_1200[i] = new Image();
			preload_400[i].src = static2url + "/images400/"+manprodcode+photoName[i]+".jpg";
			if(photoZoom[i]) {preload_1200[i].src = static1url + "/imagesLarge/"+manprodcode+photoName[i]+".jpg";}
		}
	}
}
function validQty(sText) {
   var validChars = "0123456789";
   var isValid=true;
   var qchar;

   for (i = 0; i < sText.length && isValid == true; i++) 
   { 
      qchar = sText.charAt(i); 
      if (validChars.indexOf(qchar) == -1) {isValid = false;}
   }
   if (sText.length > 2) {isValid = false;}
   return isValid;
}

function checkQty() {
	if (document.getElementById("qty")) {
		var qtyForm = document.getElementById("qty");
		if (validQty(qtyForm.value)) {
			lastGoodQty = qtyForm.value;
		}
		else {
			qtyForm.value = lastGoodQty;
		}
	} else {lastGoodQty = '';}
	if (pricevaries == true) {updateMSRP();}
	if(lastGoodQty.length > 0 || pricedisplay == 1) {showPrice();} else {hidePrice();}
	if (varientType > 0 && !productCombo) {
		if (!varientSelected && inStock) {
			skuInStock = true;
			showInStock();
		} else {
			if(qtyAvail[skuIndex] >= minInventory){
				skuInStock = true;
				showInStock();
			} else {	
				if (specialOrder[skuIndex]) {
					skuInStock = true;
					showSpecialOrder();
				} else {
					skuInStock = false;
					showNotifyMe();
				}
			}
		}
	}
	if (varientType > 0 && productCombo) { }
	if (varientType == 0 && productCombo) {
		if (comboInStock > 0) {
			skuInStock = true;
			showInStock();
		} else {
			skuInStock = false;
			showNotifyMe();
			document.getElementById("stockNote").innerHTML = "This configuration is currently out of stock. Select the Customize tab below to change your options or click on the Email Me button below for availability.";
		}
			
	}
	if (varientType > 0){
	//	console.log('skuIndex='+skuIndex);
	//	console.log('skuPhoto='+skuPhoto[skuIndex]);
		
		if (skuPhoto[skuIndex] > 0 && document.getElementById("thumb"+skuPhoto[skuIndex])) {
			if(skuPhotoVersion[skuIndex]==0) {displayImage(document.getElementById("partno").value.substr(0,5),skuPhoto[skuIndex]);}
			if(skuPhotoVersion[skuIndex]>0) {displayImage(document.getElementById("partno").value.substr(0,5)+skuPhotoVersion[skuIndex],skuPhoto[skuIndex]);}
			skuPhotoSelected = skuPhoto[skuIndex];
		} else {
			skuPhotoSelected = -1;
		}
//		Highlight the specifications for this varient
		if (hiLiteVarient.length == 7) {
			var hli = 0;
			while (document.getElementById(hiLiteVarient + hli)) {
				document.getElementById(hiLiteVarient+hli).style.color = "#4D606C";
				hli++;
			}
		}
		if (skuIndex>0) {
			hiLiteVarient = document.getElementById("partno").value.substr(5);
			var hli = 0;
			while (document.getElementById(hiLiteVarient + hli)) {
				document.getElementById(hiLiteVarient+hli).style.color = "#c81c22";
				hli++;
			}
		}
	}
}

function fadeToGold(thumbNum) {
	borderFade++;
//	console.log('borderFade='+borderFade);
	if(borderFade>borderFadeDelay) {
		var red = parseInt(255*(borderFadeSteps-(borderFade-borderFadeDelay))/borderFadeSteps + 25*(borderFade-borderFadeDelay)/borderFadeSteps);
		var green = parseInt(60*(borderFade-borderFadeDelay)/borderFadeSteps);
		var blue = parseInt(142*(borderFade-borderFadeDelay)/borderFadeSteps);
		document.getElementById("thumb"+thumbNum).style.borderColor = "rgb("+red+","+green+","+blue+")";
	}
//	console.log('bordercolor='+document.getElementById("thumb"+thumbNum).style.borderColor);
	if (borderFade<(borderFadeSteps+borderFadeDelay)) {setTimeout("fadeToGold("+thumbNum+");",100);}
}
function showInStock() {
	document.getElementById("instock").innerHTML = "&nbsp;-&nbsp;In Stock";
	document.getElementById("instock").style.color = "#808080";
	document.getElementById("stockNote").style.display="none";	
//	document.getElementById("stockMsg").style.width = "200px";
	document.getElementById("addtocartImage").src = "/images/28x154-cart-button.gif";
	document.getElementById("qtyBox").style.display = "inline-block";
}

function showSpecialOrder() {
	if (document.getElementById("icon")) {document.getElementById("icon").style.display = "none";}
	document.getElementById("instock").innerHTML = "&nbsp;-&nbsp;Special Order";
	document.getElementById("instock").style.color = "#808080";
	document.getElementById("qtyBox").style.display = "none";
	document.getElementById("stockNote").style.display="inline-block";
//	document.getElementById("stockMsg").style.width = "280px";
	document.getElementById("addtocartImage").src = "/images/28x154-cart-button.gif";
	document.getElementById("stockNote").innerHTML = "The color/size you selected is a special order item but is usually available within a few days. We will contact you with order confirmation.";

}

function showNotifyMe() {
	document.getElementById("instock").innerHTML = "&nbsp;-&nbsp;Out of Stock";
	document.getElementById("instock").style.color = "#AE0F21";
	document.getElementById("qtyBox").style.display = "none";
	document.getElementById("stockNote").style.display="inline-block";
//	document.getElementById("stockMsg").style.width = "280px";
	document.getElementById("addtocartImage").src = "/images/28x264-email-button.gif";	
	document.getElementById("stockNote").innerHTML = "Sorry, but the color/size you selected is currently out of stock. Click the Email Me button below to be informed when the item is back in stock.";

}
	
function selectVarient(vc,mpc,qty) {
	if (varientSelected) {
		document.getElementById("s_"+selectedVarientId).src = "http://www.bicycletires.com/images/unselectedBox.gif";
		document.getElementById("li_"+selectedVarientId).style.fontWeight = "normal";
	}
	varientcode = vc;
	manprodcode = mpc;
	for(i=0;i<=skuVarient.length;i++) {	
		if (skuVarient[i] == varientcode) {skuIndex = i;}
	}	
	varientSelected = true;
	selectedVarientId = vc;
	document.getElementById("partno").value = manprodcode + varientcode;
	document.getElementById("s_"+selectedVarientId).src = "http://www.bicycletires.com/images/selectedBox.gif";
	document.getElementById("li_"+selectedVarientId).style.fontWeight = "bold";
	checkQty();
}

function updateMSRP() {
	for(i=0;i<=msrps.length;i+=1) {
		if(skuVarient[i] == document.getElementById("partno").value.substr(5)) {msrpPrice = msrps[i];}
	}
	if (document.getElementById("partno").value == "") {msrpPrice = minMSRP;}
	document.getElementById("msrp").innerHTML =  formatCurrency(msrpPrice)
}

function showPrice() {
	var discountPrice = ourprice;
	var qtyCalc;
	if (lastGoodQty.length > 0) {qtyCalc = parseInt(lastGoodQty);} else {qtyCalc = 1;}
	if(pricevaries == true) {
		for(i=0;i<=prices.length;i+=1) {
			if(skuVarient[i] == document.getElementById("partno").value.substr(5)) {discountPrice = prices[i]}
		}
//		if (document.getElementById("partno").value.length == 0) {
//			document.getElementById("pricetext").innerHTML = "Low<br />As:&nbsp;&nbsp;&nbsp;&nbsp;";
//		} else {
//			document.getElementById("pricetext").innerHTML = "Your<br />Price:&nbsp;";
//		}
	}
	var qdiscount = 0;
	for(i=0;i<=quanBreak.length;i+=1) {
		if (qtyCalc >= quanBreak[i]) {qdiscount = quanDisc[i];}
	}

	discountPrice = discountPrice*(1-qdiscount);
	discountPrice = roundCurrency(discountPrice);
	var totalDiscount = 0;
	if (msrpPrice > 0 ) {totalDiscount = 100*((msrpPrice-discountPrice)/msrpPrice)+0.01;}
	var totalPrice = discountPrice*qtyCalc;
	if(totalDiscount >= showDiscPercent || (msrpPrice-discountPrice) >= showDiscDollar) {
		document.getElementById("savingsinfo").style.visibility = "visible";
		document.getElementById("savings").innerHTML = formatCurrency(qtyCalc*msrpPrice-totalPrice) + ' (' + parseInt(totalDiscount) + '%)'; 
		document.getElementById("msrptext").innerHTML = "List Price:";
		document.getElementById("msrptext").style.visibility = "visible";
		document.getElementById("msrp").innerHTML = formatCurrency(msrpPrice);	
	} else {
		document.getElementById("savingsinfo").style.visibility = "hidden";
		document.getElementById("savings").innerHTML = "";
		document.getElementById("msrptext").innerHTML = "";
		document.getElementById("msrptext").style.visibility = "hidden";
		document.getElementById("msrp").innerHTML = "";
	}
	document.getElementById("price").innerHTML = formatCurrency(discountPrice);
	document.getElementById("units").style.visibility = "visible";
	
	
}
function hidePrice() {
	if (pricedisplay == 1) {
		if (pricevaries == false) {document.getElementById("pricetext").innerHTML = "Your<br />Price:";}
		if (pricevaries == true) {document.getElementById("pricetext").innerHTML = "Low<br />As:&nbsp;&nbsp;&nbsp;&nbsp;";}
		document.getElementById("price").innerHTML = ourprice;
	}
	if (pricedisplay ==2) {
		document.getElementById("price").innerHTML = "$$$$";
		document.getElementById("units").style.visibility = "hidden";
		document.getElementById("earnVIP").style.display = "none";
		document.getElementById("enterQty").style.display = "block";
		document.getElementById("priceCalc").innerHTML = "";
		document.getElementById("priceinfo2").style.height = "59px";
		document.getElementById("priceinfo2").style.backgroundImage = "url(/images/292x59-box.gif)";
	}
}

function addToCart() {
	if (!skuInStock) {outOfStock();return false;}
	if(document.getElementById("partno").value == "") {
		alert("Please select color and/or size");
		return false;
	}
	if(document.getElementById("qty").value == "" && skuInStock) {
		alert("Please select a quantity");
		return false;
	}
	document.getElementById("prodform").submit();
}
function clearEmailBox()
{	
	if (document.outofstock.notifyemail.value == 'Your email')
	{
		document.outofstock.notifyemail.value = ''
	}
	return true;
}

function displayImage(mpc,pic) {
	if(document.getElementById("prodImage")) {
		document.getElementById("prodImage").src = static2url + "/images400/"+mpc+"-"+String(pic)+".jpg";
		document.getElementById("prodImage").alt = document.getElementById("thumb"+pic).alt;
		document.getElementById("prodImage").title = document.getElementById("thumb"+pic).title;
		document.getElementById("zoomImage").src = static1url + "/imagesLarge/"+mpc+"-"+String(pic)+".jpg";
		document.getElementById("zoomImage").alt = document.getElementById("thumb"+pic).alt;
		document.getElementById("zoomImage").title = document.getElementById("thumb"+pic).title;
	}
	imageNum = pic;
	if(photoZoom[imageNum-1]) {
		document.getElementById("zoom").style.display="inline-block";
	} else {
		document.getElementById("zoom").style.display="none";
	}
}

function roundCurrency(strValue) {
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);
	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
//	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
//		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
//		dblValue.substring(dblValue.length-(4*i+3));
	return parseFloat(((blnSign)?'':'-') + dblValue + '.' + strCents);
}
function formatCurrency(strValue) {
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);
	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

var xx;
var yy;
var lastxx = 0;
var lastyy = 0;
var zoomw = 1200;
var zoomh = 800;
var imagew = 400;
var imageh = 267;
var itop;
var ileft;
var clipstring;
var zrectw;
var zrecth;
var zleft;
var ztop;
var zoomRectWidth = 0;
var zoomRectHeight = 0;
var imagePosition;
var zoomPosition;
var pageX = 0;
var pageY = 0;
var version = 0;
if (ie) {
	var arVersion = navigator.appVersion.split("MSIE");
	version = parseFloat(arVersion[1]);
}
function zoom_on() {
	if (ie) {
		if (version >= 6 && version < 7) {ieox = document.body.scrollLeft; ieoy = document.body.scrollTop;}
		if (version >= 7) {ieox = document.documentElement.scrollLeft; ieoy = document.documentElement.scrollTop;}
	} 
	if(photoZoom[imageNum-1]) {
//		zoomw = photoWidth[imageNum-1];
//		zoomh = photoHeight[imageNum-1];
		var zoomHeight = parseInt(document.getElementById("descripInfo").offsetHeight);
		var photoHeight = parseInt(document.getElementById("photos").offsetHeight);
//console.log('photoHeight='+photoHeight);
		if (photoHeight > zoomHeight) {zoomHeight = photoHeight;}
//console.log('zoomHeight='+zoomHeight);
//console.log('zoomWidth='+document.getElementById("descripInfo").offsetWidth);
		var zoomWidth = 410;
		zoomRectWidth = 133;	//zoomWidth/zoomw*imagew
		zoomRectHeight = 267*zoomHeight/800;
//console.log('zoomRectHeight='+zoomRectHeight);
		document.getElementById("zoomRect").style.height = zoomRectHeight + "px";
		document.getElementById("zoomImageDiv").style.height = zoomHeight + "px";
//		pageX = getpagescrollx();
		pageX = posLeft();
		pageY = getpagescrolly();
//alert('pageX='+pageX+", pageY="+pageY);
		imagePosition = findPos(document.getElementById("prodImage"));
//alert('imagePosition='+imagePosition[0]+','+imagePosition[1]);
		zoomPosition = findPos(document.getElementById("descripInfo"));
//alert('zoomPosition='+zoomPosition[0]+','+zoomPosition[1]);
		if(ie && version >= 6 && version < 7 & pageWidth() > 850) {zoomPosition[0] = zoomPosition[0] - ((pageWidth()-850)/2);}
//console.log('left calculation='+(pageWidth()/2-34));

		document.getElementById("zoomImageDiv").style.left = zoomPosition[0]+"px";

		document.getElementById("zoomImageDiv").style.visibility = "visible";
		document.getElementById("zoomImage").alt = "";
		document.getElementById("zoomImage").title = "";
		document.getElementById("zoomRect").style.display="block";

	}
	
}

function zoom_off() {
	document.getElementById("zoomImageDiv").style.visibility = "hidden";
	document.getElementById("zoomRect").style.display = "none";
}



function zoom_move() {
	if(typeof(window['mx']) != "undefined" && photoZoom[imageNum-1] && imagePosition){
		if (imagePosition[0] > 0) {
			xx = mx - imagePosition[0];
			yy = my - imagePosition[1];
		} else {
			xx = mx-231; yy = my-187;
		}	
//alert('Before xx='+xx+', yy='+yy);
		xx = xx + pageX;		
		yy = yy + pageY;

//alert('After xx='+xx+', yy='+yy);		
		var zoomRect = document.getElementById("zoomRect");
//	position the zoomRect so that it is at the edge of the product image.
		xx = xx - (zoomRectWidth/2);	
		if (xx < 0) {
			xx = 0;
		} else if (xx > (imagew - zoomRectWidth)) {
			xx = (imagew-zoomRectWidth);
		} 

//alert('xx='+xx);
//console.log('yy='+yy);
		yy = yy - (zoomRectHeight/2);
//console.log('yy='+yy);
		if (yy < 0) {
			yy = 0;
		} else if (yy > (imageh - zoomRectHeight)) {
			yy = imageh - zoomRectHeight;
		}

//alert('zoomRectLeft='+(imagePosition[0]+xx)+',pageWidth='+pageWidth()+',pageX='+pageX);		
//alert('zoomRectTop='+(imagePosition[1]+yy));
		if(ie && version < 7) {
			if(pageWidth() > 850) {
				zoomRect.style.left = (imagePosition[0]+xx-((pageWidth()-850)/2)-10) + "px";
			} else {
				zoomRect.style.left = (imagePosition[0]+xx) + "px";
			}
			zoomRect.style.top = (imagePosition[1] + yy-193) + "px";
		
		} else {
			zoomRect.style.left = (imagePosition[0]+xx) + "px";
			zoomRect.style.top = (imagePosition[1] + yy) + "px";	
		}
			xx = 1.13*xx
			yy = 1.13*yy
					
		itop = parseInt(yy/(imageh-zoomRectHeight/2)*zoomh-yy);
		if (itop<0) {itop=0}
		ileft = parseInt(xx/(imagew-zoomRectWidth/2)*zoomw-xx);
		if (ileft<0) {ileft=0}
		clipstring = "rect("+itop+"px,"+(ileft+imagew)+"px,"+(itop+imageh)+"px,"+ileft+"px)";
		zrectw = 50*450/zoomw;
		zrecth = 33*300/zoomh;
		//alert(parseInt(yy/300*(67-zrecth)));
		ztop = parseInt(yy/300*(33-zrecth));
		zleft = parseInt(xx/450*(50-zrectw));
		if(ie) {zleft=zleft-59;ztop=ztop+2;} else {zleft=zleft-1;ztop=ztop-42;}
		
		document.getElementById("zoomImage").style.clip = clipstring;
		document.getElementById("zoomImage").style.marginLeft=-ileft+"px";
		document.getElementById("zoomImage").style.marginTop=-itop+"px";

//console.log('zoomRect top='+document.getElementById("zoomRect").style.top);

	}
//	alert("xx="+xx+"yy="+yy);
		
}


var shipWindow;
var sizeWindow;
var qtyWindow;
var whyBuyWindow;

function shipQuote(mpc) {
	if(typeof shipWindow == "object") {if (!shipWindow.closed) {shipWindow.close();} }
	var partno="";
	if(document.getElementById("partno")) {partno=document.getElementById("partno").value;}
	shipWindow = window.open("/shipquote.asp?p="+mpc+"&q="+lastGoodQty+"&pn="+partno,"shipquote"+mpc,"toolbar=0,menubar=0,scrollbars=0,width=750px,height=450px");
}

function sizeInfo(mpc) {
	if(typeof sizeWindow == "object") {if (!sizeWindow.closed) {sizeWindow.close();} }
	sizeWindow = window.open("/sizechart.asp?p="+mpc,"sizechart"+mpc,"toolbar=0,menubar=0,scrollbars=0,width=650px,height=350px");
}

function qtyDiscInfo(mpc) {
	if(typeof qtyWindow == "object") {if (!qtyWindow.closed) {qtyWindow.close();} }
	var partno="";
	if(document.getElementById("partno")) {partno=document.getElementById("partno").value;}	
	qtyWindow = window.open("/qtydiscounts.asp?p="+mpc+"&pn="+partno,"qtydiscounts"+mpc,"toolbar=0,menubar=0,scrollbars=0,width=600px,height=295px");
}



function vipPage(mpc) {
	if(typeof vipPageWindow == "object") {if (!vipPageWindow.closed) {vipPageWindow.close();} }
	vipPageWindow = window.open("/secure/vipclub_nonav.asp","vippage"+mpc,"toolbar=0,menubar=0,scrollbars=1,width=762px,height=910px");
}

function addCommas(nStr)
		{
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
		}	

function outOfStock() {
	if(typeof oosWindow == "object") {if (!oosWindow.closed) {oosWindow.close();} }
	var p = document.getElementById("partno").value
	if(p == "") {p = manprodcode;} 
	oosWindow = window.open("/outofstock.asp?p="+p,"oos"+p,"toolbar=0,menubar=0,scrollbars=0,width=650px,height=300px");
}

function getAdmin(mpc,vt) {
	document.getElementById("admininfo").innerHTML = "Retreiving Admin Info ..."
	xmlHttp = GetXmlHttpObject();
	xmlHttp.onreadystatechange = updateAdmin;
	xmlHttp.open("GET", "/admininfo.asp?p="+mpc+"&v="+vt, true);		
	// send the request
	xmlHttp.send(null);
	return false;
}

function updateAdmin() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("admininfo").innerHTML = xmlHttp.responseText;
		fixSpacer('productdetailpage');
	}
}

function explainVIP() {
	alert("VIP Points give you cash savings on this and future orders. We give you 500 points for joining ($5.00 off this order if you're not already a member) and when you buy this product, we'll add points to your balance for future use. Click on the VIP Buyers Club logo for more information.");
}

function cartForm(instock) {
	if (instock) {
		document.getElementById("cartforms").style.display = "inline";
		document.getElementById("outofstock").style.display = "none";
	} else {	
		document.getElementById("cartforms").style.display = "none";
		document.getElementById("outofstock").style.display = "inline";
	}
}

function selectTab(tid) {
	var tabs = new Array('des','cus','spe','siz','rev','art');
	document.getElementById("rightBox").style.height = '';
	for (i=0;i<tabs.length;i++) {
		if (document.getElementById(tabs[i]+"tab")) {
			document.getElementById(tabs[i]+"body").style.display="none";
			document.getElementById(tabs[i]+"tab").style.borderBottomStyle="solid";
			document.getElementById(tabs[i]+"tab").style.backgroundImage = "url(/images/gray-tab.jpg)";
			document.getElementById(tabs[i]+"a").style.color="#adaeb2";
		}
	}
	document.getElementById(tid+"body").style.display="inline-block";
	document.getElementById(tid+"tab").style.borderBottomStyle="none";
	document.getElementById(tid+"tab").style.backgroundImage = "url(/images/cream-tab.jpg)";
	document.getElementById(tid+"a").style.color="#AE0F21";
	matchBoxHeight(tid);
	return false;
}

function countDown() {
	tsec = tsec - 1;
	if (tsec < 0) {
		tsec = 59;
		tmin = tmin - 1;
		if (tmin < 0) {
			tmin = 59;
			thrs = thrs - 1;
			if (thrs < 0) {
				thrs = 0;
				tmin = 0;
				tsec = 0;
				document.getElementById("hurry").innerHTML = "Sorry, this daily special is over.";
				displayCount();
				return;
			}
		}
	}
	displayCount();
	setTimeout("countDown();",1000);
}

function displayCount() {
	document.getElementById("timer").innerHTML = thrs + "<span class='tt'>hrs</span> : " + tmin + "<span class='tt'>min</span> : " + tsec + "<span class='tt'>sec</span>";
}

function createReview() {
	if(typeof reviewWindow == "object") {if (!reviewWindow.closed) {reviewWindow.close();} }
	reviewWindow = window.open("/review.asp?p="+manprodcode,"review"+manprodcode,"toolbar=0,menubar=0,scrollbars=1,width=775px,height=800px");
}
function reviewHelpful(rn,v) {
	if (reviewVotes.match(rn+' ')) {
		document.getElementById("thank"+rn).style.display = "none";
		document.getElementById("onevote"+rn).style.display="inline-block";
	} else {
		reviewVotes = reviewVotes + rn + ' ';
		xmlHttp = GetXmlHttpObject();
		xmlHttp.open("GET", "/reviewvote.asp?rn="+rn+"&v="+v, true);		
		xmlHttp.send(null)
		document.getElementById("thank"+rn).style.display = "inline-block";
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function matchBoxHeight(tid) {
	var rightBoxHeight = parseInt(document.getElementById('rightBox').offsetHeight);
	var bottomHeight = leftBoxHeight;
	if (rightBoxHeight > leftBoxHeight) {bottomHeight = rightBoxHeight;}
//	We need to execute different code for IE6. If document.body.style.maxHeight is undefined, this is IE6 or earlier	
	if (typeof document.body.style.maxHeight != "undefined") {
		document.getElementById('leftBox').style.height = bottomHeight + 'px';
		document.getElementById('rightBox').style.height = bottomHeight + 'px';
	} else {
		var descripHeight = parseInt(document.getElementById("descripInfo").offsetHeight);
		var photoHeight = parseInt(document.getElementById("photos").offsetHeight);	
		var adjustHeight = 95;
		var topHeight = descripHeight;
		if (photoHeight > descripHeight) {topHeight = photoHeight;}
		var currentHeight = parseInt(document.getElementById('productdetailpage').offsetHeight);
		//	determine which div height to change first. If total height is being reduced, change it last, otherwise change it first
		if (currentHeight > (bottomHeight+topHeight+adjustHeight)) {
			document.getElementById('leftBox').style.height = bottomHeight + 'px';
			document.getElementById('rightBox').style.height = bottomHeight + 'px';
			if(ie) document.getElementById('productdetailpage').style.height = bottomHeight + topHeight + adjustHeight + "px";
		} else {
			if (ie) document.getElementById('productdetailpage').style.height = bottomHeight + topHeight + adjustHeight + "px";
			document.getElementById('leftBox').style.height = bottomHeight + 'px';
			document.getElementById('rightBox').style.height = bottomHeight + 'px';
		}
	}
}





