var JeS =
{
  contact: "seboss38@gmail.com",
  /**
   * Point d'entrée
   */
  init: function()
  {
    Ext.BLANK_IMAGE_URL = "/static/images/blank.gif";
    
    // Corrige un bug sur FF3.5 lié notamment aux combos Ext
    Ext.override(Ext.Element, {
      contains: function() {
        var isXUL = Ext.isGecko ? function(node) {
          return Object.prototype.toString.call(node) == '[object XULElement]';
        } : Ext.emptyFn;

        return function(el) {
          return !this.dom.firstChild || // if this Element has no children, return false immediately
           !el ||
           isXUL(el) ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
        };
      }()
    });
    
    // Initialisation du cookie
    this.cp = new Ext.state.CookieProvider();
    
    // Initialisation des composants
    for(var iCmp in this.cmp)
    {
      var cmp = this.cmp[iCmp];
      if(typeof cmp.init == "function") cmp.init.call(cmp);
    }
  },
  creerMask: function()
  {
    var mask = Ext.get(Ext.DomHelper.append(Ext.getBody(),{ cls: "mask" }));
    this.tailleMask(mask);
    
    return mask;
  },
  tailleMask: function(mask)
  {
    if(window.innerHeight&&window.scrollMaxY||window.innerWidth&&window.scrollMaxX)
    {
      yScroll=window.innerHeight+window.scrollMaxY;
      xScroll=window.innerWidth+window.scrollMaxX;
      var a=document.documentElement;
      var b=(a&&a.clientWidth)||document.body.clientWidth||window.innerWidth||self.innerWidth;
      var c=(a&&a.clientHeight)||document.body.clientHeight||window.innerHeight||self.innerHeight;
      xScroll-=(window.innerWidth-b);
      yScroll-=(window.innerHeight-c);
    }
    else if(document.body.scrollHeight>document.body.offsetHeight||document.body.scrollWidth>document.body.offsetWidth)
    {
      yScroll=document.body.scrollHeight;
      xScroll=document.body.scrollWidth;
    }
    else
    {
      yScroll=document.body.offsetHeight;
      xScroll=document.body.offsetWidth;
    }
    mask.setWidth(xScroll);
    mask.setHeight(yScroll);
  },
  
  cmp: {},
   
  erreurCommunication: function()
  {
    alert(String.format("Une erreur s'est produite. Essayez de rafraîchir la page.\nSi le problème devait persister, veuillez contacter {0}.", JeS.contact));
  },
  
  Window: Ext.extend(Ext.Window,
  {
    constructor: function(config)
    {
      JeS.Window.superclass.constructor.apply(this, arguments);
    }
  }),
  
  data: {}
}

// FF 2.0 ne dispose pas de cette fonction en natif
if(!String.trim)
{
  String.trim = function(str)
  {
    return str.toString().replace(/^\s+|\s+$/g, "");
  }
}

if(!/mobile/i.test(navigator.userAgent)) Ext.onReady(JeS.init, JeS, {delay: 100});