(jQuery)(function ($) {
    var config = {
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 50, // number = milliseconds for onMouseOver polling interval    
        over: menuOver, // function = onMouseOver callback (REQUIRED)    
        timeout: 500, // number = milliseconds delay before onMouseOut    
        out: menuOut // function = onMouseOut callback (REQUIRED)    
    };
    $("#mainNav ul li").hoverIntent(config);
    $("#topNav ul li:last").css("background", "none");
    $("#mainNav ul:first > li:last").css("border-left", "none");
    
    //$("#mainNav .sub .menuHolder ul li").css("padding-bottom","0px");

    var lastNavs = $("#mainNav .sub .menuHolder ul");
    lastNavs.each(function () {
        $(this).find("li:last").css("padding-bottom", "0px");
    });

    function menuOver() {
        $(this).find(".sub").stop().show();

    }
    function menuOut() {
        $(this).find(".sub").stop().hide();

    }

    var _paths = {
        oldPath: "",
        newPath: ""
    }
    $("#mainNav ul li img, #topNav ul li img").hover(function () {
        _paths.oldPath = $(this).attr("src");
        _paths.newPath = $(this).attr("class");
        $(this).attr("src", _paths.newPath);
    }, function () {
        $(this).attr("src", _paths.oldPath);
    });

    //small arrow Animation
    var _arrowP = {
    oldP: "/PublicUI/Themes/eLearning/images/btn_arrow.gif",
    newP: "/PublicUI/Themes/eLearning/images/btn_hover_arrow.gif"
    }

    $(".arrow").hover(function () {
        $(this).attr("src", _arrowP.newP);
    }, function () {
        $(this).attr("src", _arrowP.oldP);
    });

    $(".clientsBtn, .infoBtn").hover(function () {
        $(this).find(".arrow").attr("src", _arrowP.newP);
    }, function () {
        $(this).find(".arrow").attr("src", _arrowP.oldP);
    });
});

(function ($) {
    $.fn.showHide = function (options) {
        var defaults = {
            moreText: "read more",
            lessText: "hide",
            speed: "fast"
        };
        var options = $.extend(defaults, options);

        return this.each(function () {
            var $this = $(this); //insert our object into var
            var spanObj = $this.find("div.more");
            spanObj.after('<br/><a href="#" class="sh_btn">' + options.moreText + '</a><br/>');
            $this.find(".sh_btn").click(function () {
                if (spanObj.is(":hidden")) {
                    spanObj.slideDown(options.speed).show();
                    $(this).text(options.lessText);
                } else {
                    spanObj.slideUp(options.speed).hide();
                    $(this).text(options.moreText);
                }
                return false;
            });
        });
    };
})(jQuery);

(function ($) {
    $.fn.hoverImg = function (options) {
        var defaults = {
            hoverAttr: "lang"
        };
        var options = $.extend(defaults, options);

        return this.each(function () {
            var $this = $(this); //insert our object into var
            var currentSrc = $this.attr("src");
            
            var newSrc = $this.attr(options.hoverAttr);

            $this.hover(function()
            {
                $this.attr("src", newSrc);
            }, function(){
                $this.attr("src", currentSrc);
            });
        });
    };
})(jQuery);
