/* author: Luis Tello 
   Date: 10/23/08
   Description: Function calls via JQuery
*/
//Javascript namespacing: singleton pattern
var KeppraXR = KeppraXR || {};
KeppraXR.Utils = KeppraXR.Utils || {};
KeppraXR.Utils = {
    loadHovers: function() {
        //hover function call on the selected ids
        $("#signup img, #inform_section div img, .nav li img, #callout_save img, #callout_signup img, #landing a img, .vertical li a img").hover(function() {
            var imgSrc = $(this).attr('src');
            if (imgSrc.indexOf('-hover') == -1) {
                $(this).attr("src", $(this).attr("src").split(".gif").join("-hover.gif"));
            }
        }, function() {
            var imgSrc = $(this).attr('src');
            if (imgSrc.indexOf('-hover') != -1) {
                $(this).attr("src", $(this).attr("src").split("-hover.gif").join(".gif"));
            }
        }, function() {
            $("#navigation li a").hover(
                function() { $("ul", this).fadeIn("fast"); },
                function() { }
            );
            if (document.all) {
                $("li#about_landing, li#neurologist_landing, li#understanding_landing, li#epilepsy_landing, li#caregivers_landing, li#resources_landing").hoverClass("sfHover");
            }

        });

        $('#navigation li, #nav-one li').hover(
            function() { this.className += ' top-level-hover'; },
            function() { this.className = this.className.replace(' top-level-hover', ''); }
        );
        $('#navigation li, #nav-one li').hoverClass("top-level-hover");
    }
};

    $.fn.hoverClass = function(c) {
        return this.each(function(){
	        $(this).hover( 
		        function() { $(this).addClass(c);  },
		        function() { $(this).removeClass(c); }
	        );
	    });
    };

$(document).ready(function() {
    KeppraXR.Utils.loadHovers();
});

