﻿
$(document).ready(function () {

    $("span#advancedsearchbutton").click(function () { $("span#advancedsearchbutton").hide(); $("div#advancedsearch").show(); $("span#closeadvancedsearchbutton").show(); });
    $("span#closeadvancedsearchbutton").click(function () { $("span#advancedsearchbutton").show(); $("div#advancedsearch").hide(); $("span#closeadvancedsearchbutton").hide(); });

    //open the search box on every page except the homepage
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if (sPage != "") {
        $("span#advancedsearchbutton").hide(); $("div#advancedsearch").show(); $("span#closeadvancedsearchbutton").show();
    }

    //datepicker for search box
    $.datepicker.setDefaults($.datepicker.regional['en-GB']);
    $("#StartDate").datepicker({ minDate: 0, maxDate: '+2Y', onClose: function (dateText, inst) {
        //on close of startdate picker, set the min date of the enddate picker
        var startDate = $("#StartDate").datepicker('getDate');
        $("#EndDate").datepicker('option', 'minDate', startDate);
    }
    });
    $("#EndDate").datepicker({ minDate: 0, maxDate: '+2Y' });


    //datepicker for enquiry form and venue feedback
    $("#CleverDate").datepicker({ minDate: 0, maxDate: '+2Y' });
    $("#CleverDateOfHoliday").datepicker({ minDate: '-2Y', maxDate: 0 });

    //clear datepicker functions
    $("#clearStartDate").click(function () {
        $("#StartDate").val("");
    });

    $("#clearEndDate").click(function () {
        $("#EndDate").val("");
    });

    //lightbox
    $('a.lightbox').lightBox();

    //autocomplete off
    $('input').attr("autocomplete", "off");

    //dropdownmenu
    $('a#venuestab').hover(function () { $('div#dropdownmenu').show(); }, function () { $('div#dropdownmenu').hide(); });
    $('div#dropdownmenu').hover(function () { $('div#dropdownmenu').show(); }, function () { $('div#dropdownmenu').hide(); });

    //banner rotation
    $(".container").wtRotator({
        width: 486,
        height: 260,
        thumb_width: 24,
        thumb_height: 24,
        button_width: 24,
        button_height: 24,
        button_margin: 5,
        auto_start: true,
        delay: 5000,
        play_once: false,
        transition: "fade",
        transition_speed: 800,
        auto_center: true,
        easing: "",
        cpanel_position: "inside",
        cpanel_align: "BL",
        timer_align: "top",
        display_thumbs: true,
        display_dbuttons: true,
        display_playbutton: true,
        display_thumbimg: false,
        display_side_buttons: false,
        display_numbers: true,
        display_timer: false,
        mouseover_select: false,
        mouseover_pause: false,
        cpanel_mouseover: false,
        text_mouseover: false,
        text_effect: "fade",
        text_sync: true,
        tooltip_type: "text",
        shuffle: false,
        block_size: 75,
        vert_size: 55,
        horz_size: 50,
        block_delay: 25,
        vstripe_delay: 75,
        hstripe_delay: 180
    });





});

(function ($) {
    var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function () {
        var args_len = arguments.length;
        for (var i = args_len; i--; ) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
})(jQuery)

function preloadimages() {
    for (x in banners) {
        jQuery.preLoadImages("/Content/HomepageBanners/" + banners[x]);
    }

}


    


     jQuery.fn.fadeThenSlideToggle = function (speed, easing, callback) {
         if (this.is(":hidden")) {
             return this.slideDown(speed, easing).fadeTo(speed, 1, easing, callback);
         } else {
             return this.fadeTo(speed, 0, easing).slideUp(speed, easing, callback);
         }
     };

