$(document).ready(function(){
    /*
		Incluye una plantilla de estilos con parches para MSIE Browser
	*/
    if($.browser.msie){
        $('head').append('<link rel="stylesheet" href="/css/principal_ie_fix.css" type="text/css" />');

        if ($("#menu_colgante #centro").length>0) {
            $("li").find("#menu_colgante").each(function(){
                $(this).css({
                    "visibility":"hidden",
                    "display":"block"
                });
            })

            $("li").find("#menu_colgante #centro").each(function(){
                var elm = $(this);
                var pos = $(elm).position();
                elm.append("<div class='ie-shadows'></div>");
                $("> .ie-shadows",this).width($(elm).outerWidth()).height($(elm).outerHeight()).css("left", (pos.left + 1) + "px").css("top",(pos.top + 1) + "px");
            })
            
            $("li").find("#menu_colgante").each(function(){
                $(this).css({
                    "visibility":"",
                    "display":""
                });
            })

        }

    }
    /*
		Incluye una plantilla de estilos con parches para OPERA Browser
	*/
    if($.browser.opera){
        $('head').append('<link rel="stylesheet" href="/css/principal_opera_fix.css" type="text/css" />');
    }

    function menuOver(){
        menuPosicion($(this).children("a"),$(this).find(".sub"));
        $(this).find(".sub").stop().fadeTo('fast', 1).show();
        $(this).children("a").addClass("selected");

    }

    function menuOut(){
        $(this).find(".sub").stop().fadeTo('fast', 0, function() {
            $(this).hide();
        });
        $(this).children("a").removeClass("selected");
    }


    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 10, // number = milliseconds for onMouseOver polling interval
        over: menuOver, // function = onMouseOver callback (REQUIRED)
        timeout: 100, // number = milliseconds delay before onMouseOut
        out: menuOut // function = onMouseOut callback (REQUIRED)
    };
    $("#header #inf li").hoverIntent(config);

});


/*
**  Establece la posicion de los menúes debajo del botón menú
*/
function menuPosicion(elmContenedor,elmMenu){
    var posContenedor = $(elmContenedor).position();
    if($(elmMenu).length>0){
        if($.browser.msie){
            var topIE = 0;
        }else{
            var topIE = 0;
        }
        $(elmMenu).css("top",($(elmContenedor).height() + posContenedor.top + 3 + topIE) + "px").css("left",(posContenedor.left) + "px");
    }
}

