// How to use sharing ?
// The JSONP file of Addthis must be called after this file.
// call "_pgt.videoPlayer.callShare('*name_of_sharingtool*')"

var _pgt = _pgt || {};

_pgt.lang = 'en';

function _pgtstoreServices(response) {
	_pgt._services = [];
	$each(response.data, function(service){
		_pgt._services.push(service.code);
	});
}

_pgt.videoPlayerInstance = new Class({
	Implements: Options,
	
	options: {
		url: null, 
		oldUrl: null
	},
	
	initialize: function(options) {
		this.setOptions(options);
	},
	
	callShare: function(tool) {
		tool = tool.trim();
		if (_pgt._services != undefined) {
			if (_pgt._services.contains(tool)) {
				var urlToShare = window.location.href;
				
				if(this.options.url) {
					urlToShare = this.options.url;
				}
				
				window.open('http://api.addthis.com/oexchange/0.8/forward/' + tool + '/offer?url=' + urlToShare, '_blank');
			}
		};
	}
});

_pgt.videoPlayer = new _pgt.videoPlayerInstance();
