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 levafotografia(oform){
oform.antigas.value=0;
oform.categorias.value=0;
oform.fotografia2.value=0;
oform.fotografia3.value=0;
oform.submit();
}

function levafotografia2(oform){
oform.fotografia.value=0;
oform.nrdistrito.value=0;
oform.nrconcelho.value=0;
oform.nrfreguesia.value=0;
oform.categorias.value=0;
oform.fotografia3.value=0;
oform.oformato.value=1;
oform.submit();
}

function levafotografia3(oform){
oform.fotografia.value=0;
oform.nrdistrito.value=0;
oform.nrconcelho.value=0;
oform.nrfreguesia.value=0;
oform.antigas.value=0;
oform.fotografia2.value=0;
oform.oformato.value=2;
oform.submit();
}

function levadistrito(oform){
oform.antigas.value=0;
oform.fotografia2.value=0;
oform.categorias.value=0;
oform.fotografia3.value=0;
oform.nrconcelho.value=0;
oform.nrfreguesia.value=0;
oform.submit();
}

function levaconcelho(oform){
oform.antigas.value=0;
oform.categorias.value=0;
oform.nrfreguesia.value=0;
oform.submit();
}

function levafreguesia(oform){
oform.antigas.value=0;
oform.categorias.value=0;
oform.submit();
}

function levaantigas(oform){
oform.fotografia.value=0;
oform.nrdistrito.value=0;
oform.nrconcelho.value=0;
oform.nrfreguesia.value=0;
oform.categorias.value=0;
oform.fotografia3.value=0;
oform.oformato.value=1;
oform.submit();
}

function levacategorias(oform){
oform.fotografia.value=0;
oform.nrdistrito.value=0;
oform.nrconcelho.value=0;
oform.nrfreguesia.value=0;
oform.antigas.value=0;
oform.fotografia2.value=0;
oform.oformato.value=2;
oform.submit();
}

function vaiaoum(nri){
htmlin = "<select class='osinput' style='width:145px;' name='freguesia'>"
htmlin += "<option value='0'>Freguesia</option>"
htmlin += "</select>"
ajax = ajaxInit(); 
ajax.open("post", "ajaxselect.asp", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('seleti1').innerHTML = ajax.responseText;
document.getElementById('seleti2').innerHTML = htmlin;
}
}
urlp="vale="+nri+"&parte=1"
urlp=encodeURI(urlp)
ajax.send(urlp);
}

function vaidois(nri){
ajax = ajaxInit(); 
ajax.open("post", "ajaxselect.asp", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('seleti2').innerHTML = ajax.responseText;
}
}
urlp="vale="+nri+"&parte=2"
urlp=encodeURI(urlp)
ajax.send(urlp);
}

function contacto(ide){
var w = 580;
var h = 360;
var lado = (screen.width - w) / 2;
var topo = (screen.height - h) / 2;
var k = window.open('contacto.asp?id='+ide+'','contacto','scrollbars=no, width='+w+', height='+h+', top='+topo+', left='+lado+'')
k.focus();
}

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="wmode" value="opaque" />');
document.writeln('<embed id="globalnav-embed" src="' + arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" salign="tl" scale="noscale" id="' + ide + '" width="' + largura + '" height="' + altura + '"></embed>');
document.writeln('</object>');
}