/* Author: Andrew E. (twovectors.com) */

$(function(){
    // Navbar hover
    $("nav > ul > li > a").hover(
        function(){
            // change to hover class
            hoverLink = $(this).parent().attr("class");
            $(this).parents("nav").addClass(hoverLink);
        },
        function() {
            // remove hover class
            $(this).parents("nav").attr("class", "");
        }
    );

    // Front page slider
    $("#bannerButtons").tabs("#banners > div", {
        effect: 'fade',
        fadeOutSpeed: "slow",
        rotate: true,
        autoplay: true,
        interval: 5000
    }).slideshow();

    // Keep parent nav highlighted when hovering over subnav
    $("nav ul ul").hover(
        function(){
            hoverLink = $(this).parent().attr("class");
            $(this).parents("nav").addClass(hoverLink);
        }, 
        function() {
            // remove hover class
            $(this).parents("nav").attr("class", "");
        }
    );

    $("nav > ul > li").hover(
        function(){
            if ($(this).has("ul")){
                $(this).children("ul").show();
            }
        },
        function(){
            if ($(this).has("ul")){
                $(this).children("ul").hide();
            }
        }
    );

    // Default text for search field
    $("#searchForm input").focusin(function(){
        if(this.value == "search") this.value = "";
    });

    $("#searchForm input").focusout(function(){
        if(this.value == "") this.value = "search";
    });

});


redirTime = "4000";
redirURL = "index.php";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }



