﻿
var vtWidth='163px';                  // width (in pixels)
var vtHeight='600px';                  // height (in pixels)
var vmoStop=true;                     // pause on mouseover (true or false)
//var fontfamily = 'simHei, pMingLiu'; // font for content
var vtSpeed=2;                        // scroll speed (1 = slow, 5 = fast)
var vtDirectionIsTop = true;         // start direction
var vitemHeight = '320px';
var vwaitTime = 20;
var vitemHeightArr = new Array(0);

// enter your ticker content here (use \/ and \' in place of / and ' respectively)
var vcontent='Are you looking for loads of useful information <a href="http:\/\/javascript.about.com\/">About Javascript<\/a>? Well now you\'ve found it.';

// Simple Marquee / Ticker Script
// copyright 3rd January 2006, Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the below code in this script (including this
// comment) is used without any alteration
var vcps=vtSpeed; 
var vaw, vmq; 
//var vfsz = parseInt(tHeight) - 4; 
var vfsz = 12; 
var vwt = 0;
var vitemHeightCumArr = new Array(0);
function vstartticker()
{
    if (document.getElementById('vticker') != null) 
    {
        if(vitemHeightArr.length > 0)
        {
            vitemHeightCumArr = new Array(vitemHeightArr.length);
            vitemHeightCumArr[0] = 0;
            for(var k = 1; k<vitemHeightCumArr.length; k++)
            {
                vitemHeightCumArr[k] = vitemHeightCumArr[k-1] + vitemHeightArr[k-1];
            }
        
        //alert(vitemHeightArr+"\n"+vitemHeightCumArr);
        vcontent = document.getElementById('vticker').innerHTML;
        var vtick = '<div style="position:relative;width:'+vtWidth+';height:'+vtHeight+';overflow:hidden;"';
        if (vmoStop) vtick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; 
        vtick +='><div id="vmq" style="position:absolute;left:0px;top:0px;font-size:'+vfsz+'px;white-space:nowrap;"><\/div><\/div>'; 
        document.getElementById('vticker').innerHTML = vtick; 
        document.getElementById('vticker').style.display = "block";
        vmq = document.getElementById("vmq"); 
        //vmq.style.top=(parseInt(vtHeight)+10)+"px";
        vmq.style.top='0px';
        vmq.innerHTML='<span id="vtx">'+vcontent+'<\/span>'; 
        vaw = document.getElementById("vtx").offsetHeight; 
        vlefttime=setInterval("vscrollticker()",50);
        }
    }
} 
function vscrollticker()
{
    if(vwt > 0)
    {
        vwt = vwt -1;
    }
    else
    {
        if (vtDirectionIsTop != false)
        {
            vmq.style.top = (parseInt(vmq.style.top)>(-10 - vaw)) ?parseInt(vmq.style.top)-vcps+"px" : parseInt(vtHeight)+10+"px";
            for(var j = 0; j< vitemHeightCumArr.length; j++)
            {
                if(parseInt(vmq.style.top) + (vitemHeightCumArr[j]) <= 0 && parseInt(vmq.style.top) + (vitemHeightCumArr[j]) > -vcps)
                {
                    holdItem();
                }
            }
        }
        else
        {
            vmq.style.top = (parseInt(vmq.style.top)<parseInt(vtHeight)+10) ?parseInt(vmq.style.top)+vcps+"px" : (-10 - vaw)+"px";
        }
    }
} 
function skipItem()
{
    if (vtDirectionIsTop != false)
    {
        if (parseInt(vmq.style.top) > 0)
        {
            vmq.style.top = '0px';
        }
        else
        {
            for(var j = 0; j< vitemHeightCumArr.length; j++)
            {
                if(parseInt(vmq.style.top) <= -vitemHeightCumArr[j])
                {
                }
                else
                {
                    vmq.style.top = -vitemHeightCumArr[j]+'px';
                    /*holdItem();*/
                    break;
                }
                if(j == vitemHeightCumArr.length-1)
                {
                    vmq.style.top = '0px';
                }
            }
        }
       holdItem();
    }
}
function holdItem()
{
    //alert(vmq.style.top);
    vwt=vwaitTime;
}
//window.onload=startticker;
                  
