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 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');
}

/* 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;
	
	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');
	    			}
	    		});
	    	}
	    }
	});
}
	
function startRscPopulate(overlayMode,overlayModeId){
	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;
	}
	
	/* Pupulate Sales & Offers Tiles */
	$('#rsTilesContainer').load('/ajax/overlay/getoverlayitems.ashx?type=1&output=2&' + urlParamOffer + '&count=30',function(){
		$('.rscLoading').fadeOut('slow');
		rscMoreTiles();
	});
	
	/* Pupulate 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();
	    	});
	    }
	});
	
	/* Pupulate News & Events Tiles */
	function getMallNews(numMallNews){
		$.ajax({
			url: '/ajax/overlay/getoverlayitems.ashx?type=3&output=2&' + urlParamOffer + '&count=' + numMallNews,
		    cache: true,
		    success: function(html){
				$('#rsContent2 .rsSect1MiddleLeft').append(html);
		    }
		});
	}
	
	function getUpcomingEvents(numUpcomingEvents){
		$.ajax({
			url: '/ajax/overlay/getoverlayitems.ashx?type=4&output=2&' + urlParamOffer + '&count=' + numUpcomingEvents,
		    cache: true,
		    success: function(html){
				$('.rscLoading').fadeOut('slow');
				$('#rsContent2 .rsSect1MiddleRight').append(html);
		    }
		});
	}
	
	$.ajax({
		url: '/ajax/overlay/getoverlayitems.ashx?type=3&output=5&' + urlParamOffer,
	    cache: true,
	    success: function(html){
			getMallNews(html);
	    }
	});
	$.ajax({
		url: '/ajax/overlay/getoverlayitems.ashx?type=4&output=5&' + urlParamOffer,
	    cache: true,
	    success: function(html){
			getUpcomingEvents(html);
	    }
	});
	
	/* Pupulate News & Events Templates */
	function getAllNewsEventsTemplates(numAllNewsEventsTemplates){
		$.ajax({
			url: '/ajax/overlay/getoverlayitems.ashx?type=2&output=3&' + urlParamOffer + '&count=' + numAllNewsEventsTemplates,
		    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');
				});
		    }
		});
	}
	
	$.ajax({
		url: '/ajax/overlay/getoverlayitems.ashx?type=2&output=6&' + urlParamOffer,
	    cache: true,
	    success: function(html){
			getAllNewsEventsTemplates(html);
	    }
	});
}

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();
        }
    });
}

function tab1Interval(){
	
	var urlParamOffer;
			
	if(mallId !== 'null'){
	    urlParamOffer = 'id=' + mallId;
	}else{
	    urlParamOffer = 'id=' + urlParamID;
	}
	
    if($('#rsContent1 .rsSect2Content').hasClass('contentLoaded')){
    	clearInterval(interval);
    	$("#rsTab1").trigger("click");
    	if($.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9){
			$("#rsTab1").trigger("click");
			$("#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");
			$("#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);
		        }
		    });
		}
    }
}

function tab2Interval(){
    if($('#rsContent2 .rsSect2Content').hasClass('contentLoaded')){
    	clearInterval(interval);
    	$("#rsTab2").trigger("click");
    	$("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
    	opacityShift();
    	doTrackingCont2();
    	//$("#rsContent2 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
    }
}


$("#rsTab1").live("click",function() {
    if (!$(this).hasClass("current")) {
    	//$(".rsSectContainer").animate({ "left": "0px" });
    	$(".rsSectContainer").css({ "left": "0px" });
    	opacityShift();
    	$("#rsTab2").removeClass("current");
    	$(this).addClass("current");
    }
});

$("#rsTab2").live("click",function() {
    if (!$(this).hasClass("current")) {
    	//$(".rsSectContainer").animate({ "left": "-728px" });
    	$(".rsSectContainer").css({ "left": "-728px" });
    	opacityShift();
    	$("#rsTab1").removeClass("current");
    	$(this).addClass("current");
    }
});

/* 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){
		urchinTracker(urchVar);
		console.log(urchVar);
	}
}

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){
		urchinTracker(urchVar);
		console.log(urchVar);
	}
}
/* Urchin Tracking - End */

$("#rsContent1 .rsSect2BottomNext").live("click",function() {
    var currClicked = $(this);
    if($(currClicked).hasClass("enabled")){
    	$(currClicked).removeClass("enabled");
    	
    	if (-$("#rsContent1 .rsSect2Content").position().left < (numCont1Offers * 630) - 630) {
    		/*$(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;
    		}
    		
    		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");
    	
    	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");
    							});
    					    }
    					});
    				});
    			//});
    		}
    	}
    }
});

$("#rsContent2 .rsSect2BottomNext").live("click",function() {
    var currClicked = $(this);
    if($(currClicked).hasClass("enabled")){
    	$(currClicked).removeClass("enabled");
    	
    	if (-$("#rsContent2 .rsSect2Content").position().left < (numCont2Offers * 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");
    		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");
    		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");
    		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");
    		doTrackingCont2();
    	}
    }
});

$('.rsSect2BottomViewAllOffers').live('click',function(){
	$("#rsContent1 .rsWhatsNow").css({ "left": "674px" });
	$("#rsContent1 .rsWhatsNow").addClass("rsPanelRight");
	$("#rsContent1 .rsSect2").css({ "left": "709px" });
	opacityShift();
});

$('.rsSect2BottomViewAllNewsEvents').live('click',function(){
	$("#rsContent2 .rsWhatsNow").css({ "left": "674px" });
	$("#rsContent2 .rsWhatsNow").addClass("rsPanelRight");
	$("#rsContent2 .rsSect2").css({ "left": "709px" });
	opacityShift();
});

function rsActivate() {
    if (rsOpenTab == null) {
        return;
    }  else if (rsOpenTab === "rsOpenTab1") {
		$("#rsTab1").trigger("click");
	} else if (rsOpenTab === "rsOpenTab2") {
		$("#rsTab2").trigger("click");
		doTrackingCont2();
	} else if (rsOpenTab === "rsOpenTabItem1") {
		if($("#rsContent1 .rsSect2Offer").length > 0 && $.trim($('#rsContent1 .rsSect2Content .rsSect2Offer:last .offerItemTotal').text()) <= 9){
			$("#rsTab1").trigger("click");
			//$("#rsContent1 .rsSect2Content").animate({ "left": "-" + $("." + rsOpenItem).position().left + "px" }, "slow");
			$("#rsContent1 .rsSect2Content").css({ "left": "-" + $("." + rsOpenItem).position().left + "px" });
			doTrackingCont1();
		}else{
			interval = setInterval('tab1Interval()',500);
		}
	} else if (rsOpenTab === "rsOpenTabItem2") {
		if($("#rsContent2 .rsSect2Offer").length > 0){
			$("#rsTab2").trigger("click");
			//$("#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() {
	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="" 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 ($("#rsAjaxTarget .ajaxLoaderLarge").length > 0 && 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();
			    }
			});
		});
	} 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="" width="48" height="48"/>');
	}
	if(archivedEventID !== 'null'){
		archivedEventID = 'null';
		$('#rsAjaxTarget').empty();
		$('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="" 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");
	$("#overlayRetailerShowcase").jqmShow();
}

function rsTab2Call() {
	rsOpenTab = "rsOpenTab2";
	$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
	$("#overlayRetailerShowcase").jqmShow();
}

$(".aShift").live("click",function() {
    var currClicked = $(this);
    if ($(currClicked).siblings(".rsNoScroll").position().top == 0 && $(currClicked).hasClass("enabled")) {
    	$(currClicked).removeClass("enabled");
    	$(currClicked).siblings(".rsNoScroll").animate({ "top": "-374px" }, "slow");
    	$(currClicked).siblings(".rsScroll").animate({ "top": "0px" }, "slow", function() {
    		$(currClicked).css('background-position','left bottom');
    		opacityShift();
    		$(currClicked).addClass("enabled");
    	});
    } else if ($(currClicked).siblings(".rsScroll").position().top == 0 && $(currClicked).hasClass("enabled")) {
    	$(currClicked).removeClass("enabled");
    	$(currClicked).siblings(".rsNoScroll").animate({ "top": "0px" }, "slow");
    	$(currClicked).siblings(".rsScroll").animate({ "top": "374px" }, "slow", function() {
    		$(currClicked).css('background-position','left top');
    		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" });
    	opacityShift();
    	doTrackingCont1();
    }else{
    	goToMainOffer($('.rsPromoTile').index(this));
    }
});

$(".aMoreNewsEvents").live("click",function() {
    $("#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");
    $("#rsContent2 .rsSect2Content").css({ "left": "-" + $("." + $(this).attr("rsItem")).position().left + "px" });
    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");
		}
	});

	$(".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").click(function() {
		if ($(this).siblings(".podBSlideContent").css("display") === "none") {
			$(this).css("background-position", "-1099px bottom");
			$(this).siblings(".podBSlideContent").slideDown("slow");
		} else {
			$(this).css("background-position", "-1099px top");
			$(this).siblings(".podBSlideContent").slideUp("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() {
		if ($(this).attr("value") === "Keyword Search") {
			$(this).attr("value", "");
		}
	});
	$(".hideValueKeyword").blur(function() {
		if ($(this).attr("value") === "") {
			$(this).attr("value", "Keyword Search");
		}
	});
	
	$(".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();
	});
	
	/*	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'){
			$('#rsAjaxTarget').empty();
			$('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="" width="48" height="48"/>');
			mallId = 'null';
			$('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
		}
		$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
		$("#overlayRetailerShowcase").jqmShow();
	});
	
	$('.simonSlidePod2 .slidePodImg').live('click',function(){
		if(mallId !== 'null'){
			$('#rsAjaxTarget').empty();
			$('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="" width="48" height="48"/>');
			mallId = 'null';
			$('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
		}
		$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
		$("#overlayRetailerShowcase").jqmShow();
	});

	$(".btnCloseRS").click(function() {
		$("#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();
			rsOpenTab = 'rsOpenTab1';
			$('#overlayRetailerShowcase .rsTitle span').text($('#rscFindMallNames option:selected').text());
			rsAjaxCall();
		}
	});
	
	$('#rscFindMallNames option').live('dblclick',function(){
		mallId = $('#rscFindMallNames option:selected').val();
		rsOpenTab = 'rsOpenTab1';
		$('#overlayRetailerShowcase .rsTitle span').text($('#rscFindMallNames option:selected').text());
		rsAjaxCall();
	});
	
	$(".rsPanelContent1").live("click",function() {
		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 ($("#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();
	});


	/*	Porperty 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="" 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();
		});

		$(".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(".propResultsSub2").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).children(".propResultsSubMap").css("display", "none");
						$(this).css({
							"top": "0px",
							"left": "0px",
							"position": "relative",
							"display": "none"
						});
						currMallLink.parent().parent().addClass("open");

						$(this).slideDown("slow", function() {
							$(this).children(".propResultsSubMap").fadeIn("slow");
						});

						//$(this).css("display", "block");
						//$(this).children(".propResultsSubMap").css("display", "block");

					});
				} else {
					$(this).parent().parent().next().children(".propResultsSub2").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).children(".propResultsSubMap").fadeIn("slow");
					});
				}
			} else {
				$(this).parent().parent().removeClass("open");
				$(this).parent().parent().next().children(".propResultsSub2").children(".propResultsSubMap").fadeOut("slow", function() {
					$(this).parent(".propResultsSub2").slideUp("slow");
				});
			}
		});

		/* 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");

	$(".liCatHead a").click(function() {
		if (!$(this).hasClass("open")) {
			$(this).addClass("open");
			$(this).parent(".liCatHead").children("div").slideDown("slow");
		} else {
			$(this).removeClass("open");
			$(this).parent(".liCatHead").children("div").slideUp("slow");
		}
	});

	/* 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).width() + 1;
					slideWidth = slideWidth + 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() {
					rsOpenTab = "rsOpenTabItem1";
					rsOpenItem = $(this).attr("rsItem");
					if(mallId !== 'null'){
						$('#rsAjaxTarget').empty();
						$('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="" width="48" height="48"/>');
						mallId = 'null';
						$('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
					}
					$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
					$("#overlayRetailerShowcase").jqmShow();
				});

				$(".showRSItemTab2").click(function() {
					rsOpenTab = "rsOpenTabItem2";
					rsOpenItem = $(this).attr("rsItem");
					if(mallId !== 'null'){
						$('#rsAjaxTarget').empty();
						$('#rsAjaxTarget').append('<img class="ajaxLoaderLarge" src="/images/global/ajax-loader-large.gif" alt="" width="48" height="48"/>');
						mallId = 'null';
						$('#overlayRetailerShowcase .rsTitle span').text($('h2 span').text());
					}
					$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
					$("#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();
		    	}
			});
		});

		$(".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).width() + 1;
				$(this).closest(".simonSlideRight").siblings(".simonSlideContentHolder").children(".simonSlideContent").animate({ "left": "-=" + nextPodWidth + "px" }, "slow", function() {
					$(currClicked).addClass("enabled"); /// <reference path="file:///C:\Windows\TEMP\qao49v4a.bmp" />
				});
				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){
		    		$(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'){
		$('#overlayRetailerShowcase').jqmShow();
	}
	
	if(gup('tab') !== '' && gup('rsItem') !== ''){
		if(gup('tab') === '1'){
			rsOpenTab = "rsOpenTabItem1";
			rsOpenItem = gup('rsItem');
			$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
			$("#overlayRetailerShowcase").jqmShow();
		}else if(gup('tab') === '2'){
			rsOpenTab = "rsOpenTabItem2";
			rsOpenItem = gup('rsItem');
			$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
			$("#overlayRetailerShowcase").jqmShow();
		}
	}
	
	if(archivedEventID !== 'null'){
		$("#overlayRetailerShowcase").css("top", $(window).scrollTop() + "px");
		$("#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");
			$.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'
});

