// Fonction de gestion de l'acces a "Mon Compte"

//Get Cookie Function --------------------------------------------------------------------------
function getCookie(name) {
	var cname = '; ' + name + "=";
	var dc = '; '+document.cookie;
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				s=new String("");
				s=unescape(dc.substring(begin, end));
				RegExp = /\+/gi;
				s1=s.replace(RegExp,' ');
				return(s1);
				//return unescape(dc.substring(begin, end));
		}
	}
	return null;
}

//Set Cookie Function ---------------------------------------------------------------------------
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
	((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	((secure == null) ? "" : "; secure");
}

//Delete Cookie Function ------------------------------------------------------------------------
function delCookie (name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// Fonction principale, appelee depuis les pages HTML -------------------------------------------

function affiche_bandeau(){
	nom	=getCookie('nom');		if(nom==null)nom='';
	prenom	=getCookie('prenom');		if(prenom==null)prenom='';
	civilite=getCookie('civilite');		if(civilite==null)civilite='';
	id_client=getCookie('id_client');	if(id_client==null)id_client='';
	mail=getCookie('mail');			if(mail==null)mail='';

	//str= ' ' + prenom + ' ' + nom ;
	//if(str=='  ')	 str=mail;
	str=mail;

	if(id_client == '')		affiche_bandeau_non_identifie();
	else				affiche_bandeau_identifie(str);
}

function affiche_bandeau_non_identifie(){
document.write("<P class=\"ti_login\">Espace Abonné</P>")

document.write("	<form action=\"/acces/login.php\"	\
			method=\"POST\"				\
			name=\"f_ident\">")

document.write("<input class=\"inputLogin\"		\
			name=\"login\"			\
			type=\"text\"			\
			size=\"20\"			\
			maxlength=\"50\"		\
			value=\"login\"			\
			onFocus=\"if (this.value=='login') {this.value=''}\"	\
			onBlur=\"if(this.value==''){this.value='login'}\">")
document.write("<input	class=\"inputLogin\"		\
			name=\"mot_de_passe\"		\
			type=\"password\"		\
			size=\"20\"			\
			maxlength=\"30\"		\
			value=\"pass\"			\
			onFocus=\"if (this.value=='pass') {this.value=''}\"	\
			onBlur=\"if(this.value==''){this.value='pass'}\">")
document.write("<input	type=\"image\"			\
			src=\"/templates/argus/images/bouton_ok_login.gif\" >")
document.write("<input	type=\"checkbox\"		\
			name=\"MEMO\"			\
			checked=\"checked\"> Mémoriser ");
document.write("</form>")

document.write("<a href=\"/acces/moncompte/codeoublie.php\" \>\<b>Mot de passe oublié ?</b ></a><br >")
document.write("")
}


function affiche_bandeau_identifie(str){
document.write("<P class=\"ti_login\">Espace Abonné</P>")
document.write("<br />Bonjour "+str)
document.write("<p>")

document.write("<a href=\"/acces/moncompte/index.php\" ><b>Mon compte</b></a><br />")
document.write("<a href=\"/acces/deconnection.php\">    <b>D&eacute;connexion</b></a>")
document.write("</p>")
document.write("")
}

function toPass(obj)
{
        if(obj.value=="Mot de passe" || obj.value=="")
        {
                obj.value="";
                //var ele = document.getElementById("champ_password");
                //ele.innerHTML="<input id=\"mot_de_passe\" name=\"mot_de_passe\" type=\"password\" size=\"14\" maxlength=\"30\" value=\"\" onFocus=\"toPass(this);\" onBlur=\"toText(this);\"\>";
                //document.getElementById("mot_de_passe").focus();
                obj.type="password";
        }

}

function toText(obj)
{
        if(obj.value=="")
        {
                obj.value="Mot de passe";
                //var ele = document.getElementById("champ_password");
                //ele.InnerHTML="\<input id=\"mot_de_passe\" name=\"mot_de_passe\" type=\"text\" size=\"14\" maxlength=\"30\" value=\"Mot de passe\"\ onFocus=\"toPass(this);\" onBlur=\"toText(this);\" onFocus=\"toPass(this);\" onBlur=\"toText(this);\"\>";
                obj.type="text";
        }
}

function coupe(str)
{
temp = str.split('@');
document.write(temp[0]+"<br/>@"+temp[1]);
}



