function slideSwitch() {
    var $active = $('#rotatebanner ul li.active');

    if ($active.length == 0) $active = $('#rotatebanner ul li:last');

    // use this to pull the images in the order they appear in the markup
    var $next = $active.next().length ? $active.next()
	        : $('#rotatebanner ul li:first');

    $active.addClass('last-active').animate({ opacity: 0.0 }, 1000);
    $next.css({ opacity: 0.0 })
        .show()
        .addClass('active')
        .animate({ opacity: 1.0 }, 300, function () {
            if (jQuery.browser.msie) {
                this.style.removeAttribute('filter');
            }
            $active.removeClass('active last-active');
        });
}
	
    function reviewSwitch() {
	    var $active = $('.reviews-bttm ul li.current-review');
	
	    if ( $active.length == 0 ) $active = $('.reviews-bttm ul li:last');
	
	    // use this to pull the images in the order they appear in the markup
	    var $next =  $active.next().length ? $active.next()
	        : $('.reviews-bttm ul li:first');
	
	    $active.addClass('last-review').animate({opacity: 0.0}, 1000);
    
         $next.css({opacity: 0.0})
	         .show()
			.addClass('current-review')
			.animate({opacity: 1.0}, 500, function() {
			if(jQuery.browser.msie){
				 this.style.removeAttribute('filter');
			}
			 	$active.removeClass('current-review last-review');
			});
	}

	$(document).ready(function () {

	    // Hide both pop-ups and reviews 
	    $('.rate-popup, .guarantee-popup, #rotatebanner ul li, .reviews-bttm ul li').hide();

	    // rotating banner Slideshow timing
	    if ($('#rotatebanner').length != 0) {
	        slideSwitch();
	        setInterval("slideSwitch()", 7500);
	    }
	    if ($('.reviews-bttm').length != 0) {
	        reviewSwitch();
	        setInterval("reviewSwitch()", 6000);
	    }

	    // Open/Close pop-up for Best Available Rate
	    $('.best-rate').live('click', function () {
	        $('.rate-popup').show();
	        document.getElementById('ratepop').style.visibility = 'visible';
	    });

	    $('.close-rate').live('click', function () {
	        $('.rate-popup').hide();
	    });

	    // Open/Close pop-up for 100% Satisfaction Guarantee
	    $('.guarantee').live('click', function () {
	        $('.guarantee-popup').show();
	        document.getElementById('guarpop').style.visibility = 'visible';
	    });

	    $('.close-guarantee').live('click', function () {
	        $('.guarantee-popup').hide();
	    });

	    // Datepicker
	    $(".check-in, .check-out").datepicker({
	        showOn: 'button',
	        buttonImage: 'images/calendar-icon.png',
	        buttonImageOnly: true
	    });

	    function handleSliderChange(e, ui) {
	        var maxScroll = $(".scroll-pane").attr("scrollWidth") - $(".scroll-pane").width();
	        $(".scroll-pane").animate({ scrollLeft: ui.value * (maxScroll / 100) }, 1000);
	    }

	    function handleSliderSlide(e, ui) {
	        var maxScroll = $(".scroll-pane").attr("scrollWidth") - $(".scroll-pane").width();
	        $(".scroll-pane").attr({ scrollLeft: ui.value * (maxScroll / 100) });
	    }

	    // Events Calendar Accordion
	    $("#eventCal").accordion({
	        header: "h2",
	        autoHeight: false,
	        collapsible: true
	    });

	    if ($('#rotatebanner').length != 0) {
	        document.getElementById("rotatebanner").style.visibility = "visible";
	    }

	    document.body.style.background = '#ffffff';

	});
