function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',noresize'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}
var abreReceitas = function(){
	NewWindow("receitas.html","receitas", 690, 430, "no");
}
var desceTexto = function(id){
	var div = document.getElementById(id);
	div.scrollTop += 50;
}
var sobeTexto = function(id){
	var div = document.getElementById(id);
	div.scrollTop -= 50;
}
var initForm = function(){
	var form = document.getElementById("form-contato");
	var input = form.getElementsByTagName("input");
	var textarea = form.getElementsByTagName("textarea");
	form.onsubmit=function(){
		if(input[0].value==""){
			alert("Você deve preencher o campo Nome");
			input[0].focus();
			return false;
		}
		else if(input[1].value==""){
			alert("Você deve preencher o campo E-mail");
			input[1].focus();
			return false;
		}
		else if(input[1].value.indexOf("@")==-1){
			alert("Insira um e-mail válido");
			input[1].focus();
			return false;
		}
		else if(input[1].value.indexOf(".")==-1){
			alert("Insira um e-mail válido");
			input[1].focus();
			return false;
		}
		else if(textarea[0].value==""){
			alert("Preencha a sua mensagem");
			textarea[0].focus();
			return false;
		}
		else{
			return true;
		}
	}
}
window.onload=function(){
	if(document.getElementById("bt-abre-receitas")){
		var btReceitas = document.getElementById("bt-abre-receitas");
		btReceitas.onclick = function(){
			abreReceitas();
			return false;
		}
	}
	if(document.getElementById("form-contato")){
		initForm();
	}
}