/*!
 * Baldy Beanbag JavaScript Library v1.0
 * http://www.baldybeanbag.com/
 *
 * Copyright (c) 2009 Baldy Beanbag, Inc.
 * 
 */
	var videoBar;
	
	function LoadVideoBar() 
	{

		var options = {
			string_allDone : "I'm done watching this",
			largeResultSet : false,
			horizontal : true,
			thumbnailSize : GSvideoBar.THUMBNAILS_MEDIUM
		}
		
		videoBar = new GSvideoBar(
					document.getElementById("videoBar"),
					GSvideoBar.PLAYER_ROOT_FLOATING,
					options
					);
	}
  

	/**
	 * Arrange for LoadVideoBar to run once the page loads.
	*/
	//GSearch.setOnLoadCallback(LoadVideoBar);
	
	var curVideoTuple = 1;

	function playTheVideo(obj, url, playUrl, duration) 
	{
		title = "'"+obj.alt+"'";
		videoBar.playTheVideo(url, title, playUrl, obj.src, duration);
	}
		
	function videoTupleNext(blnk) 
	{

		buttonBlur(blnk);
		if (curVideoTuple < 4) 
		{
			// Move the Video tuples
			curVideoTuple++;
			
			moveVideoTupleRight('videoTupleNum1');
			moveVideoTupleRight('videoTupleNum2');
			moveVideoTupleRight('videoTupleNum3');
			moveVideoTupleRight('videoTupleNum4');
			
			// Update videobar header
			updateVideoPosDots();
			updateVideobarBtns();
		}
	}

	function videoTuplePrev(blnk) 
	{
		
		buttonBlur(blnk);
		if (curVideoTuple > 1)
		{
			// Move the Video tuples
			curVideoTuple--;
			moveVideoTupleLeft('videoTupleNum1');
			moveVideoTupleLeft('videoTupleNum2');
			moveVideoTupleLeft('videoTupleNum3');
			moveVideoTupleLeft('videoTupleNum4');
			
			// Update videobar header
			updateVideoPosDots();
			updateVideobarBtns();
		}
	}
	
	
	function updateVideoPosDots() 
	{
		var dotUrl = $('#videoDot1').attr('src');
		var imagePath = xtractPath(dotUrl);
		
		for (i=1; i<=4; i++) {
		
			$('#videoDot'+i).attr('src',imagePath+'/inactive_video_dot.gif');
		}
		
		$('#videoDot'+curVideoTuple).attr('src',imagePath+'/active_video_dot.gif');
	}
	
	function updateVideobarBtns() 
	{
	
		var dotUrl = $('#leftVideobarBtn').attr('src');
		var imagePath = xtractPath(dotUrl);
		
		// Update left button
		if (curVideoTuple > 1) {
			$('#leftVideobarBtn').css('cursor', 'auto');
			$('#leftVideobarBtn').attr('src',imagePath+'/left_active_video_btn.gif');
		}
		else {
			$('#leftVideobarBtn').css('cursor', 'default');
			$('#leftVideobarBtn').attr('src',imagePath+'/left_inactive_video_btn.gif');
		}

		// Update right button
		if(curVideoTuple < 4) {
			$('#rightVideobarBtn').css('cursor', 'auto');
			$('#rightVideobarBtn').attr('src',imagePath+'/right_active_video_btn.gif');
		}
		else {
			$('#rightVideobarBtn').css('cursor', 'default');
			$('#rightVideobarBtn').attr('src',imagePath+'/right_inactive_video_btn.gif');
		}
	}
	
	function moveVideoTupleLeft(divName) 
	{
		var leftVal = parseInt($('#'+divName).css("left")) + 270;
		$('#'+divName).animate({"left": leftVal}, 300);
	}
	
	function moveVideoTupleRight(divName) 
	{
		var rightVal = parseInt($('#'+divName).css("left")) - 270;
		$('#'+divName).animate({"left": rightVal}, 300);
	}
	


	