$(function(){

    /*
        VARIABLES FOR EVERYTHING
    */
    var $el, leftPos, newWidth;




    /*
        EMAIL FORM IN FOOTER, AUTO-CLEAR
    */
    $("#mce-EMAIL").focus(function() {
        $el = $(this);
        if ($el.val() == "your@email.com") {
            $el
                .val("")
                .css({ "color": "black", "font-style": "normal" });
        }
    });
    
    
    
    
    /*
        MAGIC LINE NAV
    */
    
    var $currentPageItem = $("#main-nav .current_page_item");
    
    if ($currentPageItem.length != 0) {
    
    var $mainNav = $("#main-nav");
    $mainNav.append("<li id='magic-line'></li>");
    var $magicLine = $("#magic-line");
    
    $magicLine
        .css("left", $currentPageItem.find("a").position().left)
        .width($currentPageItem.width())
        .data("origLeft", $magicLine.position().left)
        .data("origWidth", $magicLine.width());
        
    $("#main-nav li").not(".social-media-button").find("a").hover(function() {
    
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth
        });
    
    }, function() {
    
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth")
        });
    
    });
    
    }
    

    /*
        BACKGROUND SWITCHER
    */
    
    var allBackgrounds = new Array(
        "bg-home-1.jpg",
        "bg-home-2.jpg",
        "bg-home-3.jpg",
        "bg-home-4.jpg",
        "bg-home-5.jpg",
        "bg-home-6.jpg",
        "bg-about-1-eclipseA.jpg",
        "bg-group-1-kidmagician.jpg",
        "bg-photopg-1-ricksuzan.jpg",
        "bg-showpage-1.jpg",
        "bg-showpage-2.jpg",
        "bg-showpage-3.jpg",
        "bg-showpage-4.jpg",
        "bg-showpage-5.jpg",
        "bg-showpage-6.jpg",
        "bg-videopg-1-warehouse.jpg",
        "bg-reviewpage-1-bow.jpg",
        "bg-kidzone-1.jpg",
        "bg-magicshop-1.jpg",
        "bg-meet-1.jpg",
        "bg-kidzone-1.jpg",
        "bg-map-1.jpg",
        "bg-corporate-1.jpg",
        "bg-groupform-1.jpg"
    ),
       nextBackground = 1;
    
    $("#bg-switcher").click(function() {
        
    $("body").css("background-image", "url(/notes/wp-content/themes/WilcoxTheme2/images/" + allBackgrounds[nextBackground] + ")");
    
        nextBackground++;
    
        if (nextBackground > allBackgrounds.length-1) {
            nextBackground = 0;
        }
        
    });
    
    
    $(".widget").has(".widgettitle").css({
        "padding-top": "25px"
    });
    
    $(".widget").has(".widgettitle").prev().css({
        "margin-bottom": "30px"
    });
    
    
    $(".news-opener").click(function() {
        $("#news").toggle();
        return false;
    })
    
    
});