	/*
		Parameters:		
		p			- page (PDP, PWP, etc)
		ll			- lang_locale
		ct			- country
		
		--PDP Params:
		pid			- productId
		cid			- catalogId
		pgid		- productGroupId
		
		--PDPiD Params:
		piid		- productInstanceId
		pbid		- prebuildId
		path		- pathName
		metricsId	- metricsId
		
		--PWP Params:
		pn			- pageNumber
		so			- sortOrder
		hf			- hiddenFacets
		sl			- searchList
		sf			- selectedFacets
		fe			- facetEnabled
		
		--DS Params:
		pn			- pageNumber
		so			- sortOrder
		sl			- searchList
		sf			- selectedFacets
		iso			- inStockOnly
		ph			- primaryHex
		pr			- primaryRange
		sh			- secondaryHex
		sr			- secondaryRange
		r			- range
		
		--DD Params:
		metricId	- metricsId

	*/

	function NikeCommerce()
	{
		var self = this;
		var title = document.title.replace(/#.*/, '');
		
		this.init=function()
		{
			if(JQ("div#NIKE_COMMERCE").length==0)
				return false;
				
			if (self.commerce_mode == 0) return;
			
			//--param handling
			self.splitParams();
			
			self.setFQDN(); 
			
			if(!self.cookie_check)
				return;
			
			self.handlePage();
			
			setInterval(function() { self.hashListener(); }, 50);
		};
		this.preInit=function()
		{
			self.params={};
			self.setConfigBase();

			//--param related
			self.buildParamLookupTable();
			self.loadParameters();
			self.getUnrelatedParameters();
			
			self.mergeConfigs();
			
			//--remove initial tracking call:		
			if(typeof self.params.page != 'undefined')
				page_tracker_obj.do_not_call=true;
			
			//--locale related
			self.cookie_check=self.handleLocale();
						
			self.commerce_mode=0;
			self.commerce_mode=self.determineCommerceRegion(self.params.country,self.params.lang_locale);
			
			// -- temporary commerce shutoff:
			self.commerce_disabled=false;
			/*if(typeof serverTime != 'undefined' && self.commerce_mode!=0){
				serverTimeDate=serverTimeToDate(serverTime);
				var startTime=serverTimeToDate("2009-07-25T03:00:00-04:00");
				var endTime=serverTimeToDate("2009-07-26T07:00:00-04:00");
				if(serverTimeDate.valueOf()>startTime.valueOf() && serverTimeDate.valueOf()<endTime.valueOf()){
					self.commerce_mode=0;
					self.commerce_disabled=true;
				}
			}*/
			
			if (self.commerce_mode == 2 || self.commerce_mode == 3) self.config.siteId = self.config.siteId_EMEA;
		    if (self.commerce_mode == 2 || self.commerce_mode == 3) self.config.membershipId = self.config.membershipId_EMEA;
						
			//-- if not commerce mode, drop commerce nodes from the nav:
			if(self.commerce_mode==0||self.commerce_mode=='0')
			{
				JQ("#nav div[commerce_dependant='true']").remove();
				JQ("#nav div[id_dependant='true']").remove();
			}
			else if (self.commerce_mode==3||self.commerce_mode=='3')
			{
				JQ("#nav div[commerce_dependant='true']").remove();
			}
			
			if(!self.cookie_check)
				return;
			self.setRegionalParameters();
		};
		this.mergeConfigs=function()
		{
			//--base config object
			var config=
			{
				title:					"Nike Commerce",
				siteId:					"28",
				site:					'nikestore',
				userType:				"defaultUser",
				languageTunnelURL:		"#LANGUAGE_TUNNEL",
				configBaseURL:			"/nikeos/site/nikeprototype/global/xml/commerce/",
				localConfigPath:		null,
				US_Catalog:				"101101",
				EMEA_Catalog:			"102001",
				commerceNavTabs:		["shop"],
				categoryHeadersEnabled:	'false',
				membershipId:			0,
				commerceBaseURL:		'commerce',
				registerPath:			escape("nikeos/p/nikewomen/${LANG_LOCALE}/profile?page=register&fields=&continueURL=profile%3Fpage%3Dpersonal_info"),
				hash:					false,
				idEmailPrivacyPath:		escape("/renov/nikestore/us/v1/us/en/info/privacy.jsp?item=terms"),
				idEmailFeedbackPath:	escape("/renov/nikestore/us/v1/us/en/info/help.jsp?item=contact"),
				siteFolder:				location.href.split('/')[5]
			};
			
			if (typeof NIKE_COMMERCE_CONFIG != "undefined" && typeof NIKE_COMMERCE_CONFIG.configBaseURL != "undefined")
				config.configBaseURL = NIKE_COMMERCE_CONFIG.configBaseURL;
			
			//--individual module config objects
			//config.pdp={configPath:self.getConfigBase()+"/nikestore/testing/web/commerce/xml/inlinepdp_config.xml"};
			config.pdp={configPath:config.configBaseURL+"inlinepdp_config.xml"};
			config.nikeid=
			{
				configPath:				config.configBaseURL+"nikeid_config.xml",
				//buildConfigPath:		config.configBaseURL+"build_config_"+self.params.lang_locale+".xml",
				emailPath:				config.configBaseURL+"emailForm_config.xml",
				siteURL:				escape(document.location),
				itemReturnURL:			escape(document.location),
				idEmailMyDesignPath:	escape(document.location.toString().substring(
											document.location.toString().indexOf("/nikeos/"),
											document.location.toString().indexOf("?")
										)+"?p=PDPiD&path="+self.params.pathName+"&metricsId=${metricId}")
			};
			config.pwp=
			{
				configPath:			config.configBaseURL+"wall_config.xml",
				inStockOnly:		"true",
				numItemsPerPage:	"48",
				hiddenFacets:		""
			};

			config.minipdp=
			{
				configPath:			config.configBaseURL+"minipdp_config_nikestore.xml",
				productGroupId:		"110787",
				productId:			"153142"
			};
			config.minicart=
			{
				configPath:			config.configBaseURL+"minicart_config.xml",
				loginPath:			config.configBaseURL+"login_config.xml",
				storeReturnURL:		escape(document.location)
			};
			config.mylocker=
			{
				configPath:			config.configBaseURL+"myLocker_config.xml",
				loginPath:			config.configBaseURL+"login_config.xml",
				emailPath:			config.configBaseURL+"emailForm_config.xml",
				storeReturnURL:		escape(document.location)
			};
			config.orderstatus=
			{
				configPath:			config.configBaseURL+"orderStatus_config.xml",
				loginPath:			config.configBaseURL+"login_config.xml",
				emailPath:			config.configBaseURL+"emailForm_config.xml",
				storeReturnURL:		escape(document.location)
			};
			config.collection=
			{
				configPath:			config.configBaseURL+"collection_config.xml"
			};
			config.designsearch=
			{
				configPath:			config.configBaseURL+"designsearch_config.xml",
				loginPath:			config.configBaseURL+"login_config.xml"
			};

			if(typeof NIKE_COMMERCE_CONFIG == 'undefined')
				self.config=config;
			else
				self.config=JQ.extend(true,{},config,NIKE_COMMERCE_CONFIG);
			/*
			if (self.params.title && self.params.title != '')
				self.config.title = self.params.title;
				*/
			
			//if (typeof NIKE_COMMERCE_CONFIG!="undefined" && typeof NIKE_COMMERCE_CONFIG.DETERMINE_COMMERCE_REGION != "undefined")
			//	self.determineCommerceRegion=eval(JQ.trim(NIKE_COMMERCE_CONFIG.DETERMINE_COMMERCE_REGION));
			
			if (JQ.browser.msie && JQ.browser.version < 7) self.config.hash = false;

			if(location.href.indexOf('nke6')!=-1 && location.href.indexOf('en_EMEA')!=-1)
				self.config.registerPath = "nikeos/p/nke6/en_EMEA/profile?page=register&fields=&continueURL=profile%3Fpage%3Dpersonal_info";
		};
		this.getLocaleData=function(){
			return {
				'locale':self.params.lang_locale,
				'country':self.params.country
			};
		};
		//--region detection
		this.determineCommerceRegion=function(country,lang_locale)
		{
			if(typeof self.config.DETERMINE_COMMERCE_REGION == "undefined" || typeof self.config.DETERMINE_COMMERCE_REGION[lang_locale]=="undefined" || typeof self.config.DETERMINE_COMMERCE_REGION[lang_locale][country]=="undefined")
				return 0;
			var mode=self.config.DETERMINE_COMMERCE_REGION[lang_locale][country];
			return parseInt(mode,10);
		};
		this.setRegionalParameters=function()
		{
			if(self.commerce_mode==1)
			{
				self.params.catalogs=self.config.US_Catalog;
				/*
				if(self.config.pwp.hiddenFacets.length==0)
					self.config.pwp.hiddenFacets="10001";
				*/
			}
			if(self.commerce_mode==2 || self.commerce_mode==3)
			{
				self.params.catalogs=self.config.EMEA_Catalog;
				/*
				if(self.config.pwp.hiddenFacets.length==0)
					self.config.pwp.hiddenFacets="788";
				*/
			}
		};
		//--make mandatoryParams
		this.splitParams=function()
		{
			//--params to be used across all pages
			var mandatoryParams=['lang_locale','country'];
			self.mandatoryParams={};
			for(var i=0;i<mandatoryParams.length;i++)
				self.mandatoryParams[self.paramLookup(mandatoryParams[i])]=self.params[mandatoryParams[i]];

			//--params to be used in all flash embeds:
			var mandatoryFlashParams=['lang_locale','country','catalogs'];
			self.mandatoryFlashParams={};
			for(var i=0;i<mandatoryFlashParams.length;i++)
				self.mandatoryFlashParams[mandatoryFlashParams[i]]=self.params[mandatoryFlashParams[i]];
			
			//--add tracking json object to all flash modules:
			if (typeof tracking != "undefined" && typeof nav_tracker_obj != "undefined") {
				if ( tracker_obj && tracker_obj.prop50 ) {
					if (tracker_obj.prop50 == 'LOGGED_IN_ID' || tracker_obj.prop50 == null)
						nav_tracker_obj.prop50 = (tracking.logged_in_id != '') ? tracking.logged_in_id : '';
					//nav_tracker_obj.prop50 = tracker_obj.prop50;
				 }
				if ( tracker_obj && tracker_obj.eVar4 ) nav_tracker_obj.eVar4 = tracker_obj.eVar4;
				self.mandatoryFlashParams.trackingData=tracking.flash(nav_tracker_obj);
			}
		};
		
		this.hashListener=function()
		{
			// IE appends hash info to the document's title, screw that
			if (JQ.browser.msie) document.title = title;
			if (!self.config.hash) return;
			
			if(!self.hash)
			{
				self.hash=location.hash;
				return;
			}
			
			if(location.hash!=self.hash)
			{
				//--in the PWP & DS, we use the setState instead of the redraw...
				if(getParam("p","hash")==self.params.page)
				{
					//--reload the hash:
					self.params = {};
					self.loadParameters();
					switch(self.params.page)
					{
						case "TEE":
						case "PWP":		var data=
										{
											catalogs:self.params.catalogs,
											hiddenFacets:self.params.hiddenFacets,
											id:"productWallChange",
											pageNumber:self.params.pageNumber,
											searchList:self.params.searchList,
											selectedFacets:self.params.selectedFacets,
											sortOrder:self.params.sortOrder,
											title:((self.params.title)?unescape(self.params.title):self.config.title)
										};
										break;
										
						case "DS":		var data=
										{
											catalogs:self.params.catalogs,
											id:"dsWallChange",
											pageNumber:self.params.pageNumber,
											searchList:self.params.searchList,
											selectedFacets:self.params.selectedFacets,
											sortOrder:self.params.sortOrder,
											inStockOnly:self.params.inStockOnly,
											primaryHex:self.params.primaryHex,
											primaryRange:self.params.primaryRange,
											secondaryHex:self.params.secondaryHex,
											secondaryRange:self.params.secondaryRange,
											range:self.params.range
										};
										break;
					}
					if (data)
					{
						for(var p in data)
						{
							if(typeof data[p]=="string")
								data[p]=data[p].replace(/%2B/g,"+");
						}
						
						var e={};
						e.type="setState";
						e.data=data;
						EventBridge.dispatchEvent(e);
						scroll(0,0);
					}
					else
					{
						self.rebuild();
					}
					//self.rebuild();
				}
				else {
					self.rebuild();
				}
				self.hash = location.hash;
			}
		};
		
		this.rebuild=function()
		{
			self.destruct();
			self.preInit();
			self.init();
		};
		
		this.destruct=function()
		{
			if(self.page)
			{
				self.page.destruct();
				delete self.page;
			}
			
			for(var p in self)
			{
				if(typeof self[p] != 'function' && p!='miniCart')
					delete self[p];
			}
		};
		
		//--check cookie/hash/querystring values for lang_locale and country and set whats missing
		this.handleLocale=function()
		{
			var overwriteLocaleCookies=false;
			//if(typeof site_data != 'undefined' && typeof site_data.settings != 'undefined' /*&& site_data.settings.platypus_lang_locale!='en_EMEA'*/)
			//	overwriteLocaleCookies=true;

			if(!self.params.lang_locale || !self.params.country || overwriteLocaleCookies)
			{
				if(!JQ.cookie('NIKE_COMMERCE_LANG_LOCALE') || !JQ.cookie('NIKE_COMMERCE_COUNTRY') || overwriteLocaleCookies)
				{
					//redirect
					//if(self.params.page)
					//	location.href=self.config.languageTunnelURL;
					//return false;
					var lang_locale=location.href.substring(location.href.indexOf('/nikeos/p/')+10,location.href.length).split('/')[1];
					
					if(typeof site_data!='undefined' && typeof site_data.settings!='undefined')
						lang_locale=site_data.settings.platypus_lang_locale;
					
					if(lang_locale=='blogs' && (typeof site_data=='undefined' || typeof site_data.settings!='undefined'))
						lang_locale='en_US';

					var ct=lang_locale.split('_')[1];
					var k;
					var cr=self.config.DETERMINE_COMMERCE_REGION;
					
					if(typeof cr[lang_locale]!='undefined')
					{
						self.params.lang_locale=lang_locale;
						if(typeof cr[lang_locale][ct]!='undefined')
							self.params.country=ct;
					}
					
					if(!self.params.lang_locale || !self.params.country)
					{
						if(typeof site_data=='undefined' || typeof site_data.settings=='undefined')
							location.href = NIKEOS.BASE[NIKEOS.site_mode] + self.config.languageTunnelURL;
						return false;
					}
				}
				else
				{
					self.params.lang_locale=JQ.cookie('NIKE_COMMERCE_LANG_LOCALE');
					self.params.country=JQ.cookie('NIKE_COMMERCE_COUNTRY');
					if(self.params.page) {
						if (location.href.indexOf('#') < 0) {
							location.href=location.href+"#?ll="+self.params.lang_locale+"&ct="+self.params.country;
						}
						else {
							location.href=location.href+"&ll="+self.params.lang_locale+"&ct="+self.params.country;
						}
					}
					//location.href="#"+self.stringify(self.params);
				}
			}
			
			if(!JQ.cookie('NIKE_COMMERCE_LANG_LOCALE') || !JQ.cookie('NIKE_COMMERCE_COUNTRY'))
			{
				if(!self.params.lang_locale || !self.params.country)
					return false;
				JQ.cookie('NIKE_COMMERCE_LANG_LOCALE',self.params.lang_locale,{path:'/',domain:self.getDomain()});
				JQ.cookie('NIKE_COMMERCE_COUNTRY',self.params.country,{path:'/',domain:self.getDomain()});
			}
			return true;
		};
		
		//--returns the current domain
		this.getDomain=function()
		{
			var d='';
			if (location.href.toString().indexOf('nike.com')>=0) d='nike.com';
			else if (location.href.toString().indexOf('rga.com')>=0) d='rga.com';
			return d;
		};
		
		//--put all params into self.params (hash has higher priority than query string)
		this.loadParameters=function()
		{
			var temp;
			for(var p in self.paramLookupTable)
			{
				temp=getParam(p,'hash') || getParam(p,'query_string') || false;
				if(temp)
					self.params[self.paramLookup(p)]=temp.replace(/\^/g,"%2B");
			}
		};
		//--translates between abbreviated and non-abbreviated
		this.paramLookup=function(param)
		{
			if(self.paramLookupTable[param])
				return self.paramLookupTable[param];
			return false;
		};	
		this.buildParamLookupTable=function()
		{
			var params={};
			params.ll="lang_locale";
			params.ct="country";
			params.c="catalogs";
			params.p="page";
			
			//--PDP Params:
			params.pid="productId";
			params.cid="catalogId";
			params.pgid="productGroupId";
			
			//--PWP Params:
			params.pn="pageNumber";		// and DS
			params.so="sortOrder";		// and DS
			params.hf="hiddenFacets";
			params.sl="searchList";		// and DS
			params.sf="selectedFacets";	// and DS
			params.t='title';
			params.ipp='numItemsPerPage';
			params.fe='facetEnabled';
			
			//-- PDPiD Params:
			params.pbid='prebuildId';
			params.piid='productInstanceId';
			params.path='pathName';
			params.metricsId='metricsId';
			
			//-- DS Params:
			params.ph='primaryHex';
			params.sh='secondaryHex';
			params.pr='primaryRange';
			params.sr='secondaryRange';
			params.r='range';
			
			// Create a separate array containing all URL param values
			self.urlParams = new Array();
			for (var i in params) self.urlParams[self.urlParams.length] = i;
			
			// Adds reverse lookup values
			for(var p in params)
				params[params[p]]=p;
			self.paramLookupTable=params;
		};
		this.updateHashParams=function(data)
		{
			var params={};
			for(var p in data)
			{
				if(self.paramLookupTable[p] && typeof data[p] != 'undefined')
					params[self.paramLookup(p)]=""+(p=='title'||p=='searchList'?encodeURIComponent(data[p]):data[p]);
			}
			
			params.ll=self.params.lang_locale;
			params.ct=self.params.country;
			
			if(self.config.hash)
			{
				params.p=self.params.page;
				var str=self.stringify(params);
				//location.href="#"+str;
				if(typeof SWFAddress=='undefined')
					JQ.historyLoad(str);
				else
					SWFAddress.setValue(str);
			}
			else
			{
				params.p=self.params.page;
				JQ("div#NIKE_COMMERCE").css('visibility','hidden');	
				var str=self.stringify(params) + "&" + self.unrelatedParamString;
				location.href=str;
			}
		};
		
		//--FQDN helpers:
		this.setFQDN=function()
		{
			switch (NIKEOS.site_mode) {
				case 'dev':		self.params.FQDN = 'http://nike-dev4.ny.rga.com'; break; // change from dev2
				case 'staging':	self.params.FQDN = 'http://qa-modules.nike.com'; break;
				case 'prod':	self.params.FQDN = 'http://modules.nike.com'; break;
			}
			
			// -- for plus:
			if(typeof site_data=='object' && typeof site_data.settings=='object' && site_data.settings.base_modules_url)
				self.params.FQDN=site_data.settings.base_modules_url;
		};
		this.getFQDN=function()
		{
			return self.params.FQDN;
		};
		
		//--configBaseURL
		this.setConfigBase=function()
		{
			if (location.host.match(/env1-brand/i))	
				self.params.configBase="http://env1-emea.nike.com";
			else if (location.host.match(/ecn1-nikeplus/i))
				self.params.configBase="http://ecn1-nikeplus.nike.com";
			else if (location.host.match(/ecn1-www/i))
				self.params.configBase="http://ecn1-www.nike.com";				
			else if (location.host.match(/nike\.com/i))
				self.params.configBase="http://www.nike.com";
			else if (location.host.match(/nike-dev3/i))
				self.params.configBase="http://nike-dev3.ny.rga.com";
			else if (location.host.match(/nike-dev4/i))
				self.params.configBase="http://nike-dev4.ny.rga.com";				
			else
				self.params.configBase="http://nike-dev2.ny.rga.com";
		};
		this.getConfigBase=function()
		{
			return self.params.configBase;
		};
		
		//--page constructor/destructor
		this.buildPage=function()
		{
			switch(self.params.page)
			{
				case "PWP":		self.page=new NikePWPPage(self);
								break;
				case "PDP":		self.page=new NikePDPPage(self);
								break;
				case "PDPiD":	self.page=new NikePDPiDPage(self);
								break;
				case "ML":		self.page=new NikeMyLockerPage(self);
								break;
				case "MPDP":	self.page=new NikeMiniPDPPage(self);
								break;
				case "OS":		self.page=new NikeOrderStatusPage(self);
								break;
				case "SR":		self.page=new NikeSubmitReviewPage(self);
								break;
				case "C":		self.page=new NikeCollectionPage(self);
								break;
				case "TEE":		self.page=new NikeTeeWall(self);
								break;
				case "DS":		self.page=new DesignSearchWall(self);
								break;
			}
		};
		this.handlePage=function()
		{
			self.buildMiniCart();
		};
		this.buildMiniCart=function()
		{
			if(typeof self.miniCart == 'undefined') {
				self.miniCart=new NikeMiniCart(self);
			} else {
				self.buildPage();
			}
		};
		this.gotoPage=function(page,page_config)
		{
			var config=JQ.extend(true,{},self.mandatoryParams,page_config,{p:page});
			
			if(self.config.hash) {
				if (self.params.page && self.params.page != "undefined")
				{
					if(typeof SWFAddress=='undefined')
						JQ.historyLoad(self.stringify(config));
					else {
						SWFAddress.setValue(self.stringify(config));
					}
				} else {
					location.href = location.href.split('/').slice(0, 7).join('/')+'/' + self.config.commerceBaseURL + ( ( !!self.unrelatedParamString ) ? '?' +self.unrelatedParamString : '' ) + '#' + self.stringify(config);
				}
			}
			else
			{
				JQ("div#NIKE_COMMERCE").css('visibility','hidden');
				if (self.params.page && self.params.page != "undefined") {
					location.href = self.stringify(config) + '&' + self.unrelatedParamString;
				} else {
					location.href = location.href.split('/').slice(0, 7).join('/') + '/' + self.config.commerceBaseURL + self.stringify(config) + '&' + self.unrelatedParamString;
				}
			}
		};
		this.stringify=function(config)
		{
			var str="",seperate="?";
			for(var p in config)
			{
				if(typeof config[p]!='undefined')
				{
					str+=seperate+p+"="+config[p].replace(/\+/g,"^");
					seperate="&";
				}
			}
			return str;
		};
		this.getReviewsEnabled=function()
		{
			var ret;
			switch(self.params.lang_locale)
			{
				case "en_US":
				case "en_GB":
					ret = true;
					break;
				default:
					ret = false;
					break;
			}
			return ret;
		};
		
		this.getUnrelatedParameters=function(){
			self.unrelatedParamString='';
			var urlArray = location.search.substring(1).split(/[&]/);
			for (var i = 0; i < urlArray.length; i++) {
				var temp = urlArray[i].split(/[=]/);
				if (!self.paramCheck(temp[0])) {
					self.unrelatedParamString+='&'+temp.join('=');
				}
			}
			self.unrelatedParamString = self.unrelatedParamString.substring(1);
		};
		
		this.paramCheck=function(x){
			for (var i in self.urlParams) {
				if (x == self.urlParams[i]) {
					return true;
				}
			}
			return false;
		};
		
		self.preInit();
		JQ(self.init);		
		
		//--history plugin must be initialized before the DOM is loaded
		if (self.config.hash && typeof JQ.historyInit != "undefined" && typeof SWFAddress=='undefined') {
			window.onload=function(){
				JQ.historyInit(function(){});
			};
		}
	}

	//--base page object with container, eventbridge, etc...
	function NikeCommercePage(parent, extended)
	{
		var self=this;
		this.init=function()
		{
			if(extended.constructor!=NikeMiniCart)
				self.handleContainer();
			self.eventsToListenFor=[];
		};
		this.handleContainer=function()
		{
			self.container=JQ('div#NIKE_COMMERCE>div#COMMERCE_MODULE');
		};
		this.buildListener=function(eventsToListenFor,listenerFn)
		{
			self.listener={};
			self.listener.listenerFunction=listenerFn;
			
			EventBridge.setChannel("external");
			for(var i=0;i<eventsToListenFor.length;i++)
				EventBridge.addListener(eventsToListenFor[i],self.listener,"listenerFunction");
		};
		this.addSWF=function(module_config,container)
		{
			for(var p in module_config.variables)
			{
				if(parent.params[p]) {
					module_config.variables[p]=(p=='title'?encodeURIComponent(parent.params[p]):parent.params[p]);
				}
				else if(module_config.variables[p]==null)
					delete module_config.variables[p];
			}

			var config=JQ.extend(true,{},{variables:parent.mandatoryFlashParams},module_config);
            var flashModule=new SWFObject(config.swf, config.id, config.width, config.height, "9.0.28", "#ffffff");
            flashModule.addParam("scale", "noscale");
            
            //flashModule.addParam("allowScriptAccess", ((NIKEOS.site_mode == 'dev') ? 'always' : 'sameDomain'));
            flashModule.addParam("allowScriptAccess", 'always');
            
            
            flashModule.addParam("allowFullScreen", "true");
            
            flashModule.addParam("wmode", ((config.params && config.params.wmode) ? config.params.wmode : "transparent"));
            flashModule.addParam("salign", ((config.params && config.params.salign) ? config.params.salign : "tl"));
            
            flashModule.addParam("quality", "high");
            
            flashModule.addVariable('FQDN', parent.getFQDN());
            flashModule.addVariable('site', parent.config.site);
            
            flashModule.addVariable('membershipId',parent.config.membershipId);
			            
           for(var p in config.variables) {
				// change to allow for search of nike+ in design search
				if( p=='searchList' && typeof config.variables[p] != 'undefined' && config.escapeSearchList )
				{
					flashModule.addVariable(p, encodeURIComponent( config.variables[p] ) );
				}
				else
				{
					flashModule.addVariable(p,config.variables[p]);
				}
        	}
            
            setTimeout(function(){ var write=flashModule.write(container); }, 0);
		};
		this.destruct=function()
		{
			for(var i=0;i<self.eventsToListenFor.length;i++)
				EventBridge.removeListener(eventsToListenFor[i],self.listener,"listenerFunction");
			self.container.empty();
		};
		self.init();
	}

	//lazy extension function
	function extendNikeCommercePage(page,parent)
	{
		var temp=new NikeCommercePage(parent, page);
		for(var p in temp)
		{
			if(!page[p])
				page[p]=temp[p];
		}
		delete temp;
	}

	//--pwp page
	function NikePWPPage(parent, config)
	{
		var PWPConfig = JQ.extend(true, {
			id:"pwp",
			width:"910",
			height:"520",
			swf:parent.getFQDN()+"/nikestore/modules/web/productWall.swf",
			variables:
			{
				hiddenFacets:		parent.config.pwp.hiddenFacets,
				title:				parent.config.title,
				inStockOnly:		parent.config.pwp.inStockOnly,
				swatchEnabled:		"true",
				facetEnabled:		"true",
				numItemsPerPage:	parent.config.pwp.numItemsPerPage,
				pageNumber:			"1",
				userType:			parent.config.userType,
				configPath:			parent.config.pwp.configPath,
				alertEnabled:		"false",
				categoryHeadersEnabled:	parent.config.categoryHeadersEnabled,
				sortOrder:			null,
				selectedFacets:		null,
				searchList:			null
			}
		}, config);
		
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			
			//set on per_page basis:
			self.eventsToListenFor=["wallEventType", "sfEventType", "minipdpEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);

			//--check if commerce mode == 3 and limit only to id products if this is the case:
			if(parent.commerce_mode==3)
			{
				//--append id hiddenFacet.
				if (PWPConfig.variables.hiddenFacets.length > 0)
					PWPConfig.variables.hiddenFacets += "%2B4294966765";
				else
					PWPConfig.variables.hiddenFacets += "4294966765";
			}
			//build container and drop in the swf
			self.container.append("<div id=\"PWP_Module\" ></div>");
			self.addSWF(PWPConfig,'PWP_Module');
		};
		this.eventListener=function(evt)
		{
			console.log(evt);
			var id = evt.data.id;
			switch(id)
			{
				case "heightChange":		self.container.find('div#PWP_Module embed, #PWP_Module object').attr('height',evt.data.height);
											break;
				case "productClick":		parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "productWallChange":	parent.updateHashParams(evt.data);
											break;
				case "customizeWithId":		parent.gotoPage('PDPiD',{pid:evt.data.nikeId.productId,cid:evt.data.nikeId.catalogId,pbid:evt.data.nikeId.prebuildId,path:evt.data.nikeId.pathName,piid:evt.data.nikeId.productInstanceId});
											break;
				case "setLocation":			var xArray = evt.data.location.split(/[,\/]/g);
											if (xArray[1] == 'pdp') {
												var paramMap = {};
												for (var i = 0; i < xArray.length; i++) {
													if (xArray[i].split('-').length > 1) {
														paramMap[xArray[i].split('-')[0]] = xArray[i].split('-').slice(1).join('-').replace(/[_]/g, ' ');
													}
												}
												if (paramMap['pn']) paramMap.path = paramMap.pn;
												parent.gotoPage('PDPiD', paramMap);
											} else {
												var paramMap = {f:'',hf:'',t:''};
												for (var i = 0; i < xArray.length; i++) {
													if (xArray[i].split('-').length > 1) {
														paramMap[xArray[i].split('-')[0]] = xArray[i].split('-').slice(1).join('-').replace(/[_]/g, ' ');
													}
												}
												parent.gotoPage(parent.params.page, {sf:paramMap.f.replace(/[+]/g, '^'),t:paramMap.t,hf:paramMap.hf.replace(/[+]/g, '^')});
											}
											break;
				//-- start minipdp events
				case "relatedTechnology":	parent.gotoPage('PDP',{pgid:evt.data.productGroupId,pid:evt.data.productId,c:evt.data.catalogId});
											break;
				case "loginRequired":		if (evt.type == "minipdpEventType") location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											break;
				case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "goToLocker":			parent.gotoPage('ML');
											break;
				case "goToCheckout":		document.location.href=evt.data.url
												+ '&site=' + parent.config.site
												+ '&country=' + parent.mandatoryParams.ct
												+ '&lang_locale=' + parent.mandatoryParams.ll
												+ '&returnURL=' + escape(location.href + '&' + parent.unrelatedParamString);
											break;
				//-- end minipdp events
				default:					if (self[id]) self[id](evt);
											else console.log(evt);
			}
		};
		self.init();
	}
	
	//--tee wall page
	function NikeTeeWall(parent)
	{
		var page = new NikePWPPage(parent, {
			id: "tee_wall",
			height: 948,
			swf: parent.getFQDN() + "/nikestore/modules/web/merchandisingwall/merchandisingWall.swf",
			variables: {
				configPath: "/sportswear/global/xml/merchandisingwall_config.xml",
				numItemsPerPage: 17,
				localConfigPath: parent.config.localConfigPath
			}
		});
		
		return page;
	}
	
	//--pdp page
	function NikePDPPage(parent)
	{
		var self=this;
		var PDPConfig;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			self.eventsToListenFor=["pdpEventType", "minipdpEventType", "setLocation", "loginsuccess"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			PDPConfig=
			{
				id:"pdp",
				width:"910",
				height:"520",
				swf:parent.getFQDN()+"/nikestore/modules/web/pdp.swf",
				variables:
				{
					container:					"inline",
					userType:					parent.config.userType,
					configPath:					parent.config.pdp.configPath,
					alertEnabled:				"false",
					siteId:						parent.config.siteId,
					descriptionPanelEnabled:	"true",
					reviewsEnabled:				parent.getReviewsEnabled(),
					productGroupId:				parent.params.productGroupId,
					productId:					parent.params.productId,
					emailPath:					parent.config.mylocker.emailPath,
					catalogId:					parent.params.catalogId,
					wishlistEnabled:			"true"
				}
			};
		
			//build container and drop in the swf
			self.container.append("<div id=\"PDP_Module\"></div>");
			self.addSWF(PDPConfig,'PDP_Module');		
		};
		this.eventListener=function(evt)
		{
			if (evt.type == 'loginsuccess') {
				if ( nikeplus && nikeplus.user && nikeplus.user.reload ) nikeplus.user.reload(function () {if ( nikeplus.nav && nikeplus.nav.rebuild ) nikeplus.nav.rebuild(); });
			} else {
				switch(evt.data.id)
				{
					case "aspectChange":		parent.gotoPage('PDP', {pid:evt.data.productId, pgid: evt.data.productGroupId, cid: evt.data.catalogId});
												break;
					case "pdpHeightChange":		self.container.find('div#PDP_Module embed, div#PDP_Module object').css('height',evt.data.height);
												break;
					case "swatchChange":		if (evt.type == "pdpEventType") parent.gotoPage('PDP',{pid:evt.data.productId, cid:evt.data.catalogId,pgid:evt.data.productGroupId});
												break;
					case "loadProductWall":		parent.gotoPage('PWP',{sf:evt.data.selectedFacets,c:evt.data.catalogs});
												break;
					case "relatedTechnology":	parent.gotoPage('PDP',{pgid:evt.data.productGroupId,pid:evt.data.productId,c:evt.data.catalogId});
												break;
					case "customizeWithId":		var cwidObj = {c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId};
												if ( evt.data.nikeId.metricId ) cwidObj.metricsId=evt.data.nikeId.metricId;
												parent.gotoPage('PDPiD',cwidObj);
												break;
					case "loginRequired":		if (evt.type == "minipdpEventType") location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
												break;
					case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
												break;
					case "goToLocker":			parent.gotoPage('ML');
												break;
					case "goToCheckout":		document.location.href=evt.data.url
													+ '&site=' + parent.config.site
													+ '&country=' + parent.mandatoryParams.ct
													+ '&lang_locale=' + parent.mandatoryParams.ll
													+ '&returnURL=' + escape(location.href + '&' + parent.unrelatedParamString);
												break;
					case "submitAReview":		parent.gotoPage('SR', {pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
												break;
					case "setLocation":			location.href="http://store.nike.com/index.jsp?country="+parent.mandatoryParams.ct+"&lang_locale="+parent.mandatoryParams.ll+"&ref="+escape(location.href)+"#l="+evt.data.hash;
												break;
					default:					console.log('unhandled event: ');
												console.log(evt);
												break;
				}
			}
		};
		self.init();
	}
	//--minipdp page
	function NikeMiniPDPPage(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			self.eventsToListenFor=["pdpEventType", "minipdpEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			var PDPConfig=
			{
				id:"minipdp",
				width:"320",
				height:"240",
				// 260, 240, 205, 185
				swf:parent.getFQDN()+"/nikestore/modules/web/miniPDP.swf",
				variables:
				{
					container:			"inline",
					userType:			parent.config.userType,
					configPath:			parent.config.minipdp.configPath,
					alertEnabled:		"false",
					siteId:				parent.config.siteId,
					productGroupId:		parent.config.minipdp.productGroupId,
					productId:			parent.config.minipdp.productId,
					catalogId:			parent.config.catalogId,
					closeEnabled:		"false",
					detailsEnabled:		"true",
					wishlistEnabled:	"true"
				}
			};
		
			//drop the swf into the container (that should already exist if this code is running)
			self.addSWF(PDPConfig,'MiniPDP_Module');		
		};
		this.eventListener=function(evt)
		{
			switch(evt.data.id)
			{
				case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "customizeWithId":		parent.gotoPage('PDPiD',{c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId});
											break;
				case "loginRequired":		if (evt.type == "minipdpEventType") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											break;
				case "goToLocker":			parent.gotoPage('ML');
											break;
				case "submitAReview":		parent.gotoPage('SR', {pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				default:					console.log(evt);
											break;
			}
		};
		self.init();
	}
	//--NIKEiD page
	function NikePDPiDPage(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			self.eventsToListenFor=["pdpEventType", "minipdpEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			var PDPConfig=
			{
				id:"pdpid",
				width:"910",
				height:"520",
				swf:parent.getFQDN()+"/nikestore/modules/web/pdp.swf",
				variables:
				{
					container:					"nikeid",
					userType:					parent.config.userType,
					configPath:					parent.config.nikeid.configPath,
					//buildConfigPath:			parent.config.nikeid.buildConfigPath,
					buildConfigPath:			parent.getFQDN() + '/nikestore/modules/web/xml/nikeid/build_config_' + parent.params.lang_locale + '.xml',
					siteURL:					parent.config.nikeid.siteURL,
					itemReturnURL:				parent.config.nikeid.itemReturnURL,
					alertEnabled:				"false",
					siteId:						parent.config.siteId,
					descriptionPanelEnabled:	"true",
					productId:					parent.params.productId,
					catalogId:					parent.params.catalogId,
					prebuildId:					parent.params.prebuildId,
					productInstanceId:			parent.params.productInstanceId,
					pathName:					parent.params.pathName,
					metricId:					parent.params.metricsId,
					idEmailPrivacyPath:			parent.config.idEmailPrivacyPath,
					idEmailFeedbackPath:		parent.config.idEmailFeedbackPath,
					idEmailDomain:				NIKEOS.BASE.localhost + '/',
					idEmailMyDesignPath:		parent.config.nikeid.idEmailMyDesignPath,
					commerceItemId:				getParam('commerceItemId', 'hash')
				}
			};
		
			//build container and drop in the swf
			self.container.append("<div id=\"PDP_Module\"></div>");
			self.addSWF(PDPConfig,'PDP_Module');		
		};
		this.eventListener=function(evt)
		{
			switch(evt.data.id)
			{
				case "pdpHeightChange":		self.container.find('div#PDP_Module embed, div#PDP_Module object').css('height',evt.data.height);
											break;
				case "swatchChange":		parent.gotoPage('PDP',{pid:evt.data.productId, cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "loadProductWall":		parent.gotoPage('PWP',{sf:evt.data.selectedFacets,c:evt.data.catalogs});
											break;
				case "relatedTechnology":	parent.gotoPage('PDP',{pgid:evt.data.productGroupId,pid:evt.data.productId,c:evt.data.catalogId});
											break;
				case "loginRequired":		if (evt.type == "minipdpEventType") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											break;
				case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "goToLocker":			parent.gotoPage('ML');
											break;
				case "goToCheckout":		document.location.href=evt.data.url
												+ '&site=' + parent.config.site
												+ '&country=' + parent.mandatoryParams.ct
												+ '&lang_locale=' + parent.mandatoryParams.ll
												+ '&returnURL=' + escape(location.href);
											break;
				case "submitAReview":		parent.gotoPage('SR', {pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				default:					console.log(evt);
											break;
			}
		};
		self.init();
	}
	
	function DesignSearchWall(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			self.eventsToListenFor=["designSearchEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			var DSConfig=
			{
				id:"dsWall",
				width:"910",
				height:"520",
				swf:parent.getFQDN()+"/nikestore/modules/web/designSearch.swf",
				escapeSearchList:				true,
				variables:
				{
					container:					"dsWall",
					userType:					parent.config.userType,
					siteId:						parent.config.siteId,
					catalogs:					parent.params.catalogId,
					metricId:					parent.params.metricsId,
					pageNumber:					parent.params.pn,
					sortOrder:					parent.params.so,
					searchList:					parent.params.sl,
					selectedFacets:				parent.params.sf,
					inStockOnly:				parent.params.iso,
					primaryHex:					parent.params.ph,
					primaryRange:				parent.params.pr,
					secondaryHex:				parent.params.sh,
					secondaryRange:				parent.params.sr,
					range:						parent.params.r,
					
					configPath:					parent.config.designsearch.configPath
				}
			};
			
			//build container and drop in the swf
			self.container.append("<div id=\"DS_Module\"></div>");
			self.addSWF(DSConfig,'DS_Module');		
		};
		this.eventListener=function(evt)
		{
			switch(evt.data.id)
			{
				case "heightChange":		self.container.find('div#DS_Module embed, div#DS_Module object').css('height',evt.data.height);
											break;
				case "dsWallChange":		parent.updateHashParams(evt.data);
											break;
				case "dsDetailClick":	    var cwidObj = {c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId};
											if ( evt.data.nikeId.metricId ) cwidObj.metricsId=evt.data.nikeId.metricId;
											parent.gotoPage('PDPiD',cwidObj);
											break;
				case "customizeWithId":		var cwidObj = {c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId};
											if ( evt.data.nikeId.metricId ) cwidObj.metricsId=evt.data.nikeId.metricId;
											parent.gotoPage('PDPiD',cwidObj);
											break;
				// case "loginRequired":		document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
				//							break;
				default:					console.log(evt);
											break;
			}
		};
		self.init();
	}
	
	//--miniCart page
	function NikeMiniCart(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			self.eventsToListenFor=["minicartEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			self.buildContainer();
			
			var miniCartConfig=
			{
				id:				"minicart",
				width:			"450",
				height:			"33",
				swf:			parent.getFQDN()+"/nikestore/modules/web/miniCartNav.swf",
				params:
				{
					salign:	"tr"
				},
				variables:
				{
					container:		"inline",
					siteId:			parent.config.siteId,
					catalogId:		parent.params.catalogId,
					userType:		parent.config.userType,
					configPath:		parent.config.minicart.configPath,
					alertEnabled:	"true",
					langLocale:		parent.params.lang_locale,
					storeReturnURL:	parent.config.minicart.storeReturnURL,
					loginPath:		parent.config.minicart.loginPath
				}
			};
			
			self.container.append("<div id=\"MiniCart_Module\" style=\"position:absolute;top:0px;right:0px;\" ></div>");
			self.addSWF(miniCartConfig,'MiniCart_Module');
		};
		this.buildContainer=function()
		{
			self.container=JQ('div#NIKE_COMMERCE>div#MINI_CART');
		};
		this.eventListener=function(evt)
		{
			switch (evt.data.id)
			{
				case "minicartHeightChange":	JQ("#MiniCart_Module object").height(evt.data.height + 5);
												JQ('#MiniCart_Module embed').height(evt.data.height + 5);
												break;
				case "minicartWidthChange":		self.container.find("#MiniCart_Module embed, #MiniCart_Module object").css("width", evt.data.width);
												break;
				case "minicartLoaded":			parent.buildPage();
												break;
				case "goToCart":				document.location.href=evt.data.url
													+ '&site=' + parent.config.site
													+ '&country=' + parent.mandatoryParams.ct
													+ '&lang_locale=' + parent.mandatoryParams.ll
													+ '&returnURL=' + escape(location.href);
												break;
				case "goToCheckout":			document.location.href=evt.data.url
													+ '&site=' + parent.config.site
													+ '&country=' + parent.mandatoryParams.ct
													+ '&lang_locale=' + parent.mandatoryParams.ll
													+ '&returnURL=' + escape(location.href);
												break;
				case "gotoorderstatus":			parent.gotoPage("OS");
												break;
				case "gotomylocker":			parent.gotoPage("ML");
												break;
				default:						console.log(evt);
												break;
			}
		};
		self.init();
	}
	//--myLocker page
	function NikeMyLockerPage(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			
			self.eventsToListenFor=["resize", "launchPopup", "externalLink", "startShopping", "pdpEventType", "minipdpEventType", "loginsuccess", "loginfailure", "baseModuleEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			var myLockerConfig=
			{
				id:				"myLocker",
				width:			"910",
				height:			"650",
				swf:			parent.getFQDN()+"/nikestore/modules/web/myLocker.swf",
				variables:
				{
					container:			"inline",
					siteId:				parent.config.siteId,
					catalogId:			parent.config.catalogId,
					userType:			parent.config.userType,
					configPath:			parent.config.mylocker.configPath,
					alertEnabled:		"false",
					langLocale:			parent.params.lang_locale,
					storeReturnURL:		escape(parent.config.mylocker.storeReturnURL),
					loginPath:			parent.config.mylocker.loginPath,
					emailPath:			parent.config.mylocker.emailPath,
					miniPdpConfigPath:	parent.config.minipdp.configPath,
					registerPath:		escape(parent.config.registerPath)
				}
			};
			
			self.container.append("<div id=\"MyLocker_Module\" style=\"background-color: #2f2e2c;\" ></div>");
			self.addSWF(myLockerConfig,'MyLocker_Module');
		};
		this.eventListener=function(evt)
		{
			// Note that this one switches by type, rather than id
			switch (evt.type)
			{
				case "resize":				JQ('#MyLocker_Module embed, #MyLocker_Module object').css("height", evt.data.height);
											break;
				case "startShopping":		parent.gotoPage('PWP');
											break;
				case "minipdpEventType":	if (evt.data.id == "loginRequired") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											else if (evt.data.id == "viewDetails") parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											else if (evt.data.id == "customizeWithId") parent.gotoPage('PDPiD',{pid:evt.data.nikeId.productId,cid:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName});
											else if (evt.data.id == "swatchChange") console.log(evt.data);
											else if (evt.data.id == "goToCheckout") document.location.href=evt.data.url	+ '&site=' + parent.config.site + '&country=' + parent.mandatoryParams.ct + '&lang_locale=' + parent.mandatoryParams.ll + '&returnURL=' + escape(location.href);
											else console.log(evt.data);
											break;
				case "goToCheckout":		document.location.href=evt.data.url
												+ '&site=' + parent.config.site
												+ '&country=' + parent.mandatoryParams.ct
												+ '&lang_locale=' + parent.mandatoryParams.ll
												+ '&returnURL=' + escape(location.href);
											break;
				case 'loginsuccess':		if ( nikeplus && nikeplus.user && nikeplus.user.reload ) nikeplus.user.reload(function () {if ( nikeplus.nav && nikeplus.nav.rebuild ) nikeplus.nav.rebuild(); });
											break;
				case "close":				parent.gotoPage('ML');
											break;
				default:
					if (evt.id == "loginRequired") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + encodeURIComponent(document.location);
					else if (evt.data.id == "customizeWithId") {
						parent.gotoPage('PDPiD', {
							path:		evt.data.nikeId.pathName,
							metricsId:	evt.data.nikeId.metricsId
						});
					}
					else console.log(evt);
					break;
			}
		};
		self.init();
	}
	//--orderStatus page
	function NikeOrderStatusPage(parent)
	{
		var self=this;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			self.eventsToListenFor=["resize", "launchPopup", "externalLink", "startShopping", "pdpEventType", "minipdpEventType", "loginsuccess", "loginfailure"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			var orderStatusConfig=
			{
				id:				"orderStatus",
				width:			"910",
				height:			"650",
				swf:			parent.getFQDN()+"/nikestore/modules/web/orderStatus.swf",
				variables:
				{
					siteId:			parent.config.siteId,
					catalogId:		parent.config.catalogId,
					userType:		parent.config.userType,
					configPath:		parent.config.orderstatus.configPath,
					alertEnabled:	"false",
					langLocale:		parent.params.lang_locale,
					storeReturnURL:	escape(parent.config.orderstatus.storeReturnURL),
					loginPath:		parent.config.orderstatus.loginPath,
					emailPath:		parent.config.orderstatus.emailPath,
					registerPath:	escape(parent.config.registerPath)
				}
			};
			
			
			
			self.container.append("<div id=\"OrderStatus_Module\" ></div>");
			self.addSWF(orderStatusConfig,'OrderStatus_Module');
		};
		this.eventListener=function(evt)
		{
			// Note that this one switches by type, rather than id
			switch (evt.type)
			{
				case 'resize':			JQ('#OrderStatus_Module embed, #OrderStatus_Module object, #OrderStatus_Module').css("height", evt.data.height);
				JQ('object#orderStatus').attr('height', '');
				JQ('object#orderStatus').attr('height', evt.data.height);
										break;
				case 'startShopping':	parent.gotoPage('PWP');
										break;
				case 'loginsuccess':	if ( nikeplus && nikeplus.user && nikeplus.user.reload ) nikeplus.user.reload(function () {if ( nikeplus.nav && nikeplus.nav.rebuild ) nikeplus.nav.rebuild(); });
										break;
				default:				console.log(evt);
										break;
			}
		};
		self.init();
	}

	//--collection page
	function NikeCollectionPage(parent)
	{
		var self=this;
		var PDPConfig;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			self.eventsToListenFor=["pdpEventType", "minipdpEventType"];
			self.buildListener(self.eventsToListenFor,self.eventListener);
			
			PDPConfig=
			{
				id:"collection",
				width:"910",
				height:"520",
				swf:parent.getFQDN()+"/nikestore/modules/web/pdp.swf",
				variables:
				{
					container:					"collection",
					userType:					parent.config.userType,
					configPath:					parent.config.collection.configPath,
					alertEnabled:				"false",
					siteId:						parent.config.siteId,
					descriptionPanelEnabled:	"true",
					reviewsEnabled:				parent.getReviewsEnabled(),
					productGroupId:				parent.params.productGroupId,
					productId:					parent.params.productId,
					emailPath:					parent.config.mylocker.emailPath,
					catalogId:					parent.params.catalogId,
					wishlistEnabled:			"true"
				}
			};
		
			//build container and drop in the swf
			self.container.append("<div id=\"PDP_Module\"></div>");
			self.addSWF(PDPConfig,'PDP_Module');		
		};
		this.eventListener=function(evt)
		{
			switch(evt.data.id)
			{
				case "pdpHeightChange":		self.container.find('div#PDP_Module embed, div#PDP_Module object').css('height',evt.data.height);
											break;
				case "swatchChange":		if (evt.type == "pdpEventType") parent.gotoPage('PDP',{pid:evt.data.productId, cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "loadProductWall":		parent.gotoPage('PWP',{sf:evt.data.selectedFacets,c:evt.data.catalogs});
											break;
				case "relatedTechnology":	parent.gotoPage('PDP',{pgid:evt.data.productGroupId,pid:evt.data.productId,c:evt.data.catalogId});
											break;
				case "customizeWithId":		parent.gotoPage('PDPiD',{c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId});
											break;
				case "loginRequired":		if (evt.type == "minipdpEventType") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											break;
				case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "goToLocker":			parent.gotoPage('ML');
											break;
				case "goToCheckout":		document.location.href=evt.data.url;
											break;
				case "submitAReview":		parent.gotoPage('SR', {pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				default:					console.log(evt);
											break;
			}
		};
		self.init();
	}
	
	//--submitReview page
	//  currently does not work
	//  may not be ready to be used in HTML
	function NikeSubmitReviewPage(parent)
	{
		var self=this;
		var PDPConfig;
		this.init=function()
		{
			extendNikeCommercePage(self,parent);
			//set on per_page basis:
			var eventsToListenFor=["pdpEventType", "minipdpEventType"];
			self.buildListener(eventsToListenFor,self.eventListener);
			
			PDPConfig=
			{
				id:"review",
				width:"910",
				height:"520",
				swf:parent.getFQDN()+"/nikestore/modules/web/pdp.swf",
				variables:
				{
					container:					"submitReview",
					userType:					parent.config.userType,
					configPath:					parent.config.pdp.configPath,
					alertEnabled:				"false",
					siteId:						parent.config.siteId,
					descriptionPanelEnabled:	"true",
					productGroupId:				parent.params.productGroupId,
					productId:					parent.params.productId,
					catalogId:					parent.params.catalogId
				}
			};
		
			//build container and drop in the swf
			self.container.append("<div id=\"PDP_Submit_Review\"></div>");
			self.addSWF(PDPConfig,'PDP_Submit_Review');		
		};
		this.eventListener=function(evt)
		{
			switch(evt.data.id)
			{
				case "pdpHeightChange":		self.container.find('div#PDP_Submit_Review embed, div#PDP_Submit_Review object').css('height',evt.data.height);
											break;
				case "swatchChange":		parent.gotoPage('SR',{pid:evt.data.productId, cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "loadProductWall":		parent.gotoPage('PWP',{sf:evt.data.selectedFacets,c:evt.data.catalogs});
											break;
				case "relatedTechnology":	parent.gotoPage('PDP',{pgid:evt.data.productGroupId,pid:evt.data.productId,c:evt.data.catalogId});
											break;
				case "customizeWithId":		parent.gotoPage('PDPiD',{c:evt.data.nikeId.catalogId,path:evt.data.nikeId.pathName,pbid:evt.data.nikeId.prebuildId,pid:evt.data.nikeId.productId,piid:evt.data.nikeId.productInstanceId});
											break;
				case "loginRequired":		if (evt.type == "minipdpEventType") document.location.href='/nikeos/p/'+parent.config.siteFolder+"/"+location.href.split('/')[6]+"/profile?"+parent.unrelatedParamString+"&page=login&fields=screenname&continueURL=" + escape(document.location);
											break;
				case "viewDetails":			parent.gotoPage('PDP',{pid:evt.data.productId,cid:evt.data.catalogId,pgid:evt.data.productGroupId});
											break;
				case "goToLocker":			parent.gotoPage('ML');
											break;
				case "goToCheckout":		document.location.href=evt.data.url
												+ '&site=' + parent.config.site
												+ '&country=' + parent.mandatoryParams.ct
												+ '&lang_locale=' + parent.mandatoryParams.ll
												+ '&returnURL=' + escape(location.href);
											break;
				case 'continueShopping':
				case 'startShopping':		parent.gotoPage('PWP');
											break;
				default:					console.log(evt);
											break;
			}
		};
		self.init();
	}
	
	

	//--utilities
	function getParam(x,location)
	{
		var url=window.location.href;
		if(location=='query_string')
			url=url.substring(0,url.indexOf('#'));
		else if(location=='hash')
			url=url.substring(url.indexOf('#'),url.length);
		x=x.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS="[\\?&]"+x+"=([^&#]*)";
		var regex=new RegExp(regexS);
		var results=regex.exec(url);
		if(results==null)
			return "";
		else
			return decodeURIComponent(results[1]);
	}
	
	var serverTimeToDate=function(data, ignoreTimezone)
	{
		if(!data || typeof data != 'string' || data.indexOf('T')==-1 || data.indexOf('-')==-1 || data.indexOf(':')==-1)
			return (new Date);
		var offset		= data.split('T')[1].split(/[+-]/)[1].split(':');
		offset = {
			positive:	(data.indexOf('-') < 0),
			hours: 		offset[0],
			minutes:	offset[1]
		};

		var t			= data.split('T')[1].split(/[+-]/, 1)[0].split(':');
		var d			= data.split('T', 1)[0].split('-');
		var dt			= { year: d[0], month: d[1], day: d[2], hours: t[0], minutes: t[1], seconds: t[2] };
		for (var cv in dt) dt[cv] = parseInt(dt[cv], 10);
		var date		= new Date(dt.year, dt.month-1, dt.day, dt.hours, dt.minutes, dt.seconds);
		if (!ignoreTimezone) {
			//-- handle timezone offset
			date			= new Date( date.valueOf() - ( ( new Date() ).getTimezoneOffset() * 60000 ) );
			if (!offset.positive) {
				date = new Date( date.valueOf() + ( offset.hours * 3600000 ) + ( offset.minutes * 60000 ) );
			} else {
				date = new Date( date.valueOf() - ( offset.hours * 3600000 ) - ( offset.minutes * 60000 ) );
			}
		}
		return			date;
	};
	
	/* PREVENTING ERRORS */
	if (typeof(page_tracker_obj) == 'undefined') var page_tracker_obj = {};
	
	if(location.pathname.indexOf("/language_tunnel")==-1)
		var nike_commerce=new NikeCommerce();
