var WSpace = {};

WSpace.init = function(){
  if ($(".wes-main-story-image img").length){
	  WSpace.homepage_length = $(".wes-main-story-image img").length;
	  WSpace.timer_index = 0;
	  WSpace.timer();
  }
};

WSpace.timer = function(){
  if (WSpace.timer_index > WSpace.homepage_length - 1){
    WSpace.timer_index=0;
  }
  WSpace.homepage_timer = setTimeout("WSpace.timer()",5000);

  WSpace.turn();

  WSpace.timer_index++;
};

WSpace.turn = function(){
	$(".wes-main-story-image img").hide();
	$(".wes-main-story-image div").removeClass("hidden");
	$($(".wes-main-story-image img")[WSpace.timer_index]).show();

};

$(document).ready(function(){
  /* Manage the search form */
  $("#bottom #search #button img").mouseover(function(){
    $("#bottom #search #input").show("slow");
  }).click(function(){
    $("#bottom #searchform").submit();
  });

  $("#bottom #search #input input").focus(function(){
    this.value="";
  });

  /* Manage the links */
  $("#links #plus").click(function(){
	  $("#links #container").animate({width:"toggle"}, 600);
  });

  /* Gallery page */
  if ($('.class-gallery').length>0){
    $(".content-view-galleryline").mouseover(function(){
      $(this).css("font-weight","bold");
    }).mouseout(function(){
      $(this).css("font-weight","normal");
    });
  }


  /* Init */
  WSpace.init();

});

