/**
 * Called from flash when the video player is initialised
 * - prior to this function being called, you have no 
 * control of the video player
 */
function onVideoPlayerReady()
{
	loadVideo( baseUrl + "/video/menu/inline/id/"+firstVidId);
	
	if (autoPlayVideo) {
		playVideo( baseUrl + "/video/menu/inline/id/"+firstVidId);
	}
}


function onVideoComplete(id)
{
	//alert(id + ': video complete');
}


/**
 * Wraps up the equivalent loadVideoXML in the flash 
 * - will add an autoPlay flag later.... 
 */
function loadVideoXML(xmlURL, force)
{
	var videoPlayer = (navigator.appName.indexOf ("Microsoft") != -1) ? window["video_player"] : document["video_player"];
	videoPlayer.loadVideoXML(xmlURL, force);
}


function getPlayer()
{
	var videoPlayer = (navigator.appName.indexOf ("Microsoft") != -1) ? window["video_player"] : document["video_player"];
	return videoPlayer;
}


function loadVideo(menuURL, path)
{
	getPlayer().loadVideo(menuURL, path);
	//alert(menuURL);
}


function playVideo(menuURL, path)
{
 	var url  = baseUrl + '/ajax/insertviews';
 	var data = encodeURI('logger_id=' + firstVidId);
 	
	$.ajax({
		type: 'POST',
		url:  url,
		data: data,
		success: function(msg) {
			getPlayer().playVideo(menuURL, path);
		}
	});
	
}


function popupVideo(url) 
{
 	window.open(url,'video','height=661,width=951,top=100,left=100,scrollbars=no,toolbars=no');
}


function popupAudio(url) 
{
 	var width = 316;
 	var height = 118;
 	var winl = (screen.width-width)/2;
 	var wint = (screen.height-height)/2;
 	
 	url = baseUrl + "/audio/play/?audio=" + url;
 	window.open(url,'audio','height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars=no,toolbars=no');
}


function popupRadio() 
{
 	var width = 316;
 	var height = 118;
 	var winl = (screen.width-width)/2;
 	var wint = (screen.height-height)/2;
 	
 	url = baseUrl + "/audio/play/?audio=" + popupUrl;
 	window.open(url,'audio','height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars=no,toolbars=no');
}	


function popupGeneric(url, width, height) 
{
 	window.open(url,'sbspopup','height=' + height + ',width=' + width + ',top=100,left=100,scrollbars=no,toolbars=no');
}	


function popupVideoViews(url, loggerId, baseURL) 
{
 	popupVideo(url);
 	
 	var url  = baseURL + '/ajax/insertviews';
 	var data = encodeURI('logger_id=' + loggerId);
 	
	$.ajax ( { type: 'POST', url: url, data: data });		
}