// useful javascript functions

// create a popup window - 21/03/09 - gavin taylor
function popup(link, windowname, width, height, scrollbars, status, resizable, location, toolbar, menubar)
{	
	if(!window.focus) { return true; }
	
	//check if additional options are set
	if(windowname	== null) 	{ windowname 	= 'popup_window'; }
	if(scrollbars	== null) 	{ scrollbars 	= 'no'; }
	if(status			== null) 	{ status 			= 'no'; }
	if(resizable 	== null) 	{ resizable 	= 'no'; }
	if(location 	== null) 	{ location 		= 'no'; }
	if(toolbar 		== null) 	{ toolbar 		= 'no'; }
	if(menubar 		== null) 	{ menubar 		= 'no'; }
	
	var href;
	if(typeof(link) == 'string') { href=link; }
	else { href=link.href; }
	
	//window position
	var posleft = (screen.width - width) / 2;
	var postop = (screen.height - height) / 2;
	
	newwindow = window.open(href, windowname, 'width=' + width + ', height=' + height + ',left=' + posleft + ',top=' + postop + ',scrollbars=' + scrollbars + ',status=' + status + ',resizable=' + resizable + ',location=' + location + ',toolbar=' + toolbar + ',menubar=' + menubar + '');
	if(window.focus) {newwindow.focus()}
	return false;
}

//create instance of flowplayer - 20/08/09 - gavin taylor
function load_flowplayer(div_id, video_url, playlist)
{
	//flowplayer keys
	//ukfast.tv - @e0f82e7fcdc74e5fe81
	
	//output container to screen
	document.write('<a href="'+video_url+'" id="'+div_id+'" class="flowplayer"></a>');
	
	//initalise flowplayer
	flowplayer(div_id, "http://streaming.ukfast.tv/flowplayer.commercial-3.0.7.swf", {
	key: '@e0f82e7fcdc74e5fe81',
	clip: {
		url: video_url,
		autoPlay: false
	},
	canvas:  { 
		// configure background properties 
		background: '#000000 url(' + video_url.replace(".flv",".jpg") + ') no-repeat 0 0', 
		// remove default canvas gradient 
		backgroundGradient: 'none', 
		// setup a light-blue border 
		border:'2px solid #778899' 
	} 
	}).playlist("#" + playlist);
}
