var x=0;
	var y=0;
	var cod_noticia=0;
	var tamanhoy=660;
	var tamanhox=800;
	var cod_pesquisa=0;

	var release = new Array();
	var noticia = new Array();
	var janela = new Array();
	var completo = new Array();
	var crossobj=0;
	var active_iframe=0;

	
	
	function setLogin()
	{
	}
	
	
	function trocarTagCloud(obj)
	{
		var newsrc=document.getElementById('iframe_tagcloud').src.replace(/\&cod_secao=\d+/g,"") + '&cod_secao='+obj.value;
		document.getElementById('iframe_tagcloud').src=newsrc;
	}

	function retornarValor(varName)
	{
		alert('retornar valor:'+varname);
		eval('return '+varName+';');
	}

	function dynJs(url, onloadFunction)
	{
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = url;
		if(onloadFunction) eval('script.addEventListener("load", '+onloadFunction+');');
		document.getElementsByTagName('head')[0].appendChild(script);
	}

	function rtf(rtf_tipo, extra)
	{

		x=(screen.width-500)/2;
		y=(screen.height-420)/2;
		window.open("/rtf/cria_rtf.php?rtf_tipo="+rtf_tipo+"&extra="+extra, "RTF","resizable=yes,status=no,height=420,width=500,top="+String(y)+",left="+String(x));
		return;
	}

	function onload_noticia_completo()
	{
		if(CacheControl) ler_selecao();
	}

	function rand (n)
	{
	  return (Math.floor(Math.random() * n + 1 ));
	}


	function ver_fotografia(cod_pagina, cod_noticia)
	{
//		width=810;
//		height=680;
		width=(screen.width) - 10;
		height=(screen.height) - 60;

		window.open("/fotografia/ver_fotografia.php?cod_pagina="+cod_pagina+"&cod_noticia="+cod_noticia, "ver_fotografia_"+cod_pagina, "resizable=yes, scrollbars=auto, height="+height+", width="+width+", top=0, left=0");
		return;
	}

	function ver_montagem(cod_item_montagem, cod_noticia)
	{
//		width=810;
//		height=680;
		width=(screen.width) - 10;
		height=(screen.height) - 60;

		window.open("/montagem/ver_montagem.php?cod_item_montagem="+cod_item_montagem+"&cod_noticia="+cod_noticia, "ver_fotografia_"+cod_item_montagem, "resizable=yes, scrollbars=auto, height="+height+", width="+width+", top=0, left=0");
		return;
	}

	function verificar_opener()
	{
		if(GetCookie('opener')=='1') return true;
		return false;
	}


	function visitado(cod_noticia)
	{
		if(document.getElementById(cod_noticia))
		{
			document.getElementById(cod_noticia).style.color='#6666cc';
			SetCookie('opener', '1');
		}
	}

	function apagar(cod_noticia)
	{
		document.getElementById(cod_noticia).style.color='#33cc66';

		return true;
	}


	//A PEDIDO DA ISABELLA
	function TitleToLow()
	{
		var tituloText = document.getElementById("titulo_area");
		tituloText.value = tituloText.value.toLowerCase();
	}

	function abre_fecha(nome)
	{
		var el = document.getElementById(nome);
		if (el.style.display=="none")
		{
			el.style.display="block";
			document.getElementById('img_'+nome).src="/imagens/seta_up.gif";
		}
		else
		{
			el.style.display="none";
			document.getElementById('img_'+nome).src="/imagens/seta_down.gif";
		}
	}


	function sendmail(cod_noticia)
	{
			x=(screen.width-430)/2;
			y=(screen.height-430)/2;
			window.open("/noticia/sendmail.php?cod_noticia="+cod_noticia,"SendMail","status=no,height=430,width=430,top="+String(y)+",left="+String(x));
			return false;
	}


	function abre_janela(url_ref, cod_ref)
	{
		tamanhox = 673;
		tamanhoy = 450;
		x=x+5;
		y=y+5;
		if(parent.name=='main')
		{
			if (!parent.janela[cod_ref])
			{
					janela[cod_ref]=parent.open(String(url_ref)+String(cod_ref),"janela"+String(cod_ref),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
			}
				else
			{
				if (parent.janela[cod_ref].closed)
				{
					janela[cod_ref]=parent.open(String(url_ref)+String(cod_ref),"janela"+String(cod_ref),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
				}
					else
				{
					janela[cod_ref].focus();
				}
			}
		}
		else
		{
			if (!window.janela[cod_ref])
			{
					janela[cod_ref]=window.open(String(url_ref)+String(cod_ref),"janela"+String(cod_ref),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
			}
			else
			{
				if (window.janela[cod_ref].closed)
				{
					janela[cod_ref]=window.open(String(url_ref)+String(cod_ref),"janela"+String(cod_ref),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
				}
					else
				{
					janela[cod_ref].focus();
				}
			}
		}
		if(x>50) x=0;
		if(y>50) y=0;
		return false;
	}


	function popup_message(cod_popup_message)
	{
		url_popup = "/admin/usuario/popup_message.php?cod_popup_message="+cod_popup_message;
		if (cod_noticia != 0)	url_popup += "&cod_noticia="+cod_noticia;
		x=(screen.width-360)/2;
		y=(screen.height-280)/2;
		window.open(url_popup, "popup_message_"+cod_popup_message,"resizable=yes,scrollbars=yes,status=no,height=550,width=400,top="+String(y)+",left="+String(x));
		return;
	}

	function popup_agrupamento(cod_agrupamento)
	{
		x=(screen.width-360)/2;
		y=(screen.height-280)/2;
		window.open("/noticia/ver_agrupamento.php?cod_agrupamento="+cod_agrupamento, "popup_agrupamento_"+cod_agrupamento, "resizable=yes,status=no,height=200,width=350,top="+String(y)+",left="+String(x));
		return;
	}


	function _onload_mes()
	{
		reset_top();
		parent.topmenu.Atual("omes");
		parent.topmenu.changeImages('omes', 'imagens_top/o-mes-over.gif');
	}

	function _onload_dia()
	{
		reset_top();
		ler_selecao();
	}


	function reset_top()
	{
		if((typeof parent.topmenu.changeImages)!='function')
		{
			parent.topmenu.changeImages('hoje', 'imagens_top/hoje.gif');
			parent.topmenu.changeImages('asemana', 'imagens_top/a-semana.gif');
			parent.topmenu.changeImages('omes', 'imagens_top/o-mes.gif');
			parent.topmenu.changeImages('pesquisa', 'imagens_top/pesquisa.gif');
			parent.topmenu.changeImages('ajuda', 'imagens_top/ajuda.gif');
		}
	}


	function _onload_semana()
	{
		reset_top();
		parent.topmenu.Atual("asemana");
		parent.topmenu.changeImages('asemana', 'imagens_top/a-semana-over.gif');
	}


	function _onload_pesquisa()
	{
		reset_top();
		if(parent.topmenu)
		{
			parent.topmenu.Atual("pesquisa");
			parent.topmenu.changeImages('pesquisa', 'imagens_top/pesquisa-over.gif');
		}
		ler_selecao();
	}

	function _onload_ajuda()
	{
		reset_top();
		parent.topmenu.Atual("ajuda");
		parent.topmenu.changeImages('ajuda', 'imagens_top/ajuda-over.gif');
	}


	function pdf_parte(pdf_tipo, parte)
	{
		x=(screen.width-640)/2;
		y=(screen.height-640)/2;
		window.open("/pdf/cria_pdf.php?pdf_tipo="+pdf_tipo+"&parte="+parte,"PDF","resizable=yes,status=no,height=620,width=600,top="+String(y)+",left="+String(x));
		return;
	}


	function pdf(pdf_tipo, extra)
	{
		x=(screen.width-640)/2;
		y=(screen.height-640)/2;
		window.open("/pdf/cria_pdf.php?pdf_tipo="+pdf_tipo+"&"+extra, "PDF","resizable=yes,status=no,height=620,width=600,top="+String(y)+",left="+String(x));
		return;
	}

	function pdf_oi(cod_midia,data) {
		x=(screen.width-600)/2;
		y=(screen.height-450)/2;
		window.open("/pdf/cria_pdf.php?pdf_tipo=32&extradata="+data+"&extracod_midia="+cod_midia,"PDF","resizable=yes,status=no,height=480,width=600,top="+String(y)+",left="+String(x));
		return;
	}

	function pdf_noticia(cod_noticia)
	{
		x=(screen.width-600)/2;
		y=(screen.height-450)/2;
		window.open("/pdf/cria_pdf.php?pdf_tipo=17&cod_noticia="+cod_noticia,"PDF","resizable=yes,status=no,height=480,width=600,top="+String(y)+",left="+String(x));
		return;
	}

	function checa_formpesquisa()
	{
		if (document.forms.formpesquisa.pesquisar.value!="")
			return true;
		else
			return false;

	}

	function changeImages()
	{
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}

	function _onload_login()
	{

		if(usuario_changed) eval('parent.main.location="'+usuario_changed+'";');

	}

	function _onload_hoje()
	{

		if (top.auto_abrir && !auto_abrir) auto_abrir=top.auto_abrir;
		reset_top();
		parent.topmenu.Atual("hoje");
		parent.topmenu.changeImages('hoje', 'imagens_top/hoje-over.gif');

		ler_selecao();

		if(auto_abrir) eval("mostra_noticia("+auto_abrir+");");
		if (top.auto_abrir) top.auto_abrir=false;

	}


	function mostra_noticia(cod_noticia)
	{

		x=x+5;
		y=y+5;
		url='/noticia/mostra_noticia.php?cod_noticia='+cod_noticia;
		if(cod_pesquisa>0) url+='&cod_pesquisa='+cod_pesquisa;

		if(parent.name=='main')
		{
			if (!parent.noticia[cod_noticia])
			{
				noticia[cod_noticia]=parent.open(url, "noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
			}
				else
			{
				if (parent.noticia[cod_noticia].closed)
				{
					noticia[cod_noticia]=parent.open(url, "noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
				}
					else
				{
					noticia[cod_noticia].focus();
				}
			}
		}
			else
		{
			if (!window.noticia[cod_noticia])
			{
					noticia[cod_noticia]=window.open(url, "noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));

			}
				else
			{
				if (window.noticia[cod_noticia].closed)
				{
					noticia[cod_noticia]=window.open(url, "noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
				}
					else
				{
					noticia[cod_noticia].focus();
				}
			}
		}
		if(x>50) x=0;
		if(y>50) y=0;
		return false;
	}

	function mostra_noticia_admin(cod_noticia)
	{
		x=x+5;
		y=y+5;
		tamanhox = 780;
		tamanhoy = 600;
		if (!parent.noticia[cod_noticia])
		{
			noticia[cod_noticia]=window.open("/noticia/mostra_noticia.php?cod_noticia="+cod_noticia,"noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
		}
			else
		{
			if (parent.noticia[cod_noticia].closed)
			{
				noticia[cod_noticia]=window.open("/noticia/mostra_noticia.php?cod_noticia="+cod_noticia,"noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
			}
				else
			{
				noticia[cod_noticia].focus();
			}
		}
		if(x>50) x=0;
		if(y>50) y=0;

	}

	function mostra_noticia_pfl(cod_noticia)
	{
		x=x+5;
		y=y+5;
		tamanhox = 673;
		tamanhoy = 450;
		noticia=window.open("/noticia/mostra_noticia.php?cod_noticia="+cod_noticia,"noticia"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top="+String(y)+",left="+String(x));
		noticia.focus();
		if(x>50) x=0;
		if(y>50) y=0;
		return false;
	}


	function iframe_src(obj, url)
	{
		command='document.getElementById("'+obj+'").src';
		eval('if('+command+'!="'+url+'") '+command+'="'+url+'";');
	}


	function iframe_show(obj, status)
	{
		if(status)
		{
			active_iframe=obj;
			document.getElementById(obj).style.visibility = "visible";
//			document.getElementById(obj).focus();
		}
			else
		{
			document.getElementById(obj).style.visibility = "hidden";
		}
	}

	function getPageSize()
	{
		var x,y;

		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}


		var x1,y1;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) // all but Explorer Mac
		{
			x1 = document.body.scrollWidth;
			y1 = document.body.scrollHeight;
		}
		else // Explorer Mac;
			 //would also work in Explorer 6 Strict, Mozilla and Safari
		{
			x1 = document.body.offsetWidth;
			y1 = document.body.offsetHeight;
		}

		arrayPageSize = new Array(x,y,x1,y1)
		return arrayPageSize;
	}



	function layer_show(obj, status)
	{
		if(document.getElementById(obj))
		{
			if(userbrowser=='msie')
			{
				if(status)
				{
					command=obj+'.style.visibility = "visible";';
				}
					else
				{
					command='if('+obj+') '+obj+'.style.visibility = "hidden";';
				}

				eval(command);
				return true;
			}

			if(userbrowser=='mozilla')
			{
				if(typeof(obj)!='undefined')
				{
					if(status)
					{
						command='document.getElementById("'+obj+'").style.visibility = "visible";';
					}
						else
					{
						command='document.getElementById("'+obj+'").style.visibility = "hidden";';
					}
					eval(command);
					return true;
				}
			}
		}

		return false;
	}

	function findPosX(objtext)
	{
		if(document.getElementById(objtext))
			var obj=document.getElementById(objtext);
			else var obj=objtext;

		if(obj.layerX)
		{
			return obj.layerX;
		}
			else
		{
			var curleft = 0;
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
			return curleft;
		}
	}

	function findPosY(objtext)
	{
		if(document.getElementById(objtext))
			var obj=document.getElementById(objtext);
			else var obj=objtext;

		if(obj.layerY)
		{
			return obj.layerY;
		}
			else
		{
			var curtop = 0;
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
			return curtop;
		}
	}


	function findHeight(objtext)
	{
		var obj=document.getElementById(objtext);
		var Height = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				Height = obj.offsetHeight;
				obj = obj.offsetParent;
			}
		}
			else
		{
			if (obj.height) Height = obj.height;
		}

		return Height;
	}

	function findWidth(objtext)
	{
		var obj=document.getElementById(objtext);
		var Width = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				Width = obj.offsetWidth;
				obj = obj.offsetParent;
			}
		}
			else
		{
			if (obj.width) Width = obj.width;
		}

		return Width;
	}

	function mostrar_box_comenta()
	{

		iframe_show('iframecomenta', 1);
		iframe_src('iframecomenta', "/admin/box_comenta.php?cod_midia="+cod_midia+"&cod_noticia="+cod_noticia);
	}


	function mostra_completo(cod_noticia)
	{
		if (!window.completo[cod_noticia])
		{
			completo[cod_noticia]=window.open("/noticia/mostra_completo.php?cod_noticia="+cod_noticia, "completo"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top=50,left=50");
		}
			else
		{
			if (window.completo[cod_noticia].closed)
			{
				completo[cod_noticia]=window.open("/noticia/mostra_completo.php?cod_noticia="+cod_noticia, "completo"+String(cod_noticia),"resizable=yes,fullscreen=0,scrollbars=1,height="+String(tamanhoy)+",width="+String(tamanhox)+",top=50,left=50");
			}
				else
			{
				completo[cod_noticia].focus();
			}
		}
		return false;
	}


	function createSpan()
	{
		if(!document.getElementById('dumpView'))
		{
			var y = document.createElement('span');

			y.id = 'dumpView';
			y.style.position='absolute';
			y.style.left=0;
			y.style.top=0;
			y.style.background='white';
			y.style.width=500;
  			y.style.height=500;
  			y.style.zIndex=9999;
  			y.style.fontSize=9;
 			y.style.fontFamily='Verdana';

			var a = y.appendChild(document.createElement('span'));
			a.id = 'contentheader';
			y.innerHTML = msg;
			document.getElementsByTagName('body')[0].appendChild(y);
		}
	}

	function showProps(obj)
	{
		var msg='<PRE>'+dumpProps(obj)+'</PRE>';
		var w=window.open('');
		w.document.write('<HTML><BODY>' + msg + '</BODY></HTML>');
	}

	function dumpProps(obj)
	{
		var msg='';
		for(var i in obj)
		{
			//if (typeof obj[i] != "function")
			{
				msg+=i+" ["+typeof obj[i]+"] :"+obj[i]+"\n";

				if (typeof obj[i] == "object")
				{
					eval('var objb=obj.'+i+';');
					for(var ib in objb)
					{
						msg+="\t"+ib;
					}
				}
			}
		}
		return msg;
	}


	function sleep(numberMillis)
	{
		/*
		if(userbrowser=='msie')
		{
			var dialogScript =
	           'window.setTimeout(' +
	           ' function () { window.close(); }, ' + numberMillis + ');';

	        var result =
	         window.showModalDialog(
	           'javascript:document.writeln(' +
	            '"<script>' + dialogScript + '<' + '/script>")');
		 }*/
	}

	function apagarPesquisaRec(cod)
	{
		if (window.confirm("Você deseja mesmo apagar a pesquisa?"))
		{
			window.location='/pesquisa/popup-minhaspesquisas.php?apagar_pesquisa='+cod;
		}
	}


	function trim(str)
	{
		return str.replace(/^\s*|\s*$/g,"");
	}

	function SetCookie(cookieName, cookieValue)
	{

		var today = new Date();
		var expire = new Date();
		var nDays=360;

		expire.setTime(today.getTime() + 3600000 * 24 * nDays);
		document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
	}

	function GetCookie(cookieName)
	{
		var cookie_array = document.cookie.split(';');

		for(n=0;n<cookie_array.length;n++)
		{
			var cookie_val=cookie_array[n].split('=');
			if(trim(cookie_val[0])==cookieName) return trim(cookie_val[1]);
		}

		return false;
	}