// Create dw namespace if necessary
if (typeof dw == 'undefined') {
	var dw = {};
}

// Revert jQuery and $ variables if necessary
var lastInDollar = window.$
var lastInJQuery = jQuery.noConflict(true);
if (typeof jQuery == 'undefined') {
	jQuery = lastInJQuery;
}
if (typeof window.$ == 'undefined') {
	window.$ = lastInDollar;
}

// Store DW jQuery version
if (typeof dw.jQuery == 'undefined') {
	dw.jQuery = lastInJQuery;
}

// Add the dw.ac and dw.__ac namespaces
(function() {
	var dw$ = dw.jQuery;

	// Returns the value of the first cookie found whose name is accepted by the given function
	function getCookieValue(/*function(x)*/ acceptFunction) {
		var cookiePairs = document.cookie.split(';');
		for (var i = 0; i < cookiePairs.length; i++)
		{
			var index = cookiePairs[i].indexOf('=');
			if (index != -1) {
				var name = dw$.trim(cookiePairs[i].substring(0, index));
				if (acceptFunction(name)) {
					return dw$.trim(unescape(cookiePairs[i].substring(index + 1)));
				}
			}
		}
		
		return null;
	};
	
	// Sets a cookie with the given name and value
	function setCookieValue(/*string*/ name, /*string*/ value, /*integer*/ millisToExpiry) {
		var cookie = name + '=' + escape(value) + ';path=/';
		if (millisToExpiry != -1) {
			cookie += ";expires=" + expires.toGMTString();
		}
		document.cookie = cookie;
	};
	
	// URL encodes the given string to match the Java URLEncoder class
	function urlencode(/*string*/ value) {
		var convertByte = function(code) {
			return '%' + new Number(code).toString(16).toUpperCase();
		};
		
		var encoded = '';
		for (var i = 0; i < value.length; i++) {
			var c = value.charCodeAt(i);
			if (((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) || (c == 46) || (c == 45) || (c == 42) || (c == 95)) {
				encoded += value.charAt(i);		// a-z A-z 0-9 . - * _
			}
			else if (c == 32) {
				encoded += '+';					// (space)
			}
			else if (c < 128) {
				encoded += convertByte(c); 
			}
			else if ((c >= 128) && (c < 2048)) {
				encoded += convertByte((c >> 6) | 0xC0);
				encoded += convertByte((c & 0x3F) | 0x80);
			}
			else if ((c >= 2048) && (c < 65536)) {
				encoded += convertByte((c >> 12) | 0xE0);
				encoded += convertByte(((c >> 6) & 0x3F) | 0x80);
				encoded += convertByte((c & 0x3F) | 0x80);
			}
			else if (c >= 65536) {
				encoded += convertByte((c >> 18) | 0xF0);
				encoded += convertByte(((c >> 12) & 0x3F) | 0x80);
				encoded += convertByte(((c >> 6) & 0x3F) | 0x80);
				encoded += convertByte((c & 0x3F) | 0x80);
			}
		}
		
		return encoded;
	}

	// Returns the value of the analytics cookie set on the server
	function getAnalyticsCookieValue() {
		var acceptFunction = function(name) {
			return (name.length > 5) && (name.substring(0, 5) === 'dwac_');
		};
		return getCookieValue(acceptFunction);
	};
	
	// Contextual information retrieved from the server
	var analyticsContext = (function() {
		var cookieValue = getAnalyticsCookieValue();
		if (cookieValue == null) {
			return {
				enabled: false
			};
		}
		
		var tokens = cookieValue.split('|');
	
		return {
			enabled: true,
			visitorID: tokens[0],
			repository: tokens[1],
			customer: tokens[2],
			sourceCode: tokens[3],
			siteCurrency: tokens[4],
			encoding: 'ISO-8859-1'
		};
	}());

	// Turn debugging on or off
	var setDebugEnabled = function(enabled) {
		if (typeof enabled != 'boolean') {
			return;
		}
		
		setCookieValue('dwacdebug', '' + enabled, -1);
	};
	
	// Returns true if debug is enabled, false otherwise
	function isDebugEnabled() {
		var acceptFunction = function(name) {
			return name === 'dwacdebug';
		};
		return getCookieValue(acceptFunction) === 'true';
	};

	// ****************************
	// BEGIN OMNITURE SPECIFIC CODE
	// ****************************
	
	// Maximum number of products to submit per image request
	var MAX_PRODUCTS_PER_IMAGE_REQUEST = 15;
	
	// Number of products to submit per image request when above maximum
	var CHUNK_PRODUCTS_PER_IMAGE_REQUEST = 10;
	
	// Omniture submission engine
	var OMNITURE = new OmnitureEngine(analyticsContext);

	// Whether or not the next submission is the first for this page
	var firstSubmissionForPage = true;
	
	// Set of IDs to encode in Omniture data
	function IdSet() {
		// Array containing IDs in this set
		var set = [];
		
		// Adds the given ID to this set
		this.add = function(/*string*/ id) {
			if (typeof id != 'string') {
				return;
			}
			
			for (var i = 0; i < set.length; i++) {
				if (set[i] === id) {
					return;
				}
			}
			
			set.push(id);
		};
		
		// Adds the IDs in the given array to this set
		this.addAll = function(/*string[]*/ ids) {
			for (var i = 0; i < ids.length; i++) {
				this.add(ids[i]);
			};
		};
		
		// Returns the size of this set
		this.getSize = function() {
			return set.length;
		};
		
		// Returns true if the given ID is in this set
		this.contains = function(/*string*/ id) {
			for (var i = 0; i < set.length; i++) {
				if (id === set[i]) {
					return true;
				}
			}
			
			return false;
		};
		
		// Returns an Omniture ID string representing the contents of this set
		this.getIdsString = function() {
			var s = '';
			
			for (var i = 0; i < set.length; i++) {
				if (i > 0) {
					s += ',';
				}
				
				s += set[i];
			}
			
			return s;
		};
	};
	
	// A product to encode in Omniture data
	function Product(productID) {
		var that = this;
		
		// ID of the product
		var id = productID;
		
		// Map of event IDs to their values for this product
		var events = {};
		
		// Map of evar names to their values for this product
		var evars = {};
		
		// Associates the given event increment with this product, for the given event ID
		this.putEvent = function(/*string*/ eventID, /*number*/ value) {
			if ((typeof eventID != 'string') || (typeof value != 'number')) {
				return;
			}
			
			events[eventID] = value;
		};
		
		// Associates the given value with this product, for the given evar
		this.putEvar = function(/*string*/ evar, /*string*/ value) {
			if ((typeof evar != 'string') || (typeof value != 'string')) {
				return;
			}
			
			evars[evar] = value;
		};
		
		// Returns an array containing the IDs of events associated with this product
		this.getEventIDs = function() {
			var ids = [];
			for (eventID in events) {
				ids.push(eventID);
			}

			return ids;
		};
		
		// Returns an array containing the IDs of evars associated with this product
		this.getEvarIDs = function() {
			var ids = [];
			for (evarID in evars) {
				ids.push(evarID);
			}

			return ids;
		}
		
		// Returns an Omniture product string representing this product
		this.getProductString = function(imageRequestEvents) {
			// Returns true if the events part of the product string 
			// should be ignored given the events to be submitted 
			// for the image request containing this product
			var ignoreEvents = function() {
				if (imageRequestEvents.getSize() != 1) {
					return false;
				}
				
				var eventIDs = that.getEventIDs();
				if (eventIDs.length != 1) {
					return false;
				}
				
				return imageRequestEvents.contains(eventIDs[0]);
			};

			// Build the events part of the product string
			var eventString = '';
			if (!ignoreEvents(imageRequestEvents)) {
				for (eventID in events) {
					var value = events[eventID];
					
					if (value != 0) {
						if (eventString.length > 0) {
							eventString += '|';
						}
						
						eventString += eventID + '=' + events[eventID];
					}
				}
			}

			// Build the evar part of the product string
			var evarString = '';
			for (evar in evars) {
				var value = evars[evar];
				
				if (value != '') {
					if (evarString.length > 0) {
						evarString += '|';
					}
					evarString += evar + '=' + evars[evar];
				}
			}
			
			// Build and return the product string
			var s = ';' + id;
			
			if ((eventString != '') || (evarString != '')) {
				s += ';;;' + eventString;
				
				if (evarString != '') {
					s += ';' + evarString;
				}
			}
			
			return s;
		};
	};

	// List of products to encode in Omniture data
	function ProductsList() {
		// Array containing products in list
		var list = [];
		
		// Adds the given product to this list
		this.add = function(/*Product*/ p) {
			list.push(p);
		};
		
		// Adds all the products in the given array to this list.
		this.addAll = function(/*Product[]*/ products) {
			for (var i = 0; i < products.length; i++) {
				this.add(products[i]);
			}
		};
		
		// Returns an IdSet representing the distinct events associated 
		// with products in this list
		this.getEventSet = function() {
			var events = new IdSet();
			for (var i = 0; i < list.length; i++) {
				events.addAll(list[i].getEventIDs());
			}
			return events;
		};
		
		// Returns an IdSet representing the distinct evars associated
		// with products in this list
		this.getEvarSet = function() {
			var evars = new IdSet();
			for (var i = 0; i < list.length; i++) {
				evars.addAll(list[i].getEvarIDs());
			}
			return evars;
		}
		
		// Returns an Omniture product string representing the products in this list
		this.getProductsString = function(imageRequestEvents) {
			var s = '';
			
			for (var i = 0; i < list.length; i++) {
				if (i > 0) {
					s += ',';
				}
				
				s += list[i].getProductString(imageRequestEvents);
			}
			
			return s;
		};
	};
	
	// Struct of data encapsulating data in a single image request
	function ImageRequest(/*object*/ context) {
		this.context = context;
		this.pageName = '';
		this.prop1 = '';
		this.prop2 = '';
		this.campaign = '';
		this.events = '';
		this.products = '';
		this.eVar1 = '';
		this.eVar5 = '';
		this.evarSet = null;
	};

	// Omniture submission engine
	// This is an abstraction of the contents of the "Core Javascript File" generated by Omniture
	function OmnitureEngine(/*object*/ context) {
		if (!context.enabled) {
			return;
		}
		
		/* SiteCatalyst code version: H.17.
		Copyright 1997-2008 Omniture, Inc. More info available at
		http://www.omniture.com */
		
		var s_account=context.repository
		var s=s_gi(s_account)
		/************************** CONFIG SECTION **************************/
		/* You may add or alter any code config here. */
		s.visitorID=context.visitorID;
		s.charSet=context.encoding
		/* Conversion Config */
		s.currencyCode=context.siteCurrency
		/* Link Tracking Config */
		s.trackDownloadLinks=true
		s.trackExternalLinks=true
		s.trackInlineStats=true
		s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls"
		s.linkInternalFilters="javascript:,."
		s.linkLeaveQueryString=false
		s.linkTrackVars="None"
		s.linkTrackEvents="None"
		
		/* WARNING: Changing any of the below variables will cause drastic
		changes to how your visitor data is collected.  Changes should only be
		made when instructed to do so by your account manager.*/
		s.visitorNamespace="demandware"
		s.dc=112
		
		/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
		var s_code='',s_objectID;function s_gi(un,pg,ss){var c="=fun@6(~){`Ks=^S~$h ~.substring(~.indexOf(~;@t~';`Bt`t~=new Fun@6(~.toLowerCase()~s_c_il['+s^sn+']~};s.~`m@t~.length~.toUpperCase~=new Object~s"
		+".wd~','~){@t~')q='~.location~var ~s.pt(~dynamicAccount~link~s.apv~='+@y(~)@tx^m!Object$eObject.prototype$eObject.prototype[x])~);s.~Element~.getTime()~=new Array~ookieDomainPeriods~s.m_~referrer~.p"
		+"rotocol~=new Date~BufferedRequests~}c$s(e){~visitor~;@X^js[k],255)}~=''~javaEnabled~conne@6^M~@0c_i~Name~:'')~onclick~}@t~else ~ternalFilters~javascript~s.dl~@Os.b.addBehavior(\"# default# ~=parseF"
		+"loat(~'+tm.get~=='~cookie~s.rep(~s.^T~track~o@0oid~browser~.parent~window~colorDepth~String~while(~.host~.lastIndexOf('~s.sq~s.maxDelay~s.vl_g~r=s.m(f)?s[f](~for(~s.un~s.eo~&&s.~parseInt(~t=s.ot(o)"
		+"~j='1.~#4URL~lugins~dynamicVariablePrefix~document~Type~Sampling~s.rc[un]~Download~Event~');~this~tfs~resolution~s.c_r(~s.c_w(~s.eh~s.isie~s.vl_l~s.vl_t~Height~t,h){t=t?t~tcf~isopera~ismac~escape(~"
		+".href~screen.~s.fl(~Version~harCode~&&(~_'+~variableProvider~s.pe~)?'Y':'N'~:'';h=h?h~._i~e&&l$HSESSION'~f',~onload~name~home#4~objectID~}else{~.s_~s.rl[u~Width~s.ssl~o.type~Timeout(~ction~Lifetime"
		+"~.mrq(\"'+un+'\")~sEnabled~;i++)~'){q='~&&l$HNONE'){~ExternalLinks~charSet~onerror~lnk~currencyCode~.src~s=s_gi(~etYear(~&&!~Opera~'s_~;try{~Math.~s.fsg~s.ns6~s.oun~InlineStats~Track~'0123456789~&&"
		+"t~s[k]=~s.epa(~m._d~n=s.oid(o)~,'sqs',q);~LeaveQuery~')>=~'=')~)+'/~){n=~\",''),~vo)~s.sampled~=s.oh(o);~+(y<1900?~s.disable~ingServer~n]=~true~sess~campaign~lif~if(~'http~,100)~s.co(~x in ~s.ape~f"
		+"fset~s.c_d~s.br~'&pe~s.gg(~s.gv(~s[mn]~s.qav~,'vo~s.pl~=(apn~Listener~\"s_gs(\")~vo._t~b.attach~d.create~=s.n.app~(''+~!='~'||t~'+n~s()+'~){p=~():''~a):f(~+1))~a['!'+t]~){v=s.n.~channel~un)~.target"
		+"~o.value~g+\"_c\"]~\".tl(\")~etscape~(ns?ns:~s_')t=t~k',s.bc~omePage~s.d.get~')<~||!~[b](e);~m[t+1](~return~mobile~height~events~random~code~'MSIE ~rs,~un,~,pev~floor(~atch~s.num(~[\"s_\"+~s.c_gd~s"
		+".dc~s.pg~,'lt~.inner~transa~;s.gl(~\"m_\"+n~idt='+~page~Group,~.fromC~sByTag~?'&~+';'~t&&~1);~){s.~[t]=~>=5)~[t](~=l[n];~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e^T)`w=s.cet('g^T^u`w,'g^Tet',s.g^Toe,'g^Tfb')}`2`w`Amrq`0u`1,l=@1],n,r;@1]=0`5l)^Bn=0;n<l`C;n++){r#Gs.mr(0,0,r.r,0,r.t,r.u)}`Abr`"
		+"0id,rs`1`5@m`a$e^W@Nbr',rs))$1l=rs`Aflush`a`0`1;s.fbr(0)`Afbr`0id`1,br=^V@Nbr')`5!br)br=$1l`5br`H!@m`a)^W@Nbr`G'`Rmr(0,0,br)}$1l=0`Amr`0@q,q,$oid,ta,u`1,dc=$w,t1=s.`x@n,t2=s.`x@nSecure,ns=s.`c`ispa"
		+"ce,un=u?u:$Ys.f$S,unc=`v$p'_`G-'),r`E,l,imn=@Ni^n($S,im,b,e`5!rs){rs=@u'+(@3?'s'`j+'://'+(t1?(@3@W2?t2:t1):($Y(@3?'102':unc))+'.'+($w?$w:112)+'.2o7.net')@fb/ss/'+^C+'/'+(s.$i?'5.1':'1'@fH.17/'+@q+'"
		+"?AQB=1&ndh=1'+(q?q`j+'&AQE=1'`5^Y@Ls.^f`H`O>5.5)rs=^j$o4095);`mrs=^j$o2047)`lid){$1(id,rs);$h}`ls.d.images&&`O>=3^m!s.^e||`O>=7)^m@R<0||`O>=6.1)`H!s.rc)s.rc`E`5!^O){^O=1`5!s.rl)s.rl`E;@1n]`U;set@5'"
		+"@t^1`hl)^1.`9@8',750)^zl=@1n]`5l){r.t=ta;r.u=un;r.r=rs;l[l`C]=r;`2''}imn+='^n^O;^O++}im=`F[imn]`5!im)im=`F[im@onew Image;im@0l=0;im.^v`7'e`G^S@0l=1`5^1`hl)^1.`9@8^Rim@I=rs`5rs`4$2=@d0^m!ta||ta`t_se"
		+"lf$Ia`t_top'||(`F.^w@Wa==`F.^w))){b=e`Z;^4!im@0l&&e`T-b`T<500)e`Z}`2''}`2'<im'+'g sr'+'c=\"'+rs+'\" width=1 $j=1 border=0 alt=\"\">'`Agg`0v`1`5!`F['s^nv])`F['s^nv]`e;`2`F['s^nv]`Aglf`0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+"c^E$E`S`Hd){@Z=1;@Zl=1`l@3)u=`vu,@u:`Ghttps:^Rf`7'e`G`9.m_a(\"$J+'\",\"'+g+'\")^R^d`7's`Gf`Gu`Gc`G`Ke,o=0@Oo=s.$E`S(\"script\")`5o){@4=\"text/`o\"`5f)o.^v=f;o@I=u;c.appendChild(o)}`bo=0}`2o^Ro=^d(s"
		+",f,u,c)}`mm=`Wi(n);m._e=1;`2m`Avo1`0t,a`Ha[t]||$P)^S#Da[t]`Avo2`0t,a`H#H{a#D^S[t]`5#H$P=1}`Adlt`7'`Ks=`9,d`Z,i,vo,f=0`5`pl)^Bi=0;i<`pl`C@A{vo=`pl[i]`5vo`H!`Wm(\"d\")||d`T-$C>=^8){`pl[i]=0;s.t(@i}`m"
		+"f=1}`l`pi)clear@5`pi`Rdli=0`5f`H!`pi)`pi=set@5`pt,^8)}`m`pl=0'`Rdl`0vo`1,d`Z`5!@ivo`E;`L^9,`G$72',@i;$C=d`T`5!`pl)`pl`U;`pl[`pl`C]=vo`5!^8)^8=250;`pt()`At`0vo,id`1,trk=1,tm`Z,sed=Math&&@P$l?@P$r@P$"
		+"l()*10000000000000):tm`T,@q='s'+@P$rtm`T/10800000)%10+sed,y=tm.g@K),vt=tm.getDate(@f`sMonth(@f'@ly+1900:y)+' `sHour$K:`sMinute$K:`sSecond$K `sDay()+' `sTimezoneO@z(),^d,^T=s.g^T(),ta`e,q`e,qs`e,$m`"
		+"e,vb`E#1^9`Runs()`5!s.td){`Ktl=^T`J,a,o,i,x`e,c`e,v`e,p`e,bw`e,bh`e,^H0',k=^W@Ncc`G@p',0^q,hp`e,ct`e,pn=0,ps`5^3&&^3.prototype){^H1'`5j.m$s){^H2'`5tm.setUTCDate){^H3'`5^Y^E^f&&`O#E^H4'`5pn.toPrecis"
		+"ion){^H5';a`U`5a.forEach){^H6';i=0;o`E;^d`7'o`G`Ke,i=0@Oi=new Iterator(o)`b}`2i^Ri=^d(o)`5i&&i.next)^H7'}}}}`l`O>=4)x=^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H';^a=^Z+',^o,$R,server,#4^M,#0@6ID,purchaseID,@r,state,zip,$k,products,`N`i,`N^M';^B`Kn=1;n<51;n++)^a+=',prop$J+',eVar$J"
		+"+',hier$J;^Z2=',^U,^2,`o^k,`f,`u@9,`z@2,`z^b,`g,^x,pe$q1$q2$q3,p^J';^a+=^Z2;^9=^a+',$i,`c^N,`c^N#5`MSele@6,`MList,`MM$s,`x^PLinks,`x@D,`x@T,`N@c^3,`N^PFile^Ms,`NEx`n,`NIn`n,`N@UVa$o`N@U^Qs,`N`is,@G"
		+",eo';$x=pg#1^9)`5!ss)`Fs()",
		w=window,l=w.s_c_il,n=navigator,u=n.userAgent,v=n.appVersion,e=v.indexOf('MSIE '),m=u.indexOf('Netscape6/'),a,i,s;if(un){un=un.toLowerCase();if(l)for(i=0;i<l.length;i++){s=l[i];if(s._c=='s_c'){if(s.oun==un)return s;else if(s.fs&&s.sa&&s.fs(s.oun,un)){s.sa(un);return s}}}}
		w.s_r=new Function("x","o","n","var i=x.indexOf(o);if(i>=0&&x.split)x=(x.split(o)).join(n);else while(i>=0){x=x.substring(0,i)+n+x.substring(i+o.length);i=x.indexOf(o)}return x");
		w.s_d=new Function("x","var t='`^@$#',l='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',d,n=0,b,k,w,i=x.lastIndexOf('~~');if(i>0){d=x.substring(0,i);x=x.substring(i+2);while(d){w=d;i"
		+"=d.indexOf('~');if(i>0){w=d.substring(0,i);d=d.substring(i+1)}else d='';b=(n-n%62)/62;k=n-b*62;k=t.substring(b,b+1)+l.substring(k,k+1);x=s_r(x,k,w);n++}for(i=0;i<5;i++){w=t.substring(i,i+1);x=s_r(x"
		+",w+' ',w)}}return x");
		w.s_fe=new Function("c","return s_r(s_r(s_r(c,'\\\\','\\\\\\\\'),'\"','\\\\\"'),\"\\n\",\"\\\\n\")");
		w.s_fa=new Function("f","var s=f.indexOf('(')+1,e=f.indexOf(')'),a='',c;while(s>=0&&s<e){c=f.substring(s,s+1);if(c==',')a+='\",\"';else if((\"\\n\\r\\t \").indexOf(c)<0)a+=c;s++}return a?'\"'+a+'\"':"
		+"a");
		w.s_ft=new Function("c","c+='';var s,e,o,a,d,q,f,h,x;s=c.indexOf('=function(');while(s>=0){s++;d=1;q='';x=0;f=c.substring(s);a=s_fa(f);e=o=c.indexOf('{',s);e++;while(d>0){h=c.substring(e,e+1);if(q){i"
		+"f(h==q&&!x)q='';if(h=='\\\\')x=x?0:1;else x=0}else{if(h=='\"'||h==\"'\")q=h;if(h=='{')d++;if(h=='}')d--}if(d>0)e++}c=c.substring(0,s)+'new Function('+(a?a+',':'')+'\"'+s_fe(c.substring(o+1,e))+'\")"
		+"'+c.substring(e+1);s=c.indexOf('=function(')}return c;");
		c=s_d(c);if(e>0){a=parseInt(i=v.substring(e+5));if(a>3)a=parseFloat(i)}else if(m>0)a=parseFloat(u.substring(m+10));else a=parseFloat(v);if(a>=5&&v.indexOf('Opera')<0&&u.indexOf('Opera')<0){w.s_c=new Function("un","pg","ss","var s=this;"+c);return new s_c(un,pg,ss)}else s=new Function("un","pg","ss","var s=new Object;"+s_ft(c)+";return s");return s(un,pg,ss)}
		
		// Returns the object used to submit the initial image request for a page
		this.getSubmissionObject = function() {
			return s;
		};
	};
	
	// Adapter of DW collected data to Omniture image request submissions
	function OmnitureAdapter(/*object*/ collectedData) {
		var that = this;
	
		// Array of pending image requests
		var imageRequests = [];
		
		// Returns the given products string, formatted to fit in an alert debug
		var formatProductsStringForDebug = function(/*string*/ products) {
			if ((products == null) || (products.length <= 50)) {
				return products;
			}

			var p = products.split(/,/);
			
			var s = '';
			var ps = '';
			for (var i = 0; i < p.length; i++) {
				if (i > 0) {
					ps += ',';
				}
				
				ps += p[i];
			
				if (ps.length > 50) {
					s += ps + '\n';
					ps = '';
				}
			}

			return s + ps;
		};

		// Submits collected data using the standard code-to-paste approach
		var submitPageData = function(/*ImageRequest*/ request) {
			var s = OMNITURE.getSubmissionObject();
			
			/* You may give each page an identifying name, server, and channel on
			the next lines. */
			s.pageName = request.pageName;
			s.visitorID = request.context.visitorID;
			s.prop1 = request.prop1;
			s.prop2 = request.prop2;
			/* Conversion Variables */
			s.campaign = request.campaign;
			s.events = request.events;
			s.products = request.products;
			s.eVar1 = request.eVar1;
			s.eVar5 = request.eVar5;
			/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
			var s_code=s.t();if(s_code)document.write(s_code)
			//if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
			/*<!-- End SiteCatalyst code version: H.17. -->*/
			
			if (isDebugEnabled()) {
				var text = 's.s_account="' + request.context.repository + '"\n'; 
				text += 's.pageName="' + request.pageName + '"\n';
				text += 's.visitorID="' + request.context.visitorID + '"\n';
				text += 's.prop1="' + request.prop1 + '"\n';
				text += 's.prop2="' + request.prop2 + '"\n';
				text += 's.campaign="' + request.campaign + '"\n';
				text += 's.events="' + request.events + '"\n';
				text += 's.products="' + formatProductsStringForDebug(request.products) + '"\n';
				text += 's.eVar1="' + request.eVar1 + '"\n';
				text += 's.eVar5="' + request.eVar5 + '"\n';
				
				alert(text);
			}
		};
		
		// Submits the given image request using a custom link
		var submitCustomLink = function(/*ImageRequest*/ request) {
			// Add hardcoded variables to the ones already associated with products
			var evars = request.evarSet;
			evars.add('eVar1');
			evars.add('eVar5');
			evars.add('events');
			evars.add('products');
			var evarsToTrack = evars.getIdsString();
			
			var s = OMNITURE.getSubmissionObject();
			s.linkTrackVars = evarsToTrack;
			s.linkTrackEvents = request.events;
			s.visitorID = request.context.visitorID;
			s.eVar1 = request.eVar1;
			s.eVar5 = request.eVar5;
			s.events = request.events;
			s.products = request.products;
			s.tl(null, 'o', '__internal');
			
			if (isDebugEnabled()) {
				var text = 's.s_account="' + request.context.repository + "'\n"; 
				text += 's.linkTrackVars="' + evarsToTrack + '"\n';
				text += 's.linkTrackEvents="' + request.events + '"\n';
				text += 's.visitorID="' + request.context.visitorID + '"\n';
				text += 's.eVar1="' + request.eVar1 + '"\n';
				text += 's.eVar5="' + request.eVar5 + '"\n';
				text += 's.events="' + request.events + '"\n';
				text += 's.products="' + formatProductsStringForDebug(request.products) + '"\n';
				
				alert(text);
			}
		};
	
		// Submits pending image requests to Omniture
		this.submit = function() {
			for (var i = 0; i < imageRequests.length; i++) {
				if (firstSubmissionForPage) {
					submitPageData(imageRequests[i]);
					firstSubmissionForPage = false;
				}
				else {
					submitCustomLink(imageRequests[i]);
				}
			}
		};
		
		// Returns an array of ProductList objects representing all of the product information
		// that has been collected and is pending submission
		var createProductsLists = function() {
			var products = [];
			
			// Create Product objects for impressions
			var entries = collectedData.productImpressions.getEntries();
			for (var i = 0; i < entries.length; i++) {
				var pi = entries[i].value;
				
				var p = new Product(pi.id);
				p.putEvent('event3', 1);
	
				// Skip category evar if not collected on page
				if (collectedData.pageInfo.category != '') {
					p.putEvar('evar2', collectedData.pageInfo.category);
				}
				
				products.push(p);
			}
	
			// Create Product objects for recommendations
			var entries = collectedData.productRecommendations.getEntries();
			for (var i = 0; i < entries.length; i++) {
				var pr = entries[i].value;
				
				var p = new Product(pr.id);
				p.putEvent('event3', 1);
				p.putEvar('evar4', 'Yes');
	
				// Skip category evar if not collected on page
				if (collectedData.pageInfo.category != '') {
					p.putEvar('evar2', collectedData.pageInfo.category);
				}
	
				products.push(p);
			}

			// Create Product objects for views	
			var entries = collectedData.productViews.getEntries();
			for (var i = 0; i < entries.length; i++) {
				var pv = entries[i].value;
	
				var p = new Product(pv.id);
				p.putEvent('event4', 1);
	
				// Skip category evar if not collected on page
				if (collectedData.pageInfo.category != '') {
					p.putEvar('evar2', collectedData.pageInfo.category);
				}
	
				products.push(p);
			}
			
			// Create array of ProductList objects, suitably chunked
			var list = [];
			
			var i = 0;
			while (i < products.length) {
				var p = new ProductsList();
				list.push(p);

				// Determine products count for this element of the list
				var count = CHUNK_PRODUCTS_PER_IMAGE_REQUEST;
				if (products.length - i <= MAX_PRODUCTS_PER_IMAGE_REQUEST) {
					count = MAX_PRODUCTS_PER_IMAGE_REQUEST;
				}
				
				// Trim count to number of remaining products, if necessary
				if (count > products.length - i) {
					count = products.length - i;
				}
				
				// Add products to this element of the list
				for (var j = 0; j < count; j++) {
					p.add(products[i]);
					i++;
				}
			};
			
			return list;
		};
	
		// Constructor
		(new function() {
			var productsLists = createProductsLists();
			
			for (var i = 0; i < productsLists.length; i++) {
				var productsList = productsLists[i];
				var eventSet = productsList.getEventSet();
			
				var imageRequest = new ImageRequest(analyticsContext);
				imageRequest.pageName = '__internal';
				imageRequest.prop2 = collectedData.pageInfo.category;
				imageRequest.campaign = analyticsContext.sourceCode;
				imageRequest.events = eventSet.getIdsString();
				imageRequest.products = productsList.getProductsString(eventSet);
				imageRequest.eVar1 = analyticsContext.customer;
				imageRequest.eVar5 = analyticsContext.visitorID;
				imageRequest.evarSet = productsList.getEvarSet();
		
				imageRequests.push(imageRequest);
			}
		}());
	};
	
	// Returns an Omniture data submission adapter
	function createAdapter(/*object*/ collectedData) {
		return new OmnitureAdapter(collectedData);
	}
	
	// **************************
	// END OMNITURE SPECIFIC CODE
	// **************************

	// Map data structure
	function Map() {
		var data = [];
		
		// Returns an array containing the entries in this map
		this.getEntries = function() {
			return data;
		};

		// Puts the given value in this map under the given key
		this.put = function(/*object*/ key, /*object*/ value) {
			for (var i = 0; i < data.length; i++) {
				if (data[i].key == key) {
					data[i].value = value;
					return;
				}
			}
			
			data.push({key: key, value: value});
		};
		
		// Puts all the key value pairs in the given map into this map
		this.putAll = function(/*Map*/ map) {
			var entries = map.getEntries();
			for (var i = 0; i < entries.length; i++) {
				this.put(entries[i].key, entries[i].value);
			}
		};
		
		// Returns the value in this map under the given key, or null if there is no such value
		this.get = function(/*object*/ key) {
			for (var i = 0; i < data.length; i++) {
				if (data[i].key == key) {
					return data[i].value;
				}
			}
			
			return null;
		};
		
		// Clears this map of entries
		this.clear = function() {
			while (data.length > 0) {
				data.pop();
			}
		};
		
		// Returns if this map is empty of values 
		this.isEmpty = function() {
			return data.length > 0;
		}
	};

	// Delay in milliseconds before actually submitting data once some is ready
	var SUBMIT_DELAY_MILLIS = 500;
	
	// Product search hit type
	var PRODUCT_SEARCHHIT = 'PRODUCT_SEARCHHIT';
	
	// Product detail type
	var PRODUCT_DETAIL = 'PRODUCT_DETAIL';
	
	// Product recommendation type
	var PRODUCT_RECOMMENDATION = 'PRODUCT_RECOMMENDATION';

	// Product set product type
	var PRODUCT_SETPRODUCT = 'PRODUCT_SETPRODUCT';
	
	// Set when the DOM is ready
	var domReady = false;
	
	// Timeout to submit data after a delay
	var submitTimeout = null;
	
	// Captured page information
	var pageInfo = {
		category: ''
	};

	// Product impressions found on the page
	var productImpressions = new Map();

	// Product views found on the page
	var productViews = new Map();

	// Product recommendations found on the page
	var productRecommendations = new Map();

	// Applies values from the given source for fields defined in the given target
	function applyFields(/*object*/ source, /*object*/ target) {
		for (e in target) {
			if (typeof source[e] != 'undefined') {
				target[e] = source[e];
			}
		}
		return target;
	};

	// Collects the given product impression, and returns true if it is valid or false if it is not
	var collectProductImpression = function(/*object*/ configs) {
		// Quit if analytics collection turned off for this page
		if (!analyticsContext.enabled) {
			return;
		}
	
		if (typeof configs != 'object') {
			return false;
		}
		
		var pi = applyFields(configs, {id:null});

		// Quit if no SKU provided or is invalid	
		if (typeof pi.id != 'string') {
			return false;
		}
		
		// Throw out the impression if SKU already seen
		var previousImpression = productImpressions.get(pi.id);
		if (previousImpression != null) {
			return false;
		}

		productImpressions.put(pi.id, pi);
		return true;
	};

	// Collects the given product recommendation, and returns true if it is valid or false if it is not
	var collectProductRecommendation = function(/*object*/ configs) {
		// Quit if analytics collection turned off for this page
		if (!analyticsContext.enabled) {
			return;
		}

		if (typeof configs != 'object') {
			return false;
		}
		
		var pr = applyFields(configs, {id:null});

		// Quit if no SKU provided or is invalid	
		if (typeof pr.id != 'string') {
			return false;
		}
		
		// Throw out the recommendation if SKU already seen
		var previousRecommendation = productRecommendations.get(pr.id);
		if (previousRecommendation != null) {
			return false;
		}

		productRecommendations.put(pr.id, pr);
		return true;
	};

	// Collects the given product view, and returns true if it is valid or false if it is not
	var collectProductView = function(/*object*/ configs) {
		// Quit if analytics collection turned off for this page
		if (!analyticsContext.enabled) {
			return;
		}

		if (typeof configs != 'object') {
			return false;
		}
		
		var pv = applyFields(configs, {id:null});

		// Quit if no SKU provided or is invalid	
		if (typeof pv.id != 'string') {
			return false;
		}

		// Throw out the view if SKU already seen
		var previousView = productViews.get(pv.id);
		if (previousView != null) {
			return false;
		}

		productViews.put(pv.id, pv);
		return true;
	};

	// Collects the given information about the page
	var collectContextInformation = function(/*object*/ configs) {
		// Quit if analytics collection turned off for this page
		if (!analyticsContext.enabled) {
			return;
		}

		if (typeof configs != 'object') {
			return;
		}
		
		var info = {};
		
		// Copy collected category if valid
		if (typeof configs.category == 'string') {
			info.category = configs.category;
		}

		applyFields(info, pageInfo);
	};
	
	// Returns a new Map with the same contents as the given Map,
	// clearing the given Map in the process
	function copyAndClearMap(/*Map*/ map) {
		var copy = new Map();
		copy.putAll(map);
		map.clear();
		return copy;
	};
	
	// Returns if there are collected data to submit
	function containsDataToSubmit() {
		return !productImpressions.isEmpty() || !productRecommendations.isEmpty()
			|| !productViews.isEmpty();
	};
	
	// Performs the actual submission of collected data for analytics processing
	var performDataSubmission = function() {
		// Quit if no data to submit
		if (!containsDataToSubmit()) {
			return;
		}

		var collectedData = {
			pageInfo: pageInfo,
			productImpressions: copyAndClearMap(productImpressions),
			productViews: copyAndClearMap(productViews),
			productRecommendations: copyAndClearMap(productRecommendations)
		};
		
		var adapter = createAdapter(collectedData);
		adapter.submit();
	};
	
	// Submits the collected data for analytics processing after a short delay
	function submitCollectedData() {
		// Quit if analytics collection turned off for this page
		if (!analyticsContext.enabled) {
			if (isDebugEnabled()) {
				alert('Analytics data collection is disabled');
			}
		
			return;
		}
		
		// Quit if no data to submit
		if (!containsDataToSubmit()) {
			return;
		}

		if (submitTimeout) {
			clearTimeout(submitTimeout);
		}

		submitTimeout = setTimeout('dw.__ac.tx()', SUBMIT_DELAY_MILLIS);
	}
	
	// Captures a product impression rendered by an ISML tag
	var captureISMLProductImpression = function(configs) {
		collectProductImpression(configs);
		submitCollectedData();
	}

	// Captures a product view rendered by an ISML tag
	var captureISMLProductView = function(configs) {
		collectProductView(configs);
		submitCollectedData();
	}

	// Captures a product recommendation rendered by an ISML tag
	var captureISMLProductRecommendation = function(configs) {
		collectProductRecommendation(configs);
		submitCollectedData();
	}

	// Returns an object with the same properties as the given object, but with string type properties
	// in the given array of names set to the URL encoded form of their values using the escape function
	function escapeProperties(/*object*/ o, /*Array*/ props) {
		if (typeof o == 'undefined') {
			return;
		}
		
		var copy = {};
		for (e in o) {
			var escapeProp = false;
			for (var i = 0; (i < props.length) && !escapeProp; i++) {
				var prop = props[i];
				if ((e === prop) && (typeof o[prop] == 'string')) {
					escapeProp = true;
				}
			}
			
			copy[e] = escapeProp ? urlencode(o[e]) : o[e];
		}
		
		return copy;
	};
	
	// Applies values to the context for subsequent events that occur on the page
	var applyContext = function(/*object*/ configs) {
		if (typeof configs != 'object') {
			return;
		}
		
		collectContextInformation(escapeProperties(configs, ['category']));
	};
	
	// Captures the given object data collected in subsequent events on the page,
	// and returns true if the given object data is valid, or returns false if not
	function captureObject(/*object*/ configs) {
		if (typeof configs != 'object') {
			return false;
		}
		
		if ((configs.type === PRODUCT_SEARCHHIT) || (configs.type === PRODUCT_SETPRODUCT)) {
			return collectProductImpression(escapeProperties(configs, ['id']));
		}

		if (configs.type === PRODUCT_DETAIL) {
			return collectProductView(escapeProperties(configs, ['id']));
		}

		if (configs.type === PRODUCT_RECOMMENDATION) {
			return collectProductRecommendation(escapeProperties(configs, ['id']));
		}
		
		return false;
	}

	// Captures the given data collected in subsequent events on the page
	var capture = function(/*object*/ configs) {
		if (typeof configs == 'undefined') {
			return;
		}
		
		// Support both array and single object cases
		if (typeof configs === 'object') {
			if (configs instanceof Array) {
				for (var i = 0; i < configs.length; i++) {
					captureObject(configs[i]);
				}
			}
			else {
				captureObject(configs);
			}
		}
		
		// Submit captured data if appropriate
		if (domReady) {
			submitCollectedData();
		}
	};

	// Chain the submission function to run when the DOM is ready
	dw$(document).ready(function() {
		domReady = true;
		submitCollectedData();
	});
	
	// Construct the __ac namespace object
	dw.__ac = {
		page: collectContextInformation,
		pi: captureISMLProductImpression,
		pv: captureISMLProductView,
		pr: captureISMLProductRecommendation,
		tx: performDataSubmission
	};

	// Construct the ac namespace object
	dw.ac = {
		EV_PRD_SEARCHHIT: PRODUCT_SEARCHHIT,
		EV_PRD_DETAIL: PRODUCT_DETAIL,
		EV_PRD_RECOMMENDATION: PRODUCT_RECOMMENDATION,
		EV_PRD_SETPRODUCT: PRODUCT_SETPRODUCT,
		applyContext: applyContext,
		capture: capture,
		setDebugEnabled: setDebugEnabled
	};
}()); 
