function posicao(iden,menu){
contentorid=document.getElementById(iden)
contentorid2=document.getElementById(iden)

curtopo = 0;
if (contentorid.offsetParent){
while(contentorid.offsetParent){
curtopo += contentorid.offsetTop
contentorid = contentorid.offsetParent;
}
curtopo=curtopo
}

curesq = 0;
if (contentorid2.offsetParent){
while(contentorid2.offsetParent){
curesq += contentorid2.offsetLeft
contentorid2 = contentorid2.offsetParent;
}
curesq=curesq+175
}

document.getElementById(menu).style.top=curtopo+"px";
document.getElementById(menu).style.left=curesq+"px";
document.getElementById(menu).style.display='';
}

function desposicao(iden,menu){
document.getElementById(menu).style.display='none';
}

function GerarSWF(arquivo,altura,largura,ide){
document.writeln('<object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + largura + '" height="' + altura + '" id="' + ide + '" name="' + ide + '">');
document.writeln('<param name="movie" value="' + arquivo + '">');
document.writeln('<param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl">');
document.writeln('<param name="bgcolor" value="">');
document.writeln('<param name="menu" value="false">');
document.writeln('<param name="quality" value="high">');
document.writeln('<param name="wmode" value="transparent">');
document.writeln('<embed id="globalnav-embed" src="' + arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" bgcolor="#ffffff" menu="false" quality="high" salign="tl" scale="noscale" id="' + ide + '" width="' + largura + '" height="' + altura + '"></embed>');
document.writeln('</object>');
}

function ajaxInit() {
var req;
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(ex) {
try {
req = new XMLHttpRequest();
} catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax");
req = null;
}
}
}

return req;
}

function mudapag(iden){
ajax = ajaxInit(); 
ajax.open("GET", "noticia.asp?id="+iden, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('menu_centro_conteudo').innerHTML = ajax.responseText;
}
}
ajax.send(null);
}
function voltapag(){
ajax = ajaxInit(); 
ajax.open("GET", "indexajax.asp", true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
window.scroll(0,0);
document.getElementById('menu_centro_conteudo').innerHTML = ajax.responseText;
}
}
ajax.send(null);
}

function imgvisivel(iden,imagem){
if(document.getElementById(iden).style.display==''){
document.getElementById(iden).style.display='none'
document.getElementById(imagem).src='/images/mais.gif';
document.getElementById(imagem).title='Abrir';
}
else{
document.getElementById(iden).style.display=''
document.getElementById(imagem).src='/images/menos.gif';
document.getElementById(imagem).title='Fechar';
}
}

function enviadados(){
document.getElementById("botaoaccao2").value = "Aguarde por favor";
var formulario = document.getElementById("formlog"); 
var tamanho = formulario.elements.length; 
var conteudoformulario = "" 
var sepcampos 
sepcampos = "" 
for (var i=0; i <= formulario.elements.length-1;i++) { 
conteudoformulario += sepcampos+formulario.elements[i].name+'='+(formulario.elements[i].value); 
sepcampos="&"; 
} 
ajax = ajaxInit(); 
ajax.open("post", "ajaxlogin.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
novaarr=ajax.responseText.split(";");
if(novaarr[0]=="0"){
document.getElementById('menu_centro_conteudo').innerHTML = novaarr[1];
}
else{
document.getElementById("botaoaccao2").value = "Registar";
document.getElementById('registo_erros').innerHTML = ajax.responseText;
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}

function exec_log(){
var formulario = document.getElementById("formlogi"); 
var tamanho = formulario.elements.length; 
var conteudoformulario = "" 
var sepcampos 
sepcampos = "" 
for (var i=0; i <= formulario.elements.length-1;i++) { 
conteudoformulario += sepcampos+formulario.elements[i].name+'='+(formulario.elements[i].value); 
sepcampos="&"; 
} 
ajax = ajaxInit(); 
ajax.open("post", "ajaxexeclog.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
novaarr=ajax.responseText.split(";");
if(novaarr[0]=="0" || novaarr[0]=="1"){
alert(novaarr[1]);
}
else{
window.location.href=novaarr[1];
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}

function recdados(){
document.getElementById("botaoaccao3").value = "Aguarde por favor";
var formulario = document.getElementById("formpasse"); 
var tamanho = formulario.elements.length; 
var conteudoformulario = "" 
var sepcampos 
sepcampos = "" 
for (var i=0; i <= formulario.elements.length-1;i++) { 
conteudoformulario += sepcampos+formulario.elements[i].name+'='+(formulario.elements[i].value); 
sepcampos="&"; 
} 
ajax = ajaxInit(); 
ajax.open("post", "ajaxpasse.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
novaarr=ajax.responseText.split(";");
if(novaarr[0]=="0"){
document.getElementById('menu_centro_conteudo').innerHTML = novaarr[1];
}
else{
document.getElementById("botaoaccao3").value = "Recuperar";
document.getElementById('registo_erros').innerHTML = ajax.responseText;
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}

function enviaservicos(){
document.getElementById("botaoaccao").value = "Aguarde por favor";
var formulario = document.getElementById("formserv"); 
var tamanho = formulario.elements.length; 
var conteudoformulario = "" 
var sepcampos 
sepcampos = "" 
for (var i=0; i <= formulario.elements.length-1;i++) { 
conteudoformulario += sepcampos+formulario.elements[i].name+'='+(formulario.elements[i].value); 
sepcampos="&"; 
} 
ajax = ajaxInit(); 
ajax.open("post", "ajaxservicos.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
novaarr=ajax.responseText.split(";");
if(novaarr[0]=="0"){
document.getElementById("botaoaccao").value = "Enviar";
alert(novaarr[1].replace(/<br>/gi,"\n"));
}
else{
window.scroll(0,0);
document.getElementById('menu_centro_conteudo').innerHTML = ajax.responseText;
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}

function imprime(valor,ide){
var w = 600;
var h = 500;
var lado = (screen.width - w) / 2;
var topo = (screen.height - h) / 2;
urv="id="+ide+"&imp="+valor
var t = window.open('imprimir.asp?'+urv+'','imprime','scrollbars=yes, width='+w+', height='+h+', top='+topo+', left='+lado+'')
t.focus();
}


function vai_form(idper){
qto=document.getElementsByName("opcao");
qtd=qto.length
ovalor=0
for(oo=0; oo < qtd; oo++){
if(qto[oo].checked==true){
ovalor=qto[oo].value
}
}
if(ovalor==0){
alert("Tem que seleccionar uma opção.")
}
else{
ajax = ajaxInit(); 
oendereco="inquerito.asp?idper="+idper+"&idres="+ovalor+"&tipo=votar"
ajax.open("GET", oendereco, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('osconteudos').innerHTML = ajax.responseText;
olink="<a class='tipo1' style='font-size:11px;' href='javascript:inicio();'>Voltar</a>"
document.getElementById('aaccao').innerHTML = olink;
}
}
ajax.send(null);
}
}

function resultados(idper){
ajax = ajaxInit(); 
oendereco="inquerito.asp?idper="+idper+"&tipo=ver"
ajax.open("GET", oendereco, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('osconteudos').innerHTML = ajax.responseText;
olink="<a class='tipo1' style='font-size:11px;' href='javascript:inicio();'>Voltar</a>"
document.getElementById('aaccao').innerHTML = olink;
}
}
ajax.send(null);
}

function resultados2(idper){
ajax = ajaxInit(); 
oendereco="inquerito.asp?idper="+idper+"&tipo=ver2"
ajax.open("GET", oendereco, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('oinicio').innerHTML = ajax.responseText;
}
}
ajax.send(null);
}

function inicio(){
ajax = ajaxInit(); 
oendereco="formulario.asp"
ajax.open("GET", oendereco, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('oinicio').innerHTML = ajax.responseText;
}
}
ajax.send(null);
}

function anteriores(){
ajax = ajaxInit(); 
oendereco="anteriores.asp"
ajax.open("GET", oendereco, true);
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('oinicio').innerHTML = ajax.responseText;
}
}
ajax.send(null);
}

function osmenus(omenu){
obj=document.getElementById(omenu)
if(obj.style.display=='none'){
obj.style.display='';
qt=100
for(ct=0;ct<qt;ct++){
if(document.getElementById("submenudinamico"+ct)){
if(omenu != document.getElementById("submenudinamico"+ct).id){
document.getElementById("submenudinamico"+ct).style.display='none';
}
}
}
}
else{
obj.style.display='none'
document.cookie="";
}
}

//classificados
function vaiaoum(nri){
ajax = ajaxInit(); 
ajax.open("post", "ajaxanuncios.asp", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('selectcat').innerHTML = ajax.responseText;
}
}
urlp="vale="+nri
urlp=encodeURI(urlp)
ajax.send(urlp);
}

function exec_anuncio(){
var formulario = document.getElementById("classifica"); 
var tamanho = formulario.elements.length; 
var conteudoformulario = "" 
var sepcampos 
sepcampos = "" 
for (var i=0; i <= formulario.elements.length-1;i++) { 
conteudoformulario += sepcampos+formulario.elements[i].name+'='+(formulario.elements[i].value); 
sepcampos="&"; 
} 
ajax = ajaxInit(); 
ajax.open("post", "ajaxexecanuncio.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
novaarr=ajax.responseText.split(";");
if(novaarr[0]=="0"){
alert(novaarr[1]);
}
else{
window.location.href=novaarr[1];
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}
//fim