// PortalStructure
// This object get header/footer informations and provide methods to
// print informations on HTML structure
PortalStructure = {
	show: undefined,
	htmlHeader: "",
	htmlFooter: "",

	printHeader: function() {
		if (PortalConfiguration == undefined) { return false; }
		this.mountHeader();
		document.write(this.htmlHeader);
	},
	printFooter: function() {
		if (PortalConfiguration == undefined) { return false; }
		this.mountFooter();
		document.write(this.htmlFooter);
	},

	init: function() {
		if (PortalConfiguration == undefined) { return false; }
		this.show = PortalConfiguration.show;

		var cssIncludes = "";
		if (this.show.defaultStyles) {
			if (PortalConfiguration.getNavigatorType() == 1) {
					cssIncludes += '<link href="headerportal/css/default_txt.css" rel="stylesheet" type="text/css" />\n';
			} else if (PortalConfiguration.getNavigatorType() == 3) {
					cssIncludes += '<link href="headerportal/css/default.css" rel="stylesheet" type="text/css" />\n';
					cssIncludes += '<link href="headerportal/css/barra.css" rel="stylesheet" type="text/css" />\n';
			}
		}
		
		var jsIncludes = "";
		if (this.show.infoInstante) {
			jsIncludes += '<script type="text/javascript" src="headerportal/js/infocge.js"><\/script>\n';
		}
		if (this.show.search) {
			jsIncludes += '<script type="text/javascript" src="headerportal/js/busca.js"><\/script>\n';
		}
		
		document.write(jsIncludes+cssIncludes);
	},
	mountHeader: function() {
		this.htmlHeader += '<!-- inicio header -->\n';
		this.htmlHeader += '<div id="wrap">\n';
		this.htmlHeader += '  <div id="bprint"><img src="headerportal/img/print_topo_lgp.gif" alt="Logotipo do Portal" width="267" height="60" /><\/div>\n';
		if (this.show.header) {
			this.htmlHeader += '  <div id="btop">\n';
			if (this.show.infoInstante) {
				var urlAbsolute = '//'+topo_abspath;
				var infoCGE = (document.location.protocol == 'http:') ? '<a href="http://www.cgesp.com.br/">'+topo_alerta+'</a>' : topo_alerta;

				var infoInstante = "";
				if (topo_temperaturaMedia) {
					infoInstante += '<a href="//www.prefeitura.sp.gov.br/servicos/cidadaos/meio_ambiente/clima/index.php"><img src="'+urlAbsolute+'/'+topo_tempoImg+'" alt="'+topo_tempoMsg+'" width="18" height="17" title="'+topo_tempoMsg+'" border="0" /> '+topo_temperaturaMedia+'&deg;C</a>';
				}
				infoInstante += '&nbsp;&nbsp;';
				if (topo_transito) {
					infoInstante += '<a href="//www.prefeitura.sp.gov.br/servicos/cidadaos/transito_e_transporte/lentidao/index.php"><img src="headerportal/img/transito.gif" alt="Lentid&atilde;o do Tr&acirc;nsito" width="17" height="12" title="Lentid&atilde;o do Tr&acirc;nsito" border="0"/> '+topo_transito+'km</a>';
				} else {
					infoInstante += '&nbsp; &nbsp; &nbsp; &nbsp;';
				}
				infoInstante += '&nbsp;&nbsp; <img src="headerportal/img/rodizio.gif" alt="Rod&iacute;zio em SP" title="Rod&iacute;zio em SP" width="14" height="12" /> '+topo_rodizio;

				this.htmlHeader += '    <div id="btop_cgesp">\n';
				this.htmlHeader += '      <div id="cge">\n';
				this.htmlHeader += '        <div id="cge1">CGE<\/div>\n';
				this.htmlHeader += '        <div id="cge2"><img src="'+urlAbsolute +'/'+topo_alertaImg+'" alt="alerta CGE" title="alerta CGE" width="15" height="15" name="imgCGE" /><\/div>\n';
				this.htmlHeader += '        <div id="cge3">'+infoCGE+'<\/div>\n';
				this.htmlHeader += '      <\/div>\n';
				this.htmlHeader += '      <div id="sp_agora">'+infoInstante+'<\/div>\n';
				this.htmlHeader += '    <\/div>\n';
			}
			this.htmlHeader += '    <div id="btop_pref_int">\n';
			this.htmlHeader += '      <div id="btop_cidade_img_int"><a href="http://www.prefeitura.sp.gov.br"><img src="headerportal/img/img_cidade_40.gif" alt="prefeitura.sp.gov.br" title="prefeitura.sp.gov.br" width="315" height="70" border="0"/><\/a><\/div>\n';
			this.htmlHeader += '      <div id="btop_serv_int">\n';
			if (this.show.search) {
				this.htmlHeader += '        <div id="btop_serv_int_01"><a href="//www.capital.sp.gov.br/portalpmsp/inicio.jsp"><img src="headerportal/img/home_29.gif" alt="Home" width="21" height="25" border="0" title="Home" /><\/a><a href="//www.capital.sp.gov.br/portalpmsp/do/mapa?op=insertForm"><img src="headerportal/img/mapa_29.gif" alt="Mapa do Site" width="21" height="25" border="0" title="Mapa do Site" /><\/a><a href="//www.capital.sp.gov.br/portalpmsp/do/faleconosco?op=filtroForm"><img src="headerportal/img/contato_29.gif" alt="Entre em contato" title="Entre em contato" width="21" height="25" border="0" /><\/a><a href="//www.capital.sp.gov.br/portalpmsp/do/ajuda"><img src="headerportal/img/ajuda_29.gif" alt="Ajuda" title="Ajuda" width="21" height="25" border="0" /><\/a><\/div>\n';
				this.htmlHeader += '        <div id="btop_serv_int_02">\n';
				this.htmlHeader += '          <form name="form" onSubmit="busca();return false;" action="">\n';
				this.htmlHeader += '			<input type="hidden" name="op"/>\n';
				this.htmlHeader += '			<input type="hidden" name="buscaAvancada"/>\n';
				this.htmlHeader += '			<input type="hidden" name="buscaSimples"/>\n';
				this.htmlHeader += '			<input type="hidden" name="contadorServico"/>\n';
				this.htmlHeader += '			<input type="hidden" name="contadorInstituicao"/>\n';
				this.htmlHeader += '			<input type="hidden" name="contadorUnidade"/>\n';
				this.htmlHeader += '			<input type="hidden" name="contadorNoticia"/>\n';
				this.htmlHeader += '			<input type="hidden" name="orderBy"/>\n';
				this.htmlHeader += '			<input type="hidden" name="filter"/>\n';
				this.htmlHeader += '			<input type="hidden" name="unidadeForm"/>\n';
				this.htmlHeader += '			<input type="hidden" name="servicoForm"/>\n';
				this.htmlHeader += '			<input type="hidden" name="coInstituicao"/>\n';
				this.htmlHeader += '			<input type="hidden" name="isHead"/>\n';
				this.htmlHeader += '            <div id="bsi_02a">Busca:\n';
				this.htmlHeader += '                <input name="param" class="busca" type="text"  value="" />\n';
				this.htmlHeader += '            <\/div>\n';
				this.htmlHeader += '            <div id="bsi_02b">\n';
				this.htmlHeader += '              <input type="image" name="imageField" src="headerportal/img/btn_busca.gif" />\n';
				this.htmlHeader += '            <\/div>\n';
				this.htmlHeader += '          <\/form>\n';
				this.htmlHeader += '        <\/div>\n';
			}
			this.htmlHeader += '      <\/div>\n';
			this.htmlHeader += '      <div id="btop_logo_int"><img src="headerportal/img/logo_governo_40.gif" alt="Prefeitura da Cidade de S&atilde;o Paulo" width="160" height="70" /><\/div>\n';
			this.htmlHeader += '    <\/div>\n';
			this.htmlHeader += '  <\/div>\n';
			if (this.show.trackBack) {
				this.htmlHeader += '  <div id="btop_sec">\n';
				this.htmlHeader += '		<h1>\n';
				if (typeof(PortalStructureTrackBack) == 'string') {
					this.htmlHeader += '		'+PortalStructureTrackBack+'\n';
				} else if (typeof(PortalStructureOrgao) == 'object') {
					this.htmlHeader += '		<a href="'+PortalStructureOrgao.url+'" title="'+PortalStructureOrgao.nome+'" target="_self">'+PortalStructureOrgao.nome+' <acronym title="'+PortalStructureOrgao.nome+'">('+PortalStructureOrgao.sigla+')<\/acronym><\/a>\n';			
				}
				this.htmlHeader += '		<\/h1>\n';
				this.htmlHeader += '	<\/div>\n';
			}
		}
		this.htmlHeader += '	<hr \/>\n';
		this.htmlHeader += '  <div id="body">\n';
		this.htmlHeader += '<!-- fim header -->	\n';
	},
	mountFooter: function() {
		if (this.show.footer) {
			this.htmlFooter = '';
			this.htmlFooter += '	<!-- FOOTER para tudo-->\n';
			this.htmlFooter += '  <\/div>\n';
			this.htmlFooter += '  <!-- final do corpo -->\n';
			this.htmlFooter += '  <!-- inicio footer -->\n';
			this.htmlFooter += '  <div id="footer">\n';
			this.htmlFooter += '  <p>&nbsp;<\/p><!-- antibug --><!-- antibug --><!-- antibug -->\n';
			this.htmlFooter += '  <\/div>\n';
			this.htmlFooter += '  <div id="footer_p">\n';
			this.htmlFooter += '  <img src="headerportal/img/footer_logo_bg.gif" width="770" height="40" alt="Prefeitura da Cidade de S?o Paulo">\n';
			this.htmlFooter += '  <\/div>\n';
			this.htmlFooter += '  <!-- fim footer-->\n';
			this.htmlFooter += '<\/div>\n';
			this.htmlFooter += '<!-- fim do wrap -->\n';
		}
	}
}
PortalStructure.init();
