// JavaScript Document

/*
* Creado por Fernando Soto 
* erickfernando@gmail.com
* AÃƒÆ’Ã‚Â±o 2009
*/


var draftStatus = Class.create(draftApi,{
		
	init : function( options ){
		this.setOptions( options );
		this.iter    		= 0;
		this.idData  		= 'headerjs' + this.iter;
		this.Fieldble   	= this.options.Fieldble;
        this.Timer   		= this.options.Timer;
		this.test = "";
       
		this.Url = this.options.Data.Url;
		//alert(this.options.Data.DataGameInfo.draftId);
		//this.Url 	 		= this.options.Url;
		//Init Information	

		this.loadDraftStatus();
		
		/*if( !this.Headble ) {
		
			$('MxMlLineupTeam1HeaderNav').hide();
			$('MxMlLineupTeam1Header').hide();
			$('MxMlLineupTeam2Header').hide();
			$('MxMlLineupTeam2HeaderNav').hide();
		
		}*/
		
	},
	
	setOptions : function( options ){							  
 		
		this.options = Object.extend({
									 
			Mode :  'Secure',
			Server : '',	
			Url : '',
			Timer  : 60,
			AMode : null,
			Source : null,			
			Flagble : null,
			EnableSub : null,
			Ausenable : true,
			Fieldble : null,
			Headble : true,
			prevable:true,
			useFullnames:false,
			Actionable : false,
			onComplete : Prototype.emptyFunction
			
		}, options || {});
		
		
	},
	

	loadDraftStatus : function( ){
		if( this.Fieldble ) {
			if( this.ILoader ) {
				this.ILoader.show();
			
			}
		}
		this.loadJs();
		 this.updateStatusDraft();
	},
	


	/*
	*  function : executer 
	*  description: loadPeriodicamente el nuevo js cada 60 segundos+	
	*/
	executer : function( request ){
		this.removeLoader();
		
		this.HandLoadJs   = this.loadDraftStatus.bindAsEventListener(this);
		if( this.iter == 1 ) {
			//this.initDataPageLoad();
			new PeriodicalExecuter( this.HandLoadJs, this.Timer );
		}
		
		//Muestra los contadores del subheader grande*/
		this.updateStatusDraft();
		
		this.notify('onComplete',this);
		
	},
	
	
	

     updateStatusDraft : function(){

		
		if( $('divDraftStatus') ) {
			//if( isNoEmpty(this.DataGameInfo.draftStatus)){
                $('spanDraftStatus').update( this.options.Data.DataGameInfo.draftStatus);
				startTime = this.options.Data.DataGameInfo.draftStart.split(':');
				startShortTime = startTime[0] + ':' +startTime[0];

				$('spanDraftStart').update(startShortTime + 'Hrs' );
				
				endTime = this.options.Data.DataGameInfo.draftEnd.split(':');
				endShortTime = endTime[0] + ':' +endTime[0];
				
			    $('spanDraftEnd').update( endShortTime + 'Hrs');
			    $('spanDraftTransfers').update( this.options.Data.DataGameInfo.draftTransfers);				
				counter('spanRightTime',this.options.Data.DataGameInfo.draftStart);
   		        counter('spanLeftTime',this.options.Data.DataGameInfo.draftEnd);
				$('divDraftStatus').show();
			/*	return true;
				
			}else{
				$('divDraftStatus').hide();	
				return false;
			}*/
				
		}else{
		
			return false;
		}
	 }
	
 })