// 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(id_client==null)mail='';

	str=civilite + ' ' + prenom + ' ' + nom ;
	if(str=='  ')	str=mail;

	if(id_client == '')		affiche_bandeau_non_identifie();
	else				affiche_bandeau_identifie(str);
}

function affiche_bandeau_non_identifie(){
document.write("")
document.write("\<div style=\"background-color:black;\"\>")
document.write("\<div class=\"TIT BLANC\" style=\"background:black;border:0px;\"\>Espace abonnés\</div\>")
document.write("\<div class=\"D-RECH\" style=\"text-align:left;background:white;\"\>")
document.write("\<form action=\"/acces/login.php\" method=\"POST\" name=\"f_ident\"\>")
document.write("\<input class=\"FORM-TXT\" style=\"border:0px;padding:1px;\" name=\"login\"  type=\"text\" size=\"14\" maxlength=\"50\" value=\"Email\" onFocus=\"if (this.value=='Email') {this.value=''}\" onBlur=\"if(this.value==''){this.value='Email'}\"\>")
document.write("\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-top:1px solid black;\"\>")
document.write("\<tr valign=\"middle\"\>")
document.write("\<td\>")
document.write("\<input class=\"FORM-TXT\" style=\"border:0px;padding:1px;\" name=\"mot_de_passe\" type=\"password\" size=\"14\" maxlength=\"30\" value=\"Mot de passe\" onFocus=\"if (this.value=='Mot de passe') {this.value=''}\" onBlur=\"if(this.value==''){this.value='Mot de passe'}\"\>")
document.write("\</td\>")
document.write("")
document.write("\<td width=\"15\" class=\"BG-GRIS-CLAIR\" align=\"right\"\>")
document.write("\<div style=\"text-align:center\"\>\<input name=\"go\" id=\"go\" type=\"image\" src=\"http://www.letelegramme.com/pictos/ok_gris_2007.gif\" /\>\</div\>")
document.write("\</td\>")
document.write("\</tr\>")
document.write("\</table\>")
document.write("\</form\>")
document.write("\</div\>")
document.write("\</div\>")
document.write("")
//document.write("\<div class=\"TIT\"\>\<a style=\"color:white;\" href=\"/acces/achat1.php\"\>Acheter / S'abonner\</a\>\</div\>")
document.write("")
document.write("")
}


function affiche_bandeau_identifie(str){
document.write("")
document.write("\<div style=\"background: black;\"\>")
document.write("\<div class=\"TIT BLANC\" style=\"background:black;border:0px;\"\>Espace abonnés\</div\>")
document.write("\<div class=\"D-RECH\" style=\"text-align:left;background:white;\"\>")
document.write("\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-top:1px solid black;\"\>")
document.write("\<tr\>")
document.write("\<td  style=\"border-top:2px solid black;padding:1px;\"\>")
document.write("\<div class=\"FORM-TXT\" style=\"font-weight:bold;color:black;padding:1px;background-color:white;\"\>")
document.write("Bonjour "+str)
document.write("\</div\>")
document.write("\</td\>")
document.write("\</tr\>")
document.write("\</table\>")
document.write("\</div\>")
document.write("\</div\>")
document.write("\<div class=\"TIT\"\>\<a class=\"NOIR\" href=\"/acces/mon_compte.php\"\>Mon compte\</a\>\</div\>")
document.write("\<div class=\"TIT\"\>\<a class=\"NOIR\" href=\"/acces/deconnexion.php\"\>Déconnexion\</a\>\</div\>")
document.write("")
}



