$(document).ready(function(){	


	$("#mn-header li:first").hover(
	  function () {
		$("#smn-header").fadeIn();
	  },
	  function () {
		$("#smn-header").fadeOut();
	  }
	);
	


////// Desabilita o click direito do mouse
	$(document).bind("contextmenu",function(e){
		e.preventDefault();
		$("#direitos").remove();
		$("body").prepend("<div id='direitos'><b>Apronta 2009</b><br />Todos os direitos reservados</div>");
		$("#direitos").fadeIn().css({
			left: e.pageX + 20,
			top: e.pageY - 20
		});
		
		$(document).mousemove(function(e){
		  var pageCoords = "( " + e.pageX + ", " + e.pageY + " )";
		  var clientCoords = "( " + e.clientX + ", " + e.clientY + " )";
		  //$("span:first").text("( e.pageX, e.pageY ) - " + pageCoords);
		 // $("span:last").text("( e.clientX, e.clientY ) - " + clientCoords);
			$("#direitos").css({
				left: e.pageX + 20,
				top: e.pageY - 20
			});
		});
		
		//clearTimeout(timer);
		timer = window.setTimeout(function() {
			$("#direitos").fadeOut(function(){$(this).remove()});
		},3000);
	});
	
////// Ajuste de Layout
	resizeLayout();		
	
	var resizeTimer = null;
	$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(resizeLayout, 10);
	});	
	
	function resizeLayout() {			
		$("#wrapper").height($(window).height());
		$("#canvas").VerticalAlign();
	};
		
	$("form").bind("submit", function(evt){
		evt.preventDefault();
		
			
		obj = $(this);			
		box = obj.parent()
		
		
		if(valida(this)==true){		
		
			$.ajax({
				type: "POST",
				url: obj.attr("action"),
				cache: false,
				data: obj.serialize(),				
				beforeSend: function(){
					
					obj.find("input, button, select, label").attr("disabled", "disabled");					
					obj.next().html("Enviando...").fadeIn();				
					
				},
				success: function(data){
					obj.next().html(data);
					//obj.next().html("Ok...");					
				},
				error: function(data){
					obj.next().html(data.responseText);
					//obj.next().html("Ocorreu um erro Erro...");
				},
				complete: function(data){
					window.setTimeout(function() {
						obj.find("input, textarea, button, select, label").removeAttr("disabled");
						obj.find("input, textarea").val("");
						obj.next().fadeOut();	
					},5000);					
				}
			});
		}
	});
});

