// JScript source code

//Quito los espacios en blanco al ppio o al final
 function trim (myString)
    {
        return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
    }
    
function validarEmail(valor) 
{

    var filter = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/; ///^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
        if (filter.test(valor))
            return true;
        else
            return (false);
}

    
//    //esta funcion solo deja ingresar numeros enteros
//    function SoloNumeros(e)
//	{
//		var caracter 
//            	caracter = e.keyCode 
//            	status = caracter 
//        
//        	if (caracter>47 && caracter <58)
//            	{
//                	return true
//            	}
//            	return false
//   
//        }


//esta funcion solo deja ingresar numeros enteros
function SoloNumeros(cadena, obj, e){
opc = false;
tecla = (document.all) ? e.keyCode : e.which;
if (cadena == "%d")
if (tecla > 47 && tecla < 58)
opc = true;
if (cadena == "%f"){
if (tecla > 47 && tecla < 58)
opc = true;
if (obj.value.search("[.*]") == -1 && obj.value.length != 0)
if (tecla == 46)
opc = true;
}
return opc;
}


function validadEdad(edad)
{
    if (edad>=1 &&  edad<=100)
    {
        return true;
    }
    else 
    {
     return (false);
    }
}


function ObtenerRadioButtonSeleccionado(Radio)
{
  for(i=0;i<Radio.length;i++)
    if(Radio[i].checked) return Radio[i].value;
}

function EsTxtVacio(textbox)
{
    if (trim(textbox.value) == "")
    {
        return true;
    }
    else
        return(false);
}

function DosTxtDistintos(textbox1,textbox2)
{
    if (trim(textbox1.value) != trim(textbox2.value))
    {
        return true;
    }
    else    
        return(false);
} 

function PintarTxtBlanco(textbox)
{   
    textbox.style.background="white";

} 

function PintarTxtVerde(textbox)
{
    textbox.style.background="#99CC33";
}

function PintarTxtVerdeYMostrarAsterisco(textbox,div)
{
    textbox.style.background="#99CC33";
    div.style.display = 'block';
}

function PintarTxtNaranjaYMostrarAsterisco(textbox,div)
{
    textbox.style.background="#F7BE81";
    div.style.display = 'block';
}

function PintarTxtEmailRojoYMostrarAsteriscos(textbox1,textbox2,div1,div2)
{
    textbox1.style.background="red";
    textbox2.style.background="red";
    div1.style.display = 'block';
    div2.style.display = 'block';

} 

function PintarTxtAmarilloYMostrarAstericos(textbox,div)
{
    textbox.style.background="yellow";
    div.style.display = 'block';
}

function OcultarAsterisco(div)
{
    div.style.display = 'none';
}

function DeshabilitarTextBox(idtxt,idasterisco) {
    document.getElementById(idtxt).disabled = true;
    document.getElementById(idtxt).value = '';
    document.getElementById(idtxt).style.background = "#D3D3D3";
    document.getElementById(idasterisco).style.display ='none';

}

function HabilitarTextBox(idtxt,idasterisco) {
    document.getElementById(idtxt).disabled = false;
    document.getElementById(idtxt).style.background = "white";
    document.getElementById(idasterisco).style.display = 'none';
}




