function changeFoto(album, pag, id, n)
{
if (pag >= 1 && pag <= Math.ceil(n/6))
	$('#fotos').load('actions/changeFotos.act.php?album='+album+'&pag='+pag+'&id='+id+'&n='+n);
}

function changeAlbum(cat, pag, subcat, nn, uri1, uri2)
{
if (pag >= 1 && pag <= Math.ceil(nn/3))
	$('#album').load('actions/changeAlbum.act.php?cat='+cat+'&subcat='+subcat+'&pag='+pag+'&nn='+nn+'&uri1='+uri1+'&uri2='+uri2);
}

function scrollDiv(id, tamanhodiv, dir)
{
	var obj = document.getElementById(id);
	var height = obj.offsetHeight;
	var top = obj.offsetTop;
	var width = obj.offsetWidth;
	var left = obj.offsetLeft;
	if(dir == 'up')
	{
		if(top < 0)
		{
			novo = top+3;
			if(novo > 0)
				novo = 0;
			obj.style.top = novo + "px";
		}
	}
	if(dir == 'down')
	{
		if(top-top-top+tamanhodiv < height)
		{
			novo = top-3;
			if(novo-novo-novo+tamanhodiv > height)
				novo = top;
			obj.style.top = novo + "px";
		}
	}
	if(dir == 'left')
	{
		if(left < 0)
		{
			novo = left+3;
			if(novo > 0)
				novo = 0;
			obj.style.left = novo + "px";
		}
	}
	if(dir == 'right')
	{
		if(left-left-left+tamanhodiv < width)
		{
			novo = left-3;
			if(novo-novo-novo+tamanhodiv > width)
				novo = left;
			obj.style.left = novo + "px";
		}
	}
}
function scrolar(id, tamanho, dir, rate)
{
	scrolling = self.setInterval('scrollDiv(\''+id+'\', '+tamanho+', \''+dir+'\')', rate);
}

function descrolar()
{
	scrolling = window.clearInterval(scrolling);
}

function enviaform()
{
	var nome = $('#nome').val();
	var email = $('#email').val();
	var tel = $('#tel').val();
	var cidade = $('#cidade').val();
	var assunto = $('#assunto').val();
	var mensagem = $('#mensagem').val();
	$.post("programations/ajax/contato.prog.php", {nome: nome, email: email, tel: tel, cidade: cidade, assunto: assunto, mensagem: mensagem}, function(data){
		if(data == 'true')
		{
			alert('Dados enviados com sucesso!');
			getPage('principal');
		}
		else if(data == 'false')
			alert('Não foi possível enviar seus dados, tente novamente!');
		else
			alert("ERRO!\n"+data);
	});
}
function enviaNews()
{
	var emailnews = $('#emailnews').val();
	$.post("programations/ajax/news.prog.php", {emailnews: emailnews}, function(data){
		if(data == 'true')
			alert('Cadastro realizado com sucesso!');
		else if(data == 'existe')
			alert('E-mail ja cadastrado!');
		else if(data == 'false')
			alert('Impossível cadastrá-lo no momento, verifique seu e-mail ou tente novamente mais tarde!');
		else
			alert('ERRO!');
	});
}
function verificaForm(obj)
{
	var erro = 0;
	for (var i=0; i < obj.length; i++)
	{ 
		if (obj[i].nodeName == 'INPUT' || obj[i].nodeName == 'TEXTAREA')
		{
			if(!obj[i].value)
			{
							obj[i].style.border="3px solid #FF0000";
				var label = document.getElementById('l'+obj[i].id);
				if(label)
				{
					label.innerHTML = '<span class="span_erro">preencha este campo</span>';
					erro++;
				}
			}
			else
			{
				obj[i].style.border="3px solid #FFFFFF";
				var label = document.getElementById('l'+obj[i].id);
				if(label)
					label.innerHTML = "";
			}
		}
  }
	if(erro == 0)
		obj.submit();
}

function changeImg(id, src, alt)
{
	var img = document.getElementById(id);
	img.src = src;
	img.alt = alt;
	img.title = alt;
}

var intervalo = false;
var loles = false;
function mostraformblog(fundo,form,metodo){
	document.getElementById(fundo).style.visibility=metodo;
	document.getElementById(form).style.visibility=metodo;							
}
function enviaf()
{
	if (document.getElementById('nome').value == '' || document.getElementById('email').value == '' || document.getElementById('mensagem').value == '')
	{
		alert('Todos os campos são de preenchimento obrigatório!');
	} 
	else
	{
		mostra(document.getElementById('nome').value, document.getElementById('email').value, document.getElementById('mensagem').value);
	}
}
$(document).ready(function(){
	$("#telefone").mask("(99) 9999-9999");
});