$(function(){
	
	/* Inicia funções principais  */
    /* ====================================================================== */
	
	initPNG();
	initMask();
	
	
	/* Busca as cidades conforme o estado */
	/* ====================================================================== */
	
	$("#formulario #estado").change(function(){
		retornaCidades("#estado", "#cidade", "", null);					 
	});
		
});

function initMask()
{
	$(".mask_data").mask("99/99/9999");
	$(".mask_fone").mask("(99) 9999-9999");
	$(".mask_cpf").mask("999.999.999-99");
	$(".mask_num").mask("99");
	$(".mask_cep").mask("99999999");
}

function initPNG()
{
	$(document).pngFix();
}

function abreComm(d)
{
	$(d).slideToggle("normal");	
}

function abreAba(n)
{
	$("#postagens div.posts").each(function(){
		
		var obj = $(this);	
		var ids = obj.attr("id");
		
		if ("post_"+n == ids)
		{
			obj.show();
		}
		else
		{
			obj.hide();
		}
		
	});
}

function preencheLegenda(t)
{
	$("#legenda").empty().html(t);	
}

function indexTopo(z1, z2)
{
	$(".fullbanner").css("z-index", z1);
	$(".menu").css("z-index", z2);
}

function carregaClip(p)
{
	$(".cont-promo").slideUp("normal", function(){
		
		var int;
		var pag;
		var qry;
		
		$(".load-promo").slideDown("normal");
		
		if (p.indexOf("?") > 0)
		{
			int = p.split("?");
			pag = int[0].substring(0, int[0].length);
			qry = p.substring(int[0].length, p.length);
		}
		else
		{
			int = "";
			pag = p;
			qry = "";
		}
		
		$.ajax({
			url: pag+".php"+qry,
			cache: false,
			dataType: 'html',
			data: { localhost: 0 },
			success: function(html){
				
				$(".load-promo").slideUp("normal", function(){
					$(".cont-promo").slideDown("normal"); 
					$(".cont-promo").empty().append(html);
					$.include('../js/gampi.site.js');
				}); 
				
			}
		});	
		
	}); 
}
