var xmlDoc;
var xmlTmpl;
var id_type;

// ----------------------------------
// ----- getVarHref -----
// ----------------------------------
function getVarHref (nomVariable)
{
	    var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&";
	    if (infos.indexOf("#")!=-1)
		    infos = infos.substring(0,infos.indexOf("#"))+"&";
	    var variable=0;
	    {
		    nomVariable = nomVariable + "=";
		    var taille = nomVariable.length;
		    if (infos.indexOf(nomVariable)!=-1)
			    variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"));
	    }
	    return variable;
}

function loadXmlDoc ()
{   
    id_type = getVarHref("type"); 
    
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.load("CATALOG.xml");
    
    xmlTmpl = xmlDoc.selectSingleNode("//t_template[nm_parentType='"+ id_type +"']");
    if (xmlTmpl == null) xmlTmpl = xmlDoc.selectSingleNode("//t_template[nm_parentType = '0']");	
    
    /* Load le fichier de langue */
    xmlDocLang = new ActiveXObject("Microsoft.XMLDOM");
    xmlDocLang.async="false";
    xmlDocLang.load("language.xml");
    xmlLang = xmlDocLang.selectSingleNode("//lang[nm_Language = '" + xmlTmpl.selectSingleNode("nm_Language").text + "']");

}

function setLeftStyle ()
{
	var oSheet = document.styleSheets[0];	
	oSheet.addRule('body', 'color:' + xmlTmpl.selectSingleNode("nm_LeftTextColor").text + ';');		
	oSheet.addRule('.leftSection', 'background-color:' + xmlTmpl.selectSingleNode("nm_LeftBgColor").text + ';');	
	oSheet.addRule('td.menu_off', 'border-bottom-color:' + xmlTmpl.selectSingleNode("nm_LeftTextColor").text + ';');		
	oSheet.addRule('td.menu_over', 'background-color:' + xmlTmpl.selectSingleNode("nm_LeftOverColor").text + ';');	
	oSheet.addRule('td.menu_off', 'height:' + xmlTmpl.selectSingleNode("nu_LeftHeight").text + 'px;');		
	oSheet.addRule('td.menu_over', 'height:' + xmlTmpl.selectSingleNode("nu_LeftHeight").text + 'px;');	
}
 
function setHeaderStyle ()
{
	var oSheet = document.styleSheets[0];	
	oSheet.addRule('body', 'color:' + xmlTmpl.selectSingleNode("nm_HeaderTextColor").text + ';');		
	oSheet.addRule('body', 'background-color:' + xmlTmpl.selectSingleNode("nm_HeaderBgColor").text + ';');	
	if ( xmlTmpl.selectSingleNode("dc_HeaderBgImg").text != "")
		oSheet.addRule('body', 'background-image: url(' + xmlTmpl.selectSingleNode("dc_HeaderBgImg").text + ');');
}

function setBottomStyle ()
{
	var oSheet = document.styleSheets[0];	
	oSheet.addRule('body', 'color:' + xmlTmpl.selectSingleNode("nm_FooterTextColor").text + ';');		
	oSheet.addRule('body', 'background-color:' + xmlTmpl.selectSingleNode("nm_FooterBgColor").text + ';');
}

function setDetailStyle ()
{
	var oSheet = document.styleSheets[0];

	oSheet.addRule('body', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');		
	oSheet.addRule('body', 'background-color:' + xmlTmpl.selectSingleNode("nm_DetailBgColor").text + ';');		
	oSheet.addRule('.selectButtonUC', 'background-color:' + xmlTmpl.selectSingleNode("nm_DetailButtonColor").text + ';');	
		
	oSheet.addRule('.selectButtonCatImage', 'width:  expression( (' + xmlTmpl.selectSingleNode("nu_DetailCatImgWidth").text + ' / this.width) > (' + xmlTmpl.selectSingleNode("nu_DetailCatImgHeight").text + ' / this.height) ? null : ' + xmlTmpl.selectSingleNode("nu_DetailCatImgWidth").text + ' + "px");');				
	oSheet.addRule('.selectButtonCatImage', 'height:  expression( (' + xmlTmpl.selectSingleNode("nu_DetailCatImgWidth").text + ' / this.width) > (' + xmlTmpl.selectSingleNode("nu_DetailCatImgHeight").text + ' / this.height) ? ' + xmlTmpl.selectSingleNode("nu_DetailCatImgHeight").text + ' + "px" : null);');				

	oSheet.addRule('.selectButtonUCImage', 'width:  expression( (' + xmlTmpl.selectSingleNode("nu_DetailImgWidth").text + ' / this.width) > (' + xmlTmpl.selectSingleNode("nu_DetailImgHeight").text + ' / this.height) ? null : ' + xmlTmpl.selectSingleNode("nu_DetailImgWidth").text + ' + "px");');				
	oSheet.addRule('.selectButtonUCImage', 'height:  expression( (' + xmlTmpl.selectSingleNode("nu_DetailImgWidth").text + ' / this.width) > (' + xmlTmpl.selectSingleNode("nu_DetailImgHeight").text + ' / this.height) ? ' + xmlTmpl.selectSingleNode("nu_DetailImgHeight").text + ' + "px" : null);');				
		
	oSheet.addRule('a.cat:link', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');
	oSheet.addRule('a.cat:visited', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');
	oSheet.addRule('a.cat:active', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');
	
	oSheet.addRule('.catDesc a:link', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');
	oSheet.addRule('.catDesc a:visited', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');
	oSheet.addRule('.catDesc a:active', 'color:' + xmlTmpl.selectSingleNode("nm_DetailTextColor").text + ';');		
	
}


