$(document).ready(function(){
  $(".work_item_nav a").click(function(){
    var largePath = $(this).attr("href");
    var largeAlt = $(this).attr("title");
    
    $('.work_item_nav span').remove()
    $(this).append("<span></span>")
    $(".work_item_nav a").removeClass("active")
    $(this).addClass("active")
    
    $('.work_item_nav span').show()
    $('.large_image  a').attr({href: largePath}).load(function() {});
    $('.large_image .preview').attr({src: largePath}).load(function() {  
      $('.work_item_nav span').hide();
    });
    return false;
  });

  $(".tweet").tweet({
      username: "ignaty",
      join_text: "auto",
      avatar_size: 32,
      count: 1,
      auto_join_text_default: "",
      auto_join_text_ed: "",
      auto_join_text_ing: "",
      auto_join_text_reply: "",
      auto_join_text_url: "",
      loading_text: "loading tweets..."
  });
  
  
  $('.sender input').focus(function () {    
         $('.sender label').fadeOut(1000);
         $('.message label').fadeIn(1000);
         $('.web label').fadeIn(1000);
         $('.subject label').fadeIn(1000);
         $('.email label').fadeIn(1000);
    });
    
    $('.web input').focus(function () {
           $('.web label').fadeOut(1000);
           $('.sender label').fadeIn(1000);
           $('.message label').fadeIn(1000);
           $('.subject label').fadeIn(1000);
           $('.email label').fadeIn(1000);
      });
      
      $('.message textarea').focus(function () {
             $('.message label').fadeOut(1000);
             $('.sender label').fadeIn(1000);
             $('.web label').fadeIn(1000);
             $('.subject label').fadeIn(1000);
             $('.email label').fadeIn(1000);
        });
        
        $('.subject input').focus(function () {
        $('.subject label').fadeOut(1000);
               $('.message label').fadeIn(1000);
               $('.sender label').fadeIn(1000);
               $('.web label').fadeIn(1000);
                         $('.email label').fadeIn(1000);
          });
          
          $('.email input').focus(function () {
          $('.email label').fadeOut(1000);
          $('.subject label').fadeIn(1000);
                 $('.message label').fadeIn(1000);
                 $('.sender label').fadeIn(1000);
                 $('.web label').fadeIn(1000);
            });
       
  
  
      $(".fancy").fancybox({
        'titleShow': false,
        'padding': 4,
        'hideOnContentClick': true,
        'autoScale': false
      });
  
  
  var bouncespeed = 800;
  
  $('#recent_works li').each(
    function () {
      $(this).css({top: '0px', left: '0px'});
     bounce(this);
   }
 );
  
  function bounce(circles) {
    newx = Math.floor(10*Math.random());
    newy = Math.floor(10*Math.random());
    newspeed = bouncespeed + Math.floor(0*Math.random());
   $(circles).animate({top: newx + 'px ', left: newy + 'px'}, newspeed, 'linear', function() { bounce(circles);});
  }

  
});