
if(!window.EXTRAS) EXTRAS = {};

var cssLetra = 0;
var fer, ferc, isIE6;

var MV = {
	
	addPrinter : function() {
        var a = document.getElementById('printer');
        if (a) {
	        a.onclick = a.onkeypress = function (e) {
	            if (!e) e = window.event;
	            if(e.type == "keypress" && e.keyCode != 13) return false;
	            if(e.type == "click") this.blur();
	            window.print();
	            return false;
	        }
	    }
    },
	
	addStylesLetra : function() {
        var a = document.getElementById('cambio_tamano_letra');
        if (a) {
	        a.onclick = a.onkeypress = function (e) {
	            if (!e) e = window.event;
	            if(e.type == "keypress" && e.keyCode != 13) return false;
	            if(e.type == "click") this.blur();
	            var t = (++cssLetra)%3;
	            MV.setActiveStyleSheet("texto_"+t);
	            return false;
	        }
	    }
    },

	setActiveStyleSheet : function(title) {
		var i, a;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
				a.disabled = true;
				if(a.getAttribute("title") == title) a.disabled = false;
			}
		}
	},
	
	// gestiona el JS del bloque de login y recordar pass
	inicia_acceso : function() {

		// olvidé mi contraseña
		var a = document.getElementById('olvide_mi_contra');
		if (a) {
		    a.onclick = a.onkeypress = function (e) {
		        if (!e) e = window.event;
		        if(e.type == "keypress" && e.keyCode != 13) return false;
		        if(e.type == "click") this.blur();
		        var c = document.getElementById('formrecuerdap');
		        c.style.display = 'inline';
		        var b = document.getElementById('formlogin');
		        b.style.display = 'none';
		        this.style.display = 'none';
		        return false;
		    }
		}
	    
	    // login
		var o1  = document.getElementById('p_username');
		if (o1) {
		  if (o1.value==''){o1.value='Usuario';}
		  o1.onfocus=function () {   if (this.value=='Usuario') {this.value='';} }
		  o1.onblur=function () {    if (this.value=='') {this.value='Usuario';} }
		}
		var o2  = document.getElementById('p_password');
		if (o2) {
		  if (o2.value==''){o2.value='Contraseña';}
		  o2.onfocus=function () {   if (this.value=='Contraseña') {this.value='';} }
		  o2.onblur=function () {    if (this.value=='') {this.value='Contraseña';} }
		}
	    
	},
	
	
	inicia_forms : function() {
	
		if (document.getElementById('error_campo_form')) {
			fer = document.getElementById('error_campo_form');
			ferc = document.getElementById('error_campo_form_condiciones');
			isIE6 = (CSS.getStyle('error_campo_form','top') == '10px'); // truquillo
		}
	},
	
	check_form_partners : function() {
	
		var fpartners = document.getElementById('form_partners');
		if (fpartners) {
		
		    fpartners.onsubmit = function (e) {
		        if (!e) e = window.event;
		        var campos = Array;
				campos['nombre'] = 78;
				campos['email'] = isIE6 ? 143 : 138;
				campos['telefono'] = isIE6 ? 178 : 168;
				campos['comentarios'] = isIE6 ? 235 : 228;
		
		        for (var i in campos) {
			        if (fpartners[i].value=='' || (i=='email' && !fpartners[i].value.isEmail()) ) {
			        	fpartners[i].className = (fpartners[i].className.length==0) ? 'text_error' : fpartners[i].className + ' text_error';
			        	fpartners[i].focus();
			        	fer.style.display = 'block';
			        	fer.style.top = campos[i]+'px';
			        	return false;
					}
					else {
						fpartners[i].className = fpartners[i].className.replace('text_error','');
					}
				}
		
				fer.style.display = 'none';
				if (!fpartners['check_condiciones'].checked) {
					ferc.style.display = 'block';
		        	return false;
				}
				else 
				if (ferc.style.display == 'block') {
					ferc.style.display = 'none';
				}
		        return true;
		    }
		}
	
	},
	
	
	check_form_contacto : function() {
	
		var fcontacto = document.getElementById('form_contacto');
		if (fcontacto) {
		
		    fcontacto.onsubmit = function (e) {
		        if (!e) e = window.event;
		        var campos = Array;
		        var topInicio = 348;
				campos['nombre'] = topInicio;
				campos['email'] = isIE6 ? topInicio+65 : topInicio+60;
				campos['telefono'] = isIE6 ? topInicio+95 : topInicio+90;
				campos['comentarios'] = isIE6 ? topInicio+160 : topInicio+150;
		
		        for (var i in campos) {
			        if (fcontacto[i].value=='' || (i=='email' && !fcontacto[i].value.isEmail()) ) {
			        	fcontacto[i].className = fcontacto[i].className + ' text_error';
			        	fcontacto[i].focus();
			        	fer.style.display = 'block';
			        	fer.style.top = campos[i]+'px';
			        	fer.style.right = '75px';
			        	return false;
					}
					else {
						fcontacto[i].className = fcontacto[i].className.replace('text_error','');
					}
				}

				if (!fcontacto['check_condiciones'].checked) {
					ferc.style.display = 'block';
		        	ferc.style.left = '45px';
		        	ferc.style.top = isIE6 ? '772px' : '753px';
		        	return false;
				}
				else 
				if (ferc.style.display == 'block') {
					ferc.style.display = 'none';
				}

		        return true;
		    }
		}
	
	},

	
	check_form_trabajo : function() {
	
		var ftrabajo = document.getElementById('form_trabajo');
		if (ftrabajo) {
		
		    ftrabajo.onsubmit = function (e) {
		        if (!e) e = window.event;
		        var campos = Array;
		        var topInicio = 130;
				campos['nombre'] = isIE6 ? topInicio+4 : topInicio;
				campos['email'] = isIE6 ? topInicio+35 : topInicio+30;
				campos['telefono'] = isIE6 ? topInicio+67 : topInicio+60;
				campos['comentarios'] = isIE6 ? topInicio+131 : topInicio+120;
				campos['cv'] = isIE6 ? topInicio+250 : topInicio+240;
		
		        for (var i in campos) {
			        if (ftrabajo[i].value=='' || (i=='email' && !ftrabajo[i].value.isEmail()) ) {
			        	ftrabajo[i].className = ftrabajo[i].className + ' text_error';
			        	ftrabajo[i].focus();
			        	fer.style.display = 'block';
			        	fer.style.top = campos[i]+'px';
			        	fer.style.right = '75px';
			        	return false;
					}
					else {
						ftrabajo[i].className = ftrabajo[i].className.replace('text_error','');
					}
				}

				if (!ftrabajo['check_condiciones'].checked) {
					ferc.style.display = 'block';
		        	ferc.style.left = '45px';
		        	ferc.style.top = isIE6 ? '561px' : '550px';
		        	return false;
				}
				else 
				if (ferc.style.display == 'block') {
					ferc.style.display = 'none';
				}

		        return true;
		    }
		}
	
	},
	
	// varios rollover por JS
	inicia_rollovers : function() {

		var r1 = document.getElementById('but_acceso_ok1');
		if (r1) {
			r1.onmouseover = function (e) { r1.src = 'img/acceso_ok_over.gif'; }
			r1.onmouseout = function (e) { r1.src = 'img/acceso_ok.gif'; }
		}
		var r2 = document.getElementById('but_acceso_ok2');
		if (r2) {
			r2.onmouseover = function (e) { r2.src = 'img/acceso_ok_over.gif'; }
			r2.onmouseout = function (e) { r2.src = 'img/acceso_ok.gif'; }
		}
		var r3 = document.getElementById('but_acceso_ok3');
		if (r3) {
			r3.onmouseover = function (e) { r3.src = 'img/acceso_ok_over.gif'; }
			r3.onmouseout = function (e) { r3.src = 'img/acceso_ok.gif'; }
		}
		

		var r4 = document.getElementById('but_enviar_1');
		if (r4) {
			r4.onmouseover = function (e) { r4.src = 'img/boton_enviar_gris_1.png'; }
			r4.onmouseout = function (e) { r4.src = 'img/boton_enviar_amarillo_1.png'; }
		}
		var r5 = document.getElementById('but_enviar_2');
		if (r5) {
			r5.onmouseover = function (e) { r5.src = 'img/boton_enviar_gris_1.png'; }
			r5.onmouseout = function (e) { r5.src = 'img/boton_enviar_lila_1.png'; }
		}
		var r6 = document.getElementById('but_enviar_3');
		if (r6) {
			r6.onmouseover = function (e) { r6.src = 'img/boton_enviar_gris_1.png'; }
			r6.onmouseout = function (e) { r6.src = 'img/boton_enviar_amarillo_1.png'; }
		}
		
	}


}