

// === widget embed ===
var brighttalk_channelid = 1166;
var brighttalk_player_commid;
var brighttalk_autoplay_commid = swfobject.getQueryParamValue('commid');

var brighttalk_autostart = (brighttalk_autoplay_commid ? 'false' : 'true');
var brighttalk_widget_flashvars = {
  channelid : brighttalk_channelid,
  fromdc : 'false',
  autoStart : brighttalk_autostart,
  commid : brighttalk_autoplay_commid
};

var brighttalk_widget_params = {
  wmode: 'transparent',
  allowfullscreen: 'true',
  allowScriptAccess: 'always'
};

swfobject.embedSWF('http://www.brighttalk.com/clients/flashplatform/widget/events_academy/loader.swf',
  'bt_widget', '687', '750', '9.0.115.0',
  'http://www.brighttalk.com/clients/flashplatform/common/swfs/expressInstall.swf',
  brighttalk_widget_flashvars, brighttalk_widget_params, {});


// === overlay options ===
var overlayCssObj =  {
  'display' : 'none',
  'background-image' :'url(http://www.brighttalk.com/clients/flashplatform/resource/common/image/white_sized.png)',
  'width' :'720px',
  'height' : '800px',
  'padding' : '20px',
  'font-size' : '11px'
}

var overlayCloseCssObj = {
  'background-image' : 'url(http://www.brighttalk.com/clients/flashplatform/resource/common/image/overlay_close_gray.png)',
  'position' :'absolute',
  'right' : '5px',
  'top' : '5px',
  'cursor' : 'pointer',
  'height' : '35px',
  'width' :'35px'
}

var maskObj = {
  'color' : '#000000',
  'opacity' : '0.4',
  'loadSpeed' : '500'
}


// === player embed ===
var brighttalk_flashvarsEmbed = 'var brighttalk_player_flashvars = {channelid : "' + brighttalk_channelid + '",'
brighttalk_flashvarsEmbed += 'commid: brighttalk_player_commid, autoStart:brighttalk_autostart};';

var embedCode ='<script type="text/javascript">';
embedCode+=brighttalk_flashvarsEmbed;
embedCode+='var brighttalk_player_params = {wmode: "transparent", allowfullscreen: "true", allowScriptAccess: "always"};'
embedCode+='swfobject.embedSWF("http://www.brighttalk.com/clients/flashplatform/viewer/no_channel/loader.swf", "brighttalk_player_embed", "705", "660", "9.0.115.0", "http://www.brighttalk.com/clients/flashplatform/common/swfs/expressInstall.swf", brighttalk_player_flashvars, brighttalk_player_params, {});';
embedCode+='<\/script>';


// === overlay function called by widget ===
function brightTalkJsInvoke(param) {
 
	var querystringCommIdIndex = param.lastIndexOf("commid=");
	var btWebcastIndex = param.lastIndexOf("webcast/");
	
	 // 1st try and get from querystring
	if (querystringCommIdIndex != -1) {
    
    brighttalk_player_commid = param.substring(querystringCommIdIndex + 7);
  
  // see if we're linking to brighttalk portal
  } else if (btWebcastIndex != -1) {
  
  	// if 2 ids - i.e. webcast/444/123 	- 2nd number is commid
  	// if 1 id  - i.e. webcast/123 			- 1st number is commid
  	
  	//look for another slash
  	var nextSlashIndex = param.indexOf("/",btWebcastIndex + 8);
  	var regex = /[0-9]+/g;
  	
		if (nextSlashIndex != null) {
			regex.lastIndex = nextSlashIndex;
			brighttalk_player_commid = regex.exec(param); 
		}
	
		// nothing after a trailing slash, or no second slash, so 1st number is commid
		if (brighttalk_player_commid == null || nextSlashIndex == null) {
			regex.lastIndex = btWebcastIndex + 8;
			brighttalk_player_commid = regex.exec(param);
		}
  	
  // else we're just getting commid
  } else {
  	brighttalk_player_commid = param;
	}
  
  openInOverlay();
  brighttalk_autostart = 'true';
  return true;
}

