$(function () {

  // Index - Images Hover
  $('#latest_pictures li').hover(
    function (){
      $page_name =  $(this).children('a').children('img').attr("alt");
      $(this).children('.image_cover').html($page_name);    
      $(this).children('.image_cover').show();
    }, 
    function(){
      $(this).children('.image_cover').hide();    
    });

  // Latest Pictures Lightbox
  $('#latest_pictures li a').lightBox({fixedNavigation:true});

  // Latest Pictures Lightbox
  $('#latest_pictures .image_cover').click(function() {
    $(this).siblings('a').click();
  });

  // Latest Videos
  $('#latest_videos li .image_cover').click(
      function () {
        insert_overlay('body');
        scroll_top (0, 500);
        $(this).siblings('div').clone().appendTo('#ajax_cover');
  });


  $('#popup_cover').live('click', function () {
    $('#ajax_cover div').remove();
    $('#popup_cover').remove();
  });


  // Top Slider
  $('#slider_box').anythingSlider({
    width         : 980,
    height        : 305,
		delay         : 6000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		animationTime  : 600      // How long the slideshow transition takes (in milliseconds)

  });

  
  // Images Artists Lightbox
  $('#images li a').lightBox({fixedNavigation:true});

  // Video Artists
  $('#videos li .image_cover').click(
      function () {
        insert_overlay('body');
        scroll_top (0, 500);
        $(this).siblings('div').clone().appendTo('#ajax_cover');
  });


  $(".tweets li:nth-child(2)").attr("id","second");
  $(".tweets li:nth-child(3)").attr("id","third");




  function insert_overlay (body){
  	
  	// Inserts the overlay into the page
  	// Function requires the body element so the actual height could be calculated
  	
  	var window_height = $(body).height();
  	$('<div id="popup_cover"></div>').insertBefore($('#page'));
  
  	$('#popup_cover').css({
  		'height': window_height + 1000
  	});
  }

  function scroll_top (top, time){
  	$('html, body').animate({
  		scrollTop: top
  	}, time);	
  }


});


