// JavaScript Document
// Class created by Pellichero Olivier

// Class Constructor
function HtmlManager(){
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	// Creation de la methode qui construit des noeuds HTML
	this.createNode = function(sTypeBalise){
		// Creation des proprietes
		var oNoeud						= document.createElement(sTypeBalise);
		var oContenu;
		var nParametre					= 0;
		// Analyse des parametres de la fonction
		for(nParametre = 1; nParametre < arguments.length; nParametre++){
			oContenu					= arguments[nParametre];
			if(typeof oContenu == "string"){	// Le parametre est un texte
				oNoeud.appendChild(document.createTextNode(oContenu));
			}else if(oContenu.nodeName){			// Le parametre est un noeud
				oNoeud.appendChild(oContenu);
			}else{									// Le parametre est un objet contenant des parametres
				// Assignation des parametres
				for(var sParametre in oContenu){
					oNoeud[sParametre]	= oContenu[sParametre];
				}
			}
		}
		// Return value
		return oNoeud;
	},
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	// Identification browser
	this.typeBrowser = function(){
		var nType;
		switch(navigator.appName){
			case "Microsoft Internet Explorer":	this.nType = 0; break;
			case "Netscape":					this.nType = 1; break;
			case "Opera":						this.nType = 2; break;
		}
		// Return value
		return this.nType;
	},
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	// Identification of id	
	this.getElement = function(sId){
		var bSucces		= false;
		var oBloc;
		if(document.getElementById && document.getElementById(sId)){ 	// Recentlies browsers
			bSucces		= true;
			oBloc		= document.getElementById(sId);
		}else if(document.all && document.all[sId]){ 					// Olds versions
			bSucces		= true;	
			oBloc 		= document.all[sId];
		}else if(document.layers && document.layers[sId]){				// Older versions
			bSucces		= true;
			oBloc		= document.layers[sId];
		}
		// Return value
		if(bSucces){
			return(oBloc);
		}else{
			return;
		}
	},
	
	// Chargement xml
	this.loadXml = function(sHref){
		// Creation de la variable
		var xmlDoc;
		// Analyse du type de chargement en fonction du navigateur
		try{ 				 //Internet Explorer
  			xmlDoc 			= new ActiveXObject("Microsoft.XMLDOM");
  		}catch(e){
			try{ 			//Firefox, Mozilla, Opera, etc.
				xmlDoc 		= document.implementation.createDocument("","",null);
			}catch(oError){
				alert(oError.message);
			}
  		}
		// Chargement du xml
		try{
  			xmlDoc.async	= false;
  			xmlDoc.load(sHref);
  			return(xmlDoc);
  		}catch(oError){
			alert(oError.message)
		}
		return(null);
	}
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	// Final css value	
	this.getCssStyleFinal = function(sId){
		// Identification du bloc
		var oBloc			= this.getElement(sId);
		if(!oBloc) return;
		// Analyse du type de navigateur
		if(this.typeBrowser == 0){
			// Recherche de la valeur 
			return(window.currentStyle);
		}else{
			// Recherche de la valeur 
			return(window.getComputedStyle(oBloc, null));
		}
	}
};