// JavaScript Document
// AJAX for player and tab area
// -------------------
// Player
// -------------------
// This is a javascript handler for the player and is always needed.
// some variables to save
var currentItem = 0;
var previousItem;
// this function is caught by the JavascriptView object of the player.
//function sendEvent(typ,prm) { try{thisMovie("pfs_player").sendEvent(typ,prm)}catch(e) {}; };
function sendEvent(typ,prm) { thisMovie("pfs_player").sendEvent(typ,prm) };

// these functions is called by the JavascriptView object of the player.
 function getUpdate(typ,pr1,pr2,swf) {
 	if(typ == "item") { currentItem = pr1;
	   setTimeout("getItemData(currentItem)",100);
	}
	//else if(typ == "state") { currentState = pr1; setTimeout("getStateData(currentItem)",10)}
};
function getItemData(idx1) {
  var obj = null;
   // Not working in IE
  
   obj = thisMovie("pfs_player").itemData(idx1);
   
   if(previousItem != currentItem)
   {	
		previousItem = currentItem;
		$("#tabcontainer").load('/common/tabs/'+obj["id"]);
   }
}; 
function getStateData(idx2) {
  var obj = null;
   // Not working in IE
   obj = thisMovie("pfs_player").itemData(idx2);
   
   if(previousItem != currentItem && (currentState == 2 || currentState == 1)  )
   {	
		 previousItem = currentItem; 
		$("#tabcontainer").load('/common/tabs/'+obj["id"]);       
   }
}; 
// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
		return document.getElementsByName(movieName)[0];
};
/* function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
             //  return document.getElementsByName(movieName)[0];
	}
};
*/
function stp_plyr(){
	var player = getelementbyid('pfs_player');
	if (player){
	sendEvent('stop');
	};
}
