<!--
function currencyFormat(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
    var len = len2 = 0;
    var strCheck = '-0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;

    if (whichCode == 13) return true;                  // Enter
    key = String.fromCharCode(whichCode);              // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
	len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
    aux = '';
    for(; i < len; i++)
    	if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) fld.value = '';
    if (len == 1) fld.value = '0'+ decSep + '0' + aux;
	if (len == 2) fld.value = '0'+ decSep + aux;
	if (len > 2) {
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) {
       		if (j == 3) {
              	aux2 += milSep;
              	j = 0;
           	}
         	aux2 += aux.charAt(i);
         	j++;
    	}
   		fld.value = '';
		len2 = aux2.length;
		for(i = len2 - 1; i >= 0; i--)
         	fld.value += aux2.charAt(i);
  		fld.value += decSep + aux.substr(len - 2, len);
 	}
  	return false;
}


function atualiza(x) {
iframe_subtipo.location.href = "iframe_subtipo2.asp?cod_imovel_tipo="+ x;
}

function SC_numero(e) { // mais uma SC
var key = '';
var len = len2 = 0;
var strCheck = '0123456789()-';
var codigo = (window.Event) ? e.which : e.keyCode;
if (codigo == 13) return true;  // Tecla Enter
key = String.fromCharCode(codigo);  // Pega o valor de "key"
if (strCheck.indexOf(key) == -1) return false;  // Nao eh uma tecla valida
}

function valida_data(string) {
bissexto = ''
data = string
if (data.length != 10) { return '#- A data deve ser no formato DD/MM/AAAA' }
    else {
 if (data.substring(0,4).indexOf('/') == 2) {
  if (data.substring(3,8).indexOf('/') == 2) {
   dia = data.substring(0,2)
   mes = data.substring(3,5)
   ano = data.substring(6,10)
   if (mes < 0 || mes > 12) { return '#- Mês inválido'; }
   if (ano < 1890 || ano > 2100) { return '#- Ano inválido'; }
   if (mes == 01 || mes == 03 || mes == 05 || mes == 07 || mes == 08 || mes == 10 || mes == 12) { n_dias = 31 }
    else if (mes == 04 || mes == 06 || mes == 09 || mes == 11) { n_dias = 30 }
//     else if (mes == 02) { if (ano % 4 == 0 && ano % 100 != 0 && ano % 400 == 0 ) { n_dias = 29 ; bissexto = 'Sim'} else { n_dias = 28 } }
     else if (mes == 02) { if (ano % 4 == 0) { n_dias = 29 ; bissexto = 'SIM'} else { n_dias = 28 } }
   if (dia < 0 || dia > n_dias) { return '#- Dia inválido'; }
   if (bissexto == '') bissexto = 'NÃO'
//   alert('DIA: ' + dia + '\nMÊS: ' + mes + '\nANO: ' + ano + '\nBISSEXTO: ' + bissexto)
   return 'true';
  }
 }
    }
}
 
function FormataData(Campo,teclapres) {
 var tecla = teclapres.keyCode;
 vr = document.form8[Campo].value;
 vr = vr.replace( ".", "" );
 vr = vr.replace( "/", "" );
 vr = vr.replace( "/", "" );
 tam = vr.length + 1;
 
 if ( tecla != 9 && tecla != 8 ){
  if ( tam > 2 && tam < 5 )
   document.form8[Campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
  if ( tam >= 5 && tam <= 10 )
   document.form8[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); }
}

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_validateForm() { //v4.5 - ©2002 - StarCorp BTi
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  //document.form8.Submit.disabled = true;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+': Este campo deve conter um endereço de e-mail válido.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+': Este campo deve conter um número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+': Este campo deve conter um número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+': Este campo é requerido.\n'; }
  } 
  //if (document.form1.tipo.selectedIndex < 1) {errors +='- Escolha um tipo de imóvel.\n';}
  if (document.form8.subtipo.value < 1) {errors +='- Escolha um sub-tipo de imóvel.\n';}
  if (document.form8.categoria.value < 1) {errors +='- Escolha uma categoria.\n';}

  if (errors) {
	  alert('Os seguintes erros aconteceram:\n'+errors);
	  //document.form8.Submit.disabled = false;
  }
  document.MM_returnValue = (errors == '');
}
function atualiza(x){
	iframe_cidade.location.href='iframe_cidade.asp?cod_cidade='+x
	//iframe_cod_modelo_sub_categoria.location.href='iframe_cod_modelo_sub_categoria.asp?cod_modelo_categoria='+x+'&cod_modelo_sub_categoria=<%=request("cod_modelo_sub_categoria2")%>'
}