function ahah(url, target, delay) {
  document.getElementById(target).innerHTML = '<div align="center"><br /><br /><br /><br /><br />Cargando...</div>';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target, delay);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahah2(url, target, delay) {
  document.getElementById(target).innerHTML = '<div style="width:220px;" align="center">Cargando...</div>';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target, delay);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target, delay) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML="Error:\n"+req.statusText;
    }
    if (delay != undefined) {
       setTimeout("ahah(url,target,delay)", delay); // resubmit after delay
	    //server should ALSO delay before responding
    }
  }
}
function VerFoto(Foto) {
	izq = (screen.width - 640)/2;
	arr = (screen.height - 480)/2;
	aa = open(Foto, 'Foto', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=640,height=480,left='+izq+', top='+arr+',screenX='+izq+',screenY='+arr+'');
}
function es_mail(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length-1;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   alert("Email Invalido");
		   return false;

		}
		
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Email Invalido");
		   return false;
		}
		
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Email Invalido");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Email Invalido");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Email Invalido");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Email Invalido");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Email Invalido");
		    return false;
		 }

 		 return true;
}