//-------------------------------
// Class
//-------------------------------

function LiveBoxscoreView() {

	
	var _self = this;

	//-------------------------------
	// Constants
	//-------------------------------
	
	
	//-------------------------------
	// Properties
	//-------------------------------
	
	var _view = $j("<ul class='boxscore'></ul>");
	
	var _data;
	var _boxscore = new Object();
	
	//-------------------------------
	// Constructor
	//-------------------------------
	
	$j(function() {
		
	});
	
	//-------------------------------
	// Public Methods
	//-------------------------------
	
	_self.video = function(data) {
		$j("#featuredTabContent #live ul.live li.main h1").html($j(data).find("title").text());
		$j("#featuredTabContent #live ul.live li.main .info").html("<div id='nbaLivePlayer'>You need Flash Player 9 or newer installed to view this content.</div>");
		$j("#featuredTabContent #live ul.live li.talk").html($j(data).find("chat").text());
		$j("#featuredContainer").css("height", $j("#featuredTabContent #live ul.live li.talk").height() + "px");
		videoPlayer.load();
	}
	
	_self.ingame = function(data) {
		_data = data;
		$j("#featuredTabContent #live ul.live li.main h1").html($j(data).find("title").text());
		$j("#featuredTabContent #live ul.live li.talk").html($j(data).find("chat").text());
		$j("#featuredContainer").css("height", $j("#featuredTabContent #live ul.live li.talk").height() + "px");
	}
	
	_self.boxscore = function(data) {
	
		if($j(data).find("error").text() == "No data") {
			var zeroes = ("0|0|0|0|0|0|0|0|0").split("|");
			_boxscore.htm = { "name" : $j(_data).find("game").attr("htm"), "score" : zeroes};
			_boxscore.vtm = { "name" : $j(_data).find("game").attr("vtm"), "score" : zeroes};
			
		} else {
			_boxscore.htm = team(data, "htm");
			_boxscore.vtm = team(data, "vtm");
		}
		
		var clock = $j(data).find("game").attr("clk");
		
		var content 	= "<li class='away'>";
		content			+= "<div class='score'>" + _boxscore.htm.score[_boxscore.htm.score.length - 1] + "</div>";
		content			+= "<img src='http://cdn.iamatrailblazersfan.com/logos/team_" + _boxscore.htm.name + "100.png'/></li>";
		content			+= "<li class='scoreboard'>";
		content			+= "<div class='clock'>" + ((clock != undefined) ? clock : "12:00") + "</div>";
		content			+= "<ul class='scores'>";
		content			+= "<li class='quarters'><span class='left'>&nbsp;</span><span class='quarter'>1</span><span class='quarter'>2</span><span class='quarter'>3</span><span class='quarter'>4</span><span class='right'>&nbsp;</span><div class='clear'></div></li>";
		content			+= "<li class='vtm score'><span class='left'>" + _boxscore.vtm.name.toUpperCase() + "</span><span class='quarter'>" + _boxscore.vtm.score[0] + "</span><span class='quarter'>" + _boxscore.vtm.score[1] + "</span><span class='quarter'>" + _boxscore.vtm.score[2] + "</span><span class='quarter'>" + _boxscore.vtm.score[3] + "</span><span class='quarter total'>" + _boxscore.vtm.score[_boxscore.htm.score.length - 1] + "</span><span class='right'>&nbsp;</span><div class='clear'></div></li>";
		content			+= "<li class='htm score'><span class='left'>" + _boxscore.htm.name.toUpperCase() + "</span><span class='quarter'>" + _boxscore.htm.score[0] + "</span><span class='quarter'>" + _boxscore.htm.score[1] + "</span><span class='quarter'>" + _boxscore.htm.score[2] + "</span><span class='quarter'>" + _boxscore.htm.score[3] + "</span><span class='quarter total'>" + _boxscore.htm.score[_boxscore.htm.score.length - 1] + "</span><span class='right'>&nbsp;</span><div class='clear'></div></li>";
		content			+= "<li class='quarters last'><span class='left'>&nbsp;</span><span class='quarter'>&nbsp;</span><span class='quarter'>&nbsp;</span><span class='quarter'>&nbsp;</span><span class='quarter'>&nbsp;</span><span class='right'>&nbsp;</span><div class='clear'></div></li></ul>";
		
		content			+= "<ul class='cta'><a href='http://trailblazerslive.rayv.com'><img src='http://www.nba.com/blazers/media/tbr2-stream-game.jpg'/></a></ul></li>";

		content			+= "<li class='home'>";
		content			+= "<div class='score'>" + _boxscore.vtm.score[_boxscore.vtm.score.length - 1] + "</div>";
		content			+= "<img src='http://cdn.iamatrailblazersfan.com/logos/team_" + _boxscore.vtm.name + "100.png'/></li>";
		content			+= "<li class='meta'><a class='follow' href='http://www.iamatrailblazersfan.com/GamesPagesRoot/tabid/177/IamaGameId/383/Default.aspx'>Follow Game Live</a></li><div class='clear'></div>";
		
		_view.html(content);

		$j("#featuredTabContent #live ul.live li.main .info").html(_view);
	}
	
	_self.intro = function() {
		$j(_view).fadeIn(function() {
			
		});
	}
	
	_self.exit = function() {
		$j(_view).fadeOut();
	}
	
	//-------------------------------
	// Private Methods
	//-------------------------------
	
	function team(data, type) {
		var content = $j(data).find(type);
		//alert(content.attr("scr"));
		var score = content.attr("scr").split("|");
		
		var data = { "name" : content.attr("tcd"), "score" : score }
		return data;
	}
	
	//-------------------------------
	// Listeners
	//-------------------------------
	

}
