var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',noresizable'
win = window.open(mypage,myname,settings)
}


function Trim(str){

	while (str.charAt(0) == " ")
		str = str.substr(1,str.length -1);

	while (str.charAt(str.length-1) == " ")
		str = str.substr(0,str.length-1);

	return str;
} 

function validaEmail(valor){
	
	if( (Trim(valor) == '') || (/^([\w\.\-])+\@(([\w\-])+\.)+([\w ]{2,4})$/.test(valor) == false) ){
		// if (/^([\w\.\-])+\@(([\w\-])+\.)+([\w ]{2,4})$/.test(campo.value) == false) { 
            return false;
     }
	return true;
	
}


function validaContato(){


	f = document.frmContato;
	
	if( Trim(f.nome.value) == '' ) {
		alert('O nome deve ser informado');
		f.nome.focus();
		return false;			
	}
	if( !validaEmail(f.email.value) ) {
		alert('Você deve informar um e-mail válido');
		f.email.focus();
		return false;			
	}	
	if( Trim(f.ddd.value) == '' ) {
		alert('O ddd deve ser informado');
		f.ddd.focus();
		return false;			
	}	
	
	if( Trim(f.fone.value) == '' ) {
		alert('O telefone deve ser informado');
		f.fone.focus();
		return false;			
	}
		
	if( Trim(f.mensagem.value) == '' ) {
		alert('A mensagem deve ser informada');
		f.mensagem.focus();
		return false;			
	}
	
	
	return true;
}