// get the flash movie object
var flashMovie;
var flvDirectory = '/ada-webcast/flv/';
var imgDirectory = '/ada-webcast/images/';
var currentVideo = '';
var currentVideoImage= '';
var totalVideos = 3;

//video thumbnail images
vidThumb0 = new Image();
vidThumb0.src = imgDirectory + "vidThumb0.jpg";
vidThumb0Playing = new Image();
vidThumb0Playing.src = imgDirectory + "vidThumb0_nowplaying.jpg";

vidThumb1 = new Image();
vidThumb1.src = imgDirectory + "vidThumb1.jpg";
vidThumb1Playing = new Image();
vidThumb1Playing.src = imgDirectory + "vidThumb1_nowplaying.jpg";

vidThumb2 = new Image();
vidThumb2.src = imgDirectory + "vidThumb2.jpg";
vidThumb2Playing = new Image();
vidThumb2Playing.src = imgDirectory + "vidThumb2_nowplaying.jpg";

var vidScroller = 
{
	
	init: function() 
	{
		if (document.getElementById) 
		{
			flashMovie = document.getElementById("videoPlayer");
			if (flashMovie) 
			{
				currentVideo = "vid0";
				currentVideoImage = document.getElementById(currentVideo).style.backgroundImage;
				flashMovie.videoURL(flvDirectory + currentVideo + ".flv");
				document.getElementById(currentVideo).style.backgroundImage = "url(" + imgDirectory + "vidThumb0_nowplaying.jpg)";
			}
		}
	},
	
	getVideoURL: function(myObject)
	{
	     
		for(var i=0; i<totalVideos;i++)
		{
			if(myObject.id == ("vid" + i)) 
			{
				// pass video param 
				if (flashMovie) 
				{
					flashMovie.videoURL(flvDirectory + "vid" + i + ".flv");
					if (currentVideo != '' && currentVideo != myObject.id)
					{
						document.getElementById(currentVideo).style.backgroundImage	= currentVideoImage;
					}
					currentVideo = myObject.id;
					currentVideoImage = document.getElementById(currentVideo).style.backgroundImage;
					document.getElementById(myObject.id).style.backgroundImage = "url(" + imgDirectory + "vidThumb" + i + "_nowplaying.jpg)";
					//document.getElementById("vidCount").innerHTML = "Select a video (" + (i + 1) + " of " + totalVideos + ")";
					//alert(flvDirectory + "vid" + i + ".flv");
					//return;
				}
			}
		}
	},
	
	// call back from flash
	getFromFlash: function(name) 
	{
		document.getElementById('test').innerHTML = document.getElementById('test').innerHTML + "<br />" + name;
	},
	
	TextScroll: function(scrollname, div_name, up_name, down_name)
	{
		this.div_name = div_name;
		this.name = scrollname;
		this.scrollCursor = 0;
		this.speed = 117;
		this.timeoutID = 0;
		this.div_obj = null;
		this.up_name = up_name;
		this.dn_name = down_name;
		document.getElementById("scroll_up").style.visibility = "hidden";
		{
			if (document.getElementById) {
				div_obj = document.getElementById(this.div_name);
				if (div_obj) {
					this.div_obj = div_obj;
					this.div_obj.style.overflow = 'hidden';
				}
				div_up_obj = document.getElementById(this.up_name);
				div_dn_obj = document.getElementById(this.dn_name);
				if (div_up_obj && div_dn_obj) {
					div_up_obj.onclick = function() { eval(scrollname + ".scrollUp();");};
					//div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();");};
					div_dn_obj.onclick = function() { eval(scrollname + ".scrollDown();");};
					//div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();");}; 
				}
			}
		}
	
	
		this.stopScroll = function() {
			clearTimeout(this.timeoutID);
		}
	
		this.scrollUp = function() {
			if (this.div_obj) {
				document.getElementById("scroll_down").style.visibility = "visible";
				this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
				if(this.scrollCursor == 0)
					document.getElementById("scroll_up").style.visibility = "hidden";
				this.div_obj.scrollLeft = this.scrollCursor;
				//this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
			}
		}
	
		this.scrollDown = function() {
			if (this.div_obj) {
				document.getElementById("scroll_up").style.visibility = "visible";
				this.scrollCursor += this.speed;
				if (this.scrollCursor <= document.getElementsByTagName("div")["scroll_box"].offsetWidth)
					this.div_obj.scrollLeft = this.scrollCursor;
				if (this.div_obj.scrollLeft == this.scrollCursor) {
					//this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
				} else {
					document.getElementById("scroll_down").style.visibility = "hidden";	
					this.scrollCursor = this.div_obj.scrollLeft;
				}
			}
		}
	
	
		this.resetScroll = function() {
			if (this.div_obj) {
				this.div_obj.scrollLeft = 0;
				this.scrollCursor = 0;
			}
		}
	}
}

// wait for the page to fully load, only then initialize
//onload = vidScroller.initVideo;
		
