/* 
Originally From ITS: http://www.queensu.ca/its/apps/media/streaming/flash/player.js
Modified for Pre-Image tags - preview before image
By: Steven Leggett

Include function: It is possible for one JavaScript file to cause another JavaScript file to be included. 
Code: http://www.cryer.co.uk/resources/javascript/script17_include_js_from_js.htm
*/

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}

// Include flash detection script
IncludeJavaScript('http://www.queensu.ca/its/apps/media/streaming/flash/flash_detect.js');



// Video Player function
// Call example:  flashplayer('rtmp://streaming.queensu.ca/vod', 'marketing/queens.flv', '320', '240', 'preview', '','','http://www.queensu.ca/resources/images/identity/logo/png/QueensLogo_colour.png');

// URL of the player
// File location on the streaming server
// Video width
// Video Height
// Player style
// Branding logo - stays on video whole time Watermark
// Text CC captions
// Pre-video play image - displayed before the video starts instead of a black, blank screen
function flashplayer(url, file, w, h, style, logo, captions, image){

var h1 = parseInt(h)+20;

if(logo || logo!=''){
var logo1 = '&logo='+logo;
}
else{
var logo1 = '';
}


if(captions || captions!=''){
var captions1 = '&captions.file='+captions+'&plugins=captions-1';
}
else{
var captions1 = '';
}

if(image || image!=''){
var image1 = '&image='+image;
}
else{
var image1 = '';
}



if(!FlashDetect.installed){
		//alert("Flash is required to enjoy this site. r\n Download and install the latest version of the Flash Player.");  
		//window.location="http://get.adobe.com/flashplayer/";
		document.writeln("There was a problem playing this video. Flash Player is missing or outdated. Please download and install the latest version of <a href='http://get.adobe.com/flashplayer/'>Flash Player</a> <br /><br />" );   	
}
else if(!FlashDetect.versionAtLeast(10)){
    //alert("Flash Player 10 or greater has to be installed -- \r\n For best results, download and install the latest version of the Flash Player.");
		//window.location="http://get.adobe.com/flashplayer/";
		document.writeln("There was a problem playing this video. Flash Player is missing or outdated. Please download and install the latest version of <a href='http://get.adobe.com/flashplayer/'>Flash Player</a> <br /><br />" );   	
}else{

var s1 = new SWFObject('http://www.queensu.ca/its/apps/media/streaming/flash/player-licensed.swf','player',w,h1,'9');
if(h1 > 20){
s1.addParam('allowfullscreen','true');
} else {
s1.addParam('allowfullscreen','false');
}
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file='+file+'&image='+image1+'&streamer='+url+logo1+captions1);
s1.write(style);
}
}

// Audio Player 
function audioplayer(url, file, w, style){
var h=20;

if(!FlashDetect.installed){
		alert("Flash is required to enjoy this site. r\n Download and install the latest version of the Flash Player.");    
		window.location="http://get.adobe.com/flashplayer/";
}
else{
var s2 = new SWFObject('http://www.queensu.ca/its/apps/media/streaming/flash/player-licensed.swf','player',w,h,'9');
s2.addParam('allowfullscreen','false');
s2.addParam('allowscriptaccess','always');
s2.addParam('flashvars','file='+file+'&streamer='+url);
s2.write(style);
}
}

