var corrente;
function in_ajax_request(item)
{
		corrente = item;
		$('#testo').hide();
		$('.normal').hide();
		$('.blur').show();
		$('#box_images_blur').html('');
		$('#box_images_normal').html('');
		
	if($(corrente).parent().prev().find('img').length == 0){
		$('.prev').hide();
          $('#bottonenav').hide();
          $('#bottonenav2').show();
      } else if($(corrente).parent().next().find('img').length == 0){
          $('#bottonenav').show();
		  $('.next').hide();
          $('#bottonenav2').hide();
      } else {
          $('#bottonenav').show();
          $('#bottonenav2').show();
      }



		
		

      /* $('#box_images_blur').fadeIn("slow",function ()
       {
               var img = new Image();
               $(img).load(function ()        {
                       $(this).hide();
                       $('#box_images_blur').append(this);
                       $(this).fadeIn();
               });
               
               $(img).error(function () {
               
               });
               
               $(img).attr('src', '../images/gallery/'+$(item).attr("rel")+'b.jpg');
               $(img).click(function () {
                       out_ajax_request();
               });
       });

       $('#box_images_normal').fadeIn("slow",function ()
       {
               var img = new Image();
               $(img).load(function ()        {
                       $(this).hide();
                       $('#box_images_normal').append(this);
                       $(this).fadeIn();
               });
               
               $(img).error(function () {
               
               });
               
               $(img).attr('src', '../images/gallery/'+$(item).attr("rel")+'.jpg');
               $(img).click(function () {
                       out_ajax_request();
               });
       });*/
	   
	   $('#box_images_blur').fadeOut("slow",function ()
       {
               var img = new Image();
               $(img).load(function ()        {
                       $(this).hide();
                       $('#box_images_blur').append(this);
                       $(this).fadeIn();
               });
               
               $(img).error(function () {
               
               });
               
               $(img).attr('src', '../images/gallery/'+$(item).attr("rel")+'b.jpg');
               $(img).click(function () {
                       out_ajax_request();
               });
       });

       $('#box_images_normal').fadeOut("slow",function ()
       {
               var img = new Image();
               $(img).load(function ()        {
                       $(this).hide();
                       $('#box_images_normal').append(this);
                       $(this).fadeIn();
               });
               
               $(img).error(function () {
               
               });
               
               $(img).attr('src', '../images/gallery/'+$(item).attr("rel")+'.jpg');
               $(img).click(function () {
                       out_ajax_request();
               });
       });
	   
	   $('#box_images_blur').fadeIn(3000);
	   $('#box_images_normal').fadeIn(3000);
	   
}



	
function out_ajax_request() {
	$('.blur').hide();
	$('.normal').show();
	$('#bottonenav').hide();
	$('#bottonenav2').hide();
	

	$('#testo').fadeIn("medium");
	$('#box_images_blur').fadeOut("medium");
	$('#box_images_normal').fadeOut("medium");
	$('#box_images_blur').html('');
	$('#box_images_normal').html('');
	
}

function out_ajax_request_privacy() {
	$('.blur').hide();
	$('.normal').show();
	$('#bottonenav').hide();
	$('#bottonenav2').hide();
	

	$('#testoprivacy').fadeIn("medium");
	$('#box_images_blur').fadeOut("medium");
	$('#box_images_normal').fadeOut("medium");
	$('#box_images_blur').html('');
	$('#box_images_normal').html('');
	
}





//$('#box_images_blur').append("<img onclick='out_ajax_request()' id='' src='../images/gallery/"+$(item).attr('rel')+"b.jpg'/>");
	//$('#box_images_blur').fadeIn("slow");
	//$('#box_images_normal').append("<img onclick='out_ajax_request()' id='' src='../images/gallery/"+$(item).attr('rel')+".jpg'/>");
	//$('#box_images_normal').fadeIn("slow");
//}

//$('.normal').each(function () {
  		//$('ul.menu_body').attr('class', 'menu_body_foto');
  		//$('a.menu_head').attr('class', 'menu_head_foto');
  	//	});
function next_page(){
	in_ajax_request($(corrente).parent().next().find('img'));
}

function prev_page(){
	in_ajax_request($(corrente).parent().prev().find('img'));
}


$(document).ready(function () { 
$('#bottonenav').mouseenter(function(){
		   $('.prev').fadeIn("slow");
});
$('#bottonenav').mouseleave(function(){
		  $('.prev').fadeOut("slow");
});
$('#bottonenav2').mouseenter(function(){
		   $('.next').fadeIn("slow");
});
$('#bottonenav2').mouseleave(function(){
		   $('.next').fadeOut("slow");
});
});

$(document).ready(function () {
	
$('#close').click(function(){
		   $('#testoprivacy').fadeOut("slow");
		   $('#testo').fadeIn("slow");
		   $('#testohome').fadeIn("slow");
});

$('#privacy').click(function(){
		   $('#testoprivacy').fadeIn("slow");
		   $('#testo').fadeOut("slow");
		   $('#testohome').fadeOut("slow");
		   $('#map_canvas').fadeOut("slow");
		   $('#closemap').fadeOut("slow");
});

$('#likefacebookpage').bind("mouseenter", function () {
	$('#boxfacebookpage').fadeIn("slow");
});

$('#likefacebookpageblur').bind("mouseenter", function () {
	$('#boxfacebookpage').fadeIn("slow");
});

$('#boxfacebookpage').bind("mouseleave", function () {
	$(this).fadeOut("slow");
});

});



