
jQuery(document).ready(function() {
	
	jQuery.rsmTracker = {
		
		position: 0.0,
		duration: 0.0,
		file: '',
			
		timeTracker: function(obj) {
			// measure position and duration on timetracking events
			this.position = obj.position;
			this.duration = obj.duration;
	    },
	    
		playTracker: function(obj) {

	    	// webtrekk event INIT
	    	if (obj.newstate == 'BUFFERING') {
	    		this.file = playerconfig_1.video;
			wt_sendinfo_media('"' + this.file + '"', "init", this.position, this.duration);
	    		console.log('rsmTracker::playTracker', 'wt_sendinfo_media("' + this.file + '", "init", ' + this.position + ', ' + this.duration + ');');
	    	}

	    	// webtrekk event PLAY
	    	if (obj.newstate == 'PLAYING') {
			wt_sendinfo_media('"' + this.file + '"', "play", this.position, this.duration);
	    		console.log('rsmTracker::playTracker', 'wt_sendinfo_media("' + this.file + '", "play", ' + this.position + ', ' + this.duration + ');');
	    	}

	    	// webtrekk event PAUSE
	    	if (obj.newstate == 'PAUSED') {
			wt_sendinfo_media('"' + this.file + '"', "pause", this.position, this.duration);
	    		console.log('rsmTracker::playTracker', 'wt_sendinfo_media("' + this.file + '", "pause", ' + this.position + ', ' + this.duration + ');');
	    	}

	    	// webtrekk event STOP
	    	if (obj.newstate == 'IDLE') {
			wt_sendinfo_media('"' + this.file + '"', "stop", this.position, this.duration);
    			console.log('rsmTracker::playTracker', 'wt_sendinfo_media("' + this.file + '", "stop", ' + this.position + ', ' + this.duration + ');');
	    		this.position = 0.0;
	    	}

	    	// webtrekk event EOF
	    	if (obj.newstate == 'COMPLETED') {
			wt_sendinfo_media('"' + this.file + '"', "eof", this.position, this.duration);
    			console.log('rsmTracker::playTracker', 'wt_sendinfo_media("' + this.file + '", "eof", ' + this.position + ', ' + this.duration + ');');
	    	}
	    	
			console.log('rsmTracker::playTracker::newstate', obj.newstate);
			console.log('rsmTracker::playTracker::position', this.position);
			console.log('rsmTracker::playTracker::duration', this.duration);
	    }
	};	
});

