function sauvegardeTwimit(){
		z = document.createElement('script');
		z.src='/apps/add';
		document.body.appendChild(z);
	}


$(document).ready(function() {
    //Menu 1 lueur
    //Pour fair apparaitre un effet de dégradé sur le menu
    $("#entete_menu li a").css( { backgroundPosition: "50% 0px" } )
        .mouseover(function(){
            $(this).stop().animate({ backgroundPosition:"(50% -40px)" }, { duration:500 })
        })
        .mouseout(function(){
            $(this).stop().animate({ backgroundPosition:"(50% 0px)" }, { duration:1000 })
        })
});

/////////////////////



jQuery.unparam = function (value) {
    var
    // Object that holds names => values.
    params = {},
    // Get query string pieces (separated by &)
    pieces = value.split('&'),
    // Temporary variables used in loop.
    pair, i, l;

    // Loop through query string pieces and assign params.
    for (i = 0, l = pieces.length; i < l; i++) {
        pair = pieces[i].split('=', 2);
        // Repeated parameters with the same name are overwritten. Parameters
        // with no value get set to boolean true.
        params[decodeURIComponent(pair[0])] = (pair.length == 2 ?
            decodeURIComponent(pair[1].replace(/\+/g, ' ')) : true);
    }

    return params;
};
//////////////////////

var cookieList = function(cookieName) {
	
	var cookie = $.cookie(cookieName);
	var items = cookie ? cookie.split(/,/) : new Array();

	return {
	    "add": function(val) {
	    	a = decodeURIComponent($.param(val));
			items[items.length]= a;
			items.reverse(); 
			items = jQuery.unique(items);
			if(items.length > 5){
				items = items.slice(1,6);
			}	        
			$.cookie(cookieName, items,{ expires: 7, path: '/'});
	    },
	    "clear": function() {
	        $.cookie(cookieName, null,{ expires: 7, path: '/'});
	    },
	    "items": function() {
	    	a = new Array();
			for (var i = 0, j = items.length; i < j; i++) {
				a.push($.unparam(items[i]));
			}
	        return a;
	    }
	  }
}



function setoffreconsultee(ref,infobien){

	var list = new cookieList("offreconsultee");
	list.add(infobien);
	
}

function getoffreconsultee(id){

	var list = new cookieList("offreconsultee");
	var a = list.items();
	var divDatas = "";

	if(a.length > 0)
		{
		for (var i = 0, j = a.length; i < j; i++) 
			divDatas += "<div class='biensvisites'><a href='"+a[i]["url"]+"'><img src='"+a[i]["photo"]+"' alt='' width='159' height='106' /><span class='txt_bold'>"+a[i]["ville"]+"<br/>"+a[i]["prix"]+" €</span></a></div>";
		
		$("#consultes").show();
		var ancienHtmlContenu = $("#consultes").html();
		$("#consultes").html(ancienHtmlContenu+divDatas);
		}

}
