
    var http_request = false;

    function makeRequest(url) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Falla :( No es posible crear una instancia XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents() {
	var varRes = document.getElementById('registroslist');
	
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                varRes.innerHTML = http_request.responseText;
            } else {
                alert('Hubo problemas con la petición.');
            }
        }

    }
    
    
function openWindow(url,name,w,h,sc){
	var ancho_interface=10;
	var alto_interface=29;
	var tamx=screen.width;
	var tamy=screen.height;
	var posx=(tamx-(parseInt(w)+ancho_interface))/2;
	var posy=(tamy -(parseInt(h)+alto_interface))/2;
		
	var parameters = 'width='+w+',height='+h+',top='+posy+',left='+posx+',scrollbars='+sc;
	window.open(url,name,parameters);
}

function EsVacio(val) {
    return ((val == null) || (val.length == 0));
}

function EsFecha(val) {
    var dia = parseInt(val.substr(0,2),10);
    var mes = parseInt(val.substr(3,2),10);
    var anyo = parseInt(val.substr(6,4),10);
  
    if(val.length!=10) return false;
    d = new Date(val)
    if (isNaN( d.valueOf() )) return false;
    sArray = val.split("/")
    if (sArray.length > 3) return false;
    if( (sArray[0].length!=2) || (sArray[1].length!=2) || (sArray[2].length!=4) ) return false;
    if( (anyo<0) || (anyo>9999) ) return false;
    if((mes>12) || (mes<1)) return false;
    if((mes==4)||(mes==6)||(mes==9)||(mes==11)) {
        if((dia>30) || (dia<1)) return false;
    }
    if((mes==1)||(mes==3)||(mes==5)||(mes==7)||(mes==8)||(mes==10)||(mes==12)) {
            if((dia>31) || (dia<1)) return false;
    }
    if((mes==2) && (!EsBisiesto(anyo))) {
            if((dia>28) || (dia<1)) return false;
    } else if((mes==2) && (EsBisiesto(anyo))) {
            if((dia>29) || (dia<1)) return false;
    }
    return true;
}

function EsBisiesto(val) {
    return ((val % 4 == 0) && ((!(val % 100 == 0)) || (val % 400 == 0)));
}

function ChequeoLetras(chequeo)
{
  var digitos = "0123456789";
  for (i = 0;  i < chequeo.length;  i++)
  {
    ch = chequeo.charAt(i);
    for (j = 0;  j < digitos.length;  j++)
      if (ch == digitos.charAt(j))
        break;
    if (j == digitos.length)
    { return (true); }
   }
  return (false);
}
function valora(valor)
{this.valor=valor}

function Calcula(valor){

var val = new valora(11);

val[1] = new valora(1);
val[2] = new valora(2);
val[3] = new valora(4);
val[4] = new valora(8);
val[5] = new valora(5);
val[6] = new valora(10);
val[7] = new valora(9);
val[8] = new valora(7);
val[9] = new valora(3);
val[10] = new valora(6);
var Total=0;
  for (i = 0;  i < valor.length;  i++)
  {
    Total += valor.charAt(i)*val[i+1].valor;
   }
	Total = 11-(Total % 11)
	if (Total==10) {Total=1}
	if (Total==11) {Total=0}
  return Total;
}


function CalcularCC(CB,CS,CC,CD)
{

  if (CB.value.length != 4)
  {
    alert("Escriba el valor para el campo \"C.Banco\" con cuatro digitos.");
    CB.focus();
    return (false);
  }
  if (CS.value.length != 4)
  {
    alert("Escriba el valor para el campo \"C.Sucursal\" con cuatro digitos.");
    CS.focus();
    return (false);
  }
  if (CD.value.length != 2)
  {
    alert("Escriba el valor para el campo \"C.Control\" con dos digitos.");
    CD.focus();
    return (false);
  }
  if (CC.value.length != 10)
  {
    alert("Escriba el valor para el campo \"C.Corriente\" con diez digitos.");
    CC.focus();
    return (false);
  }

  if (ChequeoLetras(CB.value))
  {
    alert("Escriba solo numeros (0-9) el campo \"C.Banco\" .");
    CB.focus();
    return (false);
  }
  if (ChequeoLetras(CS.value))
  {
    alert("Escriba solo numeros (0-9) el campo \"C.Sucursal\" .");
    CS.focus();
    return (false);
  }
  if (ChequeoLetras(CD.value))
  {
    alert("Escriba solo numeros (0-9) el campo \"C.Control\" .");
    CD.focus();
    return (false);
  }
  if (ChequeoLetras(CC.value))
  {
    alert("Escriba solo numeros (0-9) el campo \"C.Corriente\" .");
    CC.focus();
    return (false);
  }
  
  redun =Calcula("00"+CB.value+CS.value);
  redun =""+Calcula("00"+CB.value+CS.value)+Calcula(CC.value);
	if (redun!=CD.value)
		{
		alert("La cuenta introducida no es valida.");
		return false;
		}
	else
		{
		return true;
		}
  return false;
}

function EsEmail(val) {
    arroba = val.lastIndexOf('@');

    if ( arroba < 1 )
        return false;
    else {
    punto = val.indexOf('.', arroba);
      if ( punto < arroba + 2 ||
         punto > val.length - 2 ) {
         return false;
      }
   }
   return true;
}

function EsCIFNIF(val) {
    val = val.toUpperCase()
    if (val.charAt(0) == 'X' || EsDigito(val.charAt(0)) )
        return EsNIF(val)
    else
        return EsCIF(val);
}

function EsNIF(val) {
    val = val.toUpperCase()
    var LetrasNIF = "TRWAGMYFPDXBNJZSQVHLCKE"
    
    if (!MinCaracteres(val,8)) return false;
    Letra = val.charAt(val.length-1);
    if (LetrasNIF.indexOf(Letra) == -1) return false;
    if (val.charAt(0) == 'X')
       Numero = val.substring(1,val.length-1)
    else
       Numero = val.substring(0,val.length-1);
    if (!EsDigitos(Numero)) return false;
    Numero = parseInt(Numero,10)
    Indice = Numero-(parseInt(Numero/23,10)*23);
    if (Letra != LetrasNIF.charAt(Indice)) return false;
    return true;
}

function EsCIF(val) {
    val = val.toUpperCase();
    var LetrasCIF = "ABCDEFGHNPSQ";
    var LetrasOrganismos = "JABCDEFGHI";
    var Organismo = false;
    
    if (!MinCaracteres(val,9)) return false;
    var Letra = val.charAt(0);
    if (LetrasCIF.indexOf(Letra) == -1) return false;
    if (Letra == 'P' || Letra == 'Q' || Letra == 'S') Organismo = true;
    if (!EsDigitos(val.substr(1,val.length-2))) return false;
    var CodigoControl = val.charAt(val.length-1)

    Suma1 = parseInt( val.charAt(2), 10) + parseInt( val.charAt(4), 10) + parseInt(val.charAt(6), 10 );
    Suma2 = 0;
    for( var i = 1; i < 8; i += 2) {
         Aux = parseInt(val.charAt(i), 10) * 2;
         if (Aux > 9) 
            Suma2 = Suma2 + parseInt(Aux / 10, 10) + Aux % 10
         else
            Suma2 = Suma2 + Aux;
    }
    Suma = Suma1 + Suma2;
    Codigo = 10 - Suma % 10;
    if( Codigo > 9) Codigo = 0;
    
    if (!Organismo) {
       if (Codigo != parseInt(CodigoControl, 10)) return false; }
    else {
       if (LetrasOrganismos.charAt(Codigo) != CodigoControl ) return false; }
    
    return true;
}

function EsNumerico(val) {
    num = parseFloat(val);
    if (val!=''+num) return false;
    return true;
}

function EsLetra(val) {
    return ( ((val >= "a") && (val <= "z")) || ((val >= "A") && (val <= "Z")) );
}

function EsDigito(val) {
    return ((val >= "0") && (val <= "9"));
}

function EsDigitos(val) {
    for(i=0;i<val.length;i++){
        if(!EsDigito(val.charAt(i))) return false;
    }
    return true;
}    
    
function EsRango(val,min,max) {
    if (!EsNumerico(val)) return false;
    if (val<min || max<val) return false;
    return true;
}

function MinCaracteres(val,num) {
    return !(val.length<num);
}

function EsTelefono(val) {
    if (!MinCaracteres(val,9)) return false;
    if (!EsDigitos(val)) return false;
    if (val.charAt(0)!="9") return false;
    return true;
}

function EsMovil(val) {
    if (!MinCaracteres(val,9)) return false;
    if (!EsDigitos(val)) return false;
    if (val.charAt(0)!="6") return false;
    return true;
}

function YY_checkform() { //v4.65
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(parseInt(myV))||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function sobre(src,Color) {
	  src.style.backgroundColor = Color;
}

function fuera(src,Color) {
	src.style.backgroundColor = Color;
}

function findPosX(varobj){
  var obj = document.getElementById(varobj);
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
		
	return curleft;
	
  }

  function findPosY(varobj){
  var obj = document.getElementById(varobj);
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
function mostrarCapaAdv2(varid,varVal,varPos,varX,varY){
	var idcapa = document.getElementById(varid);
	
	idcapa.style.top=varY;
	idcapa.style.left=varX;
	
	
	idcapa.style.visibility=varVal;
	idcapa.style.position=varPos;
}
function mostrarCapa(varid){
	var idcapa = document.getElementById(varid);
	
	idcapa.style.visibility='visible';
}

function mostrarCapaAdv(varid,varVal,varPos){
	var idcapa = document.getElementById(varid);
	
	idcapa.style.visibility=varVal;
	idcapa.style.position=varPos;
}