var ie4=document.all
var curindexO = 0
var timeShowO = 6000
var curindexN = 0
var timeShowN = 8000
var curindexG = 0
var timeShowG = 10000

function get_total(cual)
{
    var totalcontent = 0
    if (ie4)
        {while (eval("document.all." + cual + totalcontent)) totalcontent++}
    else
        {while (document.getElementById(cual + totalcontent)) totalcontent++}
    return totalcontent
}

function contract_all(cual, totalcontent)
{
    for (y = 0; y < totalcontent; y++)
        {if (ie4) eval("document.all." + cual + y).style.display="none"
         else document.getElementById(cual + y).style.display="none"}
}

function expand_one(which, cual, totalcontent)
{
    if (totalcontent > 0)
        if (ie4) eval("document.all." + cual + which).style.display=""
        else document.getElementById(cual + which).style.display=""
}

function rotate_content()
{
    rotate_oferta()
    rotate_recomendacion()
    rotate_Galeria()
}

function rotate_oferta()
{
    var totalcontent
    totalcontent = get_total("RecOfer")
    contract_all("RecOfer", totalcontent)
    expand_one(curindexO, "RecOfer", totalcontent)
    curindexO = (curindexO < totalcontent - 1)? curindexO + 1: 0
    setTimeout("rotate_oferta()", timeShowO)
}

function rotate_recomendacion()
{
    var totalcontent
    totalcontent = get_total("noticias")
    contract_all("noticias", totalcontent)
    expand_one(curindexN, "noticias", totalcontent)
    curindexN = (curindexN < totalcontent - 1)? curindexN + 1: 0
    setTimeout("rotate_recomendacion()", timeShowN)
}

function rotate_Galeria()
{
    var totalcontent
    totalcontent = get_total("Galeria")
    contract_all("Galeria", totalcontent)
    expand_one(curindexG, "Galeria", totalcontent)
    curindexG = (curindexG < totalcontent - 1)? curindexG + 1: 0
    setTimeout("rotate_Galeria()", timeShowG)
}
window.onload = rotate_content
