// fonction get value from textbox if not vide
function getValueIfNotNull(fieldEst, defaultValeur) {
	var str=defaultValeur;
//alert(fieldEst);
	if (fieldEst!=undefined) {
		str = fieldEst.value;
	}
	return str
}

// fonction pour dessiner le header
function drawHeader() {
	// texte to display
	var t=""; 
	
	// Arbre avec les informations pour les noms selon langue et affichage selon autorisation
	//var dRoot=document.XMLDocument.documentElement; est memorise en variable globale dans le debut du document
	
	//--------------------------------------
	// variables utilisees 
	//--------------------------------------
	// SessionGroup 'pour determiner si la personne s'est deja logger ou nom
	// si le noeud "INFO_GEN/SESSION_GROUP" n'existe pas, cela est volontaire parce qu'il n'y a pas besoin de tester si doit afficher ou non
	var Session_Group = "Ok";
	// OKForDataAccess ' si a besoin de tester si peut afficher le lien vers l'administration
	var OKForDataAccess = "1";
	// LG
	var LG = "GB";
	// Textes selon la Langue LG
	var LibelleEst = "";
	
	// test si dRoot existe ou non : correspond a XML ou HTML
	// acces en XML
	if (dRoot!= undefined)	{ 
		if (dRoot.getElementsByTagName("INFO_GEN/SESSION_GROUP").item(0)!=null) {
			Session_Group = dRoot.getElementsByTagName("INFO_GEN/SESSION_GROUP").item(0).text;
		}
		if (dRoot.getElementsByTagName("INFO_GEN/OKForDataAccess").item(0)!=null) {
			OKForDataAccess = dRoot.getElementsByTagName("INFO_GEN/OKForDataAccess").item(0).text;
		}		
		LG = dRoot.getElementsByTagName("INFO_GEN/LG").item(0).text;
	
		LibelleEst = "Administration";
		var Administration = get_Traduction(dRoot, LibelleEst);
		
		LibelleEst = "Login";
		var Login=get_Traduction(dRoot, LibelleEst);
		
		LibelleEst = "Logout";
		var Logout=get_Traduction(dRoot, LibelleEst);
		
		LibelleEst = "Reports";
		var Reports=get_Traduction(dRoot, LibelleEst);
		
		LibelleEst = "Help";
		var Aide=get_Traduction(dRoot, LibelleEst);
	}
	// acces en HTML, les valeurs sont dans un form appele formDrawHeader
	else { 
		// 2004-05-29, page concernee:
		// ReportCreaAdmin.asp
		Session_Group = getValueIfNotNull(document.formDrawHeader.SESSION_GROUP, Session_Group);
		//alert(Session_Group);
		// OKForDataAccess ' si a besoin de tester si peut afficher le lien vers l'administration
		OKForDataAccess = getValueIfNotNull(document.formDrawHeader.OKForDataAccess, OKForDataAccess)
		// LG
		LG = document.formDrawHeader.LG.value;
	
		// Textes selon la Langue LG
		Administration = document.formDrawHeader.Administration.value;

		Login=document.formDrawHeader.Login.value;

		Logout=document.formDrawHeader.Logout.value;

		Reports=document.formDrawHeader.Reports.value;
		

		Aide=document.formDrawHeader.Help.value;
	}
	
	t="<table width='630' border='0' cellpadding='0'>";
		t=t+"<tr>";
			t=t+"<td colspan='4' bgcolor='#E8EEFC'>";
				t=t+"<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
					t=t + "<tr>";
						t=t+"<td><a href='http://www.kwlog.com'><img src='../images/Kwlog_Logo_2004.jpg' border='0' width='247' height='35' ></a></td>";
						t=t+"<td align='right' valign='baseline'><font color='#556285'><b><font face='Verdana, Arial, Helvetica, sans-serif'>&nbsp;</font></b></font></td>";
					t=t+"</tr>";
				t=t+"</table>";
			t=t+"</td>";
		t=t+"</tr>";
		t=t+"<tr>";
			t=t+"<td colspan='4' bgcolor='#385B83' height='1'><img src='images/PxSpace.gif' height='1' width='100%'></td>";
		t=t+"</tr>";
		t=t+"<tr>";
			t=t+"<td colspan='4' ><img src='images/PxSpace.gif' height='15'></td>";
		t=t+"</tr>";
	t=t+"</table>";
	// si session_group est non null = la personne s'est deja loggee ou bien pas besoin de verifier si doit afficher
	if (Session_Group!='') {
 		t=t+"<table width='630' border='1' cellpadding='0' cellspacing='0'>";
			t=t+"<tr bgcolor='#CDD6F5'>";
				t=t+"<td width='126'>";
					// si a besoin de verifier, affiche le lien vers l'administration que si OKForDataAccess = 1
					if (OKForDataAccess=='1') {
						t=t+"<div align='center'><b>";
							t=t+"<font size='2' face='Arial, Helvetica, sans-serif' color='#FFFFFF'>";
								t=t+"<a href='Administration.asp?LG="+LG+"'>";
									t=t+Administration;
								t=t+"</a>";
							t=t+"</font></b>";
						t=t+"</div>";
					}
					else {
						t=t+"&nbsp;";
					}
				t=t+"</td>";
				t=t+"<td width='126'>";
					t=t+"<div align='center'><b>";
						t=t+"<font size='2' face='Arial, Helvetica, sans-serif' color='#FFFFFF'>";
							t=t+"<a href='ReportCreaAdmin.asp?LG="+LG+"'>";
								t=t+Reports;
							t=t+"</a>";
						t=t+"</font></b>";
					t=t+"</div>";
				t=t+"</td>";
				t=t+"<td width='126'>";
					t=t+"<div align='center'><b>";
						t=t+"<font size='2' face='Arial, Helvetica, sans-serif' color='#FFFFFF'>";
							t=t+"<a href='ReportLogin.asp?LG="+LG+"'>";
								t=t+Login;
							t=t+"</a>";
						t=t+"</font></b>";
					t=t+"</div>";
				t=t+"</td>";
				t=t+"<td width='126'>";
					t=t+"<div align='center'><b>";
						t=t+"<font size='2' face='Arial, Helvetica, sans-serif' color='#FFFFFF'>";
							t=t+"<a href='ReportLogout.asp?LG="+LG+"'>";
								t=t+Logout;
							t=t+"</a>";
						t=t+"</font></b>";
					t=t+"</div>";
				t=t+"</td>";
				
				t=t+"<td width='126'>";
					t=t+"<div align='center'><b>";
						t=t+"<font size='2' face='Arial, Helvetica, sans-serif' color='#FFFFFF'>";
							t=t+"<a href='Xhelp.asp?LG="+LG+"' target='_blank'>";
								t=t+Aide;
							t=t+"</a>";
						t=t+"</font></b>";
					t=t+"</div>";
				t=t+"</td>";
			t=t+"</tr>";
		t=t+"</table>";	
	}	
	document.write(t);
}

// Function pour obtenir la traduction d'un tag
// function get_Traduction(dRoot, LibelleEst): est dans le xmldom_functions.js

// fonction pour dessiner le bottom
function drawFooter() {
	// texte to display
	var t=""; 

	t=t+"<table width='630' border='0' cellspacing='0' cellpadding='0'>";
		t=t+"<tr>";
		t=t+"<td colspan='4' height='20'><img src='images/PxSpace.gif' height='20'></td>";
	  t=t+"</tr>";
	  t=t+"<tr>"; 
		t=t+"<td colspan='4' bgcolor='#385B83' height='1'>";
	  t=t+"</tr>";
	  t=t+"<tr>"; 
		t=t+"<td colspan='4' height='20' >";  
		  t=t+"<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
			t=t+"<tr>";
			  t=t+"<td valign='top'><font size='-3' color='#27405A' face='Arial, Helvetica, sans-serif'>"; 
				t=t+"KWLOG S.A.R.L. capital 7 500 Euro,12 rue poulet, 75018 Paris, France<br/>";
				t=t+"Tel : + 33 871 79 10 23, e-mail: eferreol@kwlog.com<br/>";
				t=t+"RCS : Paris B 440 965 010 - TVA : FR 21 440 965 010</font></td>";
			  t=t+"<td align='right' valign='top'><font color='#27405A' face='Arial, Helvetica, sans-serif' style='font-size: x-small;'>\251 Kwlog. All rights reserved.</font></td>"; // \251 gives the copyright symbol
			t=t+"</tr>";
		  t=t+"</table>";
		t=t+"</td>";
	  t=t+"</tr>"; 
	  t=t+"<tr>"; 
		t=t+"<td colspan='4' height='20'><img src='images/PxSpace.gif' height='20'></td>";
	  t=t+"</tr>";
	t=t+"</table>";
	document.write(t);
}
