

jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function



    <!-- On page form validator  -->

    function checkCustomerInfo(myform) {
        for(i=0;i<myform.elements.length;i++) {
            if(myform.elements[i].value=="") {
                alert("Please fill out all required fields.");
                myform.elements[i].focus();
                return false;
            }
        }
        if(!validate_email(myform.email_address)) {
            alert("Not a validate email address.");
            myform.email_address.focus();
            return false;
        }
        if(!validate_email(myform.password.value!=myform.password2.value)) {
            alert("Not same password.");
            myform.password.focus();
            return false;
        }
        return true;
    }

    function validate_email(field)
    {
        apos=field.value.indexOf("@")
        dotpos=field.value.lastIndexOf(".")
        if (apos<1||dotpos-apos<2)
        {
            return false
        }
        else {
            return true
        }
    }



    <!--  Fade and Transition Effects in header, requires jquery  -->

    $(function(){

        // $("#navigation a").fadeTo(500, 0.6); // When activated, this sets the opacity of the links to fade down to 60% when the page loads

        // Main navigation links will light up on hover and fade afterward
        $("#navigation a").hover(function(){
            $(this).fadeTo(200, 1.0); // Set opacity to 100% on hover
        },function(){
            $(this).fadeTo(200, 0.6); // Set the opacity back to 60% on mouseout
        });

        $("#.sub h2 a").hover(function(){
            $(this).fadeTo(200, 0.6); // Set opacity to 100% on hover
        },function(){
            $(this).fadeTo(200, 1.0); // Set the opacity back to 60% on mouseout
        });

        // My Account and My Cart links will light up on hover and fade back afterward
        $("#nav-support a").hover(function(){
            $(this).fadeTo(200, 0.6); // Set the opacity to 100% on hover
        },function(){
            $(this).fadeTo(200, 1.0); // Set the opacity back to 60% on mouseout
        });

        // Header Logo will fade on hover, and go back afterward
        $("#logo").hover(function(){
            $(this).fadeTo(200, 0.8); // Set the opacity to 80% on hover
        },function(){
            $(this).fadeTo(200, 1.0); // Set the opacity back to 100% on mouseout
        });

        // Feature box overlays are made visible on hover
        //$(".panel-overlay").hover(function(){
        //	$(this).fadeTo(200, 1.0); // Set the opacity to 80% on hover
        //	},function(){
        //	$(this).fadeTo(200, 0.0); // Set the opacity back to 100% on mouseout
        //});

        $(".panel-overlay").hover(function(){
            $(".panel-overlay").animate({
                "height": "230px"
            }, {
                duration: "medium"
            });
        });

        //$(".panel-overlay").hover(function(){
        //	$(".panel-overlay").animate({"height": "toggle", "opacity": "toggle"}, { duration: "slow" });
        //});


        //$('#feature').hover(
        //function() { $('.panel-overlay').fadeIn(); },
        //function() { $('.panel-overlay').fadeOut(); },
        //);

        $('#feature').hover(
            function() {
                $(".panel-overlay").animate({
                    height: "65px",
                    "opacity": "1"
                }, {
                    duration: "medium"
                });
            },
            function() {
                $(".panel-overlay").animate({
                    height: "0px",
                    "opacity": "0"
                }, {
                    duration: "slow"
                });
            }
            );


    });


    //Add the "active" class to sidemenu links representing current page
    $(function($) {
        var path = location.pathname.substring(1);
        $('.sidemenu a[href="'+path+'"]').addClass('active');
    });


    <!--  Newsletter popup from link  -->

    $('#subscribe a.newsletter').click(function (n) {
        n.preventDefault();

        // load the newsletter form
        wfs.preview(13394);
    });


    <!--  Mega Dropdown Menus  -->

    function megaHoverOver(){
        $(this).find(".sub").stop().fadeTo('fast', 1).show();
    }

    function megaHoverOut(){
        $(this).find(".sub").stop().fadeTo('fast', 0, function() {
            $(this).hide();
        });
    }

    var config = {
        sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)
        interval: 100, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 500, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    $("ul#level-1 li .sub").css({
        'opacity':'0'
    });

    $("ul#level-1 li").hoverIntent(config);
});
