var meses = new Array ();
meses[01] = "Enero";
meses[02] = "Febrero";
meses[03] = "Marzo";
meses[04] = "Abril";
meses[05] = "Mayo";
meses[06] = "Junio";
meses[07] = "Julio";
meses[08] = "Agosto";
meses[09] = "Septiembre";
meses[10] = "Octubre";
meses[11] = "Noviembre";
meses[12] = "Diciembre";

var resultado="";
var IE4 = (document.all) ? 1 : 0;

(document.all) ? document.write('<link rel=stylesheet type="text/css" href="../2065/estilo.css">') : document.write('<link rel=stylesheet type="text/css" href="../2065/estilon.css">')

// Funcion para redireccionar
function redirFrames(dire){
	parent.rightFrame.location=dire; 
}


// Funcion submite del formulario cliente
function SubmiteForm(operacion) {
if (operacion=="9845C")
   {
	document.Cliente.NUMPLANTIL.value=document.Cliente.PLANTILLA.options.length;
	document.Cliente.SECPLANTIL.value=document.Cliente.PLANTILLA.options[document.Cliente.PLANTILLA.selectedIndex].value;
	}

if (operacion=="5852C")
   {
    nif = document.Cliente.NIF.value;
	document.Cliente.NIF.value = nif.toUpperCase();
	}
   document.Cliente.OPERACION.value=operacion;
   document.Cliente.submit();
}

function SubmiteFormTrans(operacion,operacreal) 
/* usese esta funcion para ejecutar operaciones transparentes. Establece adecuadamente los valores de OPERACREAL y de OPERACION, que se pasan como parametros */
{
if (operacion=="9845C")
   {
	document.Cliente.NUMPLANTIL.value=document.Cliente.PLANTILLA.options.length;
	document.Cliente.SECPLANTIL.value=document.Cliente.PLANTILLA.options[document.Cliente.PLANTILLA.selectedIndex].value;
	}
if (operacreal=="7145") {
  if (operacion=="1004C") {
    if (document.Cliente.MODELO.value != "SIR") {
      var just = document.Cliente.JUSTIFICANTE.value;
      if (just != "") {
        just = just.substring(0,3);
        if (just != document.Cliente.MODELO.value){
          alert("Error: El número de justificante no pertenece al modelo seleccionado.");
          return false;
        }
      }
      else {
        alert("Error: No ha introducido el número del justificante.");
        return false;
      }
    }
  }
  else {
    var aux = document.Cliente.GCUENTA.value.substring(0,2)+"2065"+document.Cliente.GCUENTA.value.substring(2,6)+document.Cliente.GCUENTA.value.substring(10,22);
    document.Cliente.GCUENTA.value = aux;
  }
}

   document.Cliente.OPERACION.value=operacion;
   document.Cliente.OPERACREAL.value=operacreal;
   document.Cliente.submit();
}

// Funcion que dibuja el menu inferior, de las distintas opciones

function Menu(nombre,tipo,barra){
var tablero="";
var auxtablero="";
var auxtablero2="";
    for(x=0;x<nombre.length;x++)
    {
	auxtablero2=nombre[x].split("|")[1];
        auxtablero=auxtablero2.split("javascript:")[1];	
//	tablero+='<a href='+ nombre[x].split("|")[1]+' class=' + tipo + '>' + nombre[x].split("|")[0]+ '</a>';
	if (auxtablero == auxtablero2)
		tablero+='<a href='+ nombre[x].split("|")[1]+' class=' + tipo + '>' + nombre[x].split("|")[0]+ '</a>';
	else
		tablero+='<a href="#" onclick="'+ auxtablero +'; return false;" class=' + tipo + '>' + nombre[x].split("|")[0]+ '</a>';
	(x==(nombre.length-1))?void(null):tablero+='<span class='+barra+'>&nbsp;&brvbar;</span>';
	tablero+='\r';
    }
    if(IE4)	tablero+='<br>';
    resultado=tablero;
}
// Funcion que abre una ventana 

function ventana(Pagina,Ancho,Alto,Scroll)
{
window.open(Pagina,'','toolbar=no,location=no,directories=no,status=no,scrollbars=' + Scroll + ',resizable=yes,copyhistory=yes,width=' + Ancho + ',height=' + Alto + ',top=0,left=0');
}

function ventana2(Pagina,Ancho,Alto,Scroll)
{
window.open(Pagina,'CajaCanarias','toolbar=no,location=no,directories=no,status=no,scrollbars=' + Scroll + ',resizable=yes,copyhistory=yes,width=' + Ancho + ',height=' + Alto + ',top=0,left=0');
}
// Funcion que pasa el string de entrada a minusculas

function up2low(str)
	{
  var nombre1="", nombre2="", nombre3="", nombre4="", aux="";

    str = str.toLowerCase();
    if ( nombre1=str.split(" ")[0]) {
	    aux = nombre1.substring(0,1);
  	  aux = aux.toUpperCase();
    	nombre1=aux + nombre1.substring(1,nombre1.length);
      document.write(nombre1); 
      document.write(" ");
    }

	  if ( nombre2=str.split(" ")[1]) {
	    aux = nombre2.substring(0,1);
  	  aux = aux.toUpperCase();
    	nombre2=aux + nombre2.substring(1,nombre2.length);
      document.write(nombre2); 
      document.write(" ");
    }

	  if ( nombre3=str.split(" ")[2]) {
	    aux = nombre3.substring(0,1);
  	  aux = aux.toUpperCase();
    	nombre3=aux + nombre3.substring(1,nombre3.length);
      document.write(nombre3); 
      document.write(" ");
	  }

	  if ( nombre4=str.split(" ")[3]) {
	    aux = nombre4.substring(0,1);
  	  aux = aux.toUpperCase();
    	nombre4=aux + nombre4.substring(1,nombre4.length);

      document.write(nombre4); 
      document.write(" ");
	  }    
	}
// Funcion que imprime el numero de entrada

function imprimeccc(str) {
var caja="", cuenta="",dc="",oficina="";

   cuenta = str.substring(str.length-10, str.length);
   dc = str.substring(str.length-12, str.length-10);
   oficina = str.substring(str.length-16, str.length-12);
   caja = "2065";

   document.write(''+caja+' '+oficina+' '+dc+' '+cuenta+'');
}

function abre2(sCual,iAncho,iAlto,sScroll, Arriba, Derecha)
{
    window.open(sCual,'pepe','toolbar=no,location=no,directories=no,status=yes,scrollbars=' + sScroll + ',resizable=no,copyhistory=yes,width=' + iAncho + ',height=' + iAlto + ',top= ' + Arriba + ',left=' + Derecha + '');
}

function ventana2(Pagina,Ancho,Alto,Scroll)
{
window.open(Pagina,'','toolbar=no,location=no,directories=no,status=no,scrollbars=' + Scroll + ',resizable=yes,copyhistory=yes,width=' + Ancho + ',height=' + Alto + ',top=0,left=0');
}

function redirSelect(dire,frame){
  if (frame == 0)
    window.open(dire);
  else
    if (dire.indexOf("window.open") == -1)
	    frame.location=dire;
    else
	    window.open(dire);
}
