// **** TACTICAS ****

document.write('<script type="text/javascript" src="demo/tacticas/ejercicios.txt"></script>')

TablaAT = new Array("#Areas#v1#")
TablaET = new Array("#Ejercicios#v1#")

function CAT(datos){
  datos=datos.split("|")
  na=TablaAT.length
  TablaAT[na]=new DatosCAT(na,datos)
}

function CET(datos){
  datos=datos.split("|")
  ne=TablaET.length
  TablaET[ne]=new DatosCET(ne,datos)
}

function DatosCAT(numero,datos){
  this.num     = numero
  this.tienda  = datos[0]
  this.carpeta = datos[1]
  this.titulo  = datos[2]
  this.menu    = datos[3]
}

function DatosCET(numero,datos){
  this.num      = numero
  this.tienda   = datos[0]
  this.carpeta  = datos[1]
  this.titulo   = datos[2]
  this.nombarch = datos[3]
  this.numflash = datos[4]
  this.fecha    = datos[5]
}

function MuestraTactica()
{
  ETHome=GetCookie("ETHome")
  if(ETHome)
  {
    datos=ETHome.split("|")
    ETHomeN=parseInt(datos[0])
    ETHomeF=new Date(datos[1])
  }
  else
  {
    ETHomeN=0
    ETHomeF=new Date()
  }

  ahora=new Date()
  marca=ETHomeF
  marca.setTime(marca.getTime()+(1*1*60*60*1000)) // 1 horas
  if(ETHomeN>0 && marca>ahora)
  {numero=ETHomeN}
  else
  {
    numero=ETHomeN+1
    largolista=TotalEjercicios()
    if(numero>largolista){numero=1}

    ETHome=numero+"|"+ahora
    caduca=new Date()
    caduca.setTime(caduca.getTime()+(365*24*60*60*1000))
    SetCookie("ETHome",ETHome,caduca,"/",null,null)
  }

  MuestraTacticaHome(numero)
}

function MuestraTacticaHome(numero)
{
  busejer=0
  for(numejer=1;numejer<TablaET.length;numejer++)
  if(TablaET[numejer].numflash>0){busejer=busejer+1;if(busejer==numero){break}}
  titu=TablaET[numejer].titulo
  carp=TablaET[numejer].carpeta
  arch=TablaET[numejer].nombarch

  for(numarea=1;numarea<TablaAT.length;numarea++)
  {if(TablaAT[numarea].carpeta==carp){break}}
  area=TablaAT[numarea].titulo

  html='<span>'
  html=html+'<img border="0" height="30" src="imagenes/logo.gif" alt="Ejercicios">'
  html=html+'<br>Entre en nuestra <b>Demo Gratuita</b>'
  html=html+'<br>de tácticas y aprenda más sobre...'
  html=html+'<a href="demo/tacticas/verejercicio.html?e='+carp+'|'+arch+'">'
  html=html+'<br><b>'+area+'<br>'+titu+'</b>'
  html=html+'</a></span>'

  document.write(html)
}

function TotalEjercicios()
{
  totejer=0
  for(qejer=1;qejer<TablaET.length;qejer++)
  {if(TablaET[qejer].numflash>0){totejer=totejer+1}}
  return totejer
}
