$(document).ready(function() {

    // Expand Panel
    $("#open").click(function() {
        $("div#panel").slideDown("slow");

    });

    // Collapse Panel
    $("#close").click(function() {
        $("div#panel").slideUp("slow");
    });

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function() {
        $("#toggle a").toggle();
    });

});

// JavaScript Document

var image_path = "";

var domains_dropdown_image = "images/icona.png";
var domains_dropdown_description = "Domini e Posta";
var hosting_dropdown_image = "images/icona.png";
var hosting_dropdown_description = "Hosting";
var vps_dropdown_image = "images/icona.png";
var vps_dropdown_description = "Virtual Private Servers";
var housing_dropdown_image = "images/icona.png";
var housing_dropdown_description = "Housing & Co-Location";
var ssl_dropdown_image = "images/icona.png";
var ssl_dropdown_description = "Certificati SSL";
var ecommerce_dropdown_image = "images/icona.png";
var ecommerce_dropdown_description = "E-Commerce";
var prodotti_dropdown_image = "images/icona.png";
var prodotti_dropdown_description = "Prodotti in vendita";
var advertising_dropdown_image = "images/icona.png";
var advertising_dropdown_description = "Rendi visibile il tuo lavoro";
var email_dropdown_image = "images/icona.png";
var email_dropdown_description = "Crea la tua casella email personalizzata";

$(document).ready(function() 
{
	$("#domains_nav").click(function(){
		$("#domains_dropdown").show();
		$("#domains_dropdown .first img").attr("src", image_path + domains_dropdown_image);
		$("#domains_dropdown .first p").html(domains_dropdown_description);
	});
	$("#domains_nav").mouseout(function(){
		$("#domains_dropdown").hide();
	});
	$("#domains_dropdown").hover(
		function(){$("#domains_dropdown").show();}, 
		function(){$("#domains_dropdown").hide();}
	);
	
	$("#email_nav").click(function(){
		$("#email_dropdown").show();
		$("#email_dropdown .first img").attr("src", image_path + email_dropdown_image);
		$("#email_dropdown .first p").html(email_dropdown_description);									
	});
	$("#email_nav").mouseout(function(){
		$("#email_dropdown").hide();									
	});
	$("#email_dropdown").hover(
		function(){$("#email_dropdown").show();}, 
		function(){$("#email_dropdown").hide();}
	);
	
	$("#hosting_nav").click(function(){
		$("#hosting_dropdown").show();
		$("#hosting_dropdown .first img").attr("src", image_path + hosting_dropdown_image);
		$("#hosting_dropdown .first p").html(hosting_dropdown_description);								
	});
	$("#hosting_nav").mouseout(function(){
		$("#hosting_dropdown").hide();									
	});
	$("#hosting_dropdown").hover(
		function(){$("#hosting_dropdown").show();}, 
		function(){$("#hosting_dropdown").hide();}
	);
	
	$("#vps_nav").click(function(){
		$("#vps_dropdown").show();
		$("#vps_dropdown .first img").attr("src", image_path + vps_dropdown_image);
		$("#vps_dropdown .first p").html(vps_dropdown_description);							
	});
	$("#vps_nav").mouseout(function(){
		$("#vps_dropdown").hide();									
	});
	$("#vps_dropdown").hover(
		function(){$("#vps_dropdown").show();}, 
		function(){$("#vps_dropdown").hide();}
	);
	
	$("#housing_nav").click(function(){
		$("#housing_dropdown").show();
		$("#housing_dropdown .first img").attr("src", image_path + housing_dropdown_image);
		$("#housing_dropdown .first p").html(housing_dropdown_description);									
	});
	$("#housing_nav").mouseout(function(){
		$("#housing_dropdown").hide();									
	});
	$("#housing_dropdown").hover(
		function(){$("#housing_dropdown").show();}, 
		function(){$("#housing_dropdown").hide();}
	);
	
	$("#ssl_nav").click(function(){
		$("#ssl_dropdown").show();
		$("#ssl_dropdown .first img").attr("src", image_path + ssl_dropdown_image);
		$("#ssl_dropdown .first p").html(ssl_dropdown_description);								
	});
	$("#ssl_nav").mouseout(function(){
		$("#ssl_dropdown").hide();									
	});
	$("#ssl_dropdown").hover(
		function(){$("#ssl_dropdown").show();}, 
		function(){$("#ssl_dropdown").hide();}
	);
	
	$("#ecommerce_nav").click(function(){
		$("#ecommerce_dropdown").show();
		$("#ecommerce_dropdown .first img").attr("src", image_path + ecommerce_dropdown_image);
		$("#ecommerce_dropdown .first p").html(ecommerce_dropdown_description);								
	});
	$("#ecommerce_nav").mouseout(function(){
		$("#ecommerce_dropdown").hide();									
	});
	$("#ecommerce_dropdown").hover(
		function(){$("#ecommerce_dropdown").show();}, 
		function(){$("#ecommerce_dropdown").hide();}
	);
	
	$("#prodotti_nav").click(function(){
		$("#prodotti_dropdown").show();
		$("#prodotti_dropdown .first img").attr("src", image_path + prodotti_dropdown_image);
		$("#prodotti_dropdown .first p").html(prodotti_dropdown_description);								
	});
	$("#prodotti_nav").mouseout(function(){
		$("#prodotti_dropdown").hide();									
	});
	$("#prodotti_dropdown").hover(
		function(){$("#prodotti_dropdown").show();}, 
		function(){$("#prodotti_dropdown").hide();}
	);
	
	$("#advertising_nav").click(function(){
		$("#advertising_dropdown").show();
		$("#advertising_dropdown .first img").attr("src", image_path + advertising_dropdown_image);
		$("#advertising_dropdown .first p").html(advertising_dropdown_description);									
	});
	$("#advertising_nav").mouseout(function(){
		$("#advertising_dropdown").hide();									
	});
	$("#advertising_dropdown").hover(
		function(){$("#advertising_dropdown").show();}, 
		function(){$("#advertising_dropdown").hide();}
	);
	

	$(".dropdown li ul li a").each(function(){
		$(this).hover(
			function(){
				$(".dropdown:block .first p").html($(this).attr("title"));
				$(".dropdown:block .first img").attr("src", image_path + $(this).attr("rel"));
			},
			function(event){
				if(!$(event.relatedTarget).is("a")){
					var dropdown = $(this).closest(".dropdown");
					$(dropdown).find(".first img").attr("src", image_path + eval($(dropdown).attr("id") + "_image"));
					$(dropdown).find(".first p").html(eval($(dropdown).attr("id") + "_description"));
				}
			}
		);
	});
	
	$(".dropdown").each(function(){
		$(this).width(($(this).children().size()-2)*200+360);
	});
	
});



