function readCookie(name){
	var nameEQ = name.toLowerCase() + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i].toLowerCase();
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}return null;
}
window.onunload = function(){ 
	if(window.parent.name='masterWin'){window.parent.scroll(0,0);};
 };


function openpopupnotime(url,name,param){window.open(url,name,param);}
function openpopup(url,name,param){	window.open(url ,name,param);}
function get_focus(obj){obj.focus();}
var pathname;
pathname=location.hostname.toLowerCase()
var bName = navigator.appName;
var bVer = parseFloat(navigator.appVersion);
function formatPhone(strPhone){
	strPhone=strPhone.replace(" ","")
	return '(' + strPhone.substring(0,3) + ') ' + strPhone.substring(3,6) +'-' + strPhone.substring(6,10); 
}
function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;expires="+expire.toGMTString();
}

function expireCookie(cookieName){
	var today = new Date();
	document.cookie = cookieName+"=;path=/;expires="+today.getTime();
}
function setDDL(ddlID,strVal){
	var ddl =document.getElementById(ddlID)
	for (var no = 0; no < ddl.options.length; no++){
		if (ddl.options[no].value == strVal){
	    	ddl.selectedIndex = no;break;
		}
	}
}
var updateCount = 0; function checkRefreshTime(rooturl,id,configid,sec) { var detector = document.getElementById('detect'+id); if (detector.src && detector.src != '') { var thisheight = detector.offsetHeight; if (thisheight == 2) { document.getElementById('a'+id+'on').style.display = 'none'; document.getElementById('a'+id+'off').style.display = ''; } else if (thisheight == 1) { document.getElementById('a'+id+'on').style.display = ''; document.getElementById('a'+id+'off').style.display = 'none'; } } updateCount++; if ((updateCount % sec) == 0) { refreshImage(rooturl,id,configid); } setTimeout("checkRefreshTime('"+rooturl+"','"+id+"','"+configid+"',"+sec+");", 1000); } function refreshImage(rooturl,id,configid) { date1 = new Date(); updateurl = rooturl+"ChatScript.ashx?config="+configid+"&refresh=1&time="+date1.getTime(); var detector = document.getElementById('detect'+id); detector.src = updateurl; }

var currentDiv
function showDivDetail(destUrl,destParam,destDiv){
	currentDiv = destDiv
	var divDetails = document.getElementById(destDiv)
	divDetails.style.display="block";
	divDetails.innerHTML = "<img src=\"\/images\/animated\/indicator.gif\"> Loading Manufacturer"
	var ajaxReqObj = new ajaxRequestObjectCache(destUrl,destParam, writeDetail);
	ajaxReqObj.doGetCallback();
}
function writeDetail(strData){document.getElementById(currentDiv).innerHTML = strData}
function hideDivDetail(destDiv){document.getElementById(destDiv).style.display="none";}
function Right(str, n){
	if (n <= 0) return "";
	else if (n > String(str).length)
	   return str;
	else {var iLen = String(str).length;return String(str).substring(iLen, iLen - n);}
}

function readQuery(name){
	var nameEQ = name + "=";
	var ca = location.search.substring(1).split('&'); 
	for(var i=0;i < ca.length;i++)
	{var c = ca[i].toLowerCase();
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ.toLowerCase()) == 0) 
				return c.substring(nameEQ.length,c.length);
	}return null;
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}return "";
}
function toCurrency(dblMoney){
	currency = eval(dblMoney);
   	workNum = Math.abs((Math.round(currency*100)/100));
	workStr = "" +workNum;
   	if (workStr.indexOf(".") == -1)
		workStr+=".00";
	dStr=workStr.substr(0,workStr.indexOf("."));
	dNum=dStr-0;pStr=workStr.substr(workStr.indexOf("."));
	
	if (workNum>=1000) {
	   dLen=dStr.length;dStr=parseInt(""+(workNum/1000))+","+dStr.substring(dLen-3,dLen);
	}
	if (workNum>=1000000) {
	   dLen=dStr.length;	   dStr=parseInt(""+(workNum/1000000))+","+dStr.substring(dLen-7,dLen);
	}
	if (pStr.length == 2) 
		pStr += "0"
	retval = dStr + pStr;
	if (currency < 0)
		retval="- $"+retval;
	else
		retval="$"+retval;
   return retval
}
function stripCurrency(strMoney){
	strMoney = strMoney.replace(/[^0-9.]/g,"")
	strMoney = strMoney * 1.0
	return strMoney
}

function toPercent(dblPercent){
	percent = eval(dblPercent);
	percent = percent * 100
   	workNum = Math.abs((Math.round(percent*100)/100));
	workStr = "" +workNum;
   	if (workStr.indexOf(".") == -1)
		workStr+=".00";
	dStr=workStr.substr(0,workStr.indexOf("."));
	dNum=dStr-0;
	pStr=workStr.substr(workStr.indexOf("."));
	
	retval = dStr + pStr 
	if (percent < 0)
		retval= "- " + retval + "%"
	else
		retval= retval + "%"
   return retval
}
function AddTop(el,bk,color,size){
	var i;
	var d=document.createElement("b");
	var cn="r";
	var lim=4;
	if(size && size=="small"){ cn="rs"; lim=2}
		d.className="rtop";
	d.style.backgroundColor=bk;
	for(i=1;i<=lim;i++){
		var x=document.createElement("b");
		x.className=cn + i;
		x.style.backgroundColor=color;
		d.appendChild(x);
	}
	try{
		el.insertBefore(d,el.firstChild);
	} catch(e) {}
}

function AddBottom(el,bk,color,size){
var i;var d=document.createElement("b");var cn="r";var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
	var x=document.createElement("b");x.className=cn + i;
	x.style.backgroundColor=color;
	d.appendChild(x);
	} 
	try {
	el.appendChild(d,el.firstChild);
	} catch(e) {}
}

function getElementsBySelector(selector){
var i;var s=[];var selid="";var selclass="";var tag=selector;var objlist=[];
if(selector.indexOf(" ")>0){
	s=selector.split(" ");
	var fs=s[0].split("#");
	if(fs.length==1) return(objlist);
	return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
	}
if(selector.indexOf("#")>0){
	s=selector.split("#");
	tag=s[0];
	selid=s[1];
	}
if(selid!=""){
	objlist.push(document.getElementById(selid));
	return(objlist);
	}
if(selector.indexOf(".")>0){
	s=selector.split(".");
	tag=s[0];
	selclass=s[1];
	}
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
	return(v);
for(i=0;i<v.length;i++){
	if(v[i].className==selclass){
		objlist.push(v[i]);
		}
	}
return(objlist);
}

function fnDefault(btn, event){
	var key = (window.event) ? event.keyCode : event.which;
	if (btn != undefined && key == 13)
	{ 
		if (event.stopPropagation)
		{event.stopPropagation();event.preventDefault();		}
		event.returnValue = false;
		event.cancelBubble = true;
		btn.click();
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {window.onload = func;} else { window.onload = function() {
	  oldonload();
	  func();
	}
  }
}
function clickButton(e, buttonid){ 
	  var bt = document.getElementById(buttonid); 
	  if (typeof bt == 'object'){ 
	  	if(e.keyCode){ if (e.keyCode == 13){ bt.click(); return false; } }
			else{if (event.keyCode){ if (event.keyCode == 13){ bt.click(); return false; } } } } 
}
function insertAfter(newElement, targetElement){
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement){	parent.appendChild(newElement);	} else {parent.insertBefore(newElement, targetElement.nextSibling);	}
} 
var hideDivAcct, hideDivSite, hideDivShop
function fnHide(sID){
 	document.getElementById(sID + "subMenu").style.display = "none";
}
function clearDiv(strLinkId){
	if (strLinkId == "acctLink")
		hideDivAcct = setTimeout("fnHide('" + strLinkId + "')", 300);
	else
		if (strLinkId == "hrefSite")
			hideDivSite = setTimeout("fnHide('" + strLinkId + "')", 300);
		else
			hideDivShop = setTimeout("fnHide('" + strLinkId + "')", 300);
}
function showSub(currentLink){
	var divSub = document.getElementById(currentLink.id + "subMenu")
	if (divSub.style.display != "block")
		divSub.style.display = "block"
}
function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1){
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj){
  var curtop = 0;
  if(obj.offsetParent)
	  while(1)
	  {
		curtop += obj.offsetTop;
		if(!obj.offsetParent)
		  break;
		obj = obj.offsetParent;
	  }
  else if(obj.y)
	  curtop += obj.y;
  return curtop;
}
function rpLink(){
		if (readCookie("user%5Fid") != null && readCookie("lui%5Frep%5Fid") !=null  && readCookie("fullName") !=null ) {
			document.write( "<a class='whiteNoUnderLine smallerText' href='/admin/orders/customer.asp?id=" + readCookie("user%5Fid")  +"'>" + readCookie("fullName") + "</a><a class='whiteNoUnderLine smallerText' href='/includes/logout.aspx'>Logout</a>");
		}
}
function loadCart(){
	if (readCookie("cartItem")!=null ) {
		if (readCookie("cartItem").indexOf("~") > 0)
			SetCookie("cartItem",0 + "-" + 0,-1)
	
		var arCart = readCookie("cartItem").split('-');
		if (arCart.length == 2){
			if (arCart[0] == 0)
				document.write('0 Items : <strong>$0.00' );
			else
				document.write( arCart[0] + ' Items : <strong>' + toCurrency(arCart[1]) );
		}
	}
	else
		document.write('0 Items : <strong>$0.00' );
}
function showRecentViewed(){
	var cookieVal;cookieVal=readCookie('recentView');
	if (cookieVal !=null){
		var ca = cookieVal.split('~');
		document.write('<div id="divRecentItem"><h2 class="separator">Recently Viewed</h2><ul>');
		for(var i=0;i < ca.length;i++){ 
			var ca2 = ca[i].split('|');
			if (ca2[0].length>0 ){
				document.write("<li><a href='/products/view.aspx?sku=" + ca2[0] + "&linkLoc=recent' style='width:75px;height:75px;border:1pt solid #CCC;'>");
				if (ca2[3].length > 5)
					document.write("<img src='//hi.atgimg.com/img/t/" + ca2[3] +"'>");
				else
					document.write("No Image");
				document.write("</a>");
				if (ca2[2])
					document.write("<p class='price'>" + toCurrency(ca2[2]) + "</p></li>");}	  
		} 
		document.write('</ul></div>');
	}
}
function sendFeedBack(groupID){
	location.protocol + '//' + location.host + location.pathname + location.search
	
	var divFeedBack = document.getElementById("divFeedBackForm")
	if (groupID=="" ) groupID=0;
	if (document.getElementById("txtFeedBack").value != "We appreciate your suggestions. Please note that we are unable to respond directly to every suggestion."){
		var ajaxReqObj = new ajaxRequestObject("/ajax/miniFeedBack.aspx","group_id="+ groupID + "&feedback=Page: <a href='"  + escape(location.protocol + '//' + location.host + location.pathname + location.search) + "'>" + escape(location.protocol + '//' + location.host + location.pathname + location.search) + "</a><br>" + escape(document.getElementById("txtFeedBack").value));
		ajaxReqObj.doGetCallback();
	}
	divFeedBack.innerHTML = "<span style='color: green'>Thank you for your feedback.</span>"
}

function writeFeedBack2(groupID){document.write('<div id=\"miniFeedBack\" style=\"clear:both;\"><h2 class="separator">Suggestion Box</h2><p><strong>Need help</strong>? Have a <strong>question for customer service</strong>? Use our <a id="aControlIDon"  href="https://server.iad.liveperson.net/hc/51320037/?cmd=file&file=visitorWantsToChat&site=51320037&byhref=1&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/" target="chat51320037"  onClick="javascript:window.open(\'https://server.iad.liveperson.net/hc/51320037/?cmd=file&file=visitorWantsToChat&site=51320037&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer=\'+escape(document.location),\'chat51320037\',\'width=475,height=400,resizable=yes\');return false;" >Live Chat</a> or call ' + sitePhone + '</p><div style="border-top:1pt solid #CCC;margin:10px;"></div><div id="divFeedBackForm"><p>Tell us how we can <strong>improve this page</strong><br><textarea rows="3" cols="66" id="txtFeedBack" onclick="this.value=\'\'">We appreciate your suggestions. Please note that we are unable to respond directly to every suggestion. If you need help please contact us using the links above.</textarea><br><input type="button" value="Send Suggestion" onClick="sendFeedBack(\''+ groupID + '\')"/></p></div></div>');}

function track(strName, strValue1, strValue2){
	var ajaxReqObj=new ajaxRequestObject("/ajax/track.aspx","name="+strName + "&value1=" + strValue1 + "&value2=" + strValue2);
	ajaxReqObj.doGetCallback();
}
var cur=-1
var show=true

function $(){return document.getElementById(arguments[0]);}
function autoFillNav(){
	switch(event.keyCode){
		case 13: enter(); break;
		case 38: move("up"); break;
		case 40: move("down"); break;
		default:
			var tbxSearchTerm=$("tbxsearchterm")
			
			if (tbxSearchTerm.value.length>3){
				var ajaxReqObj=new ajaxRequestObjectCache("/ajax/fillSearch.aspx","term=" + tbxSearchTerm.value, showFillNav);
				ajaxReqObj.doGetCallback();
			}
			else hideFNDelay()
	}
}
function enter(){
	show=false

	if (cur>-1){
		var tbxSearchTerm=$("tbxsearchterm")
		var nm=$("divNavMatch")
		var arrDiv=nm.getElementsByTagName("div")
		var strSearch=arrDiv[cur].getElementsByTagName("a")[0].innerHTML.replace(new RegExp( "^\<span[^\<]*", "i" ), tbxSearchTerm.value).replace(new RegExp( "\<\/span\>", "i" ), "")
	
		window.location='/search/default.aspx?term=' + strSearch
	}
}
function move(strDirect){
	var nm=$("divNavMatch")
	var arrDiv=nm.getElementsByTagName("div")
	
	if (strDirect=="down") cur++
	else cur--
		
	if (cur>arrDiv.length - 1) cur=-1
	if (cur<-1) cur=arrDiv.length - 1
	
	for (var intCount=0; intCount<arrDiv.length; intCount++){
		if (intCount==cur) arrDiv[intCount].getElementsByTagName("a")[0].style.background="#DDD"
		else arrDiv[intCount].getElementsByTagName("a")[0].style.background="#FFF"		
	}
}
function showFillNav(strFill){
	if (show){
		var arrResult=strFill.split("~")
		var nm=$("divNavMatch")
		var tbxSearchTerm=$("tbxsearchterm")
		nm.innerHTML=""
		currentLength=arrResult.length
		
		if (arrResult.length>1){
			nm.className="fillBoxNav"
		
			for (var intCount=0; intCount<arrResult.length - 1; intCount++){
				var matchResult=arrResult[intCount].replace(tbxSearchTerm.value.replace(/^\s+/,"").toLowerCase(), "<span style=\"color: #6699FF; padding: 0px; margin: 0px;\">" + tbxSearchTerm.value.toLowerCase() + "</span>")
				nm.innerHTML +="<div style=\"margin:5px\"><a href=\"\/search\/default.aspx?term=" + arrResult[intCount] + "\" class=\"smallerText\" style=\"padding: 3px 3px; display: block; text-decoration:none;\" onm=ouseout=\"this.style.background='#FFF'\" onm=ouseover=\"clearSelectNav(); this.style.background='#DDD';this.style.color='#003399'\">" + matchResult + "</a></div>"
			}
		}
		else{ nm.className="hide"; nm.innerHTML="" }
	}
	else{ nm.className="hide"; nm.innerHTML="" }
}
function clearSelectNav(){
	if (cur>-1){
		var nm=$("divNavMatch")
		var arrDiv=nm.getElementsByTagName("div")
		cur=-1
	
		for (var intCount=0; intCount<arrDiv.length; intCount++){ arrDiv[intCount].getElementsByTagName("a")[0].style.background="#FFF" }
	}
}
function hideFN(){setTimeout(hideFNDelay,1000);}
function hideFNDelay(){ 
	var nm=$("divNavMatch"); 
	nm.className="hide"; 
	nm.innerHTML=""
}


function ajaxRequestObject(requestURL, queryString, responseMethod)
{
	var ro = init();
	ro.onreadystatechange = processRequest;
	
	 function init(){
		if (window.XMLHttpRequest){
			  return new XMLHttpRequest();
		}
		else if (window.ActiveXObject){
			  return new ActiveXObject("Microsoft.XMLHTTP");
		}
	 
	}
	
	this.doGetCallback = 
	function(){
		var rand = new Date().getTime();
		ro.open('get',requestURL+'?'+queryString +'&rand='+rand);
		ro.send(null);
	}
	this.doPostCallback = 
	function(body){
		var rand = new Date().getTime();
		ro.open('post',requestURL+'?'+queryString +'&rand='+rand);
		ro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ro.send(body);		
	}
	
	function processRequest(){
		if(ro.readyState == 4){
			if(responseMethod){
				responseMethod(ro.responseText);
			}
		}
	}
}

function ajaxRequestObjectCache(requestURL, queryString, responseMethod)
{
	var ro = init();
	ro.onreadystatechange = processRequest;
	
	 function init(){
		if (window.XMLHttpRequest){
			  return new XMLHttpRequest();
		}
		else if (window.ActiveXObject){
			  return new ActiveXObject("Microsoft.XMLHTTP");
		}	 
	}
	
	this.doGetCallback = 
	function(){
		ro.open('get',requestURL+'?'+queryString);
		ro.send(null);
	}
	this.doPostCallback = 
	function(body){
		var rand = new Date().getTime();
		ro.open('post',requestURL+'?'+queryString);
		ro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ro.send(body);		
	}
	
	function processRequest(){
		if(ro.readyState == 4){
			if(responseMethod){
				responseMethod(ro.responseText);
			}
		}
	}
}

function flipSpinner(loaderElementID)
{
	var loader = document.getElementById(loaderElementID);
	if(loader.style.display == "none" )
	{
		loader.style.display = "";
	}
	else
	{
		loader.style.display = "none";
	}
	
}

function hideElement(elementID)
{
	document.getElementById(elementID).style.display = 'none';
}

function showElement(elementID)
{
	document.getElementById(elementID).style.display = '';
}

