var bo_ns_id = 0;
function startIeFix(){  
	if(isIE()){
		document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
	}
}
function endIeFix(){
	if(isIE()){
		document.write('</div>');
		var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
		var theCode = theObject.innerHTML;
		theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
		document.write(theCode);
	}
}
function isIE(){
// only for Win IE 6+  
// But not in Windows 98, Me, NT 4.0, 2000
var strBrwsr= navigator.userAgent.toLowerCase();
if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
	if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
		return false;    
	}
	if(strBrwsr.indexOf("win98") > -1 ||
		strBrwsr.indexOf("win 9x 4.90") > -1 ||
		strBrwsr.indexOf("winnt4.0") > -1 ||
		strBrwsr.indexOf("windows nt 5.0") > -1) 
	{
		return false;
	}
		return true;  
	}else{
		return false;
	}
}


// JScript File
function hideSelects(action) {
    //documentation for this script at http://www.shawnolson.net/a/1198/
    //possible values for action are 'hidden' and 'visible'
    if (action!='visible'){action='hidden';}
    if (document.all) {
        for (var S = 0; S < document.forms.length; S++){
            for (var R = 0; R < document.forms[S].length; R++) {
                if (document.forms[S].elements[R].options) {
                    document.forms[S].elements[R].style.visibility = action;
                }
            }
        }
    }
}
function Stretch(Q, L, c) { 
    var S = Q + '';
    
    if (c.length>0) {
        while (S.length<L) { 
            S = c+S; 
        }
    }
    return S
}
function promoWindow() {
    if (document.form1.lstSkus != null) {
	    size = document.form1.lstSkus.value;
    } else {
	    size = '              ';
    }

    for (var i=0; i < arSkus.length; i++) {
	    if (arSkus[i][0] == size) {		
		    if (document.getElementById("itemPromotions")) {
			    if (arSkus[i][10]) {
				    var item = escape(document.form1.txtItem.value);
				    
				    if (window.encodeURIComponent) {
				        var sku = encodeURIComponent(document.form1.txtSku.value);
				    } else {
				        var sku = escape(document.form1.txtSku.value);
				    }
				    
				    
				    var qty = document.form1.txtQty.value;
				    newWindow = window.open("/store/promo.aspx?i="+item+"&s="+sku+"&q="+qty,"Promotions","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=525");
				    return false;
			    } else {
				    return true;
				    document.form1.submit();
			    }
		    }
	    }
    }
}
function bigImage()	{
	if (sBigImage != "#") {
		newWindow = window.open("/store/bigImage.aspx?img=" + sBigImage + "","Display","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + xPos + ",height=" + yPos);
	}
	return false;
}
function openWindow(url, x, y) {
	newWindow = window.open(url,"PopUp","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+x+",height="+y)
}
function askQuestion(topic, subject, name, email)	{
  newWindow = window.open("/help_desk/askquestion.asp?topic=" + topic + "&subject=" + subject + "&name=" + name + "&email=" + email,"AskQuestion","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=425,height=400")
}
function priceMatch(i, s, m)	{
  newWindow = window.open("/store/pricematch.aspx?i="+i+"&s="+s+"&m="+m,"PriceMatch","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=455,height=520")
}
function emailPage(url)	{
  newWindow = window.open("/store/emailpage.aspx?url=" + url,"EmailPage","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=425,height=475")
}
function chooseBrand(i) {
	if (i != "") {
		location.replace("/store/brand/?" + i + "&p=1");
	}
}
function tooLow() {
	newWindow = window.open("/help_desk/tooLow.aspx","PopUp","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=350,height=375")
}
function techlibrary(page) {
	var path = '/help_desk/techlibrary/';
	var windowname = 'techlibrary';
	var attributes = 'toolbar=yes,scrollbars=yes,resizable=yes,width=500,height=550';
	window.open(path+page, windowname, attributes);
};
function bigImageNew(img, x, y)	{
	if (img != "#") {
	    if (x + 100 < 775) {
	        x = x + 100;
	    } else if (x + 100 < 400) {
	        x = 400;
	    } else {
	        x = 775;
	    }
	    if (y + 100 < 400) {
	        y = 400;
	    } else if (y + 100 < 575) {
	        y = y + 100;
	    } else {
	        y = 575;
	    }
		newWindow = window.open("/store/bigImage.aspx?img=" + img + "","Display","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + x + ",height=" + y);
	}
	return false;
}

function reviewItem(i)	{
	newWindow = window.open("/store/review.aspx?i=" + i + "","WriteAReview","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=550");
	return false;
}

function reviewHelpful(reviewID, item, uid, helpful) {
	var isMinNS6 = (navigator.appName.indexOf("Netscape") >= 0 &&
    parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
	var isMinIE4 = (document.all) ? 1 : 0;
	var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;

	if (isMinIE5) {
		var httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
		httpRequest.open('GET', '/store/reviewhelpful.aspx?id='+reviewID+'&i='+item+'&uid='+uid+'&h='+helpful, false);
		httpRequest.send();
	} else if (isMinNS6) {
		var httpRequest = new XMLHttpRequest();
		httpRequest.open('GET', '/store/reviewhelpful.aspx?id='+reviewID+'&i='+item+'&uid='+uid+'&h='+helpful, false);
		httpRequest.send(null);
	}
	
	if (document.getElementById("divHelpful-"+reviewID)) {
		document.getElementById("divHelpful-"+reviewID).innerHTML = "Your response has been logged.  Thank You."
	}
	
	return false;
}
function selectSize() {
    var size = document.form1.lstSkus.value;
    
    for (var i=0; i < arSkus.length; i++) {
	    if (arSkus[i][0] == size) {
		
		    document.form1.txtSku.value = size;

		    sBigImage = arSkus[i][7];
		    xPos = arSkus[i][8];
		    yPos = arSkus[i][9];
				
		    if (prevImage != arSkus[i][1]) {
			    document.getElementById("imgProduct").src = arSkus[i][1];
			    prevImage = arSkus[i][1];
		    }
			
		    if (arSkus[i][11]) {
			    //document.getElementById("trYourPriceStockStatus").style.display="none";
			    //document.getElementById("btnAddToCart").value = "Add To Cart at Market Price";
		    } else {
			    if (document.all) {
				    //document.getElementById("trYourPriceStockStatus").style.display="inline";
			    } else {
				    //document.getElementById("trYourPriceStockStatus").style.display="table-row";
			    }
			    //document.getElementById("btnAddToCart").value = "Add To Shopping Cart";
		    }
			
		    document.getElementById("litPriceRange").innerHTML = arSkus[i][2];
		    //document.getElementById("tdStockStatus").innerHTML = arSkus[i][3];
			
		    if (arSkus[i][4]) {
			    //document.getElementById("divSoldOut").style.display="inline";
		    } else {
			    //document.getElementById("divSoldOut").style.display="none";
		    }
			
		    if (arSkus[i][5]) {
			    document.getElementById("btnAddToCart").style.display="inline";
			    document.getElementById("itemUnavailble").style.display="none";
		    } else {
			    document.getElementById("btnAddToCart").style.display="none";
			    document.getElementById("itemUnavailble").style.display="inline";
		    }
			
		    if (document.getElementById("itemPromotions")) {
			    if (arSkus[i][10]) {
				    if (document.all) {
					    document.getElementById("itemPromotions").style.display="inline";
				    } else {
					    document.getElementById("itemPromotions").style.display="table-row";
				    }
			    } else {
				    document.getElementById("itemPromotions").style.display="none";
			    }
		    }
			
		    if (arSkus[i][6]) {
			    if (document.all) {
			        document.getElementById("trStockAlertHeader").style.display="inline";
				    document.getElementById("trStockAlert").style.display="inline";
			    } else {
			        document.getElementById("trStockAlertHeader").style.display="table-row";
				    document.getElementById("trStockAlert").style.display="table-row";
			    }
				
		    } else {
			    if (document.all) {
			        document.getElementById("trStockAlertHeader").style.display="none";
				    document.getElementById("trStockAlert").style.display="none";
			    } else {
			        document.getElementById("trStockAlertHeader").style.display="none";
				    document.getElementById("trStockAlert").style.display="none";
			    }
		    }
			
		    if (arSkus[i][12]!='') {
			    if (document.all) {
				    //document.getElementById("trMSRP").style.display="inline";
			    } else {
				    //document.getElementById("trMSRP").style.display="table-row";
			    }
			    //document.getElementById("lblMSRP").innerHTML=arSkus[i][12];
		    } else {
			    if (document.all) {
				    //document.getElementById("trMSRP").style.display="none";
			    } else {
				    //document.getElementById("trMSRP").style.display="none";
			    }
		    }
		    
		    if (arSkus[i][13]) {
				document.getElementById("itemInStoreOnly").style.display="inline";
				document.getElementById("itemUnavailble").style.display="none";
		    } else {
    		    document.getElementById("itemInStoreOnly").style.display="none";
		    }
		    
		    document.getElementById("litPriceMSRP").innerHTML = arSkus[i][14];
		    
		    if (arSkus[i][15]!='') {
			    //if (document.all) {
				    document.getElementById("itemSave").style.display="inline";
			    //} else {
				    //document.getElementById("itemSave").style.display="table-row";
			    //}
			    document.getElementById("itemSave").innerHTML=arSkus[i][15];
		    } else {
			    //if (document.all) {
				    document.getElementById("itemSave").style.display="none";
			    //} else {
				    //document.getElementById("itemSave").style.display="none";
			    //}
		    }
	    }
    }
}

function LTrim(str) {
  for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
  return str.substring(k,str.length);
}
function RTrim(str) {
  for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
  return str.substring(0,j+1);
}
function Trim(str) {
  return LTrim(RTrim(str));
}

startList = function() {
    if (document.all&&document.getElementById) {
        var agt = navigator.userAgent.toLowerCase();
        
        if (agt.indexOf('opera')==-1) {
            navRoot = document.getElementById("drop-menu");
            
            if (navRoot) {
                for (i=0; i<navRoot.childNodes.length; i++) {
                    node = navRoot.childNodes[i];
                    if (node.nodeName=="LI") {
                        node.onmouseover=function() {
                            this.className+=" over";
                        }
                        node.onmouseout=function() {
                            this.className=this.className.replace(" over", "");
                        }
                    }
                }
            }
        }   
    }
}
window.onload=startList;