mmw.widget.ooyalaVideoDisplay = {
	ooyalaVideoStartupElements: {},
	onEvent: function(playerId, eventName, eventArgs) {
		var videoElementsObj = null;
		var playerElem = null;
		if(typeof (videoElementsObj = this.ooyalaVideoStartupElements[playerId]) != 'undefined' && typeof (playerElem = $('#' + playerId)) != 'undefined') {
			switch(eventName) {
				case 'apiReady':
					var durationElem = null;
					if(videoElementsObj.durationElemSelector != undefined && (durationElem = $(videoElementsObj.durationElemSelector)).length > 0) {
						durationElem.each(function() {
							$(this).text(' (' + mmw.widget.ooyalaVideoDisplay.tools.getHumanReadableLength(playerElem.get(0).getTotalTime()) + ')');
							//$(this).text(this.tools.getHumanReadableLength(playerElem.get(0).getTotalTime()));
						});
					}
					break;
			}
		}
	},
	tools: {
		getHumanReadableLength: function(length) {
			var returnLength = '';
			var loopLength = length;
			var minLen = 2;
			var counter = 1;
			var segmentLength = null;
			var segmentLengthDisp = null;
			while(counter <= minLen || loopLength > 1)
			{
				segmentLength = loopLength % 60;
				segmentLengthDisp = Math.floor(segmentLength);
				segmentLengthDisp = ((segmentLengthDisp.toString().length < 2 && (loopLength / 60) > 1) ? '0' + segmentLengthDisp.toString() : segmentLengthDisp.toString());
				returnLength = segmentLengthDisp + ((returnLength.length > 0) ? ':' + returnLength : returnLength);
				loopLength = loopLength / 60;
				counter++;
			}
			return returnLength;
		}
	}
};
