function handleEnterKey(Link) {
    if (13 == event.keyCode) {
        event.returnValue = false;
        event.cancel = true;
        location.href = Link;
    }
}


// the folowing four functions are used by articles to insert site-specific html code.
function ProductLink(ProductID, Description, Class) {
	document.write("<a href='/Shop/ByCategory/Product/Default.aspx?ProdID=" + ProductID + "' class='" + Class + "'>" + Description + "</a>");
}
function AddToCartLink(ProductID, Class) {
}
function rwtxtzoom(Text, ZoomImageSrc, ZIHeight, ZIWidth, Title, Caption) {
	document.write("<a href=\"javascript:popUp('/Explore/Zoom.aspx?ImageSrc=' + encodeURIComponent('" + ZoomImageSrc + "') + '&Height=" + ZIHeight + "&Width=" + ZIWidth + "&Title=' + encodeURIComponent('" + Title + "') + '&Caption=' + encodeURIComponent('" + Caption + "')," + (parseInt(ZIWidth) + 60) + "," + (parseInt(ZIHeight) + 230) + ");\">" + Text + "</a>");
}
function rwimgzoom(ImageSrc, ImgHeight, ImageWidth, ZoomImageSrc, ZIHeight, ZIWidth, Title, Caption) {
	document.write("<a href=\"javascript:popUp('/Explore/Zoom.aspx?ImageSrc=' + encodeURIComponent('" + ZoomImageSrc + "') + '&Height=" + ZIHeight + "&Width=" + ZIWidth + "&Title=' + encodeURIComponent('" + Title + "') + '&Caption=' + encodeURIComponent('" + Caption + "')," + (parseInt(ZIWidth) + 60) + "," + (parseInt(ZIHeight) + 230) + ");\">");
	document.write("<img src=" + ImageSrc + " height=" + ImgHeight + " width=" + ImageWidth + " border='0' alt=" + Caption + ">");
	document.write("</a>");
}


// Open Window Funtions
function popUp(Path, Width, Height) 
{
	window.open(Path, 'HorizonPopUp', 'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,resizable=0,width=' + Width + ',height=' + Height + ',left=50,top=50');
}

function openSurveyWindow() {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('/Survey/SurveyStart.aspx', 'Survey', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=0,width=500,height=425,left = 50,top = 50');");
	eval("page" + id + ".focus();"); 
}


// Rollover Functions
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



			var strUserAgent = navigator.userAgent.toLowerCase();
			var isIE = strUserAgent.indexOf("msie") > -1;
			var isNS6 = strUserAgent.indexOf("netscape6") > -1;
			var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion) < 5;

			//regular expressions
			var reValidChars = /\d/;

			//mask function
			function maskKeyPress(objEvent) {
				var iKeyCode, strKey;

				if (isIE) {
					iKeyCode = objEvent.keyCode;
				} else {
					iKeyCode = objEvent.which;
				}

				strKey = String.fromCharCode(iKeyCode);

				if (!reValidChars.test(strKey)) {
					return false;
				}
			}


			var isNN = (navigator.appName.indexOf("Netscape")!=-1);
			function autoTab(input,len, e) {
				var keyCode = (isNN) ? e.which : e.keyCode;
				var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
				if(input.value.length >= len && !containsElement(filter,keyCode)) {
				input.value = input.value.slice(0, len);
				input.form[(getIndex(input)+1) % input.form.length].focus();
			}
		function containsElement(arr, ele) {
			var found = false, index = 0;
			while(!found && index < arr.length)
			if(arr[index] == ele)
			found = true;
			else
			index++;
			return found;
			}
		function getIndex(input) {
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
			return index;
			}
			return true;
			}
			
function ToggleVisibility(Element){
	obj = document.getElementById(Element);
	obj.style.display = ((obj.style.display == 'none') ? '' : 'none');			
}

function ToggleSearchBrandFilter(){
	ToggleVisibility('AllBrandsExpanded');
	ToggleVisibility('Top5Brands');
	ToggleVisibility('SearchBrandFilter_AllBrandsCollapse');
	ToggleVisibility('SearchBrandFilter_RecordCount');	
	//if (document.getElementById('BrandLabel').innerHTML == "TOP BRANDS")
		//{document.getElementById('BrandLabel').innerHTML = "ALL BRANDS"}
	//else
		//{document.getElementById('BrandLabel').innerHTML = "TOP BRANDS"}	
}

function ToggleSearchCategoryFilter(){
	ToggleVisibility('AllCategoriesExpanded');
	ToggleVisibility('Top5Categories');	
	
	//if (document.getElementById('CategoryLabel').innerHTML == "TOP CATEGORIES")
		//{document.getElementById('CategoryLabel').innerHTML = "ALL CATEGORIES"}
	//else
		//{document.getElementById('CategoryLabel').innerHTML = "TOP CATEGORIES"}
}

function ToggleSearchRoadNameFilter(){
	ToggleVisibility('AllRoadnamesExpanded');
	ToggleVisibility('Top5Roadnames');
	ToggleVisibility('SearchRoadnameFilter_RecordCount');
	ToggleVisibility('SearchRoadnameFilter_AllRoadNamesCollapse');
	
	//if (document.getElementById('RoadnameLabel').innerHTML == "TOP ROADNAMES")
		//{document.getElementById('RoadnameLabel').innerHTML = "ALL ROADNAMES"}
	//else
		//{document.getElementById('RoadnameLabel').innerHTML = "TOP ROADNAMES"}
}


sfHover = function() {
	if (document.getElementById("nav")) {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// _____________________________________________________ Homepage Tabs

function showTab(tabId, tabNo)
{
	var tabCollection = document.getElementById(tabId);
	tabCollection.className='Tab'+tabNo+'Visible';
}


