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 EsNumerico(val) {
    num = parseFloat(val);
    if (val!=''+num) 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 openCalendar(varX,varY,varCampo,varFecha){
	args = openCalendar.arguments;
	window.open('../calendario/calendario.asp?Campo='+varCampo+'&Fecha='+varFecha+'&nolimit='+args[4],'calendar','left='+varX+',top='+varY+',height=140,width=145');
}

function openCalendar2(varX,varY,varCampo,varFecha){
	args = openCalendar2.arguments;
	
	window.open('calendario/calendario.asp?Campo='+varCampo+'&Fecha='+varFecha+'&nolimit='+args[4],'calendar','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 estiloMano(id){
	var obj = document.getElementById(id);
	obj.style.cursor='hand';
}

function sobre(src,Color) {
   
   // if (!src.contains(event.fromElement)) {
	  src.style.cursor = 'hand';
	  src.style.backgroundColor = Color;
	  //src.style.color = '#ffffff';
	//}
}

function fuera(src,Color) {
	//if (!src.contains(event.toElement)) {
	  src.style.cursor = 'default';
	  src.style.backgroundColor = Color;
	//}
}

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('frmbuscar');
	
	switch (objlink.innerText) {
	case '[+]':
		objlink.innerText = '[-]';
		frm.style.position = 'static';
		frm.style.visibility = 'visible';
		break;
	case '[-]':
		objlink.innerText = '[+]';
		frm.style.position = 'absolute';
		frm.style.visibility = 'hidden';
		break;
	}
}

//***********************************************************************

function update(idobj){
	BgFade(document.getElementById(idobj),0x00,0x00,0x00, 0xff,0xff,0xff,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++;
 }