function setFrontpageLogin(focusOrBlur)
{
  item = $("#clientLogin #eventId");
  
  if (focusOrBlur == "focus") {
    item.css("color", "#333");
    if (item.val() == "EVENT ID") {
      item.val("");
    }
  }
  else {
    if(item.val() == "") {
      item.val("EVENT ID");
      item.css("color","#AAA");
    }
  }
}

$(function(){
  // This is the onready function
  
  var globalTimer = 6000;
  var backgroundMove = 0;
  
  $scroller = $("#negatives ul");
  $scroller.css("left", 0);
  moveSlides();
  
  $scroller.hover(function(){
    $scroller.stop();
  }, function() {
    moveSlides();
  });
  
  $("#negatives ul li img").hover(
    function(){
      changeSplash($(this).attr("src"));
    },
    function(){
      
    }
  )
  
  $scroller.find("li img").css("opacity", 0.6);
  
  $scroller.find("li img").hover(
    function()
    {
      $(this).css("opacity", 0.9);
    },
    function()
    {
      $(this).css("opacity", 0.6);
    }
  );

  $('#portfolio a').lightBox();

  setFrontpageLogin("init");

  $("#clientLogin #eventId").blur(function(){
    setFrontpageLogin("blur");
    $(this).css("background-color","#FFF");
  })

  $("#clientLogin #eventId").focus(function(){
    setFrontpageLogin("focus");
    $(this).css("background-color","#F4F4F4");
  })
  
  $("#portfolio ul li a img").each(function() {
    var newMarginTop = parseInt(($(this).parent().height() - $(this).height() - 2) / 2);
    $(this).css("margin-top", newMarginTop);
  });


  $(".pricing_table table tr").each( function() {
    $(this).children("td:first").css("text-align","left");
  });
  
  $('.pricing_table > ul').tabs();








  function moveSlides(){
    firstItem = $scroller.find("li:first");
    moveSize = firstItem.width() + parseFloat($scroller.css("left"));
    if(moveSize != firstItem.width())
      timer = globalTimer * (moveSize/firstItem.width());
    else
      timer = globalTimer
      
    //  alert(leftAlready);
    $scroller.animate({left: "-="+(moveSize)},timer, "linear", function(){
      $scroller.append(firstItem);
      $scroller.css("left",0);
      backgroundMove += 5;
      $scroller.css("background-position", (backgroundMove) + "px 0");
      moveSlides();
    })
  }
  
});

function changeSplash(currentSrc)
{
  newSrc = currentSrc.replace(".jpg",".gif");
  newSrc = newSrc.replace("/negatives/","/splash_images/");
  
  
  $("#splashImage").attr("src",newSrc);
}

