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="#ffffff" />');
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;
}

//paginadocumentos
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';
}
}
//fim

//registo
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('registadocomsucesso').innerHTML = novaarr[1];
}
else{
document.getElementById("botaoaccao2").value = "Registar";
document.getElementById('registo_erros').innerHTML = ajax.responseText;
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}
//fim

//loginfrente
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);
}
//fim


//recuperar pass 
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('recuperadacomsucesso').innerHTML = novaarr[1];
}
else{
document.getElementById("botaoaccao3").value = "Recuperar";
document.getElementById('registo_erros').innerHTML = ajax.responseText;
}
}
}
urlid=encodeURI(conteudoformulario)
ajax.send(urlid);
}
//fim

/*
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();
}
*/


//inquerito
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='menu' 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='menu' 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);
}
//fim inquerito


//iframes
function iframeAutoHeight(quem){
    //by Micox - elmicox.blogspot.com - elmicox.com - webly.com.br  
    if(navigator.appName.indexOf("Internet Explorer")>-1){ //ie sucks
        var func_temp = function(){
            var val_temp = quem.contentWindow.document.body.scrollHeight + 0
            quem.style.height = val_temp + "px";
        }
        setTimeout(function() { func_temp() },100) //ie sucks
    }else{
        var val = quem.contentWindow.document.body.parentNode.offsetHeight + 0
        quem.style.height= val + "px";
    }    
}

function OneIframe(obj_form) {
ocodigo=obj_form.codigo.value;
if(ocodigo==0){
return false;
}
obj_form.action = "tempo.asp";
obj_form.method = "post";
obj_form.target = "temponac";
obj_form.submit();
}

function inf(qual){
ajax = ajaxInit();
document.getElementById('tempofarmacia').innerHTML = "<img style='padding:10px;' src='images/loading.gif' />";
ajax.open("post", "ajaxinformacao.asp", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById('tempofarmacia').innerHTML = ajax.responseText;
}
}
urlp="id="+qual
urlp=encodeURI(urlp)
ajax.send(urlp);
}
//fim


//directorio
function executa(){
oform=document.categorias;

if(oform.osegundo.selectedIndex >= 0){
opritxt=oform.osegundo.options[oform.osegundo.selectedIndex].text
oprival=oform.osegundo.options[oform.osegundo.selectedIndex].value
var opt = document.createElement('option');
opt.text = opritxt;
opt.value = oprival;
oter = document.getElementById("oterceiro");
qtd=oter.length;
if(qtd > "2"){
alert('Só pode seleccionar até 3 categorias')
}else{
  try
    {
    oter.add(opt,null); // standards compliant
    }
  catch(ex)
    {
    oter.add(opt); // IE only
    }
}

}
else{

if(oform.oprimeiro.selectedIndex >= 0){
opritxt=oform.oprimeiro.options[oform.oprimeiro.selectedIndex].text
oprival=oform.oprimeiro.options[oform.oprimeiro.selectedIndex].value
var opt = document.createElement('option');
opt.text = opritxt;
opt.value = oprival;
oter = document.getElementById("oterceiro");
qtd=oter.length;
if(qtd > "2"){
alert('Só pode seleccionar até 3 categorias')
}else{
  try
    {
    oter.add(opt,null); // standards compliant
    }
  catch(ex)
    {
    oter.add(opt); // IE only
    }
}
}
}
}

function remover(){
oform=document.categorias;
if(oform.oterceiro.selectedIndex >= 0){
var r=document.getElementById("oterceiro")
r.remove(r.selectedIndex)
}
}

function ajaxselect(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('div2').innerHTML = ajax.responseText;
}
}
urlp="vale="+nri
urlp=encodeURI(urlp)
ajax.send(urlp);
}
//fim

//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


//osmodals
function exec_oemail(){
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}

onome=document.multi.nome.value;
oemail=document.multi.email.value;
amensagem=document.multi.mensagem.value;
otitulo=document.multi.titulo.value;
oid=document.multi.id.value;

erro=0

if(onome.trim().length==0){
erro+=1
}
if(!/^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/.test(oemail)){
erro+=1
}
if(amensagem.trim().length==0){
erro+=1
}

if(erro > 0){
document.getElementById("ver_erros").style.display='';
return false;
}else{
document.getElementById("ver_erros").style.display='none';
ajax = ajaxInit(); 
document.getElementById("envia_mail").innerHTML="<img src='images/loading.gif' />";
ajax.open("post", "ajaxemail.asp", true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
aurli="nome="+onome+"&email="+oemail+"&mensagem="+amensagem+"&titulo="+otitulo+"&id="+oid
ajax.onreadystatechange=function() {
if(ajax.readyState==4){
document.getElementById("envia_mail").innerHTML=ajax.responseText;
}
}
urlid=encodeURI(aurli)
ajax.send(urlid);
}
}
//fim


function streaming(ide,tipo){
var w = 430;
var h = 430;
var lado = (screen.width - w) / 2;
var topo = (screen.height - h) / 2;
urv="id="+ide+"&tipo="+tipo
var k = window.open('streaming.asp?'+urv+'',''+ide+'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, width='+w+', height='+h+', top='+topo+', left='+lado+'')
k.focus();
}