/* VALIDATION */
function validateNULL(input,data,text,tipe,divd) {
	if(tipe=="I") {
		if(input.value.length==0) {
			//alert("* debes escribir tu "+text+" *");
			ErrorMSG(divd,text);
			input.focus();
			return false;
		}
	}
    if(tipe=="S") {
		if(input.selectedIndex==0) {
			ErrorMSG(divd,text);
			input.focus();
			return false;
		}
	}
	return true;
}
function validateLogin(input) {
	var chr;
    if(input.value.length<4 || input.value.length>20) {
		ErrorMSG(divd,"El nombre de usuario debe tener de 4 a 17 caracteres, sin espacios.");
		input.focus();
		return false;
	}
    for (var i=0;i<input.value.length;i++) {
		chr=input.value.substring(i,i+1);
		if((chr<"0") || (chr==" ") || (chr=="?") || (chr=="@") || (chr=="=") || (chr==":") || (chr==";") || (chr=="<") || ( chr==">") ){
			if ( (chr!="-") && (chr!="_") && (chr!=".") ) {
				ErrorMSG(divd,"El nombre de usuario debe tener de 4 a 17 caracteres, sin espacios.");
				input.focus();
				return false;
				}
		}
	}
	return true;
}
function validatePASS(input) {
	var chr;
	if(input.value.length < 4 || input.value.length > 16) {
		ErrorMSG(divd,"La contrase\361a debe tener de 4 a 17 caracteres, sin espacios.");
		input.focus();
		return false;
	}
	return true;
}
function validateSameVals(val1,val2,txt,divd) {
	if(val1.value != val2.value) {
		ErrorMSG(divd,txt);
		val2.focus();
		return false;
	}
	return true;
}
function validateEmail(email,divd) {
	var goodEmail = email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	if (goodEmail) {
		return true;
	} else {
		ErrorMSG(divd,"Por favor verifique su correo electronico.");
		email.focus();
		return false;
	}
}
function validateCheckBox(checkbox,divd) {
	if (checkbox.checked == 1)
   		return true;
  	else
		ErrorMSG(divd,"Debes leer y aceptar los <b>Terminos y Condiciones</b>.");
		checkbox.focus();
		return false;
}
function validateNULL(input,data,text,tipe,divd) {
	if(tipe=="I") {
		if(input.value.length==0) {
			//alert("* debes escribir tu "+text+" *");
			ErrorMSG(divd,text);
			input.focus();
			return false;
		}
	}
    if(tipe=="S") {
		if(input.selectedIndex==0) {
			ErrorMSG(divd,text);
			input.focus();
			return false;
		}
	}
	return true;
}
function validateLogin(input) {
	var chr;
    if(input.value.length<4 || input.value.length>20) {
		ErrorMSG(divd,"El nombre de usuario debe tener de 4 a 17 caracteres, sin espacios.");
		input.focus();
		return false;
	}
    for (var i=0;i<input.value.length;i++) {
		chr=input.value.substring(i,i+1);
		if((chr<"0") || (chr==" ") || (chr=="?") || (chr=="@") || (chr=="=") || (chr==":") || (chr==";") || (chr=="<") || ( chr==">") ){
			if ( (chr!="-") && (chr!="_") && (chr!=".") ) {
				ErrorMSG(divd,"El nombre de usuario debe tener de 4 a 17 caracteres, sin espacios.");
				input.focus();
				return false;
				}
		}
	}
	return true;
}
function validatePASS(input,divd) {
	var chr;
	if(input.value.length < 4 || input.value.length > 16) {
		ErrorMSG(divd,"Lo sentimos, contrase\361a no valida.");
		input.focus();
		return false;
	}
	return true;
}
function validateSameVals(val1,val2,txt) {
	if(val1.value != val2.value) {
		ErrorMSG(divd,txt);
		val2.focus();
		return false;
	}
	return true;
}
function validateEmail(email,divd) {
	var goodEmail = email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\..{2,2}))$)\b/gi);
	if (goodEmail) {
		return true;
	} else {
		ErrorMSG(divd,"Lo sentimos, correo electronico no valido.");
		email.focus();
		return false;
	}
}
function validateCheckBox(checkbox,divd) {
	if (checkbox.checked == 1)
   		return true;
  	else
		ErrorMSG(divd,"Debes leer y aceptar los <b>Terminos y Condiciones</b>.");
		checkbox.focus();
		return false;
}
function validateRadio(radiobox,divd,emsg) {
	myOption = -1;
	if(radiobox != undefined) {
		if(radiobox.length != undefined) {
			for(i=radiobox.length-1;i > -1; i--) {
				if(radiobox[i].checked) {
				myOption = i; i = -1;
				}
			}
		} else {
			if(radiobox.checked) myOption = 1;
		}
	}
	if (myOption == -1) {
		ErrorMSG(divd,emsg);
		return false;
	} else 
		return true;
}
function goto(eID,target,restore) {
	gURL = eID.options[eID.selectedIndex].value
	//alert(gURL)
	if(gURL != "") target.location.href = gURL
	if(restore) eID.selectedIndex=0;
}
function ErrorMSG(id,txt){
	document.getElementById(id).innerHTML = '<table border=0 cellpadding=0 cellspacing=1><tr><td width=16><img src=\"http://imgs.cosmica.tv/icns/alert.png\" align=\"absmiddle\" width=16 height=16 hspace=3 /></td><td class=dflt10pxdrkgry>'+ txt +'</td></tr></table>';
}
