// JavaScript Document
function muestra_mas(xxx){
	if ((xxx.value==1)||(xxx.value==2)||(xxx.value==8)){
		document.getElementById('centro_especial').style.display="";
	}else{
		document.getElementById('centro_especial').style.display="none";
	}
}

function activa_menu(pe,menu)
{
	if (document.getElementById('concambios').value!=0){
	 	if (confirm('Has hechos cambios en la comunicacion que aun no has guardado, si continuas perderas los cambios')){
			document.getElementById('concambios').value=0;
			document.getElementById(menu_on).style.display="none";
			document.getElementById(pe_on).className="formu_pes_off";
	
			document.getElementById(menu).style.display="";
			document.getElementById(pe).className="formu_pes_on";
			menu_on=menu;
			pe_on=pe;
		}
	}else{
		document.getElementById(menu_on).style.display="none";
		document.getElementById(pe_on).className="formu_pes_off";
	
		document.getElementById(menu).style.display="";
		document.getElementById(pe).className="formu_pes_on";
		menu_on=menu;
		pe_on=pe;
	}
}

function verifica_mail(t_mail)
{
	if ((t_mail.lastIndexOf(" ")!=-1) || (t_mail.lastIndexOf("@")==-1) || (t_mail.lastIndexOf(".")<=(t_mail.lastIndexOf("@")+1)) || (t_mail.lastIndexOf(".")==(t_mail.length-1))) return false;
		else return true;
}

function comprobar_campos(formulario,check)
{

	//alert("eso");
	for (var i=0;i<formulario.elements.length;i++)
	{
		var e = formulario.elements[i],bvar;
		var valor;
				
		
		valor=e.id.split("-");
			if (valor[0]=="requerido")
			{
				if (e.value=="")
				{
					alert(text_campo+valor[1]+text_vacio);
					if (e.dato!='textarea') e.focus();
					return false;
				}
				//alert (e.type);
				if (e.type=="select-one")
				{
					//alert(e.selectedIndex);
					var indice = e.selectedIndex;
					if ((e.options[indice].value =="")||(e.options[indice].value =="0"))
					{
						alert(text_campo+valor[1]+text_vacio);
						return false;
					}
				}
				if (valor[1]=="Email")
				{
					if (!verifica_mail(e.value))
					{
						alert(text_mail);
						e.focus();
						return false;
					}		
				}
			}
		
	
		
		if (e.name=="user_pass_TXT")
		{
			if (e.value!=formulario.repass.value)
			{
				alert(text_pass);
				if (e.dato!='textarea')
				{
					formulario.repass.value="";
					formulario.repass.focus();
				}
				return false;
			}
		}
	}
	
	//Comprovar tipo de dato
	if (check==1)
	{
		if (!verifica_check(formulario))
		{
			alert(text_mail);
			return false;
		}
	}
	return true;

}

function comprobar_autor(formulario,check)
{
	for (var i=0;i<formulario.elements.length;i++)
	{
	
		var e = formulario.elements[i],bvar;
	
		if (e.id=="user_presentador")
		{
		//alert(e.value);
			if ((e.value=="")||(e.value==0))
			{
				alert(text_campo+" "+text_presentador+" "+text_vacio);
				e.focus();
				return false;			
			}
		}
	}
}

function comprobar_datos(formulario,check)
{
	for (var i=0;i<formulario.elements.length;i++)
	{
	
		var e = formulario.elements[i],bvar;
	
		if (e.id=="user_datos")
		{
		//alert(e.value);
			if ((e.value=="")||(e.value==0))
			{
				alert("Debemos tener al menos una forma de contacto.");
				e.focus();
				return false;			
			}
		}
	}
}
