/**
 * Fonction permettant d'unifier les accès aux objets
 * et propriétés.
 *
 * Permet un accès identique quelque soit le navigateur :
 * + aux événements : addListenner(obj, sEventType, func, bubbling);
 * + aux objets et à leur style : getObjById(sObjId, win);
 * + à l'objet "événement" : getEventObj(evt)
 *
 */



/* Event and Objects
------------------------------------------------------------------------*/


/**
 * Cherche la référence sur un objet dont on connait l'id
 *
 */
function getObjById(sObjId, win)
{
    var obj = false;
    if (!win || win == null) win = window;

    if (document.getElementById) {
      return win.document.getElementById(sObjId);

    } else if (document.all) {
      return win.document.all[sObjId];

    } else if (document.layers) {
      obj = win.document.layers[sObjId];
      obj.style = win.document.layers[sObjId];
    }

    return obj;
} // end of the "getEventObj()" function




/**
 * Standardise les propriétés d'un objet "événement" en créant celles qui manquent
 *
 * source : http://developer.apple.com/internet/webcontent/eventmodels.html
 */
  function getEventObj(evt) {

    // Merci apple (voir ci dessus)
    evt = (evt) ? evt : ((window.event) ? window.event : "");

    var newevt = new Object;
    newevt.type = evt.type;

    // Cible (url de destination pour un lien, par exemple)
    if (evt.target) { // NN4, Gecko, W3C/Safari
        if (evt.currentTarget && evt.nodeType != 3) {
            newevt.target = evt.currentTarget;
        } else {
            newevt.target = evt.target;
        }
    } else {
        if (evt.srcElement) { // IE 4+
            newevt.target = evt.srcElement;
        } else {
            newevt.target = 'undefined';
        }
    }

    // Coordonnées du clic
    if (evt.pageX) { // NN4, Gecko, W3C/Safari
            newevt.pageX = evt.pageX;
            newevt.pageY = evt.pageY;
    } else {
        if (evt.clientX) { // IE 4+
            newevt.pageX = evt.clientX + document.body.scrollLeft;
            newevt.pageY = evt.clientY + document.body.scrollTop;
        } else {
            newevt.pageX = 0;
            newevt.pageY = 0;
        }
    }

    // Bouton de la souris ayant servis au clic :
    // W3C, Gecko   : gauche 0, milieu 1, droite 2
    // IE 4+        : gauche 1, milieu 4, droite 2
    if (!newevt.button) { // IE 4+, Gecko, W3C/Safari
        if (evt.which) {
            newevt.button = evt.which; // NN4
        } else {
            newevt.button = "undefined";
        }
    }

    // code de la touche pressée (NN4 a=97; autres : a=65)
    if (!newevt.keyCode) { // IE 4+, Gecko, W3C/Safari
        if (evt.which) {
            newevt.keyCode = evt.which; // NN4
        } else {
            newevt.keyCode = "undefined";
        }
    }

    return newevt;
  } // end of the "getEventObj()" function





/**
 * Retourne les dimensions de la fenêtre
 */
function getWindowSize()
{
	var size = new Array;
	//Non-IE
	if( typeof( window.innerWidth ) == 'number' ) {
		size.x = window.innerWidth;
		size.y = window.innerHeight;
		
	//IE 6+ in 'standards compliant mode'
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		size.x = document.documentElement.clientWidth;
		size.y = document.documentElement.clientHeight;
		
	//IE 4 compatible
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		size.x = document.body.clientWidth;
		size.y = document.body.clientHeight;
	}

	return size;	
	
} // end of the "getWindowSize()" function



/**
 * Retourne l'offset du scroll vertical et horizontal
 */
function getScrollOffset()
{
    var offset = new Array;
    if (self.pageYOffset) // all except Explorer
    {
        offset.x = self.pageXOffset;
        offset.y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
    {
        offset.x = document.documentElement.scrollLeft;
        offset.y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
        offset.x = document.body.scrollLeft;
        offset.y = document.body.scrollTop;
    }

    return offset;
} // end of the "getScrollOffset()" function



/**
 * Retourne les coordonnées du curseur
 */
function getMousePosition(event)
{
    if (!event) event = window.event;
    var cursorPosition = {x:0, y:0};

    if (event.pageX) {
        cursorPosition.x = event.pageX;
        cursorPosition.y = event.pageY;

    } else if (event.clientX) {
        var scrollOffset  = getScrollOffset();
        cursorPosition.x = event.clientX + scrollOffset.x;
        cursorPosition.y = event.clientY + scrollOffset.y;
    }

    return cursorPosition;

} // end of the "getMousePosition()" function



/**
 * essaie de déterminer le meilleur endroit pour afficher une boite
 * autour d'un point central (en général la position du curseur) dans une zone
 *
 * Cette fonction détermine l'endroit (haut-bas, droite-gauche) où
 * on a le plus de place pour afficher un élément.
 */
function getBestDisplayPos(ref, blockSize, zoneSize, margin)
{
    var bestPos = [0, 0];
    var depassement = 0;

    bestPos[0] = getBestPos(ref[0], blockSize[0], zoneSize[0], margin[0]);
    bestPos[1] = getBestPos(ref[1], blockSize[1], zoneSize[1], margin[1]);



    return bestPos;
} // end of the "getBestDisplayPos()" function



/**
 * calcule une coordonnée pour le placement d'un élément
 */
function getBestPos(pos, size, range, margin) {

    var best = 0;

    // Deuxième moitié
    if (pos > (range/2)) {

        // on essaie de placer la boîte avant le milieu
        if (pos - size - margin > 0) {
            best = pos - size - margin;

        } else {
            best = margin; // si on ne peut placer la boite avant le curseur, on garde une marge avec le début
        }


    // Première moitié
    } else {
        if ((pos + size + margin) <= range) {
            best = pos + margin;

        } else {
            best = range - margin - size;
        }
    }

    if (best < 0) {
        best = margin;
    }

    return best;
} // end of the "getBestPos()" function





/**
 * Attache un évènement à un objet et unifie l'objet "événement"
 *
 * Source : http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 */
function addListenner(obj, sEventType, func, bubbling)
{
    //alert('addListenner : ' + sEventType + ', ' + obj.nodeName);
    var sOnEventType = "on" + sEventType;
    var newFunc = function(evt) {
                                    // retrieve event objet with standard properties
                                    evt = getEventObj(evt);

                                    // Manage event bubbling for IE
                                    if (window.event) window.event.cancelBubble=!bubbling;

                                    // Run event handler
                                    return func(evt);
                                };

    if (sEventType == "mousemove" && document.captureEvents && Event) {
        document.captureEvents(Event.MOUSEMOVE);

    } else if (sEventType == "click" && document.captureEvents && Event) {
        document.captureEvents(Event.MOUSEMOVE);

    } else if (sEventType == "mouseup" && document.captureEvents && Event) {
        document.captureEvents(Event.MOUSEUP);

    } else if (sEventType == "mousedown" && document.captureEvents && Event) {
        document.captureEvents(Event.MOUSEDOWN);
    }


    // DOM way of managing events
    if (document.addEventListener) {
        obj.addEventListener(sEventType, func, bubbling);

    // Microsoft (attention ! Chez microsoft, les événements sont lancés dans l'ordre inverse d'arrivée)
    } else if (document.attachEvent) {
        obj.attachEvent(sOnEventType, newFunc);

    // Classic old way + http://simon.incutio.com/archive/2004/05/26/addLoadEvent
    } else {
        var oldEvent = obj[sOnEventType];
        if (typeof obj[sOnEventType] != "function") {
            obj[sOnEventType] = newFunc;
        } else {
            obj[sOnEventType] = function(evt) { var test = oldEvent(evt); return newFunc(evt) && test; };
        }
    }

    return true;
} // end function addListenner()




/* Misc
------------------------------------------------------------------------*/



/**
 * Créé la partie après le point d'interrogation d'une url
 * à partir d'un tableau de variables
 *
 */
/*function buildQueryVars(aQueryData)
{
    var query = '';
    var first = true;
    for (var svar in aQueryData) {
      if (typeof aQueryData[svar] == 'object') {
        aQueryData[svar] = objToUrl(aQueryData[svar]);

      } else if (typeof aQueryData[svar] == 'array') {
        aQueryData[svar] = objToUrl(aQueryData[svar]);
      }

      if (first) {
          first = false;
      } else {
          query += '&';
      }
      query += svar + '=' + encodeURI(aQueryData[svar]); // escape

    }

    return query;
} // end function buildQueryVars()
*/


/**
 * objToUrl
 */
/*function objToUrl(obj)
 {
    var str = '';
    for (var i in obj) {

    }
 } // end of "objToUrl()"
*/


    /**
     * Construit la liste des variables de l'url
     *
     * @param
     *
     * @return
     */
    function buildQueryVars(vars_array)
    {
        var var_list = [];

        // Parcours une variable de type tableau et créé le code de l'url
        buildUrlValue = function (path, vars_array)
          {
              for (var i in vars_array) {
                  if (typeof vars_array[i] == 'array' || typeof vars_array[i] == 'object') {
                      buildUrlValue(path + '[' + encodeURIComponent(i) + ']', vars_array[i]);
                  } else {
                      var_list.push(path + '[' + encodeURIComponent(i) + ']=' + encodeURIComponent(vars_array[i]));
                  }
              }
          }; // end of "buildUrlValue()"


        for (var i in vars_array)
        {
            if (typeof vars_array[i] == 'array' || typeof vars_array[i] == 'object') {
                buildUrlValue(i, vars_array[i]);
            } else {
                var_list.push(encodeURIComponent(i) + '=' + encodeURIComponent(vars_array[i]));
            }
        }

        /*var sign = '';
        if (var_list.length > 0) {
            sign = '?';
        }
        sign +
        */

        return var_list.join('&');

    } // end of the "buildQueryVars()" function






var DBG;
/**
 * Si la console de débuggage existe, affiche un message
 */
function DBG_msg(msg, type)
{
    if (DBG != null && DBG.dbgMsg) {
        DBG.dbgMsg(msg, type);
    }
    return true;
}



/**
 * addClass
 */
 function addClass()
 {
   if (arguments.length >= 2) {
     var obj = arguments[0];
     if (!obj) return false;
     if (!obj.className) obj.className = '';

     for (var i = 1; i < arguments.length; i++) {
       if (obj.className.indexOf(arguments[i]) == -1) {
        obj.className += (obj.className ? ' ' : '') + arguments[i];
       }
     }

     if (obj.className) {
         obj.className = trim(obj.className);
     }

   }
 } // end of "addClass()"


/**
 * removeClass
 */
 function removeClass()
 {
   if (arguments.length >= 2) {
     obj = arguments[0];
     if (!obj) return false;
     for (var i = 1; i < arguments.length; i++) {
       if (obj.className) {
        obj.className = obj.className.replace(arguments[i], '');
       }
     }
     if (obj.className) {
         obj.className = trim(obj.className);
     }
   }
 } // end of "removeClass()"


/**
 * createRandomName
 */
 function createRandomName()
 {
    var str = '';
    var letters = range('a', 'z');
    letters = letters.concat(range('0', '9'));
    for(var i = 0; i < 7; i++) {
        str += letters[getRandomInt(0, 34)];
    }
    return str;

 } // end of "createRandomName()"


function getRandomInt(min, max) {
  return Math.round(Math.random() * (max - min + 1) + min);
}



/**
 * range
 */
 function range(start, end)
 {
    var tab = [];
    for (var chr = start.charCodeAt(0); chr <= end.charCodeAt(0); chr++) {
       tab.push(String.fromCharCode(chr));
    }

    return tab;

 } // end of "range()"




/**
 * Lance la procédure d'impression, en ouvrant d'abord le popup
 *
 */
function printDoc(targetId)
{
    // Le popup récupère la feuille de style de la page appelante
    styles = document.getElementsByTagName('link');
    var stylesheet = [];
    for (var i=0; i<styles.length; i++) {
        if (styles[i].rel && styles[i].rel == 'stylesheet') {
            stylesheet.push(styles[i].href);
        }
    }

    // Ecriture du contenu du popup, et préparation
    var console  = window.open('','name','height=500,width=700,resizable=yes,scrollbars=yes,menubar=yes');
    console.document.write(getPrintWindow(stylesheet, targetId));
    console.document.close();

    return this;
} // end of "printDoc" function





/**
 * Ouvre un popup pour imprimer une partie de la page
 *
 */
function getPrintWindow(stylesheet, targetId)
{
    var targetnode = document.getElementById(targetId);
    var popupContent = '';
    popupContent += '<html>\r\n';
    popupContent += '    <head>\r\n';
    popupContent += '        <title>Impression de votre document</title>\r\n';
    for (var i=0; i < stylesheet.length; i++) {
        popupContent += '        <link rel="stylesheet" type="text/css" href="' + stylesheet[i] + '">\r\n';
    }
    popupContent += '    </head>\r\n';
    popupContent += '    <body style="background : #ffffff;">\r\n';
    popupContent += '        <div id="print-zone">\r\n';
    popupContent += '        	<' + targetnode.nodeName + ' id="' + targetId + '"';
    if (targetnode.className) {
        popupContent += ' class="' + targetnode.className + '"';
    }
    popupContent += ' >\r\n';
    
    popupContent += targetnode.innerHTML;
    popupContent += '        	</' + targetnode.nodeName + '>\r\n';
    popupContent += '        </div>\r\n';
    popupContent += '    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r\n';
    popupContent += '    <!--\r\n';
    popupContent += '    window.print();\r\n';
    popupContent += '    window.close();\r\n';
    popupContent += '    // -->\r\n';
    popupContent += '    </SCRIPT>\r\n';
    popupContent += '    </body>\r\n';
    popupContent += '</html>\r\n';

    return popupContent;
} // end of "getPrintWindow()" function







/**
 * Outils supplémentaires de base
 */

// Removes leading whitespaces
function LTrim(value) {
    var re = /\s*((\S+\s*)*)/;

    return value.replace(re, "$1");
} // end function LTrim()

// Removes ending whitespaces
function RTrim(value) {
    var re = /((\s*\S+)*)\s*/;

    return value.replace(re, "$1");
} // end function RTrim()

// Removes leading and ending whitespaces
function trim(value) {
    return LTrim(RTrim(value));
} // end function trim()





/**
 * Lit les valeurs saisies dans les champs d'un formulaire
 * (type input et select)
 *
 * @param object  form  objet contenant les données à lire
 *
 * @return array  tableau associatif des données lues
 */
 function readForm(form, button) {

    //alert('envoi des données');
    var aQueryData = {};
    
    //return aQueryData;

    // Lecture des champs textes, des cases à cocher, des boutons radios
    var inputList = form.getElementsByTagName('input');
    for (var k = 0; k < inputList.length; k++) {
        if (inputList[k].type == 'checkbox') {
            aQueryData[inputList[k].name] = 0;
            if (inputList[k].checked) {
                aQueryData[inputList[k].name] = inputList[k].value;
            }

        } else if (inputList[k].type == 'radio') {

            if (!aQueryData[inputList[k].name]) {
               aQueryData[inputList[k].name] = '';
            }
            if (inputList[k].checked) {
                aQueryData[inputList[k].name] = inputList[k].value;
            }

        } else {
            if (((inputList[k].type == 'button' || inputList[k].type == 'submit') && button && button.id == inputList[k].id)
                || (inputList[k].type != 'button' && inputList[k].type != 'submit') || !button) {
                aQueryData[inputList[k].name] = inputList[k].value;
            }
        }
    } // end for

    
    // Lecture des listes déroulantes
    var selectList = form.getElementsByTagName('select');
    for (var k = 0; k < selectList.length; k++) {
      if (typeof selectList[k].selectedIndex == 'number' && typeof selectList[k].name == 'string') {
        aQueryData[selectList[k].name] = selectList[k].options[selectList[k].selectedIndex].value;
      } /*else {
        alert('probleme avec ' + selectList[k].id + ', name=' + selectList[k].name + ', selectList[k].selectedIndex=' + selectList[k].selectedIndex);
      }*/
    }
    
    
    // Lecture des zones de texte
    var selectList = form.getElementsByTagName('textarea');
    for (var k = 0; k < selectList.length; k++) {
      if (typeof selectList[k].innerHTML == 'string' && typeof selectList[k].name == 'string') {
        aQueryData[selectList[k].name] = selectList[k].value;
      } /*else {
        alert('probleme avec ' + selectList[k].id + ', name=' + selectList[k].name + ', selectList[k].selectedIndex=' + selectList[k].selectedIndex);
      }*/
    }

    return aQueryData;

} // end of "readForm()"







/**
 * Positionnement des champs du formulaire
 *
 * @param array postvalues valeurs des champs du formulaire
 */
 function setForm(postvalues)
 {
    for (var key in postvalues) {
        var inputValue = postvalues[key];
        var input = document.getElementById(key);

        if (input) {
            if (input.type == 'checkbox') {
                if (parseInt(inputValue) == 1) {
                    input.checked = true;
                } else {
                    input.checked = false;
                }

            } else if (input.type == 'radio') {
                if (input.value == inputValue) {
                    input.checked = true;

                } else {
                    input.checked = false;
                }
                var a = 1;
                input = document.getElementById(key + '-' + a);
                while (input) {
                    if (input.value == inputValue) {
                        input.checked = true;
                    } else {
                        input.checked = false;
                    }
                    a++;
                    input = document.getElementById(key + '-' + a);
                }

            } else if (input.nodeName == 'SELECT') {
                for (var a = 0; a < input.options.length; a++) {
                    if (input.options[a].value == parseInt(inputValue) || input.options[a].value == inputValue) {
                        input.options[a].selected = 'selected';
                    } else {
                        input.options[a].selected = null;
                    }
                }
            } else {
              input.value = inputValue;
            }
        }
    } // end for
 } // end of "setForm()"




/**
 * getEventTarget
 *
 * http://www.quirksmode.org pour le code original
 */
 function getEventTarget(e)
 {
    var targ;
    if (!e) var e = window.event;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;

    return targ;

 } // end of "getEventTarget()"


 
 
 

 /**
  * Affiche un calque noir transparent à la page et une boîte centrée
  * 
  * @param string bgId        identifiant unique à donner au fond noir
  * @param string lightBoxId  identifiant unique à donner à la boîte
  * @param object options     contenu type: 
  *                           {
  *                             content: maxBox, 
  *                             width: '500px', 
  *                             height: '500px'
  *                           }
  *                           maBox étant de type "objet" noeud html 
  *                           (document.createElement()).
  * 
  * @return  object  un objet contenant les pointeurs vers le fond et la boîte
  */
 function createLightBoxHtml(bgId, lightBoxId, options)
 {

     // fond noir transparent
     var bg = document.createElement('div');
     bg.id = bgId;
     bg.style.position = 'absolute';
     bg.style.top = 0;
     bg.style.left = 0;
     bg.style.width = '100%';
     bg.style.height = '1000px';
     bg.style.background = '#000';
     bg.style.padding = 0;
     bg.style.margin = 0;
     bg.style.zIndex = 90;
     bg.style.filter = 'alpha(opacity=80)';
     bg.style.opacity = .8;
     
     
     // Boîte "conteneur"
     var lightBox = document.createElement('div');
     lightBox.id = lightBoxId;
     lightBox.style.position = 'absolute';
     ///if (options.height <= 0) {
         lightBox.style.overflow = 'visible';
     /*} else {
         lightBox.style.overflow = 'visible';
     }*/
     lightBox.style.float = 'left';
     lightBox.style.top = '50%';
     lightBox.style.left = '50%';
     if (options.width) {
         lightBox.style.width = options.width;
     }
     if (options.height > 0) {
         lightBox.style.height = options.height;
     }
     lightBox.style.background = '#fff';
     lightBox.style.padding = '10px';
     lightBox.style.margin = 0;
     lightBox.style.zIndex = 90;
     lightBox.style.textAlign = 'center';
     lightBox.className = 'spg_lightBox';
     
     if (options.content) {
         lightBox.appendChild(options.content);
     }
     
     
     var closeFn = function() {
         var bg = document.getElementById(bgId);
         bg.parentNode.removeChild(bg);
         bg = document.getElementById(lightBoxId);
         bg.parentNode.removeChild(bg);
         return false;
     };
     
     
     if (!options.closeId) {
         var lightBoxClose = document.createElement('a');
         lightBoxClose.href = '#';
         lightBoxClose.onclick = closeFn;
         lightBoxClose.style.color = '#fff';
         lightBoxClose.style.fontSize = '12px';
         lightBoxClose.style.display = 'block';
         lightBoxClose.style.float = 'left';
         lightBoxClose.style.position = 'absolute';
         lightBoxClose.style.top = '-30px';
         lightBoxClose.style.right = '0';
         lightBoxClose.style.zIndex = '30';
         lightBoxClose.style.width = 'auto';
         lightBoxClose.style.margin = ' 0 0 0 0';
         lightBoxClose.className = 'fermerLightBox';
         
         var textNode = document.createTextNode('Fermer');
         lightBoxClose.appendChild(textNode);
         lightBox.appendChild(lightBoxClose);
     }
     
     
     
     var body = document.getElementsByTagName('body');
     if (body[0]) {
         body[0].appendChild(bg);
         body[0].appendChild(lightBox);
     }
     
     
     if (options.closeId) {
         var lightBoxClose = document.getElementById(options.closeId);
         if (lightBoxClose) {
             lightBoxClose.onclick = closeFn;
         }
     }
     
     return { bg:bg, box:lightBox };
     
 } // end of "createLightBoxHtml()"


 
 
 
 /**
  * Adapte les dimensions et position de "boîte" et "fond noir" à la page
  * 
  * @param oject lightBox  objet contenant { bg:bg, box:lightBox }
  *                        (fourni par createLightBoxHtml())
  * @return
  */
 function adaptLightboxPosAndSize(lightBox, yOffset)
 {
     var whole = document.getElementById('page');
     if (!whole) {
         whole = document.getElementById('corps-page');
         if (!whole) {
             return false;
         }
     }
     
     var win = getWindowSize();
     
     if (lightBox.bg && whole.clientHeight) {
         lightBox.bg.style.height = whole.clientHeight + 'px';
         if (win.y > whole.clientHeight) {
             lightBox.bg.style.height = win.y + 'px';
         }
     }

     if (lightBox.box) {
         var x = 0, y = 0;
         var scrolloffset = getScrollOffset();
         x = (win.x - lightBox.box.clientWidth) / 2;
         if (win.y > (y + lightBox.box.clientHeight)) {
             y += ((win.y - (lightBox.box.clientHeight)) / 2);
             if (yOffset) {
                 y += yOffset;
             }
         }
         if (scrolloffset.y) {
            y += scrolloffset.y;
         }
         if (y < 0) {
            y = 10;
         }
         //alert('scrolloffset.y = ' + scrolloffset.y + ', win.y = ' + win.y + ', y = ' + y + ', lightBox.box.clientHeight = ' + lightBox.box.clientHeight);
         
         lightBox.box.style.top = y + 'px';
         lightBox.box.style.left = x + 'px';
     }
     
     return true;
     
 } // end of "adaptLightboxPosAndSize()"




 /**
  * Extrait les coordonnées GPS d'une chaîne, ainsi qu'un zoom optionnel
  * 
  * @param string  latLng
  * @return object 
  */
 function parseLatLng(latLng)
 {
     var lat = 47.2494070;
     var lng = 2.5488281;
     var zoom;
     if (!latLng || latLng.indexOf(',') < 0) {
         return {lat:lat, lng:lng};
     }
     var coor = latLng.split(',');
         if (parseFloat(coor[0])) {
             coor[0] = parseFloat(coor[0]);
         }
         if (parseFloat(coor[1])) {
             coor[1] = parseFloat(coor[1]);
         }
         if (coor[2] && parseFloat(coor[2])) {
             coor[2] = parseFloat(coor[2]);
         }
         if (typeof(coor[0]) == 'number' && typeof(coor[1]) == 'number') {
             lat = coor[0];
             lng = coor[1];
             
             if (coor[2]) {
                 zoom = coor[2];
             }
         }

     var latLng = {lat:lat, lng:lng};
     if (zoom) {
         latLng.zoom = zoom;
     }
     return latLng;
     
 } // end function "geoParseLatLng"

 
 
 
 
/**
 * Extrait les paramètres de la classe
 * 
 * @param className     classe complète du lien
 * @param triggerName   classe du déclencheur (ici "ajax-content-lightbox")
 * 
 * @returns struct tableau contenant les arguments et leurs valeurs
 */
function getArgsFromClass(className, triggerName)
{
    var tmp = className.split(triggerName);
    if (!tmp[1]) {
    	return '';
    }
    
    
    
    // autres classes après les arguments à virer
	tmp = trim(tmp[1]);
	if (tmp.indexOf(' ') >= 0) {
    	tmp = tmp.split(' ');
    	if (tmp[0]) {
    		tmp = tmp[0];
    	}
	}
	
	
	// séparation des arguments
	tmp = tmp.split(',');
	
	var key, value, parts;
	var args = {};
	for (var i in tmp) {
		if (tmp[i] && typeof tmp[i] === 'string' && tmp[i].indexOf(':') >= 0) {
			parts = tmp[i].split(':');
			parts[0] = trim(parts[0]);
			parts[1] = trim(parts[1]);
			args[parts[0]] = parts[1];
		}
	}
	
	return args;

} // end function "getArgsFromClass"
 
 
 
 
 
 


