/*
 * Kaltura player helper
 *
 * Author : Nicholas Ortenzio
 * Created : 2010/03/30
 * Last Modified : 2010/04/26
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

function jsCallbackReady (pid) { 
	ksd._player = document.getElementById(pid); 
	ksd._player.addJsListener("kdpEmpty","ksd.setReady");
	kalOmCall.register(ksd._player);
}

if($.browser.msie) { window.onerror = function() { return true; } }

var ksd = {

	init : function(parentId, entryId) {
		this.entryId = entryId;
		this._flashvars.entryId = entryId;
		this._attributes.name = parentId;
		swfobject.embedSWF("http://www.kaltura.com/kwidget/wid/_192572/ui_conf_id/1703742",
			"ts_overlay_player",
			"576",
			"430",
			"9.0.0",
			false,
			this._flashvars,
			this._params,
			this._attributes
		);
	},

	_player : null,

	_params : { 
		allowScriptAccess: "always",
		allowNetworking: "all",
		allowFullScreen: "true"
	},

	_attributes : {
		name : "",
		allowFullScreen : "true",
		allowNetworking : "all",
		allowScriptAccess : "always", 
		height : "576", 
		width : "430",
		data : "http://www.kaltura.com/kwidget/wid/_192572/ui_conf_id/1703742"
	},

	_flashvars : {
		entryid : "",
		externalInterfaceDisabled : false
	},

	_changeMedia : function() {
		if ((!this.player) || (!this.entryId)) { return; }
		ksd.player.sendNotification('changeMedia', {entryId:this.entryId});

		this.entryId = null;
	},

	setReady : function() { },
	
	close : function() {
		if (ksd._player) {
			ksd._player.sendNotification('doStop');
			$(ksd._player).replaceWith($("<div></div>").attr('id', this._attributes.name));
		}
	}


}
