function tamanio(capa){
   switch (capa){
      case  0 : ancho=191; break;
      case  1 : ancho=286; break;
      case  2 : ancho=205; break;
      case  3 : ancho=142; break;
      case  4 : ancho=216; break;
      case  5 : ancho=212; break;
      case  6 : ancho=192; break;
      case  7 : ancho=212; break;
      case  8 : ancho=216; break;
      case 	9 : ancho=150; break;
      case 10 : ancho=216; break;
      case 11 : ancho=155; break;
      case 12 : ancho=118; break;
      case 13 : ancho=250; break;
      case 14 : ancho= 94; break;
      case 15 : ancho=250; break;
      case 16 : ancho=89; break;
      case 17 : ancho=250; break;
      case 18 : ancho=234; break;
      case 19 : ancho=124; break;
      case 20 : ancho=205; break;
      case 21 : ancho=133; break;
	  case 22 : ancho=250; break;
	  case 23 : ancho=150; break;
	  case 24 : ancho=286; break;
	  case 25 : ancho=286; break;
	  case 26 : ancho=261; break;
	  case 27 : ancho=250; break;
	  case 28 : ancho=250; break;
   }
}
var imgs = new Cargar;
function Cargar(){
   this[0] = "graficos/eroski.gif";
   this[1] = "graficos/correo.gif";
   this[2] = "graficos/cajavital.gif";
   this[3] = "graficos/ayuvitoria.gif";
   this[4] = "graficos/cajalaboral.gif";
   this[5] = "graficos/fournier.gif";
   this[6] = "graficos/formatia.gif";
   this[7] = "graficos/brasilena.gif";
   this[8] = "graficos/cajalaboral.gif";
   this[9]= "graficos/diputa.gif";
   this[10]= "graficos/cajalaboral.gif";
   this[11]= "graficos/mcdonalds.gif";
   this[12]= "graficos/iratik.gif";
   this[13]= "graficos/garoka.gif";
   this[14]= "graficos/kirol.gif";
   this[15]= "graficos/gorbea.gif";
   this[16]= "graficos/tvalava.gif";
   this[17]= "graficos/gorbea.gif";
   this[18]= "graficos/ibaya.gif";
   this[19]= "graficos/kaiku.gif";
   this[20]= "graficos/cajavital.gif";
   this[21]= "graficos/sanmar.gif";
   this[22]= "graficos/cegasa.jpg";
   this[23]= "graficos/alesa.gif";
   this[24] = "graficos/correo.gif";
   this[25] = "graficos/correo.gif";
   this[26] = "graficos/robleverde.gif";
   this[27] = "graficos/autocaravanas_norte.jpg";
   this[28] = "graficos/rgv.jpg";
}

var capap = Math.round(Math.random()*28);

function mover(){
   tamanio(capap);
   if (ns4){
      document.layers["LOGOS"].src = imgs[capap];
   }else{
      document.IMG_LOGOS.src = imgs[capap];
      document.IMG_LOGOS.width = ancho;
   }
   setInterval("movimiento()",20);
}

var posicionx = screen.width;
var a = -400;
var b = 5;
var subir = 1;
var ancho = 1;

function movimiento(){
   if (ns4){
      document.layers["LOGOS"].left = a;
      document.layers["AVION"].left = a + 300;
      document.layers["CUERDA"].left = a + 100;
      document.layers["CUERDA"].top = b + 20;
   }else if (ie4){
      document.all["LOGOS"].style.left = a;
      document.all["AVION"].style.left = a + 300;
      document.all["CUERDA"].style.left = a + 100;
      document.all["CUERDA"].style.top = b + 20;
   }else{
      document.getElementById("LOGOS").style.left = a;
      document.getElementById("AVION").style.left = a + 300;
      document.getElementById("CUERDA").style.left = a + 100;
      document.getElementById("CUERDA").style.top = b + 20;
   }
   MostrarCapa("LOGOS");
   MostrarCapa("AVION");
   MostrarCapa("CUERDA");
   if (a <= posicionx){
      if (a <= posicionx - 300){
         if (ns4){
            document.layers["AVION"].left = a + 300;
            document.layers["AVION"].top = b + 8;
            document.layers["CUERDA"].left = a + 100;
            document.layers["CUERDA"].top = b + 20;
         }else if (ie4){
            document.all["AVION"].style.left = a + 300;
            document.all["AVION"].style.top = b + 8;
            document.all["CUERDA"].style.left = a + 100;
            document.all["CUERDA"].style.top = b + 20;
         }else{
            document.getElementById("AVION").style.left = a + 300;
            document.getElementById("AVION").style.top = b + 8;
            document.getElementById("CUERDA").style.left = a + 100;
            document.getElementById("CUERDA").style.top = b + 20;
         }
      }else{
         OcultarCapa("AVION");
         if (ns4){
            document.layers["AVION"].left = -250;
            document.layers["CUERDA"].left = a + 100;
            document.layers["CUERDA"].top = b + 20;
         }else if (ie4){
            document.all["AVION"].style.left = -250;
            document.all["CUERDA"].style.left = a + 100;
            document.all["CUERDA"].style.top = b + 20;
         }else{
            document.getElementById("AVION").style.left = -250;
            document.getElementById("CUERDA").style.left = a + 100;
            document.getElementById("CUERDA").style.top = b + 20;
         }
         if (a > posicionx - ancho){
            OcultarCapa("CUERDA");
               if (ns4){
                  document.layers["CUERDA"].left = -350;
               }else if (ie4){
                  document.all["CUERDA"].style.left = -350;
               }else{
                  document.getElementById("CUERDA").style.left = -350;
               }
         }
	  }
      a = a + 3;
      b = b + subir / 2;
      if (b == 10) subir = -1;
      if (b == 1) subir = 1;
   }else{
      OcultarCapa("LOGOS");
      capap = Math.round(Math.random()*34);
      a = -400;
      tamanio(capap);
      if (ns4){
         document.layers["LOGOS"].left = a;
         document.layers["LOGOS"].src = imgs[capap];
      }else if (ie4){
         document.all["LOGOS"].style.left = a;
         document.IMG_LOGOS.width = ancho;
         document.IMG_LOGOS.src = imgs[capap];
      }else{
         document.getElementById("LOGOS").style.left = a;
         document.IMG_LOGOS.width = ancho;
         document.IMG_LOGOS.src = imgs[capap];
      }
   }
}
