var divId = "text";
var leftTextPadding = 5;
var topTextPadding = 2;
var pause=20;

var step= 2; // speed 2: higher means faster
var pausestep = 1;
var fntweight = 1;  // font-weight: 1 means bold, 0 means normal
// do not edit the variables below
var clipleft,clipright,cliptop,clipbottom
var i=0;
var timer;
var textwidth;
var pauseOnMouse = true;
var scrollPause = 5000; // pause scrolling when left border is reach
    
fntweight = (fntweight==1) ? "700" : "100";
function getObj(name)
{
  this.obj = document.getElementById(name);
  this.style = this.obj.style; 
}
function initTicker() {
      if(location.pathname.indexOf('values')!=-1)
        return false;
    txt = new getObj('text');
    imgDiv = new getObj('running-line');
    getRecord(); 
    scrollerwidth = imgDiv.obj.clientWidth;
    scrollerheight = imgDiv.obj.clientHeight;
    scrollerleft_in = imgDiv.obj.offsetLeft + leftTextPadding;
    scrollertop_in= imgDiv.obj.offsetTop + topTextPadding;
    
    txt.obj.innerHTML = textcontent;
    textwidth = txt.obj.clientWidth;
    txt.style.posTop = scrollertop_in;
    txt.style.top = scrollertop_in+'px';
    txt.style.posLeft = scrollerleft_in+scrollerwidth - (leftTextPadding*2); 
    txt.style.left = txt.style.posLeft+'px';
      
    clipleft = clipright = cliptop = 0;
    clipbottom = scrollerheight-4;
    txtClip();
    scrollRecords();
    
}
function scrollRecords() {
    if (txt.style.posLeft >= scrollerleft_in-textwidth) {
        txt.style.posLeft -= step;
        txt.style.left = txt.style.posLeft+'px';
        var halfscroll = parseInt(scrollerwidth / 2);
        var halftxt = parseInt(textwidth / 2);
        var pos = scrollerleft_in + halfscroll - halftxt;
        if(txt.style.posLeft == pos) {
            pauseScroll();
        } 
        clipright += step;
        if (clipright > scrollerwidth - (leftTextPadding * 2) ) {
             clipleft += step;
        }
        txtClip();
        var timer = setTimeout("scrollRecords()",pause)
    }
    else {
        changeRecord();
    }
 
}
function pauseScroll() {
        txtClip();       
        stopScroll();
        var point = setTimeout("continueScroll();",scrollPause);
}
function changeRecord() {
    i++;
    if (i > message.length-1) {
        i=0;
    }
    getRecord();
    clipleft = clipright = 0;
    txtClip();
    txt.obj.innerHTML = textcontent;
    textwidth = txt.obj.clientWidth;
    txt.style.posLeft = scrollerleft_in+scrollerwidth - (leftTextPadding*2);    
    txt.style.left = txt.style.posLeft+'px';
    scrollRecords();
}
function txtClip() { 
    txt.style.clip ="rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)"; 
}
function getRecord() { 
    textcontent = '<p onmouseover="stopScroll();" onmouseout="continueScroll();" ';
    textcontent += 'style="position:relative;font-size:'+fntsize+'pt;font-family:';
    textcontent += fntfamily+';font-weight:'+fntweight+'; color:'+color+'">';
    if (messageurl[i]=='/' || messageurl[i].indexOf('null')!=-1){
        textcontent += message[i]+'</p>';
    }    
    else {
        textcontent+='<a href="'+messageurl[i]+'" >';
        textcontent+=message[i]+'</a></p>';    
    }
}
function stopScroll() {
        step = 0;
}

function continueScroll()  {
        step = 1;
}
function browserIs() {  
    	var sAgent = navigator.userAgent.toLowerCase() ;    
    	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
    		return 'IE';
    	if ( navigator.product == "Gecko" )	return 'Gecko';
    	if (navigator.appName == 'Opera' ) return 'Opera';
    	if (sAgent.indexOf( 'safari' ) != -1 ) return 'Safari';	// Build must be at least 312 (1.3)    	
}