function checkMember(forma){
	if (forma.telefono.value==""){
		alert ("Debes indicar el teléfono");
		forma.telefono_miembro.focus();
		return false;
	}

	if (forma.nombre.value==""){
		alert("Debes indicar el Nombre");
		forma.nombre.focus();
		return false;
	}
	
	if (forma.apellido.value==""){
		alert ("Debes indicar el apellido");
		forma.apellido.focus();
		return false;
	}
	
	if (forma.nickname.value==""){
		alert("Debes indicar el nickname");
		forma.nickname.focus();
		return false;
	}	
	
	count = 0;
	
	for (pos=0;pos<forma.length;pos++){
		elemento =forma.elements[pos]; 
		if (elemento.name=="ogrupo[]")
			if (elemento.checked)
				count++;
	}
	if (count==0){
		alert("Debes seleccionar por lo menos un grupo");
		return false;
	}

	
	return true;
}

function checkMemberEdit(forma){

	if (forma.skp.value==1)
		return true;	
	
	if (forma.telefono.value==""){
		alert ("Debes indicar el teléfono");
		forma.telefono_miembro.focus();
		return false;
	}

	if (forma.nombre.value==""){
		alert("Debes indicar el Nombre");
		forma.nombre.focus();
		return false;
	}
	
	if (forma.apellido.value==""){
		alert ("Debes indicar el apellido");
		forma.apellido.focus();
		return false;
	}
	
	if (forma.nickname.value==""){
		alert("Debes indicar el nickname");
		forma.nickname.focus();
		return false;
	}	

	return true;
}

var phone = "0123456789";
var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var gname = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
function res(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
	x = t.value.charAt(i);
	if (v.indexOf(x,0) != -1)
	w += x;
	}
	t.value = w;
}

function checkRegister(forma){
	
	if (forma.telefono.value==''){
		alert ("Debes indicar el número de tu celular");
		forma.telefono.focus();
		return false;
	}
	
	if (forma.telefono.value.length<7){
		alert ("El teléfono debe ser de 7 dígitos");
		forma.telefono.focus();
		return false;
	}
	
	if (forma.password1.value==''){
		alert ("Debes ingresar tu password");
		forma.password1.focus();
		return false;
	}		
	
	if (forma.password1.value!=forma.password2.value){
		alert ("Las dos contraseñas deben ser iguales");
		forma.password1.focus();
		return false;
	}
	
	if (forma.nombre.value==''){
		alert ("Debes escribir tu nombre");
		forma.nombre.focus();
		return false;
	}	
	
	if (forma.apellido.value==''){
		alert ("Debes escribir por lo menos un apellido");
		forma.apellido.focus();
		return false;
	}
	
	if (forma.nickname.value==''){
		alert ("Debes escribir tu nickname");
		forma.nickname.focus();
		return false;
	}
	
	if (forma.email.value==''){
		alert ("Debes escribir tu email");
		forma.email.focus();
		return false;
	}	

	var filter=/^[A-Za-z][A-Za-z0-9_.\-]*@[A-Za-z0-9_\-]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	
	if (!filter.test(forma.email.value)){		
		alert ("La dirección de email no es válida");
		forma.email.focus();
		return false;		
	}
	
	if (forma.idoperador.value==-1){
		alert ("Por favor selecciona el operador");
		forma.idoperador.focus();
		return false;
	}
	
	return true;	
	
}

function checkLogin (forma){
	if (forma.telefono_login.value==''){
		alert ("No has ingresado tu número de telefóno aún");
		forma.telefono_login.focus();
		return false;
	}	
	if (forma.password.value==''){
		alert ("Debes escribir tu contraseña para ingresar");
		forma.password.focus();
		return false;
	}	
	return true;
}

function checkTel (forma){
	if (forma.tremember.value==''){
		alert ("Debes ingresar tu número de teléfono");
		forma.tremember.focus();
		return false;
	}	
	return true;
}

function checkInputPhone (obj,message){
	if (obj.value.length < 7){
		if (message==true){
			alert ("El número de teléfono debe ser de 7 dígitos");
			
			obj.focus();
		}
		return false;
	}
	return true;
}
function checkAll (check){
	//se obtiene la refernciaa a la forma
	forma = check.form;
	if (check.checked)
		valor = true;
	else
		valor = false;
	elementos = forma.elements;
	for (i=0;i<forma.length;i++){
		if (elementos[i].name=="check[]")
			elementos[i].checked = valor;
	}
	return true;
}
function CleanForm (objeto){
	//se obtiene la freferencia a la forma
	forma = objeto.form;
	elementos = forma.elements;
	for (i=0;i<forma.length;i++){
			if (elementos[i].type!='submit')
			elementos[i].value='';
			
	}
	return false;
}

function checkPhoneLeft (forma){
	if (forma.telefono.value.slice(0,2)=='Te' || forma.telefono.value==''){
		alert ('Debes escribir el número celular de tu amigo para poder agregarlo');
		return false;
	}
	if (forma.telefono.value.length!=7){
		alert ('El número de teléfono debe ser de 7 dígitos');
		return false;
	}	
	return true;
}

function checkOperPhone(phone,idtag){
		if (phone.length<7){
			return false;
		}
		
		xmlHttp = GetXmlHttpRequest();
		
		var url="checkoper.php";
		url=url+"?ph="+phone;
		lab = idtag;
		xmlHttp.onreadystatechange=stateChanged; 
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

//trim
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') }

