





/* HomewidgetController */


/* FtumessagingController */


/* Edp_LightboxController */
Object.extend(Element,{
		setHeight: function(element,h){
			elm = $(element);
			elm.style.height = h + 'px';
		},
		setWidth: function(element,w){
			elm = $(element);
			elm.style.width = w + 'px';
		},
		setInnerHTML: function(element,c){
			elm = $(element);
			elm.innerHTML = c;
		},
		setTop: function(element,t){
			elm = $(element);
			elm.style.top = t;
		},
		setLeft: function(element,l){
			elm = $(element);
			elm.style.left = l;
		},
		setVisible: function(element,o){
			elm = $(element);
			elm.style.visibility = o;
		},
		getOffsetHeight: function(element){
			elm = $(element);
			return elm.offsetHeight;
		},
		getOffsetWidth: function(element){
			elm = $(element);
			return elm.offsetWidth;
		}
});


var Overlay = Class.create();

Overlay.prototype = {
	initialize: function() {	
		this.options = Object.extend({
			opacity:	0.8,
			duration:	0.2
		},arguments[1] || {});
		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
	},
	
	start: function(topOffset) {	

		hideSelectBoxes();
		hideFlash();

		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);
		
		new Effect.Appear('overlay', { duration: this.options.duration, from: 0.0, to: this.options.opacity });
		
		var arrScrollPos = getPageScroll();
		var iOffHeight = Element.getHeight('divbox');
		var iOffWidth = Element.getWidth('divbox');
		var sLeft = parseInt(arrScrollPos[0]) + parseInt(arrayPageSize[2]/2) - parseInt(iOffWidth/2) + "px";
		if(sLeft < 0){
			sLeft=0;
		}
		if(topOffset != undefined){
			var sTop = parseInt(topOffset) - parseInt(iOffHeight/1.3);
			sTop = sTop + "px";		
		}else{
			var sTop = parseInt(arrayPageSize[1]/2) - parseInt(iOffHeight/1.3) + "px";
		}		
		Element.setTop('divbox',sTop);			
		Element.setLeft('divbox',sLeft);
		Element.show('divbox');
	},
	
	addElm: function(e){
		var objBody = document.getElementsByTagName("body").item(0);
		objBody.appendChild(e);
	},	
	end: function() {
		Element.hide('divbox');
		new Effect.Fade('overlay', { duration: this.options.duration});
		showSelectBoxes();
		showFlash();
	}
}


var LeftOverlay = Class.create();

LeftOverlay.prototype = {
	initialize: function() {	
		this.options = Object.extend({
			opacity:	0.8,
			duration:	0.2
		},arguments[1] || {});
		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
	},
	
	start: function(topOffset) {	

		hideSelectBoxes();
		hideFlash();

		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[4]);
		Element.setHeight('overlay', arrayPageSize[1]);
		
		new Effect.Appear('overlay', { duration: this.options.duration, from: 0.0, to: this.options.opacity });
		
		var arrScrollPos = getPageScroll();
		var iOffHeight = Element.getHeight('divbox');
		if(topOffset != undefined){
			var sTop = parseInt(topOffset) - parseInt(iOffHeight/1.3);
			
			sTop = sTop + "px";		
		}else{
			var intTop = parseInt(arrayPageSize[3]/2) - parseInt(iOffHeight/2);
			if(intTop < 10){
				intTop = 100;
			}
			var sTop = intTop + "px";

		}		
		Element.setTop('divbox',sTop);			
		Element.show('divbox');
	},
	
	addElm: function(e){
		var objBody = document.getElementsByTagName("body").item(0);
		objBody.appendChild(e);
	},
	
	end: function() {
		Element.hide('divbox');
		new Effect.Fade('overlay', { duration: this.options.duration});
		showSelectBoxes();
		showFlash();
	}
}


function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight) {
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,screen.width,screen.height);
	return arrayPageSize;
}

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}

function addReminderLB(merchantId,curRow,merchname) {
	$('reminderLBConfirm').innerHTML= 'Reminder for '+ merchname+' has been added.';
	$('reminderLBConfirm').style.display="block";
    new Ajax.Request("/popularreminders/add/merchantId/" + merchantId, 
                   {method: 'post',
                   	params:{uSource:'HRB'},
                   	onLoading:$('rlist'+curRow).src='http://imga.nxjimg.com/secured/image/f08/home/rightside/loading.gif',
                    onSuccess:$('rlist'+curRow).src='http://imga.nxjimg.com/secured/image/09/sENV_confirm.gif'});
}
function killOverlay(){
	myOverlay.end();
	$('divbox').innerHTML='';
}


/* FirstTime STW*/

function killOverlay_stw() {
	$('stwContainer').style.display = 'none';
}

function killOverlay_autoenroll() {
		$('UpgradeContainer').style.display = 'none';
}

/* Edp_FooterController */
function Set_Cookie( name, value, expires, path, domain, secure )
{
    var today = new Date();
    today.setTime( today.getTime() );

    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }

    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie = name + "=" +escape( value ) +
                      (( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
                      (( path ) ? ";path=" + path : "" ) +
                      (( domain ) ? ";domain=" + domain : "" ) +
                      (( secure ) ? ";secure" : "" );
}
function on(e){
	e.src = e.src.replace(/_off./,'_on.');
}
function off(e){
	e.src = e.src.replace(/_on./,'_off.');
}
function on_id(id) {
	e = document.getElementById(id);
	e.src = e.src.replace(/_off./,'_on.');
}
function off_id(id) {
	e = document.getElementById(id);
	e.src = e.src.replace(/_on./,'_off.');
}
function setBookmark (url,str){
	if(str=='')str=url;
	if(document.all)window.external.AddFavorite(url,str);
	else alert('To add '+str+' to your bookmarks, press CTRL and D.');
}
function showHide(elementID){
	var divElement = $(elementID);
	if(divElement.style.display == "none"){
		divElement.style.display="block";
	}else{
		divElement.style.display="none";
	}
}
function imageLoader(){
	leftButtonImage = new Image();
	rightButtonImage = new Image();
	leftButtonImage.src = 'http://imga.nxjimg.com/emp_image/button_left_on.gif';
	rightButtonImage.src = 'http://imga.nxjimg.com/emp_image/button_right_on.gif';
}
function showHideDelay(divID){
	if($(divID).style.display=='none'){
		var divObj = $(divID);
		setTimeout(function(){divObj.style.display='block';},100,null,divObj);
	}else{
		$(divID).style.display='none';
	}
}
function showHideZIndexSwap(eId){
	var divElement = $(eId);
	var footerElement = $('footer');
	if(divElement.style.display == "none"){
		footerElement.style.zIndex = "3";
		divElement.style.display="block";
	}else{
		footerElement.style.zIndex = "0";
		divElement.style.display="none";
	}
}

/* EDP_CartController */
var starAdvDoLightStars = true;

function leaderboardTrophy(){	
	if ($('trophy')){	
		for (var i = 1; i < 5; i++){			
			setTimeout("$('trophy').src = 'https://imga.corporateperks.com/emp_image/UserRank/trophyani_"+i+".gif'",i*400);			
		}
	}
}


function starAdvLightStar(which)
{
	var maxBumpHeight = 10;
	var marginTops = [];
	marginTops[0] = 0;
	marginTops[1] = -0.31;
	marginTops[2] = -0.59;
	marginTops[3] = -0.81;
	marginTops[4] = -0.95;
	marginTops[5] = -1;
	marginTops[6] = -0.95;
	marginTops[7] = -0.81;
	marginTops[8] = -0.59;
	marginTops[9] = -0.31;
	marginTops[10] = 0;
	
	$('starAdvReadoutStar'+which).style.visibility = "visible";
	
	for (var i = 1; i < marginTops.length; i++)
		setTimeout("$('starAdvReadoutStar"+which+"').style.marginTop = '"+(marginTops[i]*maxBumpHeight)+"px';",i*40);
}

var counterDigits = [];
var oldCounterDigits;

function resetCounterTo(num,whichCounter) {
	if (whichCounter == 'ptsTickerDigit')
	{
		var i = 0;
		var localCounterDigits = [];
		if (num != null)
		{
			if (num == 0)
				localCounterDigits[0] = 0;
			else
			{
				while(num > 0) {
					var digit = num % 10;
					localCounterDigits[i] = digit;
					i = i + 1;
					num = num / 10;
					num = Math.floor(num);
				}
			}
		}
		
		var numDigits = 7;
		for (var i = 1; i <= numDigits; i++)
		{
			if ((numDigits-i) < localCounterDigits.length)
			{
				if (i == 1 || i == 4)
					changeBackgroundPosition('ptsTickerDigit'+i,(-23.4*(localCounterDigits[numDigits-i]+1)),'-118');
				else
					changeBackgroundPosition('ptsTickerDigit'+i,(-23.4*(localCounterDigits[numDigits-i]+1)),'-0');
			}
			else
				changeBackgroundPosition('ptsTickerDigit'+i,'0','0');
		}
	}
}

function spinCounter(num,whichCounter) {
	if ($(whichCounter+'1') == null)
		return;	// assume if first digit absent, then counter doesn't exist
		
	var i = 0;
	var localCounterDigits = [];
	if (num == 0)
		localCounterDigits[0] = 0;
	else
	{
		while(num > 0) {
			var digit = num % 10;
			localCounterDigits[i] = digit;
			i = i + 1;
			num = num / 10;
			num = Math.floor(num);
		}
	}

	if (whichCounter == 'cartCounterDigit')
	{
		var numDigits = 6;
		for(i = 0; i < localCounterDigits.length ; ++i) {
			if (i > 0 && i % 3 == 0)
				setDigitAtPositionWithComma(numDigits, localCounterDigits[i], 0, whichCounter);
			else 
				setDigitAtPosition(numDigits, localCounterDigits[i], 0, whichCounter);
			numDigits = numDigits - 1;
		}
		
		for(numDigits ; numDigits >= 1 ; --numDigits) {
			if($(whichCounter+numDigits).style.backgroundPosition != '0px 0px' && $(whichCounter+numDigits).style.backgroundPosition != '') {
				resetDigitAtPosition(numDigits, whichCounter);
			}
		}
	}
	if (whichCounter == 'ptsTickerDigit')
	{
/*
		oldCounterDigits = [];
		for (i = 0; i < counterDigits.length; i++)
			oldCounterDigits[i] = counterDigits[i];
			
		counterDigits = [];
		for (i = 0; i < localCounterDigits.length; i++)
			counterDigits[i] = localCounterDigits[i];
			
		var numDigits = 7;
		setDigitAtPosition(numDigits, counterDigits[0], (oldCounterDigits.length >= 1)? oldCounterDigits[0] : null, 'ptsTickerDigit');
*/
		var numDigits = 7;
		var step = 125;
		for (var nextDigitToStop = numDigits, i = 0, f = 0; nextDigitToStop >= 1; i = (i+1)%11, f++)
		{
			var decNextDigitToStopAfterThisTurn = false;
			
			for (var g = nextDigitToStop; g >= 1; g--)
			{
				setTimeout("changeBackgroundPosition('ptsTickerDigit"+g+"',"+(-23.4*i)+",'-39')", f*step + (1/4)*step);
				setTimeout("changeBackgroundPosition('ptsTickerDigit"+g+"',"+(-23.4*i)+",'-78')", f*step + (3/4)*step);
				
				if ((numDigits-g) < localCounterDigits.length)
					var destIndex = localCounterDigits[numDigits-g]+1;
				else
					var destIndex = 0;
					
				if (g == nextDigitToStop && ((i+1)%11) == destIndex)
				{
					if (destIndex == 0)
						nextDigitToStop--;
					else
						decNextDigitToStopAfterThisTurn = true;
					
					if (g == 1 || g == 4)
						setTimeout("changeBackgroundPosition('ptsTickerDigit"+g+"',"+(-23.4*((i+1)%11))+","+((destIndex==0)?'-0':'-118')+")", f*step + step);
					else
						setTimeout("changeBackgroundPosition('ptsTickerDigit"+g+"',"+(-23.4*((i+1)%11))+",'-0')", f*step + step);
				}
			}
			
			if (decNextDigitToStopAfterThisTurn)
				nextDigitToStop--;
		}
		
		setTimeout("starAdvLightStars()", f*step);
		setTimeout("leaderboardTrophy()", ((f*step)+(5*400)));
	}
	if (whichCounter == 'ooTickerDigit')
	{
		var numDigits = 7;
		var step = 125;
		for (var nextDigitToStop = numDigits, i = 0, f = 0; nextDigitToStop >= 1; i = (i+1)%11, f++)
		{
			var decNextDigitToStopAfterThisTurn = false;
			
			for (var g = nextDigitToStop; g >= 1; g--)
			{
				setTimeout("changeBackgroundPosition('ooTickerDigit"+g+"',"+(-31*i)+",'-52')", f*step + (1/4)*step);
				setTimeout("changeBackgroundPosition('ooTickerDigit"+g+"',"+(-31*i)+",'-104')", f*step + (3/4)*step);
				
				if ((numDigits-g) < localCounterDigits.length)
					var destIndex = localCounterDigits[numDigits-g]+1;
				else
					var destIndex = 0;
					
				if (g == nextDigitToStop && ((i+1)%11) == destIndex)
				{
					if (destIndex == 0)
						nextDigitToStop--;
					else
						decNextDigitToStopAfterThisTurn = true;
					
					if (g == 1 || g == 4)
						setTimeout("changeBackgroundPosition('ooTickerDigit"+g+"',"+(-31*((i+1)%11))+","+((destIndex==0)?'-0':'-156')+")", f*step + step);
					else
						setTimeout("changeBackgroundPosition('ooTickerDigit"+g+"',"+(-31*((i+1)%11))+",'-0')", f*step + step);
				}
			}
			
			if (decNextDigitToStopAfterThisTurn)
				nextDigitToStop--;
		}
	}
}

function resetCounter(whichCounter) {
	var step = 125;
	var increment = 1;
	var spacing = 0.25;
	if (whichCounter == 'cartCounterDigit')
	{
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit1','0','-52'); }, 1*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit1','0','-104'); }, (1+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit1','0','0'); }, (1+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit2','0','-52'); }, (1+spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit2','0','-104'); }, ((1+spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit2','0','0'); }, ((1+spacing)+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit3','0','-52'); }, (1+2*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit3','0','-104'); }, ((1+2*spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit3','0','0'); }, ((1+2*spacing)+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit4','0','-52'); }, (1+3*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit4','0','-104'); }, ((1+3*spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit4','0','0'); }, ((1+3*spacing)+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit5','0','-52'); }, (1+4*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit5','0','-104'); }, ((1+4*spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit5','0','0'); }, ((1+4*spacing)+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit6','0','-52'); }, (1+5*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit6','0','-104'); }, ((1+5*spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit6','0','0'); }, ((1+5*spacing)+2*increment)*step);
	}
	else
	{
		var numDigits = 7;
		starAdvDoLightStars = false;
		resetDigitAtPosition(numDigits, 'ptsTickerDigit');
		starAdvDoLightStars = true;
		
		counterDigits = [];
		oldCounterDigits = [];
	}
}

function resetDigitAtPosition(pos, whichCounter) {
	var step = 125;
	var increment = 1;
	var spacing = 0.25;
	if (whichCounter == 'cartCounterDigit')
	{
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-52'); }, (1+(pos-1)*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-104'); }, ((1+(pos-1)*spacing)+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','0'); }, ((1+(pos-1)*spacing)+2*increment)*step);
	}
	else
	{
		changeBackgroundPosition('ptsTickerDigit'+pos,'0','0');
		
		if (--pos >= 1)
			resetDigitAtPosition(pos, 'ptsTickerDigit');
		else
			starAdvLightStars();
	}
}

function setDigitAtPosition(pos, num, oldNum, whichCounter) {
	var step = 125;
	if (whichCounter == 'cartCounterDigit')
	{
		var increment = 1;
		var spacing = 0.25;
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-52'); }, (1+(pos-1)*spacing)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-104'); }, ((1+(pos-1)*spacing) + increment)*step);
		for(var i = 0; i <= num; ++i) {
			var f1 = function(y) { return function() { changeBackgroundPosition('cartCounterDigit' + pos,-31*(y+1),'-52'); } }(i);
			var f2 = function(y) { return function() { changeBackgroundPosition('cartCounterDigit' + pos,-31*(y+1),'0'); } }(i);
			setTimeout(f1, ((1+(pos-1)*spacing)+(2*i+2)*increment)*step);
			setTimeout(f2, ((1+(pos-1)*spacing)+(2*i+3)*increment)*step);
		}
		if(num == 0) {
			setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,-31,'-52'); }, ((1+(pos-1)*spacing)+2*increment)*step);
			setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,-31,'0'); }, ((1+(pos-1)*spacing)+3*increment)*step);
		}
	}
	else
	{
		for (var i = (oldNum == null)? 0 : oldNum+1, f = 0; i != (num+1); i = (i+1)%11, f++)
		{
			var f1 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*y,'-39'); } }(i);
			var f2 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*y,'-78'); } }(i);
			var f3 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*((y+1)%11),'0'); } }(i);
			setTimeout(f1, f*step + (1/4)*step);
			setTimeout(f2, f*step + (3/4)*step);
			setTimeout(f3, f*step + step);
		}
		
		var newPos = pos-1;
		if (newPos >= 1)
		{
			if ((7-newPos) < counterDigits.length)
			{
				var oldDigit = ((7-newPos) < oldCounterDigits.length)? oldCounterDigits[7-newPos] : null;
				if (newPos == 4 || newPos == 1)
					setTimeout("setDigitAtPositionWithComma("+newPos+","+counterDigits[7-newPos]+","+oldDigit+",'ptsTickerDigit')", f*step+step);
				else
					setTimeout("setDigitAtPosition("+newPos+","+counterDigits[7-newPos]+","+oldDigit+",'ptsTickerDigit')", f*step+step);
			}
			else
				setTimeout("resetDigitAtPosition("+newPos+", 'ptsTickerDigit')", f*step+step);
		}
		else
			starAdvLightStars();
	}
}

function setDigitAtPositionWithComma(pos, num, oldNum, whichCounter) {
	var step = 125;
	if (whichCounter == 'cartCounterDigit')
	{
		var increment = 1;
		var spacing = 0.25;
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-52'); }, 1*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,'0','-104'); }, (1+increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,-31*(num+1),'-52'); }, (1+2*increment)*step);
		setTimeout(function() {changeBackgroundPosition('cartCounterDigit' + pos,-31*(num+1),'-104'); }, (1+3*increment)*step);
	}
	else
	{
		for (var i = (oldNum == null)? 0 : oldNum+1, f = 0; i != (num+1); i = (i+1)%11, f++)
		{
			var f1 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*y,'-39'); } }(i);
			var f2 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*y,'-78'); } }(i);
			
			if ((i+1)%11 == (num+1))	// last iteration of loop
				var f3 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*((y+1)%11),'-118'); } }(i);
			else
				var f3 = function(y) { return function() { changeBackgroundPosition('ptsTickerDigit' + pos,-23.4*((y+1)%11),'0'); } }(i);
				
			setTimeout(f1, f*step + (1/4)*step);
			setTimeout(f2, f*step + (3/4)*step);
			setTimeout(f3, f*step + step);
		}

		var newPos = pos-1;
		if (newPos >= 1)
		{
			var oldDigit = ((7-newPos) < oldCounterDigits.length)? oldCounterDigits[7-newPos] : null;
			if ((7-newPos) < counterDigits.length)
				setTimeout("setDigitAtPosition("+newPos+","+counterDigits[7-newPos]+","+oldDigit+",'ptsTickerDigit')", f*step+step);
			else
				setTimeout("resetDigitAtPosition("+newPos+",'ptsTickerDigit')", f*step+step);
		}
		else
			starAdvLightStars();
	}
}

function changeBackgroundPosition(id, posX, posY) {
	if($(id)) {
		$(id).style.backgroundPosition = posX + 'px ' + posY + 'px';
	}
}

/* Beta_HeaderController */
/* pts ticker badge */
var dontHideBadgeOffers = false;
var whichPageLoaded = null;

window.onresize = loadim;

function loadim() {
    var img = document.getElementById('catbgimg');
    if(img){
        var ratio = document.body.offsetWidth / img.width;
        img.height = img.height * ratio;
        img.width = img.width * ratio;
    }
}

function setDontHideBadgeOffers(value)
{
	dontHideBadgeOffers = value;
}

function getDontHideBadgeOffers()
{
	return dontHideBadgeOffers;
}

function showBadgeOffers()
{
	setDontHideBadgeOffers(true);
	setTimeout('_showBadgeOffers()',10);

	$('starAdvArrow').src = 'http://imga.nxjimg.com/emp_image/UserRank/header/header_arrow_up.gif';
	$('starAdvantageReadoutContainer').stopObserving('click', showBadgeOffers);
	$('starAdvantageReadoutContainer').observe('click', hideBadgeOffers);
}

function _showBadgeOffers()
{
	setDontHideBadgeOffers(false);

	$('ptsTickerNormalBG').style.visibility = 'hidden';
	$('ptsTickerBadgeBG').style.visibility = 'visible';

	$('ptsBadgeOffers').innerHTML = '<center><img alt="Loading Offers" src="http://imga.nxjimg.com/emp_image/invitefriend/loading.gif" title="Loading Offers"></center>';

	var howManyPerPage = 4;
	new Ajax.Request('/header/getstaradvantage/',
					 {method:'get',
					 onSuccess:loadStarAdvantage});
	}


function loadStarAdvantage(ajax_request){
	$('ptsBadgeOffers').innerHTML = ajax_request.responseText;
	if($('hpbRed_0')) {
		var bonusCount = parseInt($('bonusCountHeader').value);
		for (var i = 0; i < bonusCount; i++){
			var timeleft = parseInt($('timeLeftHeader_' + i).value);
			var timetotal = parseInt($('timeTotalHeader_' + i).value);
            if (timetotal != 0) {
                new Effect.Morph('hpbRed_' + i, {style:'width:' + timeleft*(233/timetotal) + 'px', duration:1});
            }
		}
	}
	if($('hpbBlue')) {
		var lastYear = parseInt($('lastYearHeader').value);
		var userRankLastYear = parseInt($('userRankLastYearHeader').value);
		var userRankThisYear = parseInt($('userRankThisYearHeader').value);
		var qualPtsEarnedThisYear = parseInt($('qualPointsEarnedThisYearHeader').value);

		if (userRankThisYear == 5 || userRankLastYear == 5) {
			new Effect.Morph('hpbBlue', {style:'width:233px', duration:1});
		} else if (lastYear == 1) {
			var nextLevel = userRankLastYear + 1;
			new Effect.Morph('hpbBlue', {style:'width:' + qualPtsEarnedThisYear*(233/(nextLevel*1000)) + 'px', duration:1});
		} else {
			qualPtsEarnedThisYear = qualPtsEarnedThisYear - (userRankThisYear*1000);
			new Effect.Morph('hpbBlue', {style:'width:' + qualPtsEarnedThisYear*.233 + 'px', duration:1});
		}
	}
}



function hideBadgeOffers()
{
    WOWPointsActivity.hideInfo();
}



/* pts ticker */
function flashCounter(message, param, param2)
{
	if (message == 'winner')
		var bgImageAddress = 'http://imga.nxjimg.com/emp_image/header/pts_ticker_winner.gif';
	else
		return;	/* for now, only 'winner' supported */

	for (var f = 1; f <= 7; f++)
		$('ptsTickerDigit'+f).style.backgroundImage = "url('"+bgImageAddress+"')";

	var normalFlashDuration = 150;
	var lastFlashDuration = 2000;
	var delayBeforeCountUp = 3000;

	for (var i = 0; i < 40; i += 2)
	{
		setTimeout('flashCounterWinnerB()', i*normalFlashDuration);
		setTimeout('flashCounterWinnerA()', (i+1)*normalFlashDuration);
	}

	var resetDigitBackgrounds = "";
	for (f = 1; f <= 7; f++) {
        resetDigitBackgrounds += "$('ptsTickerDigit"+f+"').style.backgroundImage = \"url('http://imga.nxjimg.com/emp_image/header/pts_ticker_digits_2b.gif')\";";
    }
    setTimeout(resetDigitBackgrounds, (i-1)*normalFlashDuration+lastFlashDuration);

    setTimeout("resetCounterTo("+param+",'ptsTickerDigit');", (i-1)*normalFlashDuration+lastFlashDuration);
    if(!(param && param2 && param == param2)) {
        for (f = 0; f < 15; f += 2)
        {
            setTimeout("resetCounterTo(null,'ptsTickerDigit');", (i-1)*normalFlashDuration+lastFlashDuration*2 + f*normalFlashDuration);
            setTimeout("resetCounterTo("+param+",'ptsTickerDigit');", (i-1)*normalFlashDuration+lastFlashDuration*2 + (f+1)*normalFlashDuration);
        }
        setTimeout("spinCounter("+param2+",'ptsTickerDigit');", (i-1)*normalFlashDuration+lastFlashDuration+(f-1)*normalFlashDuration+delayBeforeCountUp);
    }
}

function flashCounterWinnerA()
{
	changeBackgroundPosition('ptsTickerDigit1', -47, 0);
	changeBackgroundPosition('ptsTickerDigit2', -70, 0);
	changeBackgroundPosition('ptsTickerDigit3', -94, 0);
	changeBackgroundPosition('ptsTickerDigit4', -117, 0);
	changeBackgroundPosition('ptsTickerDigit5', -140, 0);
	changeBackgroundPosition('ptsTickerDigit6', -164, 0);
	changeBackgroundPosition('ptsTickerDigit7', -187, 0);
}

function flashCounterWinnerB()
{
	changeBackgroundPosition('ptsTickerDigit1', -47, -39.5);
	changeBackgroundPosition('ptsTickerDigit2', -70, -39.5);
	changeBackgroundPosition('ptsTickerDigit3', -94, -39.5);
	changeBackgroundPosition('ptsTickerDigit4', -117, -39.5);
	changeBackgroundPosition('ptsTickerDigit5', -140, -39.5);
	changeBackgroundPosition('ptsTickerDigit6', -164, -39.5);
	changeBackgroundPosition('ptsTickerDigit7', -187, -39.5);
}



/* ptspopup */
function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent) {
		while(1)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent){
				break;
				}
			obj = obj.offsetParent;
		}
	}
	else if(obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent) {
		while(1)
		{
			curleft += obj.offsetLeft;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	}
	else if(obj.x) {
		curleft += obj.x;
	}
	return curleft;
}


function getPosY(e) {
                var posy = 0;
                if (!e) var e = window.event;

                if (e.clientY) {
                                posy = e.clientY
                } else if (e.pageY) {
                                posy = e.pageY;
                }


                if(document.body.scrollTop && document.body.scrollTop > 0) {
                                posy = posy + document.body.scrollTop;
                }
                else if (document.documentElement.scrollTop && document.documentElement.scrollTop > 0) {
                                posy = posy + document.documentElement.scrollTop;
                }
                else if (e.pageYOffset && e.pageYOffset > 0) {
                                posy = posy + e.pageYOffset;
                }

                return posy;
}

function getPosX(e) {
                var posx = 0;
                if (!e) var e = window.event;
                if (e.clientX) {
                                posx = e.clientX
                } else if (e.pageX) {
                                posx = e.pageX;
                }

                if(document.body.scrollLeft && document.body.scrollLeft > 0) {
                                posx = posx + document.body.scrollLeft;
                }
                else if (document.documentElement.scrollLeft && document.documentElement.scrollLeft > 0) {
                                posx = posx + document.documentElement.scrollLeft;
                }
                else if (e.pageXOffset && e.pageXOffset > 0) {
                                posx = posx + e.pageXOffset;
                }

                return posx;
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}

//
function togglelogin(event)
{


	if(getPosY(event)>1200)
		$("loginpopup").style.top = "950px";
	else
	{
		if(getPosY(event)>400)
			$("loginpopup").style.top = "" + (0 + getPosY(event) -220) + "px";
		else
			$("loginpopup").style.top = "0px";
	}



	if($("SIBack"))
	{
		if($("SIBack").style.display =='block')
		{
			document.body.style.background='#fff';
			$("loginpopup").style.display='none';
			$("SIBack").style.display ='none';
		}
		else
		{
			document.body.style.background='#e8e8e8';
			$("outer-container").style.background='#fff';
			$("loginpopup").style.display='block';

			$("SIBack").style.display ='block';
		}

	}
}

function toggleloginnewdeal(event)
{


	if(getPosY(event)>1200)
		$("loginpopup").style.top = "950px";
	else
	{
		if(getPosY(event)>400)
			$("loginpopup").style.top = "" + (0 + getPosY(event) -320) + "px";
		else
			$("loginpopup").style.top = "0px";
	}



	if($("SIBack"))
	{
		if($("SIBack").style.display =='block')
		{
			document.body.style.background='#fff';
			$("loginpopup").style.display='none';
			$("SIBack").style.display ='none';
		}
		else
		{
			document.body.style.background='#e8e8e8';
			$("outer-container").style.background='#fff';
			$("loginpopup").style.display='block';

			$("SIBack").style.display ='block';
		}

	}
}

function validateJoin1() {
  if (validate_email($("joinEmail1").value)) {
    return true;
  } else {
    $('error-message11').style.display='block';
  $('error-space1').style.display='none';
    $('error-message11').update("The email address you provided doesn't appear to be valid.");
    return false;
  }
}

function validatePassword1() {
if ($("loginPasswordStar1").value.length > 0) {
    return true;
  } else {
  	$('error-message11').style.display='block';
  	$('error-space1').style.display='none';
    $('error-message11').update("Please enter a password.");
    return false;
  }
}

function submitJoin1() {
  if (validateJoin1()) {
    document.join1.submit();
  }
}

function submitLogin1() {

	if (validateEmail1() && validatePassword1()) {

  	document.login1.submit();

  	return true;
	}
//	else return false;
}
//
function validateEmail1() {
  if (validate_email($("loginEmail1").value)) {
    return true;
  } else {
  $('error-message11').style.display='block';
  $('error-space1').style.display='none';
    $('error-message11').update("A valid email address is required.");
    return false;
  }
}

function hide(divID){
    if ($(divID) && $(divID).style.display == 'block')
        $(divID).style.display = 'none';
}

function bodyClick(){
    //maincatnavoff();

    var urlpath = window.location.pathname;
    var path_array = urlpath.split("/");

    hide('filter_dropdown');
    hide('org_dropdown');
    hide('category_dropdown');
    hide('accountdropdown');
    hide('helpdropdown');
    hide('pointdropdown');
    if(path_array[1]=="feedback"){
        hide('contactusdropdown');
        hide('faqsdropdown');
    }
    hide('accountdropdown');
    if($('filterList') != 'undefined' && $('filterList') != null){
        hide('filterList');
    }
    if($('tynFilterList') != 'undefined' && $('tynFilterList') != null)
        hide('tynFilterList');
    if($('tywFilterList') != 'undefined' && $('tywFilterList') != null)
        hide('tywFilterList');
    if($('destFilterList') != 'undefined' && $('destFilterList') != null)
        hide('destFilterList');
    if($('reminderCatFilterList') != 'undefined' && $('reminderCatFilterList') != null)
        hide('reminderCatFilterList');
    if($('reminderSortFilterList') != 'undefined' && $('reminderSortFilterList') != null)
        hide('reminderSortFilterList');
    if($('listHeaderSubCatsHidden') != 'undefined' && $('listHeaderSubCatsHidden') != null)
        hide('listHeaderSubCatsHidden');
    if ($('allTimespans')) {
        $('allTimespans').hide();
        $('allDisplayModes').hide();
    }
    $$('.inviteAutocompleteResults').each(function(e) {
        $(e).hide();
    });
    //hide the drop down from lto page
    if( typeof isLTO =="undefined") {
    }else{
        hide('CBdropdown');
    }

    //hide the drop down category list of best selling product widget
    if (typeof showingHGOG=="undefined") {
    } else {
        if (showingHGOG) {
            setTimeout("guidehideDivCat();",20);
        }
    }

    if(typeof(menuUp) == 'undefined'){
    }else if(menuUp){
        menuUp = false;
    }else if(typeof(hideAllHomeEscapesDropDownMenus) != 'undefined'){
        hideAllHomeEscapesDropDownMenus();
    }else if(typeof(hideAllPricelineDropDownMenus) != 'undefined'){
        hideAllPricelineDropDownMenus();
    }
}

function getPosX(e) {
  var posx = 0;
  if (!e) var e = window.event;
  if (e.clientX) {
    posx = e.clientX;
  } else if (e.pageX) {
    posx = e.pageX;
  }
  if(document.body.scrollLeft && document.body.scrollLeft > 0) {
    posx = posx + document.body.scrollLeft;
  }else if (document.documentElement.scrollLeft && document.documentElement.scrollLeft > 0) {
    posx = posx + document.documentElement.scrollLeft;
  }else if (e.pageXOffset && e.pageXOffset > 0) {
    posx = posx + e.pageXOffset;
  }
  return posx;
}

function getPosY(e) {
  var posy = 0;
  if (!e) var e = window.event;
  if (e.clientY) {
    posy = e.clientY;
  } else if (e.pageY) {
    posy = e.pageY;
  }
  if(document.body.scrollTop && document.body.scrollTop > 0) {
    posy = posy + document.body.scrollTop;
  }else if (document.documentElement.scrollTop && document.documentElement.scrollTop > 0) {
    posy = posy + document.documentElement.scrollTop;
  }else if (e.pageYOffset && e.pageYOffset > 0) {
    posy = posy + e.pageYOffset;
  }
  return posy;
}


	var rev_keepmainnav = false;

    var keepmainnav = false;
	var mlHoverOpen = false;
	var mlClickOpen = false;

    var isOpeningMainNav = false;
    var openingMainNav = false;
	var clickedMainNav = false;

	function toggleDiv(name){
		if ( $(name).style.display=='block' ) {
			$(name).style.display='none';
		} else {
			setTimeout("$('"+name+"').style.display='block';",50);
		}
	}

    function toggleUserrankUpdateBox() {
	if ($('userrankUpdateBox').style.display == 'block') {
		hide('userrankUpdateBox');
	} else {
		$('userrankUpdateBox').style.display = 'block';
		hide('pointsUpdateBox');
  		hide('accountdropdown');
  		hide('helpdropdown');
  		hide('pointdropdown');
	}
	}

	function togglePointsUpdateBox() {
	if ($('pointsUpdateBox').style.display == 'block') {
		hide('pointsUpdateBox');
	} else {
		$('pointsUpdateBox').style.display = 'block';
		hide('userrankUpdateBox');
		hide('accountdropdown');
  		hide('helpdropdown');
  		hide('pointdropdown');
	}
	}

		var pollHandle = null;

		/* Extending scriptacuolus to implement a counter */
		Effect.Counter = Class.create();
		Object.extend(Object.extend(Effect.Counter.prototype, Effect.Base.prototype), {
			initialize: function(element, to, increment, preDisplayHook) {
				var options = arguments[2] || {};
				this.element = $(element);
				this.startNumber = parseInt(this.element.innerHTML);
				this.startNumber = isNaN(this.startNumber) ? 100000 : this.startNumber;
				this.endNumber = to;
				this.delta = this.endNumber - this.startNumber;
				this.increment = increment;
				this.preDisplayHook = preDisplayHook;
				if(!this.preDisplayHook) {
					this.preDisplayHook = function(count) {
						return count;
					}
				}
				this.start(options);
			},
			update: function(position) {
				var newCount = parseInt(this.startNumber + this.delta * position);
				if((newCount - this.startNumber) % this.increment == 0 || newCount == this.endNumber) {
					Element.update(this.element, this.preDisplayHook(newCount));
				}
			}
		});

		/* Hook to be fed to the Counter to format the text before displaying */
		function checkinTextDisplayHook(count) {
			return addCommas(count);
		}

		/* Number formater */
		function addCommas(nStr) {
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
		}

		/* Update the checkin bar with new count */
		function updateHeaderCheckInBar(countPercent, checkinCount) {
			if($('header-checkin-stats-full-bar')) {
				var barWidth = parseInt($('header-checkin-stats-empty-bar').offsetWidth);
				if(!isNaN(barWidth)) {
					var originalWidth = parseInt($('header-checkin-stats-full-bar').getWidth());
					var newWidth = parseInt(barWidth * countPercent);
					if(originalWidth != newWidth && !$('header-checkin-stats-bar-left-count')) {
						new Effect.Morph('header-checkin-stats-full-bar', {style:'width:' + newWidth + 'px', duration:0.8});
					}
				}
			}
			if($('header-checkin-stats-bar-left-count')) {
				var elems = $('header-checkin-stats-bar-left-count').select('span');
				if(elems.size() > 0) {
					var elem = elems[0];
					var originalCount = parseInt(elem.innerHTML);
					originalCount = isNaN(originalCount) ? 0 : originalCount;
					var newCount = parseInt(Math.round(checkinCount));
					newCount = isNaN(newCount) ? 0 : newCount;
					if(originalCount != newCount) {
						if($('header-checkin-stats-full-bar')) {
							new Effect.Parallel(
								[new Effect.Counter(elem, newCount, 1, checkinTextDisplayHook),
								new Effect.Morph('header-checkin-stats-full-bar', {style:'width:' + newWidth + 'px'})],
								{duration:1}
								);
						} else {
							new Effect.Counter(elem, newCount, 1, checkinTextDisplayHook);
						}
					}
				}
			}
		}

		/* Start polling the checkin count engine */
		function startPollingCheckinCount(ooId, interval) {
			if(pollHandle != null) {
				clearInterval(pollHandle);
			}
			pollHandle = setInterval(function() { pollCheckinCount(ooId); }, interval);
		}

		/* Stop polling the checkin count engine */
		function stopPollingCheckinCount() {
			if(pollHandle != null) {
				clearInterval(pollHandle);
			}
		}

		/* Poll the checkin count engine once */
		function pollCheckinCount(ooId) {
			var d = new Date();
			var param = 'ooId='+ooId+'&rand='+d.getMilliseconds();
			var url = '/overwhelmingoffer/gettriggercheckindata';
			new Ajax.Request(url, {
				method: 'get',
				parameters: param,
		        onComplete: function( e ) {
						var response = e.responseText;
						if(response != false && response != '' && response != 'invalid') {
							var rContent = eval("(" + response + ")");
							if(rContent['checkInCountPercent'] != undefined && rContent['checkInCount'] != undefined) {
								var countPercent = parseFloat(rContent['checkInCountPercent']).toFixed(2);
								if(!isNaN(countPercent)) {
									updateHeaderCheckInBar(rContent['checkInCountPercent'], rContent['checkInCount']);
								}
							}
						}
					}
			});
		}

		function parseAndEvalJs(elem) {
			if(elem) {
				var scriptNodes = elem.getElementsBySelector('script');
				for(var i=0; i < scriptNodes.length; i++) {
					eval(scriptNodes[i].innerHTML);
				}
			}
		}


function loadDropDown(version) {
	var actionName = 'dropdown';
	var params = '';
	var myAjax = new Ajax.Request('/header/' + actionName + '/version/' + version, {
		parameters:params,
		method:'get',
		onComplete:function(response) {
			$('ajaxedCategoryMenu').innerHTML = response.responseText;
		}
	});
}


function toggleMoreDropDown(){
    if($('ajaxedCategoryMenu').visible()){
        hideAllMoreCats();
        $('ajaxedCategoryMenu').hide();
    }else{
        setTimeout("$('ajaxedCategoryMenu').show();", 20);
    }
}
function expandMoreCat(cat){
/* These functions are removed until the subnavs are added back to the 'More' menu
    hideAllMoreCats();
    $('subCatMenu-'+cat).show();
*/
}
function collapseMoreCat(cat){
/*
    $('subCatMenu-'+cat).hide();
*/
}
function hideAllMoreCats(){
/*
    $$('.subcatbox').invoke(hide);
*/
}
function loadDropDown(){
    var actionName = 'dropdown';
    var params = '';
    var myAjax = new Ajax.Request('/header/' + actionName, {
        parameters:params,
        method:'get',
        onComplete:function(response) {
            $('ajaxedCategoryMenu').innerHTML = response.responseText;
        }
    });
}

Event.observe(window, 'load', function() {

/**
  * Supports the auto-suggest for the header search box
  */
    /*
    if(document.getElementById('searchInput') != null)
    {
        new Autocomplete('searchInput', {
            width:141
            , serviceUrl: '/api/search-auto-complete'
            , container:'autoSuggestContainer'
        });
    }
    */
    positionNew();

    loadDropDown();

    if(navigator.userAgent.indexOf('MSIE 6') != -1){
        $$('.hasMenu').invoke('observe', 'mouseenter', function(event){
            this.addClassName('hover');
        }).invoke('observe', 'mouseleave', function(event){
            this.removeClassName('hover');
        });
    }
});

var googleMapsLoaded = false;
function loadGoogleMaps(){
    if(!googleMapsLoaded){
        googleMapsLoaded = true;
        Event.observe(window, 'load', function(){
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "//maps.google.com/maps/api/js?sensor=false&callback=empty";
            document.body.appendChild(script);
        });
    }
}
function empty(){}










/* Edp_ObsessionsController */

var usource = 'HPSG';
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}

function toggleGender(g, listStyle){
    hideToggle = 0;
    if($('popularGenderOn') && !g){
        if($('popularGenderOn').innerHTML == 'Men'){
            g = 'F';
            $('popularGenderOn').innerHTML = 'Women';
            $('popularGenderOff').innerHTML = 'Men';
        }else{
            g = 'M';
            $('popularGenderOn').innerHTML = 'Men';
            $('popularGenderOff').innerHTML = 'Women';
        }
        hideToggle = 1;
    }
    if(listStyle){
        listStyle = "/listStyle/" + listStyle;
    }else{
        listStyle = "";
    }

    var myAjax = new Ajax.Request('/obsessions/mostshoppedwidget/gender/'+ g + listStyle + '/hideToggle/'+ hideToggle,
                {	method:'post'
                    ,onSuccess:function(e){
                        $('mostPurchasedCon').innerHTML = e.responseText;
                    }
                });
}

function showZipPopup(){
	$('added_popup').setStyle('display:block');
}
/* 5 star Popup box*/
var openPopup = 0;
var timeoutid = 0;
function closeBonusPopUp(id){
	openPopup = 0;
	clearTimeout(timeoutid);
	if(id){
		timeoutid = setTimeout(closeBonusPopUpWithDelay, 300);
	}else{
		timeoutid = setTimeout(closeBonusPopUpWithDelay, 1);
	}
}

function openBonusPopUpWithDelay(){
	if(openPopup){
		$('bonusPopUp').style.display = 'block';
		openPopup = 0;
	}
}

function closeBonusPopUpWithDelay(time){
	if($('bonusPopUp')){
		$('bonusPopUp').style.display = 'none';		
	}
}
function toggleDisplay(displayId){
    if($(displayId).style.display == 'block'){
        $(displayId).style.display = 'none';
    }else if( $(displayId).style.display == 'none'){
        $(displayId).style.display = 'block';
    }
}
var openWowPopup = 0;
var wowtimeoutid = 0;

function closewowPopUp(id){
    openWowPopup = 0;
    clearTimeout(wowtimeoutid);
    if(id){
        wowtimeoutid = setTimeout(closewowPopUpWithDelay, 200);
    }else{
        wowtimeoutid = setTimeout(closewowPopUpWithDelay, 1);
    }
}

function openwowPopUp(id){
    clearTimeout(wowtimeoutid);
    openWowPopup = 1;
    wowtimeoutid = setTimeout(openwowPopUpWithDelay, 300);
}
function closewowPopUpWithDelay(){
    if(!openWowPopup){
        $('wowPopUp').style.display = 'none';
        openWowPopup = 1;
    }
}

function openwowPopUpWithDelay(){
    if(openWowPopup){
        $('wowPopUp').style.display = 'block';
        openWowPopup = 0;
    }
}
function showVipBanner(divId){
    Effect.SlideDown(divId);
    $('vipLinkSoho').hide();
}
function hideVipBanner(divId){
    Effect.SlideUp(divId);
    setTimeout("$('vipLinkSoho').show()", 500);
}

