﻿// jQuery (Standard & Custom)

$(document).ready(function()
{
    preloadImages();
    
    $('#slideshow') // Custom - Take out this wrapped set out and jQuery Slider wrapped set if no slideshow 
        .s3Slider(
        {
            timeOut: 4000
        });
    $('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=450+S.+Camino+Del+Rio,+Durango,+CO+81301&amp;sll=37.0625,-95.677068&amp;sspn=52.152749,78.75&amp;ie=UTF8&amp;ll=37.259299,-107.870808&amp;spn=0.03279,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/Antonios/Images/twitter-over.png'); // Custom
            pageTracker._trackPageview('/Twitter Link/Mouseover');
        })
        .bind('mouseout', function(event)
        {
            rollImage('twitter', '/App_Themes/Antonios/Images/twitter.png');  // Custom
        })
        .bind('click', function(event)
        {
            pageTracker._trackPageview('/Twitter Link/Clicked');
        });
    $('img#facebook')
        .bind('mouseover', function(event)
        {
            rollImage('facebook', '/App_Themes/Antonios/Images/facebook-over.png'); // Custom
            pageTracker._trackPageview('/Facebook Link/Mouseover');
        })
        .bind('mouseout', function(event)
        {
            rollImage('facebook', '/App_Themes/Antonios/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");
google.setOnLoadCallback(initialize);

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: "2563BD83-7A56-42D0-8904-D32D5908A014", analyticsID: "XXXX" };

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();
    swfobject.removeSWF("ReservationWidget");
    jQuery('#container').append("<div id='rescompcontainer' />");
}
/* End MOR Reservation System */           

// Image Preload (Custom)

function preloadImages()
{
    if (document.images)
    {
        imageObject = new Image();

        imagePath = new Array();
        imagePath[0] = "../../App_Themes/Antonios/Images/makeareservation.png";
        imagePath[1] = "../../App_Themes/Antonios/Images/makeareservationover.png";
        imagePath[2] = "../../App_Themes/Antonios/Images/twitter.png";
        imagePath[3] = "../../App_Themes/Antonios/Images/twitter-over.png";
        imagePath[4] = "../../App_Themes/Antonios/Images/facebook.png";
        imagePath[5] = "../../App_Themes/Antonios/Images/facebook-over.png";

        var i = 0;
        for (i = 0; i <= 5; i++)
        {
            imageObject.src = imagePath[i];
        }
    }
    else
    {
        return;
    }
}

/* ------------------------------------------------------------------------
s3Slider
	
Developped By: Boban Karišik -> http://www.serie3.info/
CSS Help: Mészáros Róbert -> http://www.perspectived.com/
Version: 1.0
	
Copyright: Feel free to redistribute the script/modify it, as
long as you leave my infos at the top.
------------------------------------------------------------------------- */

// s3Slider (Standard if using Slideshow)

(function($)
{

    $.fn.s3Slider = function(vars)
    {

        var element = this;
        var timeOut = (vars.timeOut != undefined) ? vars.timeOut : 4000;
        var current = null;
        var timeOutFn = null;
        var faderStat = true;
        var mOver = false;
        var items = $("#" + element[0].id + "Content ." + element[0].id + "Image");
        var itemsSpan = $("#" + element[0].id + "Content ." + element[0].id + "Image span");

        items.each(function(i)
        {

            $(items[i]).mouseover(function()
            {
                mOver = true;
            });

            $(items[i]).mouseout(function()
            {
                mOver = false;
                fadeElement(true);
            });

        });

        var fadeElement = function(isMouseOut)
        {
            var thisTimeOut = (isMouseOut) ? (timeOut / 2) : timeOut;
            thisTimeOut = (faderStat) ? 10 : thisTimeOut;
            if (items.length > 0)
            {
                timeOutFn = setTimeout(makeSlider, thisTimeOut);
            } else
            {
                console.log("Poof..");
            }
        }

        var makeSlider = function()
        {
            current = (current != null) ? current : items[(items.length - 1)];
            var currNo = jQuery.inArray(current, items) + 1
            currNo = (currNo == items.length) ? 0 : (currNo - 1);
            var newMargin = $(element).width() * currNo;
            if (faderStat == true)
            {
                if (!mOver)
                {
                    $(items[currNo]).fadeIn((timeOut / 6), function()
                    {
                        if ($(itemsSpan[currNo]).css('bottom') == 0)
                        {
                            $(itemsSpan[currNo]).slideUp((timeOut / 6), function()
                            {
                                faderStat = false;
                                current = items[currNo];
                                if (!mOver)
                                {
                                    fadeElement(false);
                                }
                            });
                        } else
                        {
                            $(itemsSpan[currNo]).slideDown((timeOut / 6), function()
                            {
                                faderStat = false;
                                current = items[currNo];
                                if (!mOver)
                                {
                                    fadeElement(false);
                                }
                            });
                        }
                    });
                }
            } else
            {
                if (!mOver)
                {
                    if ($(itemsSpan[currNo]).css('bottom') == 0)
                    {
                        $(itemsSpan[currNo]).slideDown((timeOut / 6), function()
                        {
                            $(items[currNo]).fadeOut((timeOut / 6), function()
                            {
                                faderStat = true;
                                current = items[(currNo + 1)];
                                if (!mOver)
                                {
                                    fadeElement(false);
                                }
                            });
                        });
                    } else
                    {
                        $(itemsSpan[currNo]).slideUp((timeOut / 6), function()
                        {
                            $(items[currNo]).fadeOut((timeOut / 6), function()
                            {
                                faderStat = true;
                                current = items[(currNo + 1)];
                                if (!mOver)
                                {
                                    fadeElement(false);
                                }
                            });
                        });
                    }
                }
            }
        }

        makeSlider();

    };

})(jQuery);

// Image Rollovers (Standard)

function rollImage(imgName, imgSrc)
{
    document[imgName].src = imgSrc;
}

// 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/Lunch/Clicked');
}
function menu1Mouseover(sender, e)
{
    pageTracker._trackPageview('/Menu/Lunch/Mouseover');
}
function menu2Click(sender, e)
{
    pageTracker._trackPageview('/Menu/Dinner/Clicked');
}
function menu2Mouseover(sender, e)
{
    pageTracker._trackPageview('/Menu/Dinner/Mouseover');
}

// Reservation Popup (Custom)

function popReservationWindow()
{
    window.open("https://reservations.themagellannetwork.com/reservations/iframe.aspx?rsname=antonios", "resWindow", "height = 500, width = 455, location = no, menubar = no, resizable = yes, scrollbars = yes, status = no, toolbar = no");
}