// JavaScript Document

// Scroll noticias dinámico
var ancho = 140 //anchura del cuadro
var alto = 120 //altura del cuadro
var marco = 0 //escribe 0 si no quieres borde
var fondo = '#242424' //color de fondo del cuadro
var pausilla = 2000 //tiempo de la pausa entre noticia en milisegundos (2000 = 2 segundos)
var destino = "_blank" //_blank para abrir enlaces en nueva ventana, _self en la misma.
var cursor = "default;"
var colTitular = '#FFCC00' //color del texto del titular
var colTexto = '#FFCC66' // color del texto de la noticia
var colFecha = '#FF9933' //color del texto de la fecha
var colEnlace = '#CC0000' //color del texto del enlace
var fuente = "arial" //fuente para los todos los textos
var tamTitular = '14' //tamaño de la fuente del titular
var tamTexto = '12' //tamaño de la fuente del texto de la noticia
var tamFecha = '10' // tamaño de la fuente de la fecha
var tamEnlace = '11' // tamaño de la fuente del enlace
var masInfo = true //Determina si se usa o no el enlace. true para usarlo. false para omitirlo
var poneFecha = true //true para poner fecha. false para omitirla. Si no se quiere fecha, dejar las comillas vacías ""

function noticia(titular,texto,fecha,enlace,destino){
this.titular = titular
this.texto = texto
this.fecha= fecha
this.enlace = enlace
this.destino = destino
}
var noticias = new Array()

noticias[0]= new noticia("Nueva Web","La Escuadrilla Gurú estrena sitio","14/04/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showforum=94","_blank")
noticias[1]= new noticia("Comic Machito de Kimpó","Los Machitos de Kimpó en acción","07/07/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=34300","_blank")
noticias[2]= new noticia("Skin para los Machito de Kimpó","Skin creado por Kie especialmente para la escuadrilla","10/05/2009","http://www.escuadron69.net/v20/foro/index.php?s=4caf3d40d0ef84c32fca81a308a4cde7&showtopic=31665","_blank")
noticias[3]= new noticia("Condecoraciones Gurú","Los últimos valientes pilotos Gurú en conseguir sus premios","10/05/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=33651","_blank")
noticias[4]= new noticia ("JDAM: Técnica Avanzada","Magistral mini manual de Ender explicando su uso","28/06/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=34932","_blank")
noticias[5]= new noticia ("Técnica Avanzada SEAD","Localización y destrucción con GBUs y Mavs","08/06/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=34410","_blank")
noticias[6]= new noticia("Tácticas De Interceptación Aire Aire","Correcaminos en estado puro","14/05/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=33750","_blank")
noticias[7]= new noticia("Gurú: La escuadrilla","Todo lo que necesitas saber sobre los Gurús","03/05/2009","http://www.escuadron69.net/v20/foro/index.php?s=22f374abf2eceb60bbc6dfcf17f80332&showtopic=33465","_blank")

var det = false
function escribe(){
document.write ('<div id="mami" style="width:' + ancho + 'px; height:' + alto + 'px; position:relative; overflow:hidden ">')
document.write('<table bgcolor="' + fondo + '" border = "' + marco + '" width="' + ancho + 'px" height="100%"><tr><td valign="top">')
document.write ('<div id="uno" style="top:' + alto +'px; width:' + ancho + 'px; height:' + alto + 'px; ">')
document.write ('<div class="titular">')
document.write (noticias[0].titular)
document.write ('</div>')
document.write ('<div class="fecha">')
document.write (noticias[0].fecha)
document.write ('</div>')
document.write ('<div class="texto">')
document.write (noticias[0].texto)
document.write ('</div>')
if(masInfo == true){
document.write ('<a class="enlace" href="')
document.write (noticias[0].enlace)
document.write ('" target="' + destino + '">Más información</a>')
}
document.write ('</div>')
document.write ('<div id="dos" style="top:' + (alto*2) +'px; width:' + ancho + 'px; height:' + alto + 'px; ">')
document.write ('<div class="titular">')
document.write (noticias[1].titular)
document.write ('</div>')
document.write ('<div class="fecha">')
document.write (noticias[1].fecha)
document.write ('</div>')
document.write ('<div class="texto">')
document.write (noticias[1].texto)
document.write ('</div>')
if(masInfo == true){
document.write ('<a class="enlace" href="')
document.write (noticias[1].enlace)
document.write ('" target = "' + destino + '">más información...</a>')
}
document.write ('</div>')
document.write('</td></tr></table>')
document.write ('</div>')
if(navigator.appName == "Netscape")
{altoUno = document.getElementById('uno').offsetHeight}
else
{altoUno = document.getElementById('uno').clientHeight}
document.getElementById('uno').onmouseover =function(){
det = true
clearTimeout(tiempo)
}
document.getElementById('uno').onmouseout =function(){
det = false;
clearTimeout(tiempo)
escrolea()
}

document.getElementById('dos').onmouseover =function(){
det = true
clearTimeout(tiempo)
}
document.getElementById('dos').onmouseout =function(){
det = false;
clearTimeout(tiempo)
escrolea()

}
}
desp = 1
var cont = 1
var pos,pos2
function escrolea(){
pos = document.getElementById('uno').style.top
pos = pos.replace(/px/,"");
pos = pos.replace(/pt/,"");
pos = new Number(pos);
pos2 = document.getElementById('dos').style.top
pos2 = pos2.replace(/px/,"");
pos2 = pos2.replace(/pt/,"");
pos2 = new Number(pos2);
pos -= desp
pos2 -= desp

if (pos == desp){
var contenidos = ""
document.getElementById('dos').style.top = alto + "px"
document.getElementById('dos').childNodes[0].firstChild.nodeValue = noticias[cont].titular
if(poneFecha == true){
document.getElementById('dos').childNodes[1].firstChild.nodeValue = noticias[cont].fecha
}
document.getElementById('dos').childNodes[2].firstChild.nodeValue = noticias[cont].texto
if(masInfo == true){
document.getElementById('dos').childNodes[3].href = noticias[cont].enlace
}
document.getElementById('uno').style.top = 0
if(cont == noticias.length-1)
{cont=0}
else{
cont++
}
pausa()
return false
}
else{
if (pos2 == desp){
var contenidos = ""
document.getElementById('uno').style.top = alto + "px"
document.getElementById('uno').childNodes[0].firstChild.nodeValue = noticias[cont].titular
if(poneFecha == true){
document.getElementById('uno').childNodes[1].firstChild.nodeValue = noticias[cont].fecha
}
document.getElementById('uno').childNodes[2].firstChild.nodeValue = noticias[cont].texto
if(masInfo == true){
document.getElementById('uno').childNodes[3].href = noticias[cont].enlace
}
document.getElementById('dos').style.top = 0
if(cont == noticias.length-1)
{cont=0}
else{
cont++
}
pausa()
return false
}
else{
document.getElementById('uno').style.top = pos + "px"
document.getElementById('dos').style.top = pos2 + "px"
}
}
tiempo = window.setTimeout('escrolea()',50)
}
var tiempo
function pausa()
{
clearTimeout(tiempo)
if (det == false){
tiempo = setTimeout ('continuar()',2000)
}
}
function continuar()
{
if(det == false)
{escrolea()}
}

document.write('<style type="text/css">')
document.write ('#uno {')
document.write ('color: #006699;')
if(cursor == "pointer" || cursor == "hand"){
cursor = (navigator.appName == "Netscape")?'pointer;':'hand;';
}
document.write ('cursor:' + cursor + ";")
document.write ('position:absolute;}')
document.write ('#dos {')
document.write ('color: #006699;')
document.write ('cursor:' + cursor + ";")
document.write ('position:absolute;}')
document.write ('.titular{')
document.write ('color:' + colTitular +';')
document.write ('font-family:' + fuente + ';')
document.write ('font-size :' + tamTitular + 'px;font-weight:bold}')
document.write ('.texto{')
document.write ('color:' + colTexto + ';')
document.write ('font-family:' + fuente + ';')
document.write ('font-size:' + tamTexto + 'px;}')
if(poneFecha == true){
document.write ('.fecha{')
document.write ('color:' + colFecha +';')
document.write ('font-family:' + fuente + ';')
document.write ('font-size :' + tamFecha + 'px;font-weight:bold}')
}
else{
document.write ('.fecha{display: none;}')
}
document.write ('.enlace{')
document.write ('color:' + colEnlace + ';')
document.write ('font-family:' + fuente + ';')
document.write ('font-size:' + tamEnlace + 'px;}')
document.write ('</style>')

//Otra función. Texto en la barra

var speed = 50 
var pause = 1500
var timerID = null
var bannerRunning = false
var ar = new Array()
ar[0] = "El Escuadrón69 y..."
ar[1] = "...el Ala Falcon..."
ar[2] = "presentan:..."
ar[3] = "ESCUADRILLA GURÚ"
ar[4] = "El Hogar de los Machitos de Kimpó"
var currentMessage = 0
var offset = 0
function stopBanner() {
if (bannerRunning)
clearTimeout(timerID)
bannerRunning = false
}
function startBanner() {
stopBanner()
showBanner()
}
function showBanner() {
var text = ar[currentMessage]
if (offset < text.length) {
if (text.charAt(offset) == " ")
offset++ 
var partialMessage = text.substring(0, offset + 1) 
window.status = partialMessage
offset++ // IE sometimes has trouble with "++offset"
timerID = setTimeout("showBanner()", speed)
bannerRunning = true
} else {
offset = 0
currentMessage++
if (currentMessage == ar.length)
currentMessage = 0
timerID = setTimeout("showBanner()", pause)
bannerRunning = true
}
}

//Otra funcion. Mandar Emilio

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+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
  //alert(document.form1.email.value);
}

//Otra funcion