$(function(){

	// tira a linha do primeiro e do ultimo li dos topicos
	$('#topicos li:first, #download tr:first').addClass('first');
	$('#topicos li:last, #download tr:last').addClass('last');
	
	// se for o ie7 coloca mais padding nos topicos
	if($.browser.msie && parseInt($.browser.version)<=7) {
		$('#topicos li').addClass('ie7');
	}
	
	// abre a newsletter usando fancybox
	$('a.news, a.zoom').fancybox({ 
			'frameWidth':520,
			'frameHeight':300,
			'hideOnContentClick': false,
			'overlayOpacity':0.8
	});

	// valida o form de contato
	$("form[name='contato']").submit(function(){
		var email = $("input[name='email']").val();
		var nome = $("input[name='nome']").val();
		var assunto = $("input[name='assunto']").val();
		var mensagem = $("textarea[name='mensagem']").val();
		if (email.length == 0) {
			alert("Digite um email");
			return false;
		} else if (nome.length == 0) {
			alert("Digite seu nome");
			return false;
		} else if (assunto.length == 0) {
			alert("Digite um assunto");
			return false;
		} else if (mensagem.length == 0) {
			alert("Digite uma mensagem");
			return false;
		} else if (!checkMail(email)) {
			alert("Digite um email válido!");
			return false;
		} else {
			return true;
		}
	});
});

// valida endereco de e-mail ----------------------------------------------------------------------------------
function checkMail(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string"){
		if(er.test(mail)){ return true; }
	}else if(typeof(mail) == "object"){
		if(er.test(mail.value)){
			return true;
		}
	}else{
		return false;
	}
}
// ------------------------------------------------------------------------------------------------------------
