function validaContato(oForm)
{
	try
	{
		var vFields = 
		{
			'nome': oForm.elements['nome'],
			'email': oForm.elements['email'],
			'assunto': oForm.elements['assunto'],
			'mensagens': oForm.elements['mensagens']
		};

		if(vFields.nome.value == '')throw {'source': vFields.nome, 'message': 'Por favor, informe o seu nome.', 'action': 'focus'};

		if(vFields.email.value == '')throw {'source': vFields.email, 'message': 'Por favor, informe o seu e-mail.', 'action': 'focus'};
		else if(vFields.email.value.indexOf('@') == -1)throw {'source': vFields.email, 'message': 'O endereço de e-mail informado é inválido.', 'action': 'clear'};
		if(vFields.assunto.value == '')throw {'source': vFields.assunto, 'message': 'Por favor, informe o assunto.', 'action': 'focus'};
		if(vFields.mensagens.value == '')throw {'source': vFields.mensagens, 'message': 'Por favor, informe a mensagem.', 'action': 'focus'};

	}catch(e){
		window.alert(e.message);
		if(e.action == 'clear')e.source.value = '';
		e.source.focus();
		return false;
	}
	return true;
}

function validaImprensa(oForm)
{
	try
	{
		var vFields = 
		{
			'nome': oForm.elements['nome'],
			'dia':oForm.elements['dia'],
			'veiculo': oForm.elements['veiculo'],
			'mensagens': oForm.elements['mensagens']
		};

		if(vFields.nome.value == '')throw {'source': vFields.nome, 'message': 'Por favor, informe o seu nome.', 'action': 'focus'};

		if(!isDate(oForm.elements['dia'].value + "/" + oForm.elements['mes'].value + "/" + oForm.elements['ano'].value))throw {'source': vFields.dia, 'message': 'Por favor, informe uma data válida.', 'action': 'focus'};

		if(vFields.veiculo.value == '')throw {'source': vFields.veiculo, 'message': 'Por favor, informe o veiculo.', 'action': 'focus'};
		if(vFields.mensagens.value == '')throw {'source': vFields.mensagens, 'message': 'Por favor, informe a mensagem.', 'action': 'focus'};

	}catch(e){
		window.alert(e.message);
		if(e.action == 'clear')e.source.value = '';
		e.source.focus();
		return false;
	}
	return true;
}

function validaTrabalhe(oForm)
{
	try
	{
		var vFields = 
		{
			'nome': oForm.elements['nome'],
			'curriculo': oForm.elements['curriculo'],
			'mensagens': oForm.elements['mensagens']
		};

		if(vFields.nome.value == '')throw {'source': vFields.nome, 'message': 'Por favor, informe o seu nome.', 'action': 'focus'};

		if(vFields.mensagens.value == '')throw {'source': vFields.mensagens, 'message': 'Por favor, informe a mensagem.', 'action': 'focus'};
		if(vFields.curriculo.value == '')throw {'source': vFields.curriculo, 'message': 'Por favor, insira seu currículo.', 'action': 'focus'};


	}catch(e){
		window.alert(e.message);
		if(e.action == 'clear')e.source.value = '';
		e.source.focus();
		return false;
	}
	return true;
}

function isDate(dateStr) {
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
		return false;
	}
	
	month = matchArray[3]; // parse date into variables
	day = matchArray[1];
	year = matchArray[5];
	
	if (month < 1 || month > 12) { // check month range
		return false;
	}
	
	if (day < 1 || day > 31) {
		return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		return false;
	}
	
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			return false;
		}
	}
	return true; // date is valid
}
