var _current = 0;
var _featuredprop = 0;
var _featuredprop_count = 0;
var _prop = 1;

$(document).ready(function($){
  FeaturedProp_Init();
  SlideshowNext();
  
  $("#m_map area").hover(
  function(){
    $("#map img").attr("src", "images/maps/mp_w_" + $(this).attr("class") + ".jpg");
  },
  function(){
    $("#map img").attr("src", "images/maps/mp_w_world.jpg");
  });
});

function SlideshowNext()
{
  $("#home_panel ul li:eq(" + parseInt(_current - 1) + ")").removeClass("selected");
  if (_current > 3)
  {
    _current = 0;
    FeaturedProp_Next();
  };
  $("#home_panel ul li:eq(" + _current + ")").addClass("selected");
  _current += 1;
  setTimeout("SlideshowNext()", 3000);
}

function FeaturedProp_Init()
{
  _featuredprop_count = featured_properties.length;
  FeaturedProp_Next();
  FeaturedProp_Next();
};

function FeaturedProp_Next()
{
  var prop = $("#prop_" + _prop);
  prop.find("a").attr("href", featured_properties[_featuredprop]['link']);
  prop.find("img").attr("src", featured_properties[_featuredprop]['image']);
  prop.find("a.caption").html(featured_properties[_featuredprop]['country'] + " <span>" + featured_properties[_featuredprop]['city'] + "</span>");
  
  _prop += 1;
  if(_prop > 2){_prop = 1};
  
  _featuredprop += 1;
  if(_featuredprop > _featuredprop_count - 1){_featuredprop = 0};
};