function createVideoPlayer(vid_file,vid_width,vid_height,vid_id,vid_img,vid_autostart,vid_caption)
      {
      	      	
      var vid_plugin = '';
      
	  if(vid_caption != undefined) {
	  		// vid_plugin = 'captions-1';
	  		vid_plugin = 'http://kpbs.media.clients.ellingtoncms.com/static/kpbs/flash/captions.swf';
	  	}
	  	
	  
	  var flashvars =
		  {              
			file:vid_file,
			image:vid_img,
			skin:'http://kpbs.media.clients.ellingtoncms.com/static/kpbs/flash/videoskin.swf',
      plugins: vid_plugin+",gapro-1",
			'captions.file': vid_caption,
			'captions.state': 'false',
			'captions.back': 'true',
			lightcolor: '015190',
			frontcolor: '333333',
			autostart:vid_autostart,
			repeat:'list',
      'gapro.accountid': 'UA-316834-2',
      'gapro.trackstarts' : 'true',
      'gapro.trackpercentage': 'true',
      'gapro.tracktime':'true'
		  };
	
		  var params =
		  {
			allowfullscreen:'true',
			allowscriptaccess:'always',
			wmode:'transparent'
		  };
		  
		  var attributes =
		  {
			id:'videoPlayer1',
			name:'videoPlayer1'
		  };
		  
		  var player_height = parseInt(vid_height) + 46;
	
		  swfobject.embedSWF("http://kpbs.media.clients.ellingtoncms.com/static/kpbs/flash/jwplayer44.swf", vid_id, vid_width, player_height, "9.0.115.0", "http://kpbs.media.clients.ellingtoncms.com/static/kpbs/flash/expressInstall.swf", flashvars, params, attributes);
        
      };

 
function gid(name)
      {
        return document.getElementById(name);
      };

function changeVideo(vid_file,vid_type,vid_width,vid_height,vid_id,vid_img,vid_autostart,vid_caption)
	{
	swfobject.removeSWF('videoPlayer1');
	
	if(vid_type == 'MP4') {
	
	var vid_height_plus = vid_height + 20;
	
	gid('vidPlayerContainer').innerHTML = '<div id="videoplayer"><embed src="' + vid_file + '" pluginspage="http://www.apple.com/quicktime/download/" width="' + vid_width + '" height="' + vid_height_plus + '" controller="TRUE" loop="0" autoplay="FALSE"><noembed>Video unavailable.</noembed></div><p><a href="' + vid_file + '">Download this video</a></p></a>';  
		
	} else if(vid_type == 'Flash') {
	
	gid('vidPlayerContainer').innerHTML = '<div id="videoplayer"><p>To view video on KPBS.org, you must have a JavaScript-enabled browser and the Flash Player, minimum version 9, available for free at <a href="http://get.adobe.com/flashplayer/">Adobe.com</a>.</p><p><a href="vid_file">Source file</a>.</p></div>'; 
	
	}
	createVideoPlayer(vid_file,vid_width,vid_height,vid_id,vid_img,vid_autostart,vid_caption);
		
	};      

