var procede="ok";
var test = 0;


function EsNumero(item,tipo) {
  cuasidigitos = "0123456789()-";
  numeros = "0123456789";
  (tipo==2)?(digitos=cuasidigitos):(digitos=numeros);
  num_ch= item.length;
  sts= true;
   if (num_ch >= 1) {
       for (i = 0;  i < num_ch;  i++) {
	       ch = item.charAt(i);
	       for (j = 0;  j < digitos.length;  j++) 
	           if (ch == digitos.charAt(j)) {
	             break;
	          } 
	          if (j == digitos.length) {
		        sts = false;
		       break;
	          }
       }
    }
    else {
      sts = false;
    }
    return (sts);
}


function SetListOptions(lista, campo){
  if (lista.length >= 1) {
	 campo.length=lista.length;
    for (i=0; i<lista.length; i++) {
         campo.options[i].text=lista[i][1];
         campo.options[i].value=lista[i][0];
    }
  }
}


function ValidaCorreo(item) {
    var re = /^([A-Za-z0-9\_\-]+\.)*[A-Za-z0-9\_\-]+@([A-Za-z0-9\_\-]+\.)*([A-Za-z0-9\_\-])+\.([A-Za-z]){2,3}$/;
    if (item.search(re) == -1){
        return (false);
    }
    else{
          return (true);
    }
}
 

function ValidaLongitud(item, len) {
        return (item.length >= len);
}


 function ActivaRadio(campo,cual) {
    num_campos=campo.length;
    for (i=0; i<num_campos; i++) {
       val=campo[i].value;
         if (val == cual){
           campo[i].checked=true;
           break;
         }
    }

 }


function ActivaListOptons(campo,str){
  num_campos=campo.length;
  for (i=0; i<num_campos; i++) {
    val=campo[i].value;
	 if (val == str){
	   campo[i].selected=true;
	   break;
	 }
  }
 }


function ChecaSelect(campo){
  if (campo[0].selected) {
	return false;
  } else {
	return true;
  }
}

function ChecaCheckbox(item){
   if (item.checked) return true;
   return false;
}

function ChecaRdio(item){
   radio_edo = false;
   num_radioboton = item.length;
   for (i=0; i<num_radioboton; i++) {
      if(item[i].checked) {
        radio_edo = true;
        break;
      }
   } 
   return radio_edo;
}

        
function SelError(elemento, texto) {
        if (encuentraerror) return;
        window.alert(texto);
        elemento.focus();
        encuentraerror = true;
}
  
 
function RadioError(texto){
   if (encuentraerror) return;
   alert(texto);
   encuentraerror = true;
} 
  
  
function OnError(elemento, texto) {
        if (encuentraerror) return;
        window.alert(texto);
        elemento.focus();
        elemento.select();
        encuentraerror = true;
}



function PonMayusculas(campo){
  dato = campo.value;
  dato = dato.toUpperCase();
  campo.value=dato;
}


function PonMinusculas(campo){
  dato = campo.value;
  dato = dato.toLowerCase();
  campo.value=dato;
}


// Ajax engine
 mi_dir=location.href.split("/");
 local_path ="";
 for (i=0; i<(mi_dir.length-1); i++) {
   local_path += mi_dir[i]+"/";
  }
  
function AjaxConect(ajax_url, ajax_qstring, ajax_callBack) {
  if (ajax_url==undefined || ajax_callBack == undefined) {
    alert("No definido la URL");
	return false;
  }
    var strURL=ajax_url;
    var xmlHttpReq = false;
    var self = this;

    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			ajax_callBack(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(ajax_qstring);
}


 var sitio_id = "5408";
 var eplrnd = (new String(Math.random())).substring(2,8) + (((new Date()).getTime()) & 262143);
 var sw = (self.innerWidth ? self.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body ? document.body.clientWidth : "");
 var sh = (self.innerHeight ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body ? document.body.clientHeight : "");
 var wh = (sw && sh) ? (sw.toString(16) + "x" + sh.toString(16)) : "";
 
  function TendenzzAD(espacio) {
    keywords=(ad_keywords != undefined)?(ad_keywords):('');
	//var ad = '<scri' + 'pt language="JavaScript" type="text/javascript" src="http://ads.us.e-planning.net/eb/3/' + sitio_id + '/' + espacio + '?o=j&rnd=' + eplrnd + keywords + (wh ? ('&n=' + wh) : '') + '"></scri' + 'pt>'; 
	var ad='&nbsp;';
	document.write(ad);
 }
 
 
