var lang;
var urlfirst;
var urlmod;
var newurl;
var newk;
var strurl;
var SelectImageName;

jQuery(document).ready(function () {


    jQuery(function () {
        strurl = window.location.href;
        hdfLan = jQuery(".hdn_language").val();
        if (hdfLan == "EN") {
            lang = "/_layouts/images/Chilis/EN/";
        }
        else {
            lang = "/_layouts/images/Chilis/ES/";
        }

        var str;
        var aQueryString = strurl.split("/");

        if (aQueryString[5] != undefined) {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];
        }
        else {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];

        }
        var pagename = aQueryString[5];
        pagename = pagename.substring(0, pagename.indexOf("."));
        var langauage = aQueryString[3].toUpperCase();
        var pageCategory = getPageCategory(pagename.toLowerCase());

        if (str.toUpperCase() == "EN/Pages/home.aspx".toUpperCase()) {
            var imgMenu = (jQuery("#homeImage").attr('name').split('_'))[2];
            jQuery("#homeImage").attr('src', lang + imgMenu);
        }
        else if (str.toUpperCase() == "ES/Paginas/home.aspx".toUpperCase()) {
            var imgMenu = (jQuery("#homeImage").attr('name').split('_'))[2];
            jQuery("#homeImage").attr('src', lang + imgMenu);

        }
        else {
            var imgMenu = (jQuery("#homeImage").attr('name').split('_'))[1];
            jQuery("#homeImage").attr('src', lang + imgMenu);
        }

        if (str.toUpperCase() == "EN/Pages/giftcard.aspx".toUpperCase()) {

            var imgMenu = (jQuery("#ShopImage").attr('name').split('_'))[2];
            jQuery("#ShopImage").attr('src', lang + imgMenu);
        }
        else if (str.toUpperCase() == "ES/Paginas/giftcard.aspx".toUpperCase()) {
            var imgMenu = (jQuery("#ShopImage").attr('name').split('_'))[2];
            jQuery("#ShopImage").attr('src', lang + imgMenu);

        }
        else {
            var imgMenu = (jQuery("#ShopImage").attr('name').split('_'))[1];
            jQuery("#ShopImage").attr('src', lang + imgMenu);

        }

        if (str.toUpperCase() == "EN/Pages/giftcardbulk.aspx".toUpperCase()) {

            var imgMenu = (jQuery("#ShopImage").attr('name').split('_'))[2];
            jQuery("#ShopImage").attr('src', lang + imgMenu);
        }
        else if (str.toUpperCase() == "ES/Paginas/giftcardbulk.aspx".toUpperCase()) {
            var imgMenu = (jQuery("#ShopImage").attr('name').split('_'))[2];
            jQuery("#ShopImage").attr('src', lang + imgMenu);

        }
        if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/SPORTS") {

            var imgMenu = (jQuery("#SportImage").attr('name').split('_'))[2];
            jQuery("#SportImage").attr('src', lang + imgMenu);
        }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/SPORTS") {
            var imgMenu = (jQuery("#SportImage").attr('name').split('_'))[2];
            jQuery("#SportImage").attr('src', lang + imgMenu);
        }
        else {
            var imgMenu = (jQuery("#SportImage").attr('name').split('_'))[1];
            jQuery("#SportImage").attr('src', lang + imgMenu);
        }

        if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/LOCATIONS") {
            var imgLoc = (jQuery("#locImage").attr('name').split('_'))[2];
            jQuery("#locImage").attr('src', lang + imgLoc);
        }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/LOCATIONS".toUpperCase()) {
            var imgLoc = (jQuery("#locImage").attr('name').split('_'))[2];
            jQuery("#locImage").attr('src', lang + imgLoc);
        }
        else {
            var imgLoc = (jQuery("#locImage").attr('name').split('_'))[1];
            jQuery("#locImage").attr('src', lang + imgLoc);

        }

        if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/MENU".toUpperCase()) {
            var imgMenu = (jQuery("#menuImage").attr('name').split('_'))[2];
            jQuery("#menuImage").attr('src', lang + imgMenu);
        }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/MENU".toUpperCase()) {
            var imgMenu = (jQuery("#menuImage").attr('name').split('_'))[2];
            jQuery("#menuImage").attr('src', lang + imgMenu);
        }
        else {
            var imgMenu = (jQuery("#menuImage").attr('name').split('_'))[1];
            jQuery("#menuImage").attr('src', lang + imgMenu);
        }


        var imgShopSub1 = (jQuery("#ShopImageSub1").attr('name').split('_'))[1];
        jQuery("#ShopImageSub1").attr('src', lang + imgShopSub1);

        var imgShopSub2 = (jQuery("#ShopImageSub2").attr('name').split('_'))[1];
        jQuery("#ShopImageSub2").attr('src', lang + imgShopSub2);

        var imgShopSub2 = (jQuery("#SportSubImageSub2").attr('name').split('_'))[1];
        jQuery("#SportSubImageSub2").attr('src', lang + imgShopSub2);

        /*Code commented for removal of Stars & Lakers
        var imgShopSub2 = (jQuery("#SportSubImageSub3").attr('name').split('_'))[1];
        jQuery("#SportSubImageSub3").attr('src', lang + imgShopSub2);

        var imgShopSub2 = (jQuery("#SportSubImageSub4").attr('name').split('_'))[1];
        jQuery("#SportSubImageSub4").attr('src', lang + imgShopSub2);
        */

        var imgEmail = (jQuery("#EmailImage").attr('name').split('_'))[1];
        jQuery("#EmailImage").attr('src', lang + imgEmail);
        var imgOnlineOrdering = (jQuery("#OnlineImage").attr('name').split('_'))[1];
        jQuery("#OnlineImage").attr('src', lang + imgOnlineOrdering);



        if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/CONTACTUS") {
            jQuery("#contactusid").attr('class', 'contactuslinksON');
        }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/CONTACTUS") {
            jQuery("#contactusid").attr('class', 'contactuslinksON');
        }
        else {
            jQuery("#contactusid").attr('class', 'contactuslinks');
        }

        if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/ABOUTCHILIS") {
            jQuery("#aboutusid").attr('class', 'aboutusON');
        }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/ABOUTCHILIS") {

            jQuery("#aboutusid").attr('class', 'aboutusON');
        }
        else {
            jQuery("#aboutusid").attr('class', 'aboutus');
        }
    });
    jQuery(".imgEnglish").click(function () {
        setCookie("PreferredLanguage", "/EN", 30000);
        window.location.href = "/EN/Pages/home.aspx";
    });
    jQuery(".imgSpanish").click(function () {
        setCookie("PreferredLanguage", "/ES", 30000);
        window.location.href = "/ES/Paginas/home.aspx";
    });

    jQuery("#LocationListing").click(function () {
        loadLocationPopup()
    });

    jQuery("#ChangeLocationListing").click(function () {
        loadLocationPopup()
    });

    jQuery("#ChangeLocationListingInterLocation").click(function () {
        loadLocationPopup()
    });
    jQuery("div[id$='chi_StJude_DescImageId__ControlWrapper_RichImageField']").find('img').mouseout(function () {
        try {
            imgSwap(this);
        }
        catch (err) { }
    });
    jQuery("div[id$='chi_StJude_DescImageId__ControlWrapper_RichImageField']").find('img').mouseover(function () {
        try {
            imgSwap(this);
        }
        catch (err) { }
    });
    jQuery("div[id$='CreateAPepper_ButtonImageID__ControlWrapper_RichImageField']").find('img').mouseover(function () {
        try {
            imgSwap(this);
        }
        catch (err) { }
    });
    jQuery("div[id$='CreateAPepper_ButtonImageID__ControlWrapper_RichImageField']").find('img').mouseout(function () {
        try {
            imgSwap(this);
        }
        catch (err) { }
    });
    function loadLocationPopup() {
        var strurl = window.location.href;
        var url;
        url = "./locationsearchmodal.aspx";
        parent.PopupManager.createPopupWindow(url, "", 519, 560, "alphacube", true, true);
    }
    jQuery("img.MenuClass").mouseover(function () {

        var name = (jQuery(this).attr('name').split('_'))[0];
        var SelectedName = (jQuery(this).attr('name').split('_'))[2];
        var strurl = window.location.href;
        lang = "";
        var temp;
        jQuery.each(strurl.split('/'), function () {
            if ((this) == "EN") {
                lang = "EN";
            }
            else if ((this) == "ES") {
                lang = "ES";
            }
        });
        var str;
        var aQueryString = strurl.split("/");
        if (aQueryString[5] != undefined) {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];
        }
        else {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];
        }

        var pagename = aQueryString[5];
        pagename = pagename.substring(0, pagename.indexOf("."));
        var langauage = aQueryString[3].toUpperCase();
        var pageCategory = getPageCategory(pagename.toLowerCase());
        if (str.toUpperCase() == "EN/Pages/home.aspx".toUpperCase())
        { temp = "homeImage"; }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/LOCATIONS")
        { temp = "locImage"; }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/MENU")
        { temp = "menuImage"; }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/CONTACTUS")
        { temp = "contactImage"; }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/ABOUTCHILIS")
        { temp = "aboutImage"; }
        else if (str.toUpperCase() == "EN/Pages/giftcard.aspx".toUpperCase())
        { temp = "ShopImage"; }
        else if (str.toUpperCase() == "EN/Pages/giftcardbulk.aspx".toUpperCase())
        { temp = "ShopImage"; }
        else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/SPORTS")
        { temp = "SportImage"; }

        if (lang == "EN") {
            if (jQuery(this).attr('id') == temp) {
                jQuery(this).attr('src', "/_layouts/images/Chilis/EN/" + SelectedName);
            }
            else {
                jQuery(this).attr('src', "/_layouts/images/Chilis/EN/" + name);
            }
        }
        else if (lang == "ES") {
            if (str.toUpperCase() == "ES/Paginas/home.aspx".toUpperCase())
            { temp = "homeImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/LOCATIONS")
            { temp = "locImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/MENU")
            { temp = "menuImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/CONTACTUS")
            { temp = "contactImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/ABOUTCHILIS")
            { temp = "aboutImage"; }
            else if (str.toUpperCase() == "ES/Paginas/giftcard.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (str.toUpperCase() == "ES/Paginas/giftcardbulk.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/SPORTS")
            { temp = "SportImage"; }
            if (jQuery(this).attr('id') == temp) {
                jQuery(this).attr('src', "/_layouts/images/Chilis/ES/" + SelectedName);
            }
            else {
                jQuery(this).attr('src', "/_layouts/images/Chilis/ES/" + name);
            }
        }
    });


    jQuery("img.MenuClass").mouseout(function () {
        var name = (jQuery(this).attr('name').split('_'))[1];
        var SelectedName = (jQuery(this).attr('name').split('_'))[2];
        var strurl = window.location.href;
        lang = "";
        var temp;
        jQuery.each(strurl.split('/'), function () {
            if ((this) == "EN") {
                lang = "EN";
            }
            else if ((this) == "ES") {
                lang = "ES";
            }
        });
        var str;
        var aQueryString = strurl.split("/");
        if (aQueryString[5] != undefined) {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];
        }
        else {
            str = aQueryString[3] + "/" + aQueryString[4] + "/" + aQueryString[5];
        }

        var pagename = aQueryString[5];
        pagename = pagename.substring(0, pagename.indexOf("."));
        var langauage = aQueryString[3].toUpperCase();
        var pageCategory = getPageCategory(pagename.toLowerCase());
        if (lang == "EN") {
            if (str.toUpperCase() == "EN/Pages/home.aspx".toUpperCase())
            { temp = "homeImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/LOCATIONS")
            { temp = "locImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/MENU")
            { temp = "menuImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/CONTACTUS")
            { temp = "contactImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/ABOUTCHILIS")
            { temp = "aboutImage"; }
            else if (str.toUpperCase() == "EN/Pages/giftcard.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (str.toUpperCase() == "EN/Pages/giftcardbulk.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "EN/SPORTS")
            { temp = "SportImage"; }
            if (jQuery(this).attr('id') == temp) {
                jQuery(this).attr('src', "/_layouts/images/Chilis/EN/" + SelectedName);
            }
            else {
                jQuery(this).attr('src', "/_layouts/images/Chilis/EN/" + name);
            }
        }
        else if (lang == "ES") {
            if (str.toUpperCase() == "ES/Paginas/home.aspx".toUpperCase())
            { temp = "homeImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/LOCATIONS")
            { temp = "locImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/MENU")
            { temp = "menuImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/CONTACTUS")
            { temp = "contactImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/ABOUTCHILIS")
            { temp = "aboutImage"; }
            else if (str.toUpperCase() == "ES/Paginas/giftcard.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (str.toUpperCase() == "ES/Paginas/giftcardbulk.aspx".toUpperCase())
            { temp = "ShopImage"; }
            else if (langauage.toUpperCase() + "/" + pageCategory.toUpperCase() == "ES/SPORTS")
            { temp = "SportImage"; }
            if (jQuery(this).attr('id') == temp) {
                jQuery(this).attr('src', "/_layouts/images/Chilis/ES/" + SelectedName);
            }
            else {
                jQuery(this).attr('src', "/_layouts/images/Chilis/ES/" + name);
            }
        }
    });


    jQuery("#ChilisLogo").click(function () {
        strurl = window.location.href;
        jQuery.each(strurl.split('/'), function () {
            if ((this) == "EN") {
                newurl = "/EN/Pages/home.aspx";
            }
            else if ((this) == "ES") {
                newurl = "/ES/Paginas/home.aspx";
            }
        });
        window.location.href = newurl;
    });

    jQuery(".MenuJ").click(function () {
        var name = jQuery(this).attr('name');
        var sitename = (jQuery(name.split('_'))[0]);
        var pagename = (jQuery(name.split('_'))[1]);
        SelectImageName = (jQuery(name.split('_'))[2]);
        var strurl = window.location.href;
        var TempUrl = '';
        TempUrl = strurl.toUpperCase();
        lang = "";
        jQuery.each(TempUrl.split('/'), function () {
            if ((this).toUpperCase() == "EN") {
                lang = "EN";
                urlfirst = strurl.substr(0, TempUrl.indexOf("/EN") + 3);
                if (sitename.toUpperCase() != 'a'.toUpperCase()) {
                    urlmod = "/" + sitename + "/" + "Pages" + pagename;
                }
                else {
                    urlmod = "/Pages" + pagename;
                }
            }
            else if ((this).toUpperCase() == "ES") {
                lang = "ES";
                urlfirst = strurl.substr(0, TempUrl.indexOf("/ES") + 3);
                if (sitename.toUpperCase() != 'a'.toUpperCase()) {
                    urlmod = "/" + sitename + "/" + "Paginas" + pagename;
                }
                else {
                    urlmod = "/Paginas" + pagename;
                }
            }
        });
        if ((lang == "EN") || (lang == "ES")) {
            newurl = urlfirst + urlmod;
        }
        else {
            newurl = urlmod;
        }
        window.location = newurl;

    });
    
    /*start changes for chilis top nav issue fix on 06/01/2012*/
   /* var menuids = ["treemenu1"];
    for (var i = 0; i < menuids.length; i++) {
        var menuId = "#" + menuids[i];
        var ultags = jQuery(menuId + ' ul');
        for (var t = 0; t < ultags.length; t++) {
            jQuery('#treemenu1 > li').hover(
                function () {
                    var currentUL = jQuery('#' + this.id + ' ul');
                    if (currentUL && currentUL.length > 0) {
                        jQuery('#' + this.id + ' ul')[0].style.visibility = "visible";
                    }
                },
                function () {
                    var currentUL = jQuery('#' + this.id + ' ul');
                    if (currentUL && currentUL.length > 0) {
                        jQuery('#' + this.id + ' ul')[0].style.visibility = "hidden";
                    }
                }
            );
        }
    }*/

    var menuids = ["treemenu1"];
    	for (var i = 0; i < menuids.length; i++) {
        var menuId = "#" + menuids[i];
        var ultags = jQuery(menuId + ' ul');
        for (var t = 0; t < ultags.length; t++) {
            jQuery('#treemenu1 > li').hover(
                function () {
					var pos = jQuery(this).position();
					
                    var currentUL = jQuery('#' + this.id + ' ul');
                    if (currentUL && currentUL.length > 0) {
						
						jQuery('#' + this.id + ' ul')[0].style.left = pos.left+'px';
						jQuery('#' + this.id + ' ul')[0].style.top = pos.top+46+'px'
                        jQuery('#' + this.id + ' ul')[0].style.visibility = "visible";
                    }
                },
                function () {
                    var currentUL = jQuery('#' + this.id + ' ul');
                    if (currentUL && currentUL.length > 0) {
                        jQuery('#' + this.id + ' ul')[0].style.visibility = "hidden";
                    }
                }
            );
        }
    }
    /*end changes for chilis top nav issue fix on 06/01/2012*/
});

jQuery("#divContentArea").click(function () {
    jQuery('#LoadPage').load('Captcha.aspx');

});

//For RollOver
function imgSwap(oImg) {
    var strOver = "-ON"    // image to be used with mouse over
    var strImg = oImg.src.toUpperCase();
    var dot = strImg.lastIndexOf(".");
    if (dot == -1) return;
    var fileExtension = strImg.substr(dot, strImg.length);
    var rollOverImageExtension = strOver + fileExtension;
    if (strImg.indexOf(strOver) == -1) {
        oImg.src = strImg.replace(fileExtension, rollOverImageExtension);
    }
    else {
        oImg.src = strImg.replace(rollOverImageExtension, fileExtension);
    }
}
function imageSwap2(promoImageControl, promoImage, rollOverPromoImage) {
    var currentPromoImage = promoImageControl.src.toUpperCase();
    currentPromoImage = currentPromoImage.replace(/%20/gi, ' ');
    if (currentPromoImage == promoImage.toUpperCase()) {
        promoImageControl.src = rollOverPromoImage;
    }
    else {
        promoImageControl.src = promoImage;
    }
}
//This Method is used to open the Chilis Radio
function SwapImage(obj) {
    window.open('http://webcast.playnetwork.com/chilis/index.html', 'RadioPlayer', 'height=300,width=418');
}
function launchMenuPopUp(RestaurantId) {
    var loc;
    strurl = window.location.href;
    if (strurl.search("/EN") == -1) {
        loc = "/ES/Paginas/printablemenu.aspx?RestaurantId=" + RestaurantId;
    } else {
        loc = "/EN/Pages/printablemenu.aspx?RestaurantId=" + RestaurantId;
    }
    var pop_height = 600;
    var pop_width = 600;
    var pop_top = 300;
    var pop_left = 300;
    window.open(loc, 'pop', 'height=' + pop_height + ',width=' + pop_width + ',left=' + pop_left + ',top=' + pop_top + ',fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no');
}
function tabActive(tabId) {
    var tab = "";
    for (var i = 1; i <= 3; i++) {
        tab = "tab" + i;
        if (document.getElementById(tab)) {
            document.getElementById(tab).className = "tabDeactive";
        }
    }
    if (document.getElementById(tabId)) {
        var tabObj = document.getElementById(tabId);
        tabObj.className = "tabActive";
    }
}

function openHolidays() {
    var url = "locationLandingModal.html";
    parent.PopupManager.createPopupWindow(url, "", 500, 325, "alphacube", true, true);
}

// JavaScript Document (holCal.js)
function showHoliday() {
    var tab = "<table style='margin-left:15px;' cellspacing='5';>"
    for (var i = 0; i < dateArray.length; i++) {
        tab += "<tr><td class='holDay' onclick='openHolidays();'>" + dateArray[i];
        tab += "</td><td class='holdaytxt'>" + holArray[i];
        tab += "</td></tr>";
    }
    tab += "</table>";
    document.write(tab);
}
function launchPopUp() {
    strurl = window.location.href;
    if (strurl.search("/EN") == -1) {
        loc = "/ES/Paginas/popup.htm";
    } else {
        loc = "/EN/Pages/popup.htm";
    }
    var pop_height = 330;
    var pop_width = 500;
    var pop_top = 0;
    var pop_left = 0;
    window.open(loc, 'pop', 'height=' + pop_height + ',width=' + pop_width + ',left=' + pop_left + ',top=' + pop_top + ',fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
}
function make_blank(thisObj) {
    thisObj.value = '';
}
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion() {
    var version;
    var axo;
    var e;
    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }
    if (!version) {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 

            // default to the first public version
            version = "WIN 6,0,21,0";
            // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
            axo.AllowScriptAccess = "always";
            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }
    if (!version) {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer() {
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];
        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}
function AC_AddExtension(src, ext) {
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext + '?');
    else
        return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs) {
    var str = '';
    if (isIE && isWin && !isOpera) {
        str += '<object ';
        for (var i in objAttrs) {
            str += i + '="' + objAttrs[i] + '" ';
        }
        str += '>';
        for (var i in params) {
            str += '<param name="' + i + '" value="' + params[i] + '" /> ';
        }
        str += '</object>';
    }
    else {
        str += '<embed ';
        for (var i in embedAttrs) {
            str += i + '="' + embedAttrs[i] + '" ';
        }
        str += '> </embed>';
    }
    document.write(str);
}
function AC_FL_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}


function AC_SW_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i = 0; i < args.length; i = i + 2) {
        var currArg = args[i].toLowerCase();

        switch (currArg) {
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i + 1];
                break;
            case "src":
            case "movie":
                args[i + 1] = AC_AddExtension(args[i + 1], ext);
                ret.embedAttrs["src"] = args[i + 1];
                ret.params[srcParamName] = args[i + 1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblClick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
            case "id":
                ret.objAttrs[args[i]] = args[i + 1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "name":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {

        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
	((expiredays == null) ? "" : ";expires=" + exdate.toGMTString() + "; path=/");
}


function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {
    var cookie_string = name + "=" + escape(value);

    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }

    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain)
        cookie_string += "; domain=" + escape(domain);

    if (secure)
        cookie_string += "; secure";

    document.cookie = cookie_string;
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments;

    document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

document.onkeypress = fnAllowEnter;
function IsInDesignMode() {
    if (document.getElementById('MSOLayout_InDesignMode').value == '1') {
        return true;
    }
    else {
        return false;
    }
}
function fnAllowEnter(e) {

    if (IsInDesignMode() == true) {
        return true;
    }

    var splitId;
    var splitLength;
    var evtCode = window.event ? event.keyCode : e.which;
    if (evtCode == 13) {
        var elm = jQuery.focused();

        if (elm != null) {
            if (elm.id == "") {
                /*special handling for Captcha control*/
                splitId = elm.name.split('_');
                splitLength = elm.name.split('_').length;

                if (splitId[splitLength - 1].indexOf("ucCaptcha") != -1) {
                    splitId[splitLength - 1] = "ucCaptcha";
                }

            }
            else {
                splitId = elm.id.split('_');
                splitLength = elm.id.split('_').length;
            }


            if ((splitId[splitLength - 1] == "ibtnChilisLocator") || (splitId[splitLength - 1] == "txtChilisLocator")) {

                if (jQuery("input[id$='ibtnChilisLocator']")[0]) {
                    jQuery("input[id$='ibtnChilisLocator']")[0].click();

                }
            }
            else {
                //locationSearch           
                if ((splitId[splitLength - 1] == "txtZipCode") || (splitId[splitLength - 1] == "ibtnZipCodeSearch")) {
                    if (jQuery("input[id$='ibtnZipCodeSearch']")[0]) {
                        jQuery("input[id$='ibtnZipCodeSearch']")[0].click();
                    }
                }
                //locationSearch
                if ((splitId[splitLength - 1] == "txtCity") || (splitId[splitLength - 1] == "ddlState") || (splitId[splitLength - 1] == "ibtnCityStateSearch")) {
                    if (jQuery("input[id$='ibtnCityStateSearch']")[0]) {
                        jQuery("input[id$='ibtnCityStateSearch']")[0].click();
                    }
                }
                //locationSearch
                if ((splitId[splitLength - 1] == "ddlConflicts")) {
                    if (jQuery("input[id$='ibtnAddressConflicts']")[0]) {
                        jQuery("input[id$='ibtnAddressConflicts']")[0].click();
                    }
                }
                //locationLanding
                if ((splitId[splitLength - 1] == "txtFromStreet") || (splitId[splitLength - 1] == "ddlFromStreetConflict") || (splitId[splitLength - 1] == "txtFromCity") || (splitId[splitLength - 1] == "ddlFromCityConflict") || (splitId[splitLength - 1] == "ddlFromState") || (splitId[splitLength - 1] == "txtFromZipCode") || (splitId[splitLength - 1] == "txtFromCountry") || (splitId[splitLength - 1] == "lbtnGetDirections")) {
                    if (jQuery("a[id$='lbtnGetDirections']")[0]) {
                        eval(jQuery("a[id$='lbtnGetDirections']").attr('href'));

                        jQuery("a[id$='lbtnGetDirections']").blur();

                        if (jQuery("input[id$='txtFromStreet']")[0]) {
                            jQuery("input[id$='txtFromStreet']").blur();
                        }
                        if (jQuery("select[id$='ddlFromStreetConflict']")[0]) {
                            jQuery("select[id$='ddlFromStreetConflict']").blur();
                        }
                        if (jQuery("input[id$='txtFromCity']")[0]) {
                            jQuery("input[id$='txtFromCity']").blur();
                        }
                        if (jQuery("select[id$='ddlFromCityConflict']")[0]) {
                            jQuery("select[id$='ddlFromCityConflict']").blur();
                        }

                        if (jQuery("select[id$='ddlFromState']")[0]) {
                            jQuery("select[id$='ddlFromState']").blur();
                        }
                        if (jQuery("input[id$='txtFromZipCode']")[0]) {
                            jQuery("input[id$='txtFromZipCode']").blur();
                        }

                        if (jQuery("input[id$='txtFromCountry']")[0]) {
                            jQuery("input[id$='txtFromCountry']").blur();
                        }
                    }
                }
                //TravelPlanner
                if ((splitId[splitLength - 1] == "btnGo") || (splitId[splitLength - 1] == "txtFromStreet") || (splitId[splitLength - 1] == "txtToStreet") || (splitId[splitLength - 1] == "txtFromCity") || (splitId[splitLength - 1] == "txtToCity") || (splitId[splitLength - 1] == "ddlToState") || (splitId[splitLength - 1] == "ddlFromState") || (splitId[splitLength - 1] == "txtFromZipCode") || (splitId[splitLength - 1] == "txtToZipCode") || (splitId[splitLength - 1] == "ddlExclude") || (splitId[splitLength - 1] == "ddlCorridorWidth") || (splitId[splitLength - 1] == "ddlEndRadius") || (splitId[splitLength - 1] == "ddlFromStreetConflict") || (splitId[splitLength - 1] == "ddlFromCityConflict") || (splitId[splitLength - 1] == "ddlToStreetConflict") || (splitId[splitLength - 1] == "ddlToCityConflict")) {
                    if (jQuery("input[id$='btnGo']")[0]) {
                        jQuery("input[id$='btnGo']")[0].click();
                    }
                }
                //ContactUs
                if ((splitId[splitLength - 1] == "submit") || (splitId[splitLength - 1] == "txtComments") || (splitId[splitLength - 1] == "drpTopic") || (splitId[splitLength - 1] == "drpLocation") || (splitId[splitLength - 1] == "txtCheckNo") || (splitId[splitLength - 1] == "txtGiftCardNo") || (splitId[splitLength - 1] == "drpMonth") || (splitId[splitLength - 1] == "drpDate") || (splitId[splitLength - 1] == "drpYear") || (splitId[splitLength - 1] == "drpVisit") || (splitId[splitLength - 1] == "drpMeal") || (splitId[splitLength - 1] == "drpTitle") || (splitId[splitLength - 1] == "txtFirstName") || (splitId[splitLength - 1] == "txtMiddleInitial") || (splitId[splitLength - 1] == "txtLastName") || (splitId[splitLength - 1] == "txtNameSuffix") || (splitId[splitLength - 1] == "txtEmail") || (splitId[splitLength - 1] == "drpCountry") || (splitId[splitLength - 1] == "txtAddress") || (splitId[splitLength - 1] == "txtAptUnit") || (splitId[splitLength - 1] == "txtCity") || (splitId[splitLength - 1] == "drpState") || (splitId[splitLength - 1] == "txtHome1") || (splitId[splitLength - 1] == "txtHome2") || (splitId[splitLength - 1] == "txtHome3") || (splitId[splitLength - 1] == "txtWork1") || (splitId[splitLength - 1] == "txtWork2") || (splitId[splitLength - 1] == "txtWork3") || (splitId[splitLength - 1] == "txtZipCode") || (splitId[splitLength - 1] == "ucCaptcha")) {
                    if (jQuery("input[id$='submit']")[0]) {
                        jQuery("input[id$='submit']")[0].click();
                    }
                }
                //GssContact
                if ((splitId[splitLength - 1] == "gssSubmit") || (splitId[splitLength - 1] == "drpTitle") || (splitId[splitLength - 1] == "txtFirstName") || (splitId[splitLength - 1] == "txtMiddleInitial") || (splitId[splitLength - 1] == "txtLastName") || (splitId[splitLength - 1] == "txtNameSuffix") || (splitId[splitLength - 1] == "txtEmail") || (splitId[splitLength - 1] == "txtAddress1") || (splitId[splitLength - 1] == "txtAddress2") || (splitId[splitLength - 1] == "txtCity") || (splitId[splitLength - 1] == "drpState") || (splitId[splitLength - 1] == "txtZipCode") || (splitId[splitLength - 1] == "drpCountry") || (splitId[splitLength - 1] == "txtDayPh") || (splitId[splitLength - 1] == "txtEvePh") || (splitId[splitLength - 1] == "drpLocation") || (splitId[splitLength - 1] == "txtChkNumber") || (splitId[splitLength - 1] == "txtDineMonth") || (splitId[splitLength - 1] == "txtDineDay") || (splitId[splitLength - 1] == "txtDineYear") || (splitId[splitLength - 1] == "txtPersonalCode") || (splitId[splitLength - 1] == "drpInernetCon") || (splitId[splitLength - 1] == "drpFirewall") || (splitId[splitLength - 1] == "drpTopic") || (splitId[splitLength - 1] == "txtComments")) {
                    if (jQuery("input[id$='gssSubmit']")[0]) {
                        jQuery("input[id$='gssSubmit']").click();
                    }
                }

            }
        }
        else {
            jQuery("input[id$='ibtnChilisLocator']")[0].click();
            jQuery("input[id$='txtChilisLocator']").focus();

        }
    }
    else {
        return true;
    }
};
function getPageCategory(pagename) {

    switch (pagename) {

        case "contactus": case "contactusform": case "pressinquiries": case "confirmation":
            return "CONTACTUS";
            break;
        case "aboutchilis": case "ourfood": case "chilisfolklore": case "ourcommitment":
            return "ABOUTCHILIS"
            break;
        case "locationsearch": case "locationresults": case "locationlanding": case "travelplanner": case "travelplannerresult": case "TravelPlannerDrivingDirections": case "locationslisting": case "internationallocationresults":
            return "LOCATIONS";
        case "menu": case "printablemenu":
            return "MENU";
        case "mavericks": case "stars": case "lakers":
            return "SPORTS";
            break;
        default:
            return "NOCATEGORY";
            break;
    }
}


