﻿// Image Preload (Custom)

function preloadImages()
{
    if (document.images)
    {
      imageObject = new Image();      
      
      imagePath = new Array();
      imagePath[0] = "../App_Themes/Main/Images/makeareservation.png";
      imagePath[1] = "../App_Themes/Main/Images/makeareservationover.png";
      imagePath[2] = "../App_Themes/Main/Images/twitter.png";
      imagePath[3] = "../App_Themes/Main/Images/twitter-over.png";
      imagePath[4] = "../App_Themes/Main/Images/facebook.png";
      imagePath[5] = "../App_Themes/Main/Images/facebook-over.png";

       var i = 0;
       for (i=0; i<=5; i++)
       {
           imageObject.src = imagePath[i];
       }
    }
    else
    {
        return;
    }
}

// JQuery Document Ready Function

google.load("jqueryui", "1.7.2");
google.load("swfobject", "2.2");
var urlStr = "http://www.myonlinereservations.com:82/component/";
var attrs = { id: "ReservationWidget", name: "ReservationWidget", align: "middle" };
var params = { wmode: "transparent", bgcolor: "#000000", allowscriptaccess: "always", quality: "high" };
var flashvarsKnoxLocation = { rid: "7A360EB5-FE81-4C82-85A6-CB82BB83B7BA", analyticsID: "UA-8833057-1", phone: "(214) 521-3009" };
var flashvarsAddisonLocation = { rid: "C2EC535F-8090-4A72-9E70-B761B4D9DB7B", analyticsID: "UA-8833057-1", phone: "(972) 386-7373" };
var flashvars = "";

function initialize()
{
    jQuery('#dlgComp').hide().addClass('smoothness').dialog
                    ({
                        autoOpen: false,
                        modal: true,
                        resizable: false,
                        width: 766,
                        height: 465,
                        close: function(event, ui)
                        {
                            jQuery('#dlgComp').html('');
                            jQuery('#container').hide();
                        }
                    });
    jQuery('#container').hide();
}
function showComp()
{
    jQuery('#container').show();
    if (swfobject.hasFlashPlayerVersion("6.0.65"))
    {
        swfobject.embedSWF(urlStr + "ReservationWidget.swf", "rescompcontainer", "100%", "100%", "6.0.65", "", flashvars, params, attrs);
    }
    else
    {
        var htmlURL = urlStr + "HTMLComponentHolder.aspx?rid=" + flashvars.rid;
        jQuery('#dlgComp').html('<iframe id="modalIframeId" width="100%" height="100%" marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto" />').dialog("open").parents(".ui-dialog:first").find(".ui-dialog-titlebar").hide();
        jQuery('#modalIframeId').attr('src', htmlURL);
    }
}
function hideComponent()
{
    jQuery('#container').hide();

    setTimeout(function()
    {
        swfobject.removeSWF("ReservationWidget");
        jQuery('#container').append("<div id='rescompcontainer' />");
    }, 100);

    flashvars = "";
}

google.setOnLoadCallback(initialize);

// JQuery Functions (Custom)

$(document).ready(function()
{
    preloadImages();

    $('a.thickbox').bind('mousedown', function(event)
    {
        document.getElementById('phMultLocDropDown').innerHTML = document.getElementById('pnMultLocDropDownContent').innerHTML;
    });
    $('input#btnReservationOk').bind('click', function(event)
    {
        var checkedValue = $('[name=Locations]:checked').val();

        if (checkedValue == 0)
        {
            flashvars = flashvarsKnoxLocation;
            showComp();
        }
        else
        {
            flashvars = flashvarsAddisonLocation;
            showComp();
        }
        tb_remove();
    });
//    $('input#btnReservationOk').bind('mouseover', function(event)
//    {
//        this.className='btnSubscribeOver'; 
//    });
//    $('input#btnReservationOk').bind('mouseout', function(event)
//    {
//        this.className='btnSubscribe';
//    });
});

// Image Rollovers (Standard)

function rollImage(imgName, imgSrc)
{
    document[imgName].src = imgSrc;
}
