$(document).ready(function() {
	$(".navbut").hoverIntent(
			function(){
				$(this).switchClass("navbut","navbuton",200);
			},
			function(){
				$(this).switchClass("navbuton","navbut",200);
			}
	);
	$(".lbut").hoverIntent(
			function(){
				$(this).switchClass("lbut","lbutopen",200);
			},
			function(){
				$(this).switchClass("lbutopen","lbut",200);
			}
	);
	$(".wd").waterDrop({
		event : "mouseover",
		padding : 10,
		speed : 40,
		borderRadius : "50px", 
		backgroundColor: "transparent",
		borderWidth: 4, 
		borderColor: "white"		
	});
	$(".homebloc").each(function(i){
		var it = "#"+this.id+"but";
		$(this).hoverIntent( 
			function (){
				$(it).trigger("mouseover");
				$(it).switchClass("navbut","navbuton",200);
			},
			function (){
				$(it).trigger("mouseout");
				$(it).switchClass("navbuton","navbut",200);
			}
		);
		$(this).click(function(){location.href="?p="+this.id;});
	});
	$("form#contactform").submit(function (e) {
		e.preventDefault();
	    var maskHeight = $(document).height();
	    var maskWidth = $(window).width();
	    $('#mask').css({"width":maskWidth,"height":maskHeight});
	    $('#mask').fadeTo("slow",0.5,function (){ $("#dialog").show(); }); 
	});
    $("#dialog .close").click(function (e) {
        e.preventDefault();
        $('#mask, #dialog').hide();
    });    
    $("#mask").click(function () {
        $('#mask, #dialog').hide();
    }); 
    $("#dialog .confirm").click(function (e) {
    	e.preventDefault();
    	$("#contactform").load(
    			"sendmail.php",
    			{
    				name    : $("input[name=name]").val(),
    				lang    : $("input[name=lang]").val(),
    				email   : $("input[name=email]").val(),
    				subject : $("input[name=subject]").val(),
    				message : $("textarea[name=message]").val()
    			},
    			function () {$("#mask, #dialog").hide();}
    	);
    });
});

