function callAjax(urlserver, accion, params, asincronico){
if(asincronico!==false)
	var async = true;
else
	var async=asincronico;
xmlObj=new Ajax.Request(urlserver,{method:'post',
								asynchronous:async,
 								postBody:'accion='+accion+params,
								onSuccess:function (){},
								onFailure:function (){alert('Problema de comunicación con el Server');window.location.reload();},
								evalJS:true});
}//fin callAjax


emailOk=function(email){
var ok=true; var alfa='abcdefghijklmnopqrstuvwzyx.@-_0123456789';
if (email.length==0) return true;
if (email.length<=6)
	ok=false;
if(ok){
	var i=0; var arroba=0; email=email.toLowerCase();
	while (ok && i<email.length){
		if (alfa.indexOf(email.charAt(i))<0)
			ok=false;
		else	{
			if (email.charAt(i)=='@')
				arroba++;
			i++;
			}
	}
	;if(arroba!=1) ok=false;
	if(ok && (email.indexOf('@')<1 || email.lastIndexOf('@')>=email.length-1)) ok=false;
	if(ok && (email.indexOf('.')<0)) ok=false;
	if(ok && (email.indexOf('.')<1 || email.lastIndexOf('.')>=email.length-1)) ok=false;
	if(ok && email.indexOf('hotmail')>0) ok=email.indexOf('.com')>0;
	if(ok && email.indexOf('yahoo')>0) ok=email.indexOf('.com')>0;
	if(ok && email.indexOf('gmail')>0) ok=email.indexOf('.com')>0;
}
return ok;
}//emailOk


usuarioOk=function(usuario){
var ok=true; var alfa='abcdefghijklmnopqrstuvwzyx0123456789_';
if (usuario.length==0) return true;
if (usuario.length<=3)
	ok=false;
if(ok){
	var i=0; usuario=usuario.toLowerCase();
	while (ok && i<usuario.length){
		if (alfa.indexOf(usuario.charAt(i))<0)
			ok=false;
		else	
			i++;
	}
}
return ok;
}//usuarioOk


fechaOk=function(fecha){
//fecha debe ser de la forma: dd-mm-aaaa
//la fecha vacia se toma como valida!
var ok=true;
if (fecha.length==0) return true;
if (fecha.length!=10) ok=false;
if (fecha.substr(2,1)!='-' || fecha.substr(5,1)!='-') ok=false;
var d=fecha.substr(0,2);
if(ok && (d<1 || d>31)) ok=false;
var m=fecha.substr(3,2);
if(ok && (m<1 || m>12)) ok=false;
var a=fecha.substr(6,4);
if(ok && (a<1800 || a>3000)) ok=false;
return ok;
}//fechaOk


function popup(url){
var newWin = window.open(url);
if (!newWin || !newWin.top) {
	alert("ATENCION!!\n\nEste navegador posee bloqueadas las ventanas emergentes!");
	return false;
}
else return true;
}//popup


function setAndAaveDisabledState(elem){
var arr_state=new Object();
$(elem).descendants().each(function(e){
	if(typeof(e.disabled)!="undefined"){
		arr_state[e.identify()]=e.disabled;
		e.disabled=true;
	}
});
return arr_state;
}//setAndAaveDisabledState


function restoreDisabledState(arr_state){
$H(arr_state).each(function(pair){
  $(pair.key).disabled=pair.value;
});
}//restoreDisabledState


function clvAccesoOk(clv){
var ok=true; var alfa="abcdefghijklmnopqrstuvwxyz0123456789";
if (clv.length!=6)
	ok=false
if(ok){
	var i=0; clv=clv.toLowerCase()
	while (ok && i<clv.length){
		if (alfa.indexOf(clv.charAt(i))<0)
			ok=false
		else	
			i++
	}//while
} // if ok
return ok
}//clvAccesoOk


function alfacheck(s){
var ok=false,i,c,alfa="abcdefghijklmnopqrstuvwxyz ";vocales="aeiou";
  i=0;c=0;v=0;
  s = s.toLowerCase();
  while (i<s.length){
	if (alfa.indexOf(s.charAt(i)) >= 0)
		c++;
	if (vocales.indexOf(s.charAt(i)) >= 0)
		v++;
	i++
  }
  if (c>=(s.length*8/10))
	if (v>=(c*2/10))
		ok=true
  return ok
} // alfacheck


function strzero(nro, long){
nro=""+nro;
var ceros="00000000000000000000";
return ceros.substr(0,long-nro.length)+nro;
}//strzero


function popup(url){
var newWin = window.open(url);
if (!newWin || !newWin.top) {
    alert("ATENCION!!\n\nEste navegador posee bloqueadas las ventanas emergentes!\n\nquite el bloqueo para poder ver la ventana solicitada.");
    return false;
}
else return true;
}//popup



function descargar_archivo(archivo){
popup(archivo);
}//descargar_archivo

