
function isEmpty(input)
{
	var obj = document.getElementById(input);
	if (!obj)
		return false;

	var value = obj.value+"";

	if (value.length!="")
	{
		resetInput(obj);
		return false;
	} else {
		highLightInput(obj);
		return true;
	}
}


function validateLength(input,length)
{
	var obj = document.getElementById(input);
	if (!obj)
		return false;

	var value = obj.value+"";

	if (value.length < length)
	{
		highLightInput(obj);
		return false;
	} else {
		resetInput(obj);
		return true;
	}
}


function validateEmail(input)
{
	var obj = document.getElementById(input);
	if (!obj)
		return false;

	var value = obj.value+"";

	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value)){
		highLightInput(obj);
		return false;
	} else {
		resetInput(obj);
		return true;
	}
}


function validateNumber(input,from,to)
{
	var obj = document.getElementById(input);
	if (!obj)
		return false;

	var value = obj.value+"";

    if ( !isNumeric(value) || value > to || value < from )
    {
		highLightInput(obj);
		return false;
	} else {
		resetInput(obj);
		return true;
	}
}


function validateNumeric(input)
{
	var obj = document.getElementById(input);
	if (!obj)
		return false;

	var value = obj.value+"";
    if ( !isNumeric(value) )
    {
		highLightInput(obj);
		return false;
	} else {
		resetInput(obj);
		return true;
	}
}


function isNumeric(sText)
{
	var validChars = "0123456789.";
	var isNumber=true;
	var charT;

	for (i = 0; i < sText.length && isNumber == true; i++)
	{
		charT = sText.charAt(i);
		if (validChars.indexOf(charT) == -1)
			isNumber = false;
	}
	return isNumber;
}


function highLightInput(input)
{
	input.style.borderColor = "#FF0000";
	input.style.color  = "#FF0000";
	input.focus();
	//input.select();
}



function resetInput(input)
{
	input.style.borderColor = "";
	input.style.color  = "";
}

function getSelectText(input){
	var obj = document.getElementById(input);
	if (!obj)
		return "";

	return obj.options[obj.selectedIndex].text;
}

function getSelectValue(input){
	var obj = document.getElementById(input);
	if (!obj)
		return "";

	return obj.options[obj.selectedIndex].value;
}

function setValue(input, value){
	var obj = document.getElementById(input);
	if (!obj)
		return;

	obj.value=value;
}

function validadateSexo(input){

	for(x=0;x<input.length;x++){
		if(input[x].checked){
			return true;
		}
	}

	return false;
}

function validateClub(input){
	
	for(x=0;x<input.length;x++){
	if(input[x].checked){
		return true;
	    }	
	}
	return false;
}


function validadateRadio(input){

	for(x=0;x<input.length;x++){
		if(input[x].checked){
			return true;
		}
	}

	return false;
}

function validadateClubPersonal(input){

	for(x=0;x<input.length;x++){
		if(input[x].checked){
			return true;
		}
	}

	return false;
}
function validarAreaCelular(input, input2) {

	var obj1 = document.getElementById(input);
	var value1 = obj1.value + "";

	var objDoc = document.getElementById(input2);
	var value2 = objDoc.value;
	 
     if (value1.length == 2) {
    	 if(value1.length == 2 & value2.length == 8){
    		 return true;
    	 }else{
    		alert("El numero de celular tiene que tener 8 caracteres");
    		return false;
    	 }
	} else if (value1.length == 3) {
		if(value1.length == 3 & value2.length == 7){
			return true;
		}else{
			alert("El numero de celular tiene que tener 7 caracteres");
    		return false;
		}
	} else if (value1.length == 4) {
		if (value1.length == 4 & value2.length == 6){
			return true;
		}else{
			alert("El numero de celular tiene que tener 6 caracteres");
    		return false;
		}
	}else{
		alert("el numero de area y celular no son correctos");
	}
}

function validarTamanoDocumento(input, inputDoc) {

	var obj1 = document.getElementById(input);
	var value1 = obj1.value + "";

	var objDoc = document.getElementById(inputDoc);
	var tipoDoc = objDoc.value;


	
	if (tipoDoc == "pasaporte") {
		var RegExPattern = /^([0-9]{11,11})*$/;
	} else {
		var RegExPattern = /^([0-9]{7,8})*$/;
	}
	if ((value1.match(RegExPattern)) && (value1 != '')) {
		return true;
	} else {
		return false;
	}

}


