/****** mascara telefone ******/   

$(document).ready(function() {
	$("#telefone").mask("(99)9999-9999");
					   
});

/****** jquery cycle ******/

$(".slideshow").ready(function() {
    $('.slideshow').cycle({
		fx     : 'fade' , // ex: fade, scrollUp, shuffle, etc...
		timeout: 5000 
	});
	
	$('#linkPortifolio').mouseover(function(){
		$('#linkPortifolio img').removeClass('btOculto');
	}).mouseout(function(){
		$('#linkPortifolio img').addClass('btOculto');
	});

});

/****** Função para exposição *****/

$(function() { 
 
    // assign a click event to the exposed element, using normal jQuery coding 
    $("#contSobre , #contServicos , form").click(function() { 
 
        // perform exposing for the clicked element 
        $(this).expose({api: true, color:'black'}).load(); 
    });
});

$(".msg").ready(function() {
	$(".msg").overlay({ 
	 
		// custom top position 
		top: 250, 
	 
		// some expose tweaks suitable for facebox-looking dialogs 
		expose: { 
	 
			// you might also consider a "transparent" color for the mask 
			color: '#000', 
	 
			// load mask a little faster 
			loadSpeed: 200, 
	 
			// highly transparent 
			opacity: 0.5 
		}, 
	 
		// disable this for modal dialog-type of overlays 
		closeOnClick: false, 
	 
		// we want to use the programming API 
		api: true
	 
	// load it immediately after the construction 
	}).load();
});

/***** Validação *****/

var texto = " é um campo obrigatório.";

function Checar(){

	var erros = new Array();
	
	if((Vazio($("#nome").val()) || ($("#nome").val().length < 3))){
		erros.push("Nome"+texto);
		$("#nome").attr("class","errado");
	}else{
		$("#nome").attr("class","obrigatorio");
	}
	
	if(Vazio($("#email").val())){
		erros.push("Email"+texto);
		$("#email").attr("class","errado");
	}else{
		if(!checkMail($("#email").val())){
			erros.push("O email digitado não é válido.");
			$("#email").attr("class","errado");
		}else{
			$("#email").attr("class","obrigatorio");
		}
	}

/*	if(Vazio($("#telefone").val())){
		erros.push("Telefone"+texto);
		$("#telefone").attr("class","errado");
	}else{
		$("#telefone").attr("class","obrigatorio");
	}	
	
	if(Vazio($("#cidade").val())){
		erros.push("Cidade/Estado"+texto);
		$("#cidade").attr("class","errado");
	}else{
		$("#cidade").attr("class","obrigatorio");
	}
	
	if(Vazio($("#assunto").val())){
		erros.push("Assunto"+texto);
		$("#assunto").attr("class","errado");
	}else{
		$("#assunto").attr("class","obrigatorio");
	}	
*/
	if(Vazio($("#mensagem").val())){
		erros.push("Mensagem"+texto);
		$("#mensagem").attr("class","errado");
	}else{
		$("#mensagem").attr("class","obrigatorio");
	}	

	if(erros.length > 0){
		alert("Verifique o(s) seguinte(s) erro(s):\n\n"+erros.join("\n"));
		return false;
	}else{
		return true;
	}
	
};

function Vazio(valor){
	if((valor == "") || (valor == undefined)){
		return true;
	}else{
		return false;
	}
}

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