﻿$(document).ready(function() {

    // Choose country dropdown
    $('#choose_country h5 a').click(function() {
        $(this).toggleClass('on');
        $('#countries').slideToggle(300);
        return false;
    });
    /* Commented out so menu won't disappear when US cities fade out.
    $('#choose_country').mouseleave(function() {
    var trigger = $('#choose_country h5 a');
    if (trigger.hasClass('on')) {
    $('#countries').slideToggle('fast');
    trigger.removeClass('on');
    }
    });
    */

    /* Now a nested accordion -- code in master
    // Reveal cities within countries
    function showCities() {
    $(this).addClass('hover').find('ul').fadeIn();
    }
    function hideCities() {
    $(this).removeClass('hover').find('ul').fadeOut();
    }
    $("#choose_country #countries ul ul > li").hoverIntent(showCities, hideCities);
    */

    // Maintain topnav on-state when dropdown is exposed 
    $("#navigation .AspNet-Menu-WithChildren ul").hover(
        function() { $(this).addClass('show').parent().addClass('on'); },
        function() { $(this).removeClass('show').parent().removeClass('on'); }
    );

    // Homepage bucket rollovers
    if ($("#buckets").length > 0) {
        $("#buckets").tabs("#hero div", { event: "mouseover", effect: "fade", fadeOutSpeed: "slow", rotate: true }).slideshow({ autoplay: "true", interval: "6000" });
    }

    // Interior banner slideshow

    $('#innerHero').cycle({
        fx: 'fade',
        timeout: 8000
    });


    // Click 'apply' and scroll to the top, then focus first field (careers)
    $('.accordionHeader .apply_btn').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow', function() {
            $('.form input:first').focus();
        });
    });

});


