function initNav()
{
	var nav = document.getElementById("main-nav");
	if(nav)
	{
        $(".drop-down").css({
            "opacity": 0, 
            "display": "none", 
            "visibility": "visible"
        });
		var lis = $("#main-nav li.item");
		$(lis).each(function(el)
		{
			 $(lis[el]).hover(
				function () {
					$(this).addClass("hover");
					var drop = this.getElementsByTagName("div").item(0);
					$(drop).css({"display": "block"});
					$(drop).animate({"opacity": 1}, 300);
				}, 
				function () {
					$(this).removeClass("hover");
					var drop = this.getElementsByTagName("div").item(0);
					$(drop).animate({"opacity": 0}, 300, function() {$(drop).css({"display": "none", "opacity": 0});});
				}
			);
		});
	}
}
jQuery(document).ready(function()
{
    try {
        initNav();
    } catch(e) {
        return false;
    }
});

function showFreeShipPopup1124() {        
    var body = '<div id="ship_panel" style="padding-left:310px;padding-top:260px;"><img src="/images/homepage/images/1124_overlay.jpg" usemap="#PopupMap" border="none"></div>';
    
    if (typeof shipPanel != "undefined"){ shipPanel.show(); return;}
    shipPanel = new YAHOO.widget.Panel("ship_panel", {
                        width:"352px",
                        height:"128px",
                        constraintoviewport: true,
                        underlay:"none",
                        close:false,
                        visible:false,
                        draggable:false,
                        modal: true,
                        iframe: true
                    });
    shipPanel.setBody(body);
    
    if(checkIEVersion()==6 || checkIEVersion()==7 || checkFFVersion()==2){
        shipPanel.render(document.body);
    } else {
        shipPanel.render(document.getElementById('header'));
    }

    shipPanel.show();
}

function showFreeShipPopup1126() {
    var body = '<div id="ship_panel" style="padding-left:324px;padding-top:226px;"><img src="/images/homepage/images/1126_overlay.jpg" usemap="#PopupMap" border="none"></div>';
    
    if (typeof shipPanel != "undefined"){ shipPanel.show(); return;}
    shipPanel = new YAHOO.widget.Panel("ship_panel", {
                        width:"321px",
                        height:"220px",
                        constraintoviewport: true,
                        underlay:"none",
                        close:false,
                        visible:false,
                        draggable:false,
                        modal: true
                    });
    shipPanel.setBody(body);

    if(checkIEVersion()==6 || checkIEVersion()==7 || checkFFVersion()==2){
        shipPanel.render(document.body);
    } else {
        shipPanel.render(document.getElementById('header'));
    }

    shipPanel.show();
}

function showFreeShipPopup1127() {
    var body = '<div id="ship_panel" style="padding-left:324px;padding-top:253px;"><img src="/images/homepage/images/1127_overlay.jpg" usemap="#PopupMap" border="none"></div>';

    if (typeof shipPanel != "undefined"){ shipPanel.show(); return;}
    shipPanel = new YAHOO.widget.Panel("ship_panel", {
                        width:"321px",
                        height:"179px",
                        constraintoviewport: true,
                        underlay:"none",
                        close:false,
                        visible:false,
                        draggable:false,
                        modal: true
                    });
    shipPanel.setBody(body);

    if(checkIEVersion()==6 || checkIEVersion()==7 || checkFFVersion()==2){
        shipPanel.render(document.body);
    } else {
        shipPanel.render(document.getElementById('header'));
    }

    shipPanel.show();
}

function showFreeShipPopup1128() {
    var body = '<div id="ship_panel" style="padding-left:330px;padding-top:212px;"><img src="/images/homepage/images/1128_overlay.jpg" usemap="#PopupMap" border="none"></div>';

    if (typeof shipPanel != "undefined"){ shipPanel.show(); return;}
    shipPanel = new YAHOO.widget.Panel("ship_panel", {
                        width:"312px",
                        height:"113px",
                        constraintoviewport: true,
                        underlay:"none",
                        close:false,
                        visible:false,
                        draggable:false,
                        modal: true
                    });
    shipPanel.setBody(body);

    if(checkIEVersion()==6 || checkIEVersion()==7 || checkFFVersion()==2){
        shipPanel.render(document.body);
    } else {
        shipPanel.render(document.getElementById('header'));
    }

    shipPanel.show();
}

function showFreeShipPopup1130() {
    var body = '<div id="ship_panel" style="padding-left:327px;padding-top:241px;"><img src="/images/homepage/images/1130_overlay.jpg" usemap="#PopupMap" border="none"></div>';

    if (typeof shipPanel != "undefined"){ shipPanel.show(); return;}
    shipPanel = new YAHOO.widget.Panel("ship_panel", {
                        width:"322px",
                        height:"152px",
                        constraintoviewport: true,
                        underlay:"none",
                        close:false,
                        visible:false,
                        draggable:false,
                        modal: true
                    });
    shipPanel.setBody(body);

    if(checkIEVersion()==6 || checkIEVersion()==7 || checkFFVersion()==2){
        shipPanel.render(document.body);
    } else {
        shipPanel.render(document.getElementById('header'));
    }

    shipPanel.show();
}


function hideFreeShipPopup() {
    shipPanel.hide(true);
}

/**
 * This function is called when enter key is typed in the "become an insider" textbox.
 * calls the fucntion adventure.submitForm using the textbox value.
 */
function enterPressed(myfield,e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13){
        adventure.submitForm(document.getElementById('header_email_signup').value,
            'name', null, null, null, null, null, null, '');
        return false;
    } else {
        return true;
    }
}


function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
   var rv = -1; // Return value assumes failure.
   if (navigator.appName == 'Microsoft Internet Explorer')
   {
      var ua = navigator.userAgent;
      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
      if (re.exec(ua) != null)
         rv = parseFloat( RegExp.$1 );
   }
   return rv;
}
function checkIEVersion()
{
   var msg = "You're not using Windows Internet Explorer.";
   var version = 0;
   var ver = getInternetExplorerVersion();
   if ( ver> -1 )
   {
      if ( ver>= 8.0 ){
         msg = "You're using Windows Internet Explorer 8.";
         version = 8;
      } else if ( ver == 7.0 ) {
    	 msg = "You're using Windows Internet Explorer 7.";
         version = 7;
      } else if ( ver == 6.0 ) {
    	 msg = "You're using Windows Internet Explorer 6.";
         version = 6;
      } else{
    	 msg = "You should upgrade your copy of Windows Internet Explorer";
         version = 0;
      }
    }
   //alert( msg );
   return version;
}

function checkFFVersion()
{
    var ffversion = 0;
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
        ffversion=new Number(RegExp.$1); // capture x.x portion and store as a number
    }
    return ffversion;
}