(function($) {
$.fn.add_search = function(id_sito, id_annuncio, detail_search, description) {
if (jQuery.cookie_is_enabled()) {
var saved = $.cookie('cerco-casa_saved_search');
var array = new Array();
if (saved == null) {
array[0] = new Object();
array[0].id_sito = id_sito;
array[0].id_annuncio = id_annuncio;
array[0].detail_search = detail_search;
array[0].description = description;}
else {
var i = 0;
var savedObject = $.evalJSON(saved);
if (savedObject[0].id_sito == null) {
$.cookie('cerco-casa_saved_search', '', { expires:-7 });
array[0] = new Object();
array[0].id_sito = id_sito;
array[0].id_annuncio = id_annuncio;
array[0].detail_search = detail_search;
array[0].description = description;}
else {
$(savedObject).each(function() {
array[i] = new Object();
array[i].id_sito = this.id_sito;
array[i].id_annuncio = this.id_annuncio;
array[i].detail_search = this.detail_search;
array[i].description = this.description;
i++;});
array[i] = new Object();
array[i].id_sito = id_sito;
array[i].id_annuncio = id_annuncio;
array[i].detail_search = detail_search;
array[i].description = description;}}
$.cookie('cerco-casa_saved_search', $.toJSON(array));
jQuery("#"+$(this).attr("id")).get_search();}
else {
alert("Non puoi salvare la ricerca perch? hai i cookies disabilitati");}}})(jQuery);(function ($){
$.cookie_is_enabled = function() {
return navigator.cookieEnabled}})(jQuery);(function($) {
$.fn.get_search = function() {
this.each(function() {
var obj = $(this);
if (jQuery.cookie_is_enabled()) {
var result = "";
var saved = $.cookie('cerco-casa_saved_search');
if (saved == null || saved == "[]") {
result = "<div style='font-family: Arial; font-size: 12px; color: #000000; text-decoration: underline; margin-left:35px; text-align:center;'>Non ci sono ricerche salvate</div>";}
else {
var i = 0;
var savedObject = $.evalJSON(saved);
if (savedObject[0].id_sito == null) {
result = "<div style='font-family: Arial; font-size: 12px; color: #000000; text-decoration: underline; margin-left:35px; text-align:center;'>Non ci sono ricerche salvate</div>";}
else {
$(savedObject).each(function() {
result+= "<img src='/Themes/CercoImmobili/Images/x-off.gif' alt='Cancella' onclick='jQuery(\"#"+obj.attr("id")+"\").remove_search("+i+")' />";
result+= "&nbsp;<a href='javascript:goToDetail(\""+this.id_sito+"\", \""+this.id_annuncio+"\", \""+this.detail_search+"\")'>";
result+= this.description;
result+= "</a>&nbsp;";
result+= "<br />";
i++;});}}}
else {
result = "<div style='font-family: Arial; font-size: 12px; color: #000000; text-decoration: underline; text-align:center;'>Non puoi visualizzare le ricerche memorizzate perch? hai i cookies disattivati</div>";}
obj.html(result);
$('#'+obj.attr('id')).show("slow");});}})(jQuery);(function($) {
$.fn.remove_search = function(index_of_remove)  {
var i = 0;
var j = 0;
var saved = $.cookie('cerco-casa_saved_search');
var array = new Array();
$($.evalJSON(saved)).each(function() {
if(j != index_of_remove){
array[i] = new Object();
array[i].detail_search = this.detail_search;
array[i].description = this.description;
i++;}
j++;});
$.cookie('cerco-casa_saved_search', $.toJSON(array));
jQuery("#"+$(this).attr("id")).get_search();}})(jQuery);(function ($){
$.fn.remove_all_search = function() {
$.cookie('cerco-casa_saved_search', '', { expires:-7});
jQuery("#"+$(this).attr("id")).get_search();}})(jQuery);
