// JavaScript Document

var draftHead = Class.create(draftApi,{
			
	init : function( options ){
		this.setOptions( options );		
		//Init Information	
		this.iter    		= 0;
		this.Timer   		= this.options.Timer;
		this.Url 	 		= this.options.Url;
		this.idData  		= 'headerjs' + this.iter;
		this.loadDraftHeader();
		
	},
	
	setOptions : function( options ){							  
 		
		this.options = Object.extend({
			Url : '',
			Timer  : 900,
			onComplete : Prototype.emptyFunction
			
		}, options || {});
		
		
	},
	
	loadDraftHeader : function( ){
		
		if( this.Fieldble ) {
			if( this.ILoader ) {
				
				this.ILoader.show();
			
			}
		}
		this.loadJs();
	},
	
	
	/*
	*  function : executer 
	*  description: loadPeriodicamente el nuevo js cada 60 segundos+	
	*/
	executer : function( request ){
		this.removeLoader();	
		this.DataGameInfo = this.DefineData( request );
		this.HandLoadJs   = this.loadDraftHeader.bindAsEventListener(this);
		if( this.iter == 1 ) {
			new PeriodicalExecuter( this.HandLoadJs, this.Timer );
		}
		
		
		//Muestra los contadores del subheader grande*/
		this.updateHeaderCounts();
		
		this.notify('onComplete',this);
		
	},

    updateHeaderCounts : function(){
	   if($('spanDraftTotalAdd')){
		   $('spanDraftTotalAdd').update( this.DataGameInfo.draftTotalAdd);
		   countdown('liTimeLeft', this.DataGameInfo.draftTournament.dateTime,'0', '');
	   }
	  if($('spanTournamentName')){
	       $('spanTournamentName').update( this.DataGameInfo.draftTournament.name);
	   }
	}
	
 })