$(document).ready(function()
{
	$.current = "";
	//updateMetaData();
	//setInterval('updateMetaData()',10000);
	SetUpdateMetaData();
});
function SetUpdateMetaData()
{
	setTimeout('updateMetaData', 30000);
	setInterval('updateMetaData()',10000);
}
function updateMetaData()
{
   $.post("current.php",{ cmd:'check',rand:Math.random() } ,function(data)
   {
   	if(data==$.current)
      {
      	//do nothing, no changes
      }
      else
      {
      	$.current = data;
   		$.post("current.php",{ cmd:'get',rand:Math.random() } ,function(data2)
			{
				setTimeout(function()
				{
					$("#metadata").fadeOut("slow", function()
					{
						$("#metadata").html(data2);
						setTimeout(function() 
						{ 
							$("#metadata").fadeIn("slow");
						}, 3000); 
						
					});
				}, 3000);
			});
   	}
   });
}

function bigwindow(moviename)
{
	document.movie1.Stop();
	window.open(moviename,"moviewindow","top=0,left=0,resizable=yes,height=360,width=480,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0");
}
	/* define function that shows percentage of movie loaded */
	function showProgress()
	{
		var percentLoaded = 0 ;
		percentLoaded = parseInt((document.movie1.GetMaxTimeLoaded() / document.movie1.GetDuration()) * 100);
		document.getElementById("loadStatus").innerHTML = '<h2>Movie loading: ' + percentLoaded + '% complete...</h2>';
	}
	/* define function that executes when movie loading is complete */
	function movieLoaded()
	{
		document.getElementById("loadStatus").innerHTML = "<h2>&nbsp;</h2>" ;
	}

	function movieWaiting()
	{
		document.getElementById("loadStatus").innerHTML = "<h2>Buffering</h2>" ;
	}
	function moviePlaying()
	{
		document.getElementById("loadStatus").innerHTML = "<h2>&nbsp;</h2>" ;
	}
	function movieStopped()
	{
		document.getElementById("loadStatus").innerHTML = "<h2>Video paused, please click play to resume.</h2>" ;
	}
	/* define function that adds another function as a DOM event listener */
	function myAddListener(obj, evt, handler, captures)
	{
		if ( document.addEventListener )
			obj.addEventListener(evt, handler, captures);
		else
			// IE
			obj.attachEvent('on' + evt, handler);
	}

	/* define functions that register each listener */
	function RegisterListener(eventName, objID, embedID, listenerFcn)
	{
		var obj = document.getElementById(objID);
		if ( !obj )
			obj = document.getElementById(embedID);
		if ( obj )
			myAddListener(obj, eventName, listenerFcn, false);
	}

		/* define a single function that registers all listeners to call onload */
	function RegisterListeners()
	{
	   RegisterListener('qt_progress', 'movie1', 'qtmovie_embed', showProgress);
	   RegisterListener('qt_load', 'movie1', 'qtmovie_embed', movieLoaded);
	   RegisterListener('qt_play', 'movie1', 'qtmovie_embed', moviePlaying);
	   RegisterListener('qt_pause', 'movie1', 'qtmovie_embed', movieStopped);
	   RegisterListener('qt_waiting', 'movie1', 'qtmovie_embed', movieWaiting);
	   RegisterListener('qt_loadedfirstframe ', 'movie1', 'qtmovie_embed', moviePlaying);
	}
