<!--
function PopUp(url,largura,altura,nome,topo,esquerda,bar,scroll,res) {
        if (!(esquerda)) esquerda = 100;
        if (!(topo)) topo = 100;
        if (!(altura)) altura = 500;
        if (!(largura)) largura = 618;
        if (!(bar)) scroll = 1;
        if (!(nome)) nome = "Janela";
        if (!(res)) res = 1;

        window.open( url, nome, "left=" + esquerda + ",top=" + topo + ",width=" + largura + ",height=" + altura + ",resizable=" + res + ",scrollbars=" + scroll + ",toolbar=0,status=0,location=0,directories=0,menubar=0");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function RPC_Menu(layer)
{
	var nets = navigator.appName == "Netscape";
	var ns4 = (nets && parseInt(navigator.appVersion) == 4);
	var rpclayer = MM_findObj(layer);

	if (!ns4)
	{
		if (rpclayer.style['visibility']=='visible' || rpclayer.style['visibility']=='show')
		{
			MM_showHideLayers(layer,'','hide');
			rpclayer.style['height'] = '1px';
		}
		else
		{
			MM_showHideLayers(layer,'','show');
			rpclayer.style['height'] = '';
		}
	}
}

// Funcoes de adicionar imoveis a lista

function SetCookie (name, value)    {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = "/";
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
   }

function SetTheCookie()   {
   if(document.forms[0].elements[0].value.length != 0)        {
      var expdate = new Date ();
      expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
      SetCookie('DemoName', document.forms[0].elements[0].value, expdate);
      alert('Cookie has been set to ' + document.forms[0].elements[0].value + '.');
      document.forms[0].elements[0].value = " ";
            return false;
      }    else       {
      alert('You must sign-in first.');
      return false;
      }
   }
function getCookieVal (offset)    {
     var endstr = document.cookie.indexOf (";", offset);
     if (endstr == -1)
     endstr = document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)    {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)       {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return "";
   }

function adiciona(valor,pop) {

   if (testar(valor) == 0) { 
      alert("Este anúncio já foi selecionado e se encontra em sua lista.")
      return
   }
   var valorantigo = GetCookie("GazetaClassificados")
      
   if (valorantigo != "") {
	var valornovo = valorantigo + "|" + valor
	document.lista.qtde.value = eval(document.lista.qtde.value) + 1
	if(pop)opener.document.lista.qtde.value = eval(opener.document.lista.qtde.value) + 1
	SetCookie("GazetaClassificados", valornovo) }
   else {
	document.lista.qtde.value = eval(document.lista.qtde.value) + 1
	if(pop)opener.document.lista.qtde.value = eval(opener.document.lista.qtde.value) + 1
	SetCookie("GazetaClassificados", valor) }

}

function apagar(reload) {

	if (confirm("Você tem certeza de que deseja limpar a lista?")) {
        SetCookie("GazetaClassificados", "")		
		if (reload == 1)  {
			opener.document.lista.qtde.value = 0
			document.location.href=document.location.href;
		}else{
			document.lista.qtde.value = 0			
		}
    }
	
//	document.lista.submit()

}
function testar(numero) {
   
   count = 0
   vari = GetCookie("GazetaClassificados") //document.lista.valor.value
   var inicio = 0
   for (i=0;i < vari.length;i++ ) { 
       if (vari.substring(i,i+1) == "|") {  
          if (numero == vari.substring(inicio,i)) { return 0 }
          inicio = i+1     
       }
   }
   if (numero == vari.substring(inicio,i)) { return 0 }
   return 1


}
   


function contar() {
   
   ar = new Array
   count = 0
   vari = GetCookie("GazetaClassificados") //document.lista.valor.value
   var inicio = 0
   for (i=0;i < vari.length;i++ ) { 
       if (vari.substring(i,i+1) == "|") {  
          ar[count++] = vari.substring(inicio,i)
          inicio = i+1     
       }
   }
   ar[count++] = vari.substring(inicio,i)
   return count


}

function ler() {

    var valores = GetCookie("GazetaClassificados")
	if (valores == "") {
		var valores = ""
		document.lista.qtde.value = "0" }
	else {
		document.lista.qtde.value = contar()
	}

}
function FormataMoeda(campo) {
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( ",", "" );
	tam = vr.length ;

	campo.value='';
	if (tam > 2) campo.value += vr.substr(0 ,(tam - 2)) + '.';
	if (tam) campo.value += vr.substr( (tam -2), 2 );
	if (tam  == 1) campo.value = vr + '.00' ;
	if (tam  == 2) campo.value = vr + '.00' ;

}

function apaga(numero) {

if (confirm("Você tem certeza de que deseja apagar o anúncio?")) {
     
   
   novalista = ""
   count = 0
   vari = GetCookie("GazetaClassificados") //document.lista.valor.value
   var inicio = 0
   for (i=0;i < vari.length;i++ ) { 
       if (vari.substring(i,i+1) == "|") {  
          if (vari.substring(inicio,i) != numero) { 
                    count++
					if (novalista == "") {
						novalista = vari.substring(inicio,i)
					} else {
					    novalista = novalista + "|" + vari.substring(inicio,i)
					}               
           }
           inicio = i+1
	    }
	}
   

   if (vari.substring(inicio,i) != numero) {
		count++ 
		if (novalista == "") {
				novalista = vari.substring(inicio,i)
		} else {
				novalista = novalista + "|" + vari.substring(inicio,i)
		}  
   }

   SetCookie("GazetaClassificados", novalista)
   opener.document.lista.qtde.value = count
   //document.lista.submit()
   document.location.reload();
   //document.location.href=document.location.href;
}
}


function combo(targ,selObj,restore)
{
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}

function ContaObs (campo, contacampo)
{
	if(campo.value.length > 200)
	{
		alert ("O campo de observação deve ter no máximo 200 caracteres.");
		campo.value = campo.value.substring(0, 200);
	}
        contacampo.value = campo.value.length;
}

-->

