
    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 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;
}

function cierraV() {
		setTimeout('window.close()',300);
}

function getFocus(){	
	var obj = window.document;
	obj.focus();
	
	setTimeout('getFocus()',1000);
}

function imprimir(){
	print();	
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function validarAcceso(frm){
	var msgErr = '';
	
	if (!EsEmail(frm.login.value)){msgErr+='Debe introducir su email de usuario.\n';}
	if (EsVacio(frm.pass.value)){msgErr+='Debe introducir su contraseña de usuario.';}
	
	if (!EsVacio(msgErr)){alert(msgErr);return false};
	
	return true;
}

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 openLayer(name,w,h,form){
	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 objLayer = document.getElementById(name);
	
	if (!EsVacio(form)){
		var objFrm = document.getElementById(form);
		
		for (i=0;i<objFrm.length;i++){
			switch (objFrm.elements[i].type) {
				case 'select-one':
					objFrm.elements[i].style.visibility='hidden';
					break;
				case 'submit':
					objFrm.elements[i].style.visibility='hidden';
					break;
			}
		}
	}
	
	objLayer.style.left = posx;
	objLayer.style.top = posy;
	objLayer.style.width = w;
	objLayer.style.height = h;
	objLayer.style.visibility = 'visible';
}

function closeLayer(name,form){
	var objLayer = document.getElementById(name);
	
	if (!EsVacio(form)){
		var objFrm = document.getElementById(form);
		
		for (i=0;i<objFrm.length;i++){
			switch (objFrm.elements[i].type) {
				case 'select-one':
					objFrm.elements[i].style.visibility='visible';
					break;
				case 'submit':
					objFrm.elements[i].style.visibility='visible';
					break;
			}
//			if (objFrm.elements[i].type=='select-one'){
		//		objFrm.elements[i].style.visibility='visible';
			//}
		}
	}
	
	objLayer.style.left = 0;
	objLayer.style.top = 0;
	objLayer.style.width = 0;
	objLayer.style.height = 0;
	objLayer.style.visibility = 'hidden';
}

function openWindowModeless(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;
	
	features = ",left="+posx+",top="+posy;
	var parameters = "scrollbars=no,center=yes;dialogHeight="+h+"px;dialogWidth="+w+"px;help=no;status=no;resizable=no";
	window.showModelessDialog(url, name, parameters + features);
}

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 EsVacio(val) {
    return ((val == null) || (val.length == 0));
}

function EsNumerico(val) {
    num = parseFloat(val);
    if (val!=''+num) return false;
    return true;
}

function EsNumber(val) {
    var num = new Number(val);
    num = parseFloat(num);
    if (''+num=='NaN') return false;
    return true;
}

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 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 ValidarTexto(texto){
    
    if ( texto.indexOf('@',0) != -1 || texto.indexOf(';',0) != -1
     || texto.indexOf(' ',0) != -1 || texto.indexOf('/',0) != -1
     || texto.indexOf(';',0) != -1 || texto.indexOf('<',0) != -1
     || texto.indexOf('>',0) != -1 || texto.indexOf('*',0) != -1
     || texto.indexOf('|',0) != -1 || texto.indexOf('`',0) != -1
     || texto.indexOf('&',0) != -1 || texto.indexOf('$',0) != -1
     || texto.indexOf('!',0) != -1 || texto.indexOf('"',0) != -1
     || texto.indexOf(':',0) != -1 || texto.indexOf("'",0) != -1
     || texto.indexOf(',',0) != -1)
       { return false; }
    
    return true;
}

function openWindowPos(url,name,w,h,sc,varX,varY){
		
	var parameters = 'left='+varX+',top='+varY+',height='+h+',width='+w+',scrollbars='+sc;
	window.open(url,name,parameters);	
}


function openCalendar(varX,varY,varCampo,varFecha){
	args = openCalendar.arguments;
	
	window.open('admin/calendario/calendario.asp?Campo='+varCampo+'&Fecha='+varFecha+'&nolimit='+args[4],'calendar','left='+varX+',top='+varY+',height=140,width=145');
}
function openCalendarAdmin(varX,varY,varCampo,varFecha){
	args = openCalendarAdmin.arguments;
	
	window.open('calendario/calendario.asp?Campo='+varCampo+'&Fecha='+varFecha+'&nolimit='+args[4],'calendarAdmin','left='+varX+',top='+varY+',height=140,width=145');
}

function openCalendarSMS(varX,varY,varCampo,varFecha){
	window.open('calendario.asp?Campo='+varCampo+'&Fecha='+varFecha+'&nolimit=','calendar','left='+varX+',top='+varY+',height=140,width=145');
}

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 MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe ser un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe ser un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
  } if (errors) alert('se han producido los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

function sobre(src,Color,textColor,Cursor) {
	  src.style.cursor = Cursor;
	  src.style.backgroundColor = Color;
	  src.Color = textColor;
}

function fuera(src,Color,textColor,Cursor) {
	src.style.cursor = Cursor;
	src.style.backgroundColor = Color;
	src.Color = textColor;
}

function sobreADV(idsrc,Color,Cursor) {
	  var src = document.getElementById(idsrc);
	  
	  src.style.cursor = Cursor;
	  src.style.backgroundColor = Color;
}

function fueraADV(idsrc,Color,Cursor) {
	var src = document.getElementById(idsrc);
	
	src.style.cursor = Cursor;
	src.style.backgroundColor = Color;
}

function sobreADV2(src,Color,Cursor) {	  
	  src.style.cursor = Cursor;
	  src.style.backgroundColor = Color;
}

function fueraADV2(src,Color,Cursor) {
	src.style.cursor = Cursor;
	src.style.backgroundColor = Color;
}

function EsIP(val) {
  	var tblIPSNulas = new Array('127.0.0.1','255.255.255.0','255.255.255.255','0.0.0.0');
	if(EsVacio(val)) return false;
	
	sArray = val.split(".");
	if (sArray.length != 4) return false;
	if( (!EsNumerico(sArray[0])) || (!EsNumerico(sArray[1])) 
	|| (!EsNumerico(sArray[2])) || (!EsNumerico(sArray[3])) ) return false;
	if( (parseFloat(sArray[0])>255) || (parseFloat(sArray[1])>255) 
	|| (parseFloat(sArray[2])>255) || (parseFloat(sArray[3])>255) ) return false;
	if( (parseFloat(sArray[0])<0) || (parseFloat(sArray[1])<0) 
	|| (parseFloat(sArray[2])<0) || (parseFloat(sArray[3])<0) ) return false;
	
	for (var i=0;i<tblIPSNulas.length;i++){
		if (val==tblIPSNulas[i]){return false;}
	}
	
	return true;
}

function EsDominio(val) {
	if(EsVacio(val)) return false;
	
	sArray = val.split(".");
	if (sArray.length != 2) return false;
	if (!ValidarTexto(sArray[0])) return false;
	if (!ValidarTexto(sArray[1])) return false;
	if ( (sArray[0].length<=0) || (sArray[1].length<=1) ) return false;
		
	return true;
}

function selecionaTodosLista(objLista){
	for (i=0;i<=(objLista.length-1);i++){
		objLista.options[i].selected = true;
	}
}

function cambiaImagen(img, src){
	img.src = src;
}

function cambiaImagenADV(obj, src){
	var img = document.getElementById(obj);
	img.src = src;
}

function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=30
}

function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function confirmarCambioEstado(){
	if (confirm('Se dispone a cambiar el estado del pedido.\n\n¿Desea continuar?')){
		return true;
	}
	
	return false;
}

function confirmarVaciar(){
	if (confirm('Se dispone a vaciar la cesta de compra.\n\n¿Desea continuar?')){
		document.location='cestavacia.asp';
	}
}

function confirmarSalir(){
	if (confirm('Se dispone a cerrar la sesión de usuario.\n\n¿Desea continuar?')){
		document.location='salir.asp';
	}
}

function confirmarBorrar(){
	if (confirm('Se dispone a eliminar un registro.\n\n¿Desea continuar?')){
		return true;
	}
	
	return false;
}

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=='0000')&&(CS.value='0000')&&(CC.value='0000000000')&&(CD.value='00')){
	alert("La cuenta introducida no es valida.");
	return false;
	}

  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 muestraBuscar(objlink){
	var frm = document.getElementById(objlink);
	alert(objlink);
	
	switch (frm.style.position) {
	case 'absolute':
		//objlink.innerText = '[-]';
		frm.style.position = 'static';
		frm.style.visibility = 'visible';
		break;
	case 'static':
		//objlink.innerText = '[+]';
		frm.style.position = 'absolute';
		frm.style.visibility = 'hidden';
		break;
	}
}


function borrar(){
	return confirm('Se dispone ha borrar un registro de la Dase de Datos\n\n¿Desea continuar?');
}

function borrarReferencia(){
	return confirm('Se dispone ha borrar una referencia de la Dase de Datos\nEsta acción borrará todas las relaciones con proveedores.\n\n¿Desea continuar?');
}

function establecePrecios(objPrecio){
	objPrecio.value = objPrecio.value.replace(',','.');
}

function colorIn(obj){
	obj.style.backgroundColor = '#AACDF8';
}

function colorOut(obj){
	obj.style.backgroundColor = '';
}

//***********************************************************************

function update(idobj){
	BgFade(document.getElementById(idobj),0xff,0xff,0xff, 0x32,0x83,0xd6,10);
	
	setTimeout('update(\''+idobj+'\')',1000); 
}

var sred,ered,inc,step,obj
 function BgFade(iobj,red1, grn1, blu1, red2,
 grn2, blu2, steps) {
 sred = red1; sgrn = grn1; sblu = blu1; 
 ered = red2; egrn = grn2; eblu = blu2; 
 inc = steps; 
 step = 0; 
 obj = iobj;
 RunFader();
 }
  
 function RunFader() {
 var epct = step/inc; 
 var spct = 1 - epct;
 obj.bgColor =
 Math.floor(sred * spct + ered *
 epct)*256*256 +
 Math.floor(sgrn * spct + egrn * epct)*256 +
 Math.floor(sblu * spct + eblu * epct); 
 
 if ( step < inc ) {
 setTimeout('RunFader()',25); 
 }
 step++;
 }