//
// Fonction de chargement des js !
//
var jeCharge = {
  Version: '1.0',
  include: function( filename ) {
    var js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', filename);
    document.getElementsByTagName('HEAD')[0].appendChild(js);

    var cur_file = {};
    cur_file[window.location.href] = 1;

    if (!window.php_js) window.php_js = {};
    if (!window.php_js.includes) window.php_js.includes = cur_file;
    if (!window.php_js.includes[filename]) {
        window.php_js.includes[filename] = 1;
    } else {
        window.php_js.includes[filename]++;
    }

    return window.php_js.includes[filename];
  },
  mesJs: function() {
    var js = /jeCharge\.js(\?.*)?$/;
    var seek = document.getElementsByTagName('script');
	for(var i=0; i<seek.length; i++){
	    if(seek[i].src.match(js)){
			var path = seek[i].src.replace(js, '');
	        var includes = seek[i].src.match(/\?.*j=([a-z,]*)/);
			includes = (includes ? includes[1] : '').split(',');
			for(var z=0; z<includes.length; z++){
				if(includes[z] != ""){
					this.include(path+includes[z]+'.js');
				}
			}
		}
	}
  }
};

jeCharge.mesJs();