﻿window.onerror = function () { return true; }



//
// CUFON - FONT REPLACE
//

$(document).ready(function () {
    if (typeof (culture) == 'undefined' || culture.toLowerCase() == 'en-us') {
        if (!$.browser.msie || $.browser.version >= 7) {
            Cufon.replace('#ListMenuFooter');
        }

        Cufon.replace('#cardHolders p');
        Cufon.replace('#ListMenuHeader');
        Cufon.replace('a.btnRed');
        Cufon.replace('a.btnTan');
        Cufon.replace('a.btnGrey');
        Cufon.replace('#thunderCardClub h3');
        Cufon.replace('#thunderCardClub p');
        Cufon.replace('.slide h3');
        Cufon.replace('.slide h4');
        Cufon.replace('#footerContainer h3');
        Cufon.replace('h2');
        Cufon.replace('#bookARoom h3');
        Cufon.replace('.masterTabs ul.mainTabs');
        Cufon.replace('.subTabs ul.sub-tabs');
        Cufon.replace('.innerTab h3');
        Cufon.replace('div.rankingContainer h3');
        Cufon.replace('div.sideCallouts h4');
        Cufon.replace('.subNavigation');
        Cufon.replace('div.packages li h3');
        Cufon.replace('div.greyInner h3');
        Cufon.replace('div.greyInner h4');
        Cufon.replace('h3.crest span.copy');
        Cufon.replace('.greyInner .newsBody h5');
        Cufon.replace('table tr.tableHead th');
        Cufon.replace('.inner h3');
    }
});



function InitGoogleMap() {
    if (GBrowserIsCompatible()) {
        var map_canvas = document.getElementById("map_canvas");

        if (map_canvas != null) {
            var map = new GMap2(map_canvas);

            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(38.83883, -121.309211), 13);
            map.setUIToDefault();

            var point = new GLatLng(38.83883, -121.309211);
            var marker = new GMarker(point);
            var html = ("<div style='color: #000000;'><strong>Thunder Valley Casino Resort</strong><br />1200 Athens Avenue, Lincoln, CA 95648<br />(916) 408-7777 or Toll-free: (877) 468-8777</div>");

            GEvent.addListener(marker, "click", function () {
                marker.openInfoWindowHtml(html);
            });

            map.addOverlay(marker);
            marker.openInfoWindowHtml(html);
        }
    }
}



$(document).ready(function () {

    //
    // SCROLLER
    //

    // Custom easing called "custom" ... more easing functions @ http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js
    $.easing.custom = function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    }
    $(function () {
        // initialize scrollable (3 at a time)
        $("div.scrollable").scrollable({
            clickable: false,
            loop: true,
            size: 3,
            speed: 700,
            easing: 'custom'
        });
    });
    $(function () {
        // initialize scrollable (2 at a time)
        $("div.scrollTwo").scrollable({
            clickable: false,
            loop: true,
            size: 2,
            speed: 700,
            easing: 'custom'
        });
    });
    $(function () {
        // initialize scrollable (1 at a time)
        $("div.scrollOne").scrollable({
            clickable: false,
            loop: true,
            size: 1,
            speed: 700,
            easing: 'custom'
        });
    });

    //
    // JQUERY UI CALENDAR WIDGET
    //
    $("#bookARoom #checkin").datepicker({ minDate: 0 }); // check in datepicker
    $("#bookARoom #checkout").datepicker({ minDate: '+1d' }); //check out datepicker
    $('#ui-datepicker-div').wrap('<div class="bookARoom" />'); // jQuery UI Datepicker doesnt support CSS-Scope :-/

    //
    // EQUAL HEIGHTS PLUGIN
    //
    (function ($) {
        $.fn.equalHeights = function (minHeight, maxHeight) {
            tallest = (minHeight) ? minHeight : 0;
            this.each(function () {
                if ($(this).height() > tallest) {
                    tallest = $(this).height();
                }
            });
            if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
            return this.each(function () {
                $(this).height(tallest).css("overflow", "auto");
            });
        }
    })(jQuery);
    $('.rankings').equalHeights(); //equal heights of .rankings div
    //$('.slide').equalHeights(); //equal heights of .rankings div
    //$('.sideCallouts .greyInner').equalHeights();

    //
    // SMALL TWEAKS
    //
    $('.masterTabs ul.mainTabs li:first-child').addClass('roundedTopLeft'); // main navigation rounded corners
    $('.masterTabs ul.mainTabs li:last-child').addClass('roundedTopRight'); // main navigation rounded corners
    $('.subNavigation li:first-child').addClass('roundedTopLeft'); // sub navigation rounded corners
    $('.subNavigation li:last-child').addClass('roundedTopRight'); // sub navigation rounded corners
    $('div.twoBytwo ul li:even').addClass('clearLeft');
    $('div.three ul li:nth-child(3n+4)').addClass('clearLeft');


    //
    // DROPLET - SELECT BOX REPLACEMENT ( http://s3.amazonaws.com/garrettbjerkhoel/dropdowns/ )
    //
    $('select.selectRedPromos').droplet({
        change: function (selected, i) {
            window.location = selected.value;
        }
    });

    $('select.selectRedYear').droplet({
        change: function (selected, i) {
            $('input[id*=hdnNewsYear]').val(selected.value);
        }
    });

    $('select.selectRedMonth').droplet({
        change: function (selected, i) {
            $('input[id*=hdnNewsMonth]').val(selected.value);
        }
    });


    $('select.selectRedYearNews').droplet({
        change: function (selected, i) {
            $('input[id*=hdnNewsYear]').val(selected.value);
        }
    });

    $('select.selectRedMonthNews').droplet({
        change: function (selected, i) {
            $('input[id*=hdnNewsMonth]').val(selected.value);
        }
    });

    $('select.selectRedYearPress').droplet({
        change: function (selected, i) {
            $('input[id*=hdnPressYear]').val(selected.value);
        }
    });

    $('select.selectRedMonthPress').droplet({
        change: function (selected, i) {
            $('input[id*=hdnPressMonth]').val(selected.value);
        }
    });

    // set external links to open in a new window
    // $("a[href^='http']").each(function() {
    //     this.target = "_blank";
    // });

    //
    // PAYOUT COUNTER ( http://plugins.jquery.com/project/jOdometer/ )
    //

    if (typeof (payout) != 'undefined') {
        $('#odometer').jOdometer({ increment: payout.increment, counterStart: payout.counterStart, numbersImage: payout.numbersImage, spaceNumbers: payout.spaceNumbers, widthDot: payout.widthDot, offsetRight: payout.offsetRight, heightNumber: payout.heightNumber });
    }

    var today = new Date();
    var reservationStarts = new Date('2010/07/05');
    var nextDay = new Date();
    nextDay.setDate(nextDay.getDate() + 1);

    $('#checkin').val((today <= reservationStarts) ? '07/05/2010' : today.format('mm/dd/yyyy'));
    $('#checkout').val((today <= reservationStarts) ? '07/06/2010' : nextDay.format('mm/dd/yyyy'));

    /*** Begin: MTN ****/
    /*if ($('#checkin').val() != '') {
    var dateArrival = new Date($('#checkin').val());
    var dateDeparture = new Date($('#checkout').val());
    if (GetDateDiff(today, dateArrival) > 0) {
    $('#checkin').val(dateArrival.toDateString());
    $('#checkout').val(dateDeparture.toDateString());
    }
    }else {
    $('#checkin').val(today.format('mm/dd/yyyy'));
    $('#checkout').val(nextDay.format('mm/dd/yyyy'));
    }

    function GetDateDiff(startDate, endDate) {
    return endDate.getDate() - startDate.getDate();
    }
    */
    //*** End: MTN ***/

});


var mainTabIndex, showSubTabs, itemType, showCustom, showCustomIndex, startingIndex;
var lastTab = 0;

//Example: LoadTab(202, 0, 'Event', 'TabLayoutList', true, false, -1, 0)
function LoadTab(tabId, index, type, layout, show, custom, customIndex, startIndex) {
    mainTabIndex = index;
    startingIndex = startIndex;
    showSubTabs = show;
    itemType = type;

    showCustom = custom;
    showCustomIndex = customIndex;

    if ((!showCustom) || (showCustom && showCustomIndex == -1 && type.length > 0)) {
        LoadXML("/TVC_Custom_Handlers/TVC_ProcessAJAXRequest.ashx?TabID=" + tabId.toString() + "&Type=" + type + "&IncludeDescription=" + (layout == 'TabLayout_OneByOne') + '&Culture=' + ((typeof (culture) != 'undefined') ? culture : ''), layout);
    }
    else {
        TabLayout_Custom();
    }
}

function TabLayout_Custom() {
    $('div[id*=InnerTab]').addClass('hide');
    $('#divInnerTab_Custom').removeClass('hide');
    $('#divInnerTab_Custom').addClass('show');
    $('#divSubTabs ul[id*="ulSubNavigation"]').removeClass('show');
    $('#divSubTabs ul[id*="ulSubNavigation"]').addClass('hide');

    // change tab selection
    if (showCustomIndex > 0) {
        $('.mainTabs > li').removeClass('ui-tabs-selected');
    }

    $('.mainTabs li:nth-child(' + ((startingIndex > 0) ? startingIndex + 1 : mainTabIndex + 1) + ')').addClass('ui-tabs-selected'); // using this selector starts at index 1 rather than 0, ugh

    if (lastTab != mainTabIndex) {
        $('#divSubTabs').fadeOut(0);
        $('#divSubTabs').fadeIn();
    }

    lastTab = mainTabIndex;
}

var tabs = [];

function TabLayout_OneByOne(xml, status) {
    // our resulting xml
    var data = $(xml);

    if (data.length == 0) {
        ParseTabDefaultContent();

        return;
    }

    // init our variables
    var tab = {};

    var li, a = null;

    // used to identify which sub tab we should process, respectively
    var cntr = 0;

    // we're loading a new tab, let's clear our collection and start fresh
    tabs = [];

    showSubTabs = (data.find("Table").length > 1);

    if (showSubTabs) {
        $('div[id*="pnlInnerTab"]').removeClass('inner show');
        $('div[id*="pnlInnerTab"]').addClass('innerTab show');
        $('#divSubTabs ul[id*="ulSubNavigation"]').removeClass('hide');
        $('#divSubTabs ul[id*="ulSubNavigation"]').addClass('show');
    }
    else {
        $('div[id*="pnlInnerTab"]').removeClass('innerTab show');
        $('div[id*="pnlInnerTab"]').addClass('inner show');
        $('.sub-tabs').children().remove();
        $('#divSubTabs ul[id*="ulSubNavigation"]').removeClass('show');
        $('#divSubTabs ul[id*="ulSubNavigation"]').addClass('hide');
    }

    // iterate through our data
    data.find('Table').each(function () {
        // init our object
        tab = {};

        // create our object
        tab.id = $(this).find(itemType + 'ID').text();
        tab.title = $(this).find(itemType + 'Title').text();
        tab.headline = $(this).find(itemType + 'Headline').text();
        tab.description = $(this).find(itemType + 'Description').text();
        tab.image = $(this).find(itemType + 'Image').text();

        //show meter on the jackpots tab on the casino page        
        if (tab.title == 'Progressives') {
            //make visible and align meter to the right
            document.getElementById('meters').setAttribute('style', 'display:inherit; float:right; clear:none; padding-left:20px; padding-top:5px;');
            //align copy to the left
            document.getElementById('divDescription').setAttribute('style', 'width:93%; float: left; clear:none; text-align: left; padding-left:30px;');
        }

        //hide meter on the jackpots tab on the casino page
        else if (tab.title != 'Progressives') {
            document.getElementById('meters').setAttribute('style', 'display:none;');
            document.getElementById('divDescription').setAttribute('style', 'width:100%;');
        }

        if (mainTabIndex != -1 && showSubTabs) {
            // build sub menu
            a = document.createElement('a');
            a.setAttribute('href', 'javascript:ParseTabItem_OneByOne(0, ' + cntr + ', true);');
            a.setAttribute('title', (tab.title) ? tab.title : tab.headline);
            a.innerHTML = (tab.title) ? tab.title : tab.headline;

            li = document.createElement('li');
            li.appendChild(a);

            // clear sub menu
            if (cntr == 0) {
                $('.sub-tabs').children().remove();
            }

            // parse sub menu
            $('.sub-tabs').append(li);
        }

        // let's add our object to the collection for future referencing
        tabs.push(tab);

        cntr++;
    });

    if (tabs.length > 0) {
        if (mainTabIndex == -1) {
            var hdnItemSelected = $('input[id*=hdnItemSelected]').val();
            hdnItemSelected = hdnItemSelected.split('|');

            ParseTabItem_OneByOne(hdnItemSelected[0], hdnItemSelected[1], false);
        }
        else {
            ParseTabItem_OneByOne(0, 0, true);
        }

        // now that we have loaded our content for the first time ( onpageload ), 
        // let's set this to the first tab or make sure we're showing the current tab
        mainTabIndex = (mainTabIndex == -1) ? 0 : mainTabIndex;

        // change tab selection
        $('.mainTabs > li').removeClass('ui-tabs-selected');
        $('.mainTabs li:nth-child(' + ((startingIndex > 0) ? startingIndex + 1 : mainTabIndex + 1) + ')').addClass('ui-tabs-selected'); // using this selector starts at index 1 rather than 0, ugh

        if (lastTab != mainTabIndex) {
            $('#divSubTabs').fadeOut(1);
            $('#divSubTabs').fadeIn();
        }

        lastTab = mainTabIndex;
    }
    else {
        ParseTabDefaultContent();
    }
}

function ParseTabItem_OneByOne(id, index, process) {
    if (process) {
        $('.sub-tabs > li').removeClass('ui-tabs-selected');
    }

    $('div[id*=InnerTab]').removeClass('hide');
    $('div[id*=InnerTab]').addClass('show');
    $('#divInnerTab_Custom').removeClass('show');
    $('#divInnerTab_Custom').addClass('hide');

    $('div[id*=InnerTab] h3:first').attr('title', tabs[index].headline);
    $('div[id*=InnerTab] h3:first').text(tabs[index].headline);
    $('div[id*=InnerTab] div:first').html(tabs[index].description);

    if (tabs[index].image.length > 0) {
        //removes tilda from image source path
        tabs[index].image = tabs[index].image.replace("~", "");

        $('div[id*=InnerTab] img[id*=imgImage]').removeClass('hide');
        $('div[id*=InnerTab] img[id*=imgImage]').addClass('show');
        $('div[id*=InnerTab] img[id*=imgImage]').attr('src', tabs[index].image);
        $('div[id*=InnerTab] img[id*=imgImage]').attr('alt', tabs[index].headline);
    }
    else {
        $('div[id*=InnerTab] img[id*=imgImage]').removeClass('show');
        $('div[id*=InnerTab] img[id*=imgImage]').addClass('hide');
    }

    $('.sub-tabs li:nth-child(' + (index + 1) + ')').addClass('ui-tabs-selected'); // using this selector starts at index 1 rather than 0, ugh


    if (typeof (culture) == 'undefined' || culture.toLowerCase() == 'en-us') {
        // manipulate typography
        Cufon.replace('.subTabs ul.sub-tabs');
        Cufon.replace('.innerTab h3');
        Cufon.replace('.inner h3');
    }

    HideLoading();
}

function TabLayout_TwoByTwo(xml, status) {
    // our resulting xml
    var data = $(xml);

    if (data.length == 0) {
        ParseTabDefaultContent();

        return;
    }

    // init our variables
    var tab = {};

    var ul, li, h, img, a, span, br = null;

    if (mainTabIndex != -1) {
        document.getElementById('divPackages_TwoByTwo').innerHTML = '';

        ul = document.createElement('ul');

        data.find("Table").each(function () {
            // init our object
            tab = {};

            // create our object
            tab.id = $(this).find(itemType + 'ID').text();
            tab.title = $(this).find(itemType + 'Title').text();
            tab.summary = $(this).find(itemType + 'Summary').text();
            tab.description = $(this).find(itemType + 'Description').text();
            tab.image = $(this).find(itemType + 'Image').text();
            tab.url = $(this).find(itemType + 'Url').text();
            tab.node_alias = $(this).find('NodeAlias').text();
            tab.node_alias_path = $(this).find('NodeAliasPath').text();

            li = document.createElement('li');

            if (tab.image.length > 0) {

                //removes tilda from source path
                tab.image = tab.image.replace("~", "");

                img = document.createElement('img');
                img.setAttribute('alt', tab.title);
                img.setAttribute('src', tab.image);
                img.setAttribute('width', '154');
                img.setAttribute('height', '130');
                img.setAttribute('class', 'img-two');

                if (tab.url.length > 0) {
                    a = document.createElement('a');
                    a.setAttribute('title', tab.title);

                    if (tab.url.indexOf('http') != -1) {
                        a.setAttribute('href', tab.url);
                        a.setAttribute('target', '_blank');
                    }
                    else if (tab.url.indexOf('www') != -1) {
                        a.setAttribute('href', 'https://' + tab.url);
                        a.setAttribute('target', '_blank');
                    }
                    else {
                        a.setAttribute('href', tab.url);
                    }

                    a.appendChild(img);

                    li.appendChild(a);
                }
                else {
                    if (tab.description.toString() == '1') {
                        a = document.createElement('a');
                        a.setAttribute('title', tab.title);
                        a.setAttribute('href', tab.node_alias_path);

                        a.appendChild(img);

                        li.appendChild(a);
                    }
                    else {
                        li.appendChild(img);
                    }
                }
            }

            h = document.createElement('h3');
            h.innerHTML = tab.title;

            li.appendChild(h);

            li.innerHTML += tab.summary;

            if (tab.url.length > 0) {
                a = document.createElement('a');
                a.setAttribute('class', 'btnTan');
                a.setAttribute('title', 'More Info for ' + tab.title);

                if (tab.url.indexOf('http') != -1) {
                    a.setAttribute('href', tab.url);
                    a.setAttribute('target', '_blank');
                }
                else if (tab.url.indexOf('www') != -1) {
                    a.setAttribute('href', 'https://' + tab.url);
                    a.setAttribute('target', '_blank');
                }
                else {
                    a.setAttribute('href', tab.url);
                }

                span = document.createElement('span');
                span.innerHTML = 'More Info';

                a.appendChild(span);

                br = document.createElement('br');

                li.appendChild(br);

                br = document.createElement('br');

                li.appendChild(br);
                li.appendChild(a);
            }
            else {
                if (tab.description.toString() == '1') {
                    a = document.createElement('a');
                    a.setAttribute('class', 'btnTan');
                    a.setAttribute('title', 'More Info for ' + tab.title);
                    a.setAttribute('href', tab.node_alias_path);

                    span = document.createElement('span');
                    span.innerHTML = 'More Info';

                    a.appendChild(span);

                    br = document.createElement('br');

                    li.appendChild(br);

                    br = document.createElement('br');

                    li.appendChild(br);
                    li.appendChild(a);
                }
            }

            ul.appendChild(li);
        });

        $('#divPackages_TwoByTwo').append(ul);

        // let's set this to the first tab or make sure we're showing the current tab
        mainTabIndex = (mainTabIndex == -1) ? 0 : mainTabIndex;

        // change tab selection
        $('.mainTabs > li').removeClass('ui-tabs-selected');
        $('.mainTabs li:nth-child(' + (mainTabIndex + 1) + ')').addClass('ui-tabs-selected'); // using this selector starts at index 1 rather than 0, ugh

        if (lastTab != mainTabIndex) {
            $('#divPackages_TwoByTwo').fadeOut(1);
            $('#divPackages_TwoByTwo').fadeIn();
        }

        lastTab = mainTabIndex;

        if (typeof (culture) == 'undefined' || culture.toLowerCase() == 'en-us') {
            // manipulate typography
            Cufon.replace('.subTabs ul li');
            Cufon.replace('.innerTab h3');
            Cufon.replace('div.packages li h3');
            Cufon.replace('div.greyInner h3');
            Cufon.replace('div.greyInner h4');
            Cufon.replace('h3.crest span.copy');
            Cufon.replace('.greyInner .newsBody h5');
            Cufon.replace('.btnRed');
            Cufon.replace('.btnTan');
            Cufon.replace('.btnGrey');
        }
    }
}

function TabLayout_List(xml, status) {
    // our resulting xml
    var data = $(xml);

    if (data.length == 0) {
        ParseTabDefaultContent();

        return;
    }

    // init our variables
    var tab = {};

    var div, div1, img, h, hr, a, span, br = null;

    var dateFormat;

    if (mainTabIndex != -1) {
        document.getElementById('divInner').innerHTML = '';

        data.find("Table").each(function () {
            // init our object
            tab = {};

            // create our object
            tab.id = $(this).find(itemType + 'ID').text();
            tab.title = $(this).find(itemType + 'Title').text();
            tab.venue = $(this).find(itemType + 'Venue').text();
            tab.image = $(this).find(itemType + 'Image').text();
            tab.summary = $(this).find(itemType + 'Summary').text();
            tab.description = $(this).find(itemType + 'Description').text();
            tab.more_info_url = $(this).find(itemType + 'MoreInfoUrl').text();
            tab.tickets_url = $(this).find(itemType + 'BuyTicketsUrl').text();
            tab.start_date = new Date($(this).find(itemType + 'StartDate').text().substring(0, $(this).find(itemType + 'StartDate').text().indexOf('T')).replace(/-/g, '/'));
            tab.end_date = new Date($(this).find(itemType + 'EndDate').text().substring(0, $(this).find(itemType + 'EndDate').text().indexOf('T')).replace(/-/g, '/'));
            tab.node_alias = $(this).find('NodeAlias').text();
            tab.node_alias_path = $(this).find('NodeAliasPath').text();

            div = document.createElement('div');
            div.setAttribute('class', 'item');

            if (tab.image.length > 0) {
                img = document.createElement('img');
                img.setAttribute('width', '289');
                img.setAttribute('height', '141');
                img.setAttribute('class', 'img-list');
                img.setAttribute('align', 'left');

                //removes tilda from image src path
                tab.image = tab.image.replace("~", "");


                img.setAttribute('src', tab.image);



                if (tab.more_info_url.length > 0) {
                    a = document.createElement('a');
                    a.setAttribute('title', 'More Info for ' + tab.title);

                    if (tab.more_info_url.indexOf('http') != -1) {
                        a.setAttribute('href', tab.more_info_url);
                        a.setAttribute('target', '_blank');
                    }
                    else if (tab.more_info_url.indexOf('www') != -1) {
                        a.setAttribute('href', 'https://' + tab.more_info_url);
                        a.setAttribute('target', '_blank');
                    }
                    else {
                        a.setAttribute('href', tab.more_info_url);
                    }

                    a.appendChild(img);
                    div.appendChild(a);
                }
                else {
                    if (tab.description.toString() == '1') {
                        a = document.createElement('a');
                        a.setAttribute('title', 'More Info for ' + tab.title);
                        a.setAttribute('href', tab.node_alias_path);

                        a.appendChild(img);
                        div.appendChild(a);
                    }
                    else {
                        div.appendChild(img);
                    }
                }
            }

            h = document.createElement('h3');
            h.innerHTML = tab.title;

            div.appendChild(h);

            if ($(this).find(itemType + 'StartDate').text().length > 0) {
                if ($(this).find(itemType + 'EndDate').text().length == 0) {
                    tab.end_date = tab.start_date;
                }

                if (tab.start_date.getFullYear() == tab.end_date.getFullYear()) {
                    if (tab.start_date.getMonth() == tab.end_date.getMonth()) {
                        if (tab.start_date.getDay() == tab.end_date.getDay()) {
                            //dateFormat = tab.start_date.format("mmmm") + ' ' + tab.start_date.format("dd") + ', ' + tab.end_date.getFullYear();
                            dateFormat = tab.start_date.format("dddd") + ', ' + tab.start_date.format("m") + ', ' + tab.end_date.getFullYear();
                        }
                        else {
                            dateFormat = tab.start_date.format("mmmm") + ' ' + tab.start_date.format("dd") + ' - ' + tab.end_date.format("dd") + ', ' + tab.end_date.getFullYear();
                        }
                    }
                    else {
                        //dateFormat = tab.start_date.format("mmmm") + ' ' + tab.start_date.format("dd") + ' - ' + tab.end_date.format("mmmm") + ' ' + tab.end_date.format("dd") + ', ' + tab.end_date.getFullYear();
                        dateFormat = tab.start_date.format("m") + ' - ' + tab.end_date.format("m") + ', ' + tab.end_date.getFullYear();
                    }
                }
                else {
                    dateFormat = tab.start_date.format("mmmm") + ' ' + tab.start_date.format("dd") + ', ' + tab.start_date.getFullYear() + ' - ' + tab.end_date.format("mmmm") + ' ' + tab.end_date.format("dd") + ', ' + tab.end_date.getFullYear();
                }

                h = document.createElement('h4');
                h.innerHTML = dateFormat;

                div.appendChild(h);
            }

            div1 = document.createElement('div');
            div1.innerHTML = tab.summary;

            div.appendChild(div1);

            if (tab.more_info_url.length > 0) {
                a = document.createElement('a');
                a.setAttribute('class', 'btnTan');
                a.setAttribute('title', 'More Info for ' + tab.title);

                if (tab.more_info_url.indexOf('http') != -1) {
                    a.setAttribute('href', tab.more_info_url);
                    a.setAttribute('target', '_blank');
                }
                else if (tab.more_info_url.indexOf('www') != -1) {
                    a.setAttribute('href', 'https://' + tab.more_info_url);
                    a.setAttribute('target', '_blank');
                }
                else {
                    a.setAttribute('href', tab.more_info_url);
                }

                span = document.createElement('span');
                span.innerHTML = 'More Info';

                a.appendChild(span);

                br = document.createElement('br');

                div.appendChild(br);
                div.appendChild(a);
            }
            else {
                if (tab.description.toString() == '1') {
                    a = document.createElement('a');
                    a.setAttribute('class', 'btnTan');
                    a.setAttribute('title', 'More Info for ' + tab.title);
                    a.setAttribute('href', tab.node_alias_path);

                    span = document.createElement('span');
                    span.innerHTML = 'More Info';

                    a.appendChild(span);

                    br = document.createElement('br');

                    div.appendChild(br);
                    div.appendChild(a);
                }
            }

            if (tab.tickets_url.length > 0) {
                a = document.createElement('a');
                a.setAttribute('class', 'btnTan');
                a.setAttribute('title', 'Buy Tickets for ' + tab.title);

                //tracking code for mering carson                
                a.setAttribute('onclick', 'javascript:_gaq.push([\'_trackPageview\',\'/goals/buytickets\']);MCPixelTrack(\'HTTPS://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?cn=as&ActivityID=83779&rnd=[mc_ts]\',true);');

                if (tab.tickets_url.indexOf('http') != -1) {
                    a.setAttribute('href', tab.tickets_url);
                    a.setAttribute('target', '_blank');
                }
                else if (tab.tickets_url.indexOf('www') != -1) {
                    a.setAttribute('href', 'https://' + tab.tickets_url);
                    a.setAttribute('target', '_blank');
                }
                else {
                    a.setAttribute('href', tab.tickets_url);
                }

                span = document.createElement('span');
                span.innerHTML = 'Buy Tickets';

                a.appendChild(span);

                br = document.createElement('br');

                div.appendChild(br);
                div.appendChild(a);
            }

            hr = document.createElement('hr');

            div.appendChild(hr);

            $('.greyInner').append(div);
        });

        // let's set this to the first tab or make sure we're showing the current tab
        mainTabIndex = (mainTabIndex == -1) ? 0 : mainTabIndex;

        // change tab selection
        $('.mainTabs > li').removeClass('ui-tabs-selected');
        $('.mainTabs li:nth-child(' + (mainTabIndex + 1) + ')').addClass('ui-tabs-selected'); // using this selector starts at index 1 rather than 0, ugh

        if (lastTab != mainTabIndex) {
            $('#divSubTabs').fadeOut(1);
            $('#divSubTabs').fadeIn();
        }

        lastTab = mainTabIndex;

        if (typeof (culture) == 'undefined' || culture.toLowerCase() == 'en-us') {
            // manipulate typography
            Cufon.replace('.subTabs ul li');
            Cufon.replace('.innerTab h3');
            Cufon.replace('div.packages li h3');
            Cufon.replace('div.greyInner h3');
            Cufon.replace('div.greyInner h4');
            Cufon.replace('h3.crest span.copy');
            Cufon.replace('.greyInner .newsBody h5');
            Cufon.replace('.btnRed');
            Cufon.replace('.btnTan');
            Cufon.replace('.btnGrey');
        }
    }
}

var timer = null;

function ParseTabDefaultContent() {
    if (mainTabIndex != -1) {
        ShowLoading('Could not load tab...');

        if (timer != null) {
            clearTimeout(timer);
        }

        timer = setTimeout("HideLoading()", 3000);
    }
}

function ShowLoading(msg) {
    $('#divLoading').removeClass('hide');
    $('#divLoading').addClass('show');
    $('#divLoading > p').html(msg);
}

function HideLoading() {
    if (timer != null) {
        clearTimeout(timer);
    }

    $('#divLoading').removeClass('show');
    $('#divLoading').addClass('hide');
}


// loads the xml
function LoadXML(url, callback) {
    ShowLoading('Loading tab data...');

    $.ajaxSetup
    ({
        cache: false
    });

    $.ajax
    ({
        type: "GET",
        url: url,
        dataType: "xml",
        contentType: "text/xml",
        success: eval(callback),
        error: ParseTabDefaultContent
    });

    HideLoading();
}

// MCPixelTrack -- MeringCarson Ad Conversion Function
// 
// Set onclick handler on button or link to fire specified
// pixel (first parameter).  Set second parameter to true 
// when a timestamp is desired.  Timestamp replaces [mc_ts] 
// in the address, so be sure it's there.
// 
// Usage: onclick="MCPixelTrack(string address, bool timestamp);"
//			
function MCPixelTrack(address, timestamp) {

    if (timestamp) {
        var newTS = new Date().getTime();
        address = address.replace("[mc_ts]", newTS);
    }

    MCPixel = new Image();
    MCPixel.src = address;

}

function BuildReservationsLink(sender) {
    if ($('#checkin').val() == '' || $('checkout').val() == '') {
        alert('Please select the dates you will Check In and Check Out.       ');

        return false;
    }

    //Omniture tracking
    viewrates(sender);

    //For external site tracking
    MCPixelTrack('https://smp.specificmedia.com/smp/v=5;m=1;t=2706;ts=[mc_ts]', true);

    sender.href = '/CMSTemplates/TVC/Reservations.html?checkin=' + $('#checkin').val() + '&checkout=' + $('#checkout').val() + '&rooms=' + $('#rooms').val() + '&adults=' + $('#adults').val();
    //sender.href = '/Hotel-Rates.aspx?checkin=' + $('#checkin').val() + '&checkout=' + $('#checkout').val() + '&rooms=' + $('#rooms').val() + '&adults=' + $('#adults').val();

    return true;
}


var url;

function News(monthObj, yearObj) {
    var month = $('#' + monthObj).val();
    var year = $('#' + yearObj).val();
    var urlPrefix = '/News/News-Room/';
    var today = new Date();

    if (month == '' && year == '') {
        return;
    }

    if (month != '') {
        url = urlPrefix + year + '/' + month;
    }
    else if (year != today.getFullYear()) {
        url = urlPrefix + year;
    }
    else {
        window.location.href = urlPrefix;

        return;
    }

    LoadXML("/TVC_Custom_Handlers/TVC_DoesNewsExist.ashx?AliasPath=" + url + '&Culture=' + ((typeof (culture) != 'undefined') ? culture : ''), "NewsRedirect");
}

function Press(monthObj, yearObj) {
    var month = $('#' + monthObj).val();
    var year = $('#' + yearObj).val();
    var urlPrefix = '/News/Press-Releases/';
    var today = new Date();

    if (month == '' && year == '') {
        return;
    }

    if (month != '') {
        url = urlPrefix + year + '/' + month;
    }
    else if (year != today.getFullYear()) {
        url = urlPrefix + year;
    }
    else {
        window.location.href = urlPrefix;

        return;
    }

    LoadXML("/TVC_Custom_Handlers/TVC_DoesPressExist.ashx?AliasPath=" + url + '&Culture=' + ((typeof (culture) != 'undefined') ? culture : ''), "PressRedirect");
}



function NewsRoom(monthObj, yearObj) {
    var month = $('#' + monthObj).val();
    var year = $('#' + yearObj).val();
    var urlPrefix = '/General-Information/News-Room/';
    var today = new Date();

    if (month == '' && year == '') {
        return;
    }

    if (month != '') {
        url = urlPrefix + year + '/' + month;
    }
    else if (year != today.getFullYear()) {
        url = urlPrefix + year;
    }
    else {
        window.location.href = urlPrefix;

        return;
    }

    LoadXML("/TVC_Custom_Handlers/TVC_DoesNewsExist.ashx?AliasPath=" + url + '&Culture=' + ((typeof (culture) != 'undefined') ? culture : ''), "NewsRedirect");
}


function NewsRedirect(xml, status) {
    // our resulting xml
    var data = $(xml);

    var result = data.find("Table").find("Result").text();

    if (result == "1") {
        window.location.href = url;
    }
    else {
        $('#spnNoNews').removeClass('hide');
        $('#spnNoNews').addClass('show');

        //timer = setTimeout("ClearNewsTimer()", 3000);
    }
}

function PressRedirect(xml, status) {
    // our resulting xml
    var data = $(xml);

    var result = data.find("Table").find("Result").text();

    if (result == "1") {
        window.location.href = url;
    }
    else {
        $('#spnNoNews').removeClass('hide');
        $('#spnNoNews').addClass('show');

        //timer = setTimeout("ClearNewsTimer()", 3000);
    }
}

function ClearNewsTimer() {
    $('#spnNoNews').removeClass('show');
    $('#spnNoNews').addClass('hide');

    if (timer != null) {
        clearTimeout(timer);
    }
}




/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/

var dateFormat = function () {
    var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
		    val = String(val);
		    len = len || 2;
		    while (val.length < len) val = "0" + val;
		    return val;
		};

    // Regexes and supporting functions are cached through closure
    return function (date, mask, utc) {
        var dF = dateFormat;

        // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
        if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
            mask = date;
            date = undefined;
        }

        // Passing date through Date applies Date.parse, if necessary
        //        date = date ? new Date(date) : new Date;
        //        if (isNaN(date)) throw SyntaxError("invalid date");

        mask = String(dF.masks[mask] || mask || dF.masks["default"]);

        // Allow setting the utc argument via the mask
        if (mask.slice(0, 4) == "UTC:") {
            mask = mask.slice(4);
            utc = true;
        }

        var _ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
			    d: d,
			    dd: pad(d),
			    ddd: dF.i18n.dayNames[D],
			    dddd: dF.i18n.dayNames[D + 7],
			    m: m + 1,
			    mm: pad(m + 1),
			    mmm: dF.i18n.monthNames[m],
			    mmmm: dF.i18n.monthNames[m + 12],
			    yy: String(y).slice(2),
			    yyyy: y,
			    h: H % 12 || 12,
			    hh: pad(H % 12 || 12),
			    H: H,
			    HH: pad(H),
			    M: M,
			    MM: pad(M),
			    s: s,
			    ss: pad(s),
			    l: pad(L, 3),
			    L: pad(L > 99 ? Math.round(L / 10) : L),
			    t: H < 12 ? "a" : "p",
			    tt: H < 12 ? "am" : "pm",
			    T: H < 12 ? "A" : "P",
			    TT: H < 12 ? "AM" : "PM",
			    Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
			    o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
			    S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

        return mask.replace(token, function ($0) {
            return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
        });
    };
} ();

// Some common format strings
dateFormat.masks = {
    "default": "ddd mmm dd yyyy HH:MM:ss",
    shortDate: "m/d/yy",
    mediumDate: "mmm d, yyyy",
    longDate: "mmmm d, yyyy",
    fullDate: "dddd, mmmm d, yyyy",
    shortTime: "h:MM TT",
    mediumTime: "h:MM:ss TT",
    longTime: "h:MM:ss TT Z",
    isoDate: "yyyy-mm-dd",
    isoTime: "HH:MM:ss",
    isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
    isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
    dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
    monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
    return dateFormat(this, mask, utc);
};

$(document).ready(function () {
    $('#footerContainer').delay(2000).addClass('mt0');
});


