// JavaScript Document
	$(document).ready(function(){
							   
	nav_org = 1;
	nav_menu = 0;
//	$('#popupDatepicker').datepick();

//	$("#nav_org_bottom").show();
//	$("#nav_off_bottom").show();
//	$("#campi_query").load('../org_ben.php?tip=1');
	

	$('#nav_org_bottom label').mouseover(function () {
		$(this).css("color","#FFF");  
	});

	$('#nav_org_bottom label').mouseout(function () {
		$(this).css("color","#000");  
	});

	$("#nav_org_top").bind('click',function () {
       if ($("#nav_org_bottom").is(":hidden")) {
	   		$("#nav_org_bottom").slideDown("slow");
			$('#nav_org_top').attr('src','images/up_org3.png');
			  } else {
       		$("#nav_org_bottom").slideUp("slow");
			$('#nav_org_top').attr('src','images/up_org1.png');
     	}
		});

	$('#nav_org_top').mouseover(function () {
		if ($("#nav_org_bottom").is(":hidden")) {
        		$('#nav_org1').attr('src','images/up_org2.png');
			} else {
				$('#nav_org1').attr('src','images/up_org4.png');
			}
      });

	$('#nav_org_top').mouseout(function () {
		if ($("#nav_org_bottom").is(":hidden")) {
        		$('#nav_org1').attr('src','images/up_org1.png');
			} else {
				$('#nav_org1').attr('src','images/up_org3.png');
			}
    });		
		
	$("#nav_menu_top").bind('click',function () {
       if ($("#nav_menu_bottom").is(":hidden")) {
	   		$("#nav_menu_bottom").slideDown("slow");
			$('#nav_menu1').attr('src','images/up_menu3.png');
			  } else {
       		$("#nav_menu_bottom").slideUp("slow");
			$('#nav_menu1').attr('src','images/up_menu1.png');
     	}
		});
	$('#nav_menu_top').mouseover(function () {
		if ($("#nav_menu_bottom").is(":hidden")) {
        		$('#nav_menu1').attr('src','images/up_menu2.png');
			} else {
				$('#nav_menu1').attr('src','images/up_menu4.png');
			}
      });

	$('#nav_menu_top').mouseout(function () {
		if ($("#nav_menu_bottom").is(":hidden")) {
        		$('#nav_menu1').attr('src','images/up_menu1.png');
			} else {
				$('#nav_menu1').attr('src','images/up_menu3.png');
			}
    });
	
	$("#nav_off_top").bind('click',function () {
       if ($("#nav_off_bottom").is(":hidden")) {
	   		$("#nav_off_bottom").slideDown("slow");
			$('#nav_off1').attr('src','images/up_lenostreofferte3.png');
			  } else {
       		$("#nav_off_bottom").slideUp("slow");
			$('#nav_off1').attr('src','images/up_lenostreofferte1.png');
     	}
		});
	$('#nav_off_top').mouseover(function () {
		if ($("#nav_off_bottom").is(":hidden")) {
        		$('#nav_off1').attr('src','images/up_lenostreofferte2.png');
			} else {
				$('#nav_off1').attr('src','images/up_lenostreofferte4.png');
			}
      });

	$('#nav_off_top').mouseout(function () {
		if ($("#nav_off_bottom").is(":hidden")) {
        		$('#nav_off1').attr('src','images/up_lenostreofferte1.png');
			} else {
				$('#nav_off1').attr('src','images/up_lenostreofferte3.png');
			}
    });

	$("#nav_tip_top").bind('click',function () {
       if ($("#nav_tip_bottom").is(":hidden")) {
	   		$("#nav_tip_bottom").slideDown("slow");
			$('#nav_tip1').attr('src','images/up_tipologie3.png');
			  } else {
       		$("#nav_tip_bottom").slideUp("slow");
			$('#nav_tip1').attr('src','images/up_tipologie1.png');
     	}
		});
	$('#nav_tip_top').mouseover(function () {
		if ($("#nav_tip_bottom").is(":hidden")) {
        		$('#nav_tip1').attr('src','images/up_tipologie2.png');
			} else {
				$('#nav_tip1').attr('src','images/up_tipologie4.png');
			}
      });

	$('#nav_tip_top').mouseout(function () {
		if ($("#nav_tip_bottom").is(":hidden")) {
        		$('#nav_tip1').attr('src','images/up_tipologie1.png');
			} else {
				$('#nav_tip1').attr('src','images/up_tipologie3.png');
			}
    });		


	$("#nav_forum_top").bind('click',function () {
       if ($("#nav_forum_bottom").is(":hidden")) {
	   		$("#nav_forum_bottom").slideDown("slow");
			$('#nav_forum1').attr('src','images/up_newseforum3.png');
			  } else {
       		$("#nav_forum_bottom").slideUp("slow");
			$('#nav_forum1').attr('src','images/up_newseforum1.png');
     	}
		});
	$('#nav_forum_top').mouseover(function () {
		if ($("#nav_forum_bottom").is(":hidden")) {
        		$('#nav_forum1').attr('src','images/up_newseforum2.png');
			} else {
				$('#nav_forum1').attr('src','images/up_newseforum4.png');
			}
      });

	$('#nav_forum_top').mouseout(function () {
		if ($("#nav_forum_bottom").is(":hidden")) {
        		$('#nav_forum1').attr('src','images/up_newseforum1.png');
			} else {
				$('#nav_forum1').attr('src','images/up_newseforum3.png');
			}
    });



	$("#nav_utente_top").bind('click',function () {
       if ($("#nav_utente_bottom").is(":hidden")) {
	   		$("#nav_utente_bottom").slideDown("slow");
			$('#nav_utente1').attr('src','images/up_utente3.png');
			  } else {
       		$("#nav_utente_bottom").slideUp("slow");
			$('#nav_utente1').attr('src','images/up_utente1.png');
     	}
		});

	$('#nav_utente_top').mouseover(function () {
		if ($("#nav_utente_bottom").is(":hidden")) {
        		$('#nav_utente1').attr('src','images/up_utente2.png');
			} else {
				$('#nav_utente1').attr('src','images/up_utente4.png');
			}
      });

	$('#nav_utente_top').mouseout(function () {
		if ($("#nav_utente_bottom").is(":hidden")) {
        		$('#nav_utente1').attr('src','images/up_utente1.png');
			} else {
				$('#nav_utente1').attr('src','images/up_utente3.png');
			}
    });		

//		$("#select_dest select").change(function(){
//			//xx = $('#destinazione').val();
			//alert (xx);
//			$("#select_tip").load('org_ajax.php', { tip:1, dest:$('#destinazione').val() });
			//alert ($("#destinazione").val());
			
//		});
		
	$('#viaggio1').bind('click',function () {	
										  
			 $("#campi_query").load('../org_ben.php?tip=1'); 
		<!--	$("#campi_query").hide();-->
		//	$("#org_ben").show(); 

		 });	
	
	$('#viaggio2').bind('click',function () {
		//	$("#org_ben").hide();
		//	$("#campi_query").show();							  
			$("#campi_query").load('../query.php?tip=2');
		 });	

	$('#viaggio3').bind('click',function () {
		//	$("#org_ben").hide();
		//	$("#campi_query").show();							  
			$("#campi_query").load('../query.php?tip=3');
		 });	

	$('#viaggio4').bind('click',function () {	
		//	$("#org_ben").hide();
		//	$("#campi_query").show();							  										  
			$("#campi_query").load('../org_off.php?tip=4');
		 });	
	$('#viaggio5').bind('click',function () {	
		//	$("#org_ben").hide();
		//	$("#campi_query").show();							  										  
			$("#campi_query").load('../org_week.php?tip=5');
		 });	

	$('#viaggio6').bind('click',function () {
		//	$("#org_ben").hide();
		//	$("#campi_query").show();							  										  
			$("#campi_query").load('../query.php?tip=6');
		 });	

	$("#nav_altreoff_top").bind('click',function () {
       if ($("#nav_altreoff_bottom").is(":hidden")) {
	   		$("#nav_altreoff_bottom").slideDown("slow");
			$('#nav_altreoff1').attr('src','images/up_altreproposte3.png');
			  } else {
       		$("#nav_altreoff_bottom").slideUp("slow");
			$('#nav_altreoff1').attr('src','images/up_altreproposte1.png');
     	}
		});
	$('#nav_altreoff_top').mouseover(function () {
		if ($("#nav_altreoff_bottom").is(":hidden")) {
        		$('#nav_altreoff1').attr('src','images/up_altreproposte2.png');
			} else {
				$('#nav_altreoff1').attr('src','images/up_altreproposte4.png');
			}
      });

	$('#nav_altreoff_top').mouseout(function () {
		if ($("#nav_altreoff_bottom").is(":hidden")) {
        		$('#nav_altreoff1').attr('src','images/up_altreproposte1.png');
			} else {
				$('#nav_altreoff1').attr('src','images/up_altreproposte3.png');
			}
    });
		 
		$("#nav_util_top").bind('click',function () {
       if ($("#nav_util_bottom").is(":hidden")) {
	   		$("#nav_util_bottom").slideDown("slow");
			$('#nav_util1').attr('src','images/up_utilita3.png');
			  } else {
       		$("#nav_util_bottom").slideUp("slow");
			$('#nav_util1').attr('src','images/up_utilita1.png');
     	}
		});
	$('#nav_util_top').mouseover(function () {
		if ($("#nav_util_bottom").is(":hidden")) {
        		$('#nav_util1').attr('src','images/up_utilita2.png');
			} else {
				$('#nav_util1').attr('src','images/up_utilita4.png');
			}
      });

	$('#nav_util_top').mouseout(function () {
		if ($("#nav_util_bottom").is(":hidden")) {
        		$('#nav_util1').attr('src','images/up_utilita1.png');
			} else {
				$('#nav_util1').attr('src','images/up_utilita3.png');
			}
    });

 
	$("#login_form").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").text('Validazione....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("check_login.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='yes') //if correct login detail
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{
			  //add message and change the class of the box and start fading
			  $(this).html('Logging in.....').fadeTo(900,1,
              function()
			  {
			  	 //redirect to secure page
				 document.location='user.php';
			  });

			});
		  }
		  else
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{
			  //add message and change the class of the box and start fading
			  $(this).html('Le tue credenziali per il login non sono valide...').fadeTo(900,1);
			});
          }

        });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from

});
