﻿info=[
    ['<span class="blue2"><b>- "♫ Chào mừng quý khách đến với siêu thị Rượu online 24h ♪" -</b></span>'],
    ['<span class="blue1">"Khuyến mãi đặc biệt: Giao hàng miễn phí *"</span>'],
    ['<span class="blue2">"Cám ơn quý khách đã đến với Rượu Online 24h"</span>'],
]
step=3
nextMessage=2

function initTSV1(){
    tsvDisplay=document.getElementById("scroll")

    for(var i=0;i<3;i++)
    {
        newDiv=document.createElement("DIV")
        newDiv.setAttribute("id","tsvdiv"+i)
        newDiv.onmouseover=function(){clearTimeout(timer)}
        newDiv.onmouseout=function(){scrollTSV1Left2Right()}
        newDiv.style.position="absolute"
        tsvDisplay.appendChild(newDiv)
    }

    tsvDv0=document.getElementById("tsvdiv0")
    tsvDv1=document.getElementById("tsvdiv1")
    tsvDv2=document.getElementById("tsvdiv2")
    tsvDv0.innerHTML=info[0]
    tsvDv1.innerHTML=info[1]
    tsvDv2.innerHTML=info[2]

    //tsvDv0.style.top=tsvDisplay.offsetHeight+"px"
    //tsvDv1.style.top=tsvDisplay.offsetHeight+tsvDv0.offsetHeight+"px"

    tsvDv0.style.left=tsvDisplay.offsetWidth+"px"
    tsvDv1.style.left=tsvDv0.offsetLeft+tsvDv0.offsetWidth+4+"px"
    tsvDv2.style.left=tsvDv1.offsetLeft+tsvDv1.offsetWidth+4+"px"

    scrollTSV1Left2Right()
}
function scrollTSV1Left2Right()
{
    tsvDv0Pos=parseInt(tsvDv0.style.left)
    tsvDv1Pos=parseInt(tsvDv1.style.left)
    tsvDv2Pos=parseInt(tsvDv2.style.left)
    
    tsvDv0Pos-=step
    tsvDv1Pos-=step
    tsvDv2Pos-=step
    
    tsvDv0.style.left=tsvDv0Pos+"px"
    tsvDv1.style.left=tsvDv1Pos+"px"
    tsvDv2.style.left=tsvDv2Pos+"px"
    if(tsvDv0Pos< -tsvDv0.offsetWidth)
    {
        nextMessage++
        if(nextMessage==info.length)
            {nextMessage=0}
        tsvDv0.innerHTML=info[nextMessage]
        tsvDv0.style.left = tsvDv2.offsetLeft+tsvDv2.offsetWidth+4+"px";
    }

    if(tsvDv1Pos< -tsvDv1.offsetWidth)
    {
        nextMessage++
        if(nextMessage==info.length)
            {nextMessage=0}
        tsvDv1.innerHTML=info[nextMessage]
        tsvDv1.style.left = tsvDv0.offsetLeft+tsvDv0.offsetWidth+4+"px";
    }
    if(tsvDv2Pos< -tsvDv2.offsetWidth)
    {
        nextMessage++
        if(nextMessage==info.length)
            {nextMessage=0}
        tsvDv2.innerHTML=info[nextMessage]
        tsvDv2.style.left = tsvDv1.offsetLeft+tsvDv1.offsetWidth+4+"px";
    }
    timer=setTimeout("scrollTSV1Left2Right()",50)
}

// add onload="initTSV1()" to the opening BODY tag

function GetImage(link, textbox)
{
    var _link = new String();
    var _textbox = new String();
    
   _link = link.toString();
   _textbox = textbox.toString();
   
    var _Return = new String();
    var WinSettings = "center:yes;resizable:no;dialogHeight:300px";
    
    _Return = window.showModalDialog(_link, WinSettings);
 
    return false;
}
function changeText(item, type)
{
    var _item = new String();
    var _type = new String();
    
    item = _item.toString();
    type = _type.toString();
    document.getElementById(item).className = type;
    return false;
}
function changeImg(but, img)
{
    var button = new String();
    var image = new String();
    
    button = but.toString();
    image = img.toString();
    document.getElementById(button).src = image;
    return false;
}

function elementCheck(elementID, StyleRef, styleValue)
{
    document.getElementById(elementID).style[StyleRef] = styleValue;
}

//call btnSearch's Click event when the Enter key is pressed.
//NOTE:  Have to include the javascript: OnKeyDown in every textbox in the form for this event to work properly.
function keyPress(evt) {
    if (evt.which || evt.keyCode) {
        if ((evt.which == 13) || (evt.keyCode == 13)) {
            location = document.getElementById('<% =btnSearch.ClientID %>').href;
            return false;
        }
        return true;
    }
}
