/********************************************************************************/
/*                                                                              */
/* Plataforma HELVIA.  Version 6.06.04-33 - Junta de Andalucia - Espana         */
/* Distribucion de e-ducativa Open College                                      */
/* Copyleft @ 2007-2008 de IP Learning e-ducativa S.L.                          */
/*                                                                              */
/********************************************************************************/
/*
 * www.e-ducativa.com
 */

/**
* @class Element::Select
*
* @brief Se agregar metodos para el manejo de opciones
*
*/
Element.addMethods('select', {
    /** @method add_options( element  )
    *  Elimina todas las opciones de un select
    */
    clear : function(element){
            while (element.length> 0) {
                element.remove(0);
            }
        },
    /** @method add_options( element, list )
    *  Agrega opciones a un elemento select
    *  \param element SELECT
    *  \param list Array de objetos con las propiedades label y value
    */
    add_options : function(element, list){
        list.each(function(i){
            element.appendChild(new Element('option', {value : i.value}).update(i.label) );
        });
    },

    /* mueve los elementos seleccionados a otra lista */
    moveSelectedItemsTo : function(element,hasta) {
        element.select('option')
            .findAll(function(o){return ! o.disabled && o.selected})
            .invoke('remove')
            .each(function(e){ $(hasta).appendChild( e ) });
        element.sortItems();
    },
    /* ordena los elementos del select de forma ascendente */
    sortItems : function(element){
        element.select('option')
            .invoke('remove').sort(function(a,b){
                return a.innerHTML < b.innerHTML
                    ? -1 : a.innerHTML == b.innerHTML ? 0 : 1;
            })
            .each(function(e){ element.appendChild( e ) });
    },
    /* selecciona todos los elementos del select */
    selectAllItems : function(element) {
        if(! (element.multiple && element.multiple) ) return ;
        element.select('option').each(function(o){o.selected = true});
    }
});

/**
* @class Educativa
*
* @brief Framework e-ducativa
*/

var Educativa = new Object;

Educativa.Iterator = {
    isTrue  : function(e){ return   e },
    isFalse : function(e){ return ! e }
};


Educativa.Browser = new (function(){
	var t = this, d = document, w = window, na = navigator, ua = na.userAgent;

	// Browser checks
	t.isOpera = w.opera && opera.buildNumber;
	t.isWebKit = /WebKit/.test(ua);
	t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt;
	t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
	t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
	t.isGecko = !t.isWebKit && /Gecko/.test(ua);
	t.isMac = ua.indexOf('Mac') != -1;
	t.isAir = /adobeair/i.test(ua);
});

/**
* @class Educativa::Control
*
*/
Educativa.Control = Class.create({
    initialize : function(id){
       this.element = this.element || $(id);

       // indexo los controles para la funcion E() del prototype
       if (this.element) Educativa.Control.Objects[ id || this.element.identify() ] = this;
    },
    _listeners : {},
    observe : function(event, action){
        (this._listeners[event] = this._listeners[event] || []).push( action );
        return this;
    },
    fire : function( event, memo){
        (this._listeners[event] || []).invoke( 'bind', this ).each(function(e){ e(memo) }.bind(this));
        return this;
    }
});

Educativa.Control.Objects = {};

Element.addMethods( {
    E : function(element) {
        return Educativa.Control.Objects[element.id]
    },
    control : function(element){
        return Educativa.Control.Objects[element.id]
    }
} );

/**
* @class Educativa::Utils
*
*/
Educativa.Utils = {
  disable_input_file_keypress : function(){
    $$('input[type="file"]').invoke('observe','keydown',function(e){
        if ( e.keyCode != 9 ) Event.stop(e)
    });
  },
  quitar_html_tags : function(str){
    var letters = str.split('');
    var estado = ''; //posibles estados: ''|tag|string
    var quote = '';
    var new_str = '';
    for ( var j=0; j < letters.length; ++j){
        var c = letters[j];
        switch( estado ){
            case '':
                if( c == '<') estado = 'tag';
                else new_str += c;
                break;
            case 'tag':
                if( c.match(/[\'\"]/) ){ /* ' // para que no me rompa el ue */
                    estado = 'string';
                    quote = c;
                }
                if( c == '>' ) estado = '';
                break;
            case 'string':
                if( c == quote) estado = 'tag';
                break;
            default:
                alert("epa epa!");
                break;
        }

    }
    return new_str;
  },

  helpWin : null,
  closeWinHelp : function(){
	if (Educativa.Utils.helpWin != null && !Educativa.Utils.helpWin.closed)
		Educativa.Utils.helpWin.close();
  },

  popUpHelp : function(strURL) {
	Educativa.Utils.closeWinHelp();
	var strOptions = '';
	var strHeight  = screen.height - 100;
	var strWidth   = screen.width  - 100;
	var strOptions = 'scrollbars,resizable,status,height=' + strHeight + ',width=' + strWidth +
	 ',left=50,top=50';
	try {
		Educativa.Utils.helpWin = window.open(strURL, 'helpWin', strOptions);
		Educativa.Utils.helpWin.focus();
	} catch(e){}
  },

  disable_links : function(element){
    $(element).select('a')
        .each(function(e){ e.href = '#' } )
        .invoke('observe','click',function(e){ e.stop() });
  },
  uri_split : function(uri){
    var a = uri.match( /(?:([^:/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/ );
    return { scheme : a[1], authority : a[2], path : a[3], query : a[4], fragment : a[5] };
  },

  is_uri : function(value){
    if( ! value ) return false;
    if( value.match(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i ) ) return false;
    if( value.match(/%[^0-9a-f]/i ) ) return false;
    if( value.match(/%[0-9a-f](:?[^0-9a-f]|$)/i ) ) return false;

    // from RFC 3986
    var uri = Educativa.Utils.uri_split( value );

    if( ! uri.authority ) return false;
    // scheme and path are required, though the path can be empty
	if ( !(uri.scheme != null && uri.scheme.length && uri.path != null) ) return false;

    // if authority is present, the path must be empty or begin with a /
	if(uri.authority != null  && uri.authority.length )
	{

		if( !( uri.path.length == 0 || uri.path.match(/^\//) ) ) return false;
	}
	else
	{   // if authority is not present, the path must not start with //
		if ( uri.path.match('^//') ) return false;
	}

	// scheme must begin with a letter, then consist of letters, digits, +, ., or -
	if (! uri.scheme.toLowerCase().match('^[a-z][a-z0-9\+\-\.]*$') ) return false;

    return true;
  },
  cleanCommentOnPasteFromWord : function (str)
  {
    var results = '';
    str = str.replace(/endif\]--> &lt;!--/ig, '[endif]--> <!--')
             .replace(/--&gt; <!--\[if/ig, '--> <!--[if' );

    HTMLParser( str , {
      start: function( tag, attrs, unary )
      {
        results += "<" + tag;
        for ( var i = 0; i < attrs.length; i++ )
          results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
        results += (unary ? "/" : "") + ">";
      },
      end: function( tag )
      {
        results += "</" + tag + ">";
      },
      chars: function( text )
      {
        results += text;
      },
      comment: function( text ) {}
    });

    return results;
  },
  addWmodeToFlashObjects: function( html_content, ed ){
  	  return html_content;

      var obj = new Element('div').update( html_content );
      var objects = obj.select('object');
      objects.each( function(e){
          if( e.readAttribute('classid') != 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
              return;
          }
          e.writeAttribute('wmode','transparent')
          //console.debug(e.nodeName);
          var wmode_present = false;
          e.childElements().each(function(c){

              if(     c.nodeName.toUpperCase() == 'PARAM'
                  && (c.readAttribute('name').toUpperCase() == 'wmode'.toUpperCase())
              ){
                  if(c.readAttribute('value') != 'transparent'){
                      c.writeAttribute('value','transparent')
                  }
                  wmode_present = true;
              }else if( c.nodeName.toUpperCase() == 'EMBED' ){
                  c.writeAttribute('wmode','transparent')
              }
              //console.debug("child: " +c.nodeName);
          });

          if( !wmode_present){
              e.insert( new Element('param',{ name : 'wmode',value:'transparent'}) );
          }
          //console.debug(obj.innerHTML);
      });

      return ed.serializer.serialize(obj);
  }

};

/**
* @class Educativa::Debug
*
*/
Educativa.Debug = {
  clear : function(o){
	    if ($('DivDebug')) $('DivDebug').innerHTML='';
    },
  show : function(o){
	var d;
	if (!$('DivDebug')){
		d = document.createElement('pre');
		d.id = 'DivDebug';
		d.style.position = 'fixed'
	    d.style.left     = '10px';
		d.style.bottom   = '0';
		d.style.width    = '92%';
		d.style.height   = '200px';
    	d.style.overflow = 'auto';

    	d.style.fontSize = '11px';

		d.style.color    ='#FFFFFF';
		d.style.zIndex   ='1000';
		d.style.backgroundColor='pink';
		d.style.borderWidth='2px';
		d.style.borderColor ='black';
		d.style.borderStyle ='solid';
		d.ondblclick = function(){
			Element.hide(this);
		}
		document.body.style.paddingBottom = '200px';
		document.body.appendChild(d);
	} else {
		d = $('DivDebug');
	}
	d.show();
	var str="";

	if ( typeof o == 'string')
	    str = o;
	else for(i in o)
		    str += "\t" + i + " => " + o[i] + "\n";

	d.innerHTML +=  "\n" + str;
  }
};


/**
* @class Educativa::Session
*
*/
Educativa.Session = {} ;

Educativa.uft8 = 0;


// diccionarios


Educativa.Dict     = {
    translate : function(t){

        return Educativa.Dict[t] ? Educativa.Dict[t] : '*' + t + '*';
    }
};
Educativa.Glosario = {};




if ( $('AyudaContextual')) Event.observe(window, 'load', function(){
	Event.observe(window, 'keypress', function(event) {
		if (event.charCode == 104) {
			Educativa.Utils.popUpHelp( $('AyudaContextual').href );
		}
	});

	$('AyudaContextual').onclick = function(){
		Educativa.Utils.popUpHelp( $('AyudaContextual').href );
		return false;
	}

});

/* Educativa.Alert
 */
Educativa.Alert = Class.create();
Educativa.Alert.prototype = {
    initialize : function(text, type, options){
        var options = {
            type : 'info',
            text : ''
        };
        if ( typeof( text ) == 'object' )
            Object.extend( options, text );
        else {
            if ( type ) options.type = type;
            if ( text ) options.text = text;
        }

        this.options = options;

        this.element = $( $('alertas').appendChild( document.createElement( 'div' ) ) );
        this.element.addClassName( 'alert ' + this.options.type );
        this.element.innerHTML = this.options.text;

    }
};

/* Educativa.Popup
 */
Educativa.Popup = Class.create({
    closed: function(){
        return this.window.closed;
    },
    initialize : function(options) {
        this.options = {
          url       : 'about:blank',
          width     : 600,
          height    : 500,
          name      : '_blank',
          location  : false,
          menubar   : false,
          toolbar   : false,
          status    : true,
          scrollbars: true,
          resizable : true,
          left      : 0,
          top       : 0,
          depend    : false,
          normal    : false,
          center    : true
        };

        Object.extend(this.options, options || {});

        if ( Educativa.id_grupo ) this.options.name += Educativa.id_grupo;

        if ( this.options.depend )
            Event.observe( window, 'unload', this.close.bind(this) )


        if (this.options.normal){
            this.options.menubar  = true;
            this.options.status   = true;
            this.options.toolbar  = true;
            this.options.location = true;
        }

        this.options.width
            = this.options.width < screen.availWidth
            ? this.options.width
            : screen.availWidth;

        this.options.height
            = this.options.height < screen.availHeight
            ? this.options.height
            : screen.availHeight;

        if ( this.options.center ){
            this.options.top  = (screen.availHeight - this.options.height + 1) / 2;
            this.options.left = (screen.availWidth  - this.options.width  + 1) / 2;
        }


        var openoptions =
            'width='       + this.options.width
          + ',height='     + this.options.height
          + ',location='   + (this.options.location   ? 'yes' : 'no')
          + ',menubar='    + (this.options.menubar    ? 'yes' : 'no')
          + ',toolbar='    + (this.options.toolbar    ? 'yes' : 'no')
          + ',scrollbars=' + (this.options.scrollbars ? 'yes' : 'no')
          + ',resizable='  + (this.options.resizable  ? 'yes' : 'no')
          + ',status='     + this.options.status ;

        if ( this.options.top != "" ) openoptions += ",top=" + this.options.top;
        if ( this.options.left!= "" ) openoptions += ",left="+ this.options.left;


        Educativa.Popup.Objects[this.options.name] = this;



        this.window = window.open(this.options.url, this.options.name,openoptions );

    },
    reload : function( n ){
        ele = Educativa.Popup.get( n );
        setTimeout( function(){
            if ( this.window.closed && this.options.onClose )
                this.options.onClose();
            else if ( this.options.onReload )
                this.options.onReload();
        }.bind(ele), 1)
    },
    close : function(){

        if ( ! this.closed() )
            this.window.close();
    },
    focus : function(){
        this.window.focus();
        return this;
    }

});
Educativa.Popup.Objects = {};
Educativa.Popup.get = function(name){
    var r ;
    try {
        if ( ! Educativa.Popup.Objects[name].closed() )
            r = Educativa.Popup.Objects[name];
    } catch(e){}
    return r;
}
Educativa.Popup.open = function(opt){
    var name = opt.name;
    if ( Educativa.id_grupo ) name += Educativa.id_grupo;
    var w = Educativa.Popup.Objects[ name ];
    return  w && !w.closed()
        ? w.focus()
        : new Educativa.Popup( opt );
}

/* Educativa.Tooltip
 */
Educativa.Tooltips = [];
Educativa.Tooltip = Class.create({
    initialize : function(options){
        this.options = {
            trigger   : null,
            html      : '',
            canFixed  : false
        };

        Object.extend( this.options, options );

        this.trigger = $(this.options.trigger);
        this.html    = this.options.html;

        var tt = this.element = new Element('div');
        tt.className = 'tooltip';
        tt.update(this.options.html);

        $(document.body).appendChild( tt );

        this.trigger.observe('mouseover', this.show.bindAsEventListener(this) );
        this.trigger.observe('mouseout', this.hide.bindAsEventListener(this) );
        this.trigger.observe('click', this.click.bindAsEventListener(this) );

        Educativa.Tooltips.push( this );

    },

    show : function(e){
        var tt = this.element, bt = this.trigger;
        tt.makePositioned();
        Position.clone( bt, tt, {
            setWidth:0,
            setHeight: 0,
            offsetLeft: bt.getWidth() + 2
        });
        tt.setStyle({zIndex : 100});
	    bt.addClassName('tooltip-button-over');
	    if ( this.trigger.hasClassName('tooltip-fixed') ) return;
	    tt.show();
    },
    hide : function(e){
	    if ( this.trigger.hasClassName('tooltip-fixed') ) return ;
	    this.trigger.removeClassName('tooltip-button-over');
	    this.element.hide();
    },
    click : function(e){
        return;
        if ( ! this.options.canFixed ) return;
        this.trigger.toggleClassName('tooltip-fixed');
        this.fixed = this.trigger.hasClassName('tooltip-fixed');
        Element.toggleClassName(this.element, 'tooltip-fixed-tt');

        var l = this.trigger.ancestors().find(function(e){ return e.hasClassName('line') });

        if ( ! this.trigger.hasAttribute('line_height') )
            this.trigger.setAttribute('line_height', l.getHeight() );
        if ( this.trigger.hasClassName('tooltip-fixed') ){
            if ( l.getHeight() < this.element.getHeight() )
                l.setStyle({ height : this.element.getHeight() + 'px' });
        } else {
            l.setStyle({ height : this.trigger.getAttribute( 'line_height' ) + 'px' });
        }

        Educativa.Tooltips
            .findAll(function(e){ return e.fixed } )
            .invoke('show');
    }

});

/* Deshabilito los clicks derechos
 */
Educativa.disableRightClick = function (){
    $$('.noRightClick').each(function(e){ e.oncontextmenu=function(){return false} });
}
Educativa.agregar_glosario = function() {
    if (! $('marco_principal') ) return;
    var div = $('DivTerminoGlosarizado');
    if (!div){
        new Insertion.Before($('marco_principal'), '<div id="DivTerminoGlosarizado" style="display:none"></div>');
        div = $('DivTerminoGlosarizado');
        div.makePositioned();
    }
    var tmpl = new Template(
           '<h6>#{id}</h6><p>#{desc}</p><em>'
        +  Educativa.Dict['CLICK_SOBRE_EL_TERMINO_PARA_VISUALIZAR_EL_GLOSARIO_COMPLETO']
        + '</em>'
    );

    $$('.TerminoGlosarizado').each(function(o){

        o.observe('mouseover', function(e){
            o.makePositioned();
            var offset = Position.realOffset(o);
            Position.clone( o, div, {
                setWidth  : 0,
                setHeight : 0,
                offsetLeft: 20,
                offsetTop : 20
            } );

            div.innerHTML = Educativa.Glosario[o.name]
                ? tmpl.evaluate(Educativa.Glosario[o.name])
                : '';
            div.show();
        });
        o.onmouseout = function(){ div.hide(); }

        o.onclick    = function(){
            window.open('glosario.cgi?wIdCurso=' + Educativa.id_grupo,
                        'glosario',
						'width=350,height=450,scrollbars=yes');
            return false;
        }


    })
}
Event.observe(window, 'load', Educativa.disableRightClick );
Ajax.Responders.register({  onComplete: Educativa.disableRightClick });

Event.observe(window, 'load', Educativa.agregar_glosario );
Ajax.Responders.register({  onComplete: Educativa.agregar_glosario });

Ajax.Responders.register({
    onCreate: function(){ $('ajax_indicator').show() },
    onComplete: function(){ $('ajax_indicator').hide() }
});

if ( ! window.getSelection ){
    window.getSelection = function (){
        if (document.getSelection) {
            window.getSelection = document.getSelection;
        } else if (document.selection) {
            window.getSelection = function(){
                return document.selection.createRange().text;
            }
        } else {
            window.getSelection = function(){}
        }
        return window.getSelection();
    }
}


try{
if ( window.opener && window.name && window.opener.Educativa ){
    Event.observe( window, 'unload', function(){
        try{
            window.opener.Educativa.Popup.get( window.name ).reload(window.name);
        } catch(e){}
    });

}
} catch(e){}









popupWins = new Array();

if(!window.winHelp) winHelp = function( seccion )
{
    var windowX = (screen.width/2)-255;
    var windowY = (screen.availHeight/2)-220;
    popupWin = window.open (Educativa.url_ayuda,'ayuda',
                            'toolbar=no,location=no,directories=no,status=no,'+
                            'menubar=no,scrollbars=yes,resizable=0,width=510,height=440,'+
                            'top='+windowY+',screenY='+windowY+',left='+windowX+
                            ',screenX='+windowX);
    popupWin.focus();
};


if(! window.windowOpener) windowOpener = function ( url, name, args)
{
    if ( typeof( popupWins[name] ) != "object" ){
        popupWins[name] = window.open(url,name,args);
    } else {
        if (!popupWins[name].closed){
            popupWins[name].focus();
        } else {
            popupWins[name] = window.open(url, name,args);
        }
    }
    popupWins[name].focus();
};

if (! window.OpenWin ) OpenWin = function () {
    switch ( id_usuario ){
        case "":
            alert(Educativa.Dict.translate('PARA_UTILIZAR_EL_CHAT_PRIMERO_DEBES_INGRESAR_A_LA_INTRANET'));
            break;
        case "_anonimo":
            alert(Educativa.Dict.translate('ESTA_FUNCION_NO_ESTA_DISPONIBLE_PARA_USUARIOS_ANONIMOS'));
            break;
        default:
            if ( tipo_chat == "JAVA" ){
                var windowX = (screen.width/2)-320;
                var windowY = (screen.availHeight/2)-285;
                void windowOpener('location.cgi?wseccion=21',
                                  'Chat'+id_usuario+id_grupo,
                                  'toolbar=0,location=0,directories=0,status=0,'+
                                  'menubar=0,scrollbars=0,resizable=1,width=640,'+
                                  'height=570,top='+windowY+',screenY='+windowY+
                                  ',left='+windowX+',screenX='+windowX);
            }else{
                if ( tipo_chat == "FLASH" ) {
                    var windowX = (screen.width/2)-390;
                    var windowY = (screen.availHeight/2)-285;
                    void windowOpener('location.cgi?wseccion=21',
                                      'Chat'+id_usuario+id_grupo,
                                      'toolbar=0,location=0,directories=0,status=0,'+
                                      'menubar=0,scrollbars=0,resizable=0,width=780,'+
                                      'height=570,top='+windowY+',screenY='+windowY+
                                    ',left='+windowX+',screenX='+windowX);
                }else{
                    var windowX = (screen.width/2)-300;
                    var windowY = (screen.availHeight/2)-215;
                    void windowOpener(
                        'chat_html/chat.cgi?FA=Login&NombreLogin='+
                        nombre_completo+'&Login='+id_usuario+'&color=000000',
                        'Chat'+id_usuario+id_grupo,
                        'toolbar=0,location=0,directories=0,status=0,menubar=0,'+
                        'scrollbars=0,resizable=0,width=640,height=570,top='+windowY+
                        ',screenY='+windowY+',left='+windowX+',screenX='+windowX);
                }
            }
    }//end switch

}; //end OpenWin()

if (!window.MailTo) MailTo = function ( destino, asunto) {
    MailToScript = url_dir+"mensajeria.cgi?wIdDestino="+destino+"&wAsunto="+
                    asunto;
    mailWin = window.open(MailToScript,'mensajeria','toolbar=no,location=no,'+
                       'directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,'+
                       'width=480,height=380');
    mailWin.focus();
};

if(!window.MensajeInstantaneo) MensajeInstantaneo= function ( titulo, destino, asunto) {
    InstantaneaScript=url_dir+"nph-instantanea.cgi?wIdDestino="+destino+"&wAsunto="+asunto;
    if( confirm(titulo) ){ location.href = InstantaneaScript; }
};

//es pisada en evaluaciones, pero no cousa problemas...
if (! window.small_window ) small_window =function ( myurl, ventana_x, ventana_y) {
    var newWindow;
    var winl = (screen.width - ventana_x) / 2;
    var wint = (screen.height - ventana_y) / 2;
    var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,'+
                'directories=no,width='+ventana_x+',height='+ventana_y+
                ',top='+wint+',left='+winl;
    newWindow = window.open(myurl, "microsite", props);
    //newWindow.moveTo(150,200); // lo centre
    newWindow.focus();
};

if ( !window.support_flash ) support_flash = function (){
    var noautoinstall = "";

    if( (navigator.appName == "Microsoft Internet Explorer")
         && (navigator.appVersion.indexOf("Mac") != -1 )  ){
        noautoinstall = "true";
    }

    if( navigator.appName == "Microsoft Internet Explorer" && noautoinstall != "true"){
        return true;
    }else if( navigator.plugins ){
        if     ( navigator.plugins["Shockwave Flash"] )    { return true ;}
        else if( navigator.plugins["Shockwave Flash 2.0"] ){ return false;}
        else                                               { return false ;}
    }else{
        return false;
    }
};

//utilizado por el menu izquierdo, la funcion windowOpener esta disponible desde esta libreria y es la misma que usa el chat, mensajeria, etc.
if ( !window.OpenWebConference ) OpenWebConference = function  (){
    var windowX = (screen.width/2)-390;
    var windowY = (screen.availHeight/2)-293;
    void windowOpener('webconference.cgi','Webconference','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=780,height=570,top='+windowY+',screenY='+windowY+',left='+windowX+',screenX='+windowX);
};


// Agrega el color #CCC a los option desactivados, bug del IE
if ( Prototype.Browser.IE )
    Event.observe(window, 'load', function(){
        $$('select option').each(function(e){
            if(e.disabled) e.setStyle({color : "#CCC"});
        });
    });

Event.observe(window, 'load', function(){
    var a = $$('#boton-ayuda a').first();
    if (a) a.observe('click',function(event){
        var aula_front_end = a.href.toQueryParams().section;
        event.stop();
        Educativa.Popup.open({
            url       : a.href,
            width     : aula_front_end ? 510 : screen.width-100,
            height    : aula_front_end ? 440 : screen.height-100,
            name      : '_blank',
            status    : false,
            resizable : true,
            left      : (screen.width/2)-255,
            top       : (screen.availHeight/2) - 220,
            depend    : false,
            center    : ! aula_front_end
        });
    })
})

/** @fn $string  generar_id($lenght)
 *  genera un id correspondiente al mail que se esta enviando
 *  \param lenght  la longitud del id
 *  \return string con el id de lenght caracteres , undef en caso de error
 */
Educativa.Utils.generar_id = function(cant){
    var list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    return $R(1,cant).map(function(){
        return list.charAt( Math.floor(Math.random() * (list.length + 1)) );
    }).join('');

}



