

function check_login_for_search_menu(image_url, image_cine, mes_favoris_url, mon_profil_url, mes_cines_url, login_url, register_url, deconnect_url) {

	var is_logged_in = GetCookie("user_logged");

	if( is_logged_in == "oui"){
		var texte_logged_in =  get_user_logged_in_text(image_url, image_cine, mes_favoris_url, mon_profil_url, mes_cines_url, deconnect_url);
		return texte_logged_in;
		}
		else
		{
			var texte_not_logged_in = get_user_not_logged_in_text(image_url, login_url, register_url);
			return texte_not_logged_in;
		}		
}

function get_user_logged_in_text(image_url, image_cine, mes_favoris_url, mon_profil_url, mes_cines_url, deconnect_url) {
/* Header pour AZIZA */
/*
	var aRemplacer = /\+/g;
	var username = GetCookie("pseudo");
 	text = '<div class="bloc_identification bloc_identification_logout" id="identification">';
	text += '<ul class="bloc_logout">';
	text += '<li>' + username.replace(aRemplacer, " ") + '</li>';
	text += '<li>|</li>';	
    text += '<li><a href="http://www.premiere.fr/action/edit" title="MON PROFIL" tabindex="11">MON PROFIL</a></li>';
    text += '<li>|</li>';
	text += '<li><a href="http://www.premiere.fr/action/bookmark" title="MES FAVORIS" tabindex="10">MES FAVORIS</a></li>';
	text += '<li>|</li>';
    text += '<li><a href="http://www.premiere.fr/action/logout" title="DECONNEXION" tabindex="12">DECONNEXION</a></li>';
*/
	var aRemplacer = /\+/g;

	var username = GetCookie("pseudo");
	text = '<div class="bloc_identification bloc_identification_logout" id="identification">';
	text += '<ul class="bloc_logout">';
	
	text += '<li><a href="http://www.premiere.fr/action/edit" title="PROFIL" tabindex="11">Mon profil</a></li>';
	text += '<li class="sepa"></li>';
    text += '<li><a href="http://www.premiere.fr/action/logout" title="DECONNEXION" tabindex="12">Se d&eacute;connecter</a></li>';
	text += '</ul></div>';
	
return text;	
}

function get_user_not_logged_in_text(image_url, login_url, register_url) {

/* HEADER POUR AZIZA */
/*	
	texte = '<div class="bloc_identification" id="identification">';
	texte += '<ul class="bloc_login">';
	texte += '<li><a href="http://www.premiere.fr/action/login" title="s\'identifier" tabindex="10">s\'identifier</a></li>';
	texte += '<li>|</li>';
	texte += '<li><a  href="http://www.premiere.fr/action/login" title="s\'inscrire" tabindex="11">s\'inscrire</a></li>';
	texte += '<li>|</li>';
	texte += '<li class="rss"><a href="http://www.premiere.fr/Cinema/Web-2.0/RSS" title="flux rss" tabindex="12"><span></span>flux rss</a></li>';
	texte += '</ul></div>';
*/	
	

	texte = '<div class="bloc_identification" id="identification">';
	texte += '<ul class="bloc_login">';
	texte += '<li><a href="http://www.premiere.fr/action/login" title="s\'identifier" tabindex="10">Je me connecte</a></li>';
	texte += '<li class="sepa"></li>';
	texte += '<li><a href="http://www.premiere.fr/action/login/(origine)/ins" tabindex="12"><span></span>Je m\'inscris</a></li>';
	texte += '</ul></div>';
	
	return texte;
}

function get_cine_texte(mes_cines_url, image_cine){

	cine_texte = '<li id="cinefav" class="cinemafavoris">';
   
	if ((GetCookie("cine0") == "") && (GetCookie("cine1") == "") && (GetCookie("cine2") == ""))
		{
			cine_texte += '<a href="http://www.premiere.fr/horaire/cinemasFavoris" tabindex="14">AJOUTER VOS CINEMAS FAVORIS</a>';
		}
		else
		{
			if(GetCookie("cine1")){
				var MyCookies0 = GetCookie("cine1");
				}else{
				var MyCookies0 = "";
				}
				if(GetCookie("cine2")){
				var MyCookies1 = GetCookie("cine2");
				}else{
				var MyCookies1 = "";
				}
				if(GetCookie("cine3")){
				var MyCookies2 = GetCookie("cine3");
				}else{
				var MyCookies2 = "";
				}
									
				var idCookie0 = GetCookie("id1");
				var idCookie1 = GetCookie("id2");
				var idCookie2 = GetCookie("id3");
		
				var aRemplacer = /\+/g;
				
				var cineName0 = MyCookies0.replace(aRemplacer, " ");
				var cineName1 = MyCookies1.replace(aRemplacer, " ");
				var cineName2 = MyCookies2.replace(aRemplacer, " ");
		
				cine_texte +='<span style="display: none;">';
				if (MyCookies0 != "" && idCookie0 != "")
					cine_texte +='<a href="http://www.premiere.fr/premiere/horaire/detail?cinema=' + idCookie0 + '" title="' + cineName0 + '">' + cineName0 + '<\/a>'
				if (MyCookies1 != "" && idCookie1 != "")
					cine_texte +='<a href="http://www.premiere.fr/premiere/horaire/detail?cinema=' + idCookie1 + '" title="' + cineName1 + '">' + cineName1 + '<\/a>'
				if (MyCookies2 != "" && idCookie2 != "")
					cine_texte +='<a href="http://www.premiere.fr/premiere/horaire/detail?cinema=' + idCookie2 + '" title="' + cineName2 + '">' + cineName2 + '<\/a>'

				cine_texte +='<a href="http://www.premiere.fr/horaire/cinemasFavoris" title="Ajouter \/modifier un cin&eacute;ma" tabindex="14">Ajouter \/ modifier un cin&eacute;ma</a>';
				cine_texte +='</span>AJOUTER VOS CINEMA FAVORIS';
			}
				
	cine_texte += '</li>';
		
	return cine_texte;
}


function deroule(param){
	var zone;
	param['target'] ? zone = param['target']['myvar'] : zone = param['srcElement']['myvar'];

		if (zone!=1) {
			document.getElementById('cinefav').childNodes[0].style.display='none';
		} else {
			if (document.getElementById('cinefav').childNodes[0].style.display!='block') {
				document.getElementById('cinefav').childNodes[0].style.display='block';
			} else {
				document.getElementById('cinefav').childNodes[0].style.display='none';
			}
		}
}

window.onload=function addListener() {

	if ( 
			!(
				(GetCookie("cine0") == "" || GetCookie("cine0") == null) && 
				(GetCookie("cine1") == "" || GetCookie("cine1") == null) && 
				(GetCookie("cine2") == "" || GetCookie("cine2") == null)
			)
		)
	{
		if (document.getElementById('cinefav')) {
			var listecine=document.getElementById('cinefav');
			if(window.addEventListener){
				listecine.addEventListener('click', deroule, false);
				listecine.myvar=1;
				listecine.removeEventListener('click', deroule, false);
				window.addEventListener('click', deroule, false);
			} else {
				listecine.attachEvent('onclick', deroule);
				listecine.myvar=1;
				listecine.detachEvent('onclick', deroule)
				document.body.attachEvent("onclick", deroule);
			}
		}
	}
}
