var DleagueScoreboard = Class.create({

	initialize : function(base) {
		if (!base) { return; }

		this.base = base;
		this.interval = null;
		this.todays_games = this.base.down("#scoreboard_hp_today_games .games");
		
		
		if (this.todays_games) {		
			this.loadTodaysGames();
		}
	},
	
	loadTodaysGames : function() {
		new Ajax.Request("/dleague/scoreboardHP.jsp?only_next_games=true", {
			method : "GET",
			onSuccess : function(response) {
				this.todays_games.replace(response.responseText);
				this.todays_games = this.base.down("#scoreboard_hp_today_games .games");
			}.bind(this),
			onComplete : function(response) {
				this.interval = setTimeout(this.loadTodaysGames.bind(this), 30000); 
			}.bind(this)
		})
	}

});

NBAUtil.Events.addDomLoadedHandler(function() { new DleagueScoreboard($('scoreboard')); });
