// Menus

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

var cur_id = 0;

function initMenu() {
    setPosition();
    jQuery("div.main-menu ul li").mousemove(function() {
        //closeMenus();
    });
    for(var i = 0; i < 10; i++) {
        var pb = jQuery("li#p-" + i.toString());
        if(document.getElementById("p-" + i.toString()) /* && document.getElementById("pc-" + i.toString()) */) {
            pb.mousemove(function() {
                //closeMenus();
                var o = jQuery(this);
                var id = o.attr("id");
                id = id.substr(id.indexOf("-") + 1, 1);
					 					 
					 if (cur_id != id) {					 
					    closeMenus();
	                showMenu(id);
   					 cur_id = id;
					 }				 
					 
            });
        }
    }
    jQuery("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(jQuery.browser.msie && parseFloat(jQuery.browser.version) < 7.0) {
		jQuery("div.main-menu ul li").hover(function() {
			jQuery(this).addClass("hover");
		}, function() {
			jQuery(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 = jQuery("div#pc-" + i.toString());
            var pb = jQuery("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() {
    jQuery("div.popup-item").css({ display: "none" });
}

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

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

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

