﻿// Archivo JScript
var alto=0;
var numCaracter=0;
var tipoScroll=1;
var continuar=true;

//establece desde que posicion va a empezar a subir el div con el texto
 function checkBrowser()
 {
    if (navigator.appName=="Microsoft Internet Explorer")
    {
        var size=document.getElementById("lblTipo").innerText;
        
        if (size==1)
        {
            document.getElementById("pieTicker").style.top="153px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="35%";
        }
        else if(size==2)
        {
            document.getElementById("pieTicker").style.top="55px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="60%";
        }
        else if(size==3)
        {
            document.getElementById("pieTicker").style.top="22px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="67%";
        }
        
    }
    else
    {
        var size=document.getElementById("lblTipo").innerHTML;
       
        if (size==1)
        {
            document.getElementById("pieTicker").style.top="153px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="120px";
        }
            
        else if(size==2)
        { 
            document.getElementById("pieTicker").style.top="55px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="300px";
        }
           
        else if(size==3)
        {
            document.getElementById("pieTicker").style.top="24px";
            document.getElementById("noticiasEnTuWeb").style.marginLeft="400px";
        }
    }
}
        
function iniciarAlto()
{
    var size=0;
    
    if (navigator.appName=="Microsoft Internet Explorer")
        size=document.getElementById("lblTipo").innerText;
    else
        size=document.getElementById("lblTipo").innerHTML;
 
    /*
        Size 1 = 320x165
        Size 2 = 500x70
        Size 3 = 600x37
        
        scroll = 1 (vertical)
        scroll = 2 (horizontal)
    */
    
    if (size==1)
    {
        alto=140;
        tipoScroll=1;
    }
        
    else if(size==2)
    {
        alto=500;
        tipoScroll=2;
    }
        
    else if(size==3)
    {
        alto=600;
        tipoScroll=2;
    }
    
}


function inicio()
{
    var size=document.getElementById("lblTipo").innerText;
    
    if (size!="")
    {
        checkBrowser();
        iniciarAlto(size);
        scrollea();
    }
    
}

//pausa la animacion (cuando el raton se situa sobre una noticia)
function pausar()
{
    continuar=false;
}


//reanuda la animacion (cuando el raton sale de la zona de una noticia)
function reanudar()
{
    continuar=true;
}


//hace la animacion de subir el div con el contenido
function scrollea()
{
    if (continuar==true)
    {
        if (tipoScroll==1)
        {   
                //scroll vertical
                if (alto==(document.getElementById("contenido").offsetHeight*-1))
                    iniciarAlto();
            
                alto--;
                document.getElementById("contenido").style.top=alto + "px";
        }
        else
        {
            //scroll vertical
            if (alto==(document.getElementById("contenido").offsetWidth*-1))
                iniciarAlto();
        
            alto--;
            document.getElementById("contenido").style.left=alto + "px";
        }    
        
    }
    
    if (tipoScroll==1)
        setTimeout('scrollea()',50);
    else
        setTimeout('scrollea()',15);
}


