var Galeria = new Class (
{
    id_contenedor:null,
    id_textos:null,
    elementos:null,
    resta_textos:null,
    duracion:null,
    pasos:null,
    ciclo_au:null,
    indice: 0,
    gal:null,
    array_text:null,
    posy:null,
    auto:null,
    autofunc:null,
    state:null,
    type_gal:null,
    text_efefct:null,
    initialize: function(id_contenedor,id_textos,elementos, resta_textos,posy, duracion, pasos,arraytext,auto,type_gal)
    {
        this.elementos=elementos;
        this.resta_textos=resta_textos;
        this.posy=posy;
        this.duracion=duracion;
        this.pasos=pasos;
        this.indice=0;
        this.id_textos=id_textos;
        this.array_text=arraytext;
        this.type_gal=type_gal;
        //this.text_efefct_content= new Fx.Toggle('gal_text_cont',{duration:(this.duracion + this.pasos)/2});
       // this.text_efefct_text=new Fx.Toggle(this.id_textos,{duration:(this.duracion + this.pasos)/2});
       // this.text_efefct_content.toggle('height');
       // this.text_efefct_text.toggle('height');


        if(auto==1)
        {
            this.autofunc=this.mueve_atras.periodical((this.duracion + this.pasos),this);
            this.state=1;
        }
        if(this.type_gal==1)
        {
            this.gal = new Fx.Cycle.fade(id_contenedor, {duration:this.duracion , steps:this.pasos});
            this.gal.stop();
        }
        else
        {
            this.gal= new Fx.Move(id_contenedor, {duration:this.duracion , steps:this.pasos});
        }

    },
    mueve_atras: function(quien)
    {
        if( !this.gal.timer)
        {
            if(quien==1)
                {
                    if(this.state==1)
                    {
                        $clear(this.autofunc);
                        this.state=0;
                    }
                }

            if(this.indice<this.elementos-1)
            {

                this.indice++;
                if(this.type_gal==1)
                {
                    this.gal.goTo(this.indice);
                }
                else
                {
                    this.gal.start(this.posy,this.resta_textos*this.indice);
                }
                if(this.id_textos!="")
                {

                    document.getElementById(this.id_textos).innerHTML=this.array_text[this.indice];
                }

            }
            else
            {
                this.indice=0;
                if(this.type_gal==1)
                {
                    this.gal.goTo(this.indice);
                }
                else
                {
                    this.gal.start(this.posy,this.resta_textos*this.indice);
                }
                if(this.id_textos!="")
                {

                    document.getElementById(this.id_textos).innerHTML=this.array_text[this.indice];


                }

            }
        }
    },
    mueve_adelante: function(quien)
    {
        if($defined(this.gal))
        {
            if( !this.gal.timer)
            {
                if(quien==1)
                {
                    if(this.state==1)
                    {
                        $clear(this.autofunc);
                        this.state=0;
                    }
                }


                if(this.indice>0)
                {
                    this.indice--;
                    if(this.type_gal==1)
                    {
                        this.gal.goTo(this.indice);
                    }
                    else
                    {
                        this.gal.start(this.posy,this.resta_textos*this.indice);
                    }
                    if(this.id_textos!="")
                    {

                        document.getElementById(this.id_textos).innerHTML=this.array_text[this.indice];
                    }
                }
                else
                {
                    this.indice=this.elementos-1;
                     if(this.type_gal==1)
                    {
                        this.gal.goTo(this.indice);
                    }
                    else
                    {
                        this.gal.start(this.posy,this.resta_textos*this.indice);
                    }
                    if(this.id_textos!="")
                    {
                        document.getElementById(this.id_textos).innerHTML=this.array_text[this.indice];
                    }
                }
            }
        }
    },
    pause_o_play: function()
    {

        if(this.state==1)
        {
            $clear(this.autofunc);
            this.state=0;
        }
        else
        {
           this. mueve_atras();
           this.autofunc=this.mueve_atras.periodical((this.duracion + this.pasos),this);
           this.state=1;
        }
    }




    //annoy:  (function(){ console.log('Are we there yet?'); }).periodical(5000)

  //   this.ciclo_au=setInterval("ciclo_automatico("+this.indice+")", (this.duracion+this.pasos));
  }

)
