// Menus

var mOffset = 3;
if(navigator.userAgent.indexOf("Chrome") > 0 || $.browser == "safari" || navigator.userAgent.indexOf("MSIE") > 0) {
    mOffset = 4;
}

var cur_id = 0;

function initMenu() {
    setPosition();
    $("div.main-menu ul li").mousemove(function() {
        //closeMenus();
    });
    for(var i = 0; i < 10; i++) {
        var pb = $("li#p-" + i.toString());
        if(document.getElementById("p-" + i.toString()) /* && document.getElementById("pc-" + i.toString()) */) {
            pb.mousemove(function() {
                //closeMenus();
                var o = $(this);
                var id = o.attr("id");
                id = id.substr(id.indexOf("-") + 1, 1);
					 					 
					 if (cur_id != id) {					 
					    closeMenus();
	                showMenu(id);
   					 cur_id = id;
					 }				 
					 
            });
        }
    }
    $("div.call-out, div#header, div#content-container, div.call-our-internal, div.product-navigation, div.product-overview").mousemove(function() {
        closeMenus();
		  cur_id = 0;
    });
	if($.browser.msie && parseFloat($.browser.version) < 7.0) {
		$("div.main-menu ul li").hover(function() {
			$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
		});
	}	 
}

function setPosition() {
    for(var i = 0; i < 10; i++) {
        if(document.getElementById("p-" + i.toString()) && document.getElementById("pc-" + i.toString())) {
            var pi = $("div#pc-" + i.toString());
            var pb = $("li#p-" + i.toString());
            var offset = pb.offset();
            
            offset.left -= mOffset;
            offset.top += pb.height();
            pi.css({
                left: offset.left + "px",
                top: offset.top + "px"
            });
        }
    }
}

function closeMenus() {
    $("div.popup-item").css({ display: "none" });
}

function showMenu(index) {
    $("div#pc-" + index).css({ display: "block" });
}

$(document).ready(initMenu);
$(window).resize(setPosition);

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


