(function() {
	var appPath = "/link3/cs/public-home.nsf/page?readform&app=";
	
	CSPublic	= {
		tbar	:	[{
			iconCls		: "fugue-home",
			handler		: function() {document.location.href = "/link3/cs/public-home.nsf?open";}
		},"-", {
			iconCls		: "fugue-calendar",
			text		: "Schedules",
			handler		: function() {document.location.href = appPath + "schedules";}
		}, {
			iconCls		: "fugue-sort-number",
			text		: "Final Rankings",
			handler		: function() {document.location.href = appPath + "rankings";}
		}, {
			iconCls		: "fugue-monitor",
			text		: "Combine",
			handler		: function() {document.location.href = appPath + "combine";}
		}, "->", "<span style='color:#888'>Coming for the 2009/2010 season:</span>", {
			iconCls		: "fugue-user",
			text		: "Player Profiles",
			disabled		: true
		}, {
			iconCls		: "fugue-newspaper",
			text		: "CS News",
			disabled	: true
		},{
			iconCls		: "fugue-trophy",
			text		: "Tournaments",
			disabled	: true
		}, {
			iconCls		: "fugue-calendar-day",
			text		: "Events",
			disabled	: true
		}, {
			iconCls		: "fugue-users",
			text		: "Teams",
			disabled	: true
		}, {
			iconCls		: "fugue-table",
			text		: "Leagues",
			disabled	: true
		}],
		
		
		appHeader		: {
			bodyStyle	: "padding-top:2px; padding-bottom:1px; background:transparent; border:0px",
			html		: "<div style='background:url(/link3/sections/cs/resources/images/alerts-bar.png); height:24px; padding-left:125px; overflow:hidden'>" +
				"<table style='width:100%' cellspacing='0' cellpadding='0'><tr>" +
				"<td style='height:23px; vertical-align:middle; font-size:14px; font-family:arial; font-weight:bold; color:#fff' id='alert-bar-body'></td>" +
				"</tr></table></div>"
		}
	};
	
	
	CSGlobal	= {
		openPlayer	: function(key) {
			var w = new WallCardWindow({player:{playerKey:key}});
			w.show();
		}
	};
	
	
})();


Ext.ns("CSPublic");
CSPublic.init = function() {
			/*
			 * Rotate between stories
			 */
			var stories = [
				["NHL Central Scouting Combine -- May 25th to May 30th", "/link3/cs/public-home.nsf/page?readform&app=combine"],
				["2009 Final Player Rankings Have Been Released", "/link3/cs/public-home.nsf/page?readform&app=rankings"]
			];
			
			/*
			 * Create spans
			 */
			var h = "";
			Ext.each(stories, function(st, ind) {
				h += "<span style='display:" + ((ind === 0) ? "block" : "none") + "' id='alert-bar-story-" + ind + "'>" +
					"<a href='" + st[1] + "' style='color:#fff; font-size:12px'>" + st[0] + "</a></span>";
			});
			Ext.get('alert-bar-body').dom.innerHTML = h;
			
			
			(function() {
				var storyInd = 0;
				Ext.TaskMgr.start({
					run: function() {
						Ext.get("alert-bar-story-" + storyInd).fadeOut({
							remove		: false,
		    				useDisplay	: true,
							callback	: function() {
								storyInd = (storyInd + 1 >= stories.length) ? 0 : storyInd + 1;
								Ext.get("alert-bar-story-" + storyInd).fadeIn();
							}
						});
					},
					interval:6500
				});			
			}).defer(6500);
		};