  var strBrowser=navigator.appName;
  var intCategoriaSelezionata=1;
  var tipologieResidenziali = new Array('app','Appartamento','attico','Attico-Superattico','baita','baita-chalet-cottage','bifa','Bifamiliare','bung','bungalows','casai','Casa indipendente','casam','Casa mobile','box','Garage-Box-posto','manloft','Mansarda-Loft','mass','Masserie','palstab','Palazzo-stabile','Porz','Porzione di fabbricato','rustico','Rustico-casale','tered','Terreno edificabile','trilo','Trilocale','trulli','Trulli','vill','Villa Indipendente','vilta','Villetta');
  var tipologieCommerciali = new Array('albergo','albergo','b&b','Bed&Breakfast','cap','capannone','cc	centro','commerciale','cielterr','cielo terra','comind','complesso industriale','complog','complesso logistico','comterz','complesso terziario','garage','garage','lab','laboratorio','mag','magazzino','neg','negozio','terrart','Terreno edificabile artigianale','uff','ufficio','villtur','	villaggio turistico');
  var tipologieAttivita = new Array('abb','abbigliamento','agviaggi','agenzia viaggi','agr','agriturismo-azienda agricola','alb','attivita alberghiera','Attivita\'','Attivita\' commerciale','bar','bar','barr','bar ricevitoria','bart','bar tabacchi','bartr','bar tabacchi-ricevitoria','calz','calzature','camping','camping','cartlib','cartoleria-libreria','comp','computer','automoto','concessionaria auto-moto','disco','discoteca','edic','edicola','fastf','fast food self service','fer','Ferramenta','fiori','fiori-giardinaggio-floricoltura','foto','fotografo - ottico','gastr','gastronomia-rosticceria','gel','gelateria','oro','gioielleria-oreficeria-orologeria','mark','market alimentari','pal','palestra','pan','panetteria','parrucc','parrucchiere uomo-donna','past','pasticceria','piadina','Piadina','pizz','pizzeria','pizzasp','pizzeria da asporto','prof','profumeria','pub','pub-birreria-locali notturni','ric','ricevitoria','rist','ristorante','ristpizz','ristorante-pizzeria','solarium','solarium-centro estetico','baln','Stabilimenti balneari','tab','tabacchi','tel','telefonia','lavand','tintoria-lavanderia');
  var tipologieTerreni = new Array('terr','Terreno');
  var tipologieVacanze = new Array('appvac','Appartamento','rustvac','Attico-Superattico','baitavac','baita-chalet-cottage','bungvac','bungalows','casaivac','Casa indipendente','casavac','Casa per vacanze','villvac','Villa Indipendente','viltavac','Villetta');

  if (navigator.userAgent.toLowerCase().indexOf("applewebkit/")!= -1){
    strBrowser="wk";
  }else if (strBrowser=='Microsoft Internet Explorer'){
    strBrowser="ie";
  }else if (strBrowser=='Konqueror'){
    strBrowser="ko";
  }else{
    strBrowser="ff";
  };
  
  function getElementValue(xmlDoc, strName){
      if (strBrowser=='ie'){
        try{ 
          return xmlDoc.getElementsByTagName(strName).item(0).text;
        }catch(e){
          return "";
        }
      }else if ((strBrowser=='ko') || (strBrowser=='wk')){
        try{ 
          return xmlDoc.getElementsByTagName(strName).item(0).firstChild.nodeValue;
        }catch(e){
          return "";
        }
      }else{
        try{ 
          return xmlDoc.getElementsByTagName(strName)[0].textContent;
        }catch(e){
          return "";
        }
      }
  };
  
  function XMLDoc(strXML){
    if (document.implementation.createDocument){ 
      var parser = new DOMParser(); 
      var xmldoc = parser.parseFromString(strXML, "text/xml"); 
    }
    else if (window.ActiveXObject) { 
      var xmldoc = new ActiveXObject("Microsoft.XMLDOM");   
      //xmldoc.async=false;
      xmldoc.loadXML(strXML);                                     
    }
    return xmldoc;
  };
  
  function jsSetCookies(sCookies,sTxt){
  	document.cookie=sCookies + "=" + sTxt + ";path=/;";
  };
  
  function jsGetCookies(name) { 
    var bikky = document.cookie;
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1; 
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1){ endstr = bikky.length}; 
    return unescape(bikky.substring(index, endstr));
  };
  
  function fnKy(nV){
    return nV.replace(".", "");
  };
  
  function jsHttpPost(sUrl, strXML){
    var xmlhttp=false;
    var sR;
    sR='';
    try{
		  try {
			  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
			  try {
			    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			  } catch (e) {}
		  }
    }catch (e) {
      xmlhttp = false;
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') { //firefox e altri
      xmlhttp = new XMLHttpRequest();
      xmlhttp.open("POST", sUrl,false);
      xmlhttp.send(strXML);
      sR=xmlhttp.responseText;
      return sR;
    }
    else{                                                 //internet explorer
      xmlhttp.open("POST", sUrl,false);
      xmlhttp.send(strXML); 
      return xmlhttp.ResponseText;
    }
  };
  
  function MM_findObj(n, d) { //v4.01
    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 && d.getElementById) x=d.getElementById(n); return x;
  };
  
  function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    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+' deve contenere un indirizzo email valido.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' &egrave; obligatorio.\n'; }
    } if (errors) alert('Attenzione:\n'+errors);
    document.MM_returnValue = (errors == '');
  };
  
  function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
  };
  
  function aggiorna_Categoria(intArea){
  /*
    intImmobiliArea_Ky=intCategoria;
    intCategoriaSelezionata=intCategoria;
    caricaTipologie(true);*/
  };

  function caricaTipologie(fTutte){
    var sHTML;
    var strWHERE;
    var strFROM;
    var strXML;
  /*
    var listField;
    var ArraySelezionato;
    switch (intCategoriaSelezionata){
      case 1:
        ArraySelezionato=tipologieResidenziali;
        ArraySelezionato.length=tipologieResidenziali.length;
        break;
      case 2:
        ArraySelezionato=tipologieCommerciali;
        ArraySelezionato.length=tipologieCommerciali.length;
        break;
      case 3:
        ArraySelezionato=tipologieAttivita;
        ArraySelezionato.length=tipologieAttivita.length;
        break;
      case 4:
        ArraySelezionato=tipologieTerreni;
        ArraySelezionato.length=tipologieTerreni.length;
        break;
      case 5:
        ArraySelezionato=tipologieVacanze;
        ArraySelezionato.length=tipologieVacanze.length;
        break;
    
    }
    listField=document.getElementById("tipologia");
    listField.options.length = 0;
    var len = listField.length++; 
    listField.options[len].value = '';
    listField.options[len].text = 'Qualsiasi';  
    for(var i = 0; i < ArraySelezionato.length/2; i++) {
      var len = listField.length++; 
      listField.options[len].value = ArraySelezionato[i*2];
      listField.options[len].text = ArraySelezionato[i*2+1];
    }*/
  };
  
  function Init(){
    caricaTipologie(true);
    if (document.getElementById("provincia").value!=null){
      aggiorna_Provincia();
    }
  };

  function aggiorna_Provincia(){
    var sHTML;
    var listField;
    var strWHERE;
    var strXML;
    var strProvinciaSQL;
    listField=document.getElementById("luogo");
    listField.length=0;
    strProvinciaSQL=document.getElementById("provincia").value.replace("'","''");
    strWHERE="Comuni_Zona=0 And Province_Codice='" + strProvinciaSQL + "'";
    strXML="<db><rs><st>frk_Read<\/st><tb>Comuni_Vw<\/tb><ky>Comuni_Ky<\/ky><whr>" + strWHERE + "<\/whr><ord>Comuni_Comune<\/ord><fields>Province_Codice,Comuni_Ky,Comuni_Comune<\/fields><\/rs><\/db>";
    strXML=jsHttpPost("/frk/db/SQLServer/frkStoreExecute.asp",strXML);
    var xmldoc=XMLDoc(strXML);
    var db = xmldoc.getElementsByTagName("rs");
    var len = listField.length++; 
    listField.options[len].value = '';
    listField.options[len].text = 'Qualsiasi'; 
    for(var i = 0; i < db.length; i++) {
      var len = listField.length++; 
      var e = db[i];
      listField.options[len].value = fnKy(getElementValue(e,"Comuni_Comune"));
      listField.options[len].text = getElementValue(e,"Comuni_Comune");
    }
  };
  
  function aggiorna_Comune(){
    var sHTML;
    var listField;
    var strWHERE;
    var strXML;
    /*
    listField=document.getElementById("zona");
    listField.options.length = 0;
    strWHERE="Comuni_Ky='" + document.getElementById("comune").value + "'";
    strXML="<db><rs><st>frk_Read<\/st><tb>ImmobiliZona_Vw<\/tb><ky>ImmobiliZona_Ky<\/ky><whr>" + strWHERE + "<\/whr><ord>ImmobiliZona_Descrizione<\/ord><\/rs><\/db>";
    strXML=jsHttpPost("/frk/db/SQLServer/frkStoreExecute.asp",strXML);
    if (document.implementation.createDocument){ 
      var parser = new DOMParser(); 
      xmldoc = parser.parseFromString(strXML, "text/xml"); 
    }
    else if (window.ActiveXObject) { 
        var xmldoc = new ActiveXObject("Microsoft.XMLDOM");   
        xmldoc.loadXML(strXML);                                     
    }
    var db = xmldoc.getElementsByTagName("rs");
    var len = listField.length++; 
    listField.options[len].value = '';
    listField.options[len].text = 'Qualsiasi';  
    for(var i = 0; i < db.length; i++) {
      var len = listField.length++; 
      var e = db[i];
      listField.options[len].value = getElementValue(e,"ImmobiliZona_Descrizione");
      listField.options[len].text = getElementValue(e,"ImmobiliZona_Descrizione");
    }
    */
  };

  function aggiorna_categoria(intCategoria){
  /*
    intImmobiliArea_Ky=intCategoria;
    intCategoriaSelezionata=intCategoria;
    caricaTipologie(true);
    */
  };

