var draftGroups = Class.create(draftApi,{
			
	init : function( options ){
		this.setOptions( options );		
		//Init Information	
		this.iter    		= 0;
		this.Mode 	 		= this.options.Mode;
		this.AMode 			= this.options.AMode,
		this.Actionable     = this.options.Actionable,
		this.Source  		= this.options.Source;
		this.Timer   		= this.options.Timer;
		this.Url 	 		= this.options.Url;
		this.Flagble 		= this.options.Flagble;
		this.EnableSub		= this.options.EnableSub;
		this.Ausenable  	= this.options.Ausenable;
		this.Fieldble   	= this.options.Fieldble;
		this.idData  		= 'headerjs' + this.iter;
		this.Headble    	= this.options.Headble;
		this.prevable		= this.options.prevable;
		this.useFullnames 	= this.options.useFullnames
		//this.ILoader    = $('MxMLoaderFieldGame');
		
		//this.Symbols = Symbology;
		this.OutField = '';
		this.continuer = 11;
		
		this.GameType   = null;
		this.GameStatus = null;

		this.loadDraftGroups();
		
		/*if( !this.Headble ) {
		
			$('MxMlLineupTeam1HeaderNav').hide();
			$('MxMlLineupTeam1Header').hide();
			$('MxMlLineupTeam2Header').hide();
			$('MxMlLineupTeam2HeaderNav').hide();
		
		}*/
		
	},
	
	setOptions : function( options ){							  
 		
		this.options = Object.extend({
									 
			Mode :  'Secure',
			Server : '',	
			Url : '',
			Timer  : 900,
			AMode : null,
			Source : null,			
			Flagble : null,
			EnableSub : null,
			Ausenable : true,
			Fieldble : null,
			Headble : true,
			prevable:true,
			useFullnames:false,
			Actionable : false,
			onComplete : Prototype.emptyFunction
			
		}, options || {});
		
		
	},
	
	loadDraftGroups : function( ){
		
		if( this.Fieldble ) {
			if( this.ILoader ) {
				
				this.ILoader.show();
			
			}
		}
		this.loadJs();
	},
	
   request : function(){
		new Ajax.Request(this.Url,this.ORequest);
	},
	/*
	*  function : initDataPageLoad 
	*  description: actualiza en el api los datos que se requieren  teamsUrl
	*  sÃƒÆ’Ã†â€™Ãƒâ€šÃ‚Â³lo una vez al cargar 	
	*/
	initDataPageLoad : function (){
		
		
		if( this.DefineLineUpTable() ) {
			
			this.DefineHistoryLineUps();		
			this.setButtonsEvents();
			
		}
		
		if( $('mxmSEFFieldGame') ){
			
			$('mxmSEFFieldGame').hide();			
			this.UIField = new CFieldUI(this);			
			
		}
		
	},
	
	
	/*
	*  function : executer 
	*  description: loadPeriodicamente el nuevo js cada 60 segundos+	
	*/
	executer : function( request ){
		this.removeLoader();	
		this.DataGameInfo = this.DefineData( request );
		this.HandLoadJs   = this.loadDraftGroups.bindAsEventListener(this);
		
		if( this.iter == 1 ) {
			
			this.initDataPageLoad();
			new PeriodicalExecuter( this.HandLoadJs, this.Timer );
			
		}
		
		
		//Muestra los contadores del subheader grande*/
		this.updateHeaderCounts();
		
	    var thisUrl = new String();
		//var thisUrl = window.location.toString();
		//var auxStr = thisUrl.replace('http://mxm2.televisadeportes.com/', '');
		//urchinTracker(auxStr);
	    var pix = new Image();
        pix.src = doStats('return');
		
		this.notify('onComplete',this);
		
	},
	
	
	DefineLineUpTable :function(){
		
		return $('MxMLineUpTable');
		
	},
	
	DefineGameType : function(){
		
	},
	
	DefineGameStatus : function(){
	
	},
	
	DefineLineUpContainer : function( container ){
		
		if( container == 1 || container == 'Local' ){
			
			this.container = $('MxMLineUpPrevious1');
			
			
		}else{
			
			this.container = $('MxMLineUpPrevious2');
			
		}
		
		this.container.update('');
		return this.container;

		
	},
	
	DefineSubsContainer : function( container ){
		
		this.MxMSubsTable = $('MxMSubsTable');
		
		
		if( this.MxMSubsTable ){
		
		if( container == 1 || container == 'Local'){
			
			this.Subscontainer = $('MxMSubsTableBodyTeam1');
			
			
		}else{
			
			this.Subscontainer = $('MxMSubsTableBodyTeam2');
			
		}
		
		this.Subscontainer.update('');
		return this.Subscontainer;
		
		}else{
		
			return this.MxMSubsTable;
			
		}
		
	},
	
	
	DefineUsentsContainer : function( container ){
		
		if( container == 1 || container == 'Local'){
			
			this.Acontainer = $('MxMLineUpAusentsTeam1');
			
		}else{
			
			this.Acontainer = $('MxMLineUpAusentsTeam2');
			
		}
		
		
		this.Acontainer.update('');
		return this.Acontainer;
		
	},
	 
	DefineGoalsContainer : function( container ){

		
		this.MxmLineUpGoals = $('MxmLineUpGoalsTeam1');
		
			if( this.MxmLineUpGoals ) {
			
			if( container == 1 || container == 'Local'){
				
				this.Gcontainer = $('MxmLineUpGoalsTeam1');
				
			}else{
				
				this.Gcontainer = $('MxmLineUpGoalsTeam2');
				
			}
			
			this.Gcontainer.update('');
			
			return this.Gcontainer;
		
		}else{
			
			return this.MxmLineUpGoals;
			
		}
	},
	
	DefinePenaltiesContainer : function ( container ){
			this.MxmLineUpPenalties = $('MxmLineUpPenaltiesTeam1');
			if(this.MxmLineUpPenalties){
				if( container == 1 || container == 'Local'){				
					this.Gcontainer = $('MxmLineUpPenaltiesTeam1');				
				}else{				
					this.Gcontainer = $('MxmLineUpPenaltiesTeam2');				
				}
				this.Gcontainer.update('');			
				return this.Gcontainer;
			}else{			
				return this.MxmLineUpPenalties;
			}
			
	},	
	
	
	DefinePenalizedContainer : function( container ){
		
		this.MxmLineUpPenalized = $('MxmLineUpPenalizedTeam1');
		
		if( this.MxmLineUpPenalized ){
		
		if( container == 1 || container == 'Local'){
			
			this.Pcontainer = $('MxmLineUpPenalizedTeam1');
			
		}else{
			
			this.Pcontainer = $('MxmLineUpPenalizedTeam2');
			
		}
		
		this.Pcontainer.update('');
		return this.Pcontainer;
		
		}else{
			
			return this.MxmLineUpPenalized;
			
		}
		
	},
	
	DefineExpelledContainer : function( container ){

			this.MxmLineUpExpelled = $('MxmLineUpExpelledTeam1');
		
			if( this.MxmLineUpExpelled ) {	
			
				if( container == 1 || container == 'Local'){
					
					this.Excontainer = $('MxmLineUpExpelledTeam1');
					
				}else{
					
					this.Excontainer = $('MxmLineUpExpelledTeam2');
					
				}
				
				this.Excontainer.update('');
				return this.Excontainer;
			
			
		}else{
			
			return this.MxmLineUpExpelled
			
		}
		
	},

    updateHeaderCounts : function(){
		var teamAdd = 'spanTeamAdd';
		var teamDelete = 'spanTeamDelete';
		this.DataGameInfo.draftTeams.each(function(rowset,index){ 
		   teamAdd  += rowset.id; 
   		   teamDelete  += rowset.id; 
		   //alert( rowset.teamAdd + '- '+rowset.teamDelete)
          $(teamAdd).update( rowset.teamAdd);
          $(teamDelete).update( rowset.teamDelete);
		  
	  	   teamAdd = 'spanTeamAdd';
		   teamDelete = 'spanTeamDelete';
		}.bind(this));
	   
	}
	
 })