$(document).ready(function(){

	//Validade Form
	$("#formulario_contato").validate({
		rules: {
			cto_nome: "required",
			cto_email: {
				required: true,
				email: true
			},
			cto_mensagem: {
				required: true
			}
		},
		messages: {
			cto_nome:     "Por favor informe seu nome.",
			cto_email:    "Por favor preencha um e-mail v&aacute;lido.",
			cto_mensagem: "Campo mensagem &eacute; de preenchimento obrigat&oacute;rio."
		}
	});
	
	$("#formulario_trabalhe").validate({
		rules: {
			tra_nome: "required",
			tra_curriculo: "required",
			tra_email: {
				required: true,
				email: true
			},
			tra_mensagem: {
				required: true
			}
		},
		messages: {
			tra_nome:      "Por favor informe seu nome.",
			tra_email:     "Por favor preencha um e-mail v&aacute;lido.",
			tra_mensagem:  "Campo mensagem &eacute; de preenchimento obrigat&oacute;rio.",
			tra_curriculo: "Por favor anexe seu curr&iacute;culo."
		}
	});
	
	//Submissao do contato
    $('#formulario_contato, #formulario_trabalhe').ajaxForm({
		success: showResponse,
		dataType: 'json'
		//,clearForm: true,
        //resetForm: true 
    });
    
    //Mascaras e validações
    $('input:text').setMask();
    
    //Galeria de imagens
    $('.ad-gallery').adGallery({
    	loader_image: 'js/jquery.ad-gallery/loader.gif',
		effect: 'fade', // or 'slide-vert', 'resize', 'fade', 'none' or false
		slideshow: {
		    enable: true,
		    autostart: true,
		    speed: 5000,
		    start_label: 'Iniciar',
		    stop_label: 'Parar',
		    stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
		    countdown_prefix: '(', // Wrap around the countdown
		    countdown_sufix: ')'
		  }
    });
    
});
  
function showResponse(arr_msg, statusText, xhr, $form)  {
	
	if(statusText == 'success'){
		
    	$('#msgs').append( "<h2>" + arr_msg.message + "</h2><br/>" );
		$.colorbox({
			width:"300px", 
			height:"200px", 
			inline:true, 
			href:"#msgs", 
			close:"Fechar",
			onClosed:function(){ $('#msgs').html( "" ); }
		});
		
	}
	
} 
