////////////////////////////////////////////////////////////////////////////////
// init.js
//

	// -- Initialize -----------------------------------------------------------
	function initializeMenu()
	{
		
		var elems = document.getElementById( "mnu_items" ).getElementsByTagName( "img" );
		for( var i = 0; i < elems.length; i++ )
		{
			elems[i].onmouseover = function() { swapImage( this ); }
			elems[i].onmouseout = function() { swapImage( this ); }
		}
	}
	function initializeFG()
	{
		var windowDims = findWindowDimensions();
		var contentDims = findDimensions( document.getElementById( "container" ) );
		
		var h = windowDims[1];
		if( h < contentDims[1] )
			h = contentDims[1];
		
		var elem = document.getElementById( "footerGradiant" );
			elem.style.top = (h-238) + "px";
			elem.style.visibility = "visible";
			
		var emBody = document.getElementById( "mBody" );
			emBody.style.height = h + "px";
	}
	function initializeJackpots()
	{
		if( document.getElementById( "tblJackpots" ) != undefined )
			updateJackpots();
	}
	// -------------------------------------------------------------------------
	// -- Jackpots -------------------------------------------------------------
	var jTimer;
	var curTime = new Date();
		curTime = curTime.getTime();
	function addCommas( nStr )
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
	function updateJackpots()
	{
		var nTime = new Date();
			nTime = nTime.getTime();
		
		var j = document.getElementById( "tblJackpots" );
		var jackpots = j.getElementsByTagName( "span" );
		var jackpots_increment = j.getElementsByTagName( "input" );
		
		var interval = 1;
		for( var i = 0; i < jackpots.length; i++ )
		{
			var parts = jackpots_increment[i].value.split( "|" );
			//var jvalue = parseFloat( jackpots[i].innerHTML.replace( /[^0-9.]/ig, "" ) );
			var jvalue = parseFloat( parts[0] );
			var portion = parseFloat((parts[1] / 24 / 60 / 60));
				jvalue += parseFloat((portion * parts[2]).toFixed(2)) + parseFloat((portion * ((nTime-curTime)/1000)));
			//alert( (portion * ((nTime-curTime)/1000)) );
			//alert( jvalue );
			jackpots[i].innerHTML = "$"+ addCommas( jvalue.toFixed(0));
		}
		//alert(  (portion * parts[2]).toFixed(2) +" + " + (portion * ((nTime-curTime)/1000)) );
		setTimeout( "updateJackpots()", 1000 );
	}
	// -------------------------------------------------------------------------
	// -- Scroller -------------------------------------------------------------
	var sTween;
	var sPointer = 0;
	var sTimer;
	var stops_pos = new Array();
	var sTweenAction = "stopped";
	var sTweenContinue = true;
	var ctr = 0;
	function initializeScroller()
	{
		var scroller = document.getElementById( "scrollContent" );
		
		if( scroller == undefined )
			return;
		
			//scroller.onmouseover = stopScroller;
			//scroller.onmouseout = resumeScroller;
		
		// Stops
		var stops = scroller.getElementsByTagName( "div" );		
		for( var s = 0; s < stops.length; s++ )
		{
			var pos = findPosRelativeParent( stops[s], scroller );
			stops_pos.push( pos[0] );
		}
		
		// Hover
		var imgs = document.getElementsByTagName( "img" );
		for( var i = 0; i < imgs.length; i++ )
		{
			if( imgs[i].className.indexOf( "gradiant" ) != -1 )
			{
				imgs[i].onmouseover = function()
				{
					//this.style.display = "none";
					this.style['opacity'] = 0;
					this.style['-moz-opacity'] = 0;
					sTweenContinue = false;
					//if(this.filters) this.style.filter = "alpha(opacity=99)";
					
					//this.style.visibility = "hidden";
					
					stopScroller();
				}
				imgs[i].onmouseout = function()
				{
					//this.style.display = "inline";
					this.style['opacity'] = 1;
					this.style['-moz-opacity'] = 1;
					sTweenContinue = true;
					//if(this.filters) this.style.filter = "alpha(opacity=100)";
					
					//this.style.visibility = "visible";
					
					resumeScroller();
				}
			}
		}
		
		sTimer = setTimeout( "startScroller()", 1000 );
	}
	function startScroller()
	{
		var scroller = document.getElementById( "scrollContent" );
		
		sTweenAction = "started";
		
		if( sTween == undefined || sTween.isPlaying == false )
		{
			sTween = new Tween( scroller.style, "left", Tween.strongEaseInOut, stops_pos[sPointer] * -1, stops_pos[sPointer+1] * -1, 2.5, "px" );
			sTween.onMotionFinished = function()
			{
				sTweenAction = "stopped";
				sPointer++;
				if( sPointer >= (stops_pos.length / 2) )
				{
					resetScroller();
				}
				
				sTimer = setTimeout( "startScroller()", 1000 );
			}
			sTween.start();
		}
	}
	function stopScroller()
	{
		if( sTweenAction == "started" )
		{
			sTween.stop();
			sTweenAction = "stopped";
		}
	}
	function resumeScroller()
	{
		if( sTweenAction == "stopped" )
		{
			if( sTween != undefined )
				sTween.resume();
			sTweenAction = "started";
		}
	}
	function resetScroller()
	{		
		var scroller = document.getElementById( "scrollContent" );
			scroller.style.left = "0px";
			sPointer = 0;
	}
	// -------------------------------------------------------------------------
	// -- Image ----------------------------------------------------------------
	function swapImage( obj )
	{
		if( obj.src.indexOf( "_over" ) != -1 )
			obj.src = obj.src.replace( "_over", "" );
		else
		{
			var index = obj.src.lastIndexOf( "." );
			var s = obj.src.substring( 0, index );
			var e = obj.src.substring( index );
			
			obj.src = s + "_over" + e;
		}
	}
	// -------------------------------------------------------------------------

//
//
////////////////////////////////////////////////////////////////////////////////
