// ANF Classic Global Functions
$(document).ready(function () {
	$(".gtoa92Kids").click(goToKids);
	$(".castingNav").click(gCastingPop);
	$(".radioNav").click(pListPop);
	$(".subscribeNav").click(showFadeUp);
	$(".investorFNav").click(investorPop);
	$(".contactFadeUp").click(contactUsFadeUp);
	$(".newWinPop").click(newWinPop);	
	$(".privacyPop").click(privacyPop);
	$(".tncLink").click(tncLink);
	
	$(".closeFade").click(hideFadeCtn);
	$("#fadeContainer").click(hideFadeCtn);
	$(".fadeUp").click(function () { return false; });	
	showWrap();	
})
var abtest = 'A';
//=================================== COOKIES ============================================
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
}
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
lang = readCookie('anf-lang');
if (lang == null){
	lang = "en";
}
function DeleteCookie(name,path,domain) {
   if (GetCookie(name)) {
  	 document.cookie = name + '=' +
       ((path) ? '; path=' + path : '') +
       ((domain) ? '; domain=' + domain : '') +
       '; expires=Thu, 01-Jan-70 00:00:01 GMT';
   }
}
function GetCookie(name){
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
     var j = i + alen;
     if (document.cookie.substring(i, j) == arg)
       return getCookieVal (j);
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break;
   }
   return null;
}
function getCookieVal(offset){
     var endstr = document.cookie.indexOf (";", offset);
     if (endstr == -1)
         endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
}
//=================================== SHOPPING CART ============================================
function productCartNumber(){
	var cartNum = readCookie('myCart');
	if(cartNum == null){
		if(readCookie('myStore') == '12406'){
			cartNum = '0,\u00A30.00';
		} else {
			cartNum = '0,$0.00';
		}
	}
	setCartNum(cartNum);
}
function setCartNum(thenum){
	var parts = thenum.split(",");
	var q = encodeCharEntities(parts[0]);
	var amount = encodeCharEntities(parts[1]);
	if (parts[2]){amount = amount +','+ encodeCharEntities(parts[2]);}	
	if (document.getElementById('cartContainer')){
		newHeight = (q*42+200);		
		$("#cartContainer").css("top", '45px');
		$("#cartContainer").css("height", newHeight+"px");
		$("#cartContainer").css("clip", "rect(0px, 300px, " + newHeight + "px, 0px)");
		$("#cartContent").css("height", newHeight+"px");
		$("#cartContent").css("clip", "rect(0px, 300px, " + newHeight + "px, 0px)");
	}	
	$("#cartnum").html(q);
	$("#cartTotal").html(amount);
}
function resetMenus(){resetCart();}
function resetCart(){
	if (document.getElementById('cartContainer')){
		newLeft2 = document.getElementById('miniCart').offsetLeft;
		$("#cartContainer").css("left", newLeft2+"px");
	}
}
function showWrap(){
	$("#wrapper").css("visibility", 'visible');
	$("#contentcontainer").css("display", 'block');
	$("#gencntnr").css("visibility", 'visible');
	resetCart();
}

//=================================== NAVIGATION ============================================
var division = null;
var category = null;
function highlightMenu(){
	if(document.getElementById('navHolder')){	
		if(division == 12202 || division == 12204 || division==12234||division==23648||division==12237||division==12237||division==23649||division==12834||division==23650||division==23651||division==23652||division==23654||division==23653) var target= 'mens'; 
		else if(division == 12203 || division == 12205 || division == 23598 || division==12842||division==23655||division==12249||division==23656||division==12251||division==23657||division==23658||division==23659||division==23660||division==23661) var target = 'womens';
		else return;
		//Highlight the TopNav	
		$("#"+target+"TopNavLink").css("background-position","0 -"+$("#"+target+"TopNavLink").height()+"px");	
		if(division == 12205 || division == 12204){
			link = $("#clearance");
		}else if(division == 23598){
			link = $("#23598");
		}else if(category){
			link = $("#"+category);
		}else{
			link = null;
		}
		if(division==12234||division==23648||division==12237||division==23649||division==12834||division==23650||division==23651||division==23652||division==23654||division==23653){
			//Mens Keylooks
			link = $("#12226");
		} else if(division==12842||division==23655||division==12249||division==23656||division==12251||division==23657||division==23658||division==23659||division==23660||division==23661){
			//Womens Keylooks
			link = $("#12277");
		}				
		if(link){			
			addClass(link,'menuHighlight');
			var arrow = document.createElement('img');
			addClass(arrow,'menuArrow');			
			arrow.src = '/anf/onlinestore/common/arrow.gif';						
			link.prepend(arrow);
		}
	}else return;
}
function encodeCharEntities(s){
	if(!s){ return false; }
	var LT = new RegExp("<", "g"), GT = new RegExp(">", "g"), AMP = new RegExp("&", "g"), TAB = new RegExp("\t", "g");  
	return s.replace(AMP,"&amp;").replace(LT, "&lt;").replace(GT, "&gt;").replace(TAB, "    ");  
}

//================================= LEGACY FUNCTIONS ============================================
function $old(){
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
function limitChars(fe, num){
		fe.value = fe.value.slice(0, num);
}
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ''); };
var hostName = location.host;
var serverHostname = 'http://'+hostName;
function acctLogoff(){
	DeleteCookie('afstatus','/', + serverHostname);
	window.location = '/webapp/wcs/stores/servlet/Logoff?storeId='+globalStoreId+'&langId='+CONSTANTS.LANGID+'&URL=/webapp/wcs/stores/servlet/home_'+globalStoreId+'_'+globalCatalogId+'_'+CONSTANTS.LANGID;
}
function IsEmailValid(eml){    
    var test = eml;
    var lAt = test.indexOf("@")
    var lDot = test.lastIndexOf(".")
    //Checks over 5: x@x.x
    if ( test.length <5 || lAt <= 0 || lAt >= lDot - 1 || lDot >= test.length) {                
        return false;
    }else{
    	if(filter(test)){
    		return true;
        }else{
        	return false;
        }
    }
}
function selectOption(s,m){
	if(!s){ return; }
	for (var i=0; i<s.length; i++){
		if (s.options[i].value == m){
			s.options[i].selected = true;
			break;
		}
	}
}
function filter(address){		
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(address);
}
function nvp_struct(){
		var args = nvp_struct.arguments;
		this.nvp_qvpair = args[0];
		this.nvp_var = args[1];
		this.nvp_value = args[2];
}
var nvp_array = new Array;
function nvp_parse(){
	var querystring = location.search; nvp = querystring.indexOf('&'); searchstring = "true"; prev_nvp = 1; x = 0;
	do {
	if (nvp == -1){nvp = querystring.length; searchstring = "false";}
	var nvp_qvpair = querystring.substring(prev_nvp, nvp); nvp_var = nvp_qvpair.substring(0, nvp_qvpair.indexOf('=')); nvp_value = nvp_qvpair.substring(nvp_qvpair.indexOf('=')+1);
	nvp_array[x] = new nvp_struct(nvp_qvpair,nvp_var,nvp_value); querystring = querystring.substring(nvp + 1,querystring.length);
	if(querystring == null){searchstring = "false"} else {var prev_nvp = 0;		nvp = querystring.indexOf('&');		x++;}
	} while (searchstring == "true")
}
function nvp_get(){
	var args = nvp_get.arguments; nvpsearch = args[0]; nvpvalue = "noval"; nvp_length = nvp_array.length;
	for (var x = 0; x != nvp_length; x++){
		if(nvp_array[x].nvp_var == nvpsearch){nvpvalue = nvp_array[x].nvp_value};
	}
	return nvpvalue;
}
function addEvent(elm, evType, fn, useCapture){
//x-browser event handling function written by Scott Andrew
	if(elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if(elm.attachEvent){
			var r = elm.attachEvent('on' + evType, fn);
			//EventCache.add(elm, evType, fn);
			return r;
	}else{
			elm['on' + evType] = fn;
	}
}
function addClass(el, className){
	if (hasClass(el, className)) { return; } // already present
	el.className = [el.className, className].join(' ');
}
function hasClass(el, className){
	var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
    return re.test(el.className);
}
function hideCart(){
	addItem = false;
	ypSlideOutMenu.hideMenu('cart');
	
}
function showCart(){
	ypSlideOutMenu.showMenu('cart');
	$("#cartCrumbs").css("backgroundColor", '#B1B1B1');
	var ua = navigator.userAgent.toLowerCase();
	if ((ua.indexOf("msie") != -1) && (parseFloat(navigator.appVersion.split("MSIE")[1]) < 7) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)){
		$("#size").css("visibility", 'hidden');
		$("#sizelist").css("visibility", 'hidden');
	}
}
var siteWidth = 960;
var cartLeft = 515;
var cartTop = 40;
var xmlDoc = null;
var addItem = false;
function miniCart(){
	if (xmlDoc == null){
		makeRequest('/webapp/wcs/stores/servlet/MiniOrderItemDisplay');
	} else {
		makeCart();
	}
}
function makeRequest(url, type){
    var http_request = false;
	var getstr = "?";
	getstr += "storeId=" + CONSTANTS.STOREID + "&";
	getstr += "langId=" + CONSTANTS.LANGID + "&";
	getstr += "catalogId=" + CONSTANTS.CATALOGID + "&";
	getstr += "orderId=.";
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        return false;
    }
    getstr = url + getstr;
    http_request.onreadystatechange = function() { getContents(http_request, type); };
    http_request.open('Get', getstr, true);
    http_request.send(null);
}
function getContents(http_request, type){
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        	xmlDoc = http_request.responseXML;
        	makeCart(type);
        } else {
        }
    }
}
function getTopNav(){
	var html = '';
	html += '<script language="JavaScript">';
	html += 'new ypSlideOutMenu("cart", "down", '+cartLeft+', '+cartTop+', 300, 260);';
	html += '</script> ';
	document.write(html);
}
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 200
ypSlideOutMenu.hideDelay = 125
ypSlideOutMenu.minCPUResolution = 10
function ypSlideOutMenu(id, dir, left, top, width, height){
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0

	if (this.ie || this.ns4 || this.dom) {
		this.id			 = id
		this.dir		 = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType	 = dir == "right" || dir == "down" ? "-" : "+"
		this.dim		 = this.orientation == "h" ? width : height
		this.hideTimer	 = false
		this.aniTimer	 = false
		this.open		 = false
		this.over		 = false
		this.startTime	 = 0
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")
		ypSlideOutMenu.Registry[id] = this
		if (document.all){
			mWidth = document.body.clientWidth;
		} else if (document.layers){
			mWidth = window.innerWidth;
		} else if (document.getElementById){
			mWidth = window.innerWidth;
		}
		currentLeft = left;
		newLeft = parseInt(siteWidth/2) - currentLeft;
		newLeft = parseInt(mWidth/2) - newLeft;
		if (mWidth >= siteWidth){
				left = newLeft;
		} else{}
		newleft = left + "px";
		var d = document
		d.write('<style type="text/css">')
		d.write('#' + this.id + 'Container { visibility:hidden; ')
		d.write('z-index:65; ')
		d.write('left:' + newleft +'; ')
		d.write('top:' + top + 'px; ')
		d.write('overflow:hidden; }')
		d.write('#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; ')
		d.write('width:' + width + 'px; ')
		d.write('height:' + height + 'px; ')
		d.write('clip:rect(0px, ' + width + 'px, ' + height + 'px, 0px); ')
		d.write('}')
		d.write('</style>')

		this.load()
	}
}
ypSlideOutMenu.prototype.load = function(){
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	var temp

	if (!obj1 || !obj2) {
		window.setTimeout(this.gRef + ".load()", 100)
	}
	else {
		this.container	= obj1
		this.menu		= obj2
		this.style		= this.ns4 ? this.menu : this.menu.style
		this.homePos	= eval("0" + this.dirType + this.dim)
		this.outPos		= 0
		this.accelConst	= (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen

		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);

		this.endSlide()
	}
}
ypSlideOutMenu.showMenu = function(id){
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]

	if (obj.container) {
		obj.over = true

		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }

		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
}
ypSlideOutMenu.hideMenu = function(id){
	var obj = ypSlideOutMenu.Registry[id]
		if (obj.container) {
			if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
			obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
		}
}
ypSlideOutMenu.hide = function(id){
	var obj = ypSlideOutMenu.Registry[id]
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	if (obj.open && !obj.aniTimer) obj.startSlide(false)
}
ypSlideOutMenu.prototype.startSlide = function(open){
	this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime()
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}
ypSlideOutMenu.prototype.slide = function(){
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-")		d = -d
		else if (this.open && this.dirType == "+")	d = -d
		else if (!this.open && this.dirType == "-")	d = -this.dim + d
		else										d = this.dim + d

		this.moveTo(d)
	}
}
ypSlideOutMenu.prototype.endSlide = function(){
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	if ((this.open && !this.over) || (!this.open && this.over)) {
		this.startSlide(this.over)
	}
	if ((!this.open) && (this.id == 'cart')){
		$("#cartCrumbs").css("backgroundColor", 'transparent');
		var ua = navigator.userAgent.toLowerCase();
		if ((ua.indexOf("msie") != -1) && (parseFloat(navigator.appVersion.split("MSIE")[1]) < 7) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)){
			$("#size").css("visibility", 'visible');
			$("#size").css("visibility", 'visible');
		}
	}
}
ypSlideOutMenu.prototype.setVisibility = function(bShow){
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}
ypSlideOutMenu.prototype.moveTo = function(p){
	this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : (p) + "px"
}
ypSlideOutMenu.prototype.getPos = function(c){
	return parseInt(this.style[c])
}
ypSlideOutMenu.prototype.onactivate	= function() { }
ypSlideOutMenu.prototype.ondeactivate	= function() { }
function makeCart(type){
	if (addItem){
		type = 'add';
	}
	var numItems = xmlDoc.getElementsByTagName('number')[0];
	var qItems = xmlDoc.getElementsByTagName('quantity')[0];
	var numGifts = xmlDoc.getElementsByTagName('gift')[0];
	if (numItems){
		if (numItems.childNodes[0].nodeValue > 0){
	    	var total = xmlDoc.getElementsByTagName('total')[0];
	    	var store = xmlDoc.getElementsByTagName('store')[0];
	    	var catalogid = xmlDoc.getElementsByTagName('catalogid')[0];
	    	var langid = xmlDoc.getElementsByTagName('langid')[0];
			var chtml = "<table width='100%' cellpadding=0 cellspacing=0 class=\"minitext\" id=\"miniStyle\">";
			if(type == 'add'){
				addItem = true;
				var num = (numItems.childNodes[0].nodeValue) - 1;
				var name = (xmlDoc.getElementsByTagName('name')[num]).childNodes[0].nodeValue; 
				var price = (xmlDoc.getElementsByTagName('price')[num]).childNodes[0].nodeValue; 
				var color = (xmlDoc.getElementsByTagName('color')[num]).childNodes[0].nodeValue; 
				var size = (xmlDoc.getElementsByTagName('size')[num]).childNodes[0].nodeValue; 
				var col = (xmlDoc.getElementsByTagName('collection')[num]).childNodes[0].nodeValue; 
				var seq = (xmlDoc.getElementsByTagName('sequence')[num]).childNodes[0].nodeValue; 
				var q = (xmlDoc.getElementsByTagName('qty')[num]).childNodes[0].nodeValue; 
				var backdate = (xmlDoc.getElementsByTagName('backdate')[num]).childNodes[0].nodeValue; 
				
				today = new Date();
				month = today.getMonth() +1;
				day = today.getDate();
				if(month <10){ 
					month = "0"+month;
				}
				if(day<10){
					day = "0"+day;
				}
				now = today.getFullYear() +""+ month +""+ day;
				backordered = false;
				backStr="";			
				if (typeof currItemBackordered != "undefined" || typeof xCurrItemBackordered != "undefined"){
					if(currItemBackordered == true || xCurrItemBackordered == 'true'){	//currItem is type boolean while xCurrItem is a string
						if(backdate == ''){
							backdate =  0;
						}
						if(backdate<=now){
							backStr = '<span class="mcBackorder">' + CONSTANTS.MC_BACKORDERED + '</span>';
							backordered = true;
						}else{
							shipStr = backdate.substring(4,6) + "/" + backdate.substring(6,8) + "/" + backdate.substring(2,4)
							backStr = '<span class="mcBackorder">' + CONSTANTS.MC_EXPECTSHIP + shipStr + '</span>';
							backordered = true;
						}							
					}
				}
				var colorSeq;
				if (seq == 'none'){
					colorSeq = "01";
				} else if (seq < 10) {
					colorSeq = "0"+seq;
				} else {
					colorSeq = seq;
				}
				colorSeq = colorSeq.substring(0,2);
				if (color == 'none'){
					color = '';
				}
				if ((size == 'none') || (size == 'ONE SIZE')){
					size = '';
				}
				var catentry = (xmlDoc.getElementsByTagName('catentry')[num]).childNodes[0].nodeValue;
				chtml += '<tr><td colspan="2" style="text-align:center;" class="mcItemAdded">' + CONSTANTS.MC_ITEMADDED;
				if(backordered == true){
					chtml += backStr;
				}
				chtml += '</td></tr>';
				chtml += '<tr><td colspan="2"><div class="dotBar"></div></td></tr>';
				chtml += '<tr><td width="65"><img src="/anf/onlinestore/collection/'+col+'_'+colorSeq+'_m.jpg" width="65"/></td><td width="143" valign="top" class="mcAddProdName">'+name+'<br/>';
				if(color != ''){
					chtml += '<span class="mcAddColorSize">'+color+' - ';
				}
				if(size != ''){
					chtml += size+'<br/>';
				}
				if(q > 1){
					chtml += CONSTANTS.MC_QUANTITY+' '+q;
				}
				chtml += '</span><div style="margin-top:10px;color:#999999;">'+price+'<div></td></tr>';
				chtml += '<tr><td colspan="2"><div class="dotBar"></div></td></tr>';
				if(numItems.childNodes[0].nodeValue > 15){
					chtml += '<tr><td colspan="2" class="fullCart" style="text-align:center;">'+ CONSTANTS.MC_FULL_BAG +'</td></tr>';
				}
			}else if(type == 'egcadd'){
				var num = (numItems.childNodes[0].nodeValue) - 1;
				var name = (xmlDoc.getElementsByTagName('name')[num]).childNodes[0].nodeValue; 
				var price = (xmlDoc.getElementsByTagName('price')[num]).childNodes[0].nodeValue; 
				if(((xmlDoc.getElementsByTagName('egcreceiver')[num]).childNodes[0].nodeValue != null) & ((xmlDoc.getElementsByTagName('egcreceiver')[num]).childNodes[0].nodeValue != '')){
					var rsd = (xmlDoc.getElementsByTagName('requestedshipdate')[num]).childNodes[0].nodeValue; 
					var receiver = (xmlDoc.getElementsByTagName('egcreceiver')[num]).childNodes[0].nodeValue; 
				}		
				chtml += '<tr><td colspan="2" style="text-align:center;" class="mcItemAdded">' + CONSTANTS.MC_ITEMADDED;
				chtml += '</td></tr>';
				chtml += '<tr><td colspan="2"><div class="dotBar"></div></td></tr>';
				chtml += '<tr><td width="68"><img src="/anf/onlinestore/collection/EGIFTCARD_01_m.jpg" width="65"/></td><td width="143" valign="top"><b>'+name+'</b><br/>';
				chtml += '<div style="margin-top:10px;color:#999999;">'+price+'<div></td></tr>';
				if(receiver != null && receiver != ''){
					chtml += '<tr><td colspan="2" align="left"><br/>'+ CONSTANTS.MC_SEND_ON +' '+ rsd + '</td></tr>';
				}
			}else {
				if(numItems.childNodes[0].nodeValue > 15){
					chtml += '<tr><td colspan="2" class="fullCart" style="text-align:center;">'+ CONSTANTS.MC_FULL_BAG +'</td></tr>';
				}
				for (loop = 0; loop < (numItems.childNodes[0].nodeValue); loop++) { 
					var name = (xmlDoc.getElementsByTagName('name')[loop]).childNodes[0].nodeValue; 
					var price = (xmlDoc.getElementsByTagName('price')[loop]).childNodes[0].nodeValue; 
					var color = (xmlDoc.getElementsByTagName('color')[loop]).childNodes[0].nodeValue; 
					var size = (xmlDoc.getElementsByTagName('size')[loop]).childNodes[0].nodeValue; 
					var sku = (xmlDoc.getElementsByTagName('sku')[loop]).childNodes[0].nodeValue; 
					var q = (xmlDoc.getElementsByTagName('qty')[loop]).childNodes[0].nodeValue; 
					var rsd = (xmlDoc.getElementsByTagName('requestedshipdate')[loop]).childNodes[0];  
					
					if (color == 'none'){
						color = '';
					}
					if ((size == 'none') || (size == 'ONE SIZE')){
						size = '';
					} else {
						size = ' - '+size;
					}
					var catentry = (xmlDoc.getElementsByTagName('catentry')[loop]).childNodes[0].nodeValue; 
					// RMS support
					if(sku.length == 8){
						if((sku == 99999024) || (sku == 99999014)){
							chtml += '<tr><td width="90" class="mcProdName">'+name+'<br/><span class="mcColorSize">'+color+size+'</span></td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';
						} else if((sku == 88888025) || (sku == 88888050) || (sku == 88888100) || (sku == 88888200)){
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/GiftCardDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'&cm_ven=minicart&cm_cat=product&cm_pla='+name+'&cm_ite='+catentry+'">'+name+'</a><br/>'
							if(q > 1){
								chtml += CONSTANTS.MC_QUANTITY+' '+q;
							}
							chtml += color+size+'</td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';							
						}else if((sku == 88889025) || (sku == 88889050) || (sku == 88889075) || (sku == 88889100) || (sku == 88889150) || (sku == 88889200) || (sku == 88889250) || (sku == 88889300) || (sku == 88889350) || (sku == 88889400) || (sku == 88889450) || (sku == 88889500)){
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/EGCDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'">'+name+'</a><br/><span class="mcColorSize">'+rsd.nodeValue+'</span><br/>';
							chtml += '</td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';	
						}else{
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/ProductDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'&productId='+catentry+'&colorString='+color+'&cm_ven=minicart&cm_cat=product&cm_pla='+name+'&cm_ite='+catentry+'">'+name+'</a><br/><span class="mcColorSize">'+color+size+'</span></td><td valign="top" align="right">'+price+'</td></tr>';
						}
					}else{
						if((sku == 199999024) || (sku == 199999014)){
							chtml += '<tr><td width="90" class="mcProdName">'+name+'<br/><span class="mcColorSize">'+color+size+'</span></td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';
						} else if((sku == 188888025) || (sku == 188888050) || (sku == 188888100) || (sku == 188888200)){
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/GiftCardDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'&cm_ven=minicart&cm_cat=product&cm_pla='+name+'&cm_ite='+catentry+'">'+name+'</a><br/>'
							if(q > 1){
								chtml += CONSTANTS.MC_QUANTITY+' '+q;
							}
							chtml += color+size+'</td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';							
						}else if((sku == 188889025) || (sku == 188889050) || (sku == 188889075) || (sku == 188889100) || (sku == 188889150) || (sku == 188889200) || (sku == 188889250) || (sku == 188889300) || (sku == 188889350) || (sku == 188889400) || (sku == 188889450) || (sku == 188889500)){
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/EGCDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'">'+name+'</a><br/><span class="mcColorSize">'+rsd.nodeValue+'</span><br/>';
							chtml += '</td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';	
						}else{
							chtml += '<tr><td width="90" class="mcProdName"><a class="orderItem" href="/webapp/wcs/stores/servlet/ProductDisplay?storeId='+store.childNodes[0].nodeValue+'&langId='+langid.childNodes[0].nodeValue+'&catalogId='+catalogid.childNodes[0].nodeValue+'&productId='+catentry+'&colorString='+color+'&cm_ven=minicart&cm_cat=product&cm_pla='+name+'&cm_ite='+catentry+'">'+name+'</a><br/><span class="mcColorSize">'+color+size+'</span></td><td valign="top" class="mcPriceBX">'+price+'</td></tr>';
						}
					}					
				}			
				chtml += '<tr><td colspan="2"><div class="dotBar"></div></td></tr>';
				chtml += '<tr><td class="mcPriceBX mcSubTot" colspan="2">' + CONSTANTS.MC_SUBTOTAL + '<span style="margin-left:10px;">'+total.childNodes[0].nodeValue+'</span></b></td></tr>';
			}
			chtml += '<tr><td width="180" colspan="2"><img src="/anf/images/clear.gif" width="1" height="10"/></td></tr>';
			chtml += '<tr><td colspan="2" class="mcPriceBX">';			
			chtml += '<a name="mcViewBagButton" id="mcViewBagButton" href="/webapp/wcs/stores/servlet/OrderItemDisplay?langId=' + CONSTANTS.LANGID + '&storeId=' + CONSTANTS.STOREID + '&catalogId=' + CONSTANTS.CATALOGID + '&orderId=." class="buttonClass"><span>' + CONSTANTS.MC_BTN_VIEWBAG + '</span></a>';		
			chtml += '</td></tr></table>';
			
			$("#cartlist").html(chtml);		
			
			showCart();
			if(type == 'add' || type =='egcadd'){
				setTimeout("hideAdd()", 5000);
				var cartCookie = readCookie('myCart');
				var shipMode = '';
				var prods = qItems.childNodes[0].nodeValue - numGifts.childNodes[0].nodeValue
				var cartCookie = prods + ',' + total.childNodes[0].nodeValue;
				cartCookie = cartCookie.replace(/&nbsp;/g,' ');
				cartCookie = cartCookie.replace(/&pound;/g,'\u00A3');
				createCookie('myCart',cartCookie,''); 
				setCartNum(cartCookie);
			}
		}
	}
}
function hideAdd(){
	if (addItem){
		ypSlideOutMenu.hideMenu('cart');
		addItem = false;
	}
}

//================================= FADEUPS ============================================
function goToKids(){	
	setupFade("gotokids");		
	var html = '<img style="position:absolute;z-index:4;" usemap="#a92FadeMap" src="/anf/images/I-fadeUpKidsLogo.gif"/>';
	html +=	'<div style="position:absolute;z-index:44;top:160px;text-align:center;width:300px;padding:0 19px 0 19px;">';
	html += '<div id="gtKidsPrcdBtn" style="padding-left:115px;"><a name="ProceedButton" id="ProceedButton" href="http://www.abercrombiekids.com" onclick="gTs(\'http://www.abercrombiekids.com\')" class="buttonClass "><span>'+CONSTANTS.OID_TOUT_GB_PROCEED+'</span></a><div class="clearer"></div><br/><br/></div>';
	html +=	'<span class="storeHeader">'+CONSTANTS.A92POP_DISCLAIM+'</span>';
	html +=	'</div>';
	html +=	'<map name="a92FadeMap">';
	html +=	'	<area shape="rect" coords="314,10,327,23" href="#" onclick="hideFadeCtn()" />';
	html +=	'</map>	';	
	$(ctntDiv).html(html);
	return false;		
}
function gCastingPop(){window.open($(this).attr('href'),'casting', 'toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width=918px,height=680px');return false;}
function pListPop(){window.open($(this).attr('href'),'music', 'toolbar=no,menubar=no,status=no,scrollbars=no,resizable=yes,width=240px,height=100px');return false;}
function investorPop(){window.open($(this).attr('href'),'investor','toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=750,height=600');return false;}
function privacyPop(){window.open($(this).attr('href'),$(this).attr('id'),'scrollbars=yes,width=500,height=460');return false;}
function tncLink(){window.open($(this).attr('href'),'terms','scrollbars=yes,width=460,height=460');return false;}
function newWinPop(){window.open($(this).attr('href'),$(this).attr('id'));return false;}
$.clientCoords = function() {
	var dimensions = {width: 0, height: 0};
	if (document.documentElement) {
		dimensions.width = document.documentElement.scrollWidth;
		dimensions.height = document.documentElement.scrollHeight;
	} else if (window.innerWidth && window.innerHeight) {
		dimensions.width = window.innerWidth;
		dimensions.height = window.innerHeight;
	}
	return dimensions;
}	
showFadeUp = function () {
	$(".modalHide").hide();
	$("#fadeUpContent").removeClass();
	$("#fadeUpContent").addClass("fadeUp");		
	var ctntDiv = $(this).attr("id");
	$(".fadeUp").hide();
	$("#fadeContainer").hide();
	$("#fadeContainer").addClass("transparent");
	$("#fadeContainer").css("width", $.clientCoords().width);
	$("#fadeContainer").css("height", $.clientCoords().height);
	$("#fadeContainer").show();
	ctntDiv = "#" + ctntDiv.replace(/Link/,"Content");
	$(ctntDiv).css("left", ($.clientCoords().width - $(ctntDiv).width())/2);
	$(ctntDiv).fadeIn("slow");
	return false;
}
hideFadeCtn = function(){
	$(".modalHide").show();
	$("#fadeContainer").hide();
	$("#fadeContainer").removeClass();
	$("#fadeCtn").fadeOut("slow");
	$('.fadeUp').fadeOut("slow");
	return false;
}
function gTk(){hideFadeCtn();window.open('http://www.abercrombiekids.com/kids/index.html?cm_ven=redirect&cm_cat=topnav&cm_pla=kids&cm_ite=kids_site');}	
function gTs(url){window.open(url);hideFadeCtn();}
var ctntDiv = "#fadeUpContent";
function setupFade(fadedthis){
	$("#fadeUpContent").removeClass();
	$("#fadeUpContent").addClass("fadeUp");
	$(".fadeUp").hide();
	$("#fadeContainer").hide();
	$("#fadeContainer").addClass("transparent");
	$("#fadeUpContent").addClass(fadedthis);
	$("#fadeContainer").css("width", $.clientCoords().width).css("height", $.clientCoords().height);
	$("#fadeContainer").show();
	$(ctntDiv).css("left", ($.clientCoords().width - $(ctntDiv).width())/2);
	$(ctntDiv).fadeIn("slow");
	if($("#fadeUpContent").css('height')!='auto'){
		var mH = $("#fadeUpContent").css('height').substring(0,$("#fadeUpContent").css('height').length-2);	
	}else{
		var mH = 120;
	}
	var cTop = getViewport().height - mH;
	cTop=cTop/2;
	cTop=cTop-140;
	var tmp = $("#fadeUpContent").css('top').substring(0,$("#fadeUpContent").css('top').length-2);
	$("#fadeUpContent").css("top",getViewport().top+cTop);	
}
function setupGenFade(fadedthis){
	$(".modalHide").hide();
	$("#fadeUpContent").removeClass();
	$("#fadeUpContent").addClass("fadeUp");
	var ctntDiv = "#"+fadedthis;
	$(".fadeUp").hide();
	$("#fadeContainer").hide();
	$("#fadeContainer").addClass("transparent");
	$("#fadeContainer").css("width", $.clientCoords().width);
	$("#fadeContainer").css("height", $.clientCoords().height);
	$("#fadeContainer").show();
	$(ctntDiv).css("left", ($.clientCoords().width - $(ctntDiv).width())/2);
	$(ctntDiv).fadeIn("slow");
	if($("#"+fadedthis).css('height')!='auto'){
		var mH = $("#"+fadedthis).css('height').substring(0,$("#"+fadedthis).css('height').length-2);	
	}else{
		var mH = 120;
	}
	var cTop = getViewport().height - mH;
	cTop=cTop/2;
	cTop=cTop-140;
	var tmp = $("#"+fadedthis).css('top').substring(0,$("#"+fadedthis).css('top').length-2);
	$("#"+fadedthis).css("top",getViewport().top+cTop);
}
function getFade(fadethis){
	setupFade("vdFadeUp");
	$(ctntDiv).load(fadethis.attr('href')+" #incBody");	
	return false;	
}
var win = $(window);
var getViewport = function(){
    var vp = 
    {
        top:    win.scrollTop(),
        left:   win.scrollLeft(),
        width:  win.width(),
        height: win.height()
    }
    return vp;
}
function contactUsFadeUp(p){
	setupFade("contactUsFadeUp");
	$(ctntDiv).load("/anf/ajaxinc/contactus.html", {
			"storeId" : globalStoreId,
			"catalogId" : globalCatalogId,
			"langId" : globalLangId,
			"type" : p ? p : 'def'
	}, function(){
		contactForm.init(contactUsType);
		return false;
	});
	return false;
}
function validateMlInput(page){
	$("#mailingListTopNavContent").find("#SubmitButton").hide();
	var responseDiv = 'response';
	var f = document.forms.MailingList;
	if(page == 'home'){
		responseDiv = 'responseHome';
		f = document.forms.MailingListHome;
	}
	var emailValue = f.email.value
	if (!IsEmailValid(emailValue)){
		$("#"+responseDiv).html("<b>"+CONSTANTS.ML_PLEASE_ENTER_ADDR+"</b>");
		if (page == 'fadeUp') document.getElementById(responseDiv).style.color = '#ad3232';
		$("#mailingListTopNavContent").find("#SubmitButton").show();
	}else {
		var params = {
			'aid' : f.aid.value,
			'sub' : f.sub.value,
			'unsub' : f.unsub.value,
			'resub' : f.resub.value,
			'a' : f.a.value,
			'storeId' : f.storeId.value,
			'catalogId' : f.catalogId.value,
			'languageId' : f.languageId.value,
			'URL' : f.URL.value,
			'email' : f.email.value
		}				
		$.ajax({
			url: "/webapp/wcs/stores/servlet/MailSubscription",
			global: false,
			type: "POST",
			data: params,
			dataType: "xml",
			success: function(xml){
				var status = xml.getElementsByTagName('mail_status')[0].firstChild.nodeValue;
				var msg = xml.getElementsByTagName('response')[0].firstChild.nodeValue;
				$("#response").html("<spans style='color:#999999'>"+msg+"</span>");
				document.forms.MailingList.email.value = '';								
			}
		});				
	}
}

var rmvdOs = new Array();
function closeFadeUp(whatDiv){
	if(whatDiv=='jQ'){
		hideFadeCtn();
	}else{
		fadeThisDiv('fadeUpHolder');
		$("#size").css("visibility", 'visible');
		$("#sizelist").css("visibility", 'visible');		
		setTimeout("document.getElementsByTagName('body')[0].removeChild(document.getElementById('fadeUpHer'))", 500);
		if(rmvdOs.length > 0){
			for(i = 0; i < rmvdOs.length; i++)rmvdOs[i].parent.appendChild(rmvdOs[i].child);
		}
	}
}