﻿// Horizontal menu helper
sfHover = function() {
    var navList = document.getElementById("ctl00_StandardHeader1_StandardCategoryMenu1_navList");
    if ( navList != null ) {
        var sfEls = navList.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);


// HTTPS Seal
function verifySeal()
{
    var url = 'https://seal.godaddy.com:443/verifySeal?sealID=15472162370b72aea512710970616e2617a2e09981570366653601264';		
    window.open(url,'SealVerfication','location=yes,status=yes,resizable=yes,scrollbars=yes,width=650,height=550');
}       


// Google tracking
//_uacct = "UA-799594-1";
//urchinTracker();


// Used by Product page
function popupLargeImage(url) 
{
    var popupWin, l, t, h,w;
    h = 800;
    w = 650;
	l = ((screen.width - w) / 2);
	t = ((screen.height - h) /2);
    popupWin = window.open(url,'images','width='+w+',height='+h+',left='+l+',top='+t);
    try {
	    if ( window.focus ) popupWin.focus();
	}
    catch(err)
    {
        alert("Unable to open the popup window to show product images. Please configure any popup blocker to allow popups from this site.");
    }
	return false;
}



function clearField(field) {
  // Check if field contains the default value
  if (field.value == field.defaultValue) {
    // It does, so clear the field
    field.value = "";
  }
}


function clickButton(e, buttonid){
      var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
} 


function CheckAll(pattern, bCheck)
{
    var inps = document.getElementsByTagName("input");
    var i;
    for(i=0;i<inps.length;i++)
    {
        if(pattern =='' || inps[i].id.indexOf(pattern) >=0)
            if (inps[i].type == 'checkbox')
                inps[i].checked = bCheck;
    }
}

function SelectAllCheckboxes(chkAll, pattern)
{
    CheckAll(pattern, chkAll.checked);
}


// Used by calendar control to hide it after a selection
function HideCalendar(oCalendar)
{
    oCalendar.hide();
    oCalendar.get_element().blur();
}


// Used by the update progress 
var InUpdatingMode = false;

function CenterAndShowDivInPage(divBackgroundName, divForegroundName, delay, margin)
{
    var clientWidth = 0;
    var clientHeight = 0;
    var pageWidth = 0;
    var pageHeight = 0;

    var divForeground = $get(divForegroundName);
    var divBackground = $get(divBackgroundName);
    
    // place the div on the visible part of the screen
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop  = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
    if (window.innerWidth)
        clientWidth = (window.__safari ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
    else
        clientWidth = document.documentElement.clientWidth;
    if (window.innerHeight)
        clientHeight = (window.__safari ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
    else
        clientHeight = document.documentElement.clientHeight;
    
    // Firefox 
    if( window.innerHeight && window.scrollMaxY ) 
    {
        pageWidth = window.innerWidth + window.scrollMaxX;
        pageHeight = window.innerHeight + window.scrollMaxY;
    }
    // all but Explorer Mac
    else if( document.body.scrollHeight > document.body.offsetHeight ) 
    {
        pageWidth = document.body.scrollWidth;
        pageHeight = document.body.scrollHeight;
    }
    // works in Explorer 6 Strict, Mozilla (not FF) and Safari
    else 
    { 
        pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        pageHeight = document.body.offsetHeight + document.body.offsetTop; 
    }   
    
    var x, y, w, h;
    if ( margin >= 0 ) 
    {
        x = scrollLeft + margin;
        y = scrollTop + margin;
        w = clientWidth - margin - margin;
        h = clientHeight - margin - margin;
        divForeground.style.width = w+'px';
        divForeground.style.height = h+'px';
    }
    else 
    {
//        divForeground.style.display = 'block';
        var divForegroundBounds = Sys.UI.DomElement.getBounds(divForeground);        
        x = scrollLeft + ( clientWidth - divForegroundBounds.width) / 2;
        y = scrollTop + ( clientHeight - divForegroundBounds.height) / 2;
    }
    divForeground.style.left = x + 'px';
    divForeground.style.top = y +'px';
    if ( delay == 0 )
        divForeground.style.display="block";
    
    // place background div to cover screen
    divBackground.style.left = '0px';
    divBackground.style.top = '0px';
    divBackground.style.width = pageWidth+'px';
    divBackground.style.height = pageHeight+'px';
    if ( delay == 0 )
        divBackground.style.display="block";
    
    InUpdatingMode = true;
    
    if ( delay > 0) 
    {
        var timeoutFunc = "ShowDivInPage('" + divBackgroundName + "','" + divForegroundName + "')";
        window.setTimeout(timeoutFunc, delay);
    }
}


function HideDivInPage(divBackgroundName, divForegroundName)
{
    InUpdatingMode = false;
    var divForeground = $get(divForegroundName);
    var divBackground = $get(divBackgroundName);
    
    // make it invisible
    divForeground.style.display = 'none';
    divBackground.style.display = 'none';
}


function ShowDivInPage(divBackgroundName, divForegroundName)
{
    if ( !InUpdatingMode)
        return;
    var divForeground = $get(divForegroundName);
    var divBackground = $get(divBackgroundName);
    
    // make it invisible
    divForeground.style.display = 'block';
    divBackground.style.display = 'block';
}

function OnUpdatePanelUpdating()
{
    CenterAndShowDivInPage('divBackground','divProgress',250,-1);
}

function OnUpdatePanelUpdated()
{
    HideDivInPage('divBackground','divProgress');
}

function ToggleFilter(ctrl, cs, showMsg, hideMsg) {
    var lis = document.getElementsByTagName("li");
    var i;
    var showing = false;
    for (i = 0; i < lis.length; i++) {
        var li = lis[i];
        if (li.className == cs) {
            if (li.style.display == 'none' || li.style.display == '') {
                li.style.display = 'block'
                showing = true;
            }
            else
                li.style.display = 'none'
        }
    }

    if (showing)
        ctrl.innerHTML = hideMsg;
    else
        ctrl.innerHTML = showMsg;
}


function ShowPopup(url, w, h, modal, feat) {
    var popupWin, left, top;
    left = ((screen.width - w) / 2);
    top = ((screen.height - h) / 2);
    if (modal && window.showModalDialog)
        popupWin = window.showModalDialog(url, window, 'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top + feat);
    else
        popupWin = window.open(url, 'PopupWindow', 'width=' + w + ',height=' + h + ',left=' + left + ',top=' + top + feat);
    try {
        popupWin.focus();
    }
    catch (err) {
        alert("Unable to open a popup window. Please configure any popup blocker to allow popups from this site.");
    }
    return false;
}