﻿// Image Preload (Custom)

function preloadImages()
{
    if (document.images)
    {
        imageObject = new Image();

        imagePath = new Array();
        imagePath[0] = "../../App_Themes/Blue-Water-Grille/Images/makeareservation.png";
        imagePath[1] = "../../App_Themes/Blue-Water-Grille/Images/makeareservationover.png";
        imagePath[2] = "../../App_Themes/Blue-Water-Grille/Images/twitter.png";
        imagePath[3] = "../../App_Themes/Blue-Water-Grille/Images/twitter-over.png";
        imagePath[4] = "../../App_Themes/Blue-Water-Grille/Images/facebook.png";
        imagePath[5] = "../../App_Themes/Blue-Water-Grille/Images/facebook-over.png";

        var i = 0;
        for (i = 0; i <= 5; i++)
        {
            imageObject.src = imagePath[i];
        }
    }
    else
    {
        return;
    }
}

// Image Rollovers (Standard)

function rollImage(imgName, imgSrc)
{
    document[imgName].src = imgSrc;
}

// jQuery (Standard & Custom)

$(document).ready(function()
{
    preloadImages();

    $('ul#specials').innerfade({
        animationtype: 'slide',
        speed: 'slow',
        timeout: 5000,
        type: 'sequence',
        containerheight: 'auto' 
        });    
    $('a.thickbox')
        .bind('mousedown', function(event) // Custom
        {
            document.getElementById('phMap').innerHTML = '<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=5127+Westfields+Blvd,+Centreville,+VA+20120&amp;sll=37.0625,-95.677068&amp;sspn=52.240038,79.013672&amp;ie=UTF8&amp;ll=38.877203,-77.444172&amp;spn=0.032073,0.054932&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>';
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Get Directions Link/Clicked');
        })
        .bind('mouseover', function(event)
        {
            pageTracker._trackPageview('/Get Directions Link/Mouseover');
        });
    $('a#contactUsLink')
        .bind('mouseover', function(event)
        {
            pageTracker._trackPageview('/Contact Us Link/Mouseover');
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Contact Us Link/Clicked');
        });
    $('a#commentLink')
        .bind('mouseover', function(event)
        {
            pageTracker._trackPageview('/Send Comment Link/Mouseover');
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Send Comment Link/Clicked');
        });
    $('a#btnResLink')
        .bind('mouseover', function(event)
        {
            pageTracker._trackPageview('/Make Reservation/Mouseover');
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Make Reservation/Clicked');
        });
    $('img#twitter')
        .bind('mouseover', function(event)
        {
            rollImage('twitter', '/App_Themes/Blue-Water-Grille/Images/twitter-over.png'); // Custom
            pageTracker._trackPageview('/Twitter Link/Mouseover');
        })
        .bind('mouseout', function(event)
        {
            rollImage('twitter', '/App_Themes/Blue-Water-Grille/Images/twitter.png');  // Custom
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Twitter Link/Clicked');
        });
    $('img#facebook')
        .bind('mouseover', function(event)
        {
            rollImage('facebook', '/App_Themes/Blue-Water-Grille/Images/facebook-over.png'); // Custom
            pageTracker._trackPageview('/Facebook Link/Mouseover');
        })
        .bind('mouseout', function(event)
        {
            rollImage('facebook', '/App_Themes/Blue-Water-Grille/Images/facebook.png');  // Custom
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Facebook Link/Clicked');
        });
    $('a#tmnLink')
        .bind('mouseover', function(event)
        {
            pageTracker._trackPageview('/TMN Link/Mouseover');
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/TMN Link/Clicked');
        });
});

/* Begin MOR Reservation System */
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 flashvars = { rid: "5EB72440-94BB-400B-8ED3-F7CB47AA0043", analyticsID: "UA-10203012-1", phone: "(703) 803-1040" };

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);
}

google.setOnLoadCallback(initialize);

/* End MOR Reservation System */

// Google Analytics Tracking (Standard)


function specialsMouseover(offer)
{
    pageTracker._trackPageview("/Specials/" + offer + "/Mouseover");
}
function specialsClicked(offer)
{
    pageTracker._trackPageview("/Specials/" + offer + "/Clicked");
}

// Google Analytics Tracking (Custom)

function menu1Click(sender, e)
{
    pageTracker._trackPageview('/Menu/Dinner/Clicked');
}
function menu1Mouseover(sender, e)
{
    pageTracker._trackPageview('/Menu/Dinner/Mouseover');
}
function menu2Click(sender, e)
{
    pageTracker._trackPageview('/Menu/Lunch/Clicked');
}
function menu2Mouseover(sender, e)
{
    pageTracker._trackPageview('/Menu/Lunch/Mouseover');
}
function menu3Click(sender, e)
{
    pageTracker._trackPageview('/Menu/Wine List/Clicked');
}
function menu3Mouseover(sender, e)
{
    pageTracker._trackPageview('/Menu/Wine List/Mouseover');
}

// Reservation Popup (Custom)

function popReservationWindow()
{
    window.open("https://reservations.themagellannetwork.com/reservations/iframe.aspx?rsname=bluewater", "resWindow", "height = 500, width = 455, location = no, menubar = no, resizable = yes, scrollbars = yes, status = no, toolbar = no");
}