	var tgs = new Array('div');
	var szs = new Array('xx-small','x-small','small','medium','large','x-large','xx-large');
	var startSz = 2;
	var janela = null;
	var xmlhttpc = new Array();
	var dreclames = new Array();
	var dgaleria = new Array();

	function doContagem(obj,painel)
	{
		var a = document.getElementById(obj);
		var b = document.getElementById(painel);
		var c = 1024;
		c = c-a.value.length;
		if (c<=0)
		{
			b.innerHTML = 'Seu texto <b>N&Atilde;O</b> pode ultrapassar 1024 caracteres!';
			a.value = a.value.substring(0,1024);
		}
		else if (c>1)
			b.innerHTML = 'Seu texto ainda pode conter <b>'+c+'</b> caracteres.';
		else
			b.innerHTML = 'Seu texto ainda pode conter <b>'+c+'</b> caractere.';
	}
	
	function lerCookie(name)
	{
		var cookieValue = null;
		var search = name + "=";

		if (document.cookie.length > 0)
		{
			offset = document.cookie.indexOf(search);
			if (offset != -1)
			{ 
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
			}
		}
		return cookieValue;
	}
	
	function salvaCookie(name, value, hours)
	{
		var expire = "";
		if (hours != null)
		{
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = "; expires=" + expire.toGMTString();
		}
		document.cookie = name + "=" + escape(value) + expire;
	}	
	
	function doTamanhoLetra(trgt,inc)
	{
		var d = document,cEl = null,sz = startSz,i,j,cTags;
		if (inc==0)
		{
			var tmpTamanho = lerCookie("tamanho_"+trgt);
			if ((tmpTamanho!="undefined")&&(tmpTamanho!=null))
			{
				sz = parseInt(tmpTamanho);
				startSz = sz;
			}
		}
		else
		sz += inc;
		if ( sz < 0 ) sz = 0;
		if ( sz > 6 ) sz = 6;
		startSz = sz;
		if ( !( cEl = d.getElementById(trgt) ) ) cEl = d.getElementsByTagName(trgt)[0];
		if (cEl != null)
		{
			cEl.style.fontSize = szs[ sz ];	

			for ( i = 0; i < tgs.length; i++ )
			{
				cTags = cEl.getElementsByTagName(tgs[i]);
				for (j=0; j<cTags.length; j++)
					cTags[j].style.fontSize = szs[sz];
			}
			
			salvaCookie("tamanho_"+trgt, sz, 24);
		}
	}
	
	function doAjusta()
	{
		var tam = document.getElementById("corpo").offsetHeight - 300 - document.getElementById("conteudo").offsetHeight;
		if (tam<1) tam = 1;
		document.getElementById("largura").height = tam;
	}

	function doShow(obj)
	{
		o = document.getElementById(obj);
		o.style.visibility = "visible";
		o.style.display = "inline";		
	}
	
	function doHide(obj)
	{
		o = document.getElementById(obj);
		o.style.visibility = "hidden";
		o.style.display = "none";		
	}	

	function doFotoAjuste()
	{		
		var objFoto = document.getElementById('tmpFoto');

		doShow('foto');
		doHide('carregaFoto');

		if (objFoto.height > 300)
		{
			objFoto.height = 300;
			objFoto.style.height = 300;
		}

		else if (objFoto.width > 390)
		{
			objFoto.width = 390;
			objFoto.style.width = 390;
		}

	}

	function doFoto(caminho)
	{
		doShow('carregaFoto');
		document.getElementById("foto").innerHTML = "<a href='javascript:window.close();' alt='Clique para fechar'><img id='tmpFoto' src='"+caminho+"' onload='doFotoAjuste();' border='0' ></a>";
		doHide('foto');		
	}
	function doVideo(caminho)
	{
		document.getElementById("foto").innerHTML = "<OBJECT  ID='mediaPlayer'  CLASSID='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'  CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'  STANDBY='Carregando...' height='360' width='420'><PARAM NAME='fileName'   VALUE='"+caminho+"'><PARAM NAME='animationatStart' VALUE='true'><PARAM NAME='transparentatStart' VALUE='true'><PARAM NAME='autoStart' VALUE='true'><PARAM NAME='showControls' VALUE='true'><PARAM NAME='showStatusBar' value='true'><embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/' src='"+caminho+"' autostart='true' showcontrols='true' showstatusbar='true' showdisplay='False' autorewind='true' height='360' width='420'></embed></OBJECT>";
	}

	var delayLoadRegistry=[];
	var delayLoadCompleted=[];

	function delayLoad(id,img,src)
	{
		delayLoadRegistry[delayLoadRegistry.length]=[id,img,src];
		delayLoadCompleted[id]=false;
	}

	function performDelayLoad(id)
	{
		if(!delayLoadCompleted[id])
		{
			delayLoadCompleted[id]=true;
			for(var i=0;i<delayLoadRegistry.length;i++)
			{
				if(delayLoadRegistry[i][0]==id)
				{
					delayLoadRegistry[i][1].onload="";
					delayLoadRegistry[i][1].src=delayLoadRegistry[i][2];
				}
			}
		}
	}

	try	{ xmlhttp = new XMLHttpRequest(); }	catch(ee) {
		try	{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e)	{
			try	{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { xmlhttp = false; } } }

	function doCadastro(msg)
	{
		var field = document.getElementById("email");
		var n = document.getElementById("nome");
		var str = field.value;
		var passou = false;
		if (window.RegExp)
		{
			var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
			var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
			var reg1 = new RegExp(reg1str);
			var reg2 = new RegExp(reg2str);

			if (!reg1.test(str) && reg2.test(str))
      			passou = true;
			else if (str.indexOf("@") >= 0)
				passou = true;
			if (passou==false)
			{
				field.focus();
				field.select();
				window.alert(msg);
			}
			else
			{
				var c1 = document.getElementById("cadCampos");
				c1.style.visibility = 'hidden';
				c1.style.display = 'none';

				var c1 = document.getElementById("cadCarregando");
				c1.style.visibility = 'visible';
				c1.style.display = '';

				xmlhttp.open("GET", "cadastro.php?nome="+n.value+"&email="+field.value+"&refresh="+Math.random(),true);
				xmlhttp.onreadystatechange = function()
				{
					if (xmlhttp.readyState==4)
					{
						var c2 = document.getElementById("cadCarregando");
						c2.style.visibility = 'hidden';
						c2.style.display = 'none';
						var c3 = document.getElementById("cadOk");
						c3.style.visibility = 'visible';
						c3.style.display = '';
					}
				}
				xmlhttp.send(null);
			}
		}
	}

	function doVerifica(obj1, obj2)
	{
		var o1 = document.getElementById(obj1);
		var o2 = document.getElementById(obj2);
		if (o1.value=="")
			o2.disabled = true;
		else
			o2.disabled = false;
	}
	
	function doJanela(url)
	{
		winwidth  = 550;
		winheight = 380;
		winleft   = 200;
		wintop    = 200;
  
		winleft = (screen.width / 2) - (winwidth / 2);
		wintop = (screen.height / 2) - (winheight / 2);

		janela = window.open(url, 'janela', 'scrollbars=no, top=' + wintop + ',left=' + winleft + ',height=' + winheight + ',width=' + winwidth);		
		janela.focus();
	}
	
	function doCarregar(obj)
	{
		try	{ xmlhttpc[obj] = new XMLHttpRequest(); }	catch(ee) {
			try	{ xmlhttpc[obj] = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e)	{
				try	{ xmlhttpc[obj] = new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { xmlhttpc[obj] = false; } } }
		
		var c1 = document.getElementById(obj);
		if (c1 != null)
		{
			c1.innerHTML = '<div align="center"><img src="images/carregando.gif" border="0" /><br />Carregando...</div>';
			xmlhttpc[obj].open("GET", "carregar.inc.php?id="+obj+"&refresh="+Math.random(),true);
			xmlhttpc[obj].onreadystatechange = function()
			{
				if (xmlhttpc[obj].readyState==4)
				{
					var d1 = document.getElementById(obj);
					if (obj=='reclames')
					{
						var codigoHTML = '';
						dreclames = eval((xmlhttpc[obj].responseText));
						var d3 = document.getElementById('mostraReclames');
						if (dreclames.length >0)
						{
							for(var i=0;i<dreclames.length;i++)
							{
								dreclames[i][0] = unescape(dreclames[i][0]);
								dreclames[i][1] = unescape(dreclames[i][1]);
								dreclames[i][2] = unescape(dreclames[i][2]);
								
								var textoReclame = dreclames[i][2];
								if (textoReclame.length>23)
									textoReclame = textoReclame.slice(0,20)+'...';

								codigoHTML = codigoHTML + '<div id="reclame'+i+'_normal" style="display:none;visibility:hidden"><table width="100%" border="0" cellspacing="0" cellpadding="0">' +
								'<tr><td height="1" class="reclames_nome" onmouseover="doReclame('+i+',true);" onmouseout="doReclame('+i+',false);">'+dreclames[i][1]+'</td></tr>' +
								'<tr><td height="1" class="reclames_titulos" onmouseover="doReclame('+i+',true);" onmouseout="doReclame('+i+',false);"><a href="javascript:openReclame('+i+')">'+dreclames[i][2]+'</a></td></tr>' +
								'<tr><td height="2" background="images/separador.gif"><img src="images/pixel.gif" width="1" height="1" /></td></tr>' +
								'</table></div>';

								codigoHTML = codigoHTML + '<div id="reclame'+i+'_contraido"><table width="100%" border="0" cellspacing="0" cellpadding="0">' +
								'<tr><td height="1" class="reclames_nome" onmouseover="doReclame('+i+',true);" onmouseout="doReclame('+i+',false);">'+dreclames[i][1]+'</td></tr>' +
								'<tr><td height="1" class="reclames_titulos" onmouseover="doReclame('+i+',true);" onmouseout="doReclame('+i+',false);"><a href="javascript:openReclame('+i+')">'+textoReclame+'</a></td></tr>' +
								'<tr><td height="2" background="images/separador.gif"><img src="images/pixel.gif" width="1" height="1" /></td></tr>' +
								'</table></div>';
							}
							
							d3.style.display = '';
							d3.style.visibility = 'visible';
						}
						else
						{
							d3.style.display = 'none';
							d3.style.visibility = 'hidden';
						}
						d1.innerHTML = codigoHTML;
					}
					else
					{
						d1.innerHTML = xmlhttpc[obj].responseText;
					}
				}
			}
			xmlhttpc[obj].send(null);	
		}
	}

	function doGaleria(obj,pagina)
	{
		try	{ xmlhttpd = new XMLHttpRequest(); }	catch(ee) {
			try	{ xmlhttpd = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e)	{
				try	{ xmlhttpd = new ActiveXObject("Microsoft.XMLHTTP"); } catch(E) { xmlhttpd = false; } } }
		
		var g1 = document.getElementById(obj);
		if (g1 != null)
		{
			g1.innerHTML = '<div align="center"><img src="images/carregando.gif" border="0" /><br />Carregando...</div>';
			xmlhttpd.open("GET", "carregar.inc.php?id="+obj+"&pagina="+pagina+"&refresh="+Math.random(),true);
			xmlhttpd.onreadystatechange = function()
			{
				if (xmlhttpd.readyState==4)
				{
					var h1 = document.getElementById(obj);
					var codigoHTML = '<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">';
					var h2 = document.getElementById('btGaleria');
					h2.innerHTML = '<a href="javascript:doGaleria(\'galeria\',0);">Atualizar</a>';
					dgaleria = eval((xmlhttpd.responseText));
					var j = dgaleria.length;
					var l = 0;
					
					if(j==1) 
						l = 1;
					else
						l = j-1;
						
					if (j >0)
					{
						for(var i=0;i<l;i++)
						{
							dgaleria[i][0] = unescape(dgaleria[i][0]);
							dgaleria[i][1] = unescape(dgaleria[i][1]);
							dgaleria[i][2] = unescape(dgaleria[i][2]);
							dgaleria[i][3] = unescape(dgaleria[i][3]);
							dgaleria[i][4] = unescape(dgaleria[i][4]);
							dgaleria[i][5] = unescape(dgaleria[i][5]);
														
							codigoHTML = codigoHTML + '<tr><td width="38" valign="middle"><a href="javascript:doJanela(\'galeria.inc.php?idcanal='+dgaleria[i][0]+'&idgaleria='+dgaleria[i][1]+'&idfoto='+dgaleria[i][2]+'\');"><img src="admin/'+dgaleria[i][3]+'" width="38" border="0" /></a></td>' +
														  '<td height="1" align="left" valign="middle"><a href="javascript:doJanela(\'galeria.inc.php?idcanal='+dgaleria[i][0]+'&idgaleria='+dgaleria[i][1]+'&idfoto='+dgaleria[i][2]+'\');"><div class="reclames_nome">'+dgaleria[i][4]+'</div><div class="reclames_titulos">'+dgaleria[i][5]+'</div></a></td></tr>';
							if (i!=(l-1))
							codigoHTML = codigoHTML + '<tr><td height="5"><img src="images/pixel.gif" width="1" height="1" /></td><td height="5" align="center" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5"><tr><td height="1"><img src="images/pixel.gif" width="1" height="1" /></td></tr></table></td></tr>';
						}	
						if (pagina > 0)
						{
							if (j==5)
								h2.innerHTML = '<a href="javascript:doGaleria(\'galeria\','+(pagina-1)+');">Anterior</a> | <a href="javascript:doGaleria(\'galeria\','+(pagina+1)+');">Pr&oacute;xima</a>';
							else
								h2.innerHTML = '<a href="javascript:doGaleria(\'galeria\','+(pagina-1)+');">Anterior</a>';
						}
						else
						if (j==5)
							h2.innerHTML = '<a href="javascript:doGaleria(\'galeria\','+(pagina+1)+');">Pr&oacute;xima</a>';
							
					}
					else
					{
						codigoHTML = codigoHTML + '<tr><td height="5"><div align="center">Nenhuma galeria!</div></td></tr>';
						if (pagina > 0)
							h2.innerHTML = '<a href="javascript:doGaleria(\'galeria\','+(pagina-1)+');">Anterior</a>';
					}
					codigoHTML = codigoHTML + '</table>';
					h1.innerHTML = codigoHTML;
				}				
			}
			xmlhttpd.send(null);	
		}
	}

	function doAnuncios(tempo)
	{
		window.status = 'Carregando anúncios...';
		doCarregar('banner_superior');
		doCarregar('banner_conteudo');
		doCarregar('banner_lateral');
		window.status = '';
		setTimeout('doAnuncios('+tempo+')', tempo);
	}
	
	function doReclame(indice,completo)
	{	
		var e1n = document.getElementById('reclame'+indice+'_normal');
		var e1c = document.getElementById('reclame'+indice+'_contraido');
		if (completo)
		{
			e1n.style.display = '';
			e1n.style.visibility = 'visible';
			
			e1c.style.display = 'none';
			e1c.style.visibility = 'hidden';
		}
		else
		{
			e1c.style.display = '';
			e1c.style.visibility = 'visible';

			e1n.style.display = 'none';
			e1n.style.visibility = 'hidden';			
		}
	}