
	var _vw = {};
	function VideoWall()
	{
		var self=this;
		var master=self;
		this.init=function()
		{
			self.merge_configs();
			self.setSkin();
			self.setTranslations();
			
			self.container=JQ('div#'+self.config.container_div);
			
			//ui
			self.popup=new PopUp(self,'modal');
			
			//tunnels:
			self.ajax_tunnel=new AjaxTunnel();
			self.f4a_tunnel=new F4ATunnel(self);
			self.demand_tunnel=new DemandTunnel(self);
			
			//managers:
			self.video_manager=new VideoManager(self);
			self.comment_manager=new CommentManager(self);
			
			//front end:
			self.front_end=new VideoWallFrontEnd(self);
			self.preload_images();
			//init:
			self.handle_params();
		};
		this.merge_configs=function()
		{
			var default_config=
			{
				locale:location.href.substring(location.href.indexOf("/nikeos/p/")+10,location.href.length).split("/")[1],
				all_wall_channel_id:174,
				dev_blog_community:2099,
				staging_blog_community:2103,
				prod_blog_community:2216,
				container_div:'video_wall',
				login_url:"/nikeos/p/nikebasketball/en_US/profile?page=signin&fields=screenname",
				skin:'dark',
				video_player:
				{
					regionConfig:"/nikebasketball/us/en_US/xml/regVideoConfig.xml",
					siteConfig:"/nikebasketball/global/xml/videoSiteConfig.xml"
				},
				sub_channels:[],
				touts:
				[
					/*{thumb:"/nikeos/global/image/videowall/dark/tout.gif",url:"#"},
					{thumb:"/nikeos/global/image/videowall/dark/tout.gif",url:"#"}*/
				],
				images:
				{
					pencil:"/nikeos/global/image/videowall/dark/pencil_icon.gif",
					prev_active:"/nikeos/global/image/videowall/dark/paging_last_active.gif",
					prev_inactive:"/nikeos/global/image/videowall/dark/paging_last_inactive.gif",
					next_active:"/nikeos/global/image/videowall/dark/paging_next_active.gif",
					next_inactive:"/nikeos/global/image/videowall/dark/paging_next_inactive.gif",
					thumbnail_overlay:"/nikeos/global/image/videowall/dark/thumbnail_play_overlay.png"
				}
			};
			
			if(typeof VIDEOWALL_CONFIG!='undefined')
				self.config=JQ.extend(true,{},default_config,VIDEOWALL_CONFIG);
			else
				self.config=default_config;
			
			if(self.config.locale=="en_HK")
				self.config.locale="en_GB";

			//determing correct blog domain:
			if(location.host.match(/ecn\d*-(www|nikeplus)/i))
			{
				self.config.blog_base_url="http://inside-staging.nike.com/";
				self.config.blog_community=self.config.staging_blog_community;
			}
			else if(location.host.match(/nike\.com/i))
			{
				self.config.blog_base_url="http://inside.nike.com/";
				self.config.blog_community=self.config.prod_blog_community;
			}
			else
			{
				self.config.blog_base_url="http://cs.ny.rga.com/";
				self.config.blog_community=self.config.dev_blog_community;
			}
			self.config.blog_base_url+="everywhere/780";
			
			var url=self.config.login_url;
			if(url.indexOf("/nikeos/p/")!=-1)
			{
				url=url.substring(url.indexOf("/nikeos/p/")+10,url.length);
				var arr=url.split("/");
				arr[1]=self.config.locale;
				url="/nikeos/p";
				for(var i=0;i<arr.length;i++)
					url+="/"+arr[i];
				self.config.login_url=url;
			}
			
		};
		this.handle_params=function()
		{
			//-check hash param.
			var guid = getParam('guid','hash') || getParam('guid','query_string');
			var channel = getParam('channel','hash') || getParam('channel','query_string');
			
			if(guid.length>1 && channel.length<1)
			{
				self.initial_guid = guid;
				self.front_end.events.open_guid(guid);
			} 
			else if (channel.length>1 && guid.length<1) 
			{
				_vw.initial_channel = self.initial_channel = channel;
			}
		};
		this.preload_images=function()
		{
			for(var p in self.config.images)
				self.container.append("<img src=\""+self.config.images[p]+"\" class=\"hidden\" />");
		};
		this.setSkin=function()
		{
			if(self.config.skin=='dark')
			{
				var images=
				{
					comment_bg:"/nikeos/global/image/videowall/dark/post_bg_no_avatar.gif",
					comment_bottom:"/nikeos/global/image/videowall/dark/comment_no_avatar_bot.gif",
					comment_top:"/nikeos/global/image/videowall/dark/comment_no_avatar_top.gif",
					post_bg:"/nikeos/global/image/videowall/dark/post_bg_no_avatar.gif",
					star_active:"/nikeos/global/image/videowall/dark/star_full.gif",
					star_inactive:"/nikeos/global/image/videowall/dark/star_empty.gif",
					star_half:"/nikeos/global/image/videowall/dark/star_half.gif",
					abuse_img:"http://www.nike.com/g1/global/images/commenting/flag_on.gif",
					no_abuse_img:"http://www.nike.com/g1/global/images/commenting/flag_off.gif",
					form_post_bg:"/nikeos/global/image/videowall/dark/form_post_bg_no_avatar.gif",
					form_comment_top:"/nikeos/global/image/videowall/dark/form_comment_no_avatar_top.gif",
					form_comment_bottom:"/nikeos/global/image/videowall/dark/form_comment_no_avatar_bot.gif"
				};
			}
			else
			{
				var images=
				{
					comment_bg:"/nikeos/global/image/videowall/light/post_bg_no_avatar.gif",
					comment_bottom:"/nikeos/global/image/videowall/light/comment_no_avatar_bot.gif",
					comment_top:"/nikeos/global/image/videowall/light/comment_no_avatar_top.gif",
					post_bg:"/nikeos/global/image/videowall/light/post_bg_no_avatar.gif",
					star_active:"/nikeos/global/image/videowall/light/star_full.gif",
					star_inactive:"/nikeos/global/image/videowall/light/star_empty.gif",
					star_half:"/nikeos/global/image/videowall/light/star_half.gif",
					abuse_img:"http://www.nike.com/g1/global/images/commenting/flag_on.gif",
					no_abuse_img:"http://www.nike.com/g1/global/images/commenting/flag_off.gif",
					form_post_bg:"/nikeos/global/image/videowall/light/form_post_bg_no_avatar.gif",
					form_comment_top:"/nikeos/global/image/videowall/light/form_comment_no_avatar_top.gif",
					form_comment_bottom:"/nikeos/global/image/videowall/light/form_comment_no_avatar_bot.gif"
				};
			}
			
			self.config.images=JQ.extend(true,{},images,self.config.images);
		};
		this.setTranslations=function()
		{
			var language=location.href.substring(location.href.indexOf("/nikeos/p/")+10,location.href.length).split("/")[1].split("_")[0];
			switch(language)
			{
				case "cs":	self.config.translations=
							{
								write_a_comment:"VLO\u017DIT KOMENT\u00C1\u0158",
								submit:"odeslat",
								cancel:"zru\u0161it",
								added_a_comment:"p\u0159idat koment\u00E1\u0159",
								up_next:"Pod\u00EDvat se tak\u00E9 na",
								related_videos:"Souvisej\u00EDc\u00ED videa",
								channels:"Kan\u00E1ly",
								videos:"Videa",
								episodes:"Epizody",
								add_comment:"P\u0158IDAT KOMENT\u00C1\u0158 ",
								read:"POD\u00CDVAT SE",
								loading:"nahr\u00E1v\u00E1 se",
								newest:"NEJNOV\u011AJ\u0160\u00CD",
								no_video_found:"Nic nebylo nalezeno",
								comments:"Koment\u00E1\u0159e",
								no_comments:"Zat\u00EDm \u017E\u00E1dn\u00FD koment\u00E1\u0159",
								no_comment_entered:"koment\u00E1\u0159 dosud nebyl vlo\u017Een",
								comment_too_long:"koment\u00E1\u0159 je p\u0159\u00EDli\u0161 dlouh\u00FD!",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"POD\u00CDVAT SE",
								rating:"Rating",
								view_all:"POD\u00CDVAT SE",
								sort_by:"Sort By"
							};
							break;				
				case "pl":	self.config.translations=
							{
								write_a_comment:"NAPISZ KOMENTARZ",
								submit:"wy\u015Blij",
								cancel:"anuluj",
								added_a_comment:"komentarz dodany",
								up_next:"Zobacz te\u017C",
								related_videos:"Powi\u0105zane wideo",
								channels:"Kana\u0142y",
								videos:"Wideo",
								episodes:"Odcinki",
								add_comment:"DODAJ KOMENTARZ",
								read:"ZOBACZ",
								loading:"\u0142adowanie",
								newest:"NAJNOWSZE",
								no_video_found:"Nic nie znaleziono",
								comments:"Komentarze",
								no_comments:"Nie dodano \u017Cadnych komentarzy",
								no_comment_entered:"nie wprowadzono komentarza",
								comment_too_long:"komentarz jest za d\u0142ugi!",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"ZOBACZ",
								rating:"Rating",
								view_all:"ZOBACZ",
								sort_by:"Sort By"
							};
							break;				
				case "ru":	self.config.translations=
							{
								write_a_comment:"\u041D\u0410\u041F\u0418\u0421\u0410\u0422\u042C \u041A\u041E\u041C\u041C\u0415\u041D\u0422\u0410\u0420\u0418\u0419",
								submit:"\u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C",
								cancel:"\u043E\u0442\u043C\u0435\u043D\u0430",
								added_a_comment:"\u0432\u044B \u0434\u043E\u0431\u0430\u0432\u0438\u043B\u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",
								up_next:"\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u043E",
								related_videos:"\u041F\u043E\u0445\u043E\u0436\u0438\u0435 \u0432\u0438\u0434\u0435\u043E",
								channels:"\u041A\u0430\u043D\u0430\u043B\u044B",
								videos:"\u0412\u0438\u0434\u0435\u043E",
								episodes:"\u042D\u043F\u0438\u0437\u043E\u0434\u044B",
								add_comment:"\u0414\u041E\u0411\u0410\u0412\u0418\u0422\u042C \u041A\u041E\u041C\u041C\u0415\u041D\u0422\u0410\u0420\u0418\u0419",
								read:"\u041F\u041E\u0421\u041C\u041E\u0422\u0420\u0415\u0422\u042C",
								loading:"\u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0430",
								newest:"\u041D\u041E\u0412\u042B\u0415",
								no_video_found:"\u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",
								comments:"\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438",
								no_comments:"\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043D\u0435\u0442",
								no_comment_entered:"\u0432\u044B \u043D\u0435 \u0432\u0432\u0435\u043B\u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",
								comment_too_long:"\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0434\u043B\u0438\u043D\u043D\u044B\u0439!",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"\u041F\u041E\u0421\u041C\u041E\u0422\u0420\u0415\u0422\u042C",
								rating:"Rating",
								view_all:"\u041F\u041E\u0421\u041C\u041E\u0422\u0420\u0415\u0422\u042C",
								sort_by:"Sort By"
							};
							break;				
				case "tr":	self.config.translations=
							{
								write_a_comment:"YORUM YAZ",
								submit:"g\u00F6nder",
								cancel:"iptal",
								added_a_comment:"yorum eklendi",
								up_next:"Ayrıca Bakınız",
								related_videos:"\u0130lgili Videolar",
								channels:"Kanallar",
								videos:"Videolar",
								episodes:"B\u00F6l\u00FCmler",
								add_comment:"YORUM EKLE",
								read:"\u0130ZLEME",
								loading:"y\u00FCkleniyor",
								newest:"EN YEN\u0130",
								no_video_found:"Bir \u015Fey bulunamadı",
								comments:"Yorumlar",
								no_comments:"Yorum yapılmadı",
								no_comment_entered:"yorum girilmedi",
								comment_too_long:"yorum \u00E7ok uzun!",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"\u0130ZLEME",
								rating:"Rating",
								view_all:"\u0130ZLEME",
								sort_by:"Sort By"
							};
							break;
				case "zh":	self.config.translations=
							{
								write_a_comment:"\u64B0\u5BEB\u8A55\u8AD6",
								submit:"\u63D0\u4EA4",
								cancel:"\u53D6\u6D88",
								added_a_comment:"\u589E\u52A0\u4E86\u8A55\u8AD6",
								up_next:"\u4E5F\u8ACB\u770B",
								related_videos:"\u76F8\u95DC\u5F71\u7247",
								channels:"\u983B\u9053",
								videos:"\u5F71\u7247",
								episodes:"\u96C6",
								add_comment:"\u8ACB\u589E\u52A0\u8A55\u8AD6",
								read:"\u8ACB\u770B",
								loading:"\u4E0B\u8F09\u4E2D",
								newest:"\u6700\u65B0",
								no_video_found:"\u751A\u9EBD\u4E5F\u6C92\u767C\u73FE\u3002",
								comments:"\u8A55\u8AD6",
								no_comments:"\u6C92\u6709\u4F5C\u51FA\u8A55\u8AD6\u3002",
								no_comment_entered:"\u7121\u8A55\u8AD6\u8F38\u5165",
								comment_too_long:"\u9019\u8A55\u8AD6\u592A\u9577\u4E86",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"\u6D4F\u89C8",
								rating:"\u8BC4\u5206",
								view_all:"\u8ACB\u770B",
								sort_by:"\u5206\u7C7B"
							};		
							break;
				case "ko":	self.config.translations=
							{
								write_a_comment:"\uB313\uAE00 \uC4F0\uAE30",
								submit:"\uB4F1\uB85D",
								cancel:"\uCDE8\uC18C",
								added_a_comment:"\uB313\uAE00 \uCD94\uAC00\uD568",
								up_next:"\uBCF4\uAE30",
								related_videos:"\uAD00\uB828 \uBE44\uB514\uC624",
								channels:"\uCC44\uB110",
								videos:"\uBE44\uB514\uC624",
								episodes:"\uAD00\uB828 \uC601\uC0C1",
								add_comment:"\uB313\uAE00 \uCD94\uAC00",
								read:"\uBCF4\uAE30",
								loading:"\uB85C\uB529 \uC911",
								newest:"\uCD5C\uC2E0",
								no_video_found:"\uAC80\uC0C9 \uACB0\uACFC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",
								comments:"\uB313\uAE00",
								no_comments:"\uC791\uC131\uB41C \uB313\uAE00\uC774 \uC5C6\uC2B5\uB2C8\uB2E4",
								no_comment_entered:"\uC785\uB825\uB41C \uB313\uAE00\uC774 \uC5C6\uC2B5\uB2C8\uB2E4",
								comment_too_long:"\uB313\uAE00\uC774 \uB108\uBB34 \uAE41\uB2C8\uB2E4",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"\uC870\uD68C\uC218",
								rating:"\uACF5\uAC10",
								view_all:"\uBCF4\uAE30",
								sort_by:"\uBD84\uB958"
							};		
							break;
				case "th":	self.config.translations=
							{
								write_a_comment:"\u0E40\u0E02\u0E35\u0E22\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19",
								submit:"\u0E2A\u0E48\u0E07",
								cancel:"\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
								added_a_comment:"\u0E44\u0E14\u0E49\u0E43\u0E2A\u0E48\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19",
								up_next:"\u0E14\u0E39\u0E14\u0E49\u0E27\u0E22",
								related_videos:"\u0E27\u0E35\u0E14\u0E34\u0E17\u0E31\u0E28\u0E19\u0E4C\u0E17\u0E35\u0E48\u0E40\u0E01\u0E35\u0E48\u0E22\u0E27\u0E02\u0E49\u0E2D\u0E07",
								channels:"\u0E0A\u0E48\u0E2D\u0E07",
								videos:"\u0E27\u0E35\u0E14\u0E34\u0E17\u0E31\u0E28\u0E19\u0E4C",
								episodes:"\u0E15\u0E2D\u0E19",
								add_comment:"\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19",
								read:"\u0E14\u0E39",
								loading:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14",
								newest:"\u0E43\u0E2B\u0E21\u0E48\u0E25\u0E48\u0E32\u0E2A\u0E38\u0E14",
								no_video_found:"\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
								comments:"\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19",
								no_comments:"\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E40\u0E02\u0E35\u0E22\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19\u0E43\u0E14\u0E46",
								no_comment_entered:"\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E43\u0E2A\u0E48\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19",
								comment_too_long:"\u0E02\u0E49\u0E2D\u0E04\u0E34\u0E14\u0E40\u0E2B\u0E47\u0E19\u0E22\u0E32\u0E27\u0E40\u0E01\u0E34\u0E19\u0E44\u0E1B",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"\u0E21\u0E38\u0E21\u0E21\u0E2D\u0E07",
								rating:"\u0E01\u0E32\u0E23\u0E43\u0E2B\u0E49\u0E04\u0E30\u0E41\u0E19\u0E19",
								view_all:"\u0E14\u0E39",
								sort_by:"\u0E40\u0E23\u0E35\u0E22\u0E07\u0E25\u0E33\u0E14\u0E31\u0E1A\u0E15\u0E32\u0E21"
							};			
							break;
				case "pt":	self.config.translations=
							{
								write_a_comment:"ESCREVER UM COMENT\u00C1RIO",
								submit:"ENVIAR",
								cancel:"CANCELAR",
								added_a_comment:"Fez um coment\u00E1rio",
								up_next:"Ver tamb\u00E9m",
								related_videos:"V\u00EDdeos relacionados",
								channels:"Canais",
								videos:"V\u00EDdeos",
								episodes:"\u00C9pis\u00F3dios",
								add_comment:"ADICIONAR COMENT\u00C1RIO",
								read:"VISUALIZAR",
								loading:"carregando",
								newest:"MAIS NOVOS",
								no_video_found:"Nenhum resultado",
								comments:"Coment\u00E1rios",
								no_comments:"N\u00E3o existe nenhum comentario",
								no_comment_entered:"Nenhum comentario foi enviado",
								comment_too_long:"O coment\u00E1rio \u00E9 longo demais",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"VISUALIZA\u00C7\u00D5ES",
								rating:"EVALUA\u00C7\u00C3O",
								view_all:"VISUALIZAR",
								sort_by:"CLASSIFICAR POR"
							};			
							break;
				case "it":	self.config.translations=
							{
								write_a_comment:"SCRIVI UN COMMENTO",
								submit:"INOLTRA",
								cancel:"ANNULLA",
								added_a_comment:"Hai aggiunto un commento",
								up_next:"Vedi anche",
								related_videos:"Video associati",
								channels:"Canali",
								videos:"Video",
								episodes:"Episodi",
								add_comment:"AGGIUNGI UN COMMENTO",
								read:"VISUALIZZA",
								loading:"sta caricando",
								newest:"NUOVISSIMO",
								no_video_found:"Non \u00E8 stato trovato niente.",
								comments:"Commenti",
								no_comments:"Non sono stati fatti commenti.",
								no_comment_entered:"Non \u00E8 stato inserito alcun commento",
								comment_too_long:"Il commento \u00E8 troppo lungo",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"VISUALIZZAZIONI",
								rating:"CLASSIFICAZIONE",
								view_all:"VISUALIZZA",
								sort_by:"ORDINA PER"
							};
							break;
				case "fr":	self.config.translations=
							{
								write_a_comment:"\u00C9CRIRE UN COMMENTAIRE",
								submit:"ENVOYER",
								cancel:"ANNULER",
								added_a_comment:"A fait un commentaire",
								up_next:"Voir aussi",
								related_videos:"Vid\u00E9os li\u00E9s",
								channels:"Cha\u00EEnes",
								videos:"Vid\u00E9os",
								episodes:"\u00C9pisodes",
								add_comment:"AJOUTER UN COMMENTAIRE",
								read:"VISUALISER",
								loading:"chargement en cours",
								newest:"PLUS NOUVEAUX",
								no_video_found:"Aucun r\u00E9sultat",
								comments:"Commentaires",
								no_comments:"Aucun commentaire n'a \u00E9t\u00E9 fait",
								no_comment_entered:"Aucun commentaire n'a \u00E9t\u00E9 saisi",
								comment_too_long:"Le commentaire est trop long",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"VISUALISATIONS",
								rating:"\u00C9VALUATION",
								view_all:"VISUALISER",
								sort_by:"CLASSER PAR"
							};
							break;
				case "es":	self.config.translations=
							{
								write_a_comment:"ESCRIBIR UN COMENTARIO",
								submit:"ENVIAR",
								cancel:"CANCELAR",
								added_a_comment:"Envi\u00F3 un comentario",
								up_next:"Ver tambi\u00E9n",
								related_videos:"Videos relacionados",
								channels:"Canales",
								videos:"Videos",
								episodes:"Episodios",
								add_comment:"HACER UN COMENTARIO",
								read:"VISUALIZAR",
								loading:"Cargando",
								newest:"M\u00C1S NUEVOS",
								no_video_found:"Ning\u00FAn resultado",
								comments:"Comentarios",
								no_comments:"No existe ning\u00FAn comentario",
								no_comment_entered:"Ning\u00FAn comentario fue enviado",
								comment_too_long:"El comentario es demasiado largo",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"VISUALIZACIONES",
								rating:"CLASIFICACI\u00D3N",
								view_all:"VISUALIZAR",
								sort_by:"CLASIFICAR POR"
							};
							break;
				case "de":	self.config.translations=
							{
								write_a_comment:"KOMMENTAR SCHREIBEN",
								submit:"ABSCHICKEN",
								cancel:"ABBRECHEN",
								added_a_comment:"Kommentar hinzugef\u00FCgt",
								up_next:"Siehe auch",
								related_videos:"Verwandte Videos",
								channels:"Kan\u00E4le",
								videos:"Videos",
								episodes:"Folgen",
								add_comment:"KOMMENTAR HINZUF\u00DCGEN",
								read:"ANSEHEN",
								loading:"Ladevorgang l\u00E4uft",
								newest:"NEUESTE",
								no_video_found:"Es wurde nichts gefunden.",
								comments:"Kommentare",
								no_comments:"Es wurden keine Kommentare abgegeben.",
								no_comment_entered:"Es wurde kein Kommentar eingegeben.",
								comment_too_long:"Der Kommentar ist zu lang.",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"ANSICHTEN",
								rating:"RATING",
								view_all:"ANSEHEN",
								sort_by:"SORTIEREN NACH"
							};
							break;
				default:	self.config.translations=
							{
								write_a_comment:"WRITE A COMMENT",
								submit:"submit",
								cancel:"Cancel",
								added_a_comment:"added a comment",
								up_next:"Up Next",
								related_videos:"Related Videos",
								channels:"Channels",
								videos:"Videos",
								episodes:"Episodes",
								add_comment:"ADD COMMENT",
								read:"VIEW",
								loading:"loading",
								newest:"NEWEST",
								no_video_found:"Nothing was found.",
								comments:"Comments",
								no_comments:"No comments have been made.",
								no_comment_entered:"no comment entered",
								comment_too_long:"comment is too long!",
								report_abuse:"Report Abuse",
								report_abuse_desc:"What is the primary reason you are reporting this message as abusive?",
								views:"views",
								rating:"rating",
								view_all:"view all",
								sort_by:"Sort By"
							};
							break;
			}
		};
		self.init();
	}
	
	//front end objects:
	function VideoWallFrontEnd(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			self.container=JQ('div#video_wall');
			self.container.addClass('right_background');
			
			self.video_player=new VideoPlayer(self);
			self.left_side=new WallLeftSide(self);
			self.right_side=new WallRightSide(self);
			
			self.mode='video';
			
			self.events=
			{
				open_video:function(video)
				{
					self.guid=video.guid;
					self.video_player.change_video(video);
					self.left_side.video_detail.change_video(video);
					JQ('html, body').animate({scrollTop:	JQ('div#wall_video_player').offset().top	}, 'slow');
					
					if(video.tags.length>0 && self.left_side.left_video_section.tabs.get_tab()!='episodes' && self.left_side.left_video_section.tabs.get_tab()!='related_videos')
						self.events.load_related_videos(video);
					else if(self.left_side.left_video_section.tabs.get_tab()!='related_videos')
						self.left_side.left_video_section.tabs.hide_tab('related_videos');
					
					//update right side:
					self.left_side.left_comment_section.change_video(video);
					self.right_side.right_info.video_changed(video);
				},
				open_channel_episodes:function(id)
				{
					self.left_side.left_video_section.tabs.hide_tab('related_videos');
					self.left_side.left_video_section.tabs.show_tab('episodes');
					self.left_side.left_video_section.tabs.open_tab('episodes');
					self.left_side.left_video_section.grids['episodes'].configure({type:'channel',channel_id:id});
				},
				load_related_videos:function(video)
				{
					self.left_side.left_video_section.tabs.hide_tab('episodes');
					self.left_side.left_video_section.grids['related_videos'].configure({type:'related_videos',tags:video.tags});
				},
				open_guid:function(guid)
				{
					parent.video_manager.load_guid(guid,function(data)
					{
						self.events.open_video(data.items[0]);
					});
				},
				toggle:function(add)
				{
					if(self.mode=='video')
						self.mode='comment';
					else
						self.mode='video';
					
					self.left_side.toggle(add);
					self.right_side.toggle();	
				}
			};
		};
		self.init();
	}
	
	function VideoPlayer(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div id=\"wall_video_player\"></div>");
			self.container=JQ('div#wall_video_player');
			self.guid=null;
		};
		this.change_video=function(video)
		{
			if(!video || !video.guid)
				return;
				
			var thumb=JQ("div.video_thumb[rel='"+video.guid+"']");
			if(thumb.length>0 && !thumb.hasClass('active'))
			{
				thumb.click();
				return;
			}
			
			var player = new SWFObject("/nikeos/global/modules/video/v1/swf/video_player_v2_0.swf", "feature", "908", "510", "9.0.28", "#ffffff");
			player.addParam("scale", "noscale");
			player.addParam("allowScriptAccess", "always");
			player.addParam("allowFullScreen", "true");
			player.addParam("wmode", "transparent");
			player.addVariable("locale", parent.parent.config.locale);
			player.addVariable("guid", video.guid);
			player.addVariable("regionConfig",parent.parent.config.video_player.regionConfig);
			player.addVariable("siteConfig",parent.parent.config.video_player.siteConfig);
			player.addVariable("trackerObject", escape(JSON.stringify(nav_tracker_obj)));
			
			var url=location.href;
			var hash=location.hash;
			var search=location.search;
			var pathname=location.pathname;
			if(hash.length>1)
				url="http://"+location.hostname+pathname+hash.replace("#","");
			
			player.addVariable("currentUrl",escape(url));
			
			//autoplay:
			if(self.guid && self.guid!=null)
				player.addVariable("autoPlay", "true");
			
			var write=player.write("wall_video_player");
			if(!write)
				self.container.html("<div id=\"noflash\"><a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\"><img src=\"/sportswear/global/images/no_flash.jpg\" border=\"0\"></a></div>");
			self.guid=video.guid;

		};
		this.get_guid=function()
		{
			return self.guid;
		};
		self.init();
	}
	function VideoDetail(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div class=\"video_detail\"></div>");
			self.container=JQ('.video_detail');
			
			//dummy container for sizing shit
			parent.container.append("<div class=\"video_detail far_off\"></div>");
			self.dummy_container=JQ('.video_detail.far_off');
		};
		this.change_video=function(video)
		{
			var height=self.container.height();
			self.render_video(video);
		};
		this.render_video=function(video)
		{
						
			var str ="<div class=\"active_text title border\">"+video.title+"</div>";
				str+="<div class=\"light_text under_title\" >";
				str+=date_str(video.date);
				str+=" - "+video.views+" "+parent.parent.parent.config.translations.views;
				str+="</div>";
				str+="<div class=\"standard_text description\">"+video.description+"</div>";
			self.dummy_container.html(str);
						
			var height=self.dummy_container.height();
			self.container.html(str).css({height:height});
			
			
			if(video.description.length==0)
				self.container.find(".description").hide();
			else
				self.container.find(".description").show();	
			};
		self.init();
	}
	
	function WallLeftSide(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			self.mode='video';
			parent.container.append("<div id=\"wall_left_side\" class=\"left_background\" ><div id=\"wall_left_content\"></div></div>");
			self.container=JQ('div#wall_left_content');
		
			self.video_detail=new VideoDetail(self);
			self.left_video_section=new LeftVideoSection(self);
			self.left_comment_section=new LeftCommentSection(self);
		};
		this.toggle=function(add)
		{
			if(self.mode=='video')
			{
				self.left_video_section.hide();
				self.left_comment_section.show(add);
				self.mode='comments';
			}
			else
			{
				self.left_comment_section.hide();
				self.left_video_section.show();
				self.mode='video';
			}
		};
		self.init();
	}
	
	//--Video Section Objects - Left Side:
	function LeftVideoSection(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			parent.container.append("<div id=\"left_video_content\"></div>");
			self.container=JQ('#left_video_content');
			
			self.tabs=new VideoTabs(self);
			
			self.container.append("<div id=\"left_grid_content\"></div>");
			self.content=JQ('#left_grid_content');
			
			self.tabs.add_tab('related_videos',parent.parent.parent.config.translations.related_videos,{type:'related_videos'});
			self.tabs.add_tab('videos',parent.parent.parent.config.translations.videos,{type:'channel',channel_id:parent.parent.parent.config.all_wall_channel_id});
			self.tabs.add_tab('channels',parent.parent.parent.config.translations.channels);
			self.tabs.add_tab('episodes',parent.parent.parent.config.translations.episodes,{type:'channel'});
			
			self.tabs.hide_tab('related_videos');
			self.tabs.hide_tab('episodes');

		};
		this.hide=function()
		{
			self.container.hide();
		};
		this.show=function()
		{
			self.container.show();
		};
		self.init();
	}	
	function VideoTabs(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div id=\"video_tabs_wrapper\"><div id=\"video_tabs\" class=\"\" ></div><div class=\"clearme\"></div></div>");
			self.container=JQ('#video_tabs');
			self.currently_active_tab=null;
			self.tabs={};
			self.tracking_go=false;
		};
		this.get_tabs=function()
		{
			return self.tabs;			
		};
		this.add_tab=function(id,label,config)
		{
			self.tabs[id]={id:id,label:label,total:0};
			
			var str="<div class=\"video_tab\" id=\"tab_"+id+"\"><div class=\"left\"></div><div class=\"tab_content_div\">"+label+"<span>(0)</span></div><div class=\"clearme\"></div></div>";
			self.container.append(str);
			self.container.find('div.video_tab').click(	function(){	self.open_tab(JQ(this).attr('id').replace('tab_','') );	}	);
			self.container.find('div.video_tab').hover(function()
			{
				JQ(this).addClass('hover_text');
				//JQ(this).find('span').addClass('light_text');
			},function()
			{
				if(!JQ(this).hasClass('active'))
					JQ(this).removeClass('hover_text');
				//JQ(this).find('span').removeClass('light_text');
			});
			
			parent.content.append("<div id=\"tab_content_"+id+"\" class=\"tab_content\" >"+label+"</div>");
			
			if(!parent.grids)
				parent.grids={};
			
			if(id!='channels')	
				parent.grids[id]=new VideoGrid(parent,id,config);
			else
				parent.grids[id]=new ChannelGrid(parent,id);	
		};
		this.set_total=function(id,total)
		{
			self.tabs[id].total=total;
			self.container.find('div#tab_'+id+' span').html('('+total+')');
		};
		this.open_tab=function(id)
		{
			var tab=self.container.find('div#tab_'+id);

			if(	tab.hasClass('active')	)
				return;

			//tracking fix:
			if(self.tracking_go)
				tracking.click({pageName:track_site+">media>video>"+id,prop18:"media",prop19:"video"});
			self.tracking_go=true;	
			
			var active_tab=self.container.find('div.video_tab.active');
			active_tab.removeClass('hover_text').removeClass('active');

			if(	active_tab.attr('id')	)
				parent.content.find('#tab_content_'+active_tab.attr('id').replace('tab_','')).removeClass('active');
			
			tab.show();
			tab.addClass('active');
			tab.addClass('hover_text');

			parent.content.find('#tab_content_'+id).addClass('active');
			self.currently_active_tab=id;
		};
		this.get_tab=function()
		{
			return self.currently_active_tab;
		};
		this.show_tab=function(id)
		{
			self.container.find('div#tab_'+id).show();
		};
		this.hide_tab=function(id)
		{
			self.container.find('div#tab_'+id).hide();
			parent.content.find('div#tab_content_'+id).removeClass('active');
		};
		self.init();
	}	
	function VideoGrid(parent,id,config)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			self.container=JQ('#tab_content_'+id);
			self.container.empty();
			self.sort='date';
			self.sort_menu=new VideoGridSort(self);
			self.top_paging=new Paging(self);
			self.container.append("<div class=\"video_result_content\">CONTENT</div>");
			self.content=self.container.find('div.video_result_content');
			self.bot_paging=new Paging(self,true);
			self.configure(config);
		};
		this.configure=function(data)
		{
			self.configuration=data;
			self.page=1;
			
			if(id=='episodes')
				self.open=true;
				
			if((self.configuration.type=='channel' && self.configuration.channel_id)||(self.configuration.type=='related_videos'&&self.configuration.tags))
				self.set_page(1);
		};
		self.fetch_channel=function(channel_id,page,sort)
		{
			if(sort)
				self.sort=sort;
				
			self.container.css({opacity:0});
			parent.parent.parent.parent.video_manager.load_channel(channel_id,page,self.sort,self.fetched_channel);				
		};
		self.set_sort=function(sort)
		{
			self.sort=sort;
			self.page=1;
			self.fetch_channel(self.configuration.channel_id,1,sort);
		};
		self.set_channel_page=function(page)
		{
			self.page=page;
			self.fetch_channel(self.configuration.channel_id,page);
		};
		self.fetched_channel=function(data,related)
		{
			//set total:
			parent.tabs.set_total(id,data.total);
			
			if(related)
			{
				if(data.total>1)
					parent.tabs.show_tab('related_videos');
				else
					parent.tabs.hide_tab('related_videos');	
			}
			
			//sync up paging:
			if(data.totalPages>1)
			{
				self.top_paging.set_page(self.page,data.totalPages);
				self.bot_paging.set_page(self.page,data.totalPages);
				self.container.find('.paging').css('visibility','visible');				
			}
			else
			{
				self.container.find('.paging').css('visibility','hidden');
			}
			
			//render thumbnails:
			var str="";
			for(var p=0;p<data.items.length;p++)
			{
				str+="<div class=\"video_thumb";
					
				if(data.items[p].guid==parent.parent.parent.video_player.get_guid())
					str+=" active";
						
				str+="\" rel=\""+data.items[p].guid+"\">";
				str+="	<div class=\"thumb_wrapper\"><img src=\""+data.items[p].thumb+"\" class=\"\" /><div class=\"overlay\"></div></div>";
				str+="	<div class=\"thumb_detail\">";
				str+="		<div class=\"title\">"+data.items[p].title+"</div>";
				str+="		<div class=\"date light_text\">"+date_str(data.items[p].date)+"</div>";
				str+="		<div class=\"views light_text\">"+data.items[p].views+" Views</div>";

				
				//--put rating star logic in here:
				var rating=data.items[p].rating;
				var rating_str="";
				var star_count=0;
				while(rating>=1)
				{
					rating_str+="<img src=\""+parent.parent.parent.parent.config.images.star_active+"\" />";
					star_count++;
					rating-=1;
				}
				if(rating>=0.5)
				{
					rating_str+="<img src=\""+parent.parent.parent.parent.config.images.star_half+"\" />";
					star_count++;
				}
				for(var i=0;i<(5-star_count);i++)
					rating_str+="<img src=\""+parent.parent.parent.parent.config.images.star_inactive+"\" />";
						
				str+="		<div class=\"views light_text\">"+rating_str+"</div>";
				str+="	</div>";	
				
				str+="	<div class=\"hidden description\">"+data.items[p].description+"</div>";
				str+="</div>";
					
				if((p+1)%4==0 && p!=0)
					str+="<div class=\"clearme\"></div>";
			}
			
			self.content.html(str);
			
			//for redraw:
			self.content.find('.video_thumb.active .overlay').html("<img src=\""+parent.parent.parent.parent.config.images.thumbnail_overlay+"\" />").css({opacity:.8,visibility:'visible'});
			
			//thumbnail hover:
			self.content.find('.video_thumb').hover(function()
			{
				if(JQ(this).hasClass('active'))
					return;
				
				var desc=JQ(this).find('div.description').html();
				if(desc.length>0 && desc.indexOf("undefined")==-1)
					desc="<div class=\"desc\">"+limit_string(desc,70)+"</div>";
				else
					desc="<img src=\""+parent.parent.parent.parent.config.images.thumbnail_overlay+"\" />";
				
				self.content.find('.video_thumb').not('.active').find('.overlay').css({visibility:'hidden'});
				
				JQ(this).find('.overlay').html(desc).css({opacity:.8,visibility:'visible'});
			},function()
			{
				if(JQ(this).hasClass('active'))
					return;
				JQ(this).find('.overlay').css({visibility:'hidden'});
			});
			
			//on click:
			self.content.find('.video_thumb').click(function()
			{
				if(JQ(this).hasClass('active'))
					return;
				
				self.content.find('.video_thumb.active').removeClass('active').find('.overlay').css('visibility','hidden');
				
				var guid=JQ(this).attr('rel');
				
				JQ(this).addClass('active');
				JQ(this).find('.overlay').html("<img src=\""+parent.parent.parent.parent.config.images.thumbnail_overlay+"\" />").css({visibility:'visible',opacity:0.8});
				
				location.href="#?guid="+guid;
				var vid=parent.parent.parent.parent.video_manager.cached_vids[guid];
				parent.parent.parent.events.open_video(vid);

			});
			
			if(id=='videos' && (!parent.parent.parent.video_player.guid || parent.parent.parent.parent.initial_guid))
			{
				if (!_vw.initial_channel)
					parent.tabs.open_tab(id);
				
				if(!parent.parent.parent.parent.initial_guid && !_vw.initial_channel)
					self.container.find('div.video_thumb:first').click();
				else if(!parent.parent.parent.parent.initial_guid && _vw.initial_channel)
					parent.parent.parent.events.open_channel_episodes(_vw.initial_channel);
			}
		
			self.container.css({opacity:1});
			
			if(self.open)
			{
				parent.tabs.show_tab('episodes');
				parent.tabs.open_tab('episodes');
				
				//load the initial video if deep linked into channel
				if (_vw.initial_channel > -1) {
					_vw.initial_channel = -1;
					self.parent.container.find('#tab_content_episodes').find('div.video_thumb:first').click();
				}
			}
		};
		self.set_page=function(page)
		{
			if(self.configuration.type=='channel')
				self.set_channel_page(page);
			else if(self.configuration.type=='related_videos')
				self.set_related_videos_page(page);
		};
		self.set_related_videos_page=function(page)
		{
			self.page=page;
			self.fetch_related_videos(self.configuration.tags,page);
		};
		self.fetch_related_videos=function(tags,page)
		{
			self.container.css({opacity:0});
			parent.parent.parent.parent.video_manager.load_tags(tags.replace(" ",","),page,'date',function(data)
			{
				self.fetched_channel(data,true);
			});
		};
		self.init();
	}
	function ChannelGrid(parent,id)
	{
		var self=this;
		this.init=function()
		{
			self.container=JQ('#tab_content_'+id);
			var channels=parent.parent.parent.parent.config.sub_channels;
			parent.tabs.set_total(id,channels.length);
			
			self.total=channels.length;
			
			var channels_str="";
			for(var i=0;i<parent.parent.parent.parent.config.sub_channels.length;i++)
			{
				if(typeof parent.parent.parent.parent.config.sub_channels[i]._attributes!="undefined")
					parent.parent.parent.parent.config.sub_channels[i]=parent.parent.parent.parent.config.sub_channels[i]._attributes;
				channels_str+=parent.parent.parent.parent.config.sub_channels[i].id+",";
			}
			
			var url="/nikeos/p/nikeos/en_US/video_wall/channel_totals?locale="+parent.parent.parent.parent.config.locale+"&channels="+channels_str;
			parent.parent.parent.parent.ajax_tunnel.issue(
				{
					u:url,
					data:{},
					c:function(data)
					{
						self.channel_totals=data;
						var str="";
						for(var i=0;i<channels.length;i++)
						{
							str+="<div class=\"channel_tout\" rel=\""+channels[i].id+"\">";
							str+="	<img src=\""+channels[i].img+"\"/>";
							str+="	<div class=\"bottom\">";
							str+="		<div class=\"title standard_text\">"+channels[i].title+"</div>";
							str+="		<div class=\"episodes light_text\"><span class=\"active_text\">"+self.channel_totals[channels[i].id]+"</span> "+parent.parent.parent.parent.config.translations.episodes.toLowerCase()+"</div>";
							str+="	</div>";
							str+="</div>";
						}
						self.container.html(str);
						self.container.find('.channel_tout').click(function()
						{
							var _channel = JQ(this).attr('rel');
							tracking.click({pageName:track_site+">media>video>channels>"+JQ(this).find('.title').html(),prop18:"media",prop19:"video"});
							location.href="#?channel="+_channel;
							parent.parent.parent.events.open_channel_episodes(_channel);
							parent.tabs.set_total('episodes', JQ(this).find('div.episodes>span.active_text').html());
						});
					}
				});
		};
		this.redraw=function(){};
		self.init();
	}	
	function VideoGridSort(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div class=\"video_grid_sort\"></div>");
			self.container=parent.container.find('.video_grid_sort');
			self.build_sort();
		};
		this.build_sort=function()
		{
			var str="";
			str+="<div class=\"sort_by_videowall\">"+parent.parent.parent.parent.parent.config.translations.sort_by+":</div>";
			str+="<div class=\"sort_items\">";
			str+="	<div class=\"sort_option active_option\" id=\"sort_date\" rel=\"date\" ><div class=\"left_sort\"></div><div class=\"sort_option_content\">"+parent.parent.parent.parent.parent.config.translations.newest+"</div><div class=\"clearme\"></div></div>";
			str+="	<div class=\"sort_option\" rel=\"views\" id=\"sort_views\" ><div class=\"sort_option_content\">"+parent.parent.parent.parent.parent.config.translations.views+"</div><div class=\"clearme\"></div></div>";
			str+="	<div class=\"sort_option\" rel=\"rating\" id=\"sort_rating\" ><div class=\"sort_option_content\">"+parent.parent.parent.parent.parent.config.translations.rating+"</div><div class=\"right_sort\"></div><div class=\"clearme\"></div></div>";
			str+="	<div class=\"clearme\"></div>";
			str+="</div>";
			self.container.html(str);
			
			//click on sort button
			self.container.find('.sort_option').click(function()
			{
				if(JQ(this).hasClass('active_option'))
					return;
				self.container.find('.sort_option.active_option').removeClass('active_option');
				JQ(this).addClass('active_option');
				
				parent.set_sort(	JQ(this).attr('rel')	);
			});
			
			//hover over sort button
			self.container.find('.sort_option').hover(function()
			{
				if(!JQ(this).hasClass('active_option'))
					JQ(this).addClass('standard_text');
			},function()
			{
				JQ(this).removeClass('standard_text');
			});
		};
		self.init();
	}
	
	//Comment Section Modules - Left Side:
	function LeftCommentSection(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			self.guid=false;
			self.page=0;
			self.per_page=8;
			parent.container.append("<div id=\"left_comment_section\"></div>");
			self.container=JQ('#left_comment_section');
			self.build_frame();
		};
		this.build_frame=function()
		{
			self.container.append("<div class=\"title\"><div class=\"title_content\">"+parent.parent.parent.config.translations.comments+"<span class=\"active_text\"></span></div></div>");
			self.top_paging=new Paging(self,false,self.container.find('.title'));
			self.container.find('div.title').append("<div class=\"clearme\"></div>");
			
			self.container.append("<div class=\"write_comment_btn write_top light_text\">"+parent.parent.parent.config.translations.write_a_comment+"<img src=\""+parent.parent.parent.config.images.pencil+"\" /></div>");
			self.post_form=new PostForm(self);
						
			self.container.append("<div class=\"comment_result_content\">CONTENT</div>");
			self.content=self.container.find('div.comment_result_content');
			self.bot_paging=new Paging(self,true);
			
			//self.container.append("<div class=\"write_comment_btn write_bot light_text\">"+parent.parent.parent.config.translations.write_a_comment+"<img src=\""+parent.parent.parent.config.images.pencil+"\" /></div>");
			
			//--activate frame buttons:
			
			//--'write a 
			//--top 'write a comment' link
			self.container.find('div.write_comment_btn:first').click(self.post_form.toggle);
			//--bottom 'write a comment' link
			/*self.container.find('div.write_comment_btn:last').click(function()
			{
				JQ('html, body').animate({scrollTop:	JQ('div#left_comment_section').offset().top	}, 'slow');
				self.post_form.toggle();
			});*/
			//--hover
			self.container.find('div.write_comment_btn').each(function()
			{
				JQ(this).hover(function(){	JQ(this).addClass('standard_text');	},function(){	JQ(this).removeClass('standard_text');	});
			});
		};
		this.hide=function(){self.container.hide();};
		this.change_video=function(video)
		{
			self.guid=video.guid;
			self.page=1;
		};
		this.show=function(add)
		{
			parent.parent.parent.comment_manager.load_thread(self.guid,function(data)
			{
				self.data=data;
				self.post_form.build_form();
				self.set_page();
				self.container.show();
				if(add==true)
					self.post_form.toggle(add);
			});
		};
		this.set_page=function(page)
		{
			if(page)
				self.page=page;
			if(!self.data.messages)
				self.data.messages=[];
			var total_pages=Math.ceil((self.data.messages.length)/self.per_page);
			
			self.container.find('div.title>div.title_content>span').html("("+self.data.messages.length+")");
			
			self.top_paging.set_page(self.page,total_pages);
			self.bot_paging.set_page(self.page,total_pages);

			if(total_pages<2)
			{
				self.top_paging.hide();
				self.bot_paging.hide();
			}
			else
			{
				self.top_paging.show();
				self.bot_paging.show();
			}
			self.render();
		};
		this.render=function()
		{
			var str="";
			var messages=self.data.messages;
			var start=self.per_page*(self.page-1);
			var end=self.per_page*self.page;

			if(messages)
			{
				for(var i=0;i<messages.length;i++)
				{
					if(messages[i]!=null && i>=start && i<end )
					{
						str+="<div class=\"comment_wrapper no_avatar\" style=\"background:url("+parent.parent.parent.config.images.comment_bg+") repeat-y left top;\" >";
						str+="	<div class=\"comment_top\" style=\"background:url("+parent.parent.parent.config.images.comment_top+") no-repeat left top;\" ></div>";
						str+="	<div class=\"post_left\">";
						str+="		<div class=\"username comment_username\">"+messages[i].username+"</div>";
						str+="		<div class=\"date comment_date\">"+messages[i].date+"</div>";
						str+="	</div>";
						str+="	<div class=\"post_right\">";
						str+="		<div class=\"body comment_body\">";
						str+=			messages[i].body;

						if(!messages[i].abuse)
						{
							if(messages[i].message_id)
								str+="	<div class=\"flag_comment\" id=\"message_"+messages[i].message_id+"\"><a href=\"javascript:;\" class=\"flag\"><img src=\""+parent.parent.parent.config.images.no_abuse_img+"\" /></a></div>";
						}
						else
							str+="	<div class=\"flag_comment\" ><img src=\""+parent.parent.parent.config.images.abuse_img+"\" /></div>";
						
						str+=		"</div>";
						str+="	</div>";
						str+="	<div class=\"clearme\"></div>";
						str+="	<div class=\"comment_bottom_row\" style=\"background:url("+parent.parent.parent.config.images.comment_bottom+") no-repeat left top;\" ></div>";
						str+="</div>";
					}
				}
			}
			
			if(!messages || messages.length==0)
				str="<div class=\"no_comments_left light_text\">"+parent.parent.parent.config.translations.no_comments+"</div>";
			
			self.content.html(str);
			self.content.find('div.flag_comment>a.flag').click(function()
			{
				var message_id=JQ(this).parent().attr('id').replace('message_','');
				self.showForm(message_id);
			});
		};
		this.showForm=function(id)
		{
			var str="";
			
			str+="<div class=\"flag_form left_background\">";
			str+="	<div class=\"report_abuse_title active_text\">"+parent.parent.parent.config.translations.report_abuse+"</div>";
			str+="	<div class=\"report_abuse_desc standard_text\">"+parent.parent.parent.config.translations.report_abuse_desc+"</div>";
			str+="	<textarea id=\"comments\" class=\"report_abuse_textarea border\" ></textarea>";
			str+="	<div class=\"bot_row\">";
			str+="		<a href=\"javascript:;\" class=\"report_abuse_submit active_text\" >"+parent.parent.parent.config.translations.report_abuse+"</a>";
			str+="		<a href=\"javascript:;\" class=\"cancel light_text\" >"+parent.parent.parent.config.translations.cancel+"</a>";
			str+="	</div>";
			str+="</div>";
			
			parent.parent.parent.popup.set(str);
			parent.parent.parent.popup.show();
			
			
			JQ('div.flag_form a.report_abuse_submit').click(function()
			{
				parent.parent.parent.comment_manager.flagMessage(id, JQ('div.flag_form textarea').val(), self.hideForm);
				JQ('div.flag_form').html("<div class=\"loading standard_text\">loading</div>");
			});
			
			JQ('div.flag_form a.cancel').click(function()
			{
				parent.parent.parent.popup.close();
			});
		};
		this.hideForm=function()
		{
			//reload comments:
			self.set_page(1);
			self.show();
			parent.parent.parent.popup.close();
		};
		self.init();
	}
	
	function PostForm(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div id=\"post_comment_form_wrapper\"></div>");
			self.container=parent.container.find('div#post_comment_form_wrapper');
		};
		this.build_form=function()
		{
			var str="";
			str+="<div class=\"post_form no_avatar\">";
			str+="	<div class=\"no_avatar_wrapper\" style=\"background:url("+parent.parent.parent.parent.config.images.form_post_bg+") repeat-y left top;\">";
			str+="		<div class=\"post_form_top\" style=\"background:url("+parent.parent.parent.parent.config.images.form_comment_top+") no-repeat left top\" ></div>";
			str+="		<div class=\"post_left\">";
			str+="			<div class=\"username comment_username\">"+parent.data.username+"</div>";
			str+="		</div>";
			str+="		<div class=\"message\">";
			str+="			<div class=\"message_wrapper\">";
			str+="				<div class=\"message_input\"><textarea id=\"message\" class=\"comment_body\" ></textarea></div>";
			str+="			</div>";			
			str+="		</div>";
			str+="		<div class=\"clearme\"></div>";
			str+="		<div class=\"post_form_bot\"  style=\"background:url("+parent.parent.parent.parent.config.images.form_comment_bottom+") no-repeat left top\" ></div>";
			str+="	</div>";
			
			str+="	<div class=\"message_wrapper_options\">";
			str+="		<div class=\"remaining_chars light_text\">"+parent.data.chars_remaining+": <span>500</span></div>";				
			str+="		<a href=\"javascript:f();\" class=\"submit active_text\" >"+parent.parent.parent.parent.config.translations.submit+"</a>";
			str+="		<a href=\"javascript:f();\" class=\"cancel light_text\" >"+parent.parent.parent.parent.config.translations.cancel+"</a>";				
			str+="		<div class=\"clearme\"></div>";
			str+="	</div>";
			str+="	<div class=\"message_wrapper_status active_text\"></div>";
			str+="</div>";
			
			self.container.html(str);
			
			self.container.find('textarea').focus().keyup(function()
			{
				var max=500;
				var num=500-self.container.find('div.post_form textarea').val().length;
				self.container.find('div.post_form div.remaining_chars>span').html(	num	);
			});
			
			self.container.find('a.cancel').click(function()
			{
				self.container.find('textarea').val('');
				self.toggle();
				return false;
			});
			self.container.find('a.submit').click(function()
			{
				//check comment out:
				var comment=JQ.trim(self.container.find('textarea').val());
				self.container.find('div.message_wrapper_options').hide();
			
				if(comment.length==0)
				{
					self.container.find('div.message_wrapper_status').html(parent.parent.parent.parent.config.translations.no_comment_entered).css('opacity',0).show().animate({opacity:1},400,function()
					{
						setTimeout(function()
						{
							JQ('div.message_wrapper_status').animate({opacity:0},400,function()
							{
								JQ('div.message_wrapper_options').show();JQ(this).hide();	
							});
						},500);
					});
					return false;
				}
				else if(comment.length>500)
				{
					self.container.find('div.message_wrapper_status').html(parent.parent.parent.parent.config.translations.comment_too_long).css('opacity',0).show().animate({opacity:1},400,function()
					{
						setTimeout(function()
						{
							JQ('div.message_wrapper_status').animate({opacity:0},400,function()
							{
								JQ('div.message_wrapper_options').show();
								JQ(this).hide();
							});
						},500);
					});
					return false;		
				}
				self.container.find('div.message_wrapper_status').html('submitting').css('opacity',0).show().animate({opacity:1},400);
			
				comment=comment.replace(new RegExp( "\\n", "g" ),"<br />");
				comment=comment.replace(new RegExp( "\\r", "g" ),"<br />");

				parent.parent.parent.parent.comment_manager.post_comment(comment,parent.data,function(data)
				{
					parent.set_page(1);
					parent.show();
				});

			});
		};
		this.toggle=function(open)
		{
			//--check if not logged in and bounce user to login page:
			if(!parent.data.user_exists)
			{
				location.href=parent.parent.parent.parent.config.login_url+"&continueURL="+escape(location.href);
				return;
			}
			
			self.build_form();

			if(self.container.css('display')=='none' || open)
				self.container.css('display','block');
			else
				self.container.css('display','none');
	
			if(self.container.css('display')!='none')
			{
				self.container.find('textarea').focus();
				tracking.click({pageName:track_site+">media>video>comments>write",prop18:"media",prop19:"video"});
			}
		};
		self.init();
	}
	
	//--Reused Left Side Modules:
	function Paging(parent,border,container)
	{
		var self=this;
		this.init=function()
		{
			self.page=1;
			self.totalPages=0;
			
			//--#s to each side of active paging #
			self.numbers=1;
			
			self.id=Math.ceil(Math.random()*10000000000000000);
			var borderclass="paging";
			if(typeof border != 'undefined' && border)
				borderclass+=" top_border border";
			
			if(!container)
				parent.container.append("<div class=\""+borderclass+"\" id=\"paging_"+self.id+"\" ></div>");
			else
				container.append("<div class=\""+borderclass+"\" id=\"paging_"+self.id+"\" ></div>");
			self.container=parent.container.find('div#paging_'+self.id);
		};
		this.render=function()
		{
			if(self.totalPages<=1)
				return self.hide();
			self.show();
			
			if(parent.constructor==VideoGrid)
				var config=parent.parent.parent.parent.parent.config;
			else
				var config=parent.parent.parent.parent.config;	
			
			self.container.empty();
			
			var str="";
			var start,end;

			if(self.page==1)
				str+="<a href=\"javascript:f();\" class=\"inactive\" ><img src=\""+config.images.prev_inactive+"\" /></a>";
			else
				str+="<a href=\"javascript:f();\" rel=\""+(self.page-1)+"\" ><img src=\""+config.images.prev_active+"\" /></a>";
			
			
			//get starting and ending # values:
			var j=self.totalPages;
			while(	j>(self.page-self.numbers)	&&	j>1 	)
				j--;
			start=j;
			
			end=start+2*self.numbers;
			if(end>self.totalPages)
				end=self.totalPages;
			
			while(start>1 && (end-start)<(2*self.numbers)	)
				start--;
			
			for(var i=start;i<=end;i++)
			{
				str+="<a href=\"javascript:f();\" ";
				if(self.page==i)
					str+="class=\"digit standard_text\"";
				else
					str+="class=\"digit light_text\"";
				str+="rel=\""+i+"\" >"+i+"</a>";
			}
			
			if(self.page==self.totalPages)
				str+="<a href=\"javascript:f();\" class=\"inactive\" ><img src=\""+config.images.next_inactive+"\" /></a>";
			else
				str+="<a href=\"javascript:f();\" rel=\""+(self.page+1)+"\" ><img src=\""+config.images.next_active+"\" /></a>";
			
			self.container.html(str);
			
			self.container.find('a').click(function(){return false;});
			self.container.find('a').not('.inactive').click(function(){	parent.set_page(parseInt(JQ(this).attr('rel')));});
			
		};
		this.set_page=function(page,total)
		{
			self.totalPages=total;
			self.page=page;
			self.render();
		};
		this.hide=function()
		{
			self.container.hide();
		};
		this.show=function()
		{
			self.container.show();
		};
		self.init();
	}	
	
	//-- Right Side Objects:
	
	function WallRightSide(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			parent.container.append("<div id=\"wall_right_side\" ><div id=\"wall_right_content\"></div></div>");
			self.container=JQ('div#wall_right_content');
			self.mode='video';
			
			self.right_info=new RightWallInfo(self);
			self.right_touts=new RightWallTouts(self);
		};
		this.toggle=function()
		{
			self.right_info.toggle();
		};
		self.init();
	}	
	
	function RightWallInfo(parent)
	{
		var self=this;
		this.init=function()
		{
			self.parent=parent;
			self.mode='video';
			parent.container.append("<div id=\"right_wall_info\"></div>");
			self.container=JQ('#right_wall_info');
			self.comments=new RightSideComments(self);
			self.videos=new RightSideVideos(self);
		};
		this.video_changed=function(video)
		{
			self.comments.video_changed(video);
		};
		this.toggle=function()
		{
			if(self.mode=='video')
			{
				self.mode='comment';
				self.comments.hide();
				self.videos.show();
			}
			else
			{
				self.mode='video';
				self.videos.hide();
				self.comments.show();
			}
		};
		self.init();
	}
	function RightSideVideos(parent)
	{
		var self=this;
		this.init=function()
		{
			parent.container.append("<div id=\"right_wall_videos\">HEY</div>");
			self.container=parent.container.find('#right_wall_videos');
			self.hide();
		};
		self.render=function()
		{
			var str="";
			str+="<div class=\"title border active_text\">"+parent.parent.parent.parent.config.translations.up_next+"</div>";
			
			var vids=parent.parent.parent.parent.video_manager.cached_vids;
			var guid=parent.parent.parent.video_player.get_guid();
			var vid=false;
			
			for(var p in vids)
			{
				if(p!=guid)
					vid=vids[p];
			}
			
			if(vid)
			{
				str+="<div class=\"up_next\">";
				str+="	<img class=\"thumb\" src=\""+vid.thumb+"\" />";
				str+="	<div class=\"title\">"+vid.title+"</div>";
				str+="</div>";
			}
			
			var tabs=parent.parent.parent.left_side.left_video_section.tabs.get_tabs();
			for(var p in tabs)
			{
				if(tabs[p].total>0 &&	JQ('#tab_'+tabs[p].id).css('display')!='none'	)
					str+="<div class=\"tab_section\" id=\"tab_section_"+tabs[p].id+"\" >"+tabs[p].label+" <span class=\"active_text\">("+tabs[p].total+")</span></div>";
			}
			self.container.html(str);
			self.container.find('.tab_section').click(function()
			{
				tracking.click({pageName:track_site+">media>video",prop18:"media",prop19:"video"});
				parent.parent.parent.events.toggle();
				parent.parent.parent.left_side.left_video_section.tabs.open_tab(JQ(this).attr('id').replace('tab_section_',''));
			});
			self.container.find('.tab_section').hover(function()
			{
				
			},function()
			{
				
			});
			self.container.find('div.up_next').click(function()
			{
				parent.parent.parent.events.toggle();
				parent.parent.parent.events.open_video(vid);
			});
			
			self.container.find('div.up_next, div.tab_section').hover(function()
			{
				JQ(this).addClass('active');
			},function()
			{
				JQ(this).removeClass('active');
			});
		
		};
		this.hide=function(){self.container.hide();};
		this.show=function(){self.render();self.container.show();};
		
		self.init();
	}
	function RightSideComments(parent)
	{
		var self=this;
		this.init=function()
		{
			self.guid=false;
			parent.container.append("<div id=\"right_wall_comments\"></div>");
			self.container=parent.container.find('#right_wall_comments');
		};
		this.video_changed=function(video)
		{
			//load comments based on this video and then render it out:
			parent.parent.parent.parent.comment_manager.load_thread(video.guid,function(data)
			{
				self.guid=video.guid;
				self.data=data;
				self.render();
			});
		};
		this.render=function()
		{
			var str="";
			str+="<div class=\"title active_text border\"><div class=\"title_text\" >"+self.data.messages_label+"</div>";
			if(self.data.messages&&self.data.messages.length>0)
				str+="<div class=\"view_all_link\">"+parent.parent.parent.parent.config.translations.view_all+"</div>";
			str+="<div class=\"clearme\"></div></div>";
			
			if(self.data.messages && self.data.messages.length>0)
			{
				str+="<div class=\"right_comment_bubble\">";
				str+="	<div class=\"right_comment_bubble_top\"></div>";
				str+="	<div class=\"message\">"+self.data.messages[0].body+"</div>";
				str+="	<div class=\"date\">"+self.data.messages[0].date+"</div>";
				str+="	<div class=\"right_comment_bubble_bottom\"></div>";
				str+="</div>";
				str+="<div class=\"right_comment_username\">"+self.data.messages[0].username+"</div>";
			}
			else
			{
				str+="<div class=\"no_comments\">"+parent.parent.parent.parent.config.translations.no_comments+"</div>";
			}

			str+="<div class=\"add_a_comment\">"+parent.parent.parent.parent.config.translations.add_comment+"</a>";


			self.container.html(str);
					
			self.container.find('.right_comment_username').hover(function()
			{
				JQ(this).addClass('active');
			},function()
			{
				JQ(this).removeClass('active');
			});
			
			self.container.find('.add_a_comment').hover(function()
			{
				JQ(this).addClass('active');
			},function()
			{
				JQ(this).removeClass('active');
			});
			
			self.container.find('.title, .read, .last_comment, .right_comment_username').click(function()
			{
				tracking.click({pageName:track_site+">media>video>comments",prop18:"media",prop19:"video"});
				parent.parent.parent.events.toggle();
			});
			
			self.container.find('.add_a_comment').click(function()
			{
				tracking.click({pageName:track_site+">media>video>comments",prop18:"media",prop19:"video"});
				parent.parent.parent.events.toggle();
				
				//parent.parent.parent.left_side.left_comment_section.post_form.toggle(true);
			});
		};
		this.hide=function(){self.container.hide();};
		this.show=function()
		{
			parent.parent.parent.parent.comment_manager.load_thread(self.guid,function(data)
			{
				self.data=data;
				self.render();
				self.container.show();
			});
		};
		self.init();
	}
	
	
	function RightWallTouts(parent)
	{
		var self=this;
		this.init=function()
		{
			var str="<div id=\"right_wall_touts\">";
			var touts=parent.parent.parent.config.touts;
		
			for(var i=0;i<touts.length;i++)
			{
				if(touts[i].url)
					str+="<a href=\""+touts[i].url+"\"><img src=\""+touts[i].thumb+"\" /></a>";
			}
			
			str+="</div>"	;
			parent.container.append(str);
		};
		self.init();
	}
	
	//managers:
	function VideoManager(parent)
	{
		var self=this;
		this.init=function()
		{
			self.cached_vids={};
			self.baseURL="/nikeos/p/nikeos/en_US/video_wall/odaptor?";
		};
		this.load=function(data,callback)
		{
			parent.ajax_tunnel.issue(
			{
				u:self.baseURL,
				d:data,
				c:self.loaded,
				callback:callback
			});
		};
		this.loaded=function(data, req)
		{
			if(data.error && data.error=='no_feed')
				return;
			
			for(var i=0;i<data.items.length;i++)
				self.cached_vids[data.items[i].guid]=data.items[i];
				
			data.totalPages=Math.ceil(data.total/data.pageSize);
			req.callback(data);
		};
		this.request=function(req)
		{
			var default_req=
			{
				pageSize:12,
				page:1,
				channelId:parent.config.all_wall_channel_id,
				locale:parent.config.locale,
				callback:function(data){}
			};
			req=JQ.extend(true,{},default_req,req);
			self.load(req,req.callback);
		};
		this.load_channel=function(channel,page,sort,callback)
		{
			self.request({	channelId:channel,page:page,sort_by:sort,callback:callback	});
		};
		this.load_guid=function(guid,callback)
		{
			self.request({guid:guid,callback:callback});
		};
		this.load_tags=function(tags,page,sort,callback)
		{
			self.request({tag_search:tags,page:page,sort_by:sort,callback:callback});
		};
		self.init();
	}
	function CommentManager(parent)
	{
		var self=this;
		this.init=function()
		{
			self.baseURL=parent.config.blog_base_url;
		};
		this.request=function(req)
		{
			var default_req=
			{
				courage:"true",
				locale:parent.config.locale,
				community:parent.config.blog_community,
				serviceFormat:"true",
				cacheBuster:Math.floor(Math.random()*1000000000)
			};
			var request=JQ.extend(true,{},default_req,req);
			request.callback="video_wall.demand_tunnel.response";
			self.load(request,req.callback);
		};
		this.load=function(data,callback)
		{
			var url=parent.config.blog_base_url+'?'+objToString(data);
			parent.demand_tunnel.add({	url:url,_callback:callback	});
		};
		this.load_thread=function(guid,callback)
		{
			self.request(
			{
				key:guid+'_'+parent.config.locale,
				callback:callback
			});
		};
		this.post_comment=function(comment,data,callback)
		{
			tracking.click({pageName:track_site+">media>video>comments>submit",prop18:"media",prop19:"video"});
			
			//clean comment data
			comment=escape(comment);
			
			if(	typeof data.threadID != 'undefined'	)
			{
				var params=
				{
					post:true,
					threadID:data.threadID,
					referrerURL:'',
					comment:comment
				};
			}
			else
			{
				var params=
				{
					post:true,
					key:data.key,
					communityID:data.communityID,
					referrerURL:'',
					title:parent.front_end.left_side.video_detail.container.find('div.title').html(),
					description:'description',
					comment:comment
				};
			}
			
			var req={};
			req.url=data.form_action;
			req.callback=callback;
			
			var data_string='';
			for(var p in params)
				data_string+=p+"="+params[p]+"&";
			req.data=data_string.substring(0,data_string.length-1);
			parent.f4a_tunnel.add(req);	
		};
		this.flagMessage=function(id, comment, callback)
		{
			var data=
			{
				referrerURL:escape(location.href),
				messageID:id,
				abuseType:0,//default to General Abuse
				comments:escape(comment)
			};
			var action=parent.config.blog_base_url.replace('/everywhere/780','')+"/ce-message-abuse.jspa";
			
			var data_str='';
			for(var p in data)
				data_str+=p+"="+data[p]+"&";
			var req={};
			req.url=action;
			req.data=data_str.substring(0,data_str.length-1);
			req.callback=callback;
			parent.f4a_tunnel.add(req);
		};
		self.init();
	}
	
	//tunnels:
	function AjaxTunnel()
	{
		var self=this;
		this.init=function()
		{
			self.requests=[];
			self.cached_requests={};
			self.request_running=false;
		};
		this.issue=function(request)
		{
			self.requests[self.requests.length]=request;
			if(!self.request_running)
			{
				self.request_running=true;
				self.run_requests();
			}
		};
		self.run_requests=function()
		{
			if(self.requests.length==0)
			{
				self.request_running=false;
				return;
			}
			if(!self.cached_requests[objToString(self.requests[0].d)])
			{
				JQ.get
				(
					self.requests[0].u, 
					JQ.extend(true,{},self.requests[0].d,{callback:false}),
					self.issue_done, "json"
				);
			}
			else
				self.issue_done(	self.cached_requests[objToString(self.requests[0].d)]	);
			};
		this.issue_done=function(data)
		{
			self.cached_requests[	objToString(self.requests[0].d)	]=data;
			self.requests[0].c(	data,self.requests[0]	);
			self.requests.shift();
		
			if(self.requests.length==0)
				self.request_running=false;
			else
				self.run_requests();
			};
		self.init();
	}	
	function DemandTunnel(parent)
	{
		var self=this;
		this.init=function()
		{		
			self.requests=[];
			self.isRunning=false;
		};
		this.add=function(obj)
		{
			self.requests[self.requests.length]=obj;
			if(!self.isRunning)
			{
				self.isRunning=true;
				self.run();
			}
		};
		this.run=function()
		{
			if(self.requests.length==0)
			{
				self.isRunning=false;
				return;
			}
			self.issue(self.requests[0]);
		};
		this.issue=function(obj)
		{
			var script=document.createElement('script');
			script.type = 'text/javascript';
			script.src = obj.url;
			document.body.appendChild(script);
		};
		this.response=function(data)
		{
			var url=self.requests[0].url;
			var callback=self.requests[0]._callback;
			self.requests.shift();
			self.run();
			
			//stringified output conversion:
			if(typeof data=='string')
				eval("var data="+data);
			callback(cleanJson(data));
		};
		self.init();
	}
	function F4ATunnel(parent)
	{
		var self=this;
		this.init=function()
		{
			self.build_flash();
			self.requests=[];
			self.isRunning=false;	
		};
		this.build_flash=function()
		{
			var el_id='f4a_nike';
			var f4a_id='f4a_nike';
			self.f4a=new f4a_js_flash({'id':f4a_id,'swfname':'f4a.swf','swfuri':'/nikeos/global/swf/f4a/f4a.swf'});
			
			var e=document.createElement("div");
			e.id=el_id+'flashcontent';
			e.style.width='1px';
			e.style.height='1px';
			document.getElementsByTagName('body').item(0).appendChild(e);
			self.f4a.createSwfObject();
		};
		this.add=function(obj)
		{
			self.requests[self.requests.length]=obj;		
			if(!self.isRunning)
			{
				self.isRunning=true;
				self.run();
			}
		};
		this.run=function()
		{
			if(self.requests.length==0)
			{
				self.isRunning=false;
				return;
			}
			self.issue(self.requests[0]);
		};
		this.issue=function(obj)
		{			
			var default_req=
			{
				onready:self.response,
				meth:'POST',
				data:{}				
			};
			for(var p in obj)
			{
				if(p!='callback')
					default_req[p]=obj[p];
			}
			self.f4a.open(default_req);
		};
		this.response=function(data)
		{
			var callback=self.requests[0].callback;
			self.requests.shift();
			self.run();
			callback(data);
		};
		self.init();
	}
	
	//utility functions:
	function objToString(obj)
	{
		var str="";
		for (var p in obj)
			if(typeof obj[p]!='object' && typeof obj[p]!='function')
				str+=p+"="+escape(obj[p])+"&";
		return str.substring(0,str.length-1);
	}
	function limit_string(text, maxlength)
	{
		if(text.length <= maxlength)
			return text;
		for(var i=maxlength;i>0;i--)
		{
			if(	text[i]==" "||text[i]=="#"||text[i]=="!"||text[i]=="\""||text[i]=="'"||text[i]==","||text[i]=="."||text[i]=="/"||text[i]==","||text[i]=="|")
			{
				if(text[i-1]==",")
					return text.substring(0,i-1)+"...";					
				else
					return text.substring(0,i)+"...";
			}
		}
		return text.substring(0,maxlength)+"...";
	}	
	//--gets param in query string. it its not in there, it pulls it from the hash.
	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 results[1];
	}
	//clears out dummy data from json responses:
	function cleanJson(obj)
	{
		var ret;
		if(obj.constructor==Array)
		{
			ret=[];
			for(var i=0;i<obj.length;i++)
			{
				if(obj[i]!=null && typeof obj[i]!='undefined')
				{
					if(typeof obj[p]=='object')
						ret[ret.length]=cleanJson(obj[i]);
					else
						ret[ret.length]=obj[i];
				}
			}
			return JQ.extend([],ret);
		}
		else
		{
			ret={};
			for(var p in obj)
			{
				if(p!='dummy' && obj[p]!=null)
				{
					if(typeof obj[p]=='object')
						ret[p]=cleanJson(obj[p]);
					else
						ret[p]=obj[p];	
				}
			}
			return JQ.extend({},ret);
		}
	}
	function date_str(date)
	{
		var language=location.href.substring(location.href.indexOf("/nikeos/p/")+10,location.href.length).split("/")[1].split("_")[0];
		if(language!="en")
			return date.substring(0,10);
			
		var y=parseInt(date.substring(0,4),10);
		var m=parseInt(date.substring(5,7),10)-1;
		var d=parseInt(date.substring(8,10),10);
		var h=parseInt(date.substring(11,13),10);
		var mm=parseInt(date.substring(14,16),10);
		var s=parseInt(date.substring(17,19),10);
		
		var d=new Date(y,m,d,h,mm,s);
		var ed=d.getTime()/1000;
		
		var now=new Date();
		var now_epoch=now.getTime()/1000;
		
		var diff=Math.floor(now_epoch-ed);
		
		if(diff>31536000)
			return render_date_str(diff,31536000,"year");
		else if(diff>2592000)
			return render_date_str(diff,2592000,"month");
		else if(diff>86400)
			return render_date_str(diff,86400,"day");
		else if(diff>3600)
			return render_date_str(diff,3600,"hour");
		else
			return "1 second Ago";
	}
	function render_date_str(diff,time,label)
	{
		var x=Math.floor(diff/time);
		if(x==1)
			return x+" "+label+" ago";
		else
			return x+" "+label+"s ago";
	}
	
	function PopUp(master,id)
	{
		var self=this;
		this.init=function()
		{
			self.id='popup_'+id;
			JQ('body').append("<div id=\""+self.id+"\" class=\"jqmWindow\">asd</div>");
			self.dom=JQ('#'+self.id);
			self.dom.jqm(
			{
				onHide:self.hide
			});
			self.open=false;
			self.allow=false;
		};
		this.set=function(html)
		{
			self.dom.empty().append(html);
			return self;
		};
		this.show=function()
		{
			self.open=true;
			self.dom.jqmShow();
			return self;
		};
		this.allow_close=function()
		{
			self.allow=true;
			return self;
		};
		this.refuse_close=function()
		{
			self.allow=false;
			return self;
		};
		this.hide=function(popup)
		{
			if(self.allow)
			{
				self.dom.hide();
				JQ('.jqmOverlay').hide();
				self.open=false;
				self.allow=false;
				self.dom.jqmHide();
			}
			return self;
		};
		this.close=function()
		{
			self.allow_close();
			self.hide();
			self.refuse_close();
			return self;
		};
		this.status=function()
		{
			return self.open;
		};
		self.init();
	}

	function f(){}
	var video_wall;
	JQ(document).ready(function()
	{
		//start it up:
		video_wall=new VideoWall();
	});
	
