    function cambiarfuentes(valor){
        document.cambiatamanyo.tamanyoletra.value=valor;
        document.cambiatamanyo.submit();
    }

	function multiidioma(v_idioma){
		url=window.location.href;
		enlace=document.getElementById('enlace_idioma_'+v_idioma);
		enlace.href="#";
		if (url.indexOf('__setlocale=') != -1){
			url = url.substring(0,url.indexOf('__setlocale=')-1)+url.substring(url.indexOf('__setlocale=')+14,url.length);
		}
		if (url.indexOf('?') == -1){
			url = url+"?__setlocale="+v_idioma;
		}else{
			url= url+"&__setlocale="+v_idioma;
		}
enlace.href=url;

	}

		function Trim(cadena) {
			var aux;
			aux = cadena.value.replace(new RegExp("^ +", "g"), "").replace(new RegExp(" +$", "g"), "");
			return aux;
		}

		function buscar(mensaje){
			aux = Trim(document.forms.busqueda.todas);
			enlace=document.getElementById('enlace_buscar');	
			enlace.href="#";
			//alert(document.forms.busqueda.enlace_buscar);
			if (!aux.length){
				alert (mensaje);
				document.forms.busqueda.todas.value="";
				document.forms.busqueda.todas.focus();
				return;
			}
			document.forms.busqueda.submit();
		}
		
	function imprSelec(nombre)
	{
	  var ficha = document.getElementById(nombre);
	  var ventimp = window.open(' ', 'popimpr');
	  ventimp.document.write( ficha.innerHTML );
	  ventimp.document.close();
	  ventimp.print( );
	  ventimp.close();
	} 
	
		function abrirPopUp(object,dir){
		object.href="#";
		window.open('../popup.jsp?fichero='+dir ,'contacto',		'toolbar=no,top=50,left=50,directories=no,menubar=no,width=400,resizable=no,height=500');

		}


		function abrirPopUpNoticia(object,dir,fichero){
			object.href="#";
			window.open(dir+'popup.jsp?fichero='+fichero ,'noticia','toolbar=no,top=50,left=50,directories=no,menubar=no,width=800,resizable=no,Scrollbars=YES,height=600');
		}


		function abrirEsquemaProduccion(object,dir){
				object.href="#";
				window.open('../popupesquema.jsp?fichero='+dir ,'contacto','toolbar=no,top=50,left=50,directories=no,menubar=no,width=800,resizable=no,height=400');
		}
		
		function imprimir(object,dir){
		object.href="#";
		window.open(dir,'noticia');

		}
		function descargar(object,dir){ 
		object.href="#";
		window.open(dir,'noticia',	'toolbar=no,top=50,left=50,directories=no,menubar=no,width=200resizable=no,height=200');
		}
		

	
	function validaEmail (direccCorreo) {
	// Expresion regular para campo Email
        var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
        
        // Devuelve verdadero si validacion OK, y falso en caso contrario
        return b.test(direccCorreo)
}

function validaPrefijo () {
	if (document.Form1.prefijo.value == '') {
		document.Form1.prefijo.value = '0034';
		return true;
	}
	else if (isNaN (document.Form1.prefijo.value)) {
		return false;
	}
	else {
		// Comprueba que tenga los 4 caracteres
		var charAnadir = 4 - document.Form1.prefijo.value.length;
		for (var i = 0; i < charAnadir; i++)
			document.Form1.prefijo.value = "0" + document.Form1.prefijo.value;

		return true;
	}
}

function validaTelefono () {
	if (document.Form1.telefono.value == '') {
		return true;
	}
	else if (isNaN (document.Form1.telefono.value)) {
		return false;
	}
	else {
		// Comprueba que tenga los 9 caracteres
		if (document.Form1.telefono.value.length == 9)
			return true;
		else
			return false;
	}
}

function Valida (formulario,msgApe,msgNom,msgMail1,msgMail2,msgTlf,msgDir,msgCp,msgProv,msgPob,msgPais) {
	if (formulario.apellidos.value == '') {
		alert (msgApe);
    		return false
  	} else if (formulario.nombre.value == ''){
		alert (msgNom);
    		return false
  	} else if (formulario.mail.value == ''){
		alert (msgMail2);
    		return false
  	} else if (formulario.telefono.value == ''){
		alert (msgTlf);
    		return false
        } else if (formulario.direccion.value == ''){
		alert (msgDir);
    		return false
  	} else if (formulario.cp.value == ''){
		alert (msgCp);
    		return false
  	} else if (formulario.provincia.value == ''){
		alert (msgProv);
    		return false
  	} else if (formulario.poblacion.value == ''){
		alert (msgPob);
    		return false
  	} else if (formulario.pais.value == ''){
		alert (msgPais);
    		return false
  	} else if (!validaEmail (formulario.mail.value)) {
		alert (msgMail1);
    		return false
	} else if (!validaPrefijo()) {
		alert (msgTlf);
    		return false
	} else if (!validaTelefono()) {
		alert (msgTlf);
    		return false
	}
	else 
		return true;
}
	
	function ValidaFormContacto (formulario,MsgApe,MsgNom,MsgMail1,MsgMail2,MsgAsunto,MsgMensaje) {
	if (formulario.apellidos.value == '') {
		alert (MsgApe);
    		return false
  	} else if (formulario.nombre.value == ''){
		alert (MsgNom);
    		return false
  	} else if (formulario.mail.value == ''){
		alert (MsgMail1);
			return false		
	} else if (!validaEmail (formulario.mail.value)) {
		alert (MsgMail2);
    		return false
  	} else if (formulario.asunto.value == ''){
		alert (MsgAsunto);
    		return false
  	} else if (formulario.mensaje.value == ''){
		alert (MsgMensaje);
    		return false
	}else 
		return true;
}

function ValidaContacto (formulario,MsgApe,MsgNom,MsgMail1,MsgMail2,MsgAsunto,MsgMensaje,MsgTlf) {
	if (formulario.apellidos.value == '') {
		alert (MsgApe);
    		return false
  	} else if (formulario.nombre.value == ''){
		alert (MsgNom);
    		return false
  	} else if (formulario.mail.value == ''){
		alert (MsgMail1);
			return false		
	} else if (!validaEmail (formulario.mail.value)) {
		alert (MsgMail2);
    		return false
  	} else if (formulario.asunto.value == ''){
		alert (MsgAsunto);
    		return false
  	} else if (formulario.mensaje.value == ''){
		alert (MsgMensaje);
    		return false
	} else if (!validaPrefijo()) {
		alert (msgTlf);
    		return false
	} else if (!validaTelefono()) {
		alert (msgTlf);
    		return false
	}
	else 
		return true;
}