/*
 * per gestire l'external interface
 * riporta i client swf presenti in pagina e ne richiama le
 * varie funzioni
 */
var ClientHandler = {
	
  load: function() {
  	this.clients = new Array();
	// questa costante è definita in externalInterface
	// ci possono essere comportamenti diversi nell'editing e nel live
	this.mode = EXT_INT_MODE;
	
	return this;
  },
  
  addClient: function(client) {
	if( this.checkUnique(client)) 
	{
		this.messages("checkUnique", client);
		//return;	
	}
	this.clients.push(client);
	
  },
  
  call:function(client, functionName, params)
  {
  	eval("$('" + client + "')." + functionName + "(" + params + ")")
  },
  
  checkUnique:function(client)
  {
  	return (this.clients.indexOf(client, 0) > 0)
  },
  
  messages: function(functionName, param)
  {
  	if(this.mode != "editing") return;
	switch(functionName)
	{
		case "checkUnique":
      // momentaneamente disabilitata perche' da problemi quando si usa il tasto back del browser
			alert("Attenzione! è già presente un oggetto flash di nome: " + param);
		break;
	}
  }
  

};