$(document).ready(function(){

  $("#menu").hover(
    function () {
      //$("#menu_bg").animate({ opacity: "0.8"}, 500);
	  $("#menu_bg").css({ opacity: "0.8"});
	  $(".menu_hover").css({ backgroundPosition: "0px 19px"});
	  $("#user_string").show();
    },
    function () {
      //$("#menu_bg").animate({ opacity: "0"}, 500);
	  $("#menu_bg").css({ opacity: "0"});
	  $(".menu_hover").css({ backgroundPosition: "0px 38px"});
	  $("#user_string").hide();
    }
  );
  
  $(".menu_hover_container").bind('mouseenter', function () {
	$(this).children().css({ backgroundPosition: "0px 0px"});
	//$(this).children().next().next().fadeIn(500);
	//$(this).children().next().fadeIn(500);
	$(this).children().next().next().next().show();
	$("#user_string").show();
	$(this).children().next().show();
  });
  
  $(".menu_hover_container").bind('mouseleave', function () {
	//$(this).children().next().fadeOut(500);
	//$(this).children().next().next().fadeOut(500);
	$(this).children().next().hide();
	$("#user_string").show();
	$(this).children().next().next().next().hide();
	$(this).children().css({ backgroundPosition: "0px 19px"});
  });
  
  $(".menu_hover_simple").hover(
    function () {
	  $(this).css({ backgroundPosition: "0px 0px"});
    },
    function () {
	  $(this).css({ backgroundPosition: "0px 19px"});
    }
  );

  $("#diario_beta").click(
    function () {
	  if ($(this).children().attr('src') == 'img/diario_beta_1.jpg') {
	    $(this).children().attr('src','img/diario_beta_2.jpg');
	  }
      else {
	    $(this).children().attr('src','img/diario_beta_1.jpg');
	  }
    }
  );

  $("#blog_beta").click(
    function () {
	  if ($(this).children().attr('src') == 'img/blog_beta_1.jpg') {
	    $(this).children().attr('src','img/blog_beta_2.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/blog_beta_2.jpg') {
	    $(this).children().attr('src','img/blog_beta_3.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/blog_beta_3.jpg') {
	    $(this).children().attr('src','img/blog_beta_4.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/blog_beta_4.jpg') {
	    $(this).children().attr('src','img/blog_beta_5.jpg');
	  }
	  else {
	    $(this).children().attr('src','img/blog_beta_1.jpg');
	  }
    }
  );

  $("#personaggi_beta").click(
    function () {
	  if ($(this).children().attr('src') == 'img/personaggi_beta_1.jpg') {
	    $(this).children().attr('src','img/personaggi_beta_2.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/personaggi_beta_2.jpg') {
	    $(this).children().attr('src','img/personaggi_beta_3.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/personaggi_beta_3.jpg') {
	    $(this).children().attr('src','img/personaggi_beta_4.jpg');
	  }
	  else {
	    $(this).children().attr('src','img/personaggi_beta_1.jpg');
	  }
    }
  );

  $("#luoghi_beta").click(
    function () {
	  if ($(this).children().attr('src') == 'img/luoghi_beta_1.jpg') {
	    $(this).children().attr('src','img/luoghi_beta_2.jpg');
	  }
	  else if ($(this).children().attr('src') == 'img/luoghi_beta_2.jpg') {
	    $(this).children().attr('src','img/luoghi_beta_3.jpg');
	  }
	  else {
	    $(this).children().attr('src','img/luoghi_beta_1.jpg');
	  }
    }
  );
        
  $('#map').flash({
    swf: 'flash/map.swf',
	width: '100%',
	height: 610,
	wmode: 'transparent',
    expressInstallIsActive: true,
    expressInstaller: 'javascripts/expressInstall.swf',
    hasVersion: 10,
    hasVersionFail: function (options) {
      $('#map').css('top','150px');
	  return true;
    }
  });
  
  $('#characters').flash({
    swf: 'flash/personaggi.swf',
	width: '100%',
	height: 610,
	wmode: 'transparent',
    expressInstallIsActive: true,
    expressInstaller: 'javascripts/expressInstall.swf',
    hasVersion: 10,
    hasVersionFail: function (options) {
      $('#characters').css('top','150px');
	  return true;
    }
  });
  
  $('#enigma_oct11').flash({
    swf: 'flash/enigma_oct11.swf',
	width: '100%',
	height: 610,
	wmode: 'transparent',
    expressInstallIsActive: true,
    expressInstaller: 'javascripts/expressInstall.swf',
    hasVersion: 10,
    hasVersionFail: function (options) {
      $('#enigma_oct11').css('top','150px');
	  return true;
    }
  });
  
  $('#games').flash({
    swf: 'flash/games.swf',
	width: '100%',
	height: 610,
	wmode: 'transparent',
    expressInstallIsActive: true,
    expressInstaller: 'javascripts/expressInstall.swf',
    hasVersion: 10,
    hasVersionFail: function (options) {
      $('#games').css('top','150px');
	  return true;
    }
  });

});

