// JavaScript Document

/*function cambiar(md5)
{ 	document.fmChangeLoc.action="index.php?varsession="+md5+"&loc="+document.fmChangeLoc.cmbLoc.value;
	document.fmChangeLoc.submit();
}*/

function valsLoc(){
	with(document.fmsLoc){
		if(txsLoc.value.length==0){
		alert('No hay Parametros de Busqueda');
		txsLoc.focus();
		return false;
		}
	}
return true;
}

function encuesta(campo)
{	
	var marcado = "no";
		with (document.Fm_Enc)
		{
			for ( var i = 0; i < campo.length; i++ )
			{
			if ( campo[i].checked )
			{
			window.alert("Gracias por Participar" ) ;
			return true;
			}
			}
			if ( marcado == "no" )
			{
			window.alert("Seleccione una respuesta" ) ;
			return false;
			}
		}
}
function valmifono(){
	with(document.fm_mail){
		if(login_username.value.length==0){
		alert('Em campo correo esta vacio');
		login_username.focus();
		return false;
		}
		if(secretkey.value.length==0){
		alert('El campo de contraseña esta vacio');
		secretkey.focus();
		return false;
		}
	}	
return true;
}
function valcontact(){
	with(document.fm_contacto){
		if(tx_name.value.length==0){
		alert('Debe ingresar su nombre');
		tx_name.focus();
		return false;	
		}
		if(tx_mail.value.length==0){
		alert('Debe ingresar su Correo Electronico');
		tx_mail.focus();
		return false;			
		}
		if(tx_asunto.value.length==0){
		alert('Debe ingresar el asunto');
		tx_asunto.focus();
		return false;	
		}
		if(msj.value.length==0){
		alert('El campo mensaje esta vacio');
		msj.focus();
		return false;	
		}
	}
return true;
}
function cambio(){
menuprueba.style.display="none";
}

function valMesa(){
var marcado="no";
	with(document.fmMesa){	
		if(valRadio(fmMesa, Preg1_1)==false){
		alert('Debe llenar todos los campos que sean obligatorios');
		return false;
		}
	}
return false;
}

function valRadio(form, campo){
var marcado = "no";
alert(form);
	with(document.form)
	{
		for ( var i = 0; i < campo.length; i++ )
		{
			if ( campo[i].checked )
			{
			return true;
			}
		}
			if ( marcado == "no" )
			{
			return false;
			}
	}
}

function ValConsumo(){
	with(document.fmsuma){
		if(Total.value<1){
		alert('No se ha hecho ningun registro');
		return false;
		}	
	}
return true;
}

function carga(form,ruta){
	form.action=ruta;
	form.submit();
}

function ValRegistro(){
	with(document.fmUserAdd){
		if(DeptoID.value==0){
		alert('Seleccione el Departamento');
		DeptoID.focus();
		return false;
		}
		if(MunID.value==0){
		alert('Seleccione el Municipio');
		DeptoID.focus();
		return false;
		}
		if(LocID.value==0){
		alert('Seleccione la Localidad');
		LocID.focus();
		return false;
		}
		if(NameUser.value.length==0){
		alert("Campo nombres Vacio");	
		NameUser.focus();
		return false;
		}
		if(ApellUser.value.length==0){
		alert("Campo apellidos Vacio");	
		ApellUser.focus();
		return false;
		}
		if(DocUser.value.length<6){
		alert("Campo No. documento es de minimo 6 dígitos");	
		DocUser.focus();
		return false;
		}
		var Template = /^[0-9]+$/i //Formato de alfanumerico
		if (!Template.test(DocUser.value)) 
		{	
		alert("El Número que ha Ingresado tiene Caracteres Inválidos");
		DocUser.focus();
		return false;
		}
		if(EmailUser.value.length==0){
		alert("Campo Correo Electrónico Vacio");	
		EmailUser.focus();
		return false;
		}
		var TemplateMail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		if (!TemplateMail.test(EmailUser.value)){
		alert("El Email que ha Ingresado no es correcto");
		EmailUser.focus();
		return false;
		}
		if(DirUser.value.length==0){
		alert("Campo Dirección Vacio");	
		DirUser.focus();
		return false;
		}
		if(TelUser.value.length==0){
		alert("Campo Teléfono Vacio");	
		TelUser.focus();
		return false;
		}
		if(CelUser.value.length==0){
		alert("Campo Celular Vacio");	
		CelUser.focus();
		return false;
		}
	}
return true;
}

function solonum(e){
tecla = (document.all) ? e.keyCode : e.which;     
	if ((tecla == 8) || (tecla == 0)){
	return true;
	}
	else if((tecla > 47) && (tecla < 58)){
	return true;
	}
	else{
	return false;
	}
}

function CambioLoc(session){
	with(document.fmCambioLoc){
		if(LocID2.value>0){
		window.location='index.php?loc='+LocID2.value+'&session='+session;
		return true;
		}
	}
return true;
}

function valconducta(){
	with(document.fm_conducta){
		if(msj.value.length==0){
		alert('El campo de texto esta vacio');	
		msj.focus();
		return false;
		}	
	}
return true;
}
