var Geral = {

	__construct: function() {
		_this = Geral;
		$.ifixpng('pics/pixel.gif');
		$('div.thumbs,img[@src$=.png]').ifixpng(); //png transparent no IEca
		$("input[type='text'],textarea").resetDefaultValue();
		$("input[type='text']").addClass("text");
	}

}

$(document).ready(function(){
	Geral.__construct();
	
	/*Mural HOME*/
	$('.title-recado a').click(function(){
		$('#mural-home').hide().show(600).load('mural_envia.php?retorno=mensagemSite.php&div=mural-home');
		return false;
		
	})
	

		/*Mural Interna*/
		$('#recado a').click(function(){
		$('#mural-interna').hide().show(600).load('mural_envia.php?retorno=mural-interna.php&div=mural-interna');
		return false;
		
	})
	
	
	$('input[name=incluir]').click(function(){
		end = $('#formnews').attr('action');
		$.post(end,
			   $('#formnews').serialize(),
			   function(data){
					$('#result').html(data);   
			   })	
		
	})

	/*************CLASSIFICADOS*****************/
	$('.classifikites li').hover(function(){
		$(this).css('cursor','pointer');
	},function(){
		$(this).css('cursor','none');
	})
	
	$('.classifikites li').click(function(){
		$('.classifikites li').fadeTo('fast','0.4');
    	$(this).fadeTo('fast','1.0');
		var idCat = $(this).attr('value');
		$.post('exibe_classificados.php',
			   {idCategoria:idCat},
			   function(data){
			   	$('#anuncios').html(data);
			   })
	})
	
	$('#bt-anunciar').click(function(){
		$('#anuncios').load('meusAnuncios_classificados.php');
		return false;
	})
	
	$('#bt-cadastro').click(function(){
		$('#anuncios').load('cadastro.php');
		return false;
	})
		
	$('#bt-meuAnuncios').click(function(){
		$('#anuncios').load('meusAnuncios_classificados.php');
	})
	
	

});

function Formata_rs(campo,tammax,teclapres,decimal) {
var tecla = teclapres.keyCode;
vr = Limpar(campo.value,"0123456789");
tam = vr.length;
dec=decimal

if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

if (tecla == 8 )
{ tam = tam - 1 ; }

if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
{

if ( tam <= dec )
{ campo.value = vr ; }

if ( (tam > dec) && (tam <= 5) ){
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 6) && (tam <= 8) ){
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
}
if ( (tam >= 9) && (tam <= 11) ){
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 12) && (tam <= 14) ){
campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 15) && (tam <= 17) ){
campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
}

}

function Limpar(valor, validos) {
// retira caracteres invalidos da string
var result = "";
var aux;
for (var i=0; i < valor.length; i++) {
aux = validos.indexOf(valor.substring(i, i+1));
if (aux>=0) {
result += aux;
}
}
return result;
}

/* animação setas esq e dir*/
	$('#animacao .j-img').cycle({ 
		fx:'fade',
		timeout: 9000,
		pager: '#bt-animacao',
		cleartypeNoBg: true	
	});
