var craw_line_offset;
var craw_line_step;
var craw_roll1_offset;
var craw_roll1_step;
var craw_roll2_offset;
var craw_roll2_step;
 
function enableCrawLine () {

    document.getElementById('marquee_container').style.width = screen.width - 575;

    craw_line_offset = getInt(getCookie('craw_line_offset'));
    if (!craw_line_offset)
        craw_line_offset = Math.round(getInt(document.getElementById('marquee_container').style.width) / 1.1);

    craw_line_step = 1;

    var craw_line_width = document.getElementById('marquee_text').offsetWidth; 

    moveCrawLine (craw_line_width);
}
 
function moveCrawLine (w) {

    var lefttime;
    var container_width = document.getElementById('marquee_container').offsetWidth;

    var tdelay = 50;
    var step = craw_line_step;
 
    w = parseInt(w);

    if (step >= 0)
    if (craw_line_offset<(w+container_width)) {
        craw_line_offset = craw_line_offset + step;
    } else {
        craw_line_offset = 0;
    }
 
    if (step < 0)
    if (craw_line_offset>0) {
        craw_line_offset = craw_line_offset + step;
    } else {
        craw_line_offset = 0;
    }

    document.getElementById('marquee_text').style.left = parseInt(container_width-craw_line_offset)+'px';

    setTimeout('moveCrawLine('+w+');', tdelay);
}
 
function speedCrawLineF() {
    
    craw_line_step = 100;
}

function stopCrawLine() {
    
    craw_line_step = 0;
}

function speedCrawLineB() {

    craw_line_step = -100;
}

function speedCrawLineNormal() {
    
    craw_line_step = 1;
}

function saveCrawLine() {

    setCookie('craw_line_offset', craw_line_offset);
}

function enableCrawRoll1 () {

    craw_roll1_offset = 250;

    craw_roll1_step = 0;

    var craw_roll1_height = document.getElementById('vmarquee_text1').offsetHeight; 

    moveCrawRoll1(craw_roll1_height);
}
 
function moveCrawRoll1(w) {

    var lefttime;
    var container_height = document.getElementById('vmarquee_container1').offsetWidth;

    var tdelay = 50;
    var step = craw_roll1_step;
 
    w = parseInt(w);

    if (step >= 0)
    if (craw_roll1_offset<(w+container_height)) {
        craw_roll1_offset = craw_roll1_offset + step;
    } else {
        craw_roll1_offset = 0;
    }
 
    if (step < 0)
    if (craw_roll1_offset>0) {
        craw_roll1_offset = craw_roll1_offset + step;
    } else {
        craw_roll1_offset = 0;
    }

    document.getElementById('vmarquee_text1').style.top = parseInt(container_height-craw_roll1_offset)+'px';

    setTimeout('moveCrawRoll1('+w+');', tdelay);
}
 
function speedCrawRoll1Up() {

    craw_roll1_step = -10;
}

function speedCrawRoll1Down() {

    craw_roll1_step = 10;
}

function stopCrawRoll1() {

    craw_roll1_step = 0;
}

function enableCrawRoll2 () {

    craw_roll2_offset = 180;

    craw_roll2_step = 0;

    var craw_roll2_height = document.getElementById('vmarquee_text2').offsetHeight; 

    moveCrawRoll2(craw_roll2_height);
}
 
function moveCrawRoll2(w) {

    var lefttime;
    var container_height = document.getElementById('vmarquee_container2').offsetWidth;

    var tdelay = 50;
    var step = craw_roll2_step;
 
    w = parseInt(w);

    if (step >= 0)
    if (craw_roll2_offset<(w+container_height)) {
        craw_roll2_offset = craw_roll2_offset + step;
    } else {
        craw_roll2_offset = 0;
    }
 
    if (step < 0)
    if (craw_roll2_offset>0) {
        craw_roll2_offset = craw_roll2_offset + step;
    } else {
        craw_roll2_offset = 0;
    }

    document.getElementById('vmarquee_text2').style.top = parseInt(container_height-craw_roll2_offset)+'px';

    setTimeout('moveCrawRoll2('+w+');', tdelay);
}
 
function speedCrawRoll2Up() {

    craw_roll2_step = -10;
}

function speedCrawRoll2Down() {

    craw_roll2_step = 10;
}

function stopCrawRoll2() {

    craw_roll2_step = 0;
}

function saveScreenParams() {

    setCookie('screen_height', screen.height);
    setCookie('screen_width', screen.width);
}

onLoadRun = onLoadRun + "enableCrawLine();enableCrawRoll1();enableCrawRoll2();saveScreenParams();";
onUnloadRun = onUnloadRun + "saveCrawLine();";
