// Lembrar de sempre especificar o que cada comando vai fazer
// e sempre usar da identeção pra pemitir uma melhor leitura
// do futuro desenvolvedor
function beforeCall(form, options){
    //$('#enviar').val('Enviando...');
    //$('#enviar').attr("disabled",true);
    return true;
}

// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
    if(status === true) {
    	$('#'+$(form).attr('id')).hide();
    	$('#'+$(form).attr('id')+'Resposta').show();
    	$('#'+$(form).attr('id')).each(function() {
    		this.reset();
    	});
    	alert("Formulário recebido com sucesso.");
    	// uncomment these lines to submit the form to form.action
        //form.validationEngine('detach');
        //form.submit();
        // or you may use AJAX again to submit the data
    }
	//$('#enviar').val('Enviar');
	//$('#enviar').attr("disabled",false);
}

function formValidator(idForm) {
	$('#'+idForm+'Resposta').hide();
	if($('#'+idForm).length > 0) {
		$('#'+idForm).validationEngine({
			ajaxFormValidation: true,
			onBeforeAjaxFormValidation: beforeCall,
			onAjaxFormComplete: ajaxValidationCallback
		});
	}
}
$(document).ready(function() {
	// formulario
	$('input, textarea').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
	});
	$('input, textarea').blur(function() {
		if($(this).val()=="") {
			$(this).val(value);
		}
	});
	
	formValidator('formInformativo');
	formValidator('formContato');
		
	$("#menu").superfish();
	
	// Accordion
	//	$("#accordion").accordion({ 
//			header: "h3" ,
//			autoHeight: false,
//			navigation: true
//
//		
//		});
//		
//	$('#tabs').tabs();

	$('.destaque-principal').cycle({ 
		fx:     'fade', 
		next:   '#prev-destaque', 
		prev:   '#next-destaque', 
		timeout: 0 
	});
	
	$('#slideshow').cycle({ 
		fx:     'scrollHorz', 
		next:   '#prev', 
		prev:   '#next', 
		timeout: 0 
	});
});
