﻿window.onload=function()
{
	InitFlashPos();								
	bFlashing = GetCookie('yodb_flashing');								
	if ((bFlashing == "(none)") || (bFlashing == "true"))
		iIntervalID = setInterval('moveinfobartext()', iFlashInterval );					
}		

//Where in we return the value of a cookie, accepting one paramater "sName"
function GetCookie(sName)
{
	var search = sName + "=";
	var GCvalue = "(none)";
	if (document.cookie.length > 0)
	{
		var offset = document.cookie.indexOf(search);
			if (offset != -1)
			{
				offset += search.length;
				var end = document.cookie.indexOf(';', offset);
				if (end == -1) {
					end = document.cookie.length;
				}
				GCvalue=unescape(document.cookie.substring(offset, end));
			}
	}
	return GCvalue;
}

// Scrolling marque

var memoryspeed = 2; //Scroller speed (larger is faster 1-10)
var pauseit = 1; //Pause scroller onMousever (0=no. 1=yes)?
var copyspeed = memoryspeed;
var pausespeed = (pauseit == 0) ? copyspeed : 0;
var iFlashInterval = 50;

var bFlashing = true;
var iFlashStart = 0;
var bShopping = false;
var istop = 100;
var iIntervalID = 0;

var marqueContainer = document.getElementById('scrollingNewsText');
var marqueText = marqueContainer.innerHTML;

function InitFlashPos() //Set the initial position of the text
{
	var myLastScrollerPosition = parseInt(document.getElementById('newsBar').style.width);
	if ( GetCookie("yodb_flashpos")!="(none)" )
	{
		myLastScrollerPosition = parseInt(GetCookie("yodb_flashpos"))+"px";
	}	
	marqueContainer.style.left = parseInt(myLastScrollerPosition)+"px";
}
function CookieFlash()
{
	if (iIntervalID)
		clearInterval(iIntervalID);
	iIntervalID = 0;
	document.cookie="yodb_flashpos="+document.getElementById('scrollingNewsText').style.left;
	document.cookie="yodb_flashing="+bFlashing;
}
function moveinfobartext()
{
	var myContainer = document.getElementById('newsBarText');	
	if (parseInt(marqueContainer.style.left) > String(marqueText).length*(-1)*(6) ) {
		// move it to the left
		marqueContainer.style.left = parseInt(marqueContainer.style.left) - copyspeed+"px";
	}
	else {
		// reset to beginning position
		marqueContainer.style.left = parseInt(myContainer.style.width)+"px";
	}
}	