var currentLocation = window.location.pathname;

var twinkle = function(){

  $("#image_"+randomNumber).animate({
    opacity: 1
  }, 1000, function() {
    $("#image_"+randomNumber).animate({
      opacity: 0.2
    }, 1000);
  });
}

var clearFlashMessages = function(){
  if($("#flash").is(":visible")){
    setTimeout('$("#flash").slideUp(200)', 5000);
  }
};

$(function(){
  
  if(currentLocation === "/"){
    setInterval(twinkle, 500);
  }
  
  clearFlashMessages()
  
  $("#contact form").validate();
  
  $(".popup_box").mouseleave(function(){
    $(this).hide();
  });
  
  $("#home a").hover(function(event){
    event.preventDefault();
    var linkId = $(this).attr("id");
    var logo = "10";
    var photography = "15";
    var advertising = "20";
    var about = "26";
    var ourWork = "30";
    var services = "36";
    switch(linkId){
    case logo:
      $(".popup_box:visible").hide();
      $("#logo").show();
      break;
    case photography:
      $(".popup_box:visible").hide();
      $("#photography").show();
      break;
    case advertising:
      $(".popup_box:visible").hide();
      $("#advertising").show();
      break;
    case about:
      $(".popup_box:visible").hide();
      $("#about").show();
      break;
    case ourWork:
      $(".popup_box:visible").hide();
      $("#ourWork").show();
      break;
    case services:
      $(".popup_box:visible").hide();
      $("#services").show();
      break;
    default:
      return false;
    }
  });
  
});
