$(document).ready(function() {
	var navigation = 0;
	$(".loader").hide();
	$(".content").hide();
	
	// MOUSE ENTER EFFECT
	$("#nav-company a").mouseenter(function(){
	  $("#nav-company a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	$("#nav-products a").mouseenter(function(){
	  $("#nav-products a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	$("#nav-contacts a").mouseenter(function(){
	  $("#nav-contacts a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	$("#nav-about a").mouseenter(function(){
	  $("#nav-about a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	$("#nav-develop a").mouseenter(function(){
	  $("#nav-develop a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	$("#nav-vision a").mouseenter(function(){
	  $("#nav-vision a img").animate({top: "45px", opacity: 1.0}, "fast")
		return false;
	});
	
	// MOUSE LEAVE EFFECT
	$("#nav-company a").mouseleave(function(){
		if (navigation != "company") {
			$("#nav-company a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	$("#nav-products a").mouseleave(function(){
		if (navigation != "products") {
			$("#nav-products a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	$("#nav-contacts a").mouseleave(function(){
		if (navigation != "contacts") {
			$("#nav-contacts a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	$("#nav-about a").mouseleave(function(){
		if (navigation != "about") {
			$("#nav-about a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	$("#nav-develop a").mouseleave(function(){
		if (navigation != "develop") {
			$("#nav-develop a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	$("#nav-vision a").mouseleave(function(){
		if (navigation != "vision") {
			$("#nav-vision a img").animate({top: "50px", opacity: 0.4}, "fast")
			return false;
		}
	});
	
	// AJAX LOADING PAGES
	$("#nav-company a").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow")
		$("#nav-company a img").animate({top: "45px", opacity: 1.0}, "fast")
			$(".content").fadeOut("normal", function() {
			$(".loader").show();
			$(".cont-head").css("backgroundImage","url(images/cont-head-company.gif)");
			$(".cont-cont").load("pages/company.htm", function() { 
					$(".loader").hide();
					$(".content").fadeIn("slow");
				});
			});
		navigation = "company";
		return false;
	});
	$("#nav-products a").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow")
		$("#nav-products a img").animate({top: "45px", opacity: 1.0}, "fast")
		$(".content").fadeOut("normal", function() { 
		$(".loader").show();
		$(".cont-head").css("backgroundImage","url(images/cont-head-products.gif)");
		$(".cont-cont").load("pages/products.htm", function() { 
				$(".loader").hide();
				$(".content").fadeIn("slow");
			});
		});
		navigation = "products";
		return false;
	});
	$("#nav-contacts a").click(function() {
		//$("#page").html("<img src='images/
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow")
		$("#nav-contacts a img").animate({top: "45px", opacity: 1.0}, "fast")
		$(".content").fadeOut("normal", function() { 
		$(".loader").show();
		$(".cont-head").css("backgroundImage","url(images/cont-head-contacts.gif)");
		$(".cont-cont").load("pages/contacts.php", function() { 
				$(".loader").hide();
				$(".content").fadeIn("slow");
			});
		});
		navigation = "contacts";
		return false;
	});
	$("#nav-about a").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow")
		$("#nav-about a img").animate({top: "45px", opacity: 1.0}, "fast")
			$(".content").fadeOut("normal", function() { 
			$(".loader").show();
			$(".cont-head").css("backgroundImage","url(images/cont-head-about.gif)");
			$(".cont-cont").load("pages/about.htm", function() { 
					$(".loader").hide();
					$(".content").fadeIn("slow");
				});
			});
		navigation = "about";
		return false;
	});
	$("#nav-develop a").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow")
		$("#nav-develop a img").animate({top: "45px", opacity: 1.0}, "fast")
			$(".content").fadeOut("normal", function() { 
			$(".loader").show();
			$(".cont-head").css("backgroundImage","url(images/cont-head-develop.gif)");
			$(".cont-cont").load("pages/develop.htm", function() { 
					$(".loader").hide();
					$(".content").fadeIn("slow");
				});
			});
		navigation = "develop";
		return false;
	});
	$("#nav-vision a").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow");
		$("#nav-vision a img").animate({top: "45px", opacity: 1.0}, "fast");
			$(".content").fadeOut("normal", function() { 
			$(".loader").show();
			$(".cont-head").css("backgroundImage","url(images/cont-head-vision.gif)");
			$(".cont-cont").load("pages/vision.htm", function() { 
					$(".loader").hide();
					$(".content").fadeIn("slow");
				});
			});
		navigation = "vision";
		return false;
	});
	$("#privacy").click(function() {
		if (navigation == 0) { // ci impostiamo graficamente per il contenuto
			$("#nav-header").animate({top: "5%"}, "slow");
		}
		$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow");
			$(".content").fadeOut("normal", function() { 
			$(".loader").show();
			$(".cont-head").css("backgroundImage","url(images/cont-head-privacy.gif)");
			$(".cont-cont").load("pages/privacy.htm", function() { 
					$(".loader").hide();
					$(".content").fadeIn("slow");
				});
			});
		navigation = "privacy";
		return false;
	});
	
	// AJAX BACK TO MAIN VIEW
	$("#back-to").click(function() {
		$(".content").fadeOut("normal", function() {
			$("#nav-"+navigation+" a img").animate({top: "50px", opacity: 0.4}, "slow");
			navigation = 0;
			$("#nav-header").animate({top: "33%"}, "slow");
		});
		return false;
	});
});


