jQuery(function($){  
   $("#tel_fixo").mask("(99) 9999-9999"); 
});

//envia o formulario em ajax
function response(data) {
	$('#carregando').hide('slow');
	$('#mensagem_enviado').removeAttr('style');
	$('#mensagem_enviado').html(data);
	$('#mensagem_enviado').delay(7000).fadeOut(3000, "linear");
}

//mostra a  mensagem carregando
function response2(data) {
	$('#carregando').show('fast');
} 

//envia o formulario em ajax
function response_promocao(data) {
	$('#feed_promocao_carregando').hide('slow');
	$('#feed_promocao_enviado').removeAttr('style');
	if(data = 'Cadastro feito com sucesso!'){
		$('#feed_promocao_enviado2').html(data);
		$('#table_feed_promocoes').hide();
		$('#table_feed_promocoes2').show();
		
		$('#mask').delay(3000).fadeOut(1000);
		$('.window').delay(3000).fadeOut(1000);
	} else {
		$('#feed_promocao_enviado').html(data);
	}
	$('#feed_promocao_enviado').delay(7000).fadeOut(3000, "linear");
}

//mostra a  mensagem carregando
function response_promocao2(data) {
	$('#feed_promocao_carregando').show('fast');
} 
 
$(function(){

$("#form_orcamento").validate({

submitHandler: function(form) {
	$(form).ajaxSubmit({
	dataType: 'html',
	
	beforeSubmit: response2,
	success: response,
	resetForm: true,
	
		});
	},rules: {
			nome: {
			required: true,
			minlength:5
		},
			email: {
			required: true,
			email: true
		},
			tel_fixo: 'required',
			descricao: 'required'			
		},
		messages: {
			nome: {
			required: 'Voc&ecirc; n&atilde;o preencheu seu nome',
			minlength:"Digite mais de 5 caracteres"
		},
		email: {
			required: 'Voc&ecirc; precisa preencher um e-mail',
			email: 'Endere&ccedil;o de e-mail n&atilde;o v&aacute;lido'
		},
			tel_fixo: 'Voc&ecirc; n&atilde;o preencheu seu telefone',
			descricao: 'Voc&ecirc; n&atilde;o preencheu a descri&ccedil;&atilde;o'
		}
	
		});
		
		
$("#form_contato").validate({

submitHandler: function(form) {
	$(form).ajaxSubmit({
	dataType: 'html',	
	
	beforeSubmit: response2,
	success: response,
	resetForm: true,	
	
		});
	},
		rules: {
			nome: {
			required: true,
			minlength:5
		},
			email: {
			required: true,
			email: true
		},
			tel_fixo: 'required',
			descricao: 'required'			
		},
		messages: {
			nome: {
			required: 'Voc&ecirc; n&atilde;o preencheu seu nome',
			minlength:"Digite mais de 5 caracteres"
		},
		email: {
			required: 'Voc&ecirc; precisa preencher um e-mail',
			email: 'Endere&ccedil;o de e-mail n&atilde;o v&aacute;lido'
		},
			tel_fixo: 'Voc&ecirc; n&atilde;o preencheu seu telefone',
			descricao: 'Voc&ecirc; n&atilde;o preencheu a descri&ccedil;&atilde;o'
		}
		
			
});
		
$("#form_feed_promocoes").validate({

submitHandler: function(form) {
	$(form).ajaxSubmit({
	dataType: 'html',
	
	beforeSubmit: response_promocao2,
	success: response_promocao,
	resetForm: true,
		});
	},
		rules: {
			nome: {
			required: true,
			minlength:5
		},
			email: {
			required: true,
			email: true
		}				
		},
		messages: {
			nome: {
			required: 'Voc&ecirc; n&atilde;o preencheu seu nome',
			minlength:"Digite mais de 5 caracteres"
		},
		email: {
			required: 'Voc&ecirc; precisa preencher um e-mail',
			email: 'Endere&ccedil;o de e-mail n&atilde;o v&aacute;lido'
		},
			tel_fixo: 'Voc&ecirc; n&atilde;o preencheu seu telefone',
			descricao: 'Voc&ecirc; n&atilde;o preencheu a descri&ccedil;&atilde;o'
		}
	
		});
				
});

$(document).ready(function(){
	// simple accordion		
		jQuery('#list1a').accordion({
			autoheight: false
		});
		
		// bind to change event of select to control first and seconds accordion
		// similar to tab's plugin triggerTab(), without an extra method
		var accordions = jQuery('#list1a, #list1b, #list2, #list3, #navigation, #wizard');
		
		jQuery('#switch select').change(function() {
			accordions.accordion("activate", this.selectedIndex-1 );
		});
		jQuery('#close').click(function() {
			accordions.accordion("activate", -1);
		});
		jQuery('#switch2').change(function() {
			accordions.accordion("activate", this.value);
		});
		jQuery('#enable').click(function() {
			accordions.accordion("enable");
		});
		jQuery('#disable').click(function() {
			accordions.accordion("disable");
		});
		jQuery('#remove').click(function() {
			accordions.accordion("destroy");
			wizardButtons.unbind("click");
		});
});
	
//REPASSA OS VALORES DAS MARCAS SELECIONADAS
function proximo(valor)
{   
   		
	jQuery.ajax(
		  {
		  // Especificamos o método que quermos utilizar
			type: 'POST',			
			method: "POST",
			// Especificamos o arquivo que vai processar a solicitação
			url: fullpath+'calendario_detalhe',
			// A QUERY STRING contendo os dados necessários
			data: "id=" + valor ,			
			// O que deve acontecer antes de ser enviado
			beforeSend: function(){
			  // Mostra a mensagem de carregando
			  //jQuery("#carregando").show("fast");
			},
			// O que deve acontecer quando o processo estiver completo
			complete: function(){
			  // Oculta a mensagem carregando
			  //jQuery("#carregando").hide("slow");
			},
			// Se houve sucesso vamos carregar o resultado para o argumento
			// "conteudo" para utilizá-lo onde desejarmos
			success: function(conteudo){			 
			  // jQuery("#sub_menu").html(conteudo);
			   //$('#add_not').removeAttr('style');
			    $("#calendario_tabela").html(conteudo);	
			  
			}
		  }
		);
}

//REPASSA OS VALORES DAS MARCAS SELECIONADAS
function anterior(valor)
{   
   		
	jQuery.ajax(
		  {
		  // Especificamos o método que quermos utilizar
			type: 'POST',			
			method: "POST",
			// Especificamos o arquivo que vai processar a solicitação
			url: fullpath+'calendario_detalhe',
			// A QUERY STRING contendo os dados necessários
			data: "id=" + valor ,			
			// O que deve acontecer antes de ser enviado
			beforeSend: function(){
			  // Mostra a mensagem de carregando
			 // jQuery("#carregando").show("fast");
			},
			// O que deve acontecer quando o processo estiver completo
			complete: function(){
			  // Oculta a mensagem carregando
			 // jQuery("#carregando").hide("slow");
			},
			// Se houve sucesso vamos carregar o resultado para o argumento
			// "conteudo" para utilizá-lo onde desejarmos
			success: function(conteudo){			 
			  // jQuery("#sub_menu").html(conteudo);
			   //$('#add_not').removeAttr('style');
			    $("#calendario_tabela").html(conteudo);	
			  
			}
		  }
		);
}
	
function mostra_evento(data_evento) {
	
	//redireciona o usuario para o evento selecionado
	window.location.href = fullpath+'eventos/data/'+data_evento;

}

$(document).ready(function() {
	$('a[name=modal]').click(function(e) {
		$('#table_feed_promocoes').show();
		$('#table_feed_promocoes2').hide();
		$('#feed_promocao_carregando').hide();
		$('#feed_promocao_enviado').hide();
		
		e.preventDefault();
		
		var id = $(this).attr('href');
		
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		$('#mask').fadeIn(1000);
		$('#mask').fadeTo("slow",0.8);
		
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
		
		$(id).css('top', winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
		
		$(id).fadeIn(2000);
	});
	
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});
});
