// JavaScript Document
function ChargeurDLN(racine)
{
	this._auteur = 'Jeremy joron';
	this._courriel = 'jeremy.joron@creationdln.ca';
	this._siteWeb = 'www.creationdln.ca';
	this._charger = new Array();
	this._racine = racine;
	this._preparer = new Array();
	

	//-----------------------------------------------------
	//                                           	   init 
    this.init = function()
	{
		//on définit où se trouve le dossier
		//de travail Javascript
		//par rapport à la racine du site Internet
		this._racine += 'OsDLN/js/';		
	}
	
	//-----------------------------------------------------
	//                                            controleur 
	this.controleur = function(script, param)
	{
		var param = (param == null) ? null : param
		this.charger('controleurs/'+script, param);
		
		if(DLN != null)
		{
			DLN.preparerLinstance(script);
		}
		else
		{
			alert('Impossible de charger l\'objet DLN');	
		}
		
	}//controleur
	
	//-----------------------------------------------------
	//                                                proto 
	this.proto = function(script, param)
	{
		var param = (param == null) ? null : param
		this.charger('modeles/proto/'+script, param);
	}//proto
	
	//-----------------------------------------------------
	//                                                  lib 
	this.lib = function(script, param)
	{
		var param = (param == null) ? null : param
		this.charger('modeles/lib/'+script, param);
		if(DLN != null)
		{
			DLN.preparerLinstance(script);
		}
		else
		{
			alert('Impossible de charger l\'objet DLN');	
		}
	}//lib
	
	//-----------------------------------------------------
	//                                            app 
	this.app = function(script, param)
	{
		var param = (param == null) ? null : param
		this.charger('modeles/app/'+script+'/'+script, param);
	}//app
	
	
	//-----------------------------------------------------
	//                                              charger 
	this.charger = function(url, param)
	{
		var param = (param == null) ? '' : '?'+param
		var src = this._racine + url+'.js'+param
		var noeud = this.creerUnNoeud('script', src );
		var head = document.getElementsByTagName('head')[0];
		head.appendChild(noeud);
		//head.removeChild(noeud);
	
	}
	
	this.creerUnNoeud = function(balise, src)
	{
		var nouveau = document.createElement(balise);
		nouveau.src = src;
		return nouveau;
	}

	
	//-----------------------------------------------------
	//                                             preparer 
    this.preparer = function(nom)
	{
		this._preparer.push(nom);
	}//preparer
	
	this.identifier = function()
	{
		alert('auteur : '+ this._auteur + '\n\r' +
			  'courriel : '+ this._courriel + '\n\r'
			  );	
	}
	
	this.callback = function(sMessage) 
	{
        alert(sMessage);
	}
	
	this.init();
}//ChargeurDLN










