// Fonction de gestion de l'acces a "Mon Compte"

var realmedia_sdv=0;


//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;
				return unescape(dc.substring(begin, end));
		}
	}
	return null;
}


id_client=getCookie('id_client');
largeur=window.screen.width;

var new_bandeau=0;

//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_bouton() {

	

	//Verif si bourse

	var url=document.location.toString();

	if (url.indexOf('bourse.lesechos.fr') != -1 || url.indexOf('axime.com') != -1)
	{
	document.write("<a href='http://bourse.lesechos.fr/bourse/connexion.jsp?from=ptf'>Votre portefeuille</a>");
	return;
	}

	var nom	=getCookie('nom');
	var prenom	=getCookie('prenom');
	var civilite=getCookie('civilite');
	var id_client=getCookie('id_client');

	if(nom == 'EXTRANET' && id_client!=null) affiche_bouton_extranet(prenom);
	else if(nom == null && prenom==null && id_client==null) affiche_bouton_non_identifie();
	else				affiche_bouton_identifie(civilite,nom,prenom);
}

function affiche_bandeau() {

        var url=document.location.toString();

        if (url.indexOf('bourse.lesechos.fr') != -1 || url.indexOf('axime.com') != -1)
        {
        return;
        }


	nom	=getCookie('nom');
	prenom	=getCookie('prenom');
	civilite=getCookie('civilite');
	id_client=getCookie('id_client');

	if(nom == 'EXTRANET') affiche_bandeau_extranet(prenom);
	else if(nom == null && prenom==null && id_client==null) affiche_bandeau_non_identifie();
	else affiche_bandeau_identifie(civilite,nom,prenom);
}

function valider_bandeau_abo(){
  // si la valeur du champ identifiant est non vide
  if(document.bnd_abo.USER.value != "") {
    // les données sont ok, on peut envoyer le formulaire    
    return true;
  }
  else {
    // sinon on affiche un message
    alert("Saisissez votre identifiant");
    // et on indique de ne pas envoyer le formulaire
    return false;
  }
}


function affiche_bouton_non_identifie(){



   document.write('  <a href="#" onClick="$(\'#EchosFloat\').css(\'opacity\', \'0.5\'); $(\'#identifier\').animate({\'opacity\': \'show\'}, 800); $(\'#EchosFloat\').fadeIn(800, function() {}); return false;">S\'identifier</a>');


}


function affiche_bandeau_non_identifie() {

document.write("\<div id=\"identifier\" style=\"display:none\"\>")
document.write("\<div class=\"identifier\"\>")
document.write("")
document.write("	\<div class=\"top\"\>")
document.write("		\<div style=\"position:relative;float:right;\"\>")
document.write("			Fermer\<a href=\"#\" onclick=\"$(\'#identifier\').fadeOut(900);$(\'#EchosFloat\').fadeOut(800);return false;\"\>\<img src=\"http://pics.lesechos.fr/icons/b_ident_fermer_24.png\" style=\"margin-left:5px;width:16px;height:16px;\" align=\"absmiddle\" /\>\</a\>")
document.write("")
document.write("		\</div\>")
document.write("		\<span class=\"intitule\"\>S'identifier\</span\>")
document.write("		\<div class=\"clear\"\>&nbsp;\</div\>")
document.write("	\</div\>\<!--top--\>")
document.write("	\<div class=\"sous-top\"\>&nbsp;\</div\>")
document.write("	")
document.write("	\<div class=\"clear\"\>&nbsp;\</div\>")
document.write("	")
document.write("	\<div class=\"identifiant\"\>")
document.write("		\<form action=\"http://www.lesechos.fr/acces/php/login.php?origin=bandeau\" method=\"POST\" name=\"bnd_abo\" onsubmit=\"return valider_bandeau_abo()\">")
document.write("")
document.write("		\<span class=\"tit\"\>Identifiant :\<br /\>\</span\>")
document.write("		\<input type=\"text\" class=\"champ\" size=\"20\" style=\"width:150px;\" name=\"USER\" /\>\<br /\>")
document.write("		\<br /\>")
document.write("		\<span class=\"tit\"\>Mot de passe :\<br /\>\</span\>")
document.write("		\<input type=\"text\" class=\"champ\" size=\"20\" style=\"width:150px;\" name=\"PASS\" /\>\<br /\>")
document.write("		\<br /\>")
document.write("		\<input type=\"image\" src=\"http://pics.lesechos.fr/icons/b_ident_connexion.png\" name=\"go\" /\>")
document.write("		\<input type=\"checkbox\" checked=\"checked\" name=\"MEMO\" /\> Mémoriser\<br /\>")
document.write("")
document.write("		\<br /\>")
document.write("		\<span style=\"background-image:url('http://pics.lesechos.fr/icons/f_link_bot_on.png');background-position:left center;background-repeat:no-repeat;padding-left:10px;\"\>\<a href=\"http://serviceclient.lesechos.fr/scweb/SendLP.aspx\"\>Codes oubliés ?\</a\>\</span\>")
document.write("		\</form\>")
document.write("	\</div\>\<!--identifiant--\>")
document.write("	")
document.write("	")
document.write("	\<div class=\"inscrit\"\>")
document.write("	\<span class=\"tit\"\>")
document.write("	Pas encore inscrit ?\<br /\>")
document.write("	\<br /\>")
document.write("")
document.write("	Découvrez\<br /\>")
document.write("	l'abonnement au\<br /\>")
document.write("	pack Web Les Échos\<br /\>")
document.write("	\<br /\>")
document.write("	\</span\>")
document.write("	\<a href=\"http://www.lesechos.fr/abonnement/index.htm\"\>\<img src=\"http://pics.lesechos.fr/icons/b_ident_inscription.png\" /\>\</a\>")
document.write("	\</div\>\<!--inscrit--\>")
document.write("")
document.write("	")
document.write("	\<img style=\"position:relative;float:left;\" src=\"http://pics.lesechos.fr/icons/ident_illus.jpg\" width=\"137\" height=\"193\" /\>")
document.write("	")
document.write("	\<div class=\"clear\"\>&nbsp;\</div\>")
document.write("")
document.write("")
document.write("\</div\>")
document.write("\</div\>\<!--identifier--\>")



}

function affiche_bouton_extranet(prenom) {

   document.write('  <a href="#" onClick="$(\'#EchosFloat\').css(\'opacity\', \'0.5\'); $(\'#identifier\').animate({\'opacity\': \'show\'}, 800); $(\'#EchosFloat\').fadeIn(800, function() {}); return false;">Mon compte Extranet</a>');
}


function affiche_bouton_identifie(civilite,nom,prenom){
   document.write('  <a href="#" onClick="$(\'#EchosFloat\').css(\'opacity\', \'0.5\'); $(\'#identifier\').animate({\'opacity\': \'show\'}, 800); $(\'#EchosFloat\').fadeIn(800, function() {}); return false;">Mon compte</a>');

}



function affiche_bandeau_identifie(civilite,nom,prenom){

document.write('<script language="Javascript" src="http://www.lesechos.fr/javascript/espace_abonne.php"></script>');


}



function affiche_bandeau_extranet(nom){


document.write('<script language="Javascript" src="http://www.lesechos.fr/javascript/espace_abonne.php"></script>');

return;

document.write("<TABLE WIDTH=\"290\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\">");
document.write("\<form action=\"http://www.lesechos.fr/acces/php/login.php?origin=bandeau\" method=\"POST\" \>");
document.write("<TR><TD align=center class=\"PTIT\">");
document.write("        \<b\>Extranet&nbsp;"+nom+"\</b\>");
document.write("</TD></TR>");
document.write("<TR VALIGN=\"middle\"><TD CLASS=\"REG-TXT\" align=\"center\">");
document.write("<br>\<br>\<a href=\"http://www.lesechos.fr/acces/php/deconnection.php\" class=\"LIEN-CONTEXT\"\>\ Déconnexion\</a\>");
document.write("</TD></TR>");
document.write("        \</form\>");
document.write("</TABLE>");
}



