
	function initFields(frm){
		frm.fichero.style.backgroundColor="#FFFFFF";
		frm.nombre.style.backgroundColor="#FFFFFF";
		frm.email.style.backgroundColor="#FFFFFF";
	}

	//Valida un email mediante expresiones regulares
	function valEmail(valor) {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
			return true;
		} else {
			return false;
		}
	}

	function valForm(frm){
		var error=false;
		var strError="";

		initFields(frm);
		if (frm.nombre.value.length == 0){
			error=true;
			strError += "- Nombre.\n";
			frm.nombre.focus();
			frm.nombre.style.backgroundColor="#FFFFCC";
		}
		if (!valEmail(frm.email.value)){
			error=true;
			strError += "- Correo electrónico.\n";
			frm.email.focus();
			frm.email.style.backgroundColor="#FFFFCC";
		}
		if (frm.cargo.value == "0"){
			error=true;
			strError += "- Profesión.\n";
			frm.cargo.focus();
			frm.cargo.style.backgroundColor="#FFFFCC";
		}
		if (error){
			alert("Por favor, informe correctamente los siguientes campos obligatorios, \n"+strError);
			return false;
		}
		return true;
	}
	function valText() {
		var maxSize = 600;
		var m = document.frm.comentarios.value;
		var mm = m.length;
		document.getElementById("contador").innerHTML=maxSize - mm;
		if(mm > maxSize){
			document.frm.comentarios.value = document.frm.comentarios.value.substring(0,maxSize);
			alert("El máximo es "+maxSize+".");
		}
		setTimeout("valText()",2);
	}
	function setChild(idcat, child, img, tdobj){
		obj=document.getElementById(child);
		objimg=document.getElementById(img);
		if (obj.style.display == ""){
			obj.style.display="none";
			objimg.src="/images/flechaoff.gif";
			tdobj.style.backgroundColor="#FFFFFF";
			document.frm.cargo.value="0";
		}else{
			obj.style.display="";
			objimg.src="/images/flechaon.gif";
			tdobj.style.backgroundColor="#E0E0E0";
			document.frm.cargo.value=idcat;
		}
	}
	function setMouseOver(obj){
		obj.style.backgroundColor="#E0E0E0";
		obj.style.cursor="pointer";
	}
	function setMouseOut(obj, child){
		//if (child.style.display == "")
		obj.style.backgroundColor="#FFFFFF";
	}
