var shortlist_friends = 1;
var shortlist_highlight_colour = "#E7F0F7";
$(document).ready(function(){

  $('.shortlist_toggle').click(function(){


     var shortlist_url = $(this).attr('href');
     var container_element = $(this).parents("li");
     var clicked_link = $(this);

     $.getJSON(shortlist_url, function(data){

          if (data.added == "true")
          {
            $(container_element).addClass("shortlisted_property");
            $(container_element).css({'background-color':shortlist_highlight_colour});
            clicked_link.text('remove from shortlist');
          }
          else
          {
            $(container_element).removeClass("shortlisted_property");
            $(container_element).css({'background-color':'white'});
            clicked_link.text('add to shortlist');
          }

          $("#ShortlistNav").text('Your shortlist (' + data.shortlist_size + ')');

          //alert($(container_element).css('background-color'));
          $(container_element).glow();
     });



     return false;
  });

});

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(ele){
  which = typeof(ele) != "undefined" ? ele : "#EmailForm";
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup").css({
      "opacity": "0.7"
    });

    $("#backgroundPopup").fadeIn("slow");
    $(which).fadeIn("slow");
    popupStatus = 1;
  }
}

//disabling popup with jQuery magic!
function disablePopup(ele){
  which = typeof(ele) != "undefined" ? ele : "#EmailForm";
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup").fadeOut("slow");
    $(which).fadeOut("slow");
    popupStatus = 0;
  }
}

//centering popup
function centerPopup(ele){
  which = typeof(ele) != "undefined" ? ele : "#EmailForm";
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $(which).height();
  var popupWidth = $(which).width();
  //centering
  $(which).css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6

  $("#backgroundPopup").css({
    "height": windowHeight
  });
}
