function changeMonth(set)
{
	mes += set;
	if(mes == 0)
	{
		mes = 12;
		ano -= 1;
	}
	else if(mes == 13)
	{
		mes = 1;
		ano += 1;
	}
	dia_falso = (mes == mes_atual)?dia:32;
	$('#calendario').load('includes/calendario.inc.php?ajax&dia='+dia_falso+'&mes='+mes+'&ano='+ano);
}
function enviaNews()
{
	if(a)
		$.post('ajax/news.ajax.php', {email: $('#email_news').val()}, function(data){
				alert(data);
				$('#email_news').val('');
		});
	else
		alert('Digite seu email para receber nossos informativos.');
}
function buscarArtigo()
{
	var q = $('#buscar').val();
	
	if(b)
		if(q.length >= 2)
			$.post('ajax/buscar.ajax.php', {str: q}, function(data){
				if(data == 'false')
					alert('Não foram encontrados artigos com "'+q+'".');
				else
					window.location.href=data;
			});
		else
			alert('São necessários ao menos 2 caracteres para buscar!');
	else
		alert('Digite uma palavra ou frase para buscar.');
}
function enviaContato(id)
{
	var arr = Array(5); 
	arr = {'nome': '', 'email': '', 'telefone': '', 'cidade': '', 'mensagem': ''};
	$('#'+id+' input[type=text], textarea').each(function(i){
		arr[$(this).attr('name')] = $(this).val();
	});
	$.post('ajax/contato.ajax.php', arr, function(data){
		if(data == 'true')
		{
			alert('Dados enviados com sucesso!');
			$('#'+id+' input[type=text], textarea').val('');
		}
		else
			alert(data);
	});
}

///////////SCROLLDIV////////////
var slide_id = 0;
var inter = {};
var timeout = {};
function initSlideShow(id, pos, tempo, tempofade, controls, opt)
{
	slide_id++;
	$('#'+id).append('<div class="rotator" />');
	if(controls === true && $('#'+id+' img:hidden').length > 1)
	{
		$('#'+id).append('<div class="controls" />');
		$('#'+id+' img:hidden').each(function(i){
			$('#'+id+' .controls').append('<a href="javascript: void(0);" rel="'+slide_id+'">'+(i+1)+'</a>'+((i < $('#'+id+' img').length-1)?' | ':''));
		});
		$('#'+id+' .controls a').each(function(i){
			$(this).bind('click', function(){
				clearTimeout(inter[$(this).attr('rel')]);
				clearTimeout(timeout[$(this).attr('rel')]);
				slideShow(id, i+1, tempo*2, tempofade, controls, opt, true, $(this).attr('rel'));
				$('#'+id+' .controls a').removeClass('sel');
				$(this).addClass('sel');
			});
		});
	}
	slideShow(id, pos, tempo, tempofade, controls, opt, false, slide_id);
}
function slideShow(id, pos, tempo, tempofade, controls, opt, force, slide_id)
{
	if(controls === true && $('#'+id+' img:hidden').length > 1)
	{
		$('#'+id+' .controls a').removeClass('sel');
		$('#'+id+' .controls a:eq('+(pos-1)+')').addClass('sel');
	}
	if(opt == 'trans')
	{
		$('#'+id+' .rotator').html($('#'+id+' img:hidden:eq('+(pos-1)+')').clone(true).css({display: 'block'}));
		$('#'+id+' .rotator').append($('#'+id+' img:hidden:eq('+(((pos >= $('#'+id+' img:hidden').length)?1:pos+1)-1)+')').clone(true).css({display: 'none'}));
		if($('#'+id+' img:hidden').length > 1)
			timeout[slide_id] = setTimeout(function(){ $('#'+id+' .rotator img:first').animate({opacity: 0.0}, tempofade, "linear", function(){ $(this).css({display: 'none'}); }); $('#'+id+' .rotator img:last').css({display: 'block', opacity: '0.0'}).animate({opacity: 1.0}, tempofade, "linear"); }, tempo-tempofade);
	}
	else if(opt == 'fade')
	{
		$('#'+id+' .rotator').html($('#'+id+' img:hidden:eq('+(pos-1)+')').clone(true).css({display: 'block', opacity: 0.0}).animate({opacity: 1.0}, tempofade/2))
		timeout[slide_id] = setTimeout(function(){ $('#'+id+' .rotator img').animate({opacity: 0.0}, tempofade/2); }, tempo-tempofade/2);
	}
	if($('#'+id+' img:hidden').length > 1)
		inter[slide_id] = setTimeout(function(){ block = false; slideShow(id, (pos >= $('#'+id+' img:hidden').length)?1:pos+1, ((force === true)?tempo/2:tempo), tempofade, controls, opt, false, slide_id); }, tempo);
}
////////////////////////////////////
