$(function(){

$('.navHorarios li a').click(function(){
		tableHor = '#boxHorarios #'+$(this).attr('rel');
		
		$("#boxHorarios table").removeClass('ativo');
		$("#boxHorarios table").css('display','none');
		
		$("#tit-horarios").removeClass();
		$("#tit-horarios").addClass('tt tt-'+$(this).attr('rel'));
		
		jQuery.each(jQuery.browser, function(i) {
		  if($.browser.msie){
		     $(tableHor).addClass('ativo');
		  }else{
		     $(tableHor).css('display','table');
		  }
		});
		
		$('.scroll').jScrollPane({showArrows:true});
		
	});


	
	var valorInicial = new Array();
	
	$("#formContato .campo").each(function(i) {
		var formId = $(this).attr('id');
		valorInicial[formId] = $(this).attr('value');
	});
			
	$("#formContato .campo").focus(function() {
		var valor = document.getElementById(this.id).value;
		var valorForm = document.getElementById(this.id).value;
		if (valorForm == valorInicial[this.id]) {
			document.getElementById(this.id).value = '';
		}
		
		// EXCESSÃO P/ O CAMPO SENHA
		if(this.id == 'formSenha'){
			document.getElementById(this.id).type = "password";
		}
		
	});
	
	$("#formContato .campo").blur(function() {
		var valorForm = document.getElementById(this.id).value;
		
		// EXCESSÃO P/ O CAMPO SENHA
		if(this.id == 'formSenha' && valorForm == ''){
			document.getElementById(this.id).type = "text";
		}
		
		if (valorForm == '') {
			document.getElementById(this.id).value = valorInicial[this.id];
		}
	});

});

function validaContato(){

	if ($("#nome").val() == '' || $("#nome").val() == 'Nome'){
		alert('Informe seu Nome!');
		$("#nome").focus();
		return false;
	}

	if ($("#email").val() == '' || $("#email").val() == 'E-mail'){
		alert('Informe seu E-Mail!');
		$("#email").focus();
		return false;
	} else {
		if (!checkMail($("#email").val())){
			alert('O E-Mail parece estar errado!');
			$("#email").focus();
			return false;
		}
	}

	if ($("#assunto").val() == '' || $("#assunto").val() == 'Assunto'){
		alert('Informe o Assunto!');
		$("#assunto").focus();
		return false;
	}

	if ($("#mensagem").val() == '' || $("#mensagem").val() == 'Mensagem'){
		alert('Digite sua Mensagem!');
		$("#mensagem").focus();
		return false;
	}
	
	return true;

}

function openShadowbox(content, player, title, width, height){
	Shadowbox.open({
        content:    content,
        player:     player,
        title:      title,
        width:      width,
        height:     height
    });
}

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;
	}
}
