/**
* @author iioriatti 
* @version 1.0 
* @class This generic Class provides the basic functions classes for all the children objects created with the createContainer() method.
* @param {HTMLDocumentElement} par_oHtmlContainer Html Element to which the class instance will be added
* @param {Sinfo_ClientObjManager} [par_oClientObjManager] Object that provide to manage the application enviroment.<br> If this parameter is undefined the enviroment create a new Sinfo_ClientObjManager object. 
*/
Sinfo_Application = function(par_oHtmlContainer, par_oClientObjManager)
{
	
    par_oHtmlContainer.className = "Sinfo_Application " + par_oHtmlContainer.className;
   
   var oThis = this;
   var oClientObjManager;
   if(!(!par_oClientObjManager))
   {
      oClientObjManager = par_oClientObjManager;
   }  
   else
   {
      oClientObjManager = new Sinfo_ClientObjManager();
   }       
    
   
   oThis.Ajax = oClientObjManager.Ajax;
   oThis.HtmlContainer = par_oHtmlContainer;
   oThis.ClientObjManager = oClientObjManager;
   
   /**
   * This attribute return the type of the object.
   * @property
   * @type String
   */
   this.type = 'Sinfo_Application';
   
   /**
    * This attribute return one Sinfo_Util object
    * @property 
    * @type Sinfo_Util
    */
   this.Util = oClientObjManager.Util;

   /**
   * This method return one instance of Sinfo_Container object.
   * @return {Sinfo_Container}
   */
   this.createContainer = function ()
         {  
            var oContainer = new Sinfo_Container(oThis);
            return oContainer;
         }


   /**
   * @author dmontesin 06/05/2008
   * This method append a new Image on the container. A HtmlImageElement
   * is returned if you want later change it or remove it. 
   * @param {String} par_sUrl The url you want use as image source
   */
   this.createImage = function(par_sUrl)
   {
      var oImage = document.createElement('img');
      oImage.setAttribute("src", par_sUrl);
      oThis.HtmlContainer.appendChild(oImage);
      return oImage;
   }

   /**
   * @author dmontesin 06/05/2008
   * This method append a new Iframe on the container. A HtmlIFrameElement
   * is returned if you want later change it or remove it. 
   * @param {String} par_sUrl The url you want use as iframe source
   */
   this.createIFrame = function(par_sUrl)
   {
      var oIframe = document.createElement('iframe');
      oIframe.setAttribute("src", par_sUrl);
      oThis.HtmlContainer.appendChild(oIframe);
      return oIframe;
   }

   /**
   * @author dmontesin 06/05/2008
   * This method removes all childs of this application/container.
   * Used to replace the content with another new content 
   */
   this.removeAll = function()
   {
      var oApp = oThis.HtmlContainer;
      var index = oApp.childNodes.length;
      var iCounter = oApp.childNodes.length;
      for(i=0;i < iCounter;i++)
      {
          index--;
          oApp.removeChild(oApp.childNodes[index]);
      }
   }
   
   /**
   * @author dmontesin 06/05/2008
   * This method destroy the current application and remove it from parent.
   */
   this.destroy = function()
   {
      oThis.HtmlContainer.parent.removeChild(oThis.HtmlContainer);
   }


   /**
   * @author dmontesin 06/05/2008
   * This method creates a new DivOverLayer for this Application/Container.
   * @return Sinfo_DivOverLayer
   */

   this.createDivOverLayer = function(par_offsetx, par_offsety, par_width, par_height)
   {
      //return new Sinfo_DivOverLayer(,,par_offsetx, par_offsety, par_width, par_height);
   }
   

   /**
   * @author dmontesin 06/05/2008
   * This method creates a new DivOverLayer for this Application/Container
   * that cover the entire surface
   * @return Sinfo_DivOverLayer
   */

   this.createDivOverLayer()
   {
      //return new Sinfo_DivOverLayer(,,0,0, -1, -1);
   }

   /**
   * This method provide to management of all the comunication with the remote server over the HTTP protocol.<br>
   * The request is sended from the caller container so the server can talk with this object cross the keyword  "Owner".
   * @param {String} par_sInterfaceUrl name of the service to call on the remote server.
   * @param {String} par_sParameter Parameter of the request.
   */
   this.sendWithAjax = function (par_sInterfaceUrl, par_sParameter)
   {
      var cfunction = function(request)
      {
          oClientObjManager.Ajax.crossbrowerEval(request.responseText, oThis);
      }
      oClientObjManager.Ajax.ajaxCall(par_sInterfaceUrl, par_sParameter, true, cfunction);   
   }
        
}

                           