nfl.namespace('nfl.global.sitelife.comments');
nfl.namespace("nfl.scores");

/**
 * ShowPluckStats
 * 
 * Requests data from pluck for each game, and shows
 * either the rating or the comments count based on
 * the supplied selectors.
 *
 * @static
 * @params {Object _config} Configuration of the HTML and games to show.
 *
 */
nfl.scores.ShowPluckStats = (function () {
	var BM               = nfl.sitelife.BatchManager,
	    DEFAULT_COMMENTS = '0',
	    DEFAULT_RATING   = "\u00A0";

	function getPluckData (_game) {
		var pluckId      = this.idPrefix + _game.gameKey,
		    containerId  = this.uiPrefix + _game.gameId,
		    fanRatingCSS = this.fanRatingSelector,
		    commentsCSS  = this.commentsSelector;
		
		// Request the article from Pluck
		BM.AddToRequest( new ArticleKey( pluckId ), function( _response) {
			var article   = BM.findArticlePage( _response, pluckId ),
			    container = $(containerId),
			    noArticle = Object.isUndefined(article),
			    fanRating,
			    comments;
			
			// if we have a fan rating template, and a fan rating element update & show it
			fanRating = container.down(fanRatingCSS);
			if ( fanRating ) {
				fanRating.
					update((article && parseInt(article.Ratings.NumberOfRatings, 10) > 0) ? parseInt(article.Ratings.AverageRating, 10) : DEFAULT_RATING).
					show();
			}
			
			// if we have a comments object, update and show it.
			comments = container.down(commentsCSS);
			if (comments) {
				comments.update(article ? article.Comments.NumberOfComments : DEFAULT_COMMENTS).show();
			}
		});
	}
	
	return function(_config) {
		// for each game, get Pluck data and display it
		_config.games.each(getPluckData, _config);
	};
}());

nfl.scores.Engine	= Class.create({
	initialize:function(options){
		this.options		= (typeof options !== 'undefined')?options:{};
		this.boundHandlers	= {};
		this.polling		= {'interval':15,'pe':false};
		
		/* create the event handlers */
		document.observe('scores:data:updated',this.onUpdate.bind(this));
		document.observe('scores:engine:start',this.start.bind(this));
		document.observe('scores:engine:stop',this.stop.bind(this));
		
		/* start the party */
		this.start();
		
		/* we put this on a timer to allow initialization of class instances to finish */
		setTimeout(function(){document.fire('scores:engine:created',this);}.bind(this),100);
	},
	start:function(){
		if(this.polling.interval > 0){
			console.log('nfl.scores.engine.start');
			this.get();
			this.polling.pe	= new PeriodicalExecuter(this.get.bind(this),this.polling.interval);
			try{document.fire('scores:engine:started');}catch(e){}
		}else{
			console.warn('nfl.scores.engine.start: this.polling.interval = '+this.polling.interval);
		}
	},
	stop:function(){
		if(this.polling.pe){
			console.log('nfl.scores.engine.stop');
			this.polling.pe.stop();
			this.polling.pe	= false;
			document.fire('scores:engine:stopped');
		}else{
			console.warn('nfl.scores.engine.stop: no periodical executer present.');
		}
	},
	restart:function(interval){
		console.log('nfl.scores.engine.restart');
		this.polling.interval = interval;
		this.stop();
		if(this.polling.interval > 0){this.start();}
	},
	get:function(){
		console.log('nfl.scores.engine.get');
		var path	= '/liveupdate/scores/scores.json?random='+ this.getCacheBustInt();
		var request	= new Ajax.Request(path,{
			method:'get',
			evalScripts:true,
			evalJSON: "force",
			onSuccess:function(XHR){
				console.log('nfl.scores.engine.get: onsuccess');
				var json	= false;
				try{
					if(typeof XHR.responseJSON != "undefined"){
						json	= XHR.responseJSON;
					}else{
						json	= eval('(' + XHR.responseText + ')');
					}
					document.fire('scores:data:updated',json);
				}catch(e){console.warn('wtf? '+e.message)}
				//console.log('nfl.scores.engine.get: onsuccess fired scores:data:updated');
			},
			onFailure:function(){
				console.log('nfl.scores.engine.get: onfailure');
				document.fire('scores:data:updated',{error:true});
			}
		});
	},
	getCacheBustInt:function(){
		var time, d;
		d = new Date();
		d.setSeconds(Math.floor(d.getUTCSeconds() / 10) * 10);
		d.setMilliseconds(0);
		time = d.getTime();
		return time
	},
	set:function(json){
		var dc		= false;
		//console.info('nfl.scores.engine.set');
		if(typeof this.data === 'undefined'){
			/* this is the first load, no intelligence needed, just update everything */
			dc			= true;
			this.data	= json;
		}else{
			/* data exists, check for game nodes */
			for(var key in json){
				var node	= json[key];
				if(typeof this.data[key] === 'undefined'){
					/* this game did not exist prior to this update */
					dc				= true;
					this.data[key]	= node;
					/* send out an event telling subscribers that this particular game has been added to data */
					document.fire('scores:data:game:statechanged',{'id':key,'state':'active'});
				}else{
					/* game already exists in data, get more specific */
					if(typeof node.home !== 'undefined'){
						if(typeof node.home.score !== 'undefined' && node.home.score !== this.data[key].home.score){this.data[key].home.score = node.home.score;dc=true;}
						if(typeof node.home.abbr !== 'undefined' && node.home.abbr !== this.data[key].home.abbr){this.data[key].home.abbr = node.home.abbr;dc=true;}
						if(typeof node.home.to !== 'undefined' && node.home.to !== this.data[key].home.to){this.data[key].home.to = node.home.to;dc=true;}
					}
					if(typeof node.away !== 'undefined'){
						if(typeof node.away.score !== 'undefined' && node.away.score !== this.data[key].away.score){this.data[key].away.score = node.away.score;dc=true;}
						if(typeof node.away.abbr !== 'undefined' && node.away.abbr !== this.data[key].away.abbr){this.data[key].away.abbr = node.away.abbr;dc=true;}
						if(typeof node.away.to !== 'undefined' && node.away.to !== this.data[key].away.to){this.data[key].away.to = node.away.to;dc=true;}
					}
					if(typeof node.yl !== 'undefined' && node.yl !== this.data[key].yl){this.data[key].yl = node.yl;dc=true;};
					if(typeof node.down !== 'undefined' && node.down !== this.data[key].down){this.data[key].down = node.down;dc=true;};
					if(typeof node.togo !== 'undefined' && node.togo !== this.data[key].togo){this.data[key].togo = node.togo;dc=true;};
					if(typeof node.redzone !== 'undefined' && node.redzone !== this.data[key].redzone){this.data[key].redzone = node.redzone;dc=true;};
					if(typeof node.clock !== 'undefined' && node.clock !== this.data[key].clock){this.data[key].clock = node.clock;dc=true;};
					if(typeof node.posteam !== 'undefined' && node.posteam !== this.data[key].posteam){this.data[key].posteam = node.posteam;dc=true;};
					if(typeof node.note !== 'undefined' && node.note !== this.data[key].note){this.data[key].note = node.note;dc=true;};
					if(typeof node.bp !== 'undefined' && node.bp !== this.data[key].bp){this.data[key].bp = node.bp;dc=true;};
					if(typeof node.media !== 'undefined' && node.media !== this.data[key].media){this.data[key].media = node.media;dc=true;};
					if(typeof node.qtr !== 'undefined' && node.qtr !== this.data[key].qtr){
						var newState	= false;
						if(this.data[key].qtr == 'Pregame'){
							newState	= 'active';	/* this game went from Pregame to something else, tell subscribers about it */
						}
						if(node.qtr == 'Final'){
							newState	= 'post';	/* this game went to final, tell subscribers about it */
						}
						this.data[key].qtr = node.qtr;dc=true;
						if(newState !== false){
							document.fire('scores:data:game:statechanged',{'id':key,'state':newState});
						}
					};
				}
			}
		}
		if(dc){
			/* data has changed, broadcast w/ data as the memo */
			document.fire('scores:data:changed',this.data);
		}
	},
	onUpdate: function(event){
		var json	= event.memo;
		//console.info('nfl.scores.engine.onUpdate '+ Object.toJSON(event.memo));
		if(!json.error && !json.empty){
			this.set(json);
		}else{
			console.warn('nfl.scores.engine.onUpdate: NO DATA!');
		}
	}
});

nfl.scores.Game	= Class.create({
	initialize:function(gameid,gamekey,options){
		this.gameid		= gameid;
		this.gamekey	= gamekey;
		this.options	= (typeof options !== 'undefined')?options:{};
		this.template	= (typeof this.options.template !== 'undefined')?this.options.template:'no template';
		this.template	= new Template(this.template);
		this.state		= (typeof this.options.state !== 'undefined')?this.options.state:'pre';
		this.onDataChanged	= this.onDataUpdated.bind(this);
		
		/* create event listeners */
		if(this.state !== 'post'){
			document.observe('scores:data:changed',this.onDataChanged);
			document.observe('scores:data:game:statechanged',this.onStateChanged.bind(this));

			/* check to see if engine already exists */
			var engineExists	= false;
			var engineHasData 	= false;
			try{
				engineExists	= (typeof nfl.global.scores.engine !== 'undefined')?true:false;
			}catch(e){}
			
			
			if(engineExists){
				if(typeof nfl.global.scores.engine.data !== 'undefined'){
					if(typeof nfl.global.scores.engine.data[this.gameid] !== 'undefined'){
						engineHasData = true
					}
				}
			}
			if(engineHasData){
				console.log('engine has data for this game '+this.gameid);
				this.data	= nfl.global.scores.engine.data[this.gameid];
				this.render();
			}else{
				if(this.state === 'active'){
					/* this game is in active state, but there is no data, this should never happen */
					/* handling it anyways for pretty-ness factor (a.w) */
					if(document.loaded){
						/* we know for sure now that there is no scores engine */
						this.loadActiveViewDummy();
					}else{
						document.observe('dom:loaded',this.loadActiveViewDummy.bind(this));
					}
				}
			}
		}
	},
	getCacheBustInt:function(){
		var time, d;
		d = new Date();
		d.setSeconds(Math.floor(d.getUTCSeconds() / 10) * 10);
		d.setMilliseconds(0);
		time = d.getTime();
		return time
	},
	onDataUpdated: function(event){
		console.log('nfl.scores.Game.onDataUpdated: '+this.gameid,event.memo);
		if(typeof event.memo !== 'undefined'){
			if(typeof event.memo[this.gameid] !== 'undefined'){
				this.data	= event.memo[this.gameid];
				this.render();
			}
		}
	},
	onStateChanged: function(event){
		console.log('nfl.scores.Game.onStateChanged');
		if(typeof event.memo !== 'undefined'){
			if(event.memo.id === this.gameid){
				/* this games state has changed, get fancy */
				console.info('game state changed for '+this.gameid+' to '+event.memo.state);
				this.state	= event.memo.state;
				this.loadView(this.state);
				if(this.state==='post'){
					/* unbind listeners, they are no longer necessary */
					//console.log('state changed to post for #'+this.gameid);
					document.stopObserving('scores:data:changed',this.onDataChanged);
				}
			}
		}
	},
	loadActiveViewDummy: function(event){
	/* check if we have data one last time */
		if(typeof this.data !== 'undefined'){ return false; }
		var json	= {
			"home":{
				"score":{
					"1": 0,
					"2": 0,
					"3": 0,
					"4": 0,
					"5": 0,
					"T": 0
				},
				"abbr": this.options.homeabbr,
				"to": 3
			},
			"away":{
				"score":{
					"1": 0,
					"2": 0,
					"3": 0,
					"4": 0,
					"5": 0,
					"T": 0
				},
				"abbr": this.options.awayabbr,
				"to": 3
			},
			"weather": null,"media": null,"bp": 0,"yl": "0","qtr": "Pregame","down": 0,"togo": 0,"clock": "","posteam": "","note": null,"redzone": false,"stadium": null
		}
		this.data	= json;
		this.render();
	},
	loadView: function(state){
		/* state change has occurred, flip tile view */
		console.info('load '+ state +' view for #'+this.gameid);
		if(typeof this.options.wrapper !== ''){
			if($(this.options.wrapper)){
				/* we have a wrapper, load new content into it */
				var widgetURI		= '/ajax/scores/scorebox?gameId='+this.gameid+'&state='+(state.toUpperCase())+'&random='+this.getCacheBustInt();
				
				if(this.state === 'active'){
					var contentRequest	= new Ajax.Request(widgetURI, {
						method: 'get', 
						evalScripts: true,
						sanitizeJSON: false,
						onSuccess: function(XHR){
							if(typeof XHR.responseText != "undefined"){
								//console.log('loadView returned response text:\n\r'+XHR.responseText);
								$(this.options.wrapper).update(XHR.responseText);
								this.template	= new Template($(this.options.container).innerHTML);
								this.render();
								/*
								setTimeout(function(){
									//set new template content
									this.template	= new Template($(this.options.container).innerHTML);
									this.render();
								}.bind(this),1);
								*/
							}
						}.bind(this)
					});
					return false
				}
				var contentRequest	= new Ajax.Updater($(this.options.wrapper), widgetURI, {
					method: 'get', 
					evalScripts: true,
					sanitizeJSON: false,
					onSuccess: function(XHR){
						console.info('loaded '+ this.state +' view for #'+ this.gameid );
						if(this.state === 'post'){
							
							nfl.scores.ShowPluckStats({
								idPrefix: (nfl.global.ENV === "PROD" ? "" : nfl.global.ENV + '-') + 'GC',
								uiPrefix: "sb-wrapper-",
								root: 'score-boxes',
								fanRatingSelector: ".scorebox td.fan-rating + td span",
								commentsSelector: ".scorebox td.comments-count span",
								games: [{ gameKey: this.gamekey,gameId: this.gameid }]
							});
							
						}
					}.bind(this)
				});
			}
		}
	},
	getIntegerPostfix: function(i){
		var cmpStr		= new String(i);
		var digit1Str	= cmpStr.substring(cmpStr.length - 1);
		var digit2Str	= (cmpStr.length > 1)?(cmpStr.substring(cmpStr.length - 2)):'0';
		//console.log('getIntegerPostfix('+i+') : '+ digit1Str +','+digit2Str);
		switch(digit1Str){
			case '1':
				if(digit2Str.startsWith('1')){ return 'th'; }
				return 'st';
			case '2':
				if(digit2Str.startsWith('1')){ return 'th'; }
				return 'nd';
			case '3':
				if(digit2Str.startsWith('1')){ return 'th'; }
				return 'rd';
			default:
				return 'th';
		}
	},
	hasActiveTileContent: function(){
		/* we check for the comment element because active state does not have it */
		var commentCountSelector	= 'td.comments-count';
		var fanRatingSelector		= 'td.fan-rating';
		var commentElement			= $(this.options.container).down(commentCountSelector);
		var fanRatingElement		= $(this.options.container).down(fanRatingSelector);
		if(typeof commentElement !== 'undefined' && commentElement){ return false }
		if(typeof fanRatingElement !== 'undefined' && fanRatingElement){ return false }		
		return true
	},
	render: function(){
		/* write out ui stuff */
		if(!this.hasActiveTileContent){console.info('nfl.scores.Game '+this.gameid+' render() exited. active tile content not present.'); return true;}
		console.info('nfl.scores.Game '+this.gameid+' render() called');
		if(typeof this.data !== 'undefined'){
			var data	= this.data;
			/* extend object with stuff */
			data.qtrclass1 = '';
			data.qtrclass2 = '';
			data.qtrclass3 = '';
			data.qtrclass4 = '';
			switch(data.qtr){
				case 'Pregame':
					try{
						data.home.score['1']	= '';
						data.home.score['2']	= '';
						data.home.score['3']	= '';
						data.home.score['4']	= '';
						data.home.score['5']	= '';
						data.home.score['T']	= '--';
						data.away.score['1']	= '';
						data.away.score['2']	= '';
						data.away.score['3']	= '';
						data.away.score['4']	= '';
						data.away.score['5']	= '';
						data.away.score['T']	= '--';
					}catch(e){}
					break;
				case 'Halftime':
					try{
						data.home.score['3']	= '';
						data.home.score['4']	= '';
						data.home.score['5']	= '';
						data.away.score['3']	= '';
						data.away.score['4']	= '';
						data.away.score['5']	= '';
						data.clock				= 'Half';
					}catch(e){}
					break;
				case '1':
					data.qtrclass1	= ' class="current-quarter"';
					try{
						data.home.score['2']	= '';
						data.home.score['3']	= '';
						data.home.score['4']	= '';
						data.home.score['5']	= '';
						data.away.score['2']	= '';
						data.away.score['3']	= '';
						data.away.score['4']	= '';
						data.away.score['5']	= '';
					}catch(e){}
					break;
				case '2':
					data.qtrclass2	= ' class="current-quarter"';
					try{
						data.home.score['3']	= '';
						data.home.score['4']	= '';
						data.home.score['5']	= '';
						data.away.score['3']	= '';
						data.away.score['4']	= '';
						data.away.score['5']	= '';
					}catch(e){}
					break;
				case '3':
					data.qtrclass3	= ' class="current-quarter"';
					try{
						data.home.score['4']	= '';
						data.home.score['5']	= '';
						data.away.score['4']	= '';
						data.away.score['5']	= '';
					}catch(e){}
					break;
				case '4':
					data.qtrclass4	= ' class="current-quarter"';
					try{
						data.home.score['5']	= '';
						data.away.score['5']	= '';
					}catch(e){}
					break;
				default:
					break;
			}
			data.home.posclass	= (data.posteam == data.home.abbr)?'img-football':'img-football-off';
			data.away.posclass	= (data.posteam == data.away.abbr)?'img-football':'img-football-off';
			data.gameclass		= (data.redzone)?'redzone':'active';
			data.posdisp		= (parseInt(data.down) + parseInt(data.togo) > 0) ? (parseInt(data.down) + (this.getIntegerPostfix(data.down)) + ' down and ' + parseInt(data.togo) + '<br />on ' + data.yl) : '';
			
			//console.log('data: '+Object.toJSON(data));
			
			var retVal	= this.template.evaluate(data);
			//console.log('nfl.scores.Game.render(): retVal = '+ retVal);
			if(!$(this.options.container)){ return false }
			$(this.options.container).update(retVal);
			//console.log('nfl.scores.Game.render(): this.options.container = '+ $(this.options.container));
		}
	},
	destroy: function(){
		document.stopObserving('scores:data:changed',this.onDataChanged);
	}
});

nfl.scores.BigPlays = (function(){
	var OPTIONS	= {w:'965',h:'330',mh:'26',containerid:'big-plays',vars:{}}; //default swf options
	var __SO	= false;
	
	var initialize = function(event){
		if(typeof event !== 'undefined'){
			if(typeof event.memo !== 'undefined'){
				if(typeof event.memo.options !== 'undefined'){
					console.log('extending options with',event.memo.options);
					OPTIONS 		= Object.extend(OPTIONS, event.memo.options);
				}
			}
		}
		if(!nfl.global.scores.currentWeek){
			/* minimize the big play module by default */
			var c	= $(OPTIONS.containerid);
			c.setStyle({'height':OPTIONS.mh+'px','overflow':'hidden'});
		}
		if($(OPTIONS.containerid) && !__SO){
			__SWFID = OPTIONS.containerid.replace(/-/g, '') + 'swf';
			__SO    = new SWFObject(nfl.global.flashpath + "/flex/scores/big-plays-chart.swf", __SWFID, OPTIONS.w, OPTIONS.h, "10", "#FFFFFF", true);
			__SO.useExpressInstall(nfl.global.flashpath + "/flash/expressinstall.swf");
			__SO.addParam('allowScriptAccess', 'always');
			__SO.addParam('allowFullScreen', 'true');
			__SO.addParam('wmode', 'transparent');
			__SO.addVariable('uniqid', __SWFID);
			for(var fvar in OPTIONS.vars){
				__SO.addVariable(fvar, OPTIONS.vars[fvar]);
			}
			__SO.write(OPTIONS.containerid);
		}
	}
	var __toggle = function(){
		var c	= $(OPTIONS.containerid);
		
		if(c.style.height == (OPTIONS.mh+'px')){
			c.setStyle({'height':OPTIONS.h+'px','overflow':'default'});
			return
		}
		c.setStyle({'height':OPTIONS.mh+'px','overflow':'hidden'});
	}
	var __logger = function(){
		var propValue = "Scores_BigPlay";
		var s_analytics = s_gi(s_account);
		s_analytics.linkTrackEvents = "";
		s_analytics.linkTrackVars = "prop47";
		s_analytics.prop47 = propValue;
		s_analytics.events = '';
		s_analytics.tl(true,'o',propValue);
	}
	document.observe('scores:bigplays:initialize',initialize);
	
	return {
		toggle: function(){
			__toggle();
		},
		logger: function(){
			__logger();
		}
	}
}());

/*
 * moved weather stuff in to own namespace. 8/9/09 a.w.
 */
nfl.scores.Weather = (function(){
	var onWeatherOver = function(event){
		var element	= $(event.element());
		element = (element.hasClassName('game-weather-section') || element.hasClassName('game-weather-section-left'))?element:(element.up('.game-weather-section-left'));
		/* check for a weather content node, there should only be one if we actually have weather for this box */
		//console.log('mouse over on weather node. has weather content? '+element.down('.weather-content') +'\n\r'+ element.innerHTML);
		if(typeof element === 'undefined'){ return false;}
		if(element.down('.weather-content')){
			/* has weather */
			var ele	= element.down('.weather-content');
			ele.show();
			event.stop();
		}
	}
	var onWeatherOut = function(event){
		var element	= event.element();
		element = (element.hasClassName('game-weather-section') || element.hasClassName('game-weather-section-left'))?element:(element.up('.game-weather-section-left'));
		/* check for a weather content node, there should only be one if we actually have weather for this box */
		if(typeof element === 'undefined'){ return false;}
		if(element.down('.weather-content')){
			/* has weather */
			var ele	= element.down('.weather-content');
			ele.hide();
			event.stop();
		}
	}
	var bindWeatherEvents		= function(element){
		element.observe('mouseover',onWeatherOver)
		element.observe('mouseout',onWeatherOut)
	}
	var bindAllWeatherEvents	= function(){
		$$('.scorebox-container .game-weather-section').each(function(element){
			bindWeatherEvents(element);
		});
	}
	if(!document.loaded){
		document.observe('dom:loaded',bindAllWeatherEvents);
	}else{
		bindAllWeatherEvents();
	}
	return {
		addWeatherBox: function(ele){
			bindWeatherEvents(ele)
		}
	}
}());

nfl.scores.Logger = new PeriodicalExecuter(function(){
	console.info('nfl.scores.Logger called');
	
	// wanted to use nfl.global.scores.season and nfl.global.scores.week but we need to keep the values
	// consistent with what is in analytics/scores.js
	var season = document.getElementById('season').content;
	var week = document.getElementById('week').content;
	week = week.toLowerCase();
	
	var s_analytics 		= s_gi(s_account);
	s_analytics.linkTrackEvents = "event1";
	s_analytics.linkTrackVars	= "events,pageName,hier1,prop5,eVar4";
	s_analytics.pageName 	= "nfl:scores:" + season + ":" + week;
	s_analytics.hier1 		= "nfl:scores|" + season + "|" + week;
	s_analytics.prop5 		= "nfl:scores|" + season + "|" + week;
	s_analytics.eVar4 		= "nfl:scores|" + season + "|" + week;
	s_analytics.prop35 	= '';
	s_analytics.prop6 	= '';
	s_analytics.events 	= 'event1';
	void(s_analytics.t());
},600);

document.observe('nfl:modal:click',function(event){
	if(typeof event.memo !== 'undefined'){
		if(event.memo == 2){
			/* skin logo click */
			//location.href = 'http://www.mcdonalds.com/dollar';
		}
	}
});
document.observe('scores:videolink:click',function(event){
	var videoId	= event.memo.id;
	console.info('{draft:tracker:videolink:click} id: '+videoId);
	nfl.ui.modal.show(window.location.protocol+'//'+window.location.host+'/widget/scores/video?id='+videoId,{
		width:615,
		height:497,
		player:{height:346},
		scrolling:'no',
		title:'<img src="'+nfl.global.imagepath+'/img/scores/skins/mcdonalds-video-title.gif">',
		maskclickable:true,
		titlebar:{height:0},
		zones:{
			'2':{href: 'http://www.mcdonalds.com/dollar'}
		}
	});
});
document.observe('dom:loaded', function(event) {
	if(nfl.ui.modal.mask){
		// attach click on mask event to close window
		nfl.ui.modal.mask.observe('click',nfl.ui.modal.hide);
	}
});

/*
 * Function for the year dropdown in the nav area.  Add an event listener to the submit action, extract the
 * correct year value from the dropdown, and then redirect the user appropriately.
 * 
 */
document.observe('dom:loaded', function(event) {
	/* currentYear value of 2008 is for simulation only */
	var currentYear = nfl.global.scores.season;  
	
	$('scores-nav-form').observe('submit', function(event){
		Event.stop(event);
		var el = Event.element(event);
		var yearValue = el.season.value;
		
		if(currentYear == yearValue){
			window.location.href = '/scores/';
		}else{
			window.location.href = '/scores/' + yearValue + '/REG1';
		}
	});
	
});
