var currentState = "NONE"; 
var previousState = "NONE"; 

var player = null;

function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
	addListeners();
}


function addListeners() {
	if (player) { 
		player.addModelListener("STATE", "stateListener");
	} else {
		setTimeout("addListeners()",100);
	}
}


function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
	currentState = obj.newstate; 
	previousState = obj.oldstate; 
/*	
 	if(currentState == "PLAYING") {
 		update_video_stat(2);
 	}
  	
 	if((currentState == "COMPLETED")&&(previousState == "PLAYING")) {
 		update_video_stat(1);
 	}
*/
}


function createPlayer(videoID, start, width, height, path) {
	path = path || '';


   var flashvars = {
      'file':                path+'videos/video.php%3Fv%3D'+videoID,
      'plugins': 						 'googlytics-1',
			'autostart': 					 start,
			'controlbar':					 'over',
      'stretching':          'exactfit',
      'playlist':            'none'
   };
   var params = {
      'allowfullscreen':     'true',
      'allowscriptaccess':   'always',
      'bgcolor':             '#ffffff'
   };
   var attributes = {
      'id':                  'player1',
      'name':                'player1'
   };

	swfobject.embedSWF(path+"include/flash/player_nntv.swf", "placeholder1", width, height, "9.0.115", 'expressInstall.swf', flashvars, params, attributes);
}
