
if (typeof FlashPDF == "undefined") {
var FlashPDF = {
	callBacks:[],
	oROOT:{}
	};
}
/**
 * @method log
 * @static
 * @param  {String}  msg  The message to log.
 */
FlashPDF.log = function(msg, cat, src) {
    alert(msg);
};

/**
 * @method init
 * @static
 */
FlashPDF.init = function(p_root) {
	this.oROOT = p_root;
	
};
FlashPDF.init(this);
/*****************************************************************************************************************************************************
 ****   FlashPDF.CallBack   **********************************************************************************************************************
 *****************************************************************************************************************************************************/
FlashPDF.CallBack = function ( p_id, successH, failureH )
{
	var id = null;
	var succesHandler = null;
	var failureHandler = null;
	if(arguments.length >= 2)
	{
		this.initialize(arguments);
	}
}
FlashPDF.CallBack.prototype = {
   initialize: function(prms) {
      
	  this.id = prms[0];
	  this.succesHandler = prms[1];
	  if(prms[2] != undefined)
	  {
	  	this.failureHandler = prms[2];
	  }
	  
  },
  getID:function()
   {
	   return this.id;
   },
   executeSuccess:function(o)
   {
	  this.succesHandler(o);
   }
   
}


function XMLSocket(options){
	var instanceId, connector;
	var self = this;
	var options = options || {};
	self.connect = function(host, port){
		connector.connect(instanceId, host, port);
	}
	self.send = function(str){
		connector.send(instanceId, str);
	}
	self.close = function(host, port){
		connector.close(instanceId);
	}
    self.addEventListener = function(type, listener){
        if(!XMLSocket.eventListeners[instanceId]){
            XMLSocket.eventListeners[instanceId] = [];
        }
        var eventListenerId = connector.addJSEventListener(instanceId, type, "XMLSocket.dispatcher");
        XMLSocket.eventListeners[instanceId][eventListenerId] = listener;
        return eventListenerId; 
    }
    self.removeEventListener = function(eventListenerId){
    	connector.removeJSEventListener(eventListenerId);
		XMLSocket.eventListeners[instanceId][eventListenerId] = function(){}
    }
	self.XMLSocket = function(){
		alert("new XMLSocket() "+document.getElementById("flashPDF_swf"));
		connector = document[options.swfElementId || "JSXMLSocket"];
		instanceId = connector.create();
	}();
}
XMLSocket.eventListeners = [];
XMLSocket.dispatcher = function(instanceId, eventListenerId, event){
	XMLSocket.eventListeners[instanceId][eventListenerId](event);
}

 
 

