$(document).ready(function() {
    $("#profile-gallery .photo-group").fancybox();
    //$("#careers_container .lightbox_images_container a").fancybox();

    $(".occupation-list li").click(function() {
        if ($("input", this).attr("value") == "Other") {
            $(".other-occupation").removeAttr("disabled");
        }
        else {
            $(".other-occupation").attr("disabled", "disabled");
        }
    });

    $(".clickable").click(function() {
        var href = $(".click-target", this).attr("href");
        window.location.href = href;
    });
    $(".gumboots_container").click(function() {
        var href = $("a", this).attr('href');
        window.location.href = href;
    });

    if (jQuery().cycle) {
        $("#news-articles > ul").cycle({
            fx: 'scrollLeft',
            pager: '#news-articles-pager',
            easing: 'easeOutBounce',
            timeout: 11000,
            cleartypeNoBg: true
        });
    }

    $(".view-yt-video").click(function(e) {
        $.fancybox({
            'padding': 0,
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'title': this.title,
            'width': 680,
            'height': 495,
            'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type': 'swf',    // <--add a comma here
            'swf': { 'allowfullscreen': 'true'} // <-- flashvars here
        });
        e.preventDefault();
    });

    $("#search-submit").click(function() {
        $("#search-form").submit();
    });
    $("#search-events-form a").click(function(e) {
        $(this).parents("form").submit();
        e.preventDefault();
    });

    // Navigation drop-down
    var $navItems = $("#nav li");
    $navItems.hover(function() {
        $(this).children("a").addClass("hover");
        $(this).parent().children("a").addClass("hover");
        $("ul:first", this).css('visibility', 'visible');
    }, function() {
        $(this).children("a").removeClass("hover");
        $(this).parent().children("a").removeClass("hover");
        $("ul:first", this).css('visibility', 'hidden');
    });
    $("a[rel=disabled]", $navItems).click(function(e) {
        e.preventDefault();
    });

    $("#alternating-content p:odd").addClass("odd");
    $("#alternating-content p:even").addClass("even");
});

function preload(arrayOfImages) {
    $(arrayOfImages).each(function() {
        $('<img/>')[0].src = this;
    });
}
