

function displayMail (to, domain, ext){
	var address = to + String.fromCharCode(64) + domain + String.fromCharCode(46) + ext;
	document.write ("<a href=\"mailto:" + address + "\">" + address + "</a>");
}

function btnOverImg (btnName){
	if (document.layers){
		document.layers[btnName].src = document.layers[btnName].src.substring(0,document.layers[btnName].src.length-5) + "1.jpg";
	}else if (document.all){
		document.all[btnName].src = document.all[btnName].src.substring(0,document.all[btnName].src.length-5) + "1.jpg";
	}else if (document.getElementById){
		document.getElementById(btnName).src = document.getElementById(btnName).src.substring(0,document.getElementById(btnName).src.length-5) + "1.jpg";
	}
}
function btnOutImg (btnName){
	if (document.layers){
		document.layers[btnName].src = document.layers[btnName].src.substring(0,document.layers[btnName].src.length-5) + "0.jpg";
	}else if (document.all){
		document.all[btnName].src = document.all[btnName].src.substring(0,document.all[btnName].src.length-5) + "0.jpg";
	}else if (document.getElementById){
		document.getElementById(btnName).src = document.getElementById(btnName).src.substring(0,document.getElementById(btnName).src.length-5) + "0.jpg";
	}
}

//jQuery function

$(function() {
	window.setTimeout(home_diapo, 4000);
	function home_diapo(){
		randomNum = (Math.floor(Math.random()*7)+1);
		$("#home_diapo_img_dn").attr("src", $("#home_diapo_img_up").attr("src"));
		$("#home_diapo_up").fadeOut(0);
		$("#home_diapo_img_up").attr("src", "images/home_diapo_" + randomNum + ".jpg");
		$("#home_diapo_up").fadeIn(1000);
		window.setTimeout(home_diapo, 4000);
	}

	$("#menu > div").find(" > :nth-child(2)").hide();
	$("#menu > div").find(" > :nth-child(2)").removeClass("hideElement");

	$("#menu > div").hover(function() {
		//$(this).find(" > :nth-child(1)").addClass("mainMenuOver");
		$(this).find(" > :nth-child(1)").find("img").removeClass("hideElement");
		$(this).find(" > :nth-child(2)").fadeIn(100);
		$(this).find(" > :nth-child(2)").find("div").hover(function(){
			$(this).addClass("subMenuOver");
		},function(){
			$(this).removeClass("subMenuOver");
		});
		$(this).find(":nth-child(2)").find("div").click(function(){
			if ($(this).attr("href")){
				window.location = $(this).attr("href");
			}
		});
		$(this).css("cursor", "hand");

	},function(){
		//$(this).find(" > :nth-child(1)").removeClass("mainMenuOver");
		$(this).find(" > :nth-child(1)").find("img").addClass("hideElement");
		$(this).find(" > :nth-child(2)").fadeOut(100);
		$(this).css("cursor", "pointer");
	});

	$("#displayProduct").hide();
	$("#displayProduct").removeClass("hideElement");

	$("#displayProduct").click(function() {
		$(this).fadeOut(250, function(){
			$("#displayProdImg").attr("src","images/blank.gif");
			$("#displayProdDescr").empty();
			$("#displayProdTitle").empty();
		});
	});

	$(".btnProduct").hover(function() {
		$(this).css("cursor", "hand");
	},function(){
		$(this).css("cursor", "pointer");
	});
	$(".btnProduct").click(function() {
		//$("#normalProd").show();
		$("#displayProdTitle").append($("#displayProdTitle").attr($(this).attr("prod")));
		$("#displayProdDescr").append($("#displayProdDescr").attr($(this).attr("prod")));
		$("#displayProdImg").attr("src","images/" + $("#displayProdImg").attr($(this).attr("prod")));
		$("#displayProduct").fadeIn(250);
	});

});
