var rsOpenTab;
var rsOpenItem;
var totNumOffers;
var numCont1Offers;
var numCont2Offers;
var rscOffersHtml;
var interval;
var mallId = 'null';
var urlParamID;
var archivedEventID = 'null';
var isEditWindowOpen = false;
var socialTab;

var DEBUG = new Boolean(false);
var newsEventCount = -1;

var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

if (gup('id') === "") {
    urlParamID = gup('ID');
} else {
    urlParamID = gup('id');
}

if (gup('eid') !== "") {
    archivedEventID = gup('eid');
}
_userv = 0;
_jason = 1506;
/* MainMaster - Qtip Jquery
---------------------------------------------------	*/
$(document).ready(function() {
    //    $("#shopsmarterlogo").qtip({
    //        content: '<h3>Shop Smarter. At Simon Malls.</h3><p>More stores. More brands. More deals. All in one place.</p><p>Look for this symbol to find smart bargains, tips, and services at your Simon Mall.</p>', position: { corner: { target: 'topRight', tooltip: 'bottomRight'} }
    //    });
    try {
        $(".btnClose").qtip({
            content: 'Close', position: { corner: { target: 'bottomMiddle', tooltip: 'topRight'} }
        });
        $("#tabBusiness").qtip({
            content: '<p class="tipBusiness">Prospective Tenants, Tenants, Suppliers, Media &amp; Sponsorship Opportunities</p>',
            style: {
                background: '#e7e7e7',
                padding: 0,
                width: 270,
                border: {
                    width: 2,
                    radius: 10,
                    color: '#e7e7e7'
                }
            },
            position: {
                corner: {
                    target: 'topRight',
                    tooltip: 'bottomLeft'
                },
                adjust: {
                    x: 23,
                    y: 10
                }
            }
        });
    } catch (err) { }
});
/* Error/Message Overlay
---------------------------------------------------	*/
function showMessage(messageTitle, messageBody) {
    $("#overlaySmall p, #overlaySmall h4").remove();
    $("#overlaySmall").append('<h4>' + messageTitle + '</h4><p>' + messageBody + '</p>');
    $("#overlaySmall").jqmShow();
}

/* Sliders Height Function
---------------------------------------------------	*/

function sliderResize() {
    $('.simonSlideContent.resizable').each(function() {
        var podTallest = 0;
        $(this).children().css('height', 'auto');
        $(this).children().each(function() {
            if ($(this).height() > podTallest) {
                podTallest = $(this).height();
            }
        });
        $(this).css('height', podTallest + 'px');
        $(this).children().css('height', podTallest + 'px');
        $(this).parent().siblings('.simonSlideLeft').css('height', podTallest + 'px');
        $(this).parent().siblings('.simonSlideLeft').children('a').css('margin-top', ((podTallest - 37) / 2) + 'px');
        $(this).parent().siblings('.simonSlideRight').css('height', podTallest + 'px');
        $(this).parent().siblings('.simonSlideRight').children('a').css('margin-top', ((podTallest - 37) / 2) + 'px');
        $(this).parent().css('height', podTallest + 'px');
        $(this).parent().parent('.simonSlideContainer').css('height', podTallest + 'px');
    });
}


/* Retailer Showcase Interaction
---------------------------------------------------	*/

/* Retailer Showcase More Tiles
---------------------------------------------------	*/
function rscMoreTiles() {
    //    var offersContainerHeight = Math.ceil(totNumOffers / 3) * 165;
    //    var urlParamOffer;
    //    if (mallId !== 'null') {
    //        urlParamOffer = 'id=' + mallId;
    //    } else {
    //        urlParamOffer = 'id=' + urlParamID;
    //    }

    //    $('#rsTilesContainer').parent('div').bind('scroll', function() {
    //        if (-$('#rsTilesContainer').position().top < offersContainerHeight - 404) {
    //            if ($('#rsTilesContainer').children('a:last').position().top <= 404 && $('#rsTilesContainer').hasClass('enabled') && $('#rsTilesContainer').children('a').length < totNumOffers) {
    //                $('#rsTilesContainer').removeClass('enabled');
    //                $('.rscLoading').fadeIn('slow');
    //                var currNumTiles = $('#rsTilesContainer').children('a').length;
    //                $.ajax({
    //                    url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=2&' + urlParamOffer + '&count=30&index=' + currNumTiles,
    //                    cache: true,
    //                    success: function(html) {
    //                        $('#rsTilesContainer').append(html);
    //                        $('#rsTilesContainer').addClass('enabled');
    //                        $('.rscLoading').fadeOut('slow');
    //                    }
    //                });
    //            }
    //        }
    //    });
}

var loadedTabs = new Array();   // stores what tabs have been loaded

function startRscPopulate(overlayMode, overlayModeId) {
    if (DEBUG == true) console.log("starting RSC populate for tab: " + rsOpenTab);
    if (DEBUG == true) console.log("cached tabs: " + loadedTabs);

    var tabOneCacheStatus = $.inArray('rsOpenTab1', loadedTabs);
    var tabTwoCacheStatus = $.inArray('rsOpenTab2', loadedTabs);

    if (DEBUG == true) console.log("tab one cache status: " + tabOneCacheStatus);
    if (DEBUG == true) console.log("tab two cache status: " + tabTwoCacheStatus);

    var urlParamOffer;

    if (overlayMode === 'OfferPreview') {
        urlParamOffer = 'oid=' + overlayModeId;
    } else if (overlayMode === 'ShowcasePreview') {
        urlParamOffer = 'sid=' + overlayModeId;
    } else if (mallId !== 'null') {
        urlParamOffer = 'id=' + mallId;
    } else {
        urlParamOffer = 'id=' + urlParamID;
    }

    if ((rsOpenTab === "rsOpenTab1" || rsOpenTab === "rsOpenTabItem1") && tabOneCacheStatus == -1) {
        $('.rscLoading').fadeIn('slow');

        loadedTabs.push("rsOpenTab1");

        /* Populate Sales & Offers Tiles */
        $('#rsTilesContainer').load('/ajax/overlay/getoverlayitems.ashx?type=1&output=2&' + urlParamOffer + '&count=30', function() {
            $('.rscLoading').fadeOut('slow');
            rscMoreTiles();
        });

        /* Populate Sales & Offers Templates */
        $.ajax({
            url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9',
            cache: true,
            success: function(html) {
                $("#rsContent1 .rsSect2Content").append(html);
                $('.rscLoading').fadeOut('slow', function() {
                    numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                    $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                    $('#rsContent1 .rsSect2Content').addClass('contentLoaded');
                    doTrackingCont1();
                });

            }
        });
    }

    // See if we display News & Event Tab
    displayNewsEventTab(function(hasNewsEvents) {
        if (hasNewsEvents == true) {
            $('#rsTab2').show();
            if ((rsOpenTab === "rsOpenTab2" || rsOpenTab === "rsOpenTabItem2") && tabTwoCacheStatus == -1) {
                // Obtain Mall News & Upcoming Events if Available (Else Hide News & Events Tab)
                $('.rscLoading').fadeIn('slow');

                loadedTabs.push("rsOpenTab2");
                getMallNews();
                getUpcomingEvents();
                getAllNewsEventsTemplates();
            }

        } else {
            $('#rsTab2').hide();
        }
    });

    /* Populate News & Events Tiles */
    function getMallNews() {
        $.ajax({
            url: '/ajax/overlay/getoverlayitems.ashx?type=3&output=2&' + urlParamOffer,
            cache: true,
            success: function(html) {
                $('#rsContent2 .rsSect1MiddleLeft').append(html);
            }
        });
    }

    function getUpcomingEvents() {
        $.ajax({
            url: '/ajax/overlay/getoverlayitems.ashx?type=4&output=2&' + urlParamOffer,
            cache: true,
            success: function(html) {
                $('.rscLoading').fadeOut('slow');
                $('#rsContent2 .rsSect1MiddleRight').append(html);
            }
        });
    }

    function getAllNewsEventsTemplates() {
        $.ajax({
            url: '/ajax/overlay/getoverlayitems.ashx?type=2&output=3&' + urlParamOffer + '&count=' + newsEventCount,
            cache: true,
            success: function(html) {
                $('#rsContent2 .rsSect2Content').append(html);
                $('.rscLoading').fadeOut('slow', function() {
                    numCont2Offers = $("#rsContent2 .rsSect2Offer").length;
                    $("#rsContent2 .rsSect2Content").width(numCont2Offers * 630 + "px");
                    $('#rsContent2 .rsSect2Content').addClass('contentLoaded');
                });
                $(".maskWhole").delay(3000).fadeOut("slow");
            }
        });
    }

    setTimeout(function() {
        if (DEBUG == true) console.log("completed getting RSC overlay items...");
        if (gup('tab') != '') {
            //if (typeof rsAjaxCallback == "function") setTimeout ( "rsAjaxCallback()", 2000 );
        }
    }, 2000);

    /* Returns True/False To Display News & Events Tab (Only Once Per Page Load) */
    function displayNewsEventTab(fn) {
        if (DEBUG == true) console.log("Seeing if we display the News & Events tab: " + newsEventCount);
        var hasNewsEvents = new Boolean(false);
        if (newsEventCount == 0) {
            hasNewsEvents = false;
            if (DEBUG == true) console.log("Result of Tab Display: " + hasNewsEvents);
            if (typeof fn == "function") fn(hasNewsEvents);
        } else if (newsEventCount == -1) {
            $.ajax({
                url: '/ajax/overlay/getoverlayitems.ashx?type=3&output=5&' + urlParamOffer,
                cache: true,
                success: function(html) {
                    newsEventCount = getOverlayItemCount(html);
                    if (newsEventCount > 0 && typeof fn == "function") fn(hasNewsEvents);
                    $.ajax({
                        url: '/ajax/overlay/getoverlayitems.ashx?type=4&output=5&' + urlParamOffer,
                        cache: true,
                        success: function(html) {
                            newsEventCount += getOverlayItemCount(html);
                            if (newsEventCount > 0) hasNewsEvents = true;

                            if (DEBUG == true) console.log("Result of Tab Display: " + hasNewsEvents);
                            if (typeof fn == "function") fn(hasNewsEvents);
                        }
                    });
                }
            });
        } else {
            hasNewsEvents = true;
            if (DEBUG == true) console.log("Result of Tab Display: " + hasNewsEvents);
            if (typeof fn == "function") fn(hasNewsEvents);
        }
    }
}

function getOverlayItemCount(html) {
    var count = 0;
    try {
        count = parseInt(html);
    } catch (e) {
        count = -1;
    }
    return count;
}


function opacityShift() {
    if ($('.jqmOverlayRS').css('opacity') === '0.85') {
        $('.jqmOverlayRS').fadeTo('fast', 0.84);
    } else {
        $('.jqmOverlayRS').fadeTo('fast', 0.85);
    }

}


function goToMainOffer(mainOfferId) {

    var urlParamOffer;

    if (mallId !== 'null') {
        urlParamOffer = 'id=' + mallId;
    } else {
        urlParamOffer = 'id=' + urlParamID;
    }

    $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
    //$(".rsPanelContent1").trigger("click");
    $("#rsContent1 .rsWhatsNow").css({ "left": "43px" });
    $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
    $("#rsContent1 .rsSect2").css({ "left": "79px" });
    opacityShift();
    $('.rscLoading').fadeIn('slow', function() {
        $("#rsContent1 .rsSect2Content").css("left", "0px");
        $.ajax({
            url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9&index=' + (mainOfferId + 1),
            cache: true,
            success: function(html) {
                $("#rsContent1 .rsSect2Content").append(html);
                numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                $('.rscLoading').fadeOut('slow');
                opacityShift();
                doTrackingCont1();

            }
        });
    });
}

function getTab1ItemsSearch(tab1Index) {

    var urlParamOffer;

    if (mallId !== 'null') {
        urlParamOffer = 'id=' + mallId;
    } else {
        urlParamOffer = 'id=' + urlParamID;
    }

    $.ajax({
        url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9&index=' + tab1Index,
        cache: true,
        success: function(html) {
            $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
            $("#rsContent1 .rsSect2Content").append(html);
            numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
            $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
            $('.rscLoading').fadeOut('slow');
            doTrackingCont1();
            $(".maskWhole").delay(3000).fadeOut("slow");
        }
    });
}

function tab1Interval() {

    try {
        var urlParamOffer;

        if (mallId !== 'null') {
            urlParamOffer = 'id=' + mallId;
        } else {
            urlParamOffer = 'id=' + urlParamID;
        }

        if ($('#rsContent1 .rsSect2Content').hasClass('contentLoaded')) {
            clearInterval(interval);
            if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9) {
                //$("#rsTab1").trigger("click");
                doTabOneClick();
                $("#rsContent1 .rsWhatsNow").css({ "left": "43px" });
                $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent1 .rsSect2").css({ "left": "79px" });
                $("#rsContent1 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
                //$("#rsContent1 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
                opacityShift();
                doTrackingCont1();

            } else {
                $('.rscLoading').fadeIn('slow');
                //$("#rsTab1").trigger("click");
                doTabOneClick();
                $("#rsContent1 .rsWhatsNow").css({ "left": "43px" });
                $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent1 .rsSect2").css({ "left": "79px" });
                $.ajax({
                    url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=7&' + urlParamOffer + '&rsItem=' + rsOpenItem,
                    cache: true,
                    success: function(html) {
                        getTab1ItemsSearch(html);

                    }
                });
            }
        }
    } catch (e) { console.log(e.message); }
}

function tab2Interval() {
    if ($('#rsContent2 .rsSect2Content').hasClass('contentLoaded')) {
        try {
            clearInterval(interval);
            //$("#rsTab2").trigger("click");
            doTabTwoClick();
            $(".maskWhole").hide();
            $("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
            opacityShift();
            doTrackingCont2();
        } catch (e) { }
        //$("#rsContent2 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
    }
}

$("#rsTab1").live("click", function() {
    doTabOneClick();
    startRscPopulate();
});

function doTabOneClick() {
    var tabOne = $("#rsTab1");
    if (!$(tabOne).hasClass("current")) {
        //$(".rsSectContainer").animate({ "left": "0px" });
        $(".rsSectContainer").css({ "left": "0px" });
        opacityShift();
        $("#rsTab2, #rsTab3").removeClass("current");
        $('#rsContent3').hide();
        $(tabOne).addClass("current");
    }
    $("#rsContent2,#rsContent3").hide();
    $("#rsContent1").show();
    $(".rsSectContainer").css('left', '1px');
    $(".maskWhole").remove();       // IE Fix
    if ($("#rsContent1 .rsWhatsNow").hasClass('current')) $(".rsSect2Offer").show(); else {
        $(".rsSect2Offer").hide();
    }
    rsOpenTab = "rsOpenTab1";
}

$("#rsTab2").live("click", function() {
    doTabTwoClick();
    startRscPopulate();
});

function doTabTwoClick() {
    var tabTwo = $("#rsTab2");
    if (!$(tabTwo).hasClass("current")) {
        //$(".rsSectContainer").animate({ "left": "-728px" });
        $(".rsSectContainer").css({ "left": "-728px" });
        opacityShift();
        $("#rsTab1, #rsTab3").removeClass("current");
        $('#rsContent3').hide();
        $(tabTwo).addClass("current");
    }
    $("#rsContent1,#rsContent3").hide();
    $("#rsContent2").show();
    $("#rsContent3").css('left', '1px');
    $(".rsSectContainer").css('left', '1px');
    $(".maskWhole").hide();
    if ($(".rsPanelNewsEvents").hasClass('current')) $("div[class*=NewsEventItem]").hide(); else {
        $("div[class*=NewsEventItem]").show();
    }
    rsOpenTab = "rsOpenTab2";
}

$("#rsTab3").live("click", function() {
    $('.rscLoading').fadeIn('slow');
    doTabThreeClick();
    loadOverlaySocialContent();
});

function doTabThreeClick() {
    var tabThree = $("#rsTab3");
    if (!$(tabThree).hasClass("current")) {
        //opacityShift();
        $('#rsContent3').show();
        $("#rsTab2, #rsTab1").removeClass("current");
        $(tabThree).addClass("current");
    }
    // force
    $("#rsContent1,#rsContent2").hide();
    $("#rsContent3").show();
    $("#rsContent3").css('top', '1px');
    $(".rsSectContainer").css('left', '1px');
}

function loadOverlaySocialContent(fn) {
    var tabThreeCacheStatus = $.inArray('rsOpenTab3', loadedTabs);
    if (tabThreeCacheStatus == -1) {
        $.ajax({
            url: '/ajax/overlay/getoverlaysocial.ashx?id=' + urlParamID,
            cache: true,
            dataType: 'html',
            success: function(html) {
                var obj = $(html);
                var fbContent = obj.parent().find('div[id*=facebookBox]').html();
                var twContent = obj.parent().find('div[id*=twitterBox]').html();

                var fbHTML = '<div id="ctl00_facebookBox">' + fbContent + '</div>';
                var twHTML = '<div id="ctl00_twitterBox">' + twContent + '</div>';

                $('#facebox').html(fbHTML);
                $('#twitbox').html(twHTML);

                loadedTabs.push("rsOpenTab3");

                $('.rscLoading').fadeOut('slow');

                checkFacebookTwitterOverlay();

                if (typeof fn == "function") fn();
            }
        });
    }
}

function checkFacebookTwitterOverlay() {
    // social/connection tab
    if ($("#socialFacebook").css('display') == 'none') {
        socialTab = 'twitter';
    } else {
        socialTab = 'facebook';
    }
    if (typeof socialTab != 'undefined' && socialTab != '') {

        forceConnectionTabDisplay();
        selectTab(socialTab);
    }
    var hasTwitter = $("input[name*=hasTwitter]").val();
    if (typeof hasTwitter == "undefined" || hasTwitter == 'undefined' || hasTwitter == '') {
        $("#rsTab3").hide();
    } else {
        var hasFacebook = $("input[name*=hasFacebook]").val();
        if (hasFacebook != '1') {
            selectTab('twitter');
            $(".facebookicon").hide();
            $(".twittericon").removeClass().addClass("socialIconSelected");
        }
        if (hasTwitter != '1') {
            $(".twittericon").hide();
        }
    }
}

/* Urchin Tracking - Begin */
function doTrackingCont1() {
    var urchLeft = $('#rsContent1 .rsSect2Content').position().left;
    if (urchLeft < 0) {
        urchLeft = -$('#rsContent1 .rsSect2Content').position().left;
    }
    var urchWidth = $('#rsContent1 .rsSect2Content').width();
    var urchAmt = $('#rsContent1 .rsSect2Content').width() / $('#rsContent1 .rsSect2Content .rsSect2Offer').width();
    var urchPos = (urchWidth - urchLeft) / $('#rsContent1 .rsSect2Content .rsSect2Offer').width();
    var urchIndex = urchAmt - urchPos;
    var urchVar = $('#rsContent1 .rsSect2Content .rsSect2Offer').eq(urchIndex).find('.rsTracking').val();
    if (urchVar) {
        try {
            urchinTracker(urchVar);
            console.log(urchVar);
        } catch (e) { }
    }
}

function doTrackingCont2() {
    var urchLeft = $('#rsContent2 .rsSect2Content').position().left;
    if (urchLeft < 0) {
        urchLeft = -$('#rsContent2 .rsSect2Content').position().left;
    }
    var urchWidth = $('#rsContent2 .rsSect2Content').width();
    var urchAmt = $('#rsContent2 .rsSect2Content').width() / $('#rsContent2 .rsSect2Content .rsSect2Offer').width();
    var urchPos = (urchWidth - urchLeft) / $('#rsContent2 .rsSect2Content .rsSect2Offer').width();
    var urchIndex = urchAmt - urchPos;
    var urchVar = $('#rsContent2 .rsSect2Content .rsSect2Offer').eq(urchIndex).find('.rsTracking').val();
    if (urchVar) {
        try {
            urchinTracker(urchVar);
            console.log(urchVar);
        } catch (e) { }
    }
}
/* Urchin Tracking - End */

$("#rsContent1 .rsSect2BottomNext").live("click", function() {
    var currClicked = $(this);
    if ($(currClicked).hasClass("enabled")) {
        $(currClicked).removeClass("enabled");
        $('.rsNoScroll').css('top', '0');
        $('.rsScroll').css('top', '0px');
        if (-$("#rsContent1 .rsSect2Content").position().left < (numCont1Offers * 630) - 630) {
            $("#rsContent1 .rsSect2Content").css({ "left": $("#rsContent1 .rsSect2Content").position().left - 630 + "px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            doTrackingCont1();
        } else {
            var urlParamOffer;

            if (mallId !== 'null') {
                urlParamOffer = 'id=' + mallId;
            } else {
                urlParamOffer = 'id=' + urlParamID;
            }

            function getNextOffers(indexNumber) {
                //$("#rsContent1 .rsSect2Content").animate({ "left": "-=630px" }, "slow", function() {
                //                $('.rscLoading').fadeIn('slow', function() {
                //                    $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
                //                    $("#rsContent1 .rsSect2Content").css("left", "0px");
                //                    $.ajax({
                //                        url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9&index=' + indexNumber,
                //                        cache: true,
                //                        success: function(html) {
                //                            $("#rsContent1 .rsSect2Content").append(html);
                //                            numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                //                            $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                //                            $('.rscLoading').fadeOut('slow', function() {
                //                                $(currClicked).addClass("enabled");
                //                                doTrackingCont1();
                //                            });
                //                        }
                //                    });
                //                });
                //});
            }

            if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9) {
                //$("#rsContent1 .rsSect2Content").animate({ "left": "0px" }, "normal");
                $("#rsContent1 .rsSect2Content").css({ "left": "0px" });
                opacityShift();
                $(currClicked).addClass("enabled");
                doTrackingCont1();
            } else if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemNumber').text()) === $.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text())) {
                getNextOffers(0);
            } else {
                getNextOffers($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemNumber').text()));
            }
        }
    }
});
$("#rsContent1 .rsSect2BottomPrevious").live("click", function() {
    var currClicked = $(this);
    if ($(currClicked).hasClass("enabled")) {
        $(currClicked).removeClass("enabled");
        $('.rsNoScroll').css('top', '0');
        $('.rsScroll').css('top', '0px');
        if ($("#rsContent1 .rsSect2Content").position().left < 0) {
            /*$(currClicked).removeClass("enabled");
            $("#rsContent1 .rsSect2Content").animate({ "left": "+=630px" }, "slow", function() {
            $(currClicked).addClass("enabled");
            opacityShift();
            });*/
            $("#rsContent1 .rsSect2Content").css({ "left": $("#rsContent1 .rsSect2Content").position().left + 630 + "px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            doTrackingCont1();
        } else {

            var urlParamOffer;

            if (mallId !== 'null') {
                urlParamOffer = 'id=' + mallId;
            } else {
                urlParamOffer = 'id=' + urlParamID;
            }

            if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9) {
                /*$("#rsContent1 .rsSect2Content").animate({ "left": -((numCont1Offers * 630) - 630) + "px" }, "normal", function() {
                $(currClicked).addClass("enabled");
                });*/
                $("#rsContent1 .rsSect2Content").css({ "left": -((numCont1Offers * 630) - 630) + "px" });
                opacityShift();
                $(currClicked).addClass("enabled");
                doTrackingCont1();
            } else if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemNumber').text()) < 9 && $.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemNumber').text()) > 1) {
                //$("#rsContent1 .rsSect2Content").animate({ "left": "+=630px" }, "slow", function() {
                //                $('.rscLoading').fadeIn('slow', function() {
                //                    $.ajax({
                //                        url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=' + ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemNumber').text()) - 1),
                //                        cache: true,
                //                        success: function(html) {
                //                            $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
                //                            $("#rsContent1 .rsSect2Content").append(html);
                //                            numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                //                            $("#rsContent1 .rsSect2Content").css("left", -((numCont1Offers * 630) - 630) + "px");
                //                            opacityShift();
                //                            doTrackingCont1();
                //                            $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                //                            $('.rscLoading').fadeOut('slow', function() {
                //                                $(currClicked).addClass("enabled");
                //                            });
                //                        }
                //                    });
                //                });
                //});
            } else if ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemNumber').text()) === '1') {
                //$("#rsContent1 .rsSect2Content").animate({ "left": "+=630px" }, "slow", function() {
                //                $('.rscLoading').fadeIn('slow', function() {
                //                    $.ajax({
                //                        url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9&index=' + ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemTotal').text()) - 9),
                //                        cache: true,
                //                        success: function(html) {
                //                            $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
                //                            $("#rsContent1 .rsSect2Content").append(html);
                //                            numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                //                            $("#rsContent1 .rsSect2Content").css("left", -((numCont1Offers * 630) - 630) + "px");
                //                            opacityShift();
                //                            doTrackingCont1();
                //                            $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                //                            $('.rscLoading').fadeOut('slow', function() {
                //                                $(currClicked).addClass("enabled");
                //                            });
                //                        }
                //                    });
                //                });
                //});
            } else {
                //$("#rsContent1 .rsSect2Content").animate({ "left": "+=630px" }, "slow", function() {
                //                $('.rscLoading').fadeIn('slow', function() {
                //                    $.ajax({
                //                        url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=3&' + urlParamOffer + '&count=9&index=' + ($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:first .offerItemNumber').text()) - 10),
                //                        cache: true,
                //                        success: function(html) {
                //                            $('#rsContent1 .rsSect2Content .rsSect2Offer').remove();
                //                            $("#rsContent1 .rsSect2Content").append(html);
                //                            numCont1Offers = $("#rsContent1 .rsSect2Offer").length;
                //                            $("#rsContent1 .rsSect2Content").css("left", -((numCont1Offers * 630) - 630) + "px");
                //                            doTrackingCont1();
                //                            $("#rsContent1 .rsSect2Content").width(numCont1Offers * 630 + "px");
                //                            $('.rscLoading').fadeOut('slow', function() {
                //                                $(currClicked).addClass("enabled");
                //                            });
                //                        }
                //                    });
                //                });
                //});
            }
        }
    }
});



/* function to control the learn-more button showing/hiding  */


$("#rsContent2 .rsSect2BottomNext").live("click", function() {
    var currClicked = $(this);
    if ($(currClicked).hasClass("enabled")) {
        $(currClicked).removeClass("enabled");
        if (-$("#rsContent2 .rsSect2Content").position().left < (newsEventCount * 630) - 630) {
            /*$(currClicked).removeClass("enabled");
            $("#rsContent2 .rsSect2Content").animate({ "left": "-=630px" }, "slow", function() {
            $(currClicked).addClass("enabled");
            opacityShift();
            });*/

            $("#rsContent2 .rsSect2Content").css({ "left": $("#rsContent2 .rsSect2Content").position().left - 630 + "px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            $(".maskWhole").delay(3600).fadeOut("slow");
            if ($('#newspod').length < 1) {
                $('#rsTab2').hide();
            } else {
                $('#rsTab2').show();
            }
            doTrackingCont2();
        } else {
            /*$(currClicked).removeClass("enabled");
            $("#rsContent2 .rsSect2Content").animate({ "left": "0px" }, "normal", function() {
            $(currClicked).addClass("enabled");
            opacityShift();
            });*/
            $("#rsContent2 .rsSect2Content").css({ "left": "0px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            $(".maskWhole").delay(3600).fadeOut("slow");
            if ($('#newspod').length < 1) {
                $('#rsTab2').hide();
            } else {
                $('#rsTab2').show();
            }
            doTrackingCont2();
        }
    }
});

$("#rsContent2 .rsSect2BottomPrevious").live("click", function() {
    var currClicked = $(this);
    if ($(currClicked).hasClass("enabled")) {
        $(currClicked).removeClass("enabled");

        if ($("#rsContent2 .rsSect2Content").position().left < 0) {
            /*$(currClicked).removeClass("enabled");
            $("#rsContent2 .rsSect2Content").animate({ "left": "+=630px" }, "slow", function() {
            $(currClicked).addClass("enabled");
            opacityShift();
            });*/
            $("#rsContent2 .rsSect2Content").css({ "left": $("#rsContent2 .rsSect2Content").position().left + 630 + "px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            $(".maskWhole").delay(3000).fadeOut("slow");

            doTrackingCont2();
        } else {
            /*$(currClicked).removeClass("enabled");
            $("#rsContent2 .rsSect2Content").animate({ "left": -((numCont2Offers * 630) - 630) + "px" }, "normal", function() {
            $(currClicked).addClass("enabled");
            opacityShift();
            });*/
            $("#rsContent2 .rsSect2Content").css({ "left": -((numCont2Offers * 630) - 630) + "px" });
            opacityShift();
            $(currClicked).addClass("enabled");
            $(".maskWhole").delay(3000).fadeOut("slow");

            doTrackingCont2();

        }
    }
});

$('.rsSect2BottomViewAllOffers').live('click', function() {
    $("#rsContent1 .rsWhatsNow").css({ "left": "674px" });
    $("#rsContent1 .rsWhatsNow").addClass("rsPanelRight");
    $("#rsContent1 .rsSect2").css({ "left": "709px" });
    opacityShift();
    removeCurrentSubNavCurrent(1);
    $(".rsPanelSalesOffers").addClass('current');
    $(".rsSect2Offer").hide();
});

$('.rsSect2BottomViewAllNewsEvents').live('click', function() {
    $("#rsContent2 .rsWhatsNow").css({ "left": "674px" });
    $("#rsContent2 .rsWhatsNow").addClass("rsPanelRight");
    $("#rsContent2 .rsSect2").css({ "left": "709px" });
    opacityShift();
    removeCurrentSubNavCurrent(2);
    $(".rsPanelNewsEvents").addClass('current');
    $("div[class*=NewsEventItem]").hide();
});

function rsActivate() {
    if (rsOpenTab == null) {
        return;
    } else if (rsOpenTab === "rsOpenTab1") {
        //$("#rsTab1").trigger("click");
        doTabOneClick();
    } else if (rsOpenTab === "rsOpenTab2") {
        //$("#rsTab2").trigger("click");
        doTabTwoClick();
        doTrackingCont2();
    } else if (rsOpenTab === "rsOpenTab3") {
        //$("#rsTab3").trigger("click");
        //doTrackingCont3();	
        doTabThreeClick();
    } else if (rsOpenTab === "rsOpenTabItem1") {
        if ($("#rsContent1 .rsSect2Offer").length > 0 && $.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9) {
            //$("#rsTab1").trigger("click");
            doTabOneClick();
            //$("#rsContent1 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
            $("#rsContent1 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
            doTrackingCont1();
            $(".maskWhole").delay(3000).fadeOut("slow");
            if ($('#newspod').length < 1) {
                $('#rsTab2').hide();
            } else {
                $('#rsTab2').show();
            }
        } else {
            interval = setInterval('tab1Interval()', 500);
        }
    } else if (rsOpenTab === "rsOpenTabItem2") {
        if ($("#rsContent2 .rsSect2Offer").length > 0) {
            //$("#rsTab2").trigger("click");
            doTabTwoClick();
            //$("#rsContent2 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
            $("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
            doTrackingCont2();
        } else {
            interval = setInterval('tab2Interval()', 500);
        }
    }
}

function rsAjaxCall() {
    if (DEBUG == true) console.log("running ajax calls...");
    var RSCOverlayMode = $('.RSCOverlayMode input').val();
    var RSCOverlayModeId = $('.RSCOverlayModeId input').val();

    if (RSCOverlayMode === 'OfferPreview') {
        //        $('#rsAjaxTarget').load('/ajax/overlay/getoverlaycontent.ashx?id=176', function() {
        //            rsActivate();
        //            startRscPopulate('OfferPreview', RSCOverlayModeId);
        //        });
    } else if (RSCOverlayMode === 'ShowcasePreview') {
        //        $('#rsAjaxTarget').load('/ajax/overlay/getoverlaycontent.ashx?id=176', function() {
        //            rsActivate();
        //            startRscPopulate('ShowcasePreview', RSCOverlayModeId);
        //        });
    } else if ($('#rsAjaxTarget .rsFindProp').length > 0 && mallId !== 'null') {
        //        $('#rsAjaxTarget').empty();
        //        $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48"/>');
        //        $('#rsAjaxTarget').load('/ajax/overlay/getoverlaycontent.ashx?id=' + mallId, function() {
        //            rsActivate();
        //            $.ajax({
        //                url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=5&id=' + mallId,
        //                cache: true,
        //                success: function(html) {
        //                    totNumOffers = html;
        //                    startRscPopulate();
        //                }
        //            });
        //        });
    } else if (rsOpenTab === "rsFindProp" || urlParamID === "") {
        $("#rsAjaxTarget").load("/ajax/overlay/getoverlaysearch.ashx", function() {
            $("#rsAjaxTarget :text").blur();
        });
    } else if (urlParamID !== "") {
        /*$("#rsAjaxTarget").load("/sandbox/retailer-showcase/retailer-showcase-content.html", function(){*/
        /*$("#rsAjaxTarget").load("/temp/retailer-showcase-content.html", function(){*/
        /*$("#rsAjaxTarget").load("/retailpromotions/showcase/ajax/GetOffer.ashx?Key=1246", function() {*/
        //        $('#rsAjaxTarget').load('/ajax/overlay/getoverlaycontent.ashx?id=' + urlParamID, function() {
        //            rsActivate();
        //            $.ajax({
        //                url: '/ajax/overlay/getoverlayitems.ashx?type=1&output=5&id=' + urlParamID,
        //                cache: true,
        //                success: function(html) {
        //                    totNumOffers = html;
        //                    startRscPopulate();
        //                }
        //            });

        //            if (gup('tab') == '') {
        //                if (typeof rsAjaxCallback == "function") rsAjaxCallback();
        //            }
        //        });
    } else {
        rsActivate();
    }
}

/* End Retailer Showcase Interaction
---------------------------------------------------	*/

var fadeOpen = function(hash) {
    hash.w.fadeIn(500);
    //hash.o.fadeIn(2000);
};
var rsFadeOpen = function(hash) {
    hash.w.fadeIn(500);
    hash.o.fadeIn(500);
    if (archivedEventID === 'null' && isEditWindowOpen == false) {
        rsAjaxCall();
    }
    isJQModalCall = true; //Used by adminEditor.js to decide if the window.onbeforeunload is because of a Modal popup call or not
};
var fadeClose = function(hash) {
    hash.w.fadeOut(500, function() { if (hash.o) hash.o.fadeOut(500); });
    if (sPage.toLowerCase() === 'tenantdetail.aspx') {
        if (gup('tid') === '0' && gup('preview') === '') {
            history.go(-1);
        }
    }
};
var rsFadeClose = function(hash) {
    hash.w.fadeOut(500);
    hash.o.fadeOut(500);

    if ($('#rsAjaxTarget .rsFindProp').length > 0) {
        $('#rsAjaxTarget').empty();
        $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48"/>');
    }
    if (archivedEventID !== 'null') {
        archivedEventID = 'null';
        $('#rsAjaxTarget').empty();
        $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48"/>');
        $('#navCoverPanels').remove();
    }
    setTimeout("isJQModalCall = false;", 500);
};

function renderFlash() {
    var currentTime = new Date();

    if ($("#flashSales1").length > 0) {
        var flashvars = {};
        flashvars.xmlFile = "/xml/test.xml?=" + currentTime.getTime();
        var params = {};
        params.wmode = "transparent";
        params.base = "/swf/";
        var attributes = {};
        swfobject.embedSWF("/swf/slider.swf", "flashSales1", "589", "130", "9.0.0", "/swf/expressInstall.swf", flashvars, params, attributes);
    }
}

function oneMall() {
    $("#containerResultsMallHeader").addClass("open");
    $("#containerResultsMallHeader").siblings("#containerResultsMall").slideDown("slow");
}

function oneStore() {
    $("#containerResultsStoreHeader").addClass("open");
    $("#containerResultsStoreHeader").siblings("#containerResultsStore").slideDown("slow");
}

function activateStoreLinks() {
    $(".inMallsBottom a").click(function() {
        var mallLink = $(this).parent().siblings(".inMallsMid").children("select").children("option:selected").attr("value");
        if (mallLink !== undefined) {
            window.location = mallLink;
        } else {
            $(this).siblings(".error").show();
        }
    });
}

/* Retailer Showcase Default Content
---------------------------------------------------	*/

function rsFindCall() {
    rsOpenTab = "rsFindProp";
    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");

    $("#overlayRetailerShowcase").jqmShow();


}

function rsTab1Call() {
    rsOpenTab = "rsOpenTab1";
    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
    $(".maskWhole").delay(3600).fadeOut("slow");
    $("#overlayRetailerShowcase").jqmShow();

}

function rsTab2Call() {
    rsOpenTab = "rsOpenTab2";
    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
    $(".maskWhole").delay(3600).fadeOut("slow");
    $("#overlayRetailerShowcase").jqmShow();

}

function rsTab3Call() {
    rsOpenTab = "rsOpenTab3";
    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
    $(".maskWhole").delay(3600).fadeOut("slow");
    $("#overlayRetailerShowcase").jqmShow();

}

$(".aShift").live("click", function() {
    var currClicked = $(this);
    /* 
    if ($(currClicked).parent(".rsSect2Middle").find(".rsScroll").css('display') === 'none') {
		
	}
    else {
	
	}
    */
    if ($(currClicked).parent(".rsSect2Middle").find(".rsNoScroll").position().top == 0) {
        //$(currClicked).removeClass("enabled");
        $(currClicked).css('background-position', 'left bottom');

        $(currClicked).parent(".rsSect2Middle").find(".rsNoScroll").hide();
        $(currClicked).parent(".rsSect2Middle").find(".rsScroll").toggle();

        //    	$(currClicked).parent(".rsSect2Middle").find(".rsNoScroll").animate({ "top": "-374px" }, "slow");    	
        //    	$(currClicked).parent(".rsSect2Middle").find(".rsScroll").show();
        //    	$(currClicked).parent(".rsSect2Middle").find(".rsScroll").animate({ "top": "0px" }, "slow", function() {
        //    		opacityShift();
        //    		$(currClicked).addClass("enabled");
        //    	});
    } else /* if ($(currClicked).parent(".rsSect2Middle").find(".rsScroll").position().top == 374) */{
        //$(currClicked).removeClass("enabled");
        $(currClicked).css('background-position', 'left top');
        $(currClicked).parent(".rsSect2Middle").find(".rsNoScroll").show();
        $(currClicked).parent(".rsSect2Middle").find(".rsScroll").toggle();
        //    	$(currClicked).parent(".rsSect2Middle").find(".rsNoScroll").animate({ "top": "0px" }, "slow"); 
        //    	$(currClicked).parent(".rsSect2Middle").find(".rsScroll").animate({ "top": "374px" }, "slow", function() {
        //    		opacityShift();
        //    		$(currClicked).addClass("enabled");
        //    	}); 
    }
});

$(".rsPromoTile").live("click", function() {
    if ($(".rsPromoTile").length < 9) {
        $("#rsContent1 .rsWhatsNow").css({ "left": "43px" });
        $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
        $("#rsContent1 .rsSect2").css({ "left": "79px" });
        //$("#rsContent1 .rsSect2Content").animate({ "left": "-" + (($('.rsPromoTile').index(this) * 630) + 630) + "px" }, "slow");
        $("#rsContent1 .rsSect2Content").css({ "left": "-" + (($('.rsPromoTile').index(this) * 630) + 630) + "px" });
        $(".rsSect2Offer").show();
        opacityShift();
        doTrackingCont1();
        $(".maskWhole").delay(3000).fadeOut("slow");

    } else {
        goToMainOffer($('.rsPromoTile').index(this));
        $(".maskWhole").delay(3000).fadeOut("slow");
        $(".rsSect2Offer").show();
        if ($('#newspod').length < 1) {
            $('#rsTab2').hide();
        } else {
            $('#rsTab2').show();
        }
    }
    removeCurrentSubNavCurrent(1);
    $("#rsContent1 .rsWhatsNow").addClass('current');
});

$(".aMoreNewsEvents").live("click", function(e) {
    $("#rsContent2 .rsWhatsNow").css({ "left": "43px" });
    $("#rsContent2 .rsWhatsNow").removeClass("rsPanelRight");
    $("#rsContent2 .rsSect2").css({ "left": "79px" });
    //$("#rsContent2 .rsSect2Content").animate({ "left": "-" + $("." + $(this).attr("rsItem")).position().left + "px" }, "slow");

    $(".rsSect2Offer").show();
    //console.log("new pos: -" + $(e.target).attr("rsItem") + ":" + $("." + $(e.target).attr("rsItem")).position().left);

    $("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + $(e.target).attr("rsItem")).position().left + "px" });

    removeCurrentSubNavCurrent(2);

    $("#rsContent2 .rsWhatsNow").addClass('current');
    //opacityShift();
    //doTrackingCont2();
});

function centerCards() {
    if ($('#cardsAvailableColA .simonSlideContent').width() < 150) {
        $('#cardsAvailableColA .simonSlideContent').css('left', '210px');
    } else if ($('#cardsAvailableColA .simonSlideContent').width() < 290) {
        $('#cardsAvailableColA .simonSlideContent').css('left', '140px');
    } else if ($('#cardsAvailableColA .simonSlideContent').width() < 430) {
        $('#cardsAvailableColA .simonSlideContent').css('left', '70px');
    }
}

/* End Retailer Showcase Default Content
---------------------------------------------------	*/

$(document).ready(function() {
    //renderFlash();

    $("head").append('<!--[if ie 6]><link rel="stylesheet" href="/css/ie6.css" type="text/css" media="screen" charset="utf-8" /><![endif]--> <!--[if ie 7]><link rel="stylesheet" href="/css/ie7.css" type="text/css" media="screen" charset="utf-8" /><![endif]-->');

    $("#btnFindPropertySlider").click(function() {
        if ($("#searchSlideDown").css("top") === "-46px") {
            $("#searchSlideDown").animate({ "top": "0px" }, "slow");
        } else {
            $("#searchSlideDown").animate({ "top": "-46px" }, "slow");
        }
    });

    $(".rsPanelSalesOffers").click(function() {
        $(".rsSect2Offer").hide();
    });

    $(".btnLogIn").click(function() {
        if ($("#slideSignInHolder").css("display") === "none") {
            $(".btnLogIn").css("text-decoration", "underline");
            $("#slideSignInHolder").show();
            $("#slideSignIn").animate({ "top": "0px" }, "slow");
            $("input[name='EmailLogin']").focus();
        } else {
            $("#slideSignIn").animate({ "top": "-165px" }, "slow", function() {
                $("#slideSignInHolder").hide();
                $(".btnLogIn").css("text-decoration", "none");
            });
        }
    });

    $("#slideSignIn .btnClose").click(function() {
        $("#slideSignIn").animate({ "top": "-165px" }, "slow", function() {
            $("#slideSignInHolder").hide();
            $(".btnLogIn").css("text-decoration", "none");
            $("#slideSignIn .error").hide();
        });
    });

    if ($("#slideCheckBalanceHolder").length > 0) {
        var position = $(".btnCheckBalance").position();

        $("#slideCheckBalanceHolder").css({
            "left": (position.left - 12) + "px",
            "top": "-" + (340 - position.top) + "px"
        });

        $(".btnCheckBalance").click(function() {
            if ($("#slideCheckBalanceHolder").css("display") === "none") {
                $(".btnCheckBalance").css("background", "url(/images/global/pod-nav-bottom-bg-hover.png) left top repeat-x");
                $("#slideCheckBalanceHolder").show();
                $("#slideCheckBalance").animate({ "top": "0px" }, "slow");
            } else {
                $("#slideCheckBalance").animate({ "top": "396px" }, "slow", function() {
                    $("#slideCheckBalanceHolder").hide();
                    $(".btnCheckBalance").css("background", "none");
                });
            }
        });

        $("#slideCheckBalance .btnClose").click(function() {
            $("#slideCheckBalance").animate({ "top": "396px" }, "slow", function() {
                $("#slideCheckBalanceHolder").hide();
                $(".btnCheckBalance").css("background", "none");
            });
        });
    }

    //$(".btnRegisterCard").attr("href","javascript:;");
    $(".btnRegisterCard span").click(function() {
        showMessage('Register Your Card', 'Planning to use your Simon Giftcard<sup>&reg;</sup> for online purchases? If so, register with us first to ensure smooth transactions! <br /><br /><a href="/giftcard/faq.aspx?giftcard=1">See our Gift Card FAQ&rsquo;s for more information.</a>');
        return false;
    });
    /*$(".btnRegisterCard :not(span)").click(function(){
    window.location = "/giftcard/"
    });*/

    $(".podTopNavHalf a").click(function() {
        if (!$(this).hasClass("current")) {
            $(".podTopNavHalf .current").removeClass("current");
            $(this).addClass("current");
            if ($(".podAMid .sect1").css("display") === "none") {
                $(".podAMid .sect2").hide();
                $(".podAMid .sect1").show();
            } else {
                $(".podAMid .sect1").hide();
                $(".podAMid .sect2").show();
            }
        }
    });

    $(".podBSlide .slideTrigger,#genericMallMap").click(function() {
        if ($(".podBSlideContent").css("display") === "none") {
            $(".podBSlide .slideTrigger").css("background-position", "-1099px bottom");
            $("#genericMallMap").fadeOut("slow");
            $(".podBSlide .slideTrigger").siblings(".podBSlideContent").slideDown("slow");
            if (typeof window.LoadMap == 'function') LoadMap();
        } else {
            $(".podBSlide .slideTrigger").css("background-position", "-1099px top");
            $(".podBSlide .slideTrigger").siblings(".podBSlideContent").slideUp("slow");
            $("#genericMallMap").fadeIn("slow");
        }
    });

    $(".podNavABottom a.navLast").hover(
		function() {
		    $(this).children("span").css("background-position", "-1026px bottom");
		},
		function() {
		    $(this).children("span").css("background-position", "-1026px top");
		}
	);

    $(".hideValueKeyword").click(function() {
        $(this).attr("value", "");
    });
    $("#searchMainHorz .hideValueKeyword").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "Keyword Search");
        }
    });
    $("#colB .hideValueKeyword").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "Retailer or Dining Option");
        }
    });

    $(".findOffersKeyword").click(function() {
        if ($(this).attr("value") === "Keyword") {
            $(this).attr("value", "");
        }
    });
    $(".findOffersKeyword").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "Keyword");
        }
    });

    $(".hideValueZip").click(function() {
        if ($(this).attr("value") === "ZIP") {
            $(this).attr("value", "");
            $(this).mask("99999");
        }
    });
    $(".hideValueZip").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "ZIP");
        }
    });

    $("#mallDirectoryList input").click(function() {
        if ($(this).attr("value") === "Search") {
            $(this).attr("value", "");
        }
    });
    $("#mallDirectoryList input").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "Search");
        }
    });

    $(".rsFindPropText").click(function() {
        if ($(this).attr("value") === "Search here") {
            $(this).attr("value", "");
        }
    });
    $(".rsFindPropText").blur(function() {
        if ($(this).attr("value") === "") {
            $(this).attr("value", "Search here");
        }
    });

    $(".txtFooterSearch").click(function() {
        if (!$(this).css("background-image") === "") {
            $(this).css("background-image", "none");
        }
    });
    $(".txtFooterSearch").blur(function() {
        if ($(this).css("background-image") === "none") {
            $(this).css("background-image", "url(/images/global/bg-google.png)");
        }
    });


    $(":checkbox").each(function() {
        $(this).addClass("inputNotText");
    });

    /*	Forgot Password Overlay
    ---------------------------------------------------	*/
    $("#overlayForgotPassword").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85
    });
    $("#overlayForgotPassword .btnClose").click(function() {
        $("#overlayForgotPassword").jqmHide();
    });
    $(".forgotPassword").click(function() {
        $("#overlayForgotPassword").jqmShow();
    });

    /*	Small Overlay
    ---------------------------------------------------	*/
    $("#overlaySmall").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85,
        overlayClass: "jqmOverlaySmall"
    });
    $("#overlaySmall .btnClose").click(function() {
        $("#overlaySmall").jqmHide();
    });
    $(".showSmallOverlay").click(function() {
        $("#overlaySmall").jqmShow();
    });

    /*	Video Overlay
    ---------------------------------------------------	*/
    $("#overlayVideo").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85,
        overlayClass: "jqmOverlaySmall"
    });
    $("#overlayVideo .btnClose").click(function() {
        $("#videoContent").html("");
        $("#overlayVideo").jqmHide();
    });


    /*	divThreeDigit Overlay
    ---------------------------------------------------	*/
    $("#divThreeDigit").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85,
        overlayClass: "jqmOverlaySmall"
    });
    $("#divThreeDigit .btnClose").click(function() {
        $("#divThreeDigit").jqmHide();
    });
    $(".showSmallOverlay").click(function() {
        $("#divThreeDigit").jqmShow();
    });

    /*	divWarning Overlay
    ---------------------------------------------------	*/
    $("#divWarning").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85,
        overlayClass: "jqmOverlaySmall"
    });

    /*	divNY Overlay
    ---------------------------------------------------	*/
    $("#divNY").jqm({
        onShow: fadeOpen,
        onHide: fadeClose,
        overlay: 85,
        overlayClass: "jqmOverlaySmall"
    });

    /*	Retailer Showcase Overlay
    ---------------------------------------------------	*/
    $("#overlayRetailerShowcase").jqm({
        onShow: rsFadeOpen,
        onHide: rsFadeClose,
        overlay: 85,
        overlayClass: "jqmOverlayRS"
    });
    $(".showRS").live('click', function() {
        rsOpenTab = $(this).attr("rsOpenTab");
        if (mallId !== 'null') {
            displayOverlayLoader();
            mallId = 'null';
            $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());

        }

        $(".maskWhole").delay(3000).fadeOut("slow");

        $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
        $("#overlayRetailerShowcase").jqmShow();

        $(".rsWhatsNow").removeClass("current");            // Make What's Now Not The Current Tab
        $(".rsPanelSalesOffers,rsPanelNewsEvents").addClass("current");

        if (rsOpenTab != 'rsOpenTab3') socialTab = '';

        displayViewAllRsTab(rsOpenTab);

    });

    /*$('.simonSlidePod2 .slidePodImg').live('click',function(){
    if(mallId !== 'null'){
    $('#rsAjaxTarget').empty();
    $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48"/>');
    mallId = 'null';
    $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
    }
    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
    $(".maskWhole").delay(3000).fadeOut("slow");
    if ($('#newspod').length<1) {
    $('.rsTab2').hide();
    } else {
    $('.rsTab2').show();
    }
    $("#overlayRetailerShowcase").jqmShow();
				
    });
    */

    $('div[id*=ImagePanelShowcaseItem]').live('click', function(event) {
        event.stopPropagation();
        if (mallId !== 'null') {
            $('#rsAjaxTarget').empty();
            $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48"/>');
            mallId = 'null';
            $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
        }
        $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
        $(".maskWhole").delay(3000).fadeOut("slow");
        if ($('#newspod').length < 1) {
            $('#rsTab2').hide();
        } else {
            $('#rsTab2').show();
        }
        $("#overlayRetailerShowcase").jqmShow();

        rsOpenTab = 'rsOpenTab1';
        displayViewAllRsTab('rsOpenTab1');
    });

    $(".btnCloseRS").click(function() {
        $(".maskWhole").show();
        $("#overlayRetailerShowcase").jqmHide();
    });

    $('.aRscFindMall').click(function() {
        if ($('.rsFindProp').length === 0) {
            $("#rsAjaxTarget").load("/ajax/overlay/getoverlaysearch.ashx", function() {
                $("#rsAjaxTarget :text").blur();
            });
        }
    });

    $('.rsButtonGo').live('click', function() {
        if ($('#rscFindMallNames option:selected').val()) {
            mallId = $('#rscFindMallNames option:selected').val();
            window.location = '/mall/deals.aspx?id=' + mallId;

            //            rsOpenTab = 'rsOpenTab1';
            //            $('#overlayRetailerShowcase .rsTitle span').text($('#rscFindMallNames option:selected').text());
            //            rsAjaxCall();
        }
    });

    $('#rscFindMallNames option').live('dblclick', function() {
        mallId = $('#rscFindMallNames option:selected').val();
        window.location = '/mall/deals.aspx?id=' + mallId;
        //        rsOpenTab = 'rsOpenTab1';
        //        $('#overlayRetailerShowcase .rsTitle span').text($('#rscFindMallNames option:selected').text());
        //        rsAjaxCall();
    });

    $(".rsWhatsNow").live("click", function() {
        //console.log($(this).hasClass('rsPanelContent1') + ":" + $(this).hasClass('rsPanelContent2'));
        if ($(this).hasClass('current') == false) {
            if ($(this).hasClass('rsPanelContent1')) {
                //$("div[class*=NewsEventItem]").hide();       
                $(".rsSect2Offer").show();
                //rsOpenTab = "rsOpenTab1";
                //rsActivate();
            } else if ($(this).hasClass('rsPanelContent2')) {
                tab2Interval();
                $(".rsSect2Offer").hide();
                //$("div[class*=NewsEventItem]").show();
                //rsOpenTab = "rsOpenTab2";
                //rsActivate();
                //rsOpenTab = "rsOpenTab2";
                //rsActivate();
            }
        }
    });


    $(".rsPanelContent1").live("click", function() {
        if ($(this).hasClass('current') == false) {
            removeCurrentSubNavCurrent(1);
            $(this).addClass('current');
            if ($(this).hasClass('rsWhatsNow') == false) {
                $(".rsSect2Offer").hide();
            }
            if ($("#rsContent1 .rsWhatsNow").css("left") === "43px") {
                $("#rsContent1 .maskWhole").show();
                $("#rsContent1 .rsWhatsNow").animate({ "left": "674px" }, "slow", function() {
                    $("#rsContent1 .rsWhatsNow").addClass("rsPanelRight");
                    $("#rsContent1 .maskWhole").hide();
                });
                $("#rsContent1 .rsSect2").animate({ "left": "709px" }, "slow");
                $("#rsContent1 .rsWhatsNow").css({ "left": "674px" });
                $("#rsContent1 .rsWhatsNow").addClass("rsPanelRight");
                $("#rsContent1 .rsSect2").css({ "left": "709px" });

                opacityShift();
            } else {
                $("#rsContent1 .maskWhole").show();
                $("#rsContent1 .rsWhatsNow").animate({ "left": "43px" }, "slow", function() {
                    $("#rsContent1 .maskWhole").hide();
                });
                $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent1 .rsSect2").animate({ "left": "79px" }, "slow");
                $("#rsContent1 .rsWhatsNow").css({ "left": "43px" });
                $("#rsContent1 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent1 .rsSect2").css({ "left": "79px" });

                opacityShift();
            }
        }
    });

    $(".rsPanelContent2").live("click", function() {
        if ($(this).hasClass('current') == false) {
            removeCurrentSubNavCurrent(2);
            $(this).addClass('current');
            if ($(this).hasClass('rsWhatsNow') == false) {
                $("div[class*=NewsEventItem]").hide();
            }
            $(".rsSect2Offer").show();
            if ($("#rsContent2 .rsWhatsNow").css("left") === "43px") {
                $("#rsContent2 .rsWhatsNow").css({ "left": "674px" });
                $("#rsContent2 .rsWhatsNow").addClass("rsPanelRight");
                $("#rsContent2 .rsSect2").css({ "left": "709px" });
                opacityShift();

                $("#rsContent2 .maskWhole").show();
                $("#rsContent2 .rsWhatsNow").animate({ "left": "674px" }, "slow", function() {
                    $("#rsContent2 .rsWhatsNow").addClass("rsPanelRight");
                    $("#rsContent2 .maskWhole").hide();
                });
                $("#rsContent2 .rsSect2").animate({ "left": "709px" }, "slow");
            } else {
                $("#rsContent2 .rsWhatsNow").css({ "left": "43px" });
                $("#rsContent2 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent2 .rsSect2").css({ "left": "79px" });

                opacityShift();
                $("#rsContent2 .maskWhole").show();
                $("#rsContent2 .rsWhatsNow").animate({ "left": "43px" }, "slow", function() {
                    $("#rsContent2 .maskWhole").hide();
                });
                $("#rsContent2 .rsWhatsNow").removeClass("rsPanelRight");
                $("#rsContent2 .rsSect2").animate({ "left": "79px" }, "slow");
            }
        }
    });

    /*	Wide Overlay
    ---------------------------------------------------	*/
    $(".jqmWindowWide").jqm({
        onShow: rsFadeOpen,
        onHide: fadeClose,
        overlay: 85
    });

    $(".showPropertyMap").click(function() {
        $("#PropertyMap").css("top", $(window).scrollTop() + "px");
        $("#PropertyMap").jqmShow();
    });

    $(".jqmWindowWide .btnClose").click(function() {
        $(".jqmWindowWide").jqmHide();
    });


    /*	Property Search Results
    ---------------------------------------------------	*/

    if ($(".propResultsSub1").length > 0 || $("#tableView").length > 0) {
        var tallestMall = 0;
        var tallestStore = 0;

        $("#tableView").hide();

        $("#containerResultsMall .propResultsSub2").empty();
        $("#containerResultsStore .propResultsSub2").empty();

        $(".propResultsSubHeader h6").append('<img src="/images/global/ajax-loader.gif" alt="ajax-loader" width="25" height="25" style="float:left; display:none;"/>');

        //20090815 jhopper - these have been changed to separate pages
        $("#navTabsResults a").click(function() {
            if (!$(this).hasClass("current")) {
                if ($(this).parent().attr("id") === "tabTableView") {
                    /*$("#navTabsResults a").removeClass("current");
                    $("#tabTableView a").addClass("current");
                    $("#mapView").hide();
                    $("#tableView").show();*/
                    location.href = $(this).attr("href") + '?' + location.href.split("?")[1];


                } else if ($(this).parent().attr("id") === "tabMapView") {
                    /*$("#navTabsResults a").removeClass("current");
                    $("#tabMapView a").addClass("current");
                    $("#tableView").hide();
                    $("#mapView").show();*/
                    location.href = $(this).attr("href") + '?' + location.href.split("?")[1];
                }
            }
        });

        $(".propResultsMainHeader a").click(function() {
            if ($(this).parent().parent().next().css("display") === "none") {
                $(this).parent().parent().next().slideDown("slow");
                $(this).parent().parent().addClass("open");
            } else {
                $(this).parent().parent().next().slideUp("slow");
                $(this).parent().parent().removeClass("open");
            }
        });

        /* Mall Extended info ajax and slide calls
        ---------------------------------------------------	*/
        $(".propResultsMalls .propResultsSubHeader p a").click(function() {
            $(this).parent().parent().children("h6").children("a").click();
        });

        /* Expand For More Info (Malls) */
        $(".propResultsMalls .propResultsSubHeader h6 a").click(function() {
            if (!$(this).parent().parent().hasClass("open")) {
                var clickedMallId = $(this).attr("id");
                var currMallLink = $(this);

                if (!$(this).parent().parent().next().children(".propResultsSubMap").length > 0) {
                    currMallLink.siblings("img").css("display", "block");
                    $(this).parent().parent().next().children(".propResultsSub2").load("/ajax/search/GetSearchResultsExpandedMallView.ashx?id=" + clickedMallId, function() {
                        currMallLink.siblings("img").css("display", "none");
                        $(this).siblings(".propResultsSubMap").css("display", "none");
                        $(this).siblings(".propResultsSubMap").css("left", "-3000px");
                        $(this).css({
                            "top": "0px",
                            "left": "0px",
                            "position": "relative",
                            "display": "none"
                        });
                        currMallLink.parent().parent().addClass("open");

                        $(this).slideDown("slow", function() {
                            $(this).siblings(".propResultsSubMap").hide();
                            $(this).siblings(".propResultsSubMap").left("449px");
                            $(this).siblings(".propResultsSubMap").fadeIn("slow");
                        });

                        $(this).css("display", "block");
                        $(this).children(".propResultsSubMap").css("display", "block");

                    });
                } else {
                    var myPointer = this;
                    $(this).parent().parent().next().children(".propResultsSub2").load("/ajax/search/GetSearchResultsExpandedMallView.ashx?id=" + clickedMallId, function() {

                        var index = $(".propResultsMalls .propResultsSubHeader h6 a").index(myPointer);
                        var mallID = $(myPointer).attr('id');
                        var newHTML = '<iframe src="/search/GoogleMapDisplay.aspx?id=' + mallID + '" width="453" height="291" style="overflow: hidden; border: 0px;" frameborder="0"></iframe>';
                        var divID = $('.propResultsSubMap:eq(' + index + ')').css('display', 'block');
                        var divID = $('.propResultsSubMap:eq(' + index + ')').html(newHTML);

                        /*						
                        currMallLink.siblings("img").css("display", "none");
                        $(this).siblings(".propResultsSubMap").css("display", "none");
                        $(this).css({
                        "top": "0px",
                        "left": "0px",
                        "position": "relative",
                        "display": "none"
                        });
                        */
                        currMallLink.parent().parent().addClass("open");

                        $(this).slideDown("slow", function() {
                            $(divID).fadeIn("slow");
                        });
                    });
                    $(this).parent().parent().next().children(".propResultsSubMap").css("display", "none");
                    $(this).parent().parent().next().children(".propResultsSub2").css({
                        "top": "0px",
                        "left": "0px",
                        "display": "none"
                    });
                    $(this).parent().parent().addClass("open");
                    $(this).parent().parent().next().children(".propResultsSub2").slideDown("slow", function() {
                        $(this).siblings(".propResultsSubMap").fadeIn("slow");
                    });
                }
            } else {
                $(this).parent().parent().removeClass("open");
                $(this).parent().parent().next().children(".propResultsSubMap").fadeOut("slow", function() {
                    $(this).siblings(".propResultsSub2").slideUp("slow");
                });
            }
        });

        /* Auto Expand if =1 Results */
        var results = $('.propResultsMalls .propResultsSubHeader h6 a').length;
        if (results == 1) {
            $('.propResultsMalls .propResultsSubHeader h6 a').each(function(i) {
                $(this).trigger('click');
            });
        }

        /* Store Extended info ajax and slide calls
        ---------------------------------------------------	*/

        $(".propResultsStores .propResultsSubHeader h6 a").click(function() {
            if (!$(this).parent().parent().hasClass("open")) {
                var clickedStoreName = $(this).attr("id");

                //clickedStoreName = clickedStoreName.replace(/\s+/g, "+");
                //clickedStoreName = escape(clickedStoreName);

                var currStoreLink = $(this);

                if (!$(this).parent().parent().next().children(".propResultsSub2").children(".storeInfo").length > 0) {
                    currStoreLink.siblings("img").css("display", "block");
                    $(this).parent().parent().next().children(".propResultsSub2").load("/ajax/search/GetSearchResultsExpandedStoreView.ashx?btid=" + clickedStoreName, function() {
                        currStoreLink.siblings("img").css("display", "none");
                        activateStoreLinks();
                        $(this).css({
                            "top": "0px",
                            "left": "0px",
                            "display": "none"
                        });
                        currStoreLink.parent().parent().addClass("open");

                        //$(this).slideDown("slow");

                        $(this).css("display", "block");

                    });
                } else {
                    $(this).parent().parent().next().children(".propResultsSub2").css({
                        "top": "0px",
                        "left": "0px",
                        "display": "none"
                    });
                    $(this).parent().parent().addClass("open");

                    //$(this).parent().parent().next().children(".propResultsSub2").slideDown("slow");

                    $(this).parent().parent().next().children(".propResultsSub2").css("display", "block");
                }
            } else {
                $(this).parent().parent().removeClass("open");
                //$(this).parent().parent().next().children(".propResultsSub2").slideUp("slow");
                $(this).parent().parent().next().children(".propResultsSub2").css("display", "none");
            }
        });

        $("#tableView tr").each(function() {
            $(this).children("td:last").css("border-right", "none");
        });

        $("#tableView thead td:last").css("border-right", "none");
    }

    if ($('.resultsPageTop').length > 0) {
        $('.resultsPageBottom').html($('.resultsPageTop').html());
    }

    /* Mall Directory
    ---------------------------------------------------	*/

    if ($("#mallDirectoryList").length > 0) {
        $(".sect2").localScroll();
        var storeLet = gup("let");
        var storeCat = gup("cid");

        if (storeLet !== "") {
            $("#viewLetter").trigger("click");
            $.scrollTo($("a[name=" + storeLet + "]"), "slow");
        } else if (storeCat !== "") {
            $.scrollTo($("#cat" + storeCat), "slow", { onAfter: function() { $("#cat" + storeCat).trigger("click"); } });
        }
    }

    $("#mallDirectoryLegend li:last").addClass("last");
    /*  browser detection */

    //$.browser.msie7 = $.browser.msie && /MSIE 7\.0/i.test(window.navigator.userAgent);

    $(".liCatHead a").click(function() {
        if (!$(this).hasClass("open")) {
            $(this).addClass("open");
            $(this).parent(".liCatHead").children("div").slideDown("fast");
            $(this).parent(".liCatHead").children("div").css("zoom", "1");

        } else {
            $(this).removeClass("open");
            $(this).parent(".liCatHead").children("div").slideUp("fast");
            $(".liCatHead").children("div").css("zoom", "1");
        }
    });

    /* Simon Slide
    ---------------------------------------------------	*/

    if ($(".simonSlideContent").length > 0) {
        $(".simonSlideContent").each(function() {
            var ajaxLink = $(this).attr("ajaxLink");
            $(this).load(ajaxLink, function() {
                var slideWidth = 0;
                $(this).parent(".simonSlideContentHolder").parent(".simonSlideContainer").append('<div class="simonSlidePodCount" style="display:none;">0</div>');
                $(this).children("div").each(function() {
                    var currWidth = $(this).innerWidth() + 1;
                    slideWidth = slideWidth + currWidth;
                    //console.log("Adding: " + currWidth);
                });
                $(this).width(slideWidth);

                $("img.reflect").each(function() {
                    $(this).load(function() {
                        $(this).attr({
                            "width": "145",
                            "height": "93"
                        });
                        $(this).reflect({ height: 0.1, opacity: 0.3 });
                    });
                });

                /* init slider if sliderIndex value set */
                var initIndex = $("input[type=hidden][id*=sliderIndex]").val();
                if (initIndex != 'undefined') {
                    InitHorizSlider(initIndex);
                }

                $(".slideMallDirectory .simonSlidePod img").each(function() {
                    $(this).load(function() {
                        var imgHeight = $(this).height();
                        var containerHeight = 68;
                        var imgMarginTop = (containerHeight - imgHeight) / 2;
                        $(this).css("margin-top", imgMarginTop + "px");
                    });
                });

                /* Retailer Showcase Open Items */
                $(".showRSItemTab1").click(function() {
                    resetTabCache();
                    rsOpenTab = "rsOpenTabItem1";
                    rsOpenItem = $(this).attr("rsItem");
                    if (mallId !== 'null') {
                        $('#rsAjaxTarget').empty();
                        $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48" />');
                        mallId = 'null';
                        $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
                        $(".maskWhole").delay(3000).fadeOut("slow");

                    }
                    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
                    $(".rsPanelSalesOffers").removeClass("current");
                    $("#rsContent1 .rsWhatsNow").addClass("current");
                    $("#overlayRetailerShowcase").jqmShow();
                });

                $(".showRSItemTab2").click(function() {
                    resetTabCache();
                    rsOpenTab = "rsOpenTabItem2";
                    rsOpenItem = $(this).attr("rsItem");
                    if (mallId !== 'null') {
                        $('#rsAjaxTarget').empty();
                        $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48" />');
                        mallId = 'null';
                        $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());


                        $(".maskWhole").delay(3000).fadeOut("slow");

                    }
                    $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
                    $(".rsPanelNewsEvents").removeClass("current");
                    $("#rsContent2 .rsWhatsNow").addClass("current");
                    $("#overlayRetailerShowcase").jqmShow();

                });

                if ($(this).hasClass('resizable')) {
                    if ($(this).find('.slidePodImg').length > 0) {
                        $('.slidePodImg img').load(function() {
                            sliderResize();
                        });
                    } else {
                        sliderResize();
                    }
                }

                if ($(this).width() < 570 && $(this).parent('.simonSlideContentHolder').width() > 230) {
                    $(this).parent().siblings('.simonSlideLeft').css('border', 'none');
                    $(this).parent().siblings('.simonSlideLeft').children('a').hide();
                    $(this).parent().siblings('.simonSlideRight').css('border', 'none');
                    $(this).parent().siblings('.simonSlideRight').children('a').hide();
                    $(this).children(':last').css('background', 'none');
                }

                setTimeout('centerCards()', 100);

                if ($(this).children('.simonSlidePod2').length > 0 && $(this).children('.simonSlidePod').length == 0 && $(this).parent().parent().parent().siblings('.podATop').children().children('.AdminEditLink').length == 0) {
                    $(this).parent().parent().parent().parent('.podA').hide();
                }
            });
        });

        $(".showRSItemTab3").click(function() {
            rsOpenTab = "rsOpenTabItem3";
            rsOpenItem = $(this).attr("rsItem");
            if (mallId !== 'null') {
                $('#rsAjaxTarget').empty();
                $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48" />');
                mallId = 'null';
                $('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
                $(".maskWhole").delay(3000).fadeOut("slow");
            }
            $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");

            $("#overlayRetailerShowcase").jqmShow();

        });




        $(".btnSimonSlideRight").click(function() {
            var currClicked = $(this);
            var widthDiff = $(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").width() - $(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").width();
            if (-$(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").position().left + 1 < widthDiff && $(currClicked).hasClass("enabled")) {
                $(currClicked).removeClass("enabled");
                var currCountLoc = $(this).closest(".simonSlideRight").siblings(".simonSlidePodCount");
                var currCount = currCountLoc.text();
                var nextPodWidth = $(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").children("div").eq(currCount).innerWidth() + 1;
                $(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").animate({ "left": "-=" + nextPodWidth + "px" }, "slow", function() {
                    $(currClicked).addClass("enabled");
                });
                currCount = (currCount * 1) + 1;
                currCountLoc.text(currCount);
            } else {
                $(currClicked).removeClass("enabled");
                $(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").animate({ "left": "0px" }, "slow", function() {
                    $(currClicked).addClass("enabled");
                });
                $(this).closest(".simonSlideRight").siblings(".simonSlidePodCount").text('0');
            }
        });

        $(".btnSimonSlideLeft").click(function() {
            var currClicked = $(this);
            if ($(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").position().left < 0 && $(currClicked).hasClass("enabled")) {
                $(currClicked).removeClass("enabled");


                var currCountLoc = $(this).closest(".simonSlideLeft").siblings(".simonSlidePodCount");
                var currCount = currCountLoc.text();
                var nextPodWidth = $(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").children("div").eq(currCount - 1).width() + 1;
                $(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").animate({ "left": "+=" + nextPodWidth + "px" }, "slow", function() {
                    $(currClicked).addClass("enabled");
                });
                currCount = (currCount * 1) - 1;
                currCountLoc.text(currCount);
            } else {
                $(currClicked).removeClass("enabled");
                var podWidth = 0;
                var containerWidthCount = $(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").children(".simonSlidePod").length;
                if ($(this).closest(".simonSlideLeft").parent("#orderBuildCard").length > 0) {
                    containerWidthCount = containerWidthCount - 1;
                } else {
                    containerWidthCount = containerWidthCount - 4;
                }
                for (i = 0; i < containerWidthCount; i++) {
                    podWidth = podWidth + 1 + $(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").children(".simonSlidePod").eq(i).width();
                }
                $(this).closest(".simonSlideLeft").siblings(".simonSlideContentHolder").children(".simonSlideContent").animate({ "left": "-" + podWidth + "px" }, "slow", function() {
                    $(currClicked).addClass("enabled");
                });
                $(this).closest(".simonSlideLeft").siblings(".simonSlidePodCount").text(containerWidthCount);
            }
        });

        function InitHorizSlider(index) {
            if (index > 0) {
                var contentHolder = $(".simonSlideContentHolder");
                var nextPodWidth = contentHolder.children(".simonSlideContent").children("div").eq(index).width() + 1;
                contentHolder.children(".simonSlideContent").css({ "left": "-" + (nextPodWidth * index) + "px" });
                var currCountLoc = $(".simonSlideRight").siblings(".simonSlidePodCount");
                currCountLoc.text(index);
            }
        }
    }

    if ($(".simonSlideContentVert").length > 0) {
        $(".simonSlideContentVert").each(function() {
            var ajaxLink = $(this).attr("ajaxLink");
            $(this).load(ajaxLink, function() {
                /* For giftcard slider to initialize */
                var initIndex = $("input[type=hidden][id*=sliderIndex]").val();
                if (initIndex != 'undefined') {
                    InitVertSlider(initIndex);
                }
                /*if($(this).height() < 470){*/
                var verticalHeight = $(this).height();
                var verticalContainerHeight = $(".simonSlideContentHolderVert").height();
                if (verticalHeight <= verticalContainerHeight) {
                    $(this).parent().siblings('.simonSlideTop').css({
                        'border': 'none',
                        'background': 'url(/images/global/slider-border-vert.png) left bottom repeat-x'
                    });
                    $(this).parent().siblings('.simonSlideTop').children('a').hide();
                    $(this).parent().siblings('.simonSlideBottom').css({
                        'border': 'none',
                        'background': 'url(/images/global/slider-border-vert.png) left top repeat-x'
                    });
                    $(this).parent().siblings('.simonSlideBottom').children('a').hide();
                    $(this).children(':last').css('background', 'none');
                }
            });
        });

        $(".btnSimonSlideBottom").click(function() {
            var widthDiff = $(this).parent(".simonSlideBottom").siblings(".simonSlideContentHolderVert").children(".simonSlideContentVert").height() - $(this).parent(".simonSlideBottom").siblings(".simonSlideContentHolderVert").height();
            if (-$(this).parent(".simonSlideBottom").siblings(".simonSlideContentHolderVert").children(".simonSlideContentVert").position().top + 1 < widthDiff) {
                $(this).parent(".simonSlideBottom").siblings(".simonSlideContentHolderVert").children(".simonSlideContentVert").animate({ "top": "-=155px" }, "slow");
            }
        });

        $(".btnSimonSlideTop").click(function() {
            if ($(this).parent(".simonSlideTop").siblings(".simonSlideContentHolderVert").children(".simonSlideContentVert").position().top < 0) {
                $(this).parent(".simonSlideTop").siblings(".simonSlideContentHolderVert").children(".simonSlideContentVert").animate({ "top": "+=155px" }, "slow");
            }
        });

        function InitVertSlider(index) {
            if (index > 0) {
                var contentHolder = $(".simonSlideContentHolderVert");
                var nextPodWidth = contentHolder.children(".simonSlideContentVert").children("div").eq(index).height() + 1;
                contentHolder.children(".simonSlideContentVert").animate({ "top": "-=" + (nextPodWidth * index) + "px" }, "slow");
                var currCountLoc = $(".simonSlideRight").siblings(".simonSlidePodCount");
                currCountLoc.text(index);
            }
        }
    }

    if (gup('rsc') === '1') {
        $(".maskWhole").delay(3600).fadeOut("slow");
        if ($('#newspod').length < 1) {
            $('#rsTab2').hide();
        } else {
            $('#rsTab2').show();
        }
        $('#overlayRetailerShowcase').jqmShow();

    }


    if (gup('tab') !== '' && gup('rsItem') !== '') {
        resetTabCache();
        $("#overlayRetailerShowcase").jqmShow();
        rsOpenTab = "rsOpenTabItem" + gup('tab');
        rsOpenItem = gup('rsItem');
    }

    //    if (archivedEventID !== 'null') {
    //        $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
    //        $(".maskWhole").delay(3600).fadeOut("slow");
    //        $("#overlayRetailerShowcase").jqmShow();
    //        $('#rsAjaxTarget').load('/ajax/overlay/getoverlaycontent.ashx?id=' + urlParamID, function() {
    //            $('.rsSect2BottomViewAllNewsEvents').hide();
    //            $('.rsSect2BottomPrevious').hide();
    //            $('.rsSect2BottomNext').hide();
    //            $('#rsTab1').hide();
    //            $('#overlayRetailerShowcase').append('<div id="navCoverPanels" style="position:absolute; z-index:1000; top:147px; left:9px; width:90px; height:474px;"></div>');
    //            //$("#rsTab2").trigger("click");
    //            doTabTwoClick();
    //            $.ajax({
    //                url: '/ajax/overlay/getoverlayitems.ashx?type=2&output=3&eid=' + archivedEventID,
    //                cache: true,
    //                success: function(html) {
    //                    $('#rsContent2 .rsSect2Content').append(html);
    //                    $('.rscLoading').fadeOut('slow', function() {
    //                        numCont2Offers = $("#rsContent2 .rsSect2Offer").length;
    //                        $("#rsContent2 .rsSect2Content").width(numCont2Offers * 630 + "px");
    //                        $('#rsContent2 .rsSect2Content').addClass('contentLoaded');
    //                        doTrackingCont2();
    //                    });
    //                }
    //            });
    //        });
    //    }

});


/* sIFR CONFIGURATION
---------------------------------------------------	*/

/*****************************************************************************
It is adviced to place the sIFR JavaScript calls in this file, keeping it
separate from the `sifr.js` file. That way, you can easily swap the `sifr.js`
file for a new version, while keeping the configuration.

You must load this file *after* loading `sifr.js`.

That said, you're of course free to merge the JavaScript files. Just make sure
the copyright statement in `sifr.js` is kept intact.
*****************************************************************************/

// Make an object pointing to the location of the Flash movie on your web server.
// Try using the font name as the variable name, makes it easy to remember which
// object you're using. As an example in this file, we'll use Futura.
var gothamMedium = { src: '/swf/gotham-medium.swf' };
var gothamBook = { src: '/swf/gotham-book.swf' };

// Now you can set some configuration settings.
// See also <http://wiki.novemberborn.net/sifr3/JavaScript+Configuration>.
// One setting you probably want to use is `sIFR.useStyleCheck`. Before you do that,
// read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad>.

// sIFR.useStyleCheck = true;

// Next, activate sIFR:
sIFR.activate(gothamMedium, gothamBook);

// If you want, you can use multiple movies, like so:
//
//		 var futura = { src: '/path/to/futura.swf' };
//		 var garamond = { src '/path/to/garamond.swf' };
//		 var rockwell = { src: '/path/to/rockwell.swf' };
//		 
//		 sIFR.activate(futura, garamond, rockwell);
//
// Remember, there must be *only one* `sIFR.activate()`!

// Now we can do the replacements. You can do as many as you like, but just
// as an example, we'll replace all `<h1>` elements with the Futura movie.
// 
// The first argument to `sIFR.replace` is the `futura` object we created earlier.
// The second argument is another object, on which you can specify a number of
// parameters or "keyword arguemnts". For the full list, see "Keyword arguments"
// under `replace(kwargs, mergeKwargs)` at 
// <http://wiki.novemberborn.net/sifr3/JavaScript+Methods>.
// 
// The first argument you see here is `selector`, which is a normal CSS selector.
// That means you can also do things like '#content h1' or 'h1.title'.
//
// The second argument determines what the Flash text looks like. The main text
// is styled via the `.sIFR-root` class. Here we've specified `background-color`
// of the entire Flash movie to be a light grey, and the `color` of the text to
// be red. Read more about styling at <http://wiki.novemberborn.net/sifr3/Styling>.
sIFR.replace(gothamMedium, {
    selector: '#mallHomeBanner h2',
    css: '.sIFR-root { color: #ffffff; }',
    transparent: 'true',
    filters: {
        DropShadow: {
            knockout: false,
            distance: 2,
            color: '#000000',
            strength: 2
        }
    }
});

sIFR.replace(gothamBook, {
    selector: '#mallHomeBanner p',
    css: '.sIFR-root { color: #000000; }',
    transparent: 'true'
});

sIFR.replace(gothamBook, {
    selector: '#topOfContent h2',
    css: '.sIFR-root { color: #221e19; }',
    transparent: 'true'
});
sIFR.replace(gothamBook, {
    selector: '#content_wLnav-R h2',
    css: '.sIFR-root { color: #221e19; }',
    transparent: 'true'
});

/* Social JS Functions */
function selectTab(tab) {
    $('.socialTab').each(function(index) {
        $(this).removeClass('socialIconSelected');
        var tabName = $(this).text().toLowerCase() + "Box";
        $("#ctl00_" + tabName).parent().hide();
    });
    $("." + tab + "icon").addClass('socialIconSelected');
    $("#ctl00_" + tab + "Box").parent().show();
}

function forceConnectionTabDisplay(tab) {
    //resetTabCache();
    //doTabThreeClick();
    //loadOverlaySocialContent(function() {
    //selectTab(tab);
    //});
}

function rsAjaxCallback() {
    if (DEBUG == true) console.log("running content callback function...");
    try {

        // Handler for .load() called.
        // non-social tabs (offers & news/events)
        removeCurrentSubNavCurrent(1);
        removeCurrentSubNavCurrent(2);
        if (typeof rsOpenTab != '') {
            // main tabs
            if (rsOpenTab == 'rsOpenTab1') {
                //$('.rsTab1').trigger('click');
                doTabOneClick();
                $('.rsPanelSalesOffers').trigger('click');
                $('.rsPanelContent1').addClass('current');
                $('#rsContent1 .rsWhatsNow').removeClass('current');
                $('#rsContent2 .rsWhatsNow').addClass('current');
                $(".rsPanelSalesOffers").addClass("current");
            }
            else if (rsOpenTab == 'rsOpenTab2') {
                //$('.rsTab2').trigger('click');
                doTabTwoClick();
                $('.rsPanelNewsEvents').trigger('click');
                //$('.rsPanelContent2').addClass('current');
                $('#rsContent1 .rsWhatsNow').addClass('current');
                $(".rsPanelSalesOffers,rsPanelNewsEvents").removeClass("current");
            }
            else if (rsOpenTab == 'rsOpenTab3') {
                $('.rsWhatsNow').addClass('current');
            }

            // sub-tabs (view details -> Whats Now)
            if (rsOpenTab == 'rsOpenTabItem1' || rsOpenTab == 'rsOpenTabItem2') {
                if (DEBUG == true) console.log("Adding current to both sub nav...");
                $(".rsWhatsNow").addClass("current");
                $(".rsPanelSalesOffers,rsPanelNewsEvents").removeClass("current");
                if (rsOpenTab == 'rsOpenTabItem1') $(".rsSect2Offer").show();
            } else {
                //$(".rsWhatsNow").removeClass("current");           
                //$(".rsPanelSalesOffers,rsPanelNewsEvents").addClass("current");
            }

            $("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
        } else {
            $(".rsPanelSalesOffers,rsPanelNewsEvents").removeClass("current");
            $(".rsWhatsNow").addClass("current");     // Make All What's Now Sub-Tabs the Current Tab
        }


        // see if from direct link
        var tabId = gup('tab');
        if (typeof tabId != 'undefined' && tabId != '') {
            rsOpenItem = gup('rsItem');
            if (typeof rsOpenItem != 'undefined' && rsOpenItem != '') {
                var prependClass = '';
                if (tabId == '1') {
                    if (rsOpenItem.indexOf('OfferItem') == -1) prependClass = 'OfferItem';
                    $("#rsContent1 .rsSect2Content").css({ "left": "-" + $("." + prependClass + rsOpenItem).position().left + "px" });
                } else if (tabId == '2') {
                    if (rsOpenItem.indexOf('OfferItem') > 0) {
                        rsOpenItem.replace('OfferItem', 'NewsEventItem');
                    }

                    if (rsOpenItem.indexOf('NewsEventItem') == -1) prependClass = 'NewsEventItem';
                    if (rsOpenItem.indexOf('OfferItem') > 0) {
                        prepentClass = "";
                    }
                    $("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + prependClass + rsOpenItem).position().left + "px" });
                }
            }
        }


    } catch (e) {
        if (DEBUG == true) console.log("rsAjaxCallback() Error: " + e.message);
    }
}

function displayOverlayLoader() {
    $('#rsAjaxTarget').empty();
    $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48" />');
}

function displayOverlayLoader() {
    $('#rsAjaxTarget').empty();
    $('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="ajax-loader-large" width="48" height="48" />');
}

function displayViewAllRsTab(rsOpenTab) {
    // reset cache and other variables here
    resetTabCache();

    if (DEBUG == true) console.log("if statement: " + rsOpenTab);
    if (rsOpenTab == 'rsOpenTab1') {
        rsOpenTab = "rsOpenTab1";
        doTabOneClick();
        $('.rsPanelSalesOffers').trigger('click');
        if ($('#rsContent1 .rsWhatsNow').hasClass('rsPanelRight') == false) {
            $('.rsPanelSalesOffers').trigger('click');
        }
    } else if (rsOpenTab == 'rsOpenTab2') {
        rsOpenTab = "rsOpenTab2";
        doTabTwoClick();
        $('.rsPanelNewsEvents').trigger('click');
        if ($('#rsContent2 .rsWhatsNow').hasClass('rsPanelRight') == false) {
            $('.rsPanelNewsEvents').trigger('click');
        }
    } else if (rsOpenTab == 'rsOpenTab3') {
        //$("#rsTab3").trigger("click");
        doTabThreeClick();
        loadOverlaySocialContent();
    }
}

function removeCurrentSubNavCurrent(subTabNum) {
    $("a[class*=rsPanelContent" + subTabNum + "]").each(function() {
        $(this).removeClass("current");
    });
}

function resetTabCache() {
    newsEventCount = -1;
    loadedTabs.length = 0;
}


