

nfl.namespace('nfl.draft');
nfl.namespace('nfl.draft.tracker');

updateTrackerFromFlash	= function(uri){
	if(typeof draftTrackerController != "undefined"){
		draftTrackerController.updateHashPath(uri);
	}
}
/*
 * nfl.draft.tracker.dataset
 * uber dataset for draft tracker.
 * 
 * properties: 
 * a dataset for drafted players
 * a dataset for undrafted players
 * a dataset for player pick analysis's
 * 
 * when a player analysis row is added/updated it is automagically
 * merged into the drafted player dataset. because it 
 * is outside the scope of the dataset we can keep the 
 * appearance of state with regards to expanded and unexpanded rows.
 */
nfl.draft.tracker.dataset	= Class.create();
nfl.draft.tracker.dataset.prototype	= {
	initialize: function(JSON,draftState){
		this.__playerJSON		= (typeof JSON != "undefined")? JSON:{};
		this.__filterkeys		= [];
		this.__undraftedfilterKeys	= [];
		this.draftedPlayers		= new nfl.data.dataset({});
		this.undraftedPlayers	= new nfl.data.dataset({});
		this.teamPicks			= new nfl.data.dataset({});
		this.playerAnalysis		= new nfl.data.dataset({});
		this.livefilter			= new nfl.data.livefilter($('activesearch-term'));
		//this.uselocalrequest	= (window.location.hostname == "localhost")?true:false;
		this.uselocalrequest	= false;
		this.__draftState		= (typeof draftState != 'undefined')? draftState.state:-1;
		this.__draftRound		= (typeof draftState != 'undefined')? draftState.round:-1;
		this.__pollInterval		= 15;
				
		/* create events to bind to */
		document.observe("livefilter:change",this.onLiveFilterChange.bind(this));
		document.observe("livefilter:blur",this.logLiveFilterView.bind(this));
		document.observe("window:hashchange",this.onHashChange.bind(this));
		//this.observe("analysisupdated",this.draftedPlayers.merge(this.playerAnalysis.__dataset,0));
		//this.observe("draftedplayersupdated",this.undraftedPlayers.merge(this.draftedPlayers.__dataset,-1));
		
		/* bind datasets to their containers */
		this.draftedPlayers.bindTo($('players-grid-table-by-name-drafted'));
		this.undraftedPlayers.bindTo($('players-grid-table-by-name-undrafted'));
		this.teamPicks.bindTo($("players-grid-table-by-round"));
		
		/* create any sorting rules (avoid these if you can)*/
		this.teamPicks.sortBy("pick","playerid",function(a,b){ return (a-b); });
		
		/* populate dataset bound object templates */
		this.draftedPlayers.templates.rowClass			= "drafted-data-row";
		this.draftedPlayers.templates.rowClassAlt		= "drafted-data-row-alt";
		this.draftedPlayers.templates.toggle			= "<a id=\"#{objid}-#{playerid}\" class=\"toggleicon\">[#{toggleicon}]</a>";
		this.draftedPlayers.templates.header			= "<thead><tr><td class=\"col-toggle\"></td><td class=\"col-name\">Name</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td class=\"col-college\">College</td><td class=\"col-pickext\">Pick</td><td class=\"col-team\">Team</td></tr></thead>\n\r";
		//this.draftedPlayers.templates.header			= "<colgroup><col class=\"col-toggle\"/><col class=\"col-name\"/><col class=\"col-pos\"/><col class=\"col-height\"/><col class=\"col-weight\"/><col class=\"col-college\"/><col class=\"col-pickext\"/><col class=\"col-team\"/></colgroup>\n\r<thead><tr><td class=\"col-toggle\"></td><td class=\"col-name\">Name</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td class=\"col-college\">College</td><td class=\"col-pickext\">Pick</td><td class=\"col-team\">Team</td></tr></thead>\n\r";
		this.draftedPlayers.templates.row				= "<tr class=\"#{rowclass}\"><td>#{toggle}</td><td><a href=\"#{playerprofileparam}\">#{name}</a></td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-position/pos-#{positionparam}\">#{position}</a></td><td>#{height}</td><td>#{weight}</td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-college/college-#{collegeidparam}\">#{college}</a></td><td>Pick #{pick}, <a class=\"filterlink\" href=\"##{tabsetid}:dt-by-round/round-#{roundparam}\">Round #{round}</a>(#{overall})</td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-team/team-#{teamabbrparam}\">#{teamname}</a></td></tr>\n\r<tr class=\"#{rowclass}\" id=\"#{objid}-analysis-row-#{playerid}\"><td colspan=\"2\"></td><td colspan=\"6\">#{pickanalysis}</td></tr>";
		this.undraftedPlayers.templates.header			= "<thead><tr><td class=\"col-toggle\"></td><td class=\"col-name\">Name</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td>College</td></tr></thead>\n\r";
		//this.undraftedPlayers.templates.header			= "<colgroup><col class=\"col-toggle\"/><col class=\"col-name\"/><col class=\"col-pos\"/><col class=\"col-height\"/><col class=\"col-weight\"/><col class=\"col-college\"/></colgroup>\n\r<thead><tr><td class=\"col-toggle\"></td><td class=\"col-name\">Name</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td>College</td></tr></thead>\n\r";
		this.undraftedPlayers.templates.row				= "<tr class=\"#{rowclass}\"><td></td><td><a href=\"#{playerprofileparam}\">#{name}</a></td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-position/pos-#{positionparam}\">#{position}</a></td><td>#{height}</td><td>#{weight}</td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-college/college-#{collegeidparam}\">#{college}</a></td></tr>\n\r";
		
		this.teamPicks.templates.toggle					= "<a id=\"#{objid}-#{playerid}\" class=\"toggleicon\">[#{toggleicon}]</a>";
		this.teamPicks.templates.header					= "<thead><tr><td class=\"col-toggle\"></td><td class=\"col-pick\">Pick</td><td class=\"col-teamext\">Team</td><td class=\"col-player\">Player</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td>College</td></tr></thead>\n\r";
		//this.teamPicks.templates.header					= "<colgroup><col class=\"col-toggle\"/><col class=\"col-pick\"/><col class=\"col-team\"/><col class=\"col-player\"/><col class=\"col-pos\"/><col class=\"col-height\"/><col class=\"col-weight\"/><col class=\"col-college\"/></colgroup>\n\r<thead><tr><td class=\"col-toggle\"></td><td class=\"col-pick\">Pick</td><td class=\"col-team\">Team</td><td class=\"col-player\">Player</td><td class=\"col-pos\">Pos</td><td class=\"col-height\">Ht</td><td class=\"col-weight\">Wt</td><td>College</td></tr></thead>\n\r";
		this.teamPicks.templates.row					= "<tr class=\"#{rowclass}\"><td>#{toggle}</td><td>#{pick} (#{overall})</td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-team/team-#{teamabbrparam}\">#{teamname}</a>#{teamnotes}</td><td><a href=\"#{playerprofileparam}\">#{name}</a></td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-position/pos-#{positionparam}\">#{position}</a></td><td>#{height}</td><td>#{weight}</td><td><a class=\"filterlink\" href=\"##{tabsetid}:dt-by-college/college-#{collegeidparam}\">#{college}</a></td></tr>\n\r<tr class=\"#{rowclass}\" id=\"#{objid}-analysis-row-#{playerid}\"><td colspan=\"2\"></td><td colspan=\"6\">#{pickanalysis}</td></tr>";
		
		/* create pe to poll for player data via xhr */
		this.pe					= new PeriodicalExecuter(this.getPlayers.bind(this), this.__pollInterval);
		this.splitPlayerDataByPick(this.__playerJSON);
		/* update any tab filter params from location hash if applicable*/
		if(location.hash && typeof location.hash == "string"){
			var hparams		= window.location.hashparams.get();
			var anchorEleTarget	= hparams.get('dt-tab-set-1');
			if($(anchorEleTarget) && $(anchorEleTarget).visible() && hparams.keys().length > 1){
				/*matched a tab section */
				this.setTabParamElement(hparams);
			}
		}
		this.updateDisplay();
		//this.getPlayers();
	},
	getCacheBustInt: function(){
		var time, d;
		d = new Date();
		d.setSeconds(Math.floor(d.getUTCSeconds() / 10) * 10);
		d.setMilliseconds(0);
		time = d.getTime();
		return time
	},
	getPollIntervalFromState: function(){
		switch(this.__draftState){
			case "PRE":
				//10 mins
				return -1;
				break;
			case "IN":
				//5 mins
				return -1;
				break;
			case "ACTIVE":
				//30 seconds
				return -1;
				break;
			case "POST":
				//none
				return -1;
				break;
			default:
				return -1;
				break;
		}
	},
	/* getDraftedPlayers
	 * update players via XHR request
	 */
	getPlayers: function(){
		nfl.log("nfl.draft.tracker.dataset.getPlayers");
		document.fire("draft:tracker:dataupdating",{});
		var buster			= this.getCacheBustInt(); // yeah, thats right buster  =P
		var request			= {url:"/liveupdate/draft/2008/draftTracker.json?random="+ buster,params:{r:buster},method:"get"}
		if(this.uselocalrequest){request.url = "/ajax/draft/tracker?year=2008"}
		var playerRequest	= new Ajax.Request(request.url, {
			method: request.method, 
			params: request.params, 
			evalJSON: "force",
			onSuccess: function(XHR){
				try{
					if(typeof XHR.responseJSON != "undefined"){
						this.__playerJSON	= XHR.responseJSON[0];
						this.__draftState	= XHR.responseJSON[1].state;
						this.__draftRound	= XHR.responseJSON[1].round;
					}else{
						var __XHRResult		= eval('(' + XHR.responseText + ')');
						this.__playerJSON	= __XHRResult[0];
						this.__draftState	= __XHRResult[1].state;
						this.__draftRound	= __XHRResult[1].round;
						__XHRResult	= null;
					}
				}catch(e){nfl.log("XHR Error: error occured while assigning object scope variables. \n\r"+ e); throw e;}
				try{
					var pollInterval		= this.getPollIntervalFromState();
					if(pollInterval != this.__pollInterval){
						/* interval has changed, reset executer */
						this.__pollInterval	= pollInterval;
						this.pe.stop();
						if(this.__pollInterval > -1){
							this.pe			= new PeriodicalExecuter(this.getPlayers.bind(this), this.__pollInterval);
						}
					}
					pollInterval = null;
				}catch(e){nfl.log("XHR Error: error occured while updating polling state. \n\r"+ e); throw e;}
				try{
					this.splitPlayerDataByPick(this.__playerJSON);
					this.updateDisplay();
					document.fire("draft:tracker:dataupdated",this.__playerJSON);
				}catch(e){nfl.log("XHR Error: \n\r"+ e +"\n\r"); throw e;}
			}.bind(this),
			onFailure: function(){
				/* this is a failure, for now just simulate response */
				/*
				this.__playerJSON	= {"UNDRAFTED_PLAYER_9":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Raiders","round":1,"playerid":"UNDRAFTED_PLAYER_9","height":"","collegeid":"","teamname":"Oakland Raiders","teamcity":"Oakland","name":"","positionGroup":"","pick":11,"firstName":"","notes":"","overall":11},"UNDRAFTED_PLAYER_8":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Chiefs","round":1,"playerid":"UNDRAFTED_PLAYER_8","height":"","collegeid":"","teamname":"Kansas City Chiefs","teamcity":"Kansas City","name":"","positionGroup":"","pick":10,"firstName":"","notes":"","overall":10},"UNDRAFTED_PLAYER_7":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Broncos","round":1,"playerid":"UNDRAFTED_PLAYER_7","height":"","collegeid":"","teamname":"Denver Broncos","teamcity":"Denver","name":"","positionGroup":"","pick":9,"firstName":"","notes":"","overall":9},"UNDRAFTED_PLAYER_6":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Steelers","round":1,"playerid":"UNDRAFTED_PLAYER_6","height":"","collegeid":"","teamname":"Pittsburgh Steelers","teamcity":"Pittsburgh","name":"","positionGroup":"","pick":8,"firstName":"","notes":"","overall":8},"UNDRAFTED_PLAYER_22":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Vikings","round":1,"playerid":"UNDRAFTED_PLAYER_22","height":"","collegeid":"","teamname":"Minnesota Vikings","teamcity":"Minnesota","name":"","positionGroup":"","pick":24,"firstName":"","notes":"","overall":24},"UNDRAFTED_PLAYER_4":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Bengals","round":1,"playerid":"UNDRAFTED_PLAYER_4","height":"","collegeid":"","teamname":"Cincinnati Bengals","teamcity":"Cincinnati","name":"","positionGroup":"","pick":6,"firstName":"","notes":"","overall":6},"UNDRAFTED_PLAYER_23":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Rams","round":1,"playerid":"UNDRAFTED_PLAYER_23","height":"","collegeid":"","teamname":"St. Louis Rams","teamcity":"St. Louis","name":"","positionGroup":"","pick":25,"firstName":"","notes":"","overall":25},"UNDRAFTED_PLAYER_5":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Browns","round":1,"playerid":"UNDRAFTED_PLAYER_5","height":"","collegeid":"","teamname":"Cleveland Browns","teamcity":"Cleveland","name":"","positionGroup":"","pick":7,"firstName":"","notes":"","overall":7},"UNDRAFTED_PLAYER_20":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Lions","round":1,"playerid":"UNDRAFTED_PLAYER_20","height":"","collegeid":"","teamname":"Detroit Lions","teamcity":"Detroit","name":"","positionGroup":"","pick":22,"firstName":"","notes":"","overall":22},"728":{"position":"QB","lastName":"Dixon","weight":205,"college":"Oregon","teamnickname":"Bills","round":1,"playerid":728,"height":"6'4\"","collegeid":48,"teamname":"Buffalo Bills","teamcity":"Buffalo","name":"Dennis Dixon","positionGroup":"QB","pick":1,"firstName":"Dennis","notes":"","overall":1},"UNDRAFTED_PLAYER_2":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Jets","round":1,"playerid":"UNDRAFTED_PLAYER_2","height":"","collegeid":"","teamname":"New York Jets","teamcity":"NY Jets","name":"","positionGroup":"","pick":4,"firstName":"","notes":"","overall":4},"UNDRAFTED_PLAYER_21":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Packers","round":1,"playerid":"UNDRAFTED_PLAYER_21","height":"","collegeid":"","teamname":"Green Bay Packers","teamcity":"Green Bay","name":"","positionGroup":"","pick":23,"firstName":"","notes":"","overall":23},"UNDRAFTED_PLAYER_3":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Ravens","round":1,"playerid":"UNDRAFTED_PLAYER_3","height":"","collegeid":"","teamname":"Baltimore Ravens","teamcity":"Baltimore","name":"","positionGroup":"","pick":5,"firstName":"","notes":"","overall":5},"UNDRAFTED_PLAYER_1":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Patriots","round":1,"playerid":"UNDRAFTED_PLAYER_1","height":"","collegeid":"","teamname":"New England Patriots","teamcity":"New England","name":"","positionGroup":"","pick":3,"firstName":"","notes":"","overall":3},"UNDRAFTED_PLAYER_28":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Panthers","round":1,"playerid":"UNDRAFTED_PLAYER_28","height":"","collegeid":"","teamname":"Carolina Panthers","teamcity":"Carolina","name":"","positionGroup":"","pick":30,"firstName":"","notes":"","overall":30},"UNDRAFTED_PLAYER_29":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Saints","round":1,"playerid":"UNDRAFTED_PLAYER_29","height":"","collegeid":"","teamname":"New Orleans Saints","teamcity":"New Orleans","name":"","positionGroup":"","pick":31,"firstName":"","notes":"","overall":31},"UNDRAFTED_PLAYER_26":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Seahawks","round":1,"playerid":"UNDRAFTED_PLAYER_26","height":"","collegeid":"","teamname":"Seattle Seahawks","teamcity":"Seattle","name":"","positionGroup":"","pick":28,"firstName":"","notes":"","overall":28},"UNDRAFTED_PLAYER_27":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Falcons","round":1,"playerid":"UNDRAFTED_PLAYER_27","height":"","collegeid":"","teamname":"Atlanta Falcons","teamcity":"Atlanta","name":"","positionGroup":"","pick":29,"firstName":"","notes":"","overall":29},"UNDRAFTED_PLAYER_24":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Cardinals","round":1,"playerid":"UNDRAFTED_PLAYER_24","height":"","collegeid":"","teamname":"Arizona Cardinals","teamcity":"Arizona","name":"","positionGroup":"","pick":26,"firstName":"","notes":"","overall":26},"UNDRAFTED_PLAYER_25":{"position":"","lastName":"","weight":"","college":"","teamnickname":"49ers","round":1,"playerid":"UNDRAFTED_PLAYER_25","height":"","collegeid":"","teamname":"San Francisco 49ers","teamcity":"San Francisco","name":"","positionGroup":"","pick":27,"firstName":"","notes":"","overall":27},"UNDRAFTED_PLAYER_31":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Bills","round":2,"playerid":"UNDRAFTED_PLAYER_31","height":"","collegeid":"","teamname":"Buffalo Bills","teamcity":"Buffalo","name":"","positionGroup":"","pick":2,"firstName":"","notes":"","overall":33},"UNDRAFTED_PLAYER_10":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Chargers","round":1,"playerid":"UNDRAFTED_PLAYER_10","height":"","collegeid":"","teamname":"San Diego Chargers","teamcity":"San Diego","name":"","positionGroup":"","pick":12,"firstName":"","notes":"","overall":12},"UNDRAFTED_PLAYER_11":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Titans","round":1,"playerid":"UNDRAFTED_PLAYER_11","height":"","collegeid":"","teamname":"Tennessee Titans","teamcity":"Tennessee","name":"","positionGroup":"","pick":13,"firstName":"","notes":"","overall":13},"UNDRAFTED_PLAYER_12":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Texans","round":1,"playerid":"UNDRAFTED_PLAYER_12","height":"","collegeid":"","teamname":"Houston Texans","teamcity":"Houston","name":"","positionGroup":"","pick":14,"firstName":"","notes":"","overall":14},"UNDRAFTED_PLAYER_30":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Buccaneers","round":2,"playerid":"UNDRAFTED_PLAYER_30","height":"","collegeid":"","teamname":"Tampa Bay Buccaneers","teamcity":"Tampa Bay","name":"","positionGroup":"","pick":1,"firstName":"","notes":"","overall":32},"714":{"position":"TE","lastName":"Brown","weight":null,"college":"Virginia Tech","teamnickname":"Dolphins","round":1,"playerid":714,"height":null,"collegeid":28,"teamname":"Miami Dolphins","teamcity":"Miami","name":"Duane Brown","positionGroup":"TE","pick":2,"firstName":"Duane","notes":"","overall":2},"UNDRAFTED_PLAYER_13":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Colts","round":1,"playerid":"UNDRAFTED_PLAYER_13","height":"","collegeid":"","teamname":"Indianapolis Colts","teamcity":"Indianapolis","name":"","positionGroup":"","pick":15,"firstName":"","notes":"","overall":15},"UNDRAFTED_PLAYER_14":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Jaguars","round":1,"playerid":"UNDRAFTED_PLAYER_14","height":"","collegeid":"","teamname":"Jacksonville Jaguars","teamcity":"Jacksonville","name":"","positionGroup":"","pick":16,"firstName":"","notes":"","overall":16},"UNDRAFTED_PLAYER_15":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Cowboys","round":1,"playerid":"UNDRAFTED_PLAYER_15","height":"","collegeid":"","teamname":"Dallas Cowboys","teamcity":"Dallas","name":"","positionGroup":"","pick":17,"firstName":"","notes":"","overall":17},"UNDRAFTED_PLAYER_16":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Giants","round":1,"playerid":"UNDRAFTED_PLAYER_16","height":"","collegeid":"","teamname":"New York Giants","teamcity":"NY Giants","name":"","positionGroup":"","pick":18,"firstName":"","notes":"","overall":18},"UNDRAFTED_PLAYER_17":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Eagles","round":1,"playerid":"UNDRAFTED_PLAYER_17","height":"","collegeid":"","teamname":"Philadelphia Eagles","teamcity":"Philadelphia","name":"","positionGroup":"","pick":19,"firstName":"","notes":"","overall":19},"UNDRAFTED_PLAYER_18":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Redskins","round":1,"playerid":"UNDRAFTED_PLAYER_18","height":"","collegeid":"","teamname":"Washington Redskins","teamcity":"Washington","name":"","positionGroup":"","pick":20,"firstName":"","notes":"","overall":20},"UNDRAFTED_PLAYER_19":{"position":"","lastName":"","weight":"","college":"","teamnickname":"Bears","round":1,"playerid":"UNDRAFTED_PLAYER_19","height":"","collegeid":"","teamname":"Chicago Bears","teamcity":"Chicago","name":"","positionGroup":"","pick":21,"firstName":"","notes":"","overall":21}}
				this.splitPlayerDataByPick(this.__playerJSON);
				this.updateDisplay();
				*/
				document.fire("draft:tracker:dataupdated",this.__playerJSON);
			}.bind(this)
		});
	},
	splitPlayerDataByPick: function(JSON){
		var dataset1	= {};
		var dataset2	= {};
		var jsonkeys	= [];
		this.__filterkeys			= this.__undraftedfilterKeys;
		
		for(var key in JSON){ jsonkeys[jsonkeys.length]	= key;}
		for(var index=0, len=jsonkeys.length; index < len; ++index) {
			var key			= jsonkeys[index];
			var playerId	= key;
			var playerRow	= JSON[playerId];
			var drafted		= ((""+ playerId).indexOf("UNDRAFTED_PLAYER") == -1 && (playerRow.pick != null && playerRow.pick != "")) ? true:false;
			playerRow.roundpick				= playerRow.round+""+playerRow.pick;
			playerRow.tabsetid				= 'dt-tab-set-1';
			playerRow.collegeidparam		= playerRow.collegeid;
			playerRow.positionparam			= (typeof playerRow.positionGroup == "string")? playerRow.positionGroup.toLowerCase():"";
			playerRow.roundparam			= (typeof playerRow.round == "number")? playerRow.round:"";
			playerRow.teamabbrparam			= (typeof playerRow.teamabbr == "string")? playerRow.teamabbr.toLowerCase():"";
			playerRow.teamnotes				= (typeof playerRow.notes == "string" && playerRow.notes != "")? (" ("+playerRow.notes+")"):"";
			if(typeof playerRow.lastName == "string" && typeof playerRow.firstName == "string"){
				playerRow.name				= (playerRow.lastName != "" && playerRow.firstName != "")? (playerRow.lastName+", "+playerRow.firstName):"";
			}
			//playerRow.name					= ((typeof playerRow.lastName == "string" && typeof playerRow.firstName == "string") && (playerRow.lastName != "" && playerRow.firstName != ""))? (playerRow.lastName+", "+playerRow.firstName):"";
			if(drafted){
				this.__filterkeys[("alpha-"+(playerRow.lastName.substring(0,1).toLowerCase()))]=true;
				this.__filterkeys[("pos-"+(playerRow.positionGroup.toLowerCase()))]=true;
				this.__filterkeys[("round-"+(playerRow.round))]=true;
				//nfl.log("added \"alpha-"+(playerRow.lastName.substring(0,1).toLowerCase())+"\", \"pos-"+(playerRow.positionGroup.toLowerCase())+"\", \"round-"+(playerRow.round)+"\" to this.__filterkeys");
				if(playerRow.pickAnalysis == 1){ playerRow.toggle = true; }
				playerRow.toggleicon		= '+';
				playerRow.playerprofileparam	= ("/draft/2008/profiles/"+ playerRow.firstName.toLowerCase().replace(/ /gi,"-") +"-"+ playerRow.lastName.toLowerCase().replace(/ /gi,"-") +"?id="+ playerRow.playerid);
				if(typeof playerRow.conference == "undefined"){
					if(typeof this.undraftedPlayers.__dataset[playerId] != "undefined" && this.undraftedPlayers.__dataset[playerId] != null){
						playerRow.conference	= this.undraftedPlayers.__dataset[playerId].conference;
					}else{
						if(typeof this.draftedPlayers.__dataset[playerId] != "undefined"){
							playerRow.conference	= this.draftedPlayers.__dataset[playerId].conference;
						}
					}
				}
				if(typeof this.playerAnalysis.__dataset[playerId] != 'undefined' && this.playerAnalysis.__dataset[playerId] != null){
					playerRow.pickanalysis	= this.playerAnalysis.__dataset[playerId].analysis;
					playerRow.toggleicon	= '-';
					playerRow.rowclass		= "expanded-row";
				}
				if(this.draftedPlayers.__dataset[playerId] !== playerRow){ this.draftedPlayers.__isDirty	= true; }
				if(this.teamPicks.__dataset[playerId] !== playerRow){ this.teamPicks.__isDirty	= true; }
				dataset1[playerId]			= playerRow;
				dataset2[playerId]			= playerRow;
				/* check the undrafted dataset for this player */
				if(typeof this.undraftedPlayers.__dataset[playerId] != "undefined" && this.undraftedPlayers.__dataset[playerId] != null){
					/* remove entry from undrafted players*/
					this.undraftedPlayers.__dataset[playerId]	= null;
					this.undraftedPlayers.__isDirty				= true;
				}
			}else{
				/* this is an undrafted player OR pick */
				if((typeof playerRow.lastName != "undefined" && typeof playerRow.firstName != "undefined") && (playerRow.lastName != "null" && playerRow.lastName != "" && playerRow.firstName != "null" && playerRow.firstName != "")){
					/* this entry is a player entry and goes into undrafted players */
					this.__filterkeys[("alpha-"+(playerRow.lastName.substring(0,1).toLowerCase()))]=true;
					this.__filterkeys[("pos-"+(playerRow.positionGroup.toLowerCase()))]=true;
					this.__undraftedfilterKeys[("alpha-"+(playerRow.lastName.substring(0,1).toLowerCase()))]=true;
					this.__undraftedfilterKeys[("pos-"+(playerRow.positionGroup.toLowerCase()))]=true;
					//nfl.log("added \"alpha-"+(playerRow.lastName.substring(0,1).toLowerCase())+"\", \"pos-"+(playerRow.positionGroup.toLowerCase())+"\" to this.__filterkeys");
					
					playerRow.toggle				= false;
					playerRow.playerprofileparam	= ("/draft/2008/profiles/"+ playerRow.firstName.toLowerCase().replace(/ /gi,"-") +"-"+ playerRow.lastName.toLowerCase().replace(/ /gi,"-") +"?id="+ playerRow.playerid)
					this.undraftedPlayers.__dataset[playerId]	= playerRow;
					this.undraftedPlayers.__isDirty				= true;
				}else{
					/* this entry is a pick entry and goes into dataset 3 */
					this.__filterkeys[("round-"+(playerRow.round))]=true;
					playerRow.toggle			= false;
					dataset2[playerId]			= playerRow;
				}
			}
			key = playerId = playerRow = drafted = null; 
		}
		try{
			if(this.undraftedPlayers.__isDirty || this.draftedPlayers.__isDirty){
				var listFilters	= $$(".players-list-links li");
				for(var index=0, len=listFilters.length; index < len; ++index) {
					var ele	= listFilters[index];
					if(typeof this.__filterkeys[ele.id] == "undefined"){
						ele.addClassName("inactive");
					}else{
						ele.removeClassName("inactive");
					}
					ele = null;
				}
				listFilters = null;
			}
		}catch(e){nfl.log("splitPlayerDataByPick Error: error occured while processing available filters. \n\r"+ e);}
		this.draftedPlayers.__dataset	= dataset1;
		this.teamPicks.__dataset		= dataset2;
		dataset1 = dataset2 = jsonkeys = null;
	},
	getTeamTabContent: function(teamAbbr,teamName){
		var requestURL			= '/widget/draft/tracker/teams/profile?year=2008&team='+teamAbbr;
		if(typeof teamName != "undefined"){
			teamName			= teamName.toLowerCase().replace(/ /gi,"");
			requestURL			= '/widget/draft/tracker/teams/'+ teamName +'/profile?year=2008&team='+teamAbbr;
		}
		if(this.__lastActiveTeam != teamAbbr){ $('dt-container-by-team').update(); }
		this.__lastActiveTeam	= teamAbbr;
		nfl.log("getTeamTabContent: "+ teamAbbr);
		document.fire("draft:tracker:dataupdating",{});
		var teamTabContentRequest	= new Ajax.Updater('dt-container-by-team', requestURL, {
			parameters: { team: teamAbbr },
			method: 'get', 
			evalScripts: true,
			onSuccess: function(){ 
				document.fire("draft:tracker:dataupdated",{});
			}.bind(this)
		});
	},
	getPlayerAnalysis: function(playerId){
		nfl.log("nfl.draft.tracker.dataset.getPlayerAnalysis");
		// /ajax/pickanalysis?playerId=0
		document.fire("draft:tracker:dataupdating",{});
		var analysisRequest	= new Ajax.Request(("/ajax/pickanalysis?playerId="+ playerId), {
			method: "get", 
			params: {"playerId":playerId}, 
			evalJSON: "force",
			onSuccess: function(XHR){
				try{
				if(typeof XHR.responseJSON != "undefined"){
					nfl.log("sending responseJSON");
					var analysisJSON	= XHR.responseJSON;
				}else{
					var analysisJSON	= eval('(' + XHR.responseText + ')');
					nfl.log(XHR.responseText);
				}
				this.playerAnalysis.__dataset[playerId]					= {analysis:'<strong>Pick Analysis:</strong>&nbsp;'+ analysisJSON.pickAnalysis};
				this.draftedPlayers.__dataset[playerId].pickanalysis	= this.playerAnalysis.__dataset[playerId].analysis;
				this.draftedPlayers.__dataset[playerId].toggleicon		= '-';
				this.draftedPlayers.__dataset[playerId].rowclass		= "expanded-row";
				this.teamPicks.__dataset[playerId].pickanalysis			= this.playerAnalysis.__dataset[playerId].analysis;
				this.teamPicks.__dataset[playerId].toggleicon			= '-';
				this.teamPicks.__dataset[playerId].rowclass				= "expanded-row";
				}catch(e){ nfl.log("getPlayerAnalysis: Error"+ e.message);}
				this.updateDisplay();
				document.fire("draft:tracker:dataupdated",{});		
			}.bind(this)
		});
	},
	removePlayerAnalysis: function(playerId){
		nfl.log("nfl.draft.tracker.dataset.removePlayerAnalysis");
		this.playerAnalysis.__dataset[playerId]					= null;
		this.draftedPlayers.__dataset[playerId].pickanalysis	= null;
		this.draftedPlayers.__dataset[playerId].toggleicon		= '+';
		this.draftedPlayers.__dataset[playerId].rowclass		= null;
		this.teamPicks.__dataset[playerId].pickanalysis			= null;
		this.teamPicks.__dataset[playerId].toggleicon			= '+';
		this.teamPicks.__dataset[playerId].rowclass				= null;
	},
	getFilterListId: function(currentTab,returnAny){
		var tabView		= this.getCurrentView(currentTab);
		var retAny		= (typeof returnAny != "undefined" && returnAny)?returnAny:false;
		switch(tabView){
			case "by-name":
				return "players-list-links-alphabetical";
				break;
			case "by-position":
				return "players-list-links-position";
				break;
			case "by-college":
				if($("college-conference-dropdown").selectedIndex > 0 || retAny){
					return "college-conference-dropdown";
				}else{
					if($("college-dropdown").selectedIndex > 0 || retAny){
						return "college-dropdown";
					}else{
						return null
					}
				}
				break;
			case "by-team":
				if($("teams-dropdown").selectedIndex > 0 || retAny){
					return "teams-dropdown";
				}else{
					return null;
				}
				break;
			case "by-round":
				return "players-list-links-round";
				break;
			default:
				break;
		}
	},
	/*
	 * getCurrentViewFilter Method
	 * returns String
	 */
	getCurrentView: function(currentTab){
		var currentTab	= (typeof currentTab == "undefined")? $$("#dt-tab-set-1 li.active")[0]:currentTab;
		if(currentTab){
			var tabAnchor	= currentTab.down("a").getAttribute("href");
			var viewStr		= tabAnchor.replace("#dt-","");
			nfl.log("getCurrentView: "+viewStr);
			return viewStr;
		}
		return false;
	},
	getCurrentViewFilter: function(currentTab,filterParam){
		var tabView				= this.getCurrentView(currentTab);
		var tabFilterListId		= this.getFilterListId(currentTab);		
		var tabFilterEle		= false;
		var tabFilterParam		= (typeof filterParam != "undefined")? filterParam:false;
		var tabFilterName		= false;
		nfl.log("getCurrentViewFilter: tabFilterListId = "+ tabFilterListId);
		
		try{
			if($(tabFilterListId)){
				var tabFilterListType	= $(tabFilterListId).tagName.toLowerCase();
				nfl.log("getCurrentViewFilter: tabFilterListType = "+ tabFilterListType);
				if(tabFilterListType == 'ul'){
					nfl.log("getCurrentViewFilter: looking up li filter element");
					if($$("#"+tabFilterListId+" li.active").length > 0){
						var tabFilterEle = $$("#"+tabFilterListId+" li.active")[0];
					}else{
						if($$("#"+tabFilterListId+" li.default").length > 0){
							var tabFilterEle	= $$("#"+tabFilterListId+" li.default")[0];
						}
					}
					if(tabFilterEle){var tabFilterParam	= (new String(tabFilterEle.innerHTML).strip());}
				}
				if(tabFilterListType == 'select'){
					nfl.log("getCurrentViewFilter: looking up select filter element");
					var tabFilterParam	= $(tabFilterListId).options[$(tabFilterListId).selectedIndex].value;
					var tabFilterName	= $(tabFilterListId).options[$(tabFilterListId).selectedIndex].text;
				}
			}
		}catch(err){ nfl.log("getCurrentViewFilter: Error: "+ err.message);}
		if(tabFilterParam){
			switch(tabView){
				case "by-name":
					return {field:"lastName",operator:"startsWith",criteria: tabFilterParam};
					break;
				case "by-position":
					return {field:"positionGroup",operator:"=",criteria: tabFilterParam};
					break;
				case "by-college":
					if(tabFilterListId == "college-dropdown"){
						return {field:"collegeid",operator:"=",criteria: tabFilterParam};
					}else{
						return {field:"conference",operator:"=",criteria: tabFilterParam};
					}
					break;
				case "by-team":
					return {field:tabFilterName,operator:"=",criteria: tabFilterParam};
					break;
				case "by-round":
					return {field:"round",operator:"=",criteria: tabFilterParam};
					break;
				default:
					break;
			}
		}
		return false;
	},
	updateLinks: function(tabView){
		var tabView		= (typeof tabView != "undefined")? tabView:this.getCurrentView();
		var filterEles	= [];
		switch(tabView){
			case "by-name":
				$$("#"+ this.draftedPlayers.__databoundobject.id +" .toggleicon").each(function(ele){
					/* add event listeners to expand/collapse icons */
					Event.observe(ele,"click",this.onRowToggle.bind(this));
				}.bind(this));
				filterEles	= $$("#"+ this.draftedPlayers.__databoundobject.id +" .filterlink");
				$$("#"+ this.undraftedPlayers.__databoundobject.id +" .filterlink").each(function(ele){filterEles[filterEles.length] = ele;});
				break;
			case "by-position":
				$$("#"+ this.draftedPlayers.__databoundobject.id +" .toggleicon").each(function(ele){
					/* add event listeners to expand/collapse icons */
					Event.observe(ele,"click",this.onRowToggle.bind(this));
				}.bind(this));
				filterEles	= $$("#"+ this.draftedPlayers.__databoundobject.id +" .filterlink");
				$$("#"+ this.undraftedPlayers.__databoundobject.id +" .filterlink").each(function(ele){filterEles[filterEles.length] = ele;});
				break;
			case "by-college":
				$$("#"+ this.draftedPlayers.__databoundobject.id +" .toggleicon").each(function(ele){
					/* add event listeners to expand/collapse icons */
					Event.observe(ele,"click",this.onRowToggle.bind(this));
				}.bind(this));
				filterEles	= $$("#"+ this.draftedPlayers.__databoundobject.id +" .filterlink");
				$$("#"+ this.undraftedPlayers.__databoundobject.id +" .filterlink").each(function(ele){filterEles[filterEles.length] = ele;});
				break;
			case "by-team":
				/* this is some wacky stuff */
				/* TODO - make it work */
				break;
			case "by-round":
				$$("#"+ this.teamPicks.__databoundobject.id +" .toggleicon").each(function(ele){
					/* add event listeners to expand/collapse icons */
					Event.observe(ele,"click",this.onRowToggle.bind(this));
				}.bind(this));
				filterEles	= $$("#"+ this.teamPicks.__databoundobject.id +" .filterlink").each(function(ele){filterEles[filterEles.length] = ele;});
				break;
			default:
				$$("#"+ this.draftedPlayers.__databoundobject.id +" .toggleicon").each(function(ele){
					/* add event listeners to expand/collapse icons */
					Event.observe(ele,"click",this.onRowToggle.bind(this));
				}.bind(this));
				filterEles	= $$("#"+ this.draftedPlayers.__databoundobject.id +" .filterlink");
				$$("#"+ this.undraftedPlayers.__databoundobject.id +" .filterlink").each(function(ele){filterEles[filterEles.length] = ele;});
				break;
		}
		for(var a=0,len=filterEles.length; a<len; ++a){
			Event.observe(filterEles[a],"click",this.onFilterLinkClicked.bind(this));
		}
		filterEles	= null;
		/*
		filterEles.each(function(ele){
			//add event listeners to data view links 
			Event.observe(ele,"click",this.onFilterLinkClicked.bind(this));
		}.bind(this));
		*/
	},
	ieFooterUIReset: function(){
		if(Prototype.Browser.IE){
			var ft = $('ft');
			if (!ft) return;
			ft.style.position = 'static';
			ft.style.position = '';
			ft = null;
		}
	},
	updateDisplay: function(tabView,tabFilter){
		/* get currently visible dataview */
		var tabView		= (typeof tabView != "undefined")? tabView:this.getCurrentView();
		var tabFilter	= (typeof tabFilter != "undefined")? tabFilter:this.getCurrentViewFilter();
		var filterEles	= [];
		nfl.log("nfl.draft.tracker.dataset.updateDisplay: "+ tabView);
		switch(tabView){
			case "by-name":
				this.draftedPlayers.bindTo($('players-grid-table-by-name-drafted'));
				this.draftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.draftedPlayers.filter();
				this.undraftedPlayers.bindTo($('players-grid-table-by-name-undrafted'));
				this.undraftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.undraftedPlayers.filter();
				this.draftedPlayers.bind();
				this.undraftedPlayers.bind();
				break;
			case "by-position":
				this.draftedPlayers.bindTo($('players-grid-table-by-position-drafted'));
				this.draftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.draftedPlayers.filter();
				this.undraftedPlayers.bindTo($('players-grid-table-by-position-undrafted'));
				this.undraftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.undraftedPlayers.filter();
				this.draftedPlayers.bind();
				this.undraftedPlayers.bind();
				break;
			case "by-college":
				this.draftedPlayers.bindTo($('players-grid-table-by-college-drafted'));
				this.draftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.draftedPlayers.filter();
				this.undraftedPlayers.bindTo($('players-grid-table-by-college-undrafted'));
				this.undraftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.undraftedPlayers.filter();
				this.draftedPlayers.bind();
				this.undraftedPlayers.bind();
				break;
			case "by-team":
				/* this is some wacky stuff */
				/* TODO - make it work */
				if(tabFilter){
					this.getTeamTabContent(tabFilter.criteria,tabFilter.field);
				}
				break;
			case "by-round":
				this.teamPicks.bindTo($("players-grid-table-by-round"));
				this.teamPicks.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				this.teamPicks.filter();
				this.teamPicks.bind();
				break;
			default:
				this.draftedPlayers.bindTo($('players-grid-table-by-name-drafted'));
				this.undraftedPlayers.bindTo($('players-grid-table-by-name-undrafted'));
				this.draftedPlayers.bind();
				this.undraftedPlayers.bind();
				break;
		}
		this.ieFooterUIReset();
		this.updateLinks(tabView);
	},
	onFilterLinkClicked: function(event){
		nfl.log("!!onFilterLinkClicked!!");
		var href	= Event.element(event);
		this.clearLiveFilter();
		this.updateHashPath(href.href);
	},
	onRowToggle: function(event){
		var elementId	= Event.element(event).id;
		var playerId	= elementId.substring(elementId.lastIndexOf("-")+1);
		nfl.log("onRowToggle: playerId = "+ playerId);
		if(this.playerAnalysis.__dataset[playerId] != null){
			/* already has player analysis, collapse it */
			this.removePlayerAnalysis(playerId);
			$(elementId).update("[+]");
			this.updateDisplay();
		}else{
			this.getPlayerAnalysis(playerId);
			$(elementId).update("[-]");
		}
	},
	onTabClick: function(event){
		var srcObj		= Event.element(event);
		var tabObj		= srcObj;
		switch(srcObj.tagName){
			case "A":
				tabObj	= srcObj.up();
				break;
			case "LI":
				tabObj	= srcObj;
				break;
			case "DIV":
				tabObj	= srcObj.up();
				break;
			default:
				break;
		}
		var tabView		= this.getCurrentView(tabObj);
		var tabFilter	= this.getCurrentViewFilter(tabObj);
		this.clearLiveFilter();
		this.logTabView(tabView);
		this.updateDisplay(tabView,tabFilter);
	},
	logTabView: function(tabView){
		//t_view can follow the deep linking convention.
		//tabText = tab:dt-by-position || tab:dt-by-name || tab:dt-by-college || tab:dt-by-team || tab:dt-by-round
		var s_analytics 	= s_gi(s_account);
		s_analytics.linkTrackEvents = 'event1';
		s_analytics.linkTrackVars="events,pageName,hier1,prop5,eVar4";
		
		var t_view			= "tab:dt-"+ tabView;
		s_analytics.pageName = "nfl:draft:tracker:" + t_view;
		
		//t_view can follow the deep linking convention but we need to change the colon ( : ) to a pipe (|).
		//tabText = tab|dt-by-position || tab|dt-by-name || tab|dt-by-college || tab|dt-by-team || tab|dt-by-round
		t_view				= "tab|dt-"+ tabView;
		s_analytics.hier1 	= "nfl:draft|tracker|" + t_view;
		s_analytics.prop5 	= "nfl:draft|tracker|" + t_view;
		s_analytics.eVar4 	= "nfl:draft|tracker|" + t_view;
		s_analytics.prop35 = '';
		s_analytics.prop6 = '';
		
		s_analytics.events = 'event1';
		
		//alert("s_analytics.hier1 = "+s_analytics.hier1+"\n\r"+"s_analytics.prop5 = "+ s_analytics.prop5 +"\n\r"+"s_analytics.eVar4 = "+ s_analytics.eVar4 +"\n\r");
		void(s_analytics.t());
	},
	logFilterView: function(filterViewId){
		var s_analytics = s_gi(s_account);
		s_analytics.linkTrackEvents="";
		s_analytics.linkTrackVars="prop35";
		s_analytics.prop35=filterViewId;
		s_analytics.events = '';
		s_analytics.tl(true,'o',filterViewId);
	},
	logLiveFilterView: function(searchTerm){
		var resultsReturned = (this.draftedPlayers.size() + this.undraftedPlayers.size());
		var alphaKey		= ('alpha-'+searchTerm.substring(0,1).toLowerCase());
		nfl.log("logLiveFilterView: alphaKey = "+alphaKey+", resultsReturned = "+resultsReturned+", searchTerm = "+ searchTerm);
		var s_analytics		= s_gi(s_account);
		s_analytics.linkTrackVars="prop6,eVar5,prop7";
		s_analytics.linkTrackEvents="event2";
		s_analytics.prop6=searchTerm; // this is the value from the text field
		s_analytics.eVar5=searchTerm; // this is the value from the text field
		s_analytics.prop7=resultsReturned;
		s_analytics.events = 'event2'; 
		s_analytics.tl(true,'o',alphaKey);
	},
	onNavClick: function(event){
		var srcObj		= Event.element(event);
		var hrefObj		= null;
		switch(srcObj.tagName.toLowerCase()){
			case "li":
				hrefObj	= srcObj.down("a");
				break;
			case "a":
				hrefObj	= srcObj;
				break;
		}
		this.clearLiveFilter();
		//get tab parameter;
		//this.updateHashPath(hrefObj.href);
	},
	setTabParamElement: function(param){
		nfl.log("setTabParamElement("+ param +")");
		var filterListId, filterList;
		if(typeof param == 'string'){
			param	= $H({param: param});
		}
		param.unset('dt-tab-set-1');
		param.each(function(pair){
			if(param.keys().indexOf(pair.key) > -1){
				paramEle = $(pair.value);
				
				nfl.log('setTabParamElement: paramEle.tagName = '+ paramEle.tagName)
				if(paramEle && paramEle.tagName){
					/* do things the awesome way */
					switch(paramEle.tagName.toLowerCase()){
						case "option":
							filterList					= paramEle.up("select");
							filterList.selectedIndex	= paramEle.previousSiblings().length;
							nfl.log("setTabParamElement:option. filterList = "+ filterList +"\n\rtried to set filterList.selectedIndex to "+paramEle.previousSiblings().length);
							var filterListSibling		= filterList.previous('select');
							while(filterListSibling){
								filterListSibling.selectedIndex	= 0;
								filterListSibling		= filterListSibling.previous('select');
							}
							filterListSibling			= filterList.next('select');
							while(filterListSibling){
								filterListSibling.selectedIndex	= 0;
								filterListSibling		= filterListSibling.next('select');
							}
							filterListSibling = null;
							break;
						case "li":
							filterList		= paramEle.up("ul");
							filterListId	= filterList.id;
							/* deactivate previous filters */
							$$("#"+ filterListId +" li.active").each(function(ele){ ele.removeClassName("active"); });
							/* activate new filter*/
							paramEle.addClassName("active");
							break;
						default:
							break;
					}
				}
			}
		});
		filterListId = filterList = paramEle = null;
	},
	onHashChange: function(e){
		if(window.location.hashparams.get() != null){
			this.setTabParamElement(window.location.hashparams.get());
			this.clearLiveFilter();
			this.updateDisplay();
		}
	},
	updateHashPath: function(uri){
		var anchorparams	= window.location.hashparams.getHashFromString(uri.substring(uri.lastIndexOf("#")+1));
		window.location.hashparams.set(anchorparams);
	},
	clearLiveFilter: function(){
		if(typeof this.draftedPlayers.__filters[1] != "undefined" || typeof this.undraftedPlayers.__filters[1] != "undefined"){
			this.draftedPlayers.__filters		= [this.draftedPlayers.__filters[0]];
			this.undraftedPlayers.__filters		= [this.undraftedPlayers.__filters[0]];
			this.draftedPlayers.__isDirty		= true;
			this.undraftedPlayers.__isDirty		= true;
			this.teamPicks.__isDirty			= true;
		}
		draftTrackerController.livefilter.reset();
	},
	onLiveFilterChange: function(args){
		nfl.log("DT onLiveFilterChange: start");
		if(!($("dt-tab-set-1-tab-0").hasClassName("active"))){
			/* change tab to by name */
			dtTabSet.changeTab($("dt-tab-set-1-tab-0").down("a"));
		}
		if(args.value != ""){
			if(!($("alpha-"+ (args.value.substring(0,1)).toLowerCase()).hasClassName("active"))){
				nfl.log("live filter: changing tracker active filter class and filters");
				$$("#"+ draftTrackerController.getFilterListId() +" li.active").each(function(ele){ ele.removeClassName("active"); });
				$("alpha-"+ (args.value.substring(0,1)).toLowerCase()).addClassName("active");
			}
			var tabFilter	= this.getCurrentViewFilter();
			this.draftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
			this.undraftedPlayers.filterBy(tabFilter.field,tabFilter.operator,tabFilter.criteria);
				
			this.draftedPlayers.__isDirty				= true;
			this.undraftedPlayers.__isDirty				= true;
			this.draftedPlayers.__filters[1]	= {"field":"lastName","criteria":args.value,"operator":"startsWith"};
			this.undraftedPlayers.__filters[1]	= {"field":"lastName","criteria":args.value,"operator":"startsWith"};
			this.draftedPlayers.filter();
			this.undraftedPlayers.filter();
		}
		this.draftedPlayers.bindTo($('players-grid-table-by-name-drafted'));
		this.undraftedPlayers.bindTo($('players-grid-table-by-name-undrafted'));
		this.draftedPlayers.bind();
		this.undraftedPlayers.bind();
		this.updateLinks("by-name");
		nfl.log("DT onLiveFilterChange: stop");
	}
}
