var ar = new Array(
'<P CLASS="color"><A CLASS=banner HREF="http://www.oei.es/" TARGET="_blank">Organización de Estados Iberoamericanos <BR>OEI</A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.mec.es/sgpe/socrates" TARGET="_blank">Agencia Espa&ntilde;ola S&oacute;crates</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.iale.es" TARGET="_blank">IALE S.L.</A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.darelsadaka.com" TARGET="_blank">Dar el Sadaka</A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.miomaembolizacion.com/" TARGET="_blank">Miomaembolización</A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.gmr.ssr.upm.es" TARGET="_blank">Grupo de Microondas y Radar (ETSI Telecomunicaci&oacute;n UPM)</A>', 
'<P CLASS="color"><A CLASS="banner" HREF="http://www.mec.es/sgpe/" TARGET="_blank">Subdirecci&oacute;n General de Programas Europeos</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.grupoargo.org" TARGET="_blank">Grupo Argo</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.cigarsantander.com" TARGET="_blank">CigarSantander</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.ortosol.com" TARGET="_blank">Ortosol S.L.</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.afs-intercultura.org" TARGET="_blank">AFS Intercultura</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.terra.es" TARGET="_blank">Fundaci&oacute;n Telef&oacute;nica para el Deporte (Terra)</A>',
'<P CLASS="color"><A CLASS="banner" HREF="galeriammacias/index.html" TARGET="_blank">Galer&iacute;a Manuel Mac&iacute;as</A>',
'<P CLASS="color"><A CLASS="banner" HREF="http://www.centro-odontologico.com" TARGET="_blank">Centro Odontol&oacute;gico C. Zorita</A>',
//'<A HREF="carlosmacias/index.html">Carlos Mac&iacute;as: Modelo y actor</A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.oeibrpt.org" TARGET="_blank">Organiza&ccedil;&atilde;ç dos Estados Ibero-americanos </A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.iberformat.org" TARGET="_blank">Iberformat </A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.anima-dos.com" TARGET="_blank">Anima-dos </A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.cerrajerias-fagon.com" TARGET="_blank">Cerrajerías FAGON </A>',
'<P CLASS="color"><A CLASS=banner HREF="http://www.a2mix.com" TARGET="_blank">A2mix </A></P>'
//<P CLASS="texto">Nuestros trabajos:</P>
//<P CLASS="texto"><A HREF="radiacion/index.html" TARGET="asenmac">Efectos de la Radiaci&oacute;n en la salud</A><BR>
//<A HREF="tvdigital/index.html" TARGET="asenmac">Televisi&oacute;n Digital Terrenal</A><BR>
//<A HREF="tvdigital2/index.html" TARGET="asenmac">Televisi&oacute;n Digital Terrenal 2</A><BR>
//<A HREF="sinformacion.htm" TARGET="asenmac">Sociedad de la Informaci&oacute;n</A><BR>
//<A HREF="busca.htm" TARGET="asenmac">Buscador </A></P>
//</P>
  );

var NS4 = (document.layers) ? true : false;
var IE4 = (document.all) ? true : false;

var bannerLeft, bannerTop, bannerWidth, bannerHeight;

var interval = 50;      // velocidad del texto
var increment = 3;   //
var pause = 4000;  // tiempo de espera en milisegundos
// var bannerColor = "#C9A470";
var bannerColor = "#FFFFFF";
var leftPadding = 1;
var topPadding = 1;


onload = startBanner;

function showMessage(n, show) {
  var whichEl = (NS4) ? eval("message" + n) :
                        eval("message" + n + ".style");
  whichEl.visibility = (show) ? ((NS4) ? "show" : "visible") :
                                ((NS4) ? "hide" : "hidden");
}

function nextMessage() {
  var fromInd = current;
  current = (fromInd == ar.length - 1) ? 0 : fromInd + 1;
  scrollBanner(fromInd, current);
}

function moveUp() {
  if (NS4) {
    fromEl.top -= increment;
    if (toEl.top - increment <= toElTarget) {
      toEl.top = toElTarget;
      clearInterval(intervalID);
      fromEl.visibility = "hide";
      timeoutID = setTimeout("nextMessage()", pause);
    } else {
      toEl.top -= increment;
    }
  } else {
    fromEl.pixelTop -= increment;
    if (toEl.pixelTop - increment <= toElTarget) {
      toEl.pixelTop = toElTarget;
      clearInterval(intervalID);
      fromEl.visibility = "hidden";
      timeoutID = setTimeout("nextMessage()", pause);
    } else {
      toEl.pixelTop -= increment;
    }
  }
}

function scrollBanner(from, to) {
  if (NS4) {
    fromEl = eval("message" + from);
    toEl = eval("message" + to);
    toEl.top = fromEl.top + bannerHeight;
    toElTarget = fromEl.top;
  } else {
    fromEl = eval("message" + from + ".style");
    toEl = eval("message" + to + ".style");
    toEl.pixelTop = fromEl.pixelTop + bannerHeight;
    toElTarget = fromEl.pixelTop;
  }
  showMessage(to, true); // show the upcoming message
  intervalID = setInterval("moveUp()", interval);
}

function makeIE() {
  // assign the necessary code to a variable
  var text = '<DIV ID="banner" STYLE="position:absolute">';
  for (var i = ar.length - 1; i >= 0; i--) {
    text += '<DIV ID="message' + i +
            '" STYLE="position:absolute"></DIV>';
  }
  text += '</DIV>';

  // insert the code before the end of the document
  document.body.insertAdjacentHTML("BeforeEnd", text);

  // define the main element's properties
  with (banner.style) {
    width = bannerWidth;
    height = bannerHeight;
    clip = "rect(0 " + bannerWidth + " " + bannerHeight + " 0)";
    backgroundColor = bannerColor;
    pixelLeft = bannerLeft;
    pixelTop = bannerTop;
  }

  // define the child elements' properties
  for (i = 0; i < ar.length; i++) {
    with (eval("message" + i + ".style")) {
      visibility = "hidden";
      pixelLeft = leftPadding;
      pixelTop = topPadding;
      width = bannerWidth - leftPadding;
      backgroundColor = bannerColor;
    }
  }
}

function makeNS() {
  // create the main element
  banner = new Layer(bannerWidth);

  // define the main element's properties
  with (banner) {
    clip.right = bannerWidth;
    clip.bottom = bannerHeight;
    document.bgColor = bannerColor;
    left = bannerLeft;
    top = bannerTop;
    visibility = "show";
  }

  // define the child elements' properties
  for (var i = 0; i < ar.length; i++) {
    // create a child element
    eval("message" + i + " = " +
         "new Layer(bannerWidth - leftPadding, banner)");
    with(eval("message" + i)) {
      visibility = "hide";
      left = leftPadding;
      top = topPadding;
      document.bgColor = bannerColor;
    }
  }
}

function fillBanner() {
  var whichEl;
  if (NS4) {
    for (var i = 0; i < ar.length; i++) {
      whichEl = eval("message" + i);
      whichEl.document.write(ar[i]);
      whichEl.document.close();
    }
  } else {
    for (var i = 0; i < ar.length; i++) {
      whichEl = eval("message" + i);
      whichEl.innerHTML = ar[i];
    }
  }
}

function startBanner() {

	bannerLeft = (NS4) ? document.images.noticia.x :  noticia.offsetLeft;
 	bannerTop = (NS4) ? document.images.noticia.y :  noticia.offsetTop;
	bannerWidth = (NS4) ? document.images.noticia.width :  noticia.width;
	bannerHeight = (NS4) ? document.images.noticia.height :  noticia.height+10;

  if (NS4)
      makeNS()
  else
      makeIE();

  fillBanner();
  showMessage(0, true);
  current = 0;
  timeoutID = setTimeout("nextMessage()", pause);
}



