$(document).ready(function(){
	
	$("#page_0").fadeIn("normal");
	
	
	$(".btn_prosegui").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	$(".btn_conferma").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
		
		
		
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	
	
	$(".btn_conferma").click(function () {
									   
		check_test_drive();
	
    });


	$("#btn_close").click(function () {
									   
		$("#show_test_drive").fadeOut("normal");
		$("#btn_close").fadeOut("normal");
	
    });

	$("#btn_close2").click(function () {
									   
		$("#show_invita").fadeOut("normal");
		$("#btn_close2").fadeOut("normal");
	
    });
	
	
	$(".btn_prosegui").click(function () {
									   
		check_date();				
		quale_page = "#page_1";
	
    });
	
	


	$(".btn_send_to_friend").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	$(".btn_send_to_friend").click(function () {
									   
		check_send();				
	
    });
	
	
	/*        gestione btn eventi (page 4)            */
	
	

	$("#city_roma").click(function () {
									   
		$("#event_city").load("pages/city_roma.php");
		$("#event_img").load("pages/events.php?l=roma_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);

	
    });


	$("#city_roma").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	$("#city_torino").click(function () {
									   
		$("#event_city").load("pages/city_torino.php");
		$("#event_img").load("pages/events.php?l=torino_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);
	
    });


	$("#city_torino").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	$("#city_milano").click(function () {
									   
		$("#event_city").load("pages/city_milano.php");
		$("#event_img").load("pages/events.php?l=milano_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);
	
    });


	$("#city_milano").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	$("#city_trieste").click(function () {
									   
		$("#event_city").load("pages/city_trieste.php");
		$("#event_img").load("pages/events.php?l=trieste_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);
    });


	$("#city_trieste").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	$("#city_rimini").click(function () {
									   
		$("#event_city").load("pages/city_rimini.php");
		$("#event_img").load("pages/events.php?l=rimini_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);
	
    });


	$("#city_rimini").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	$("#city_bari").click(function () {
									   
		$("#event_city").load("pages/city_bari.php");
		$("#event_img").load("pages/events.php?l=bari_d_1_l_1");
		var Str = "";
		$("#indirizzo_txt").html(Str);

	
    });


	$("#city_bari").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	
	
	
	
	
	/*        gestione voci di menu            */
	
	$("#blocchi .btn1").addClass('selected');
	$("#blocchi .btn1").css({backgroundPosition: '0 -21px'});
	
	
	$('#blocchi > li').click(function(){
									  
	form_test_drive =  loginForm = document.getElementById('test_drive');
									  
	$(".radio_input1_r").fadeOut("normal");
	$(".radio_input2_r").fadeOut("normal");
	$(".radio_input3_r").fadeOut("normal");
	$(".radio_input4_r").fadeOut("normal");
	$(".radio_input5_r").fadeOut("normal");
	$(".radio_input6_r").fadeOut("normal");
	$(".radio_input7_r").fadeOut("normal");
	$(".radio_input8_r").fadeOut("normal");
	$(".radio_input9_r").fadeOut("normal");
	$(".radio_input10_r").fadeOut("normal");
	
	form_test_drive._1[0].checked == false
	form_test_drive._1[1].checked == false
	form_test_drive._1[2].checked == false
	
	form_test_drive._2[0].checked == false
	form_test_drive._2[1].checked == false
	form_test_drive._2[2].checked == false
	
	form_test_drive._3[0].checked == false
	form_test_drive._3[1].checked == false
	form_test_drive._3[2].checked == false
	
	form_test_drive._4[0].checked == false
	form_test_drive._4[1].checked == false
	form_test_drive._4[2].checked == false
	
	form_test_drive._5[0].checked == false
	form_test_drive._5[1].checked == false
	form_test_drive._5[2].checked == false
	
	form_test_drive._6[0].checked == false
	form_test_drive._6[1].checked == false
	form_test_drive._6[2].checked == false
	
	form_test_drive._7[0].checked == false
	form_test_drive._7[1].checked == false
	form_test_drive._7[2].checked == false
	
	form_test_drive._8[0].checked == false
	form_test_drive._8[1].checked == false
	form_test_drive._8[2].checked == false
	
	form_test_drive._9[0].checked == false
	form_test_drive._9[1].checked == false
	form_test_drive._9[2].checked == false
	
	form_test_drive._10[0].checked == false
	form_test_drive._10[1].checked == false
	form_test_drive._10[2].checked == false
    	
		
		//controllo al click se il tasto ha applicata la classe "selected"
		if (!$(this).hasClass('selected')) {    
			   
			
			//tolgo la classe "selected" ha tutti i LI   
			$('#blocchi > li').removeClass('selected');
			$('#blocchi > li').css({backgroundPosition: '0 0'});
			
			
			//Riassegno al tasto cliccato la classe "selected"
			$(this).addClass('selected');
			$(this).css({backgroundPosition: '0 -21px'});
			
			
			//Faccio il fadeout di "div_content" e in callback faccio il load e il FadeIn
			$(quale_page).fadeOut("normal", function(){
				
				$(quale_page).fadeIn("normal");
				nascondi_overlay();
			
			});
			
			
		}
 	
	})
	
	
	
	
	$('#blocchi > li').mouseover(function(){
	
		if (!$(this).hasClass('selected')) { 
			
			$(this).css({backgroundPosition: '0 -21px'});
		
		}
		
	})
	
	
	
	$('#blocchi > li').mouseout(function(){
	
		if (!$(this).hasClass('selected')) { 
			
			$(this).css({backgroundPosition: '0 0'});
		
		}
		
	})
	
	
	
	
	
	
	$("#blocchi .btn1").click(function(){
		
		quale_page = "#page_1";
										
	});
	
	
	$("#blocchi .btn2").click(function(){
		
		quale_page = "#page_2";
		
	});
	
	
	$("#blocchi .btn3").click(function(){
		
		quale_page = "#page_3";
   
	});
	
	
	$("#blocchi .btn4").click(function(){
		
		quale_page = "#page_4";
		
	});
	
	
	$("#blocchi .btn5").click(function(){
		
		quale_page = "#page_5";
   
	});
	
	
	$("#blocchi .btn6").click(function(){
		
		quale_page = "#page_6";
		
	});
	$("#blocchi .btn7").click(function(){
		
		quale_page = "#page_7";
   
	});
	$("#blocchi .btn8").click(function(){
		
		quale_page = "#page_8";
   
	});
	
	
	$(".btn_blog").hover(function(){
	
		$(this).css({backgroundPosition: '0 -21px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	$(".btn_blog").click(function () {
									   
		newWindow('blog/', 'popup', 1100, 600, 1, 1, 0, 0, 0, 1, 0);
	
    });
	
	
	/*FOOTER*/
	
	$(".btn_footer_termini").hover(function(){
	
		$(this).css({backgroundPosition: '0 -16px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	$(".btn_footer_privacy").hover(function(){
	
		$(this).css({backgroundPosition: '0 -16px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	$(".btn_footer_br").hover(function(){
	
		$(this).css({backgroundPosition: '0 -16px'});
   
	},function(){
	 
		$(this).css({backgroundPosition: '0 0'});
   
	});
	
	
	
	
	$("#footer .btn_footer_br").click(function(){
		newWindow('blog/bere_responsabile.php', 'popup', 830, 600, 1, 1, 0, 0, 0, 1, 0);
		
	});
	
	
	$("#footer .btn_footer_termini").click(function(){		
		newWindow('blog/termini.php', 'popup', 830, 600, 1, 1, 0, 0, 0, 1, 0);
	});
	
	$("#footer .btn_footer_privacy").click(function(){
										
		newWindow('blog/privacy.php', 'popup', 830, 600, 1, 1, 0, 0, 0, 1, 0);   
	});
	
	

});