$(document).ready(function($) {


  // Style switcher
  $(function(){
    $.stylesheetInit();
		
	$('.styleswitch').bind(
		'click',
		function(e)
		{
			$.stylesheetSwitch(this.getAttribute('rel'));
			return false;
		}
	);
  });	
	
  $("#accordion li").hover(function(){
  	$(this).siblings().animate({width: "50px"}, {duration:300, queue:false});
    $(this).animate({width: "455px"}, {duration:300, queue:false});
    $(this).addClass('active').siblings().removeClass('active');
  });
  
  $("#accordion li").each(function(index){
    $(this).hover(
	  function() { 
	  	$('#news li:eq(' + index + ')').show().siblings().hide(); }
	);
  });
  	
  $('#featured .info a').click(function(e) {
    e.preventDefault();
    $('#featured .info div').slideDown('slow', function() {
		$('#featured .info div a.close').fadeIn('slow');	
	});
  });
  
  $('#featured .info a.close').click(function() {
    $('#featured .info div').fadeOut('fast');
  });
  
  $('#featured .col_2 div').each(function(index) {
    $(this).click(function() {
      $('#featured .col_1 > div:eq(' + index + ')').fadeIn('slow').siblings().hide();
    });
  });
  
  $('#featured .col_2 div').click(function() {
    $('#featured .col_2 div').removeClass();
	$(this).addClass('active');
  });
  
  $('.archive #blog .post,.search #blog .post').each(function(index) {
    $(this).hover(
	function() { $('.content:eq(' + index + ')').slideDown('slow');
			   $(this).siblings().fadeTo(500,0.25); },
	function() { $('.content:eq(' + index + ')').slideUp('fast');
			   $(this).siblings().fadeTo(100,1); }
    );
  });
  
  $('.blog .post .contentbox').each(function(index) {
    $(this).hover(
	  function() { $('a.more-link:eq(' + index + ')').slideDown('fast'); },
	  function() { $('a.more-link:eq(' + index + ')').slideUp('slow'); }
	);
  });
  
  $('h3.comments a').click(function(e) {
    e.preventDefault();	  
    $('#comments,h3.comments a').toggle();
  });

  $('a.torna').click(function(e) {
    e.preventDefault();
    $.scrollTo('0', 1000);
  });
  
  $('a.hide_show').click(function(e) {
    $('#featured div.col_1,#featured div.col_2').slideToggle('slow');
  });
  
  $('.ngg-galleryoverview').wrap('<div class="foto" />');
  
  $('.slideshow').cycle({
    fx: 'fade',
	timeout: 3000,
	pause: true
  });
  
});
