///////////////////////////////  Begin Image Rotation ////////////////////////////////////////////////////////////////////////

var scrollImages = new Array();
scrollImages[0] = 'images/5148_b1.jpg';
scrollImages[1] = 'images/140130.jpg';
scrollImages[2] = 'images/daybreakcouplec.jpg';
scrollImages[3] = 'images/daysinnfrontbmk3.jpg';
scrollImages[4] = 'images/dicoupledportscar2008c.jpg';
scrollImages[5] = 'images/140131.jpg';
var currentImage = 0;

seconds = "5";

function imgShow() {
    if (document.all) {
        document.images.imgSplash.style.filter = "blendTrans(duration=2)";
        document.images.imgSplash.style.filter = "blendTrans(duration=crossFadeDuration)";
        document.images.imgSplash.filters.blendTrans.Apply();
    }
    document.imgSplash.src = scrollImages[currentImage];
    if (document.all) {
    document.images.imgSplash.filters.blendTrans.Play();
    }

    currentImage = (currentImage + 1) % scrollImages.length;
    setTimeout("imgShow()", seconds * 1000);
}

///////////////////////////////  End Image Rotation ////////////////////////////////////////////////////////////////////////
///////////////////////////////  Begin Popup Calendar //////////////////////////////////////////////////////////////////////

var m_monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

YAHOO.util.Event.onDOMReady(function() {


    var Event = YAHOO.util.Event,
            Dom = YAHOO.util.Dom,
            dialog,
            calendar;

    // Initialize the date input field with todays date.
    var todaysDate = new Date();
    Dom.get("date").value = todaysDate.getDate().toString() + ' ' + m_monthNames[todaysDate.getMonth()] + ' ' + todaysDate.getFullYear().toString();

    var showBtn = Dom.get("show");
    Event.on(showBtn, "click", function() {

        // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
        if (!dialog) {

            // Hide Calendar if we click anywhere in the document other than the calendar
            Event.on(document, "click", function(e) {
                var el = Event.getTarget(e);
                var dialogEl = dialog.element;
                if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {
                    dialog.hide();
                }
            });

            dialog = new YAHOO.widget.Dialog("container", {
                visible: false,
                context: ["show", "tl", "bl"],
                draggable: false,
                close: true
            });
            dialog.setHeader('Check-in');
            dialog.setBody('<div id="cal"></div>');
            dialog.render(document.getElementById('datefieldCheckIn'));

            dialog.showEvent.subscribe(function() {
                if (YAHOO.env.ua.ie) {
                    // Since we're hiding the table using yui-overlay-hidden, we 
                    // want to let the dialog know that the content size has changed, when
                    // shown
                    dialog.fireEvent("changeContent");
                }
            });
        }

        // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
        if (!calendar) {

            calendar = new YAHOO.widget.Calendar("cal", {
                iframe: false,          // Turn iframe off, since container has iframe support.
                hide_blank_weeks: true, // Enable, to demonstrate how we handle changing height, using changeContent
                mindate: todaysDate     // Can't check in before today
            });
            calendar.render();

            calendar.selectEvent.subscribe(function() {
                if (calendar.getSelectedDates().length > 0) {

                    var selDate = calendar.getSelectedDates()[0];

                    // Pretty Date Output, using Calendar's Locale values: 8 Feb 2008
                    var dStr = selDate.getDate();
                    var mStr = calendar.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
                    var yStr = selDate.getFullYear();

                    Dom.get("date").value = dStr + " " + mStr + " " + yStr;
                } else {
                    Dom.get("date").value = "";
                }
                dialog.hide();
            });

            calendar.renderEvent.subscribe(function() {
                // Tell Dialog it's contents have changed, which allows 
                // container to redraw the underlay (for IE6/Safari2)
                dialog.fireEvent("changeContent");
            });
        }

        var seldate = calendar.getSelectedDates();
        if (seldate.length > 0) {
            // Set the pagedate to show the selected date if it exists
            calendar.cfg.setProperty("pagedate", seldate[0]);
            calendar.render();
        }

        dialog.show();
    });

    // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
    var Event2 = YAHOO.util.Event,
            Dom2 = YAHOO.util.Dom,
            dialog2,
            calendar2;
    var showBtn2 = Dom2.get("buttonDepart");

    // Initialize the departureDate input field with tomorrows date.
    var tomorrowsDate = new Date();
    var tomorrowTime = todaysDate.getTime() + (1000 * 60 * 60 * 24);
    tomorrowsDate.setTime(tomorrowTime);
    Dom2.get("departureDate").value = tomorrowsDate.getDate().toString() + ' ' + m_monthNames[tomorrowsDate.getMonth()] + ' ' + tomorrowsDate.getFullYear().toString();

    Event2.on(showBtn2, "click", function() {
        // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
        if (!dialog2) {
            // Hide Calendar if we click anywhere in the document other than the calendar
            Event2.on(document, "click", function(e) {
                var el = Event2.getTarget(e);
                var dialogEl = dialog2.element;
                if (el != dialogEl && !Dom2.isAncestor(dialogEl, el) && el != showBtn2 && !Dom2.isAncestor(showBtn2, el)) {
                    dialog2.hide();
                }
            });

            dialog2 = new YAHOO.widget.Dialog("container2", {
                visible: false,
                context: ["buttonDepart", "tl", "bl"],
                draggable: false,
                close: true
            });

            dialog2.setHeader('Check-out');
            dialog2.setBody('<div id="cal2"></div>');
            dialog2.render(document.getElementById('datefieldCheckOut'));
            dialog2.showEvent.subscribe(function() {
                if (YAHOO.env.ua.ie) {
                    // Since we're hiding the table using yui-overlay-hidden, we 
                    // want to let the dialog know that the content size has changed, when
                    // shown
                    dialog2.fireEvent("changeContent");
                }
            });
        }

        // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
        if (!calendar2) {

            calendar2 = new YAHOO.widget.Calendar("cal2", {
                iframe: false,          // Turn iframe off, since container has iframe support.
                hide_blank_weeks: true, // Enable, to demonstrate how we handle changing height, using changeContent
                mindate: tomorrowsDate, // Can't check out until tomorrow
                today: tomorrowsDate
            });


            calendar2.render();

            calendar2.selectEvent.subscribe(function() {
                if (calendar2.getSelectedDates().length > 0) {

                    var selDate = calendar2.getSelectedDates()[0];

                    // Pretty Date Output, using Calendar's Locale values: 8 Feb 2008
                    var dStr = selDate.getDate();
                    var mStr = calendar2.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
                    var yStr = selDate.getFullYear();

                    Dom2.get("departureDate").value = dStr + " " + mStr + " " + yStr;
                } else {
                    Dom2.get("departureDate").value = "";
                }
                dialog2.hide();
            });

            calendar2.renderEvent.subscribe(function() {
                // Tell Dialog it's contents have changed, which allows 
                // container to redraw the underlay (for IE6/Safari2)
                dialog2.fireEvent("changeContent");
            });
        }

        var seldate = calendar2.getSelectedDates();
        if (seldate.length > 0) {
            // Set the pagedate to show the selected date if it exists
            calendar2.cfg.setProperty("pagedate", seldate[0]);
            calendar2.render();
        }

        dialog2.show();
    });
});
///////////////////////////////  End Popup Calendar //////////////////////////////////////////////////////////////////////




