// JavaScript Document

// Offset for images in different subdirectories.
//var itemLevel = window.location.href.substring(window.location.href.indexOf("www") + 4).split("/").length -1;
//var offsetText = "";
//for(var i = 0; i < itemLevel; i++)
 //   offsetText += "../";

function openWin(page,ww,wh)
{
   var sw;
   var sh;
   var ssx;
   var ssy;
   var winopt;

   sw=new Number(screen.availWidth);
   sh=new Number(screen.availHeight);
   ssx = (sw/2)-(ww/2);
   ssy= (sh/2)-(wh/2);

   if (ssy <0) {
   	ssy=0;
   }
   if (ssx <0) {
   	ssx=0;
   }
	winopt = "width=" + ww + ",height=" + wh + ",resizable=0,scrollbars=0,status=0,titlebar=0,screenX="+ ssx + ", screenY=" + ssy + ", Top=" + ssy + ", Left=" + ssx +",toolbar=no,menubar=no,location=no"
	window.open(page,'_blank', winopt);
}
// Rollovers
function initRollovers() {
    if (!document.getElementById) return
    
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');

    for (var i = 0; i < aImages.length; i++) {
        if (aImages[i].className == 'imgover') {
            var src = aImages[i].getAttribute('src');
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var hsrc = src.replace(ftype, '_on'+ftype);

            aImages[i].setAttribute('hsrc', hsrc);
            
            aPreLoad[i] = new Image();
            aPreLoad[i].src = hsrc;
            
            aImages[i].onmouseover = function() {
                sTempSrc = this.getAttribute('src');
                this.setAttribute('src', this.getAttribute('hsrc'));
            }    
            
            aImages[i].onmouseout = function() {
                if (!sTempSrc) sTempSrc =
this.getAttribute('src').replace('_on'+ftype, ftype);
                this.setAttribute('src', sTempSrc);
            }
        }
    }
    
}

window.onload = initRollovers;


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function DisplayDialog() {
    $('#zip-dialog').css("display", "block");
    var dlg = $("#zip-dialog").dialog({        
        modal: true,
        resizable: false,
        title: "Enter Zip Code"
    });
    dlg.parent().appendTo($("form:first"));
}

function ExamplesDialog() {
    $('#examples-dialog').css("display", "block");
    $('#examples-dialog').dialog('open');
}

function ShoppingModeDialog() {
    $('#shopping-mode-dialog').css("display", "block");
    $('#shopping-mode-dialog').dialog("open");
}

$(document).ready(function() {
    $('#mainNav ul li ul').hide();
    
    $('#mainNav ul li').hover(
        function() {
        //$(this).children('ul').show('blind',75);
        $(this).children('ul').show();
            return false;
        },
        function() {
            //$(this).children('ul').hide('blind',75);
            $(this).children('ul').hide();
            return false;
        }
    );        
    
    $('#examples-dialog').dialog({
        autoOpen: false,
        modal:true,
        resizable: false,
        title: "Catalog Search Examples"
    });
    
    $('#lnkExamples').click(function(e) {
        e.preventDefault();
        $('#examples-dialog').dialog('open');
    });

    $('#shopping-mode-dialog').dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        title: "Shopping Mode"
    });      
        
});