var arrFound = new Array()
var curCheck = new Array()
var minPrice = -1
var maxPrice = -1
var minMSRP = -1
var maxMSRP = -1

var mousex = mousey = 0;
var algor = 0;
var xMulti = yMulti = 0;
var largeImgBoxWidth = largeImgBoxHeight = 550

var optLrg, zoomHideTimeout, imgPos, reqOpt, checkCnt, arrHidden, hideCnt, isFound, showZT, imgPos, hideLarge
var debug = ""
var divPos = null

var strHost = location.hostname.toLowerCase();

if (strHost.indexOf("atgstores") < 0){
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	
	if (sPage.toLowerCase() != "view.aspx" && sPage.indexOf('.html') < 2 && strHost.indexOf("kitchens") < 0 && strHost.indexOf("ibaths") < 0 && strHost.indexOf("homesavvi")  < 0 )
		strHost="atgstores.atgstores.com";
	else
		strHost=strHost.replace("www.","").replace("development.","").replace(".com",".ATGStores.com");
}
if(strHost=="www.atgstores.com"){strHost="atgstores.atgstores.com";}

//////////
// timeLeft
//////////
function timeLeft(){
	if (shipTimeCutOff != ""){
		msPerDay = 24 * 60 * 60 * 1000 ;
		
		var dateNow = new Date()
		var targetDate = new Date(dateNow.getMonth() + "/" + dateNow.getDay() + "/" + dateNow.getYear() + " " + shipTimeCutOff)	
		var gmtHours = (dateNow.getTimezoneOffset()/60) + 1;
		var timeLeft = ((targetDate.getTime() + (8 * 60 * 60 * 1000)) - (dateNow.getTime() + (gmtHours * 60 * 60 * 1000)));
		
		e_daysLeft = timeLeft / msPerDay;
		daysLeft = Math.floor(e_daysLeft);
		e_hrsLeft = (e_daysLeft - daysLeft)*24;
		hrsLeft = Math.floor(e_hrsLeft);
		e_minsLeft = (e_hrsLeft - hrsLeft)*60;
		minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
		secLeft = Math.floor((e_minsLeft - minsLeft)*60);
		
		document.getElementById("timeLeft").style.display = "block"
		
		if ((hrsLeft + minsLeft + secLeft) > 0 && hrsLeft < 12){
			document.getElementById("timeLeft").innerHTML = "<span style=\"font-weight:normal;font-size:8pt;\">Order in " + hrsLeft + "h " + minsLeft + "m " + secLeft + "s to have it ship today</span>"
			
			setTimeout("timeLeft()",1000);
		}
		else
			document.getElementById("timeLeft").innerHTML = "<span style=\"font-weight:normal;font-size:8pt;\">Order before " + shipTimeCutOff + "AM PST to have it ship tomorrow</span>"
	}
}
timeLeft()

if (readQuery("searchTerm") != null)
	addLoadEvent(function(){multiHi(unescape(readQuery("searchTerm")), document.getElementById("viewBody"), "#FFFF66")})

//////////
// checkForSet
//////////
function checkForSet(){
	var intCount = 0
	var intCountDiv = 1
	var strAdditionalSku = ""
	
	while (document.getElementById("spnSetSku" + intCount) != null){
		if (intCount == 0){
			strAdditionalSku = document.getElementById("spnSetSku" + intCount).innerHTML
		}
		else{
			if (document.getElementById("cbxProdSetPage" + intCount).checked){
				strAdditionalSku += "," + document.getElementById("spnSetSku" + intCount).innerHTML
			}
		}
		
		intCount += 1;	
		intCountDiv += 2;	
	}
	
	return strAdditionalSku
	//document.getElementById("lnkAddToCart").href = "http://" + strHost + "/cart/addtocart.aspx?sku=" + strAdditionalSku + strTrack;
}

var intervalFav
function hideFav(){
	intervalFav = window.setTimeout("hideFavTime()",750);
}	
function hideFavTime(){document.getElementById("ulAddFav").style.display = "none"}
function stopFavHide(){clearTimeout(intervalFav)}
function showBorder(objCurrent, strLargeImg, strName){
	var arrImg = objCurrent.getElementsByTagName("img")
	arrImg[1].style.display = "block"	
	var arrDiv = objCurrent.parentNode.getElementsByTagName("div")
	arrDiv[0].innerHTML = "<img src=\"http://hi.atgimg.com/images/options/image/" + strLargeImg + "\" style=\"position:absolute;width:120px;height:120px;top:2px;left:2px;z-index:2;\"><img src=\"/images/windowLgLB.png\" style=\"position:absolute;z-index:5;\"><div style=\"position:absolute;bottom:10px;left:4px;text-align:center;z-index:8;font-size:8pt;color:#333;background:#EEE;filter:alpha(opacity=80);-moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;width:115px;\">" + strName + "</div>"
	arrDiv[0].style.top = objCurrent.style.top.replace("px","") * 1.0 + 33;
	arrDiv[0].style.left = objCurrent.style.left.replace("px","") * 1.0 + 33;
	arrDiv[0].style.width = "130"
	arrDiv[0].style.height = "150"
	arrDiv[0].style.display = "block";
}
//////////
// clearBorder
//////////
function clearBorder(objCurrent){
	var arrImg = objCurrent.getElementsByTagName("img")
	var arrDiv = objCurrent.parentNode.getElementsByTagName("div")
	if (arrImg[1].id != "imgCurrent"){
		arrImg[1].style.display = "none"
	}
	arrDiv[0].style.display = "none";
}
//////////
// saveRecent
//////////
function saveRecent(strSKU, strGroupId, strPrice, strMfr, strImg)
{
    var recent = readCookie("recentView");
    var strCookieValue = recent;
    var curProd = strSKU + "|" + strGroupId + "|" + strPrice + "|" + strMfr + "/" + strImg + "~";
    if(strCookieValue != null)
    {
        //check if current product already found in recent viewed list
        var foundIndex = -1;
        foundIndex = strCookieValue.indexOf(curProd);
        if(foundIndex > -1)
            strCookieValue = strCookieValue.replace(curProd, "");
        //insert current prod at top
        strCookieValue = curProd + strCookieValue;
        //check if there are more than 5 products in queue
        var arr = strCookieValue.split("~");
        var count = arr.length;
        if(count > 5)
        {
            //select top 5 only
            var i = 0;
            var temp = "";
            for(i = 0; i < 5; i ++)
            {
                var t = arr[i] + "~";
                temp = temp + t;
            }
            strCookieValue = temp;
        }
    }
    else
    {
        strCookieValue = strSKU + "|" + strGroupId + "|" + strPrice + "|" + strMfr + "/" + strImg + "~";
    }
    //Remove Extra blank values
    strCookieValue = strCookieValue.replace(" ", "");
    SetMyCookie("recentView", strCookieValue, 5);
}        
//////////
// SetMyCookie
//////////
function SetMyCookie(cookieName, cookieValue, exp)
{
    var today = new Date();
    var expire = new Date();
    if(exp == null || exp == 0)
        exp = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * exp);
    document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + expire.toTimeString();
}

//////////
// swapImage
//////////
function swapImage(strImagePath, spnMiniImage, strCap){	
	var newImg = document.createElement("img")

	newImg.src = strImagePath
	newImg.onLoad = altLoad(newImg)

	var divMiniImageWrapper = document.getElementById("divMiniImageWrapper")
	var arrMiniImage = divMiniImageWrapper.getElementsByTagName("a")
	
	for (var i = 0; i < arrMiniImage.length; i++){
		if (arrMiniImage[i].id == spnMiniImage.id)
			arrMiniImage[i].style.borderColor = "red"
		else
			arrMiniImage[i].style.borderColor = "#CCC"
	}	
	
	if (strCap != ""){
		document.getElementById("divAltImgCap").innerHTML = strCap.replace(/([0-9]+)/, "<a href=\"\/products\/view.aspx?sku=$1\">$1</a>")
		document.getElementById("divAltImgCap").style.display = "block"
		if (document.getElementById("imgText"))
			document.getElementById("imgText").style.display = "none"		
	}
	else{
		document.getElementById("divAltImgCap").innerHTML = ""
		document.getElementById("divAltImgCap").style.display = "none"

		if (document.getElementById("imgText"))
//			if (document.getElementById("imgText").innerHTML != "")
//				document.getElementById("imgText").style.display = "block"
//			else
				document.getElementById("imgText").style.display = "none"		
	}
	
	updateZoom(strImagePath)
}

//////////
// updateZoom
//////////
function updateZoom(strImagePath){
	//Update Zoom Img
	xMulti = 0
	var imgLoad = new Image()
	imgLoad.onerror = function () {loadLarge(strImagePath)}	
	imgLoad.src = strImagePath.replace(/\/p\//,"/x/")
	
	if (imgLoad.width > 0 && imgLoad.width < 50)
		loadLarge(strImagePath)
	else{
		var imgZoom = document.getElementById("imgZoom")
		imgZoom.src = imgLoad.src
	}
}

//////////
// loadLarge
//////////
function loadLarge(strImagePath){
	var imgLoad = new Image()
	imgLoad.onerror = function () {document.getElementById("imgZoom").src = ""}	
	imgLoad.src = strImagePath.replace(/\/p\//,"/l/")	
	
	var imgZoom = document.getElementById("imgZoom")
	imgZoom.src = imgLoad.src
}

//////////
// altLoad
//////////
function altLoad(newImg){
	if (newImg.width == 0 || !newImg.complete){
		window.setTimeout(function () {altLoad(newImg);}, 50);		
	}
	else{
		var imgMain = document.getElementById("imgProduct") 
	
		if (newImg.width > 300)
			newImg.width = 300
		if (newImg.height > 300)
			newImg.height = 300
		
		imgMain.src = newImg.src
		imgMain.width = newImg.width
		imgMain.height = newImg.height
	}
}

//////////
// multiHi
//////////
function multiHi(term, container, color){
	if (!/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){	
		var arrTerm = term.split(" ")
		
		for (var i=0; i < arrTerm.length; i++){		
			if (arrTerm[i].length > 2){
				highlight(arrTerm[i], container, color)		
			}
		}
	}
}

//////////
// highlight
//////////
function highlight(term, container, color){
	var term_low = term.toLowerCase();
	if (term_low != ""){		
		for(var i=0; i < container.childNodes.length; i++){
			var node = container.childNodes[i];
			var nodeOriginal = container.childNodes[i];
	
			if (node.nodeType == 3){
				var data = node.data;
				var data_low = data.toLowerCase();
				var result = "";
				if (data_low.indexOf(term) != -1){
					//term found!
					var new_node = document.createElement('span');
	
					node.parentNode.replaceChild(new_node,node);					
					
					while((result = data_low.indexOf(term)) != -1){
						new_node.appendChild(document.createTextNode(data.substr(0,result)));
						new_node.appendChild(create_node(document.createTextNode(data.substr(result,term.length)),color));
						data = data.substr(result + term.length);
						data_low = data_low.substr(result + term.length);
					}
					new_node.appendChild(document.createTextNode(data));
				}	
			}else{
				highlight(term, node, color);
			}
		}
	}
}

//////////
// create_node
//////////
function create_node(child, color){
	var node = document.createElement('SPAN');
	node.style.backgroundColor = color;
	node.appendChild(child);
	return node;
}

//////////
// rateIt
//////////
function rateIt(intStar){
	document.getElementById("miniReviewText").innerHTML = miniReviewDefaultText + "<span class=\"red\">&nbsp;&nbsp;&nbsp;&nbsp;SAVED</span>"
	miniReviewBaseImage = "/images/reviews/star" + intStar + "_0.gif"
	document.getElementById("miniReviewWriteReview").innerHTML = "<a class=\"blueUnderLine\" href=\"\/products\/review.aspx?family=" + miniReviewGroupId + "\">Write a review<\/a>"
	var ajaxReqObj = new ajaxRequestObject("/ajax/miniReview.aspx","group_id=" + miniReviewGroupId + "&rate=" + intStar);
	ajaxReqObj.doGetCallback();
}
//////////
// rateReview
//////////
function rateReview(intReviewId, intHelpful, curObject){
	var ajaxReqObj = new ajaxRequestObject("/ajax/reviewReview.aspx","reviewId=" + intReviewId + "&helpful=" + intHelpful);
	ajaxReqObj.doGetCallback();
	curObject.parentNode.innerHTML = "<span style='color: green'>Thank you for rating this review.</span>"
}
//////////
// rateAnswer
//////////
function rateAnswer(intQuestionId, intAnswerId, intHelpful, intReport, curObject){
	var ajaxReqObj = new ajaxRequestObject("/ajax/rateAnswer.aspx","questionId=" + intQuestionId + "&answerId=" + intAnswerId + "&helpful=" + intHelpful + "&report=" + intReport);
	ajaxReqObj.doGetCallback();
	curObject.parentNode.innerHTML = "<span style='color: green'>Thank you for giving feedback on this answer.</span>"
}
//////////
// getQtyPage
//////////
function getQtyPage(curLink){
	var selQty = document.getElementById("selQty")
	var strTrack = ""
	var sessionId = readCookie("NetSessionID")
	var sku = ""
	
	if (sessionId!=null){
		if (sessionId.length < 30) {
			strTrack= strTrack + "&NetSessionID=" + sessionId; 
		}
	}
	if (readCookie("af")!=null){strTrack= strTrack + "&af=" +readCookie("af") }
	if (readCookie("af2")!=null){strTrack= strTrack + "&af2=" +readCookie("af2") }
	if (readCookie("af800")!=null){strTrack= strTrack + "&af800=" +readCookie("af800") }
	if (readCookie("af%5ftrack%5fid")!=null){strTrack= strTrack + "&afTrackId=" +readCookie("af%5ftrack%5fid") }
	
	//product set
	if (document.getElementById("spnSetSku1")){
		sku = checkForSet()
	}
	//regular
	else
		sku = document.getElementById("spnPart").innerHTML.replace(/<span><span [^>]*>([0-9]*)<\/span><\/span>/ig,"$1")
		
	if (sku.match(/[^0-9]/))
		sku = intSku
	
	curLink.href = "http://" + strHost + "/cart/addtocart.aspx?sku=" + sku + "&qty=" + selQty.value + strTrack
}
//////////
// updateCartCookie
//////////
function updateCartCookie(){
	if (document.getElementById("spnPrice")) {
		var spnPrice = document.getElementById("spnPrice")
		var arrPrice = spnPrice.innerHTML.split("&")
	
		arrPrice[0] = arrPrice[0].replace("$","").replace(",","")
	
		if (readCookie("cartItem")!=null){
			if (readCookie("cartItem").indexOf("~") > 0){
				SetCookie("cartItem","1-" + arrPrice[0],365)
			}
			else{				
				var selQty = document.getElementById("selQty")
				var cur = readCookie("cartItem").split("-")
				
				if (cur[0] == "NaN"){
					SetCookie("cartItem","1-" + arrPrice[0],365)
				}
				else{
					var qty = cur[0] * 1.0 + selQty.value * 1.0
					var total = cur[1] * 1.0 + (selQty.value  * 1.0 * arrPrice[0]  * 1.0)  * 1.0
					//Response.Cookies("cartItem").value = intItemCount & "~" & (CDbl(litShipHandle.Text) + cdbl(litsubtotal.text))
					
					SetCookie("cartItem",qty + "-" + total,365)
				}
			}
		}
		else{
			SetCookie("cartItem","1-" + arrPrice[0],365)
		}
	}
	return true;
}
function showImgText(B){var A=document.getElementById("imgText");if(A){if(B==1){A.style.display="block"}else{A.style.display="none"}}};
function tagProd(intFamily){var ajaxReqObj = new ajaxRequestObject("/ajax/tag.aspx","tag=" + document.getElementById("tbxTag").value + "&family=" + intFamily);ajaxReqObj.doGetCallback();document.getElementById("tbxTag").value = '';document.getElementById("divTagHelp").innerHTML="Your tags have been saved";document.getElementById("divTagHelp").style.color="#009933"}

//////////
// addToCart
//////////
var strMissing = ""
function addToCart(){
	var bRet = true
		
	bRet = checkOption()
	
	if (!bRet){
		document.getElementById("divAddError").innerHTML = "<div style=\"float:left;width:255px;margin-left:5px;\">Select " + strMissing.toLowerCase() + " before adding to your cart </div><img src=\"/images/arrow.png\" style=\"vertical-align:middle;\">"
		document.getElementById("divAddError").style.display = "block"
	}
	
	return bRet
}

//////////
// checkOption
//////////
function checkOption(){
	var bRet = true
	
	//Check for all options set	
	for (i = numGroups - 1; i >= 0 ; i--){
		if (optMustBe[i] == -1)	{
			document.getElementById("oErr" + (i+1)).style.display = "inline"
			bRet = false

			if (strMissing.length > 0)
				strMissing += ", "

			strMissing += document.getElementById("oName" + (i+1)).innerHTML
		}
	}
	
	return bRet
}

//////////
// initOption
//////////
function initOption(){
	try{
		if (arrOpt.length > 0){
			setPreSet()
			checkMatch()
		}
		buildSelString()
	}
	catch(err){
		
	}
}

//////////
// setPreSet
//////////
function setPreSet(){
	for (i = 0; i < numGroups; i++){
		if (optMustBe[i] > -1){
			document.getElementById("oSel" + (i + 1)).innerHTML = optSelName[i]
			document.getElementById((i + 1) + "::" + optMustBe[i]).className = "optionSel"
			
			//Check to see if other options should be disabled
			for (var j = 1; j <= numOptions[i]; j++){
				if (j != optMustBe[i]){
					isFound = false
					checkDis(i + 1, j, true)
					
					if (!isFound)
						document.getElementById((i + 1) + "::" + j).className = "optionNotAvailable"
				}
			}
		}
	}
}

//////////
// oSelect - Called when an option is clicked
//////////
function oSelect(g, o, strName, recheckCurrent){
	//alert(g + "," + o + "," + strName + "," + recheckCurrent)
	var oSel = document.getElementById("oSel" + g)
	var oErr = document.getElementById("oErr" + g)
	var currentOpt = document.getElementById(g + "::" + o)

	//Disabled option clicked (turn off all other options)
	if (currentOpt.className == "optionNotAvailable"){
		//Turn off all the other options
		for (i = numGroups - 1; i >= 0 ; i--){
			if (numOptions[i] > 1){				
				optSelName[i] = ""
				document.getElementById("oSel" + (i + 1)).innerHTML = ""
				optMustBe[i] = -1
				
				//Turn off each option in current group
				if (i + 1 == g){
					for (k = 1; k <= numOptions[i]; k++){
						if (k != o){
							document.getElementById((i + 1) + "::" + k).className = "option"
						}
					}
				}
				//Clear all other options
				else{
					for (k = 1; k <= numOptions[i]; k++){
						if (k != o){
							document.getElementById((i + 1) + "::" + k).className = "option"
						}
					}
				}				
			}
			
			//Turn On 				
			optSelName[g - 1] = strName;
			oSel.innerHTML = optSelName[g - 1]
			optMustBe[g - 1] = o;
			oErr.style.display = "none"
			currentOpt.className = "optionSel"
		}
	}
	//Non disabled clicked (turn off the rest of current option)
	else{
		//Turn On 
		oSel.innerHTML = strName;
		optSelName[g - 1] = strName;
		optMustBe[g - 1] = o;
		oErr.style.display = "none"		
		currentOpt.className = "optionSel"
	
		//Turn off the other options in this group
		for (i = 1; i <= numOptions[g-1]; i++){
			if (o != i){
				if (document.getElementById(g + "::" + i).className != "optionNotAvailable"){
					document.getElementById(g + "::" + i).className = "option"
				}
			}
		}
	}
	
	checkDis(-1)
	
	if (recheckCurrent){		
		for (var i = 1; i <= numOptions[g-1]; i++){
			if (i != o){
				isFound = false
				checkDis(g, i, true)
				
				//alert("Check:" + g + "::" + i)
				
				if (!isFound)
					document.getElementById(g + "::" + i).className = "optionNotAvailable"
			}
		}
	}

	checkMatch()	
	buildSelString()
	
	document.getElementById("notAv").className = "hide"
}

//////////
// checkMatch  -- check and see if there is a valid sku at the called position
//////////
function checkMatch(g, o){
	if ( g === undefined ) {
      g = "0"
   }
   	if ( o === undefined ) {
      o = "0"
   }
   //alert("g = " + g + ", o - " + o)
	var key=buildSelID(g,o)
	document.getElementById("divNotifyWhenInStock").style.display = "none"	
	if (arrOpt[key]){
		intSku = arrOpt[key].sku
		document.getElementById("spnPart").innerHTML = intSku
		document.getElementById("tdPrice").innerHTML = toCurrency(arrOpt[key].price)
		document.getElementById("spnMSRP").innerHTML = toCurrency(arrOpt[key].msrp)
		document.getElementById("tdSave").innerHTML = toCurrency(arrOpt[key].msrp * 1.0 - arrOpt[key].price * 1.0) + "&nbsp;(" + toPercent((arrOpt[key].msrp * 1.0 - arrOpt[key].price * 1.0) / arrOpt[key].msrp * 1.0).replace(/\.[0-9][0-9]/,"") + ")"
		document.getElementById("spnProdId").innerHTML = arrOpt[key].partNo

		//Internal Box
		if (document.getElementById("viewProd_celIntMfrProdIdText")){
		    document.getElementById("viewProd_celIntMfrProdIdText").innerHTML = "<strong>Mfr Part No:</strong><br>" + arrOpt[key].partNo
			
			if (document.getElementById("viewProd_celBasisText"))
			    document.getElementById("viewProd_celBasisText").innerHTML = "<strong>Basis:</strong><br>" + toCurrency(arrOpt[key].basis)
			
			document.getElementById("viewProd_celLUCostText").innerHTML = "<strong>LU Cost:</strong><br>" + toCurrency(arrOpt[key].ac)
			document.getElementById("viewProd_celIntRetailText").innerHTML = "<strong>Retail Price:</strong><br>" + toCurrency(arrOpt[key].price)
			document.getElementById("viewProd_celShippingText").innerHTML = "<strong>Shipping Cost:</strong><br>" + toCurrency(arrOpt[key].ship)
			document.getElementById("viewProd_celMarginText").innerHTML = "<strong>Margin:</strong><br>" + toCurrency(arrOpt[key].price - arrOpt[key].ac - arrOpt[key].ship)
		}
		//Price
		minPrice = maxPrice = arrOpt[key].price
		minMSRP = maxMSRP = arrOpt[key].msrp
		
		//if (document.getElementById("divShipTime"))
		//	document.getElementById("divShipTime").style.display = "block"
		
		//Stock/Ship Time/Notify when in stock
		if (arrOpt[key].bo != ""){
			if (document.getElementById("divShipTime"))
				document.getElementById("divShipTime").style.display = "none"
			
			document.getElementById("divStock").style.display = "block"	
			document.getElementById("divStock").innerHTML = "<span class=\"red\" style=\"font-size:12pt;\">Out of Stock until " + arrOpt[key].bo + "</span>"
			document.getElementById("divNotifyWhenInStock").style.display = "block"	
			if(intSku != "")
			{
				document.getElementById("divNotifyWhenInStock").innerHTML = "<a href='#' onclick=\"javascript:window.open('/products/notifyWhenInStock.aspx?sku=" + intSku + "', 'NotifyInStock', 'scrollbars=no, resizeable=no, toolbar=no, menubar=no, location=no, directories=no, width=350, height=60');return false;\">Notify Me When In Stock</a>"
			}
			else
				document.getElementById("divNotifyWhenInStock").style.display = "none"	
			
			if (arrOpt[key].invChk != ""){
				document.getElementById("divStock").innerHTML += "<div style=\"color:#666;font-size:8pt;font-weight:normal;\">Stock Updated " + arrOpt[key].invChk + "</div>"
			}
		}
		else{
			if (arrOpt[key].mfrStk != ""){
				var m,t				
				//alert(arrOpt[key].mfrStk)
				document.getElementById("divStock").style.display = "block"			
				
				if (arrOpt[key].mfrStk == 0)
					document.getElementById("divNotifyWhenInStock").style.display = "none"	

				if (document.getElementById("divShipTime"))
					document.getElementById("divShipTime").style.display = "none"
				
				if (document.getElementById("timeLeft"))
					t = document.getElementById("timeLeft").innerHTML
				else
					t = ""
			
				if (arrOpt[key].mfrStk > 5 || arrOpt[key].mfrStk == -1){
					m = "In Stock<div id=\"timeLeft\">" + t + "</div>"
					document.getElementById("divNotifyWhenInStock").style.display = "none"	
				}
				else{
					if (arrOpt[key].mfrStk > 0)
					{
						m = arrOpt[key].mfrStk + " In Stock<div id=\"timeLeft\">" + t + "</div>"					
						document.getElementById("divNotifyWhenInStock").style.display = "none"	
					}
					else
					{
						m = "<span class=\"red\" style=\"font-size:12pt;\">Out of Stock</span><div id=\"timeLeft\" style=\"display:none;\">" + t + "</div>"
						document.getElementById("divNotifyWhenInStock").style.display = "block"	
						if(document.getElementById("divPartNo") && (document.getElementById("divPartNo").innerHTML == "" || document.getElementById("divPartNo").innerHTML == "Loading..."))
						{
							document.getElementById("divPartNo").innerHTML = "<div id=\"timeLeft\" style=\"display:block;\">" + t + "</div>"
						}
					}
					
				}			
				
				if (arrOpt[key].invChk != ""){
					m += "<div style=\"color:#666;font-size:8pt;font-weight:normal;\">Stock Updated " + arrOpt[key].invChk + "</div>"
				}
				
				document.getElementById("divStock").innerHTML = m		
				if (intSku != "")
				{
					document.getElementById("divNotifyWhenInStock").innerHTML = "<a href='#' onclick=\"javascript:window.open('/products/notifyWhenInStock.aspx?sku=" + intSku + "', 'NotifyInStock', 'scrollbars=no, resizeable=no, toolbar=no, menubar=no, location=no, directories=no, width=350, height=60');return false;\">Notify Me When In Stock</a>"
				}
			}
			else{
				if (document.getElementById("divShipTime"))
					document.getElementById("divShipTime").style.display = "block"
					
				document.getElementById("divStock").style.display = "none"
				document.getElementById("divNotifyWhenInStock").style.display = "none"	
			}
		}
		
		//Image
		if (document.getElementById("imgProduct"))
			if (arrOpt[key].img != ""){
				document.getElementById("imgProduct").src = imgPath + "/img/p/" + mfrId + "/" + arrOpt[key].img
				document.getElementById("divAltImgCap").style.display = "none"
			}
			else
				if (defaultImg != "")
					document.getElementById("imgProduct").src = defaultImg

		//Image Text
		if (arrOpt[key].imgT != ""){
			document.getElementById("imgText").innerHTML = arrOpt[key].imgT
			document.getElementById("imgText").style.display = "block"
		}
		else
			if (defaultImgText != ""){
				document.getElementById("imgText").innerHTML = defaultImgText
				document.getElementById("imgText").style.display = "block"
			}
			else
				if (document.getElementById("imgText"))
					document.getElementById("imgText").style.display = "none"

		//Description	
		if (arrOpt[key].desc != "")
			document.getElementById("divSkuDesc").innerHTML = arrOpt[key].desc
		else
			document.getElementById("divSkuDesc").innerHTML = ""
			
		//Dimensions		
		if (document.getElementById("spnDim")){
			if (arrOpt[key].d != "")
				document.getElementById("spnDim").innerHTML = arrOpt[key].d.replace(/-\s*([a-zA-Z]+)/g,"<br>&nbsp;$1").replace(/-\s$/,"").replace(/^\s*\<br\>/g, "")
			else
				if (defaultDim != "")
					document.getElementById("spnDim").innerHTML = defaultDim.replace(/-\s*([a-zA-Z]+)/g,"<br>&nbsp;$1").replace(/-\s$/,"").replace(/^\s*\<br\>/g, "")
				else
					document.getElementById("spnDim").innerHTML = ""
		}
					
		updatePrice()
		
		if (g == 0 && arrOpt[key].img != "")
			updateZoom(imgPath + "/img/p/" + mfrId + "/" + arrOpt[key].img)
	}
	else{		
		document.getElementById("spnPart").innerHTML = document.getElementById("divNeedSelect").innerHTML
		document.getElementById("imgProduct").src = defaultImg
		updatePrice()		
	}
}

//////////
// updatePrice -- updates the price elements with sku data
//////////
function updatePrice(){
	if (minPrice == maxPrice){
		if (minPrice > -1){
			document.getElementById("tdPrice").innerHTML = toCurrency(minPrice)
			document.getElementById("spnMSRP").innerHTML = toCurrency(minMSRP)
			document.getElementById("tdSave").innerHTML = toCurrency(minMSRP * 1.0 - minPrice * 1.0) + "&nbsp;(" + toPercent((minMSRP * 1.0 - minPrice * 1.0) / minMSRP * 1.0).replace(/\.[0-9][0-9]/,"") + ")"
		}
		else{
			document.getElementById("tdPrice").innerHTML = defaultPrice;
			document.getElementById("tdSave").innerHTML = defaultSave;
			document.getElementById("spnMSRP").innerHTML = defaultMSRP;		
		}
	}
	else{
		document.getElementById("tdPrice").innerHTML = toCurrency(minPrice) + " - " + toCurrency(maxPrice) + "<div style='font-size:8.5pt;color:#666;font-weight:normal;position:absolute;top:19px;left:0px;'>Select options to see final price</div>"
		document.getElementById("spnMSRP").innerHTML = toCurrency(minMSRP) + " - " + toCurrency(maxMSRP)
		
		if (toPercent((minMSRP * 1.0 - minPrice * 1.0) / minMSRP * 1.0).replace(/\.[0-9][0-9]/,"") == toPercent((maxMSRP * 1.0 - maxPrice * 1.0) / maxMSRP * 1.0).replace(/\.[0-9][0-9]/,""))
			document.getElementById("tdSave").innerHTML = toCurrency(minMSRP * 1.0 - minPrice * 1.0) + "&nbsp;(" + toPercent((minMSRP * 1.0 - minPrice * 1.0) / minMSRP * 1.0).replace(/\.[0-9][0-9]/,"") + ")"
		else
			document.getElementById("tdSave").innerHTML = toPercent((minMSRP * 1.0 - minPrice * 1.0) / minMSRP * 1.0).replace(/\.[0-9][0-9]/,"") + " - " + toPercent((maxMSRP * 1.0 - maxPrice * 1.0) / maxMSRP * 1.0).replace(/\.[0-9][0-9]/,"")
	}
	
	//Add on configure message
	if (document.getElementById("tdPrice").innerHTML.match(".*-.*"))
		document.getElementById("tdPrice").innerHTML += "<div style='font-size:8.5pt;color:#999;font-weight:normal;position:absolute;top:19px;left:0px;width:155px;'>Select options to see final price</div>"		
}

//////////
// oMouseOver
//////////
function oMouseOver(g, o, strName){
	if (!hideLarge) {
		if (optMustBe[g - 1] == o)
			document.getElementById("oSel" + g).innerHTML = strName
		else
			document.getElementById("oSel" + g).innerHTML = "<span style='color:#336699'>" + strName + "</span>"
		
		if (document.getElementById(g + "::" + o).className == "optionNotAvailable")
			showNotAv(g, strName)
		
		//Hide larger option image
		hideOI(false)
		
		if (document.getElementById(g + "::" + o).getElementsByTagName("div")[0].className == "optionImg"){
			optLrg = document.getElementById(g + "::" + o).getElementsByTagName("div")[2]
			
			optLrg.style.display = "block"
			optLrg.innerHTML = "<img src=\"" + document.getElementById(g + "::" + o).getElementsByTagName("div")[0].style.backgroundImage.replace(/mini/gi, "image").replace("url(","").replace(")","") + "\">\<br\>" + strName
		}
			
		checkMatch(g, o)
		checkDis(g, o);
		
		switch(g){
			case 1:
				clearTimeout(timer1);
				break;
			case 2:
				clearTimeout(timer2);
				break;
			case 3:
				clearTimeout(timer3);
				break;
			case 4:
				clearTimeout(timer4);
				break;
			case 5:
				clearTimeout(timer5);
				break;
			case 6:
				clearTimeout(timer6);
				break;
			case 7:
				clearTimeout(timer7);
				break;
			case 8:
				clearTimeout(timer8);
				break;
		}	
	}
	else
		hideLarge = false
}

//////////
// hideOI
//////////
function hideOI(hide){
	hideLarge = hide

	if (optLrg){
		optLrg.style.display = "none"
	}	
}

//////////
// showNotAv
//////////
function showNotAv(g, strName){
	var arrN = new Array()

	for (i = 0; i <= numGroups; i++){
		if (optMustBe[i] > -1 && i + 1 != g){
			arrN[arrN.length] = document.getElementById("oName" + (i + 1)).innerHTML + ": <span style='color:#990000'>" + optSelName[i] + "</span>"
		}
	}
	
	var notAv = document.getElementById("notAv")
		
	notAv.innerHTML = "<div style='margin:10px;'>This item is not avaiable in<br>" + arrN.join("<br>") + "<br>" + document.getElementById("oName" + (g)).innerHTML + ": <span style='color:#990000'>" + strName + "</div>" 
	notAv.className = "notAv"
}

/// -------------BEGIN BRAD

//////////
// checkLevel
//////////
function checkLevel(rootStr, chkLevel,chkVal,start){
	//debug += "<br><br>rootStr:" + rootStr + " - chkLevel:" + chkLevel + " chkVal:" + chkVal + " numGroups [" + numGroups +"]<br>" 
	//initial start 
	if (start==1){  
		//debug += "New Start<br>"
		
		if (chkLevel > 1) 
			rootStr += "::";

		//debug += "1.0 Non required option found - " + chkLevel + "<br>"
		if (reqOpt[chkLevel - 1] > 0){
			curCheck[chkLevel - 1] = reqOpt[chkLevel - 1]
			checkLevel((rootStr + reqOpt[chkLevel - 1]), chkLevel + 1,reqOpt[chkLevel - 1],0)
		}
		else
			for(var h=1; h <= numOptions[chkLevel - 1]; h++){
				curCheck[chkLevel - 1] = h				
				checkLevel((rootStr + h), chkLevel + 1,h,0)				
			}
	}else { 		
		curCheck[chkLevel - 2] = chkVal
				
		//recurision
		if (chkLevel <= numGroups){
			//Fixed option
			if (reqOpt[chkLevel - 1] > 0) { 
				//debug += "2.0 Required option found - " + chkLevel + " must be " + reqOpt[chkLevel - 1] + "<br>"
				checkLevel(rootStr + "::" + reqOpt[chkLevel -1],chkLevel+1, reqOpt[chkLevel - 1],0);
			}
			//find next option in next group
			else{ 
				//debug += "2.0 Non required option found - " + chkLevel + "<br>"
				for (var i=1;i <= numOptions[chkLevel - 1]; i++){
					checkLevel(rootStr + "::" + i,chkLevel+1, i,0) 
				}
			}
		}
		//final check
		else{ 				
			if (arrOpt[rootStr]){
				isFound = true
				//debug += "FOUND: " + rootStr + "<br>"
			
				if (minPrice > arrOpt[rootStr].price || minPrice == -1){
					minPrice = arrOpt[rootStr].price
					minMSRP = arrOpt[rootStr].msrp
				}
				if (maxPrice < arrOpt[rootStr].price || maxPrice == -1){
					maxPrice = arrOpt[rootStr].price
					maxMSRP = arrOpt[rootStr].msrp
				}
				//debug += "Array [" + (chkLevel-2) + "][" + (chkVal-1) + "]<br>"
				//debug += "Cur Check:" + curCheck[0] + "::" + curCheck[1] + "::" + curCheck[2] + "::" + curCheck[3] + "::" + curCheck[4]
				
				arrFound[chkLevel-2][chkVal-1] = 1;
				
				for (var x = 0; x < numGroups-1; x++){
					arrFound[x][(curCheck[x]-1)] = 1;
				}				
			}
		}
	}
}

//////////
// hideOpt
//////////
function hideOpt(hide,g,o){
	var b = document.getElementById(g + "::" + o)
	
	//Don't ever check groups with just 1 option
	if (numOptions[g-1] > 1){
		if (hide == 1){
			if (b){
				b.className = "optionNotAvailable"
			}
			hideCnt++;
			arrHidden[hideCnt]= g + "::" + o;
		}
		else{
			if (b){
				if (optMustBe[g - 1] == o)
					b.className = "optionSel"
				else{
					b.className = "option"				
				}
			}
		}
	}
}

//////////
// buildSelID
//////////
function buildSelID(og,strId){
	//builds selected keys
	var aKey = new Array(numGroups)
	
	for (i = numGroups; i >= 1; i--){
		if (i==og) 
			aKey[i -1] = strId
		else{ 
			if (numOptions[i-1] == 1)
				aKey[i - 1] = 1
			else
				aKey[i - 1] = optMustBe[i - 1]
		}
	}
	
	return aKey.join("::");
}

//////////
// buildSelString
//////////
function buildSelString(og,strId){
	//builds selected keys
	var needSelect = "";
	
	for (i = 1; i <= numGroups; i++){
		if (i!=og && numOptions[i-1] > 1){ 
			if (optMustBe[i - 1] == -1){
				if (needSelect != "")
					needSelect += ", "
					
				needSelect += document.getElementById("oName" + i).innerHTML
			}
		}
	}
	
	if (needSelect != ""){
		document.getElementById("divNeedSelect").innerHTML = document.getElementById("spnPart").innerHTML = "Select " + needSelect.toLowerCase();
	}
	else{
		document.getElementById("divNeedSelect").innerHTML = "To Buy, Add to Shopping Cart";
		document.getElementById("divAddError").style.display = "none"
	}
}

//////////
// checkDis
//////////
function checkDis(g, intValue, limitToCurrentGroup){
	hideCnt=-1;
	arrHidden= new Array();
	debug = ""
	var doCheck=false
	reqOpt = new Array(0,0,0,0,0,0,0,0)

	if (g>0 )
		doCheck=true;
	
	//set options that are already selected and or are hovered.  don't need to loop these.
	for (var a = 0; a <= numGroups-1; a++){		
		if (g-1 == a){
			//debug +="reqOpt set: " + (a+1) + "-" + intValue + "<br>"
			reqOpt[a]=intValue
			doCheck=true;
		}
		else if (optMustBe[a] > -1){
			//debug +="Must be set: " + (a+1) + "-" + intValue + "<br>"
			reqOpt[a]=optMustBe[a]
			doCheck=true;
		}
		arrFound[a] = new Array(numOptions[a])
	}

	//debug += "Checking-" + g + "::" + intValue
	//debug += "Must be:" + reqOpt[0] + "::" + reqOpt[1] + "::" + reqOpt[2] + "::" + reqOpt[3] + "::" + reqOpt[4] + "::" + reqOpt[5] + "::" + reqOpt[6] + "::" + reqOpt[7]
	
	var infcatch = 0
	if (doCheck==true){
		var strStart = "";
		
		//Clear Prices
		minPrice = -1
		maxPrice = -1
		minMSRP = -1
		maxMSRP = -1	

		if (!limitToCurrentGroup)			
			for (var a = 0; a < numGroups; a++){
				//debug +="checkStart: " + a + "-" + intValue + "-" + reqOpt[a] + "<br>"
				
				if (reqOpt[a] > 0) {
					if ( a >0 ) 
						strStart += "::";
	
					curCheck[a] = reqOpt[a];
					strStart += reqOpt[a]; 
				}
				else{   
					checkLevel(strStart,a+1,1,1)
					break;
				}
			}
		else{
			checkLevel("",1,1,1)
		}
		
		var hideCount;var availTmp;
		//Don't have to do hides if we're doing a recheck
		if (!limitToCurrentGroup){
			for (var a = 0; a <= numGroups-1; a++){
				//set options that are already selected and or are hovered.  don't need to loop these.
				hideCount=0;availTmp=0
				
				if (optMustBe[a] == -1 && g-1 != a ){  //possibly remove this
					for(var b=0;b<numOptions[a];b++){					
						//debug+="Hide?: " + a + "::" + b + " result: " + arrFound[a][b] + "<br>"
						if(!arrFound[a][b]){
							hideOpt(1,a+1,b+1);
							hideCount +=1;
						}
						else{
							hideOpt(0,a+1,b+1);
							availTmp=b;
						}
					}
					if (g==-1 && hideCount == (numOptions[a]-1)){
						//alert("show" + a + ":" + availTmp);
						var strTmp = String(document.getElementById((a+1) + "::" + (availTmp+1)).getElementsByTagName("div")[0].title);
						strTmp = strTmp.substring(strTmp.length, 16);
	
						oSelect(a+1, availTmp+1, strTmp, false);					
					}
				}
			}
		}
			
		if (g>0)
			divDebug.innerHTML=debug;
	}
}


/// -------------END BRAD

//////////
// oMouseOut
//////////
function oMouseOut(g){
	document.getElementById("notAv").className = "hide"

	switch(g){
		case 1:
			clearTimeout(timer1)
			timer1 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 2:
			clearTimeout(timer2)
			timer2 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 3:
			clearTimeout(timer3)
			timer3 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 4:
			clearTimeout(timer4)
			timer4 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 5:
			clearTimeout(timer5)
			timer5 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 6:
			clearTimeout(timer6)
			timer6 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 7:
			clearTimeout(timer7)
			timer7 = setTimeout("mOut(" + g + ")", "150")
			break;
		case 8:
			clearTimeout(timer8)
			timer8 = setTimeout("mOut(" + g + ")", "150")
			break;
	}
}

//////////
// mOut
//////////
function mOut(g){
	var oSel = document.getElementById("oSel" + g)

	if (optMustBe[g - 1] > -1)
		oSel.innerHTML = "<span style='color:#CC6600'>" + optSelName[g - 1] + "</span>"
	else
		oSel.innerHTML = ""
	
	for(j=hideCnt; j>=0;j--){
		document.getElementById(arrHidden[j]).className = "option"
	}
	
	checkMatch()
	checkDis(0, 0)		
	
	//Hide Larger Image
	if (optLrg){
		optLrg.style.display = "none"
	}	
}

//////////
// intBox
//////////
function intBox(current){
	if (current.innerHTML == "+"){
		current.innerHTML = "-"
		document.getElementById("tblIntBlock").style.display = "block"
	}	
	else{
		current.innerHTML = "+"
		document.getElementById("tblIntBlock").style.display = "none"
	}
	
	return false
}

//////////
// mouseO
//////////
function mouseO(waitCount){
	clearTimeout(showZT)
	showZT = setTimeout(function () {showZoom(1)}, 300);
}

function showZoom(waitCount){
	//Get the position on the screen
	imgPos = findPos(document.getElementById("imgProduct"))
	divPos = findPos(document.getElementById("mainImg"))

	if (waitCount === undefined)
		waitCount = 1
		
	if (waitCount < 10){
		//divDebug.innerHTML += "<br>Load: " + waitCount
		//Set ratios
		var imgSmall = document.getElementById("imgProduct")
		var imgZoom = document.getElementById("imgZoom")

		if (document.getElementById("imgZoom").src != ""){	
			xMulti = imgZoom.width / imgSmall.width
			yMulti = imgZoom.height / imgSmall.height
			
			document.getElementById("divLarge").style.width = "1"
			document.getElementById("divLarge").style.height = "1"
			document.getElementById("divLarge").style.display = "block"
			
			if (xMulti > 0){
				if (xMulti == 1)
					document.getElementById("divLarge").style.display = "none"
				else{
					//Just show the image if the ratio is less then 2
					document.onmousemove = update; // update(event) implied on NS, update(null) implied on IE
					update();
				}
			}
			else{
				showZT = setTimeout(function () {showZoom(waitCount + 1)}, 100);
			}
		}
	}
	else{
		document.getElementById("divLarge").style.width = "1"
		document.getElementById("divLarge").style.height = "1"
		document.getElementById("divLarge").style.display = "block"
	}
	//	divDebug.innerHTML += "<br>Failed Load: " + waitCount
}

//////////
// mouseOut
//////////
function mouseOut(e){
	//getMouseXY(e);

	if (divPos == null){
		return false
	}
		
	if (mousex == 0 && mousey == 0){
		return false
	}	
	
	//document.getElementById("divDebugStatic").innerHTML = "mX:" + mousex + " posX:" + divPos[0] + " mY:" + mousey + " posY" + divPos[1]
	//((mousex - divPos[0]) > 0 && (mousex - divPos[0]) < 310) || (mousey - divPos[1]) > 0 && (mousey - divPos[1]) < 310
	if ((mousex - divPos[0] > 0) && (mousex - divPos[0] < largeImgBoxWidth / 2) && (mousey - divPos[1] > 0) && (mousey - divPos[1] < largeImgBoxHeight / 2)){
		return false
	}

	clearTimeout(showZT)
	
	document.getElementById("divZoomBox").style.display = "none"	
	document.getElementById("divLarge").style.display = "none"
	//document.onmousemove = ""
	mousex = mousey = 0
	
	var imgZoom = document.getElementById("imgZoom")
	imgZoom.style.top = 0
	imgZoom.style.left = 0
	//zoomHideTimeout = setTimeout ("hideZoom()", 50);
}

//////////
// getMouseXY
//////////
function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mousex = e.clientX + document.documentElement.scrollLeft;
      mousey = e.clientY + document.documentElement.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] '
    }  
  }
}

//////////
// update
//////////
function update(e)
{
	if (xMulti == 0){
	
	}
	else{
		var imgSmall = document.getElementById("imgProduct")
		var imgBox = document.getElementById("imgProduct")
		var imgZoom = document.getElementById("imgZoom")

		var divZoomBox = document.getElementById("divZoomBox")
		var vewBody = document.getElementById("vewBody")
		
		xMulti = imgZoom.width / imgSmall.width
		yMulti = imgZoom.height / imgSmall.height
		
		getMouseXY(e); // NS is passing (event), while IE is passing (null)
		//divDebug.innerHTML = "mousex:" + mousex 		
		//divDebug.innerHTML += "<div style='text-align:left'>X on Img:" + (mousex - divPos[0]) + "<br>Y on Img:" + (mousey - divPos[1]) + "<br>X ratio:" + xMulti + "<br>imgPos[0]: " + imgPos[0] + "<br>ZoomBox Left:" + ((mousex-imgPos[0]) - (largeImgBoxWidth / xMulti / 2)) + "<br>largeImgBoxWidth:" + largeImgBoxWidth
		//divDebug.innerHTML += "<br>Box Width: " + (largeImgBoxWidth / xMulti)
		//divDebug.innerHTML += "</div>"		
	
		if ((mousey - divPos[1]) < largeImgBoxHeight / 2 && (mousey - divPos[1]) > 0 && (mousex - divPos[0]) > 0 && (mousex - divPos[0]) < largeImgBoxWidth / 2) {			
			if (imgZoom.width > largeImgBoxWidth || imgZoom.height > largeImgBoxHeight){
				document.getElementById("divLarge").style.display = "block"
				document.getElementById("divLarge").style.width = largeImgBoxWidth + "px"
				document.getElementById("divLarge").style.height = largeImgBoxHeight + "px"
				document.getElementById("divLarge").style.margin = ""
				
				//Large Image
				imgZoom.style.top = -yMulti * (mousey- imgPos[1]) + (largeImgBoxHeight / 2) + "px"
				imgZoom.style.left = -xMulti * (mousex- imgPos[0]) + (largeImgBoxWidth / 2) + "px"
				
				//Zoom Box
				divZoomBox.style.display = "block"
				divZoomBox.style.height = largeImgBoxHeight / yMulti + "px"
				divZoomBox.style.width =  largeImgBoxWidth / xMulti + "px"
				divZoomBox.style.top = (mousey- divPos[1]) - (largeImgBoxHeight / yMulti / 2) + "px"
				divZoomBox.style.left = (mousex- divPos[0]) - (largeImgBoxWidth / xMulti / 2) + "px"
			}
			else{
				if (xMulti > 1 || yMulti > 1){
					document.getElementById("divLarge").style.display = "block"
					document.getElementById("divLarge").style.width = imgZoom.width + 20 + "px"
					document.getElementById("divLarge").style.height = imgZoom.height + 20 + "px"
					imgZoom.style.top = "10"				
					imgZoom.style.left = "10"
				}
			}
		}
		else{
			//document.onmousemove = null;
			mouseOut(e)
		}
	}
}

//////////
// findPos
//////////
function findPos(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	
	return [curleft,curtop];
}

//////////
// resetOption
//////////
function resetOption(){
	try{
		for (i = 0; i < numGroups; i++){
			optMustBe[i] = optDefault[i]
		}
	
		if (arrOpt.length > 0){
			resetOpt()
			checkMatch()
		}
		buildSelString()
	}
	catch(err){
		
	}
}

//////////
// resetOption
//////////
function resetOpt(){
	for (i = 0; i < numGroups; i++){
		if (optMustBe[i] > -1){
			document.getElementById("oSel" + (i + 1)).innerHTML = optSelName[i]
			document.getElementById((i + 1) + "::" + optMustBe[i]).className = "optionSel"
			
			//Check to see if other options should be disabled
			for (var j = 1; j <= numOptions[i]; j++){
				if (j != optMustBe[i]){
					isFound = false
					checkDis(i + 1, j, true)
					
					if (!isFound)
						document.getElementById((i + 1) + "::" + j).className = "optionNotAvailable"
				}
			}
		}
		else{
			for (var j = 1; j <= numOptions[i]; j++){
				document.getElementById((i + 1) + "::" + j).className = "option"
			}
		}
	}
}


