try { console.log('init console loging...done'); } catch(e) { console = { log: function() {} } }
var Debug = {};
var Dom = {};
var Mouse = {};
var Global = {};
var HTTP = {};
var Draw = {};
Global.registerObject = function(objType, id, o) {
if (!this.objById)
this.objById = new Array();
if (!this.objById[objType])
this.objById[objType] = new Array();
if (!this.objById[objType][id])
this.objById[objType][id] = o;
}
Global.getObjectById = function(objType, id) {
return this.objById[objType][id];
}
Global.getObjectsByType = function(objType) {
return this.objById[objType] || new Array();
}
Global.myGarbageCollector = [];
String.prototype.repeat = function(many) {
var s = '';
while (--many >= 0) s += this;
return s;
}
String.prototype.firstUpper = function() {
return this.substr(0,1).toUpperCase()+this.substr(1).toLowerCase();
}
String.prototype.toFullString = function() {
return this
}
Number.prototype.addZero = function(value) {
return ('0'.repeat(value)+this.toString()).substring(('0'.repeat(value)+this.toString()).length-value);
}
Object.prototype.each = function(fct) {
for (var i in this) {
try {
if ( !this.constructor.prototype[i] ) {
fct.call(this,this[i], i);
}
}
catch(err) {
fct.call(this,this[i], i); //PB with native prototype of DIV Element causes this.constructor.prototype[i] to fail
}
}
}
Function.prototype.bind = function(obj) {
var _this = this;
var _args = $A(arguments);
_args.shift();
return function() {
var args_ = _args.concat($A(arguments));
return _this.apply(obj, args_);
}
}
function $(id) {
return document.getElementById(id);
}
function $$(selector) {
  //On découpe les éléments du sélecteur
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = $(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        elements = currentContext[h].getElementsByTagName(tagName);
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        elements = currentContext[h].getElementsByTagName(tagName);
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}
function $A(iterable) {
  if (!iterable) return [];
  //Si l'objet itérable à déjà une méthode lui permettant de se convertir en tableau, alors on renvoie ça
  if (iterable.toArray) {
    return iterable.toArray();
  } else { //L'objet ne définit pas de méthode pour se convertir en tableau, on en définit une pour lui
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}
var Util = {};
Util.delay = function(fct, time, timerType) {
var timer = setTimeout( fct, time);
var id = this.getId();
Global.registerObject((timerType)?timerType:'timer', id, timer);
}
Util.clearTimeout = function(timerType) {
var tblTimer = Global.getObjectsByType((timerType)?timerType:'timer');
for (var i=0; i < tblTimer.length; i++) {
clearTimeout(tblTimer[i]);
}
}
/* NOT USED BUT INTERESTING */
Util._try = function(code) {
try {
code();
}
catch (err) {
Debug.debug_err(err);
Debug.debug(code);
throw err;
}
}
var alert_ = window.alert;
window.alert = function() {
var str = '';
for (var i=0; i< arguments.length; i++) {
if ( ( typeof arguments[i] == 'object' || typeof arguments[i] == 'array' ) && arguments[i].length > 0 ) {
for (var j=0; j< arguments[i].length; j++) {
str += arguments[i][j];
if ( j != arguments[i].length-1 )
str += ',';
}
}
else
str += arguments[i];
if ( i != arguments.length-1 )
str += '\n';
}
alert_(str);
}
Util.collector = new Array();
Util.collector.register = function(obj, objAttr, token) {
}
Util.collector.unregister = function(obj) {
var tab = [];
this.each( function(el, i) {
if ( el[0] == obj ) {
el[0][el[1]] = null;
}
});
}
Util.collector.empty = function() {
for (var i=0; i < this.length; i++) {
this[i][0][this[i][1]] = null;
}
}
Util.collector.emptyOne = function(obj, objAtt) {
obj[objAtt] = null;
}
Util.collector.emptyChildNodes = function(dom) {
for (var i = dom.childNodes.length -1; i >= 0; i--) {
if ( dom.childNodes[i].typeOf == 'LDivElement') {
Util.collector.emptyChildNodes(dom.childNodes[i]);
}
dom.removeChild_(dom.childNodes[i]);
}
}
Util.getId = function() {
if (!this.id)
this.id = 0;
this.id++;
return this.id;
}
window.onbeforeunload = function() {
try {
Util.collector.empty();
Util.collector.emptyChildNodes(lbody);
}
catch(err) { //lbody n'existe pas si tout DOOM n'est pas inclus
}
}
window.onunload = function() {
try {
Util.collector.empty();
Util.collector.emptyChildNodes(lbody);
}
catch(err) { //lbody n'existe pas si tout DOOM n'est pas inclus
}
}
Util.random = function(maxVal) {
return Math.floor(Math.random()*maxVal);
}
Cookie = {};
Cookie.getCookie = function(name) {
var index = document.cookie.indexOf(name+'=');
var length = (name+'=').length;
if ( index != -1 ) {
var indexFin = ( document.cookie.indexOf(';', index) != -1 ? document.cookie.indexOf(';', index) : document.cookie.length );
return document.cookie.substring( index+length, indexFin );
}
else {
return false;
}
}
Cookie.setCookie = function(name, value, dtExpire) {
var strExpire = ( dtExpire ) ? '; expires='+dtExpire.toGMTString() : '';
document.cookie = name+'='+value+strExpire;
}
Cookie.delCookie = function(name) {
Cookie.setCookie(name, '', new Date());
}
Log = {};
Log.log = function(type_, params) {
controller.pool.newHttpRequest('log.asp?type='+type_, {
onSuccess: Undefined.nothing,
method: 'POST',
body: 'params='+params
});
}
Observable = function() {
this.observers = new Array();
this.notifyObservers = function() {
for (var i=0; i < this.observers.length; i++) {
this.observers[i].update(this);
}
}
this.addObserver = function(o) {
this.observers.push(o);
}
this.rmObserver = function(o) {
for (var i=this.observers.length-1; i >=0 ; i--) {
if ( o == this.observers[i] ) {
this.observers.splice(i, 1);
}
}
}
this.switchObservers = function(observable) {
var staticObservers = [];
for (var i=0; i < this.observers.length; i++) {
if ( !this.observers[i].static ) {
this.observers[i].observes(observable);
}
else
staticObservers.push(this.observers[i]);
}
this.observers = staticObservers;
}
}
Observer = function() {
if (!this.update) this.update = function() {}
this.observes = function(observable, att) {
this.observed = observable;
observable.addObserver(this);
this.update(this.observed);
}
this.stopObserving = function(observable) {
this.observed = Undefined;
observable.rmObserver(this);
}
}
StaticObserver = function() {
Observer.call(this);
this.static = true;
}
/* UNUSED BUT INTERESTING */
Scrollable = function() {
if (this.childNodes.length > 0) {
var plusBas = this.childNodes[0].top + this.childNodes[0].height;
for (var i=0; i < this.childNodes.length; i++) {
plusBas = Math.max(plusBas, this.childNodes[i].top + this.childNodes[i].height);
}
if ( this.height < plusBas ) {
this.minTop = this.childNodes[0].top;
this.maxTop = this.minTop + this.height - plusBas;
this.upArrow = new LDivElement( 'upArrow', '', 10, '0px solid #000', '', '', '', '0px', 2, 0, 6, 11, '');
this.upArrow.style.left = 'auto';
this.upArrow.style.right = 2+'px';
this.upArrow.style.background = '#FFF url(include/img/upArrow.png) 0 0 no-repeat';
this.upArrow.setEvent('click', 'this.parentNode', 'goUp', []);
this.downArrow = new LDivElement( 'downArrow', '', 10, '0px solid #000', '', '', '', '0px', 0, 0, 6, 11, '');
this.downArrow.style.left = 'auto';
this.downArrow.style.right = 2+'px';
this.downArrow.style.top = 'auto';
this.downArrow.style.bottom = 4+'px';
this.downArrow.style.background = '#FFF url(include/img/downArrow.png) 0 0 no-repeat';
this.downArrow.setEvent('click', 'this.parentNode', 'goDown', []);
this.appendChild_(this.upArrow, this.downArrow);
this.goDown = function() {
if ( this.childNodes[0].top > this.maxTop) {
for (var i=0; i < this.childNodes.length; i++) {
if ( this.childNodes[i].id != 'upArrow' && this.childNodes[i].id != 'downArrow' )
this.childNodes[i].setTop(this.childNodes[i].getTop()-10);
}
}
}
this.goUp = function() {
if ( this.childNodes[0].top < this.minTop) {
for (var i=0; i < this.childNodes.length; i++) {
if ( this.childNodes[i].id != 'upArrow' && this.childNodes[i].id != 'downArrow' )
this.childNodes[i].setTop(this.childNodes[i].getTop()+10);
}
}
}
}
}
}
var Undefined = {};
Undefined.getAllChildsLength = function() {
return 0;
}
Undefined.ldom = {
id: 'UNDEFINED',
getTop: function() {
return 0;
},
getHeight: function() {
return 0;
}
}
Undefined.childBefore = function() {
return this;
}
Undefined.value = 'Undefined';
Undefined.innerHTML = '';
Undefined.nothing = function() {}
Undefined.view = {
update: function() {}
}
Undefined.request = {
readyState: 4,
abort: function() {}
}
Undefined.toString = function() {
return 'Undefined';
}
Undefined.getColor = function() {
return '#FFE771';
}
Undefined.getLibelle = function() {
return 'Jour chômé';
}
Undefined.addConge = Undefined.nothing
Undefined.isCalendaire = function() {
return 0;
}
Undefined.out = Undefined.nothing
Undefined.outDelayed = Undefined.nothing
Undefined.over = Undefined.nothing
Undefined.nom = '-';
Undefined.prenom = '-';
Undefined.dt_arr = '-';
Undefined.dt_dep = '-';
Observer.call(Undefined);
Observable.call(Undefined);
Undefined.getJours = function() {
return 0;
}
Undefined.getSolde = function() {
return Undefined;
}
UndefinedObject = function() {
this.isUndefined = true;
this.nothing = function() {}
Observable.call(this);
this.getJours = function() {
return '0';
}
this.getSolde = function() {
return new UndefinedObject();
}
this.setActif = this.nothing;
this.switchSoldes = this.nothing;
this.tabSoldes = Undefined;
this.getDateFinaleSoldes = function() {
return ( this.dateFinaleSoldes || this.setDateFinaleSoldes() );
}
this.setDateFinaleSoldes = function() {
return this.dateFinaleSoldes = new UndefinedObject();
}
this.getLibelle = function() {
return '-';
}
this.getNom = function() {
return '-'
}
this.getPrenom = function() {
return '-';
}
this.updateSemaineType = Undefined.nothing
this.getInfosJoursTravailles = Undefined.nothing
this.getTabSoldes = function() {
return new Array(new Array(new Undefined(), new Undefined(), new Undefined(), new Undefined(), new Undefined()),new Array(new Undefined(), new Undefined(), new Undefined(), new Undefined(), new Undefined()),new Array(new Undefined(), new Undefined(), new Undefined(), new Undefined(), new Undefined()),new Array(new Undefined(), new Undefined(), new Undefined(), new Undefined(), new Undefined()));
}
this.toString = function() {
return '';
}
this.get_nbj_travaille_prec = function() {
return 0;
}
this.get_nbj_travaille_encours = function() {
return 0;
}
this.get_nbj_absence = function() {
return 0;
}
this.toFullString = function() {
return '';
}
this.toMonthString = function() {
return '-';
}
this.setJours = this.nothing;
this.getTime = function() {
return 0;
}
}
/*
Mouse.addEvent = function(evt, args) {
if ( this.margeRight == undefined )
this.margeRight = this.margeLeft = this.offsetWidth;
var grp = args[0];
var fct = args[1];
var arg = ( args[2] || ( new Array() ) );
grp.leader = this;
evt = evt || event;
Mouse.savePos(this, evt);
document.ondblclick = function(e) {
return false;
}
switch (fct) {
case 'mouseMove':
document.onmousemove = function(e) {
Mouse.evtLocked = true;
grp.setLeft(Math.max( Math.min( mybro.getMouseX(e) - Mouse.decalX, Mouse.guest.parentNode.getOffsetWidth() - Mouse.guest.getMargeRight() ), Mouse.guest.getMargeLeft() - Mouse.guest.getOffsetWidth() + Mouse.guest.parentNode.getOffsetLeft() ));
grp.setTop(Math.max( Math.min( mybro.getMouseY(e) - Mouse.decalY, Mouse.guest.parentNode.getOffsetHeight() - Mouse.guest.getOffsetHeight() ), Mouse.guest.parentNode.getOffsetTop() ));
}
document.onmouseup = function(e) {
document.onmousemove = null;
Mouse.evtLocked = false;
}
break;
case 'cloneAndMouseMove':
newGrp = grp.cloneNode(false);
newGrp.setZIndex(grp.getZIndex()-1);
grp.parentNode.appendChild(newGrp);
newGrp.leader = grp.leader;
document.onmousemove = function(e) {
Mouse.evtLocked = true;
newGrp.setLeft(Math.max( Math.min( mybro.getMouseX(e) - Mouse.decalX, Mouse.guest.parentNode.getOffsetWidth() - Mouse.guest.getMargeRight() ), Mouse.guest.getMargeLeft() - Mouse.guest.getOffsetWidth() + Mouse.guest.parentNode.getOffsetLeft() ));
newGrp.setTop(Math.max( Math.min( mybro.getMouseY(e) - Mouse.decalY, Mouse.guest.parentNode.getOffsetHeight() - Mouse.guest.getOffsetHeight() ), Mouse.guest.parentNode.getOffsetTop() ));
}
document.onmouseup = function(e) {
document.onmousemove = null;
Mouse.evtLocked = false;
}
break;
case 'dragNDrop':
document.onmousemove = function(e) {
Mouse.evtLocked = true;
mybro.setLeft(grp, Math.max( Math.min( (mybro.getMouseX(e) - Mouse.decalX), (mybro.getWindowWidth() - Mouse.guest.margeRight)), Mouse.guest.margeLeft - Mouse.guest.offsetWidth));
mybro.setTop(grp, Math.max( Math.min( (mybro.getMouseY(e) - Mouse.decalY), mybro.getWindowHeight() - Mouse.guest.offsetHeight ), 0 ));
}
document.onmouseup = function(e) {
document.onmousemove = null;
Mouse.evtLocked = false;
}
break;
case 'reduce':
if (!Mouse.evtLocked) {
if ( !grp.reduced ) {
grp.reduce(arg[0]);
}
else {
grp.expand(arg[0]);
}
}
break;
case 'addResize':
this.onmousemove = function(e) {
if ( !Mouse.evtLocked )
this.setResizeCursor(e);
}
this.onmouseout = function(e) {
this.onmousemove = null;
this.onmousedown = null;
}
this.setEvent('onmousedown', 'Mouse.addEvent', 'this', [ldiv, 'doResize']);
break;
case 'doResize':
document.onmousemove = function(e) {
Mouse.evtLocked = true;
if ( Mouse.guest.getCursor() == 'e-resize' || Mouse.guest.getCursor() == 'ne-resize' || Mouse.guest.getCursor() == 'se-resize' )
grp.setWidth( Math.max( Math.min( mybro.getMouseX(e) - Mouse.guest.getOffsetLeft() + Mouse.guest.oldWidth - Mouse.decalX, mybro.getWindowWidth() - Mouse.guest.getOffsetLeft() ), Mouse.guest.getMinimumWidth() ) );
if ( Mouse.guest.getCursor() == 's-resize' || Mouse.guest.getCursor() == 'sw-resize' || Mouse.guest.getCursor() == 'se-resize' )
grp.setHeight( Math.max( Math.min( mybro.getMouseY(e) - Mouse.guest.getOffsetTop() + Mouse.guest.oldHeight - Mouse.decalY, mybro.getWindowHeight() - Mouse.guest.getOffsetTop() ), Mouse.guest.getMinimumHeight() ) );
if ( Mouse.guest.getCursor() == 'move' ) {
grp.setLeft( Math.max( Math.min( (mybro.getMouseX(e) - Mouse.decalX), (mybro.getWindowWidth() - Mouse.guest.getMargeRight())), Mouse.guest.getMargeLeft() - Mouse.guest.getOffsetWidth()));
grp.setTop( Math.max( Math.min( (mybro.getMouseY(e) - Mouse.decalY), mybro.getWindowHeight() - Mouse.guest.getOffsetHeight() ), 0 ));
}
}
document.onmouseup = function(e) {
document.onmousemove = null;
Mouse.guest.resetCursor();
Mouse.evtLocked = false;
}
break;
default:
break;
}
}*/
Mouse.savePos = function(ldiv, evt) {
this.guest = ldiv;
ldiv.oldWidth = ldiv.width;
ldiv.oldHeight = ldiv.height;
this.decalX = mybro.getMouseX(evt) - ldiv.getOffsetLeft();
this.decalY = mybro.getMouseY(evt) - ldiv.getOffsetTop();
}
Mouse.getXForElement = function() {
return Math.max( Math.min( mybro.getMouseX(Mouse.e) - this.decalX, this.guest.parentNode.getOffsetWidth() - this.guest.getMargeRight() ), this.guest.getMargeLeft() - this.guest.getOffsetWidth() + this.guest.parentNode.getOffsetLeft() );
}
Mouse.getYForElement = function() {
return Math.max( Math.min( mybro.getMouseY(Mouse.e) - this.decalY, this.guest.parentNode.getOffsetHeight() - this.guest.getOffsetHeight() ), this.guest.parentNode.getOffsetTop() );
}
/*Mouse.Dragable = function( obj, grp ) {
obj.onmousedown = function(e) {
Mouse.addEvent(grp, e, 'mouseMove');
}
}*/
Mouse.preventDefault = function() {
mybro.preventDefault(Mouse.e);
}
Mouse.evtLocked = false;
function Browser() {
this.win = ( navigator.appVersion.indexOf( 'Win' )  != -1 );
this.mac = ( navigator.appVersion.indexOf( 'Mac' )  != -1 );
this.lin = ( navigator.userAgent.indexOf( 'Linux' ) != -1 );
this.plateForm = ( this.win ) ? 'windows' : ( ( this.mac ) ? 'mac' : 'linux' );
if ( !document.layers ) {
this.op      = ( navigator.userAgent.indexOf( 'Opera' )      != -1 );
this.konq    = ( navigator.userAgent.indexOf( 'Konqueror' )  != -1 );
this.saf     = ( navigator.userAgent.indexOf( 'Safari' )     != -1 );
this.moz     = ( navigator.userAgent.indexOf( 'Gecko' )      != -1 && !this.saf && !this.konq);
this.moz10   = ( navigator.userAgent.indexOf( 'Firefox/1.0' )!= -1 && this.moz );
this.moz15   = ( navigator.userAgent.indexOf( 'Firefox/1.5' )!= -1 && this.moz );
this.net70   = ( navigator.userAgent.indexOf( 'Netscape/7.0' )!= -1 && this.moz );
this.ie7     = ( navigator.userAgent.indexOf( 'MSIE 7.0' )!= -1 );
this.ie      = ( document.all && !this.op );
this.ie4     = ( this.ie && !document.getElementById );
this.ie5x    = ( this.ie && document.all && document.getElementById );
this.ie5mac  = ( this.mac && this.ie5x );
this.ie5xwin = ( this.win && this.ie5x );
this.fast = ( this.ie7 || !this.ie ); //Pour le scroll dans le planning
}
this.browserName = ( this.ie4 ) ? 'Internet Explorer 4' : ( ( this.ie5x ) ? 'Internet Explorer 5+' : ( ( this.moz ) ? 'Mozilla' : ( ( this.saf ) ? 'Safari' : ( ( this.op ) ? 'Opera' : 'Konqueror' ) ) ) );
this.browserClassName = ( this.ie4 ) ? 'ie' : ( ( this.ie5x ) ? 'ie' : ( ( this.moz ) ? ( ( this.moz10 ) ? 'moz10' : ( ( this.moz15 ) ? 'moz15' : 'net70' ) ) : ( ( this.saf ) ? 'saf' : ( ( this.op ) ? 'op' : 'konq' ) ) ) );
this.setOpacity = function(dom, op) { }
this.getMouseX = function(e) { return 0; }
this.getMouseY = function(e) { return 0; }
this.getCompatibleWidth = function(v, bt, br, bb, bl, pt, pr, pb, pl) { return 0; }
this.getCompatibleHeight = function(v, bt, br, bb, bl, pt, pr, pb, pl) { return 0; }
this.setCompatibleWidth = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) { return 0; }
this.setCompatibleHeight = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) { return 0; }
this.getWindowWidth = function() { return 0; }
this.getWindowHeight = function() { return 0; }
this.getRelativeMouseX = function(dom, e) { return 0; }
this.getRelativeMouseY = function(dom, e) { return 0; }
this.getStyleProperty = function(dom, property) { return ''; }
this.getHttpObject = function() {
return new XMLHttpRequest();
}
this.setSimpleBackground = function(div, imgURL, repeat) {
div.style.background = 'url(\'' + imgURL + '\') 0 0 transparent '+ ((repeat=='no')?'no-repeat':('repeat'+repeat));
}
this.preventDefault = function(evt) {
evt.preventDefault();
}
this.getSoundObject = function() {
var mysound = document.createElement('EMBED');
mysound.src = "start.wav";
mysound.style.visibility = 'hidden';
mysound.style.height = 0+'px';
mysound.style.width = 0+'px';
return mysound;
}
this.getErrorNumber = function(err) {
return err.lineNumber;
}
this.getErrorDescription = function(err) {
return err.toString();
}
this.setBackground = function(doom, pic, end) {
Util.collector.emptyChildNodes(doom);
var img = new LDivElement( '', doom.className, doom.zIndex-1, '0px solid #000', '', '', '', doom.padding.getPadding(), 0, 0, doom.height, doom.width, '');
img.style.background = ('url(\''+pic+'\') '+end);
doom.appendChild_(img);
}
this.getMouseEnterLabel = function() {
return 'mouseover';
}
this.getMouseLeaveLabel = function() {
return 'mouseout';
}
this.getCompatibleOffsetBackgroundImage = function(borderWidth) {
return 0;
}
this.getMessageNav = function() {
return new LDivElement( '', 'warningNav hidden', 10, '0px solid #000', '', '', '', '0px', 0, 14, 0, 732, '' ); //Par défaut, on suppose que les gens ne sont pas sous IE 6 donc pas de message
}
this.getOffsetTop = function(dom) {
return dom.offsetTop;
}
eval(this.browserClassName+'Browser').call(this);
}
ieBrowser = function() {
this.setOpacity = function(dom, op) {
dom.style.filter = 'alpha(opacity='+parseInt(op*100)+')';
}
this.getMouseX = function(e) {
return event.x;
}
this.getMouseY = function(e) {
return event.y;
}
this.getRelativeMouseX = function(dom, e) {
evt = e || event;
return ( evt.offsetX + parseInt(dom.border.getLeftWidth()) + 1 );
}
this.getRelativeMouseY = function(dom,e) {
evt = e || event;
return ( evt.offsetY + parseInt(dom.border.getTopWidth()) + 1 );
}
this.getCompatibleWidth = function(v, bt, bl, bb, br, pt, pl, pb, pr) {
return v;
}
this.getCompatibleHeight = function(v, bt, bl, bb, br, pt, pr, pb, pl) {
return v;
}
this.setCompatibleWidth = function(dom, v, bt, bl, bb, br, pt, pl, pb, pr) {
dom.style.width = v+'px';
}
this.setCompatibleHeight = function(dom, v, bt, bl, bb, br, pt, pl, pb, pr) {
dom.style.height = v+'px';
}
this.getWindowWidth = function() {
return document.body.clientWidth;
}
this.getWindowHeight = function() {
return document.body.clientHeight;
}
this.getStyleProperty = function(dom, property) {
if ( property.indexOf('-') != -1 )
property = property.split('-')[0]+property.split('-')[1].firstUpper();
return dom.currentStyle[property];
}
this.getHttpObject = function() {
return new ActiveXObject("Microsoft.XMLHTTP");
}
this.setSimpleBackground = function(div, imgURL, repeat) {
if (repeat == 'no')
var sizing = 'image';
if (repeat == '-x' || repeat == '-y' || repeat == '')
var sizing = 'scale';
div.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' +imgURL+ '\', sizingMethod=\'' +sizing+ '\')';
}
this.preventDefault = function(evt) {
Undefined.nothing();
}
this.getErrorNumber = function(err) {
return 'unknown';
}
this.getErrorDescription = function(err) {
return err.description;
}
this.setBackground = function(doom, pic, end) {
var left = end.split('px ')[0];
var top = end.split('px ')[1];
var img = new LDivElement( '', doom.className, doom.zIndex-1, '0px solid #FFF', '', '', '', doom.padding.getPadding(), top, left, doom.height, doom.width, '');
img.style.filter += 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' +pic+ '\', sizingMethod=\'scale\')';
doom.appendChild_(img);
}
this.getMouseEnterLabel = function() {
return 'mouseenter';
}
this.getMouseLeaveLabel = function() {
return 'mouseleave';
}
this.getCompatibleOffsetBackgroundImage = function(borderWidth) {
return -borderWidth;
}
this.getMessageNav = function() {
if ( !this.fast )
return new LDivElement( '', 'warningNav hidden', 10, '0px solid #000', '', '', '', '0px', 0, 14, 20, 732, 'Pour un comportement plus fluide de Mes Congés, nous vous conseillons les navigateurs <a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx" target="_blank">Internet Explorer 7</a> ou <a href="http://www.mozilla-europe.org/fr/products/firefox/" target="_blank">Firefox</a>');
else
return new LDivElement( '', 'warningNav hidden', 10, '0px solid #000', '', '', '', '0px', 0, 14, 0, 732, '');
}
this.getOffsetTop = function(dom) {
var top = dom.offsetTop;
var el = dom;
while (el = el.parentNode) {
top += el.offsetTop||0;
}
return top;
}
}
safBrowser = function() {
this.setOpacity = function(dom, op) {
dom.style.filter = 'alpha(opacity='+parseInt(op*100)+')';
}
this.getMouseX = function(e) {
return event.x;
}
this.getMouseY = function(e) {
return event.y;
}
this.getRelativeMouseX = function(dom,e) {
evt = e || event;
return ( evt.offsetX + 1 );
}
this.getRelativeMouseY = function(dom,e) {
evt = e || event;
return ( evt.offsetY + 1 );
}
this.getCompatibleWidth = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return Math.max(v-bl-br-pl-pr, 0);
}
this.getCompatibleHeight = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return Math.max(v-bt-bb-pt-pb, 0);
}
this.setCompatibleWidth = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.width = Math.max((v-bl-br-pl-pr),0)+'px';
}
this.setCompatibleHeight = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.height = Math.max((v-bt-bb-pt-pb),0)+'px';
}
this.getWindowWidth = function() {
return document.body.clientWidth;
}
this.getWindowHeight = function() {
return document.body.clientHeight;
}
this.getStyleProperty = function(dom, property) {
return document.defaultView.getComputedStyle(dom,null).getPropertyValue(property);
}
}
mozBrowser = function() {
this.setOpacity = function(dom, op) {
dom.style.opacity = op;
}
this.getMouseX = function() {
return Mouse.e.pageX;
}
this.getMouseY = function() {
return Mouse.e.pageY;
}
this.getCompatibleWidth = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return Math.max((v+bl+br+pl+pr),0);
}
this.getCompatibleHeight = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return Math.max((v+bt+bb+pt+pb),0);
}
this.setCompatibleWidth = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.width = Math.max((v-bl-br-pl-pr),0)+'px';
}
this.setCompatibleHeight = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.height = Math.max((v-bt-bb-pt-pb),0)+'px';
}
this.getWindowWidth = function() {
return window.innerWidth;
}
this.getWindowHeight = function() {
return window.innerHeight;
}
this.getStyleProperty = function(dom, property) {
return document.defaultView.getComputedStyle(dom,null).getPropertyValue(property);
}
}
moz10Browser = function() {
mozBrowser.call(this);
this.getRelativeMouseX = function(dom, e) {
evt = e || event;
return ( evt.layerX + 1 );
}
this.getRelativeMouseY = function(dom, e) {
evt = e || event;
return ( evt.layerY + 1 );
}
}
moz15Browser = function() {
mozBrowser.call(this);
this.getRelativeMouseX = function(dom, e) {
evt = e || event;
return evt.layerX;
}
this.getRelativeMouseY = function(dom, e) {
evt = e || event;
return evt.layerY;
}
}
net70Browser = function() {
mozBrowser.call(this);
this.getRelativeMouseX = function(dom, e) {
evt = e || event;
return evt.layerX;
}
this.getRelativeMouseY = function(dom, e) {
evt = e || event;
return evt.layerY;
}
}
opBrowser = function() {
mozBrowser.call(this);
this.getCompatibleHeight = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return v;
}
this.getCompatibleWidth = function(v, bt, br, bb, bl, pt, pr, pb, pl) {
return v;
}
this.setCompatibleHeight = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.height = v+'px';
}
this.setCompatibleWidth = function(dom, v, bt, br, bb, bl, pt, pr, pb, pl) {
dom.style.width = v+'px';
}
this.getRelativeMouseX = function(dom, e) {
evt = e || event;
return evt.offsetX;
}
this.getRelativeMouseY = function(dom, e) {
evt = e || event;
return evt.offsetY;
}
}
var mybro = new Browser();
Debug.debug = function( str) {
debug_window = new Debug.SinglePopup();
debug_window.document.body.innerHTML += str+'<br>';
}
Debug.off = function() {
if ( Debug.SinglePopup.instance )
debug_window.close();
}
Debug.debug_err = function(err) {
Debug.debug( 'ERROR : ' + (err.number & 0xFFFF) + ' line 0<br>' + err.message );
}
Debug.reset = function() {
debug_window = new Debug.SinglePopup();
}
Debug.SinglePopup = function() {
_this = arguments.callee;
if ( _this.instance == undefined )
_this.instance = window.open('', 'debug', 'height=200,width=400,status=no,toolbar=no,resizable=no,scrollbars=yes');
return _this.instance;
}
/* FROM PROTOTYPE */
Array.prototype.push = function() {
var startLength = this.length;
for (var i = 0; i < arguments.length; i++)
    this[startLength + i] = arguments[i];
  return this.length;
}
Array.prototype.toString = function() {
var str = '';
for( var i=0; i<this.length; i++) {
str += this[i].toString();
if ( i!=this.length-1 )
str += ',';
}
return str;
}
Array.prototype.remove = function(obj) {
var offset = 0;
var position = -1; //La dernière position de l'élément viré
this.getIndex(obj).each( function(el, i) {
this.splice(el-offset,1);
position = el-offset;
offset++;
}.bind(this));
return position;
}
Array.prototype.getIndex = function(obj) {
var tab = [];
for( var i=0; i < this.length; i++) {
if ( this[i] == obj )
tab.push(i);
}
return tab;
}
Array.prototype.getFirst = function() {
if ( this.length > 0 )
return this[0];
else
return null;
}
Array.prototype.getLast = function() {
if ( this.length > 0 )
return this[this.length-1];
else
return null;
}
Array.SingleArray = function() {
_this = arguments.callee;
if ( _this.instance == undefined )
_this.instance = new Array();
return _this.instance;
}
Array.concat = function(tab1, tab2) {
var newTab = new Array();
for (var i=0; i < tab1.length; i++)
newTab.push(tab1[i]);
for (var j=0; j < tab2.length; j++)
newTab.push(tab2[j]);
return newTab;
}
Array.prototype.insert = function(el, pos) {
var length = this.length
for (var i=length; i > pos; i--) {
this[i] = this[i-1];
}
this[pos] = el;
}
HttpRequestPool = function() {
this.httpRequests = new Array();
this.newHttpRequest = function(url, options) {
if ( !options || ( options && !options.noRed ) )
this.setConnexionOn();
else //Cas où on a précisé qu'on ne voulait pas le voyant rouge, on affiche le vert
controller.server.showGreen();
var req = new HttpRequest(url, options);
return req.request;
}
this.registerHttpRequest = function(httpRequest) {
if (httpRequest.priority == 1)
this.cancelNonPrior();
if (httpRequest.priority == 2)
this.abortPreviousToken(httpRequest.token);
httpRequest.id = this.httpRequests.push(httpRequest)-1;
controller.server.setRed(this.httpRequests.length);
}
this.unRegisterHttpRequest = function(id) {
this.httpRequests.splice(id,1);
controller.server.setRed(this.httpRequests.length);
for (var i=id; i < this.httpRequests.length; i++)
this.httpRequests[i].id = i;
this.checkPriority();
}
this.checkPriority = function() {
var bln = true;
for (var i=0; i < this.httpRequests.length; i++) {
if (this.httpRequests[i].priority==1) {
bln = false;
break;
}
}
if (bln)
this.rescheduleNonPrior();
}
this.cancelNonPrior = function() {
for (var i=0; i < this.httpRequests.length; i++) {
if (this.httpRequests[i].priority==0) {
this.httpRequests[i].request.abort();
this.httpRequests[i].canceled = true;
}
}
}
this.rescheduleNonPrior = function() {
for (var i=0; i < this.httpRequests.length; i++) {
if (this.httpRequests[i].canceled) {
this.httpRequests[i].sendAsync();
this.httpRequests[i].canceled = false;
}
}
}
this.abortPreviousToken = function(token) {
for (var i=0; i < this.httpRequests.length; i++) {
if (this.httpRequests[i].token && this.httpRequests[i].token != token) {
this.httpRequests[i].request.abort();
this.unRegisterHttpRequest(this.httpRequests[i].id);
}
}
}
this.abortAll = function() {
for (var i=0; i < this.httpRequests.length; i++) {
this.httpRequests[i].request.abort();
this.unRegisterHttpRequest(this.httpRequests[i].id);
}
}
this.httpRequestFinished = function(httpRequest) {
if ( httpRequest.request.status == 306 ) {
var tabError = eval(httpRequest.request.responseText);
var status = tabError[0][0];
var description = tabError[0][1];
this.setConnexionOff();
controller.server.hideGreen();
if (httpRequest.async)
this.unRegisterHttpRequest(httpRequest.id);
if ( status == 10100 )
location.href = GLO_URL_ACCUEIL; //On ne redirige pas vers deconnexion car sinon on perd le cookie en plus, alors que là, si on a le cookie, on sera reconnecté automatiquement
else {
alert('Erreur sur le serveur, votre action n\'a pas été prise en compte : \n\n'+description);
}
return ;
}
controller.server.setRed(this.httpRequests.length);
if ( httpRequest.request.status == 500 ) {
controller.displayError('Erreur sur le serveur, votre action n\'a pas été prise en compte');
return ;
}
else {
try {
httpRequest.onSuccess.apply(this, eval(httpRequest.response));
}
catch(e) {
Log.log('retour_serveur_inexploitable', '<responsetext>'+httpRequest.request.responseText.replace(/'/gi, '\\\'')+'</responsetext>');
controller.displayError('Erreur sur le serveur, votre action n\'a pas été prise en compte');
throw(e);
}
}
if (httpRequest.async)
this.unRegisterHttpRequest(httpRequest.id);
this.setConnexionOff();
controller.server.hideGreen();
Util.collector.emptyOne(httpRequest, 'request');
}
this.setConnexionOn = function() {
controller.connexionOn();
}
this.setConnexionOff = function() {
if ( this.httpRequests.length == 0 )
controller.connexionOff();
}
}
HttpRequest = function(url, options) {
this.method = options.method||'GET';
this.url = url;
this.async = (options.async===false)?false:true;
this.body = options.body||null;
this.onSuccess = options.onSuccess||Undefined.nothing;
this.onError = options.onError||Undefined.nothing;
this.token = options.token||null;
this.format = options.format||'HTML';
this.priority = options.priority||0;
if ( this.url.indexOf('?') != -1 )
this.url += '&randomNumber='+Util.random(1000000);
else
this.url += '?randomNumber='+Util.random(1000000);
this.request = mybro.getHttpObject();
Util.collector.register(this, 'request');
this.response = null;
this.sendAsync = function() {
var _this = this;
this.request.onreadystatechange = function() {
_this.callBack();
}
this.request.send(this.body);
}
this.callBack = function() {
if (this.async) {
if (this.request.readyState == 4) {
if (this.request.status == 200){ //Attention, dans notre gestion des erreurs, les status 10000...40000 donnent des status 200 quand même
if (this.format == 'XML')
this.response = this.request.responseXML;
else if (this.format == 'HTML') {
this.response = this.request.responseText;
}
}
controller.pool.httpRequestFinished(this);
}
}
else {
if (this.format == 'XML')
this.response = this.request.responseXML;
else if (this.format == 'HTML') {
this.response = this.request.responseText;
}
controller.pool.httpRequestFinished(this);
}
}
this.request.open(this.method, this.url, this.async);
if (this.method=='POST') {
this.request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
if (!this.async) {
  this.request.send(this.body);
this.callBack();
}
else {
controller.pool.registerHttpRequest(this);
this.sendAsync();
}
}
LBorder = function( border, borderWidth, borderStyle, borderColor ) {
if ( border != '' ) {
var match = border.split(' ');
match[0] = match[0].split('px')[0];
var matches = new Array( [ match[0],match[0],match[0],match[0] ], [ match[1],match[1],match[1],match[1] ], [ match[2],match[2],match[2],match[2] ]);
}
else if ( borderWidth != '' ) {
var bw = borderWidth.split(/px\s?/g);
var bs = borderStyle.split(' ');
var bc = borderColor.split(' ');
var matches = new Array(bw, bs, bc);
}
else {
var matches = new Array( [ 0,0,0,0 ], [ 0,0,0,0 ], [ 0,0,0,0 ]);
}
this.borderWidthTop = parseInt(matches[0][0]);
this.borderWidthRight = parseInt(matches[0][1]);
this.borderWidthBottom = parseInt(matches[0][2]);
this.borderWidthLeft = parseInt(matches[0][3]);
this.borderStyleTop = matches[1][0];
this.borderStyleRight = matches[1][1];
this.borderStyleBottom = matches[1][2];
this.borderStyleLeft = matches[1][3];
this.borderColorTop = matches[2][0];
this.borderColorRight = matches[2][1];
this.borderColorBottom = matches[2][2];
this.borderColorLeft = matches[2][3];
this.getTopWidth = function() {
return this.borderWidthTop;
}
this.getRightWidth = function() {
return this.borderWidthRight;
}
this.getBottomWidth = function() {
return this.borderWidthBottom;
}
this.getBottomStyle = function() {
return this.borderStyleBottom;
}
this.getBottomColor = function() {
return this.borderColorBottom;
}
this.getLeftWidth = function() {
return this.borderWidthLeft;
}
this.setBottomColor = function(color) {
this.borderColorBottom = color;
}
this.toString = function() {
return this.borderWidthTop+' '+this.borderWidthRight+' '+this.borderWidthBottom+' '+this.borderWidthLeft+'\n'+this.borderStyleTop+' '+this.borderStyleRight+' '+this.borderStyleBottom+' '+this.borderStyleLeft+'\n'+this.borderColorTop+' '+this.borderColorRight+' '+this.borderColorBottom+' '+this.borderColorLeft;
}
}
LPadding = function( padding ) {
var match = padding.split(/px\s?/g);
if (match.length <= 2) {
var matches = new Array(match[0],match[0],match[0],match[0]);
}
else if (match.length <= 5) {
var matches = new Array(match[0],match[1],match[2],match[3]);
}
else {
var matches = new Array('','','','');
}
this.paddingTop = parseInt(matches[0]);
this.paddingRight = parseInt(matches[1]);
this.paddingBottom = parseInt(matches[2]);
this.paddingLeft = parseInt(matches[3]);
this.getTop = function() {
return this.paddingTop;
}
this.getRight = function() {
return this.paddingRight;
}
this.getBottom = function() {
return this.paddingBottom;
}
this.getLeft = function() {
return this.paddingLeft;
}
this.getPadding = function() {
return this.paddingTop+'px '+this.paddingRight+'px '+this.paddingBottom+'px '+this.paddingLeft+'px ';
}
}
divcounter = 0;
LDivElement = function(id, classNames, zIndex, border, borderWidth, borderStyle, borderColor, padding, top, left, height, width, innerHTML, options) {
if ( Global.myGarbageCollector.length > 0) {
var dom = Global.myGarbageCollector.pop(); //Dans ce cas, la DIV a déjà toutes les fonctionnalités
divManager.clean.call(dom);
}
else { //Il faut en créer une from scratch
var dom = document.createElement('DIV');
LDivFactory.call(dom);
divcounter++;
}
dom.typeOf = 'LDivElement';
LDivForge.apply(dom, arguments);
return dom;
}
LDivFactory = function() {
this.getLeft = function() { return this.left; }
this.setLeft = function(value) { this.left = value; this.style.left = value + 'px';}
this.getTop = function() { return this.top;}
this.setTop = function(value) {this.top = value; this.style.top = value + 'px'; }
this.getHeight = function() { return this.height; }
this.saveHeight = function() { this.oldHeight = this.height; }
this.saveWidth = function() { this.oldWidth = this.width; }
this.getWidth = function() { return this.width; }
this.setHeight = function(value) {
this.height = value;
mybro.setCompatibleHeight(this, this.height, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
}
this.setAndSaveHeight = function(value) {
this.saveHeight();
this.setHeight(value);
}
this.setWidth = function(value) {
this.width = value;
mybro.setCompatibleWidth(this, this.width, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
}
this.setAndSaveWidth = function(value) {
this.saveWidth();
this.setWidth(value);
}
this.getOffsetLeft = function() {
return this.left;
}
this.getOffsetTop = function() {
return this.top;
}
this.getOffsetWidth = function() {
return this.width;
}
this.getOffsetHeight = function() {
return this.height;
}
this.getMargeRight = function() {
return this.margeRight || this.getOffsetWidth();
}
this.getMargeLeft = function() {
return this.margeLeft || this.getOffsetWidth();
}
this.setMargeRight = function(value) {
this.margeRight = value;
}
this.setMargeLeft = function(value) {
this.margeLeft = value;
}
this.getMinimumHeight = function() {
return this.minimumHeight || 50;
}
this.getMinimumWidth = function() {
return this.minimumWidth || 50;
}
this.setMinimumHeight = function(value) {
this.minimumHeight = value;
}
this.setMinimumWidth = function(value) {
this.minimumWidth = value;
}
this.getBorderTopWidth = function() {
return this.border.getTopWidth();
}
this.getBorderRightWidth = function() {
return this.border.getRightWidth();
}
this.getBorderBottomWidth = function() {
return this.border.getBottomWidth();
}
this.getBorderLeftWidth = function() {
return this.border.getLeftWidth();
}
this.setBorder = function( border, borderWidth, borderStyle, borderColor) {
if ( border != '' ) {
this.style.border = border;
this.border = new LBorder( border, borderWidth, borderStyle, borderColor );
}
else {
this.style.borderWidth = borderWidth;
this.style.borderStyle = borderStyle;
this.style.borderColor = borderColor;
this.border = new LBorder( border, borderWidth, borderStyle, borderColor );
}
mybro.setCompatibleWidth(this, this.width, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
mybro.setCompatibleHeight(this, this.height, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
}
this.setBorderBottomColor = function(color) {
this.border.setBottomColor(color);
this.style.borderBottom = this.border.getBottomWidth() + 'px ' + this.border.getBottomStyle() + ' ' + color;
}
this.getPaddingTop = function() {
return this.padding.getTop();
}
this.getPaddingRight = function() {
return this.padding.getRight();
}
this.getPaddingBottom = function() {
return this.padding.getBottom();
}
this.getPaddingLeft = function() {
return this.padding.getLeft();
}
/* --------------------------- DOM STYLE ----------------------------------- */
this.saveCursor = function() {
this.oldCursor = this.cursor||'default';
}
this.setCursor = function(value) {
this.cursor = value;
this.style.cursor = value;
}
this.getCursor = function() {
return this.cursor;
}
this.saveAndSetCursor = function(value) {
this.saveCursor();
this.setCursor(value);
}
this.resetCursor = function() {
this.cursor = this.oldCursor||'default';
this.style.cursor = this.cursor;
}
this.getOpacity = function() {
return this.opacity;
}
this.setOpacity = function(value) {
this.opacity = value;
mybro.setOpacity(this, value);
}
this.setVisible = function(bln) {
this.style.visibility = ((bln) ? 'visible' : 'hidden');
this.visibility = bln;
}
this.setBackgroundColor = function(value) {
this.backgroundColor = value;
this.style.backgroundColor = value;
}
this.setBorderColor = function(value) {
this.style.borderColor = value;
}
this.setBackgroundImage = function( src ) {
this.backgroundImage = src;
this.style.backgroundImage = 'url('+src+')';
}
this.resetBackgroundImage = function() {
this.backgroundImage = '';
this.style.backgroundImage = 'url()';
}
this.setBackground = function( value ) {
this.background = value;
this.style.background = value;
}
this.setPNGBackground = function(value) {
this.background = value;
var img = value.split(/rl\(|\) /)[1];
var end = value.split(/rl\(|\) /)[2];
mybro.setBackground(this, img, end);
}
/* --------------------------- DOM TREE ----------------------------------- */
this.appendChild_ = function() {
for (var i=0; i < arguments.length; i++) {
this.appendChild(arguments[i]);
}
}
this.removeChild_ = function(childNode) {
if ( childNode.typeOf == 'LDivElement' ) {
Global.myGarbageCollector.push(childNode);
}
this.removeChild(childNode);
}
this.setInnerHTML = function(value) {
this.innerHTML = value;
}
this.addInnerHTML = function(value) {
this.innerHTML += value;
}
this.setTextNode = function(value) {
if ( this.firstChild ) {
if ( this.firstChild.nodeName == '#text' )
this.setInnerHTML( value);
else
this.firstChild.innerHTML = value;
}
else {
this.setInnerHTML( value);
}
}
this.getInnerHTML = function() {
return this.innerHTML;
}
/* --------------------------- METHOD ----------------------------------- */
}
LDivForge = function(id, classNames, zIndex, border, borderWidth, borderStyle, borderColor, padding, top, left, height, width, innerHTML, options) {
this.id = id;
this.className = classNames;
this.style.zIndex = zIndex;
this.zIndex = zIndex;
if ( border != '' ) {
this.style.border = border;
this.border = new LBorder( border, borderWidth, borderStyle, borderColor );
}
else {
this.style.borderWidth = borderWidth;
this.style.borderStyle = borderStyle;
this.style.borderColor = borderColor;
this.border = new LBorder( border, borderWidth, borderStyle, borderColor );
}
this.style.padding = padding;
this.padding = new LPadding( padding );
this.style.top = top+'px';
this.top = top;
this.style.left = left+'px';
this.left = left;
mybro.setCompatibleWidth(this, width, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
this.width = width;
mybro.setCompatibleHeight(this, height, this.border.getTopWidth(), this.border.getRightWidth(), this.border.getBottomWidth(), this.border.getLeftWidth(), this.padding.getTop(), this.padding.getRight(), this.padding.getBottom(), this.padding.getLeft());
this.height = height;
if ( innerHTML != '' )
this.setInnerHTML(innerHTML);
else
this.setInnerHTML('');
}
function GROUP() {
var elements = [];
this.add = function() {
for (var i=0; i < arguments.length; i++) {
elements.push(arguments[i]);
this.createMethods();
}
}
this.createMethods = function() {
for (var el in elements[0]) {
if ( typeof(elements[0][el]) == 'function' && !elements[0].constructor.prototype[el]) {
this.createMethod(el);
}
}
this.createMethods = function() {};
}
this.createMethod = function(el) {
this[el] = function() {
for (var i=0; i < elements.length; i++) {
elements[i][el].apply(elements[i], arguments);
}
}
}
this.add.apply(this, arguments);
}
var divManager = {}
divManager.clean = function() {
this.id = '';
this.className = '';
this.style.backgroundImage = 'none';
this.style.backgroundColor = '';
this.style.zIndex = 0;
this.zIndex = 0;
this.style.border = '';
this.style.padding = '';
this.style.visibility = '';
this.style.cursor = '';
this.style.color = '';
this.setInnerHTML('');
Event.resetevents.call(this);
Aide.unregister(this);
this.edition = false;
(this.stopObserving)?this.stopObserving(this.observed):null;
this.update = function() {}
}
var Event = {}
Event.setevent = function(type, fct) {
Event.initevent.call(this, type);
this[type+'_'] = [fct];
}
Event.addevent = function(type, fct) {
Event.initevent.call(this, type);
if ( !this[type+'_'] )
this[type+'_'] = [fct];
else
this[type+'_'].push(fct);
}
Event.initevent = function(type) {
if ( !this[type+'_'] ) {
this['on'+type] = function(type, e) {
Mouse.e = (e||event);
Mouse.e.LTarget = (type=='mouseout'||type=='mouseleave') ? lbody:Mouse.e.srcElement||Mouse.e.target;
for (var i=0; i < this[type+'_'].length; i++)
this[type+'_'][i].call(this, e);
}.bind(this, type)
}
}
Event.resetevents = function() {
var tabEvents = [ 'mouseover', 'mouseout', 'click', 'mousedown', 'mouseup', 'mousemove'];
for (var i=0; i < tabEvents.length; i++) {
if ( this[tabEvents[i]+'_'] ) {
this[tabEvents[i]+'_'] = [];
}
}
}
var Effect = {};
Effect.fadeTo = function(opacity, duration, on) {
if ( this.opacity == '' || this.opacity == undefined ) {
this.setOpacity(1);
}
this.setOpacity(this.opacity - ( this.opacity - opacity ) * Math.min( 100/duration, 1));
if ( duration > 100 && on ) {
this.fadeTimer = setTimeout(function(opacity, duration, bln) {
Effect.fadeTo.call(this, opacity, duration, bln);
}.bind(this, opacity, duration-100, true), 100);
}
}
Effect.hide = function() {
clearTimeout(this.fadeTimer);
this.style.visibility = 'hidden';
this.shown = false;
}
Effect.show = function() {
clearTimeout(this.fadeTimer);
this.style.visibility = 'visible';
this.shown = true;
}
LBodyElement = function() {
document.body.typeOf = 'LBodyElement';
LDivFactory.call(document.body);
return document.body;
}
lbody = new LBodyElement();
Global.for_a_select = [];
Global.for_a_select.hideAllButThisOne = function(el) {
for (var i=0; i < this.length; i++)
( this[i] != el ) ? this[i].opt.hide() : null ;
}
window.onclick = function(e) {
Global.for_a_select.hideAllButThisOne(e.target);
}
function replace_select(select, border, backgroundImg, color) {
var div = document.createElement('div');
div.id = 'div_select_'+select.id;
div.className = 'for_a_select pointer';
div.style.position = 'absolute';
div.style.top = select.offsetTop+'px';
div.style.left = select.offsetLeft+'px';
div.style.width = select.offsetWidth+'px';
div.style.height = select.offsetHeight+'px';
div.style.background = 'url('+GLO_IMG_REP+backgroundImg+') 0 0 no-repeat transparent';//100% '+(Math.round((select.offsetHeight-20)/2)-1)+'px no-repeat transparent';
div.style.border = border;
div.select = select;
select.parentNode.appendChild(div);
var opt = document.createElement('UL');
div.opt = opt;
opt.className = 'for_a_select hidden';
opt.style.position = 'absolute';
opt.style.top = ( select.offsetTop + select.offsetHeight ) + 'px';
opt.style.left = ( select.offsetLeft + 1 ) + 'px';
opt.style.width = ( select.offsetWidth - 4 ) + 'px';
opt.style.height = ( select.options.length * 12 ) + 'px'; //(div.parentNode.offsetHeight - (div.offsetTop+div.offsetHeight))+'px';*/
opt.style.borderLeft = '1px solid #FF9626';
opt.style.borderRight = '1px solid #FF9626';
opt.style.borderBottom = '1px solid #FF9626';
var html = '';
for (var i=0; i < select.options.length; i++)
html += '<li onclick="$(\''+div.id+'\').selectOption('+i+');" onmouseover="this.style.backgroundColor=\'#FC0\';" onmouseout="this.style.backgroundColor=\'#FE9\';">'+select.options[i].innerHTML+'</li>';
opt.innerHTML = html;
opt.switchVisibility = function() {
this.visible ? this.hide() : this.show();
}
opt.show = function() {
this.style.visibility = 'visible';
this.visible = true;
}
opt.hide = function() {
this.style.visibility = 'hidden';
this.visible = false;
}
select.parentNode.appendChild(opt);
div.selectOption = function(i) {
this.select.selectedIndex = i;
this.select.onchange();
this.innerHTML = this.select.options[i].innerHTML;
this.opt.hide();
}
div.initOption = function(i) {
this.innerHTML = this.select.options[i].innerHTML;
}
div.initOption(select.selectedIndex);
div.onclick = function() {
this.opt.switchVisibility();
Global.for_a_select.hideAllButThisOne(this);
}
Global.for_a_select.push(div);
}
var monthText = [ 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre' ];
var dateCounter = 0;
LDate = function( str_date, duree ) {
dateCounter++;
if ( arguments.length==0 || arguments[0]=='' ) {
var date = new Date();
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
date.duree = 'ALL';
}
else {
if ( typeof arguments[0] == 'number' )
var date = new Date(arguments[0]); //Ici c'est un timestamp donc pas de pb d'heure
else
var date = new Date(str_date.split('/')[2], str_date.split('/')[1]-1, str_date.split('/')[0]); //Dans ce cas, c'est 00:00:00 qui est pris car omis
if ( arguments.length > 1 )
date.duree = duree;
else
date.duree = 'ALL';
}
date.stringValue = date.getDate().addZero(2)+'/'+(date.getMonth()+1).addZero(2)+'/'+date.getFullYear();
return date;
}
Date.prototype.updateStringValue = function() {
this.stringValue = this.getDate().addZero(2)+'/'+(this.getMonth()+1).addZero(2)+'/'+this.getFullYear();
}
Date.prototype.addJours = function( value ) {
this.setDate(this.getDate()+value);
this.updateStringValue();
return this;
}
Date.prototype.getFirstInMonth = function() {
return new LDate('01/'+(this.getMonth()+1).addZero(2)+'/'+this.getFullYear());
}
Date.prototype.getLastInMonth = function() {
var date =  new LDate(this.toFullString());
date.addMois(1);
date = date.getFirstInMonth();
date.addJours(-1);
return date;
}
Date.prototype.addMois = function(value) {
var day = this.getDate();
this.setMonth(this.getMonth()+value);
if ( day != this.getDate() )
this.addJours( - this.getDate() );
this.updateStringValue();
return this;
}
Date.prototype.toString = function() {
return this.getDate().addZero(2)+'/'+(this.getMonth()+1).addZero(2)+'/'+(this.getYear()-100).addZero(2);
}
Date.prototype.toFullString = function() {
return this.stringValue;
}
Date.prototype.toMonthString = function() {
return (this.getMonth()+1).addZero(2)+'/'+this.getFullYear();
}
Date.prototype.toMonthText = function() {
return monthText[this.getMonth()].firstUpper();
}
Date.prototype.getWeek = function (dowOffset) {
/*getWeek() was developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */
dowOffset = typeof(dowOffset) == 'int' ? dowOffset : 0; //default dowOffset to zero
var newYear = new Date(this.getFullYear(),0,1);
var day = newYear.getDay() - dowOffset; //the day of week the year begins on
day = (day >= 0 ? day : day + 7);
var daynum = Math.floor((this.getTime() - newYear.getTime() -
(this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
var weeknum;
if(day < 4) {
weeknum = Math.floor((daynum+day-1)/7) + 1;
if(weeknum > 52) {
nYear = new Date(this.getFullYear() + 1,0,1);
nday = nYear.getDay() - dowOffset;
nday = nday >= 0 ? nday : nday + 7;
/*if the next year starts before the middle of
the week, it is week #1 of that year*/
weeknum = nday < 4 ? 1 : 53;
}
}
else {
weeknum = Math.floor((daynum+day-1)/7);
}
return weeknum;
}
Date.dateDiff = function(date1, date2) {
var dt1 = new LDate(date1.toFullString());
var dt2 = new LDate(date2.toFullString());
return Math.round(( dt2-dt1 ) / 86400000);
}
Date.yearDiff = function(date1, date2) {
return (date2.getFullYear() - date1.getFullYear());
}
Date.checkFormat = function(s, format) {
var format = (format)?format:'JJ/MM/AAAA';
if ( s.length != format.length )
return false;
var dJ = format.toUpperCase().indexOf('J');
var fJ = format.toUpperCase().lastIndexOf('J');
var dM = format.toUpperCase().indexOf('M');
var fM = format.toUpperCase().lastIndexOf('M');
var dA = format.toUpperCase().indexOf('A');
var fA = format.toUpperCase().lastIndexOf('A');
var j = s.substring(dJ, fJ+1);
var m = s.substring(dM, fM+1);
var a = s.substring(dA, fA+1);
if ( isNaN(j) || (j<1) || (j>31) || isNaN(m) || (m<=0) || (m>12) || isNaN(a) )
return false;
j = parseInt(j);
m = parseInt(m)-1;
a = parseInt(a);
if ( fA-dA < 2 ) {
if ( a > 70)
a = "19"+a;
else
a = "20"+a;
}
a = parseInt(a);
var date = new Date(a, m, j);
if ( date.getDate() == j && date.getMonth() == m && date.getFullYear() == a )
return true;
return false;
}
Date.today = new LDate();
Date.getInfo = function( method, offset, type) {
Date.today[method](offset);
var info = Date.today[type]();
Date.today[method](-offset);
return info;
}
/* -------- Quelques fonctions utiles concernant le respect d'un format de date dans un champ --------- */
function checkDateTemp(str_date, el) { //el est facultatif
if (isFull(str_date)) {
if (!check(str_date)) {
alert("Veuillez respecter le format de date JJ/MM/AAAA.");
(el)?el.blur():null;
}
}
}
function checkDateFinish(str_date) {
if (!isFull(str_date) || !check(str_date)) {
alert("Veuillez respecter le format de date JJ/MM/AAAA.");
return false;
}
return true;
}
function isFull(str_date) {
if ( str_date.length >= 10 || str_date.length == 0 )
return true;
else
return false;
}
function check(str_date) {
if ( str_date.length == 0 )
return true;
var regexp = new RegExp("[0-3][0-9]/(0[1-9]|1[0-2])/(19|20)[0-9]{2}");
if (str_date.match(regexp)) {
try {
var date = new Date(str_date.substr(7,4),str_date.substr(3,2)-1,str_date.substr(0,2));
return true;
}
catch (err) { return false; }
}
else
return false;
}
function checkKey(obj, event) {
keycode = event.which;
if (!( (keycode >=47 && keycode <=57) || keycode==0 || keycode==8 )) {
return false;
}
}
Error = function(controller) {
this.controller = controller;
this.manage = function(code, motif) {
this.controller.displayMessage('<br><a nohref onclick="this.parentNode.obj.hide();">Fermer</a><br><br>Erreur '+code+'<br><br>'+motif);
}
}
Tryable = function() {
for (var i in this) {
if (typeof this[i]=='function') {
var _fct = this[i];
this[i] = function() {
try {
_fct.call(this);
}
catch(e) {
document.body.innerHTML += 'Error in object '+this.typeOf+' while executing function '+i;
if ( !e.firstThrown )
document.body.innerHTML += ': line '+mybro.getErrorNumber(e)+', '+mybro.getErrorDescription(e)+'<br>';
else
document.body.innerHTML += ': see stack for details<br>';
e.firstThrown = true;
throw(e);
}
}
}
}
}
Server = function(controller) {
this.controller = controller;
this.red = viewTitre.childNodes.red;
this.green = viewTitre.childNodes.green;
this.error = new LDivElement( 'div_error', 'left hidden white auto', 9999, '1px solid #000', '', '', '', '0px', 0, 10, 260, 400, '');
this.on = function() {
Effect.show.call(this.red);
}
this.setRed = function(html) {
this.red.setInnerHTML(html);
}
this.off = function() {
Effect.hide.call(this.red);
}
this.showGreen = function() {
this.greenTimer = this.greenTimer || new LDate(); //Si le timer est déjà initialisé, on ne le modifie pas
Effect.show.call(this.green);
}
this.hideGreen = function() {
if ( this.green.shown ) {
var elapsedTime = new LDate() - this.greenTimer;
setTimeout( function() {
Effect.hide.call(this.green);
this.greenTimer = null;
}.bind(this), 1000 - elapsedTime); //On est ainsi sur que le voyant sera resté au moins 1 seconde allumé
}
}
this.display = function(html) {
this.error.setInnerHTML(html+'<br><br><a nohref onclick="this.parentNode.obj.hide();">Fermer</a><br><br>');
Effect.show.call(this.error);
}
this.hide = function() {
this.error.hide();
}
}
Controller = function() {
this.pool = new HttpRequestPool(this);
this.server = new Server(this);
this.connexionOn = function() {
this.server.on();
}
this.connexionOff = function() {
this.server.off();
}
this.displayMessage = function(html) {
this.server.display(html);
}
this.error = new Error(this);
this.manageError = function(code, motif) {
this.error.manage(code, motif);
}
}
