function SelectionDeLisa(){
	this.ajouter=function(annonceId){
        var testCk=application.setcookie('test','ok');
		if (application.getcookie('test')==null){
			var msg="L'ajout de ce bien à votre sélection suppose que votre navigateur accepte les \"cookies\".\n Pour savoir comment modifier ce paramètre, veuillez consulter l'aide de votre navigateur.";
			alert(msg);
			return false
		};
		var ajoutee=false;
		var aSelectionDeLisa=this.getSelectionDeLisaCookie();
		if (aSelectionDeLisa.indexOf(annonceId)==-1){
			aSelectionDeLisa[aSelectionDeLisa.length]=annonceId;
			ajoutee=true;
		}
		this.setSelectionDeLisaCookie(aSelectionDeLisa);
        if (ajoutee===false) alert('Cette annonce figure déjà dans votre sélection');
        return ajoutee;
	}
	this.afficher=function(){
        var aSelectionDeLisa=this.getSelectionDeLisaCookie();
		if (aSelectionDeLisa.length==0) {
			alert('Votre sélection ne contient actuellement aucune annonce.');
			return false;
		}
		$$('body')[0].addClassName('waiting');
		application.createBodyMask();
        return true;
	}
	this.supprimer=function(annonceLongId){
        var aSelectionDeLisa=this.getSelectionDeLisaCookie();
		if (aSelectionDeLisa.indexOf(annonceLongId)>=0) {
			aSelectionDeLisa=aSelectionDeLisa.without(annonceLongId);
			this.setSelectionDeLisaCookie(aSelectionDeLisa);
		}
        application.createBodyMask();
        window.location.reload();
        return;
	}
	this.getSelectionDeLisaCookie=function(){
		var c=application.getcookie('laSelectionDeLisa');//alert(c);
		if (c===null) return new Array(); else return c.evalJSON();
	}
	this.setSelectionDeLisaCookie=function(aSelectionDeLisa){
		var dMaintenant=new Date();
		dExpire=new Date();
		dExpire.setTime(dMaintenant.getTime() + (60*86400000 )) // 60 jrs
		cSelectionDeLisa=aSelectionDeLisa.toJSON();//alert(aSelectionDeLisa.toJSON())
		application.setcookie('laSelectionDeLisa',cSelectionDeLisa,dExpire);
	}
	this.envoyer=function(){
        parameters=$('formEnvoyerLaSelectionDeLisa').serialize(); alert(parameters);return;
		$('formEnvoyerLaSelectionDeLisa').disable();
		var url = '/pages/commun/ajax/selectionDeLisa.php';
		new Ajax.Request(url, {
			method: 'get',
			asynchronous: true,
			parameters: parameters,
			onSuccess: function(r) {  // alert(r.responseText); $('formEnvoyerLaSelectionDeLisa').enable(); return;
				datas=r.responseText.split('\n');
				$('formEnvoyerLaSelectionDeLisa').enable();
				if (datas[0]=='err') {
					alert(datas[1]);
					$('formEnvoyerLaSelectionDeLisa').enable();
				} else{
					alert(datas[1]);
                   // $('pbLaSelectionDeLisaEmail').value="";
					//application.destroyUserPromptBox(500);
				}
			},
			onFailure: function() {
				$$('body')[0].removeClassName('waiting');
				alert('La requête a echouée...');
				application.destroyBodyMask();
			}
		});
	}
}
laSelectionDeLisa=new SelectionDeLisa();
