$(function() {
    var oldImg = 1;
    if ($('.accordion').length) {
        $('.accordion').accordion({ autoHeight: false });
        $('.accordion').bind('accordionchange', function(event, ui) {
            $('.' + ui.oldHeader.attr('id')).removeClass('disabled').toggle();
            $('.' + ui.newHeader.attr('id')).fadeIn('fast');
            document.location.href = ui.newHeader.attr('href');
        });
        if (document.location.hash) {$('.accordion').accordion('activate', $('#' + document.location.hash.replace('#','')))};
    }
    if ($('.haccordion').length) {
        $('.haccordion').haccordion();
    }
    if ($('div.scrollable').length) {
        $('div.scrollable').scrollable({
            onSeek: function() {
                var theImg = $(this.getRoot()).children().children('.active').attr('id').replace('img-', '');
                $('#main-img-' + oldImg).toggle();
                if (oldImg != theImg) {
                    $('#main-img-' + theImg).fadeIn('fast');
                    oldImg = theImg;
                } else {
                    $('#main-img-' + theImg).show();
                }
            },
            vertical:true, size: 2,
            speed: 200
        });
    }
    setTimeout("$('#feature-1').click()", 500);
    if ($('.vLargeTextField').length) {
        $('.vLargeTextField').rte('/media/pages/css/rte.css', '/media/pages/images/');
    }
    if ($('#request-quote-form').length) {
        $('#id_preferred_contact, #id_vehicles_interested, #id_email_confirm').siblings().children('label').addClass('double-label')
        $('#request-quote-form input:not(.submit), #request-quote-form textarea').bind('focus', function() {
            if (!$(this).parent().hasClass('error')) {
                $(this).parent().css('background-color','#FAFFBD');
            }
        }).bind('blur', function() {
            if (!$(this).parent().hasClass('error')) {
                $(this).parent().css('background-color','transparent');
            }
        });
        $('.error-container').parent().addClass('error');
        $('#id_pick_up_date, #id_drop_off_date').datepicker({ showAnim: 'fadeIn', duration: 'fast' });
        // $('#id_drop_off_date').parent().before('<div id="multiple-dates" class="clearfix"><input type="checkbox" name="multiple_dates" id="id_multiple_dates"> <label for="id_multiple_dates">Check for multi-date travel</label></div>');
        // $('#id_drop_off_date, #id_drop_off_time').parent().toggle();
        // $('#id_multiple_dates').bind('click', function() {
        //             $('#id_drop_off_date, #id_drop_off_time').parent().toggle('fast');
        //         });
    }
});
