$(document).ready(function() {	

	$('a[id=modal]').click(function(e) {
		e.preventDefault();
		
		var id = $(this).attr('href');
	
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});

		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).fadeIn(2000); 
	
	});
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});

function validaForm(cont){
	
var emailamigo = cont.emailamigo.value;	
	
if(cont.seuamigo.value ==""){
      alert("Por favor, preencha corretamente o campo Nome do Amigo!");
      cont.seuamigo.focus();
      return false;
	}

	if(emailamigo=="") {
		alert("É necessário o preenchimento de um endereço de e-mail válido.");
		cont.emailamigo.focus();
		return false;
	}
	//Checando se o endereço de e-mail é válido
	
	
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(cont.emailamigo.value))) {
		alert("É necessário o preenchimento de um endereço de e-mail válido.");
		cont.emailamigo.focus();
		return false;
	}


	return true;
}

