﻿$(document).ready(function() {
  var sPath = window.location.pathname;
  var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  if (sPage != "housing_search.aspx"){
    $('#housing_search').hide();
  };
  $('#housing_search_link').click(function(){
          $('#housing_search').slideToggle();
          $('#subnav a').removeClass('selected');
          $('#housing_search_link').toggleClass('selected');
  });
  $('#property_further_details a[title=View Site Plan]').click(
    function(){
      $.scrollTo(0, 500);
      $("#siteplan_popup img:first").attr('src', $(this).attr('href'));
      $("#siteplan_popup").show();
      $("#pop_overlay").show();
      return false;
    }
  );
  $("#siteplan_popup img:last").click(
    function(){
      $("#siteplan_popup").hide();
      $("#pop_overlay").hide();
    }
  );
  $("#thumbs img").css("cursor", "pointer");
  $("#thumbs img").click(
    function(){  
      $("#big_img").attr("src", $(this).attr("class"));
      $("#big_img").attr("class", $(this).attr("src"));
    });
  $("#big_img").click(
    function(){
     // var img = $(this).attr("class").replace("_th", "_z");
     // $("#siteplan_popup img:first").attr('src', img);
     // $("#siteplan_popup").show();
     // $("#pop_overlay").show();
    }
  );
  if (typeof housing_images != "undefined"){
    var arLen=housing_images.length;
    if (arLen > 0)
    {
        for ( var i=0, len=arLen-1; i<len; ++i ){
            var image = "<image src=\"" + housing_images[i] + "\" alt=\"\" width=\"" + width + "\" height=\"" + height + "\" >"
            $("#housing_images").html($("#housing_images").html() + image);
        };
    };
    $("#housing_images").cycle();
  };
});
