/**
 * Muestra la fecha en la cabecera de las páginas
 */
function date(){
	var months = new Array();
	months[0] = "Enero";
	months[1] = "Febrero";
	months[2] = "Marzo";
	months[3] = "Abril";
	months[4] = "Mayo";
	months[5] = "Junio";
	months[6] = "Julio";
	months[7] = "Agosto";
	months[8] = "Septiembre";
	months[9] = "Octubre";
	months[10] = "Noviembre";
	months[11] = "Diciembre";
	
	var days = new Array();
	days[1] = "Lunes";
	days[2] = "Martes";
	days[3] = "Miércoles";
	days[4] = "Jueves";
	days[5] = "Viernes";
	days[6] = "Sábado";
	days[0] = "Domingo";
	
	var current_date = new Date();
	var current_day = current_date.getDate();
	var current_month = current_date.getMonth();
	var current_year = current_date.getFullYear();
	var current_dayWeek = current_date.getDay();
	document.write(days[current_dayWeek] + ", " + current_day + " de " + months[current_month] + " de " + current_year);
}/**
 * Herramientas de la web, pinta y hace la lógica de aumentar y disminuir el texto
 * 
 * @author Luis gil
 * @date 01-2009
 */
var Herramientas = new Class({

	/**
	 * Estilo actual (viene configurado con el "por defecto")
	 *
	 * @protected
	 * @sa styles
	 */
	actualSize : 1,

	/**
	 * Estilos a usar. El primero es 0, el segundo 1, etc.
	 *
	 * @protected
	 */
	styles : [
		{'font-size' : '125%', 'line-height' : '100%'},
		{'font-size' : '125%', 'line-height' : '100%'},
		{'font-size' : '125%', 'line-height' : '100%'},
		{'font-size' : '125%', 'line-height' : '100%'}
	],

	/**
	 * Constructor :: Inicializa la clase
	 *
	 * @public
	 */
	initialize : function(){
		window.addEvent('domready', this.init.bindWithEvent(this));
	},

	/**
	 * Inicialización de todos los elementos en domready
	 *
	 * @public
	 */
	init : function(e) {
		this.resizePageFromStyles();
		this.createButtons();	
		this.imprimir();
	},

	/**
	 * Cambia el tamaño de la página según los estilos indicados en la
	 * cookie
	 *
	 * @public
	 */
	resizePageFromStyles : function() {
		var style = this.readCookie('style');
		if(!style || !style.match(/^\d+$/)) {
			style = null;
		}
		this._setSize(style);
	},

	/**
	 * Aplica un tamaño a la página mediante css
	 *
	 * Si no se indica un tamaño, se establece el de por defecto
	 *
	 * @public
	 */
	setPageSize : function() {
		$$('body')[0].setStyles(this.styles[this.actualSize]);
	},

	/**
	 * Aumenta tamaño de la página cambiando al siguiente estilo
	 *
	 * @public
	 */
	setBiggerStyle : function() {
		this._setSize(this.actualSize + 1);
	},

	/**
	 * Reduce tamaño de la página cambiando al estilo anterior
	 *
	 * @public
	 */
	setSmallerStyle : function() {
		this._setSize(this.actualSize - 1);
	},

	/**
	 * Realiza la acción de cambiar el tamaño y actualiza la cookie
	 *
	 * @param size int índice del tamaño a usar según styles
	 * @protected
	 */
	_setSize : function(size) {
		if(size != null) {
			if(size >= this.styles.length) {
				this.actualSize = this.styles.length - 1;
			}
			else if(size < 0) {
				this.actualSize = 0;
			}
			else {
				this.actualSize = size;
			}
		}

		this.writeCookie('style', this.actualSize);
		this.setPageSize();
	},
	
	/**
	 * Añadimos la funcionalidad al boton de imprimirPagina
	 *
	 * @public
	 */
	imprimir : function () {
		$$('.imprimirPagina').each(function(el) {
			el.addEvent('click', function(e){
				new Event(e).stop();
				window.print();
			});
		}, this);
	},
	
	/**
	 * Crea los botones de aumentar y disminuir el texto
	 * 
	 * Nota: se insertan en el div .imprimir
	 */
	createButtons : function() {
		$$('.Imprimir').each(function(el) {
			var t = new Element('span', {
				'html': 'imprimir '
			}).injectInside(el);

			new Element('img', {
				'src' : frontGlob['rel_path'] + '/common/imgs/ico.impresora.gif',
				'alt' : 'Imprimir'
			}).injectInside(
				new Element('a', {
					'href' : '#',
					'rel' : 'nofollow',
					'class' : 'imprimirPagina',
					'title' : 'imprimir esta página'
				}).injectInside(el)
			);

			new Element('span', {
				'html': '<span>|</span>tamaño'
			}).injectInside(el);

			new Element('img', {
				'src' : frontGlob['rel_path'] + '/common/imgs/ico.disminuirTexto.gif',
				'alt' : 'Disminuir Texto'
			}).injectInside(
				new Element('a', {
					'href' : '#',
					'rel' : 'nofollow',
					'class' : 'link_disminuye'
				}).addEvent('click', this.setSmallerStyle.bindWithEvent(this)).injectInside(el)
			);

			new Element('img', {
				'src' : frontGlob['rel_path'] + '/common/imgs/ico.aumentarTexto.gif',
				'alt' : 'Aumentar Texto'
			}).injectInside(
				new Element('a', {
					'href' : '#',
					'rel' : 'nofollow',
					'class' : 'link_aumenta'
				}).addEvent('click', this.setBiggerStyle.bindWithEvent(this)).injectInside(el)
			);
		}, this);
	},

	/**
	 * Crea una cookie
	 * 
	 * @param {Object} name
	 * @param {Object} value
	 * @param {Object} days
	 */
	writeCookie : function(name, value) {
		Cookie.write(name, value, {
			'path' : frontGlob['rel_path'],
			'duration' : 365
		});
	},
	
	/**
	 * Lee una cookie
	 * 
	 * @param {Object} name
	 */
	readCookie : function(name){
		return (Cookie.read(name) || null);
	}
});

var herramientas = new Herramientas();
function addTextSearchBox() {
	if($('buscar-texto')) {
		$('buscar-texto').addEvent('blur', blurSearchBox.bindWithEvent($('buscar-texto')));
		$('buscar-texto').addEvent('focus', focusSearchBox.bindWithEvent($('buscar-texto')));
	}
	
	if($('InputBuscador')) {
		$('InputBuscador').addEvent('blur', blurSearchBox404.bindWithEvent($('InputBuscador')));
		$('InputBuscador').addEvent('focus', focusSearchBox404.bindWithEvent($('InputBuscador')));
	}
	
	if($('buscar-texto-clasificados')) {
		$('buscar-texto-clasificados').addEvent('blur', blurSearchBox.bindWithEvent($('buscar-texto-clasificados')));
		$('buscar-texto-clasificados').addEvent('focus', focusSearchBox.bindWithEvent($('buscar-texto-clasificados')));
	}

	if($('buscar-texto-avanzado')) {
		$('buscar-texto-avanzado').addEvent('blur', blurSearchBoxAv.bindWithEvent($('buscar-texto-avanzado')));
		$('buscar-texto-avanzado').addEvent('focus', focusSearchBoxAv.bindWithEvent($('buscar-texto-avanzado')));
	}
	
	if($('frmTextoLocalidad')) {
		$('frmTextoLocalidad').addEvent('blur', blurSearchBox2.bindWithEvent($('frmTextoLocalidad')));
		$('frmTextoLocalidad').addEvent('focus', focusSearchBox2.bindWithEvent($('frmTextoLocalidad')));
	}
}

function blurSearchBox(e) {
	var e = new Event(e);
	if(this.value == '')
		this.value = frontGlob['textobuscar'];
	
}

function focusSearchBox(e) {
	var e = new Event(e);
	if(this.value == frontGlob['textobuscar'])
		this.value = '';
	else
		this.select();
}

function blurSearchBoxAv(e) {
	var e = new Event(e);
	if(this.value == '')
		this.value = frontGlob['textobuscar'];
	
}

function focusSearchBoxAv(e) {
	var e = new Event(e);
	if(this.value == frontGlob['textobuscar'] || this.value == 'todo el site')
		this.value = '';
	else
		this.select();
}

function blurSearchBox2(e) {
	var e = new Event(e);
	if(this.value == '')
		this.value = 'todo el site';
	
}

function focusSearchBox2(e) {
	var e = new Event(e);
	if(this.value == 'todo el site')
		this.value = '';
}

function blurSearchBox404(e) {
	var e = new Event(e);
	if(this.value == '')
		this.value = 'introduce texto';
	
}

function focusSearchBox404(e) {
	var e = new Event(e);
	if(this.value == 'introduce texto')
		this.value = '';
	else
		this.select();
}

window.addEvent('domready', addTextSearchBox);/**
 * Clase para la llamda de twitter
 *
 * @author Luis gil
 * @date 2009-03
 */
var loginWeb = new Class({
    
    /**
     * Constructor de la clase
     */
    initialize: function(){
    
        if($('FormularioRegistro')) {
            this.divFormularioRegistro = $('FormularioRegistro');
        }
        else {
            this.divFormularioRegistro = $('frmAcceso');
        }
    
        if($('CondicionesUso')) {
            this.divCondicionesUso = $('CondicionesUso');
        }
    	
        if($('frmAcceso')) {
            this.divFrmAcceso = $('frmAcceso');
        }
        if($('Login')) {
            this.divLogin = $('Login');
        }
        if($('DatosUsuario')) {
            this.divDatosUsuario = $('DatosUsuario');
        }
        if($('cargandoDatos')) {
            this.divCargandoDatos = $('cargandoDatos');
        }
        if($('referrer')) {
            this.referrer = $('referrer');
        }
        if($('botonLogin')){
            $('botonLogin').getElement('span').addEvent('click',(function(){
                this.divCargandoDatos.removeClass('Accesorio');
            }).bind(this));
        }
        if($('errorContainer')){
            this.errorContainerOnExtLogin = $('errorContainer');
        }

        // read the cookie
        this.readCookie('login');
    	    	
        // check the cookie

        if(this.cookieLogin != null && typeof(this.cookieLogin)!="undefined" ){ // logueado
            var c = this.splitCookie();
            this.showNew();
            this.changeButtons(c[0], c[1], c[2]);
            this.hideFormularioAcceso();
    		
        }
        else { // deslogueado
            //if (typeof(loginRequired) == 'undefined' || (typeof(loginRequired) != 'undefined' && loginRequired == '1')){
            this.hideNew();
        //}
        //else{
    			
        //	this.showNew();
        //	this.hideFormularioAcceso();
        //}
    		
        }

    	
        // añadimos evento al form
        this.addEventSubmit();
    	
        // añadimos evento al input de correo electrónico form
        this.addEventInputCorreoElectronico();
    },
    
    addEventInputCorreoElectronico : function () {
        if($('frmusuario3')) {
            $('frmusuario3').addEvent('click', this.cleanData.bindWithEvent(this));
        }
    },
    
    cleanData : function (e) {
        new Event(e).stop();
        $('frmusuario3').value = '';
    },
    
    
    /**
     * Añadimos el evento al submit
     */
    addEventSubmit : function() {
        if($('frmsubmit')) {
            
            $('frmsubmit').addEvent('click', this.fillVars.bindWithEvent(this));
        }
    },
    
    /**
     * Recogemos las variables del formulario
     */
    fillVars : function(e) {
        new Event(e).stop();
    	
        this.user = $('frmusuario3');
        this.password = $('frmcontrasena3');
        this.remenberPassword = $('frmrecordarproxima');
    	
        this.requestLogin();
    },
    
    /**
     * Crea la primera petición con la votación actual del contenido
     */
    requestLogin: function(){                
        new Request({
            'url': frontGlob['rel_path'] + '/index.php/services/loginWeb',
            'method': 'post'
        }).addEvent('success', this.handleRequestLogin.bindWithEvent(this)).send('user=' + this.user.get('value') + '&password=' + this.password.get('value') + '&remenber=' + this.remenberPassword.get('checked') + '&referrer=' + this.referrer.get('value'));
    },
    
    /**
     * Recoge los valores de la respuesta Ajax y llama a render
     *
     * @param {Object} text
     * @param {Object} xml
     */
    handleRequestLogin: function(text, xml){
        var referrer = xml.getElementsByTagName('referrer');
    	
        if (referrer[0].firstChild != null) {
            referrer = referrer[0].firstChild.nodeValue;
            window.location = referrer;
        }
        else {
            referrer = '';
        }
        var status = xml.getElementsByTagName('status');
        if (status != null) {
            status = status[0].firstChild.nodeValue;
        }
        else {
            status = '';
        }
	    
        var msg = xml.getElementsByTagName('msg');
        if (msg[0].firstChild != null) {
            msg = msg[0].firstChild.nodeValue;
        }
        else {
            msg = '';
        }
	    
        var idUser = xml.getElementsByTagName('idUser');
        if (idUser[0].firstChild != null) {
            idUser = idUser[0].firstChild.nodeValue;
        }
        else {
            idUser = '';
        }
	    		
        var user = xml.getElementsByTagName('user');
        if (user[0].firstChild != null) {
            user = user[0].firstChild.nodeValue;
        }
        else {
            user = '';
        }
	    
        var email = xml.getElementsByTagName('email');
        if (email[0].firstChild != null) {
            email = email[0].firstChild.nodeValue;
        }
        else {
            email = '';
        }
	    
        var cookieDuration = xml.getElementsByTagName('cookieDuration');
        if (cookieDuration[0].firstChild != null) {
            cookieDuration = cookieDuration[0].firstChild.nodeValue;
        }
        else {
            cookieDuration = '';
        }
	    
        var sections = xml.getElementsByTagName('sections');
        if (sections[0].firstChild != null) {
            sections = sections[0].firstChild.nodeValue;
            if(sections == 0) {
                sections = '';
            }
        }
        this.renderLogin(status, msg, idUser, user, email, cookieDuration, sections);
    },
    
    /**
     * Muestra mensaje ok/Nok y creamos cookie
     *
     * @param status string
     * @param msg string
     * @param idUser int
     * @param user string
     * @param email string
     */
    renderLogin : function(status, msg, idUser, user, email, cookieDuration, sections) {
        if(status == 'ok') {
    		
            if(sections == 0) {
                sections = '';
            }
    	    		
            this.createCookie('login', idUser + '|' + user + '|' + email + '|' + cookieDuration, cookieDuration, sections);
    		
            this.showMsg(msg, 'Aviso');
    		
            this.showNew();
    		
            this.changeButtons(idUser, user, email);
    		
            this.hideFormularioAcceso();
    		
            if(this.user) {
                this.user.setProperty('class', '');
                this.password.setProperty('class', '');
            }
        }
        else {
            
            this.showMsg(msg, 'Error');            
            this.deleteCookie('login');
            this.user.setProperty('class', 'Incompleto');            
            this.password.setProperty('class', 'Incompleto');
            this.hideNew();
        }
    },
    
    /**
     * Deslogueo en la aplicacion
     */
    logOut : function(e, idUser) {
        new Event(e).stop();
        this.divCargandoDatos.setProperty('class','');
        //Buscamos la capa donde están los enlaces en caso de estar en el foro
        $$('.linklist').each(function(el){
            if(el.get('class')=='linklist leftside'){
                el.dispose();
            }
        });
        new Request.XML({
            'url': frontGlob['rel_path'] + '/index.php/services/loginWeb',
            'method': 'post'
        }).addEvent('success', this.asyncHideNew.bindWithEvent(this)).send('action=' + 'logout' + '&idUser=' + idUser);

    },


    asyncHideNew:  function() {
        this.deleteCookie('login');
        //this.hideNew();
        window.location.reload();
        //this.changeButtons();

        //if(this.divCondicionesUso) {
        //	this.hideUseConditions();
        //}
        this.hideMsg();
		
    },


    /**
     * Mostramos un aviso al usuario
     */
    showMsg : function (msg, classCss) {    	
        this.hideMsg();        
        if(location['pathname'].contains('loginUser') || location['pathname'].contains('loginExt') || classCss == 'Error') {
            if(location['pathname'].contains('loginExt')){
                var contenedor = this.errorContainerOnExtLogin;
            }
            else{
                var contenedor = this.divFormularioRegistro;
            }
            
            if (classCss == 'Error'){                
                if (!($$('.Error').length)){                    
                    new Element('p').set('html', msg).injectInside(new Element('div').set('class', classCss).injectBefore(contenedor));
                }else{
                    $$('div.Error')[0].setStyle('display','');
                    $$('.Error').getElement('p').set('html',msg);
                }
            }
            else{
                
                new Element('p').set('html', msg).injectInside(new Element('div').set('class', classCss).injectBefore(contenedor));
            }
        }
    },
    
    /**
     * Ocultamos un aviso al usuario
     */
    hideMsg : function () {
        if($$('div.Error')[0]) {
            $$('div.Error')[0].setStyle('display', 'none');
        }
        if($$('div.Aviso')[0]) {
            $$('div.Aviso')[0].setStyle('display', 'none');
        }
    },
    
    /**
     * Mostramos la noticia
     */
    showNew : function() {	
        if(this.checkSection() == true) {
            if(this.divCondicionesUso) {
                this.hideUseConditions();
            }
  			
            this.changeClass(null);
	    	
            if(this.divFormularioRegistro) {
                this.divFormularioRegistro.setProperty('class', 'Formulario Accesorio');
            }
        }
    },
    
    /**
     * Ocultamos la noticia
     */
    hideNew : function() {
        this.changeClass('Accesorio');
    	
        this.showForm();
        this.showFormularioAcceso();
    },
    
    /**
     * Cambiamos el class de los elementos de la noticia
     */
    changeClass : function(classOcultar) {
        var moreClass = '';
        if(classOcultar != null) {
            moreClass = ' ' + classOcultar;
        }
    
        $each($$('.Herramientas'), function(el) {
            el.setProperty('class', 'Herramientas' + moreClass);
        });
   			
        $each($$('.Comments'), function(el) {
            el.setProperty('class', 'Comentarios' + moreClass);
        });
   			
	    	
        $each($$('.Texto'), function(el) {
            el.setProperty('class', 'Texto' + moreClass);
        });
	    	
        $each($$('.FotoGaleria'), function(el) {
            el.setProperty('class', 'FotoGaleria' + moreClass);
        });
    },
    
    /**
     * Chequeamos las secciones que tienen proteccion de lectura
     */
    checkSection : function () {
        var retorno = true;
        var RegExPattern = /\/\d{4}\/\d{2}\/\d{2}/;
        if(typeof(seccionProtegida) != 'undefined' && seccionProtegida != '') {
            if(!seccionProtegida.match(RegExPattern)) {
                var pathSection = seccionProtegida;
            }
            else {
                var replaceUrl = seccionProtegida.replace(RegExPattern, '#');
                var splitUrl = replaceUrl.split('#');
                var pathSection = splitUrl[1];
            }
            if(location['pathname'].match(pathSection)) {
                if(!this.in_array(pathSection, this.splitCookieSections())) {
                    this.showUseConditions(pathSection);
                    var retorno = false;
                }
            }
        }
        return retorno;
    },
    
    /**
     * Cambiamos los botones de cabecera
     */
    changeButtons : function(idUser, user, email) {

        /*	if(this.cookieLogin != null){
    		if ($$('.Login span')[0]){
    			$$('.Login span')[0].set('html', '<strong>Hola ' + user + '</strong> [');
    		
	    		$('botonLogin').removeEvents(); // limpio los eventos del boton para que no se dupliquen
	    		$('botonLogin').set('html', 'Salir').addEvent('click', this.logOut.bindWithEvent(this, idUser));
	    		if ($('alogOut')){
	    			$('alogOut').addEvent('click', this.logOut.bindWithEvent(this, idUser));
	    		}
	    		
	    		// si tiene un rel lightbox lo quitamos para el logout
	    		if($('botonLogin').get('rel') != '') {
	    			$('botonLogin').set('rel', '');	
	    		}
	    		
	    		
	    		$('registro').set({
	    			'html' : 'cambiar preferencias',
	    			'href' : frontGlob['rel_path'] + '/index.php/services/registro/'
	    		});
    		}
    	}
    	else {
    		if ($$('.Login span')[0]){
    			$$('.Login span')[0].set('html', '[');
	    		$('botonLogin').set('html', 'Entrar');
	    		if($('botonLogin').get('rel') == '' || $('botonLogin').get('rel') == null || !$('botonLogin').get('rel')) {
	    			$('botonLogin').set('rel', 'lightbox[login 300 350]');	
	    			Mediabox.scanPage();
	    		}
	    		$('registro').set('html', 'registrate');
    		}
    	}*/
        if ($('cambioPreferencias')){
            $('cambioPreferencias').set('text', user);
        }
        if ($('botonLogOut')){
            $('botonLogOut').set('html', 'Salir').addEvent('click', this.logOut.bindWithEvent(this, idUser));
        }
    },
    
    /**
     * Muestra los formularios
     */
    showForm : function() {
        if(this.divFormularioRegistro) {
            this.divFormularioRegistro.setProperty('class', this.divFormularioRegistro.getProperty('class') + ' Formulario');
        }
    },
    
    /**
     * Esconde los formularios
     */
    hideForm : function() {
        if(this.divFormularioRegistro) {
            this.divFormularioRegistro.setProperty('class', 'Formulario Accesorio');
        }
    },
    
    /**
     * Muestra el formulario de acceso
     */
    showFormularioAcceso : function() {    	
        if(this.divFrmAcceso) {
            this.divFrmAcceso.setProperty('class', this.divFrmAcceso.getProperty('class') + ' FormularioComun');
        }
        if (this.divLogin && this.divDatosUsuario && this.divCargandoDatos){
            this.divCargandoDatos.setProperty('class','Accesorio');
            this.divLogin.setProperty('class', 'Login');
            this.divDatosUsuario.setProperty('class', 'Login Accesorio');
        }
    },
    
    /**
     * Esconde el formulario de acceso
     */
    hideFormularioAcceso : function() {    	
        if(this.divFrmAcceso) {
            this.divFrmAcceso.setProperty('class', 'FormularioComun Accesorio');

        }
        if (this.divLogin && this.divDatosUsuario && this.divCargandoDatos){
            this.divCargandoDatos.setProperty('class','Accesorio');
            this.divLogin.setProperty('class', 'Login Accesorio');
            this.divDatosUsuario.setProperty('class', 'Login');
        }

    },
    
    /**
     * Mostramos el formulario de las condiciones de uso
     */
    showUseConditions : function(section) {
    	
        this.divCondicionesUso.set('class', 'Formulario');
    	    	
        if($('frmContinuar')) {
            $('frmContinuar').removeEvents();
            $('frmContinuar').addEvent('click', this.setConditions.bindWithEvent(this, section));
        }
    	
        this.hideMsg();
        this.hideFormularioAcceso();
        this.hideForm();
    },
    
    /**
     * Oculta el formulario de las condiciones de uso
     */
    hideUseConditions : function() {
        if(this.divCondicionesUso) {
            this.divCondicionesUso.setProperty('class', 'FormularioComun Accesorio');
        }
    },
    
    /**
     * Establece las secciones permitidas
     */
    setConditions : function(e, section) {
        if($('frmaceptocondiciones').get('checked') == true){
    		    		
            // añadir seccion a la cookie
            this.addSectionToCookie(section);
    		
            // ajax para guardarlo en el perfil de openNus
            new Request.XML({
                'url': frontGlob['rel_path'] + '/index.php/services/loginWeb',
                'method': 'post'
            }).send('action=' + 'addSection' + '&section=' + section);
    		
            this.showNew();
        }
        else {
            this.showMsg('Tiene que aceptar las condiciones de uso', 'Error');
        }
    },
    
    /**
	 * Crea una cookie
	 * 
	 * @param {Object} name
	 * @param {Object} value
	 * @param {Object} days
	 */
    createCookie : function(name, value, cookieDuration, section){
		
        // si viene seccion la añadimos
        if(typeof(section) != 'undefined' && section != '') {
            if(this.cookieLogin != null && this.cookieLogin.contains('#')) {
                value += ';' + section;
            }
            else {
                value += '#' + section;
            }
        }
		
        var expires = '';
        if (cookieDuration == 'true') {
            expires = 30;
        }
		
        Cookie.write(name, value, {
            duration: expires,
            path: '/'
        });
        this.readCookie(name);
    },
	
    /**
     * Añade la seccion a la cookie
     */
    addSectionToCookie : function(section) {
        var c = this.splitCookie();
        this.createCookie('login', this.cookieLogin, c[3], section);
    },
	
    /**
	 * Lee una cookie
	 * 
	 * @param {Object} name
	 */
    readCookie : function(name){
        this.cookieLogin = Cookie.read(name);
    },
	
    /**
	 * Borra una cookie
	 *
	 * @param {Object} name
	 */
    deleteCookie : function(name) {
        Cookie.write(name, this.cookieLogin, {
            duration: -1,
            path: '/'
        });
        this.readCookie(name);
    /*
		@TODO
		Cookie.dispose(name, this.cookieLogin);
		*/
    },
	
    /**
	 * Retorna la cookie en un array
	 */
    splitCookie : function() {
        if(this.cookieLogin.contains('#')) {
            var s = this.cookieLogin.split('#');
            return s[0].split('|');
        }
        else {
            return this.cookieLogin.split('|');
        }
    },
	
    /**
	 * Retorna las secciones del web que estan en la cookie como array
	 */
    splitCookieSections : function() {
        if(this.cookieLogin.contains('#')) {
            var s = this.cookieLogin.split('#');
            return s[1].split(';');
        }
        else {
            return this.cookieLogin.split(';');
        }
    },
	
    /**
	 * in_array
	 *
	 * http://www.bitrepository.com/equivalent-of-phps-in_array-function.html
	 */
    in_array : function (string, array) {
        for (i = 0; i < array.length; i++) {
            if(array[i] == string){
                return true;
            }
        }
        return false;
    },
	
    implode : function( glue, pieces ) {
        return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces );
    }
});

window.addEvent('domready', function() {
    new loginWeb();
});
/**
 * Tip Title para los rss
 *
 * @author Luis Gil
 * @date 2009-03
 */
window.addEvent('domready', function() {
	// nueva instancia a Tips
	var myTips = new Tips('.thisisatooltip', {
		'className' : 'Tip'
	});
	
	// borramos los nodos que no nos interesan
	myTips.tip.childNodes[2].destroy(); // div.tip-top
	myTips.tip.childNodes[0].destroy(); // div.tip-bottom
	
	// efecto fade al mostrar
	myTips.addEvent('show', function(tip){
    	tip.fade('in');
	});
	// efecto fade al ocultar
	myTips.addEvent('hide', function(tip){
    	tip.fade('out');
	});
	// establecemos el texto a mostrar
	// el titulo lo coge del "title" del enlace
	$$('.thisisatooltip').each(function(el) {
		if(el.getParent().getElement('.Accesorio')) {
			el.store('tip:text', el.getParent().getElement('.Accesorio').get('html'));
		}
	});
});

