$(document).ready(function() {	

    $('#slider1').s3Slider({
        timeOut: 4000 
    });
    /**
     * NewsLetter
     */
	$("#assine").click(function(){
	
		//$("#formnews").validate();
		
		$.ajax({
			type:'POST',
			url:'index/newsletter',
			data:'acao=0&news='+$("#news").val(),
			dataType: "html",
			beforeSend: function(){
				$("#response").html('<img src="public/imgs/carrega.gif">');
			},
			success: function(response){
				$("#response").html(response);
				$("#carrega").html('');
			},
			error: function(){
				alert('ocorreu um erro');
			}
		});
	});	
	/**
	 * Contato
	 */
	$("#contato").click(function()
	{
		alert('contato');
		$.ajax(
		{
			type:'POST',
			url:'index/contato',
			data:'nome='+$("#nome").val+'&email='+$("#email").val+'&assunto='+$("#assunto").val+'&msg='+$("#msg").val,
			dataType: "html",
			beforeSend: function(){
				$("#carrega").html('&nbsp;&nbsp;&nbsp;<img src="public/imgs/carrega.gif">');
			},
			success: function(response)
			{
				$("#result"+parametro).html(response);
				$("#carrega").html('');
			},
			error: function()
			{
				alert('ocorreu um erro');
			}
		});
	});
    /**
     * Busca Associado
     */
	$("#buscaAssociado").click(function()
	{

		$.ajax(
		{
			type:'POST',
			url:'index/buscaassociado',
			data:'estado='+$("#estado").val()+'&cultura='+$("#cultura").val(),
			dataType: "html",
			beforeSend: function(){
				$("#carrega").html('&nbsp;&nbsp;&nbsp;<img src="public/imgs/carrega.gif">');
			},  
			success: function(response){
				$("#ajax").html(response);
				$("#carrega").html('');
			},
			error: function(){
				alert('ocorreu um erro');
			}
		});
		
	});
	/**
	 * 
	 */
	$('a[name=modal]').click(function(e) {
		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(1000); 
	
	});
	/**
	 * 
	 */
	$('.window .close').click(function (e) {
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	/**
	 * 
	 */
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});		
		
});
/**
 * Detalhes do Informativo
 */
function informativodetalhe(parametro)
{
	$.ajax(
	{
		type:'POST',
		url:'index/informativodetalhe',
		data:'id='+parametro,
		dataType: "html",
		beforeSend: function()
		{
			$("#carrega").html('&nbsp;&nbsp;&nbsp;<img src="public/imgs/carrega.gif">');
		},  
		success: function(response)
		{
			$("#ajax").html(response);
			$("#carrega").html('');
		},
		error: function()
		{
			alert('ocorreu um erro');
		}
	});
}
/**
 * Links do Menu
 */
function link(action, titulo)
{
	$.ajax({
		type:'GET',
		url:'index/'+action,
		data:'titulo='+titulo,
        dataType: "html",
        beforeSend: function(){
            $("#carrega").html('&nbsp;&nbsp;&nbsp;<img src="public/imgs/carrega.gif">');
        },  
		success: function(response){
			$("#ajax").html(response);
			$("#carrega").html('');
		},
		error: function(){
			alert('ocorreu um erro');
		}
	});
}