$(document).ready(function() {
    $('a.email').nospam({ replaceText: true });
    $('a.email_replace').nospam({ replaceText: false });
    my_tabs();
    $('#loading_top').hide();
  
});

function showResponse(responseText, statusText)  {
    
}    



$(function(){
   $("#neighborhood_link").click(function(){
    $("#neighborhood_wrapper").toggle('blind',{ direction: "vertical" }, 300, function(){
        
         $("#neighborhood_link").toggleClass("active");

    });


   }); 
});

$(function(){
    $('ul.htabs li a').click(function(){
        $(this).addClass('active');
        $('ul.htabs li a').not(this).removeClass('active');
    });
});

$(function(){
    $('.emailme').click(function(){
        $('#email').toggle('blind',{ direction: "vertical" }, 300, function(){});
          $(this).toggleClass("open");
            //  return false;
    });

        
});

$(function(){
    $('.contact').click(function(){
        $('#contact').toggle('blind',{ direction: "vertical" }, 300, function(){});
          $(this).toggleClass("open");
    return false;
    });
    
        
});

$(function(){
    $('#email_favorites').live("click", function(){
      $('.email_favorites_wrapper').toggle('blind',{ direction: "vertical" }, 300, function(){
          $("#email_favorites").toggleClass("active");

      })
      return false;
    });   
});



function save(id,el) {
        
        var property_listing = $(el).parents('.property-listing').get(0);
        var loader = $($(property_listing).children('.save_loader').get(0));
        $(loader).show();
    
        $(el).toggleClass('active');
        if ($(el).is('.active')) {
          var action = 'add';    
        } else {
          var action = 'delete'  
        }
            
       if ($('#favorites').length) {
        $('#favorites').load(
          "/property/"+action+"/"+id,null, function() { $(loader).hide(); }
        );        
        } else {
        $.ajax({
          type: "GET",
          url: "/property/"+action+"/"+id,
          success: function() {
            $(loader).hide();
          }  
        });
        }
};




function my_tabs(){
 //if this is not the first tab, hide it
 $(".tab:not(:first)").hide();

 //to fix u know who
 $(".tab:first").show();

 //when we click one of the tabs
 $(".htabs a").click(function(){
    
 //get the ID of the element we need to show
 stringref = $(this).attr("href").split('#')[1];
 //hide the tabs that doesn't match the ID
 $('.tab:not(#'+stringref+')').hide();
 //fix
 if ($.browser.msie && $.browser.version.substr(0,3) == "6.0") {
 $('.tab#' + stringref).show();
 }
 else
 //display our tab fading it in
 $('.tab#' + stringref).fadeIn();
 //stay with me
 return false;
 });

};
