Cufon.replace('.cufon, #home h2, #header h2, #navigation > ul > li > a, #action-btns a, .tout h4,  #subnav h4, #side-blog h4, #events-view-all, #footer-action h4, #footer-action p, #footer h5, #sidebar h4', {hover: true});

// to remove sticky hover state in #navigation where nav item has a dropdown
function nav_color_replace() {
    jQuery("#navigation > ul > li").mouseout( function() { 
       Cufon.replace('#navigation > ul > li > a', { hover: true } ); 
    });

}

function form_input_classes(){
    jQuery('input[type="text"]').addClass('text');
    jQuery('input[type="password"]').addClass('text');
    jQuery('input[type="checkbox"]').addClass('checkbox');
    jQuery('input[type="radio"]').addClass('radiobutton');
    jQuery('input[type="submit"]').addClass('submit');
    jQuery('input[type="image"]').addClass('buttonImage');
}

function assign_fitted(){
  jQuery('.clickable').fitted();
}

function cycle_lite(){
    jQuery('#rotator').cycle({ 
      timeout: 10000,
      next:   '#next', 
      prev:   '#prev', 
      pager: '#pager',
      pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#pager li:eq(' + idx + ') a'; 
        }
    });
}

function superfish(){
    jQuery('ul.sf-menu').superfish({ 
        delay:       200,                            // delay on mouseout 
        dropShadows: false,                            // disable drop shadows 
        autoArrows: false,
        animation:   {opacity:'show', filter: 'none'}
    });
}

function form_labelize(){  jQuery(".labelize input:text").clearingInput(); }   


function subnav(){
  // Hide all second-level subnavigation
  jQuery('#subnav ul ul').hide();
 
        var path = location.pathname.substring(1);

        // remove trailing slash from path, if present
        path = path.replace(/\/$/,'');
            jQuery('#subnav a[href$="/' + path + '/"]').parent().addClass('current');   // with trailing slash in nav link
            jQuery('#subnav a[href$="/' + path + '"]').parent().addClass('current');    // no trailing slash in nav link

//  Show containing <ul>s of current page
    jQuery('li.current').parents("ul").show();

//  Show child <ul> of current page
    jQuery('li.current > ul').show();

}

function footer_hours() {
    if(jQuery('#footer #add-hours').length > 0) {
        jQuery("#footer #add-hours").hide();
        jQuery("#footer #hours").prepend('<p id="toggle-hours">Show More Hours<span></span></p>');
        jQuery("#toggle-hours").click(function () {
            if ( !jQuery('#add-hours').is(':animated') ) {
                jQuery("#add-hours").slideToggle(500);
                jQuery("#footer-info").toggleClass('expanded');
                jQuery("#footer-info.expanded #toggle-hours").html("Show Less Hours<span></span>");
                jQuery("#footer-info:not(.expanded) #toggle-hours").html("Show More Hours<span></span>");
                // For replaced text
                Cufon.replace('#toggle-hours');
            }
        });
//      For initial load of #toggle-hours
        Cufon.replace('#toggle-hours');
    }    
}

//$("tr:even").css("background-color", "#bbbbff");

jQuery.noConflict();

jQuery(document).ready(function() {
    form_input_classes();
    form_labelize();
    cycle_lite();
    superfish();
    assign_fitted()
    subnav();
    nav_color_replace();
    footer_hours();

    if(jQuery('#accordion').length > 0) {
        jQuery("#accordion").accordion({ autoHeight: false, active: false, collapsible: true, change: function(event, ui) {
               var activeHeader = jQuery( "#accordion" ).accordion( "option", "active" );
               var activeHeaderTop = jQuery("#accordion h3:eq(" + activeHeader + ")").offset();
               if(activeHeader !== false) {
                   jQuery('html, body').animate({scrollTop:activeHeaderTop.top}, 'slow');
                   return false; 
               }

            }
        });

     //  prevent weird scrolling issue - TBD

    }

    if(jQuery('body#programs').length > 0) {
    // :even is 0-index, so it gets the 1st, 3rd, 5th, etc. It's actually odd numbers
        jQuery("div.entry:even").addClass('odd');
    } // endif
});
