      /* -------------------------------------------------------------------------------- */      
      var oImgWin = null;
      var b3D = false;
      var sDivBackColor = "";
      var sDivForeColor = "";
      var vMapLoad  = new Array(false,false,false,false,false,false);
      var vLandLoad = new Array(false,false,false,false,false,false,false,false);
      /* --------------------------------------------------------------------------------       
      zBlock(nVisibility)
      zCalendar()
      zDivClick(obj)
      zDivMouseOut(obj)
      zDivMouseOver(obj)
      zHCIncome(vEvent)
      zHCLoan(nFlag)
      zHCMinPay()
      zHCPayment(obj)
      zHCPeriod(obj)
      zHCSource(vEvent)
      zHCSum(vEvent)
      zMapClick(obj)
      zMapImgLoad(obj)
      zMapLoad()
      zMapMouseOut(obj)
      zMapMouseOver(obj)
      zNumericField(obj, bFloat)
      zPageSetup()
      zPhotoShow(obj)
      zPrint(nFlag)
      zRestDay(nMonth, nStart, nLen, sClassName, sTitle)
      zSearchAction(obj)
      zSearchLoad()
      zSearchSize(obj)
      zStrToInt(sPar, bFloat)
      /* -------------------------------------------------------------------------------- */      
      function zMapLoad()
      {
        if (!document.all) document.getElementById("imgMap").style.visibility = "visible";
      } //zMapLoad
      /* -------------------------------------------------------------------------------- */      
      function zMapImgLoad(obj)
      {
        vMapLoad[parseInt(obj.parentElement.id.substring(7,8))] = true;
        var bMapLoad = true;
        for (var i=0; i<vMapLoad.length; i++)
          bMapLoad = bMapLoad && vMapLoad[i];
        if (bMapLoad) document.getElementById("imgMap").style.visibility = "visible";
      } //zMapImgLoad
      /* -------------------------------------------------------------------------------- */      
      function zMapMouseOver(obj, sDiv)
      {
        if (!sDiv || sDiv.length == 0) sDiv = "divMap";
        var oStyle = document.getElementById(sDiv + obj.id.substring(4,6)).style;
        oStyle.visibility = "visible";
        if (b3D)
        {
          if (oStyle.left.length == 0) oStyle.left = "0px";
          if (oStyle.top.length  == 0) oStyle.top  = "0px";
          oStyle.left = parseInt(oStyle.left) - 1;
          oStyle.top  = parseInt(oStyle.top)  - 1;
        }
      } //zMapMouseOver
      /* -------------------------------------------------------------------------------- */      
      function zMapMouseOut(obj, sDiv)
      {
        if (!sDiv) sDiv = "divMap";
        var oStyle = document.getElementById(sDiv + obj.id.substring(4,6)).style;
        oStyle.visibility = "hidden";
        if (b3D)
        {
          if (oStyle.left.length == 0) oStyle.left = "0px";
          if (oStyle.top.length  == 0) oStyle.top  = "0px";
          oStyle.left = parseInt(oStyle.left) + 1;
          oStyle.top  = parseInt(oStyle.top)  + 1;
        }
      } //zMapMouseOut
      /* -------------------------------------------------------------------------------- */      
      function zMapClick(obj)
      {
        if (obj.href.length == 0) return(false);       
        document.location = obj.href;
        return(false);
      } //zMapClick
      /* -------------------------------------------------------------------------------- */
      function zDivMouseOver(obj)
      {
        obj.style.color = "#FEE000";
        obj.style.backgroundColor = "green";
        for (var i=0;i<obj.getElementsByTagName("img").length;i++)
          obj.getElementsByTagName("img")[i].src="Images/Icon16.gif";
      } //zDivMouseOver
      /* -------------------------------------------------------------------------------- */
      function zDivMouseOut(obj)
      {
        obj.style.color = "green";
        obj.style.backgroundColor = "#FEE000";
        for (var i=0;i<obj.getElementsByTagName("img").length;i++)
          obj.getElementsByTagName("img")[i].src="Images/Icon16-2.gif";
      } //zDivMouseOut
      /* -------------------------------------------------------------------------------- */      
      function zDivClick(obj)
      {
        document.location = obj.id;
      } //zDivClick
      /* -------------------------------------------------------------------------------- */      
      function zHCIncome(vEvent)
      {
        //if (vEvent.propertyName != "value") return;
        var nIncome = zStrToInt(document.forms[0].elements["Income"].value);
        if (nIncome > 0)
        {
          document.forms[0].elements["MaxSum"].value = nIncome * 30;
          document.forms[0].elements["MaxPay"].value = (nIncome * 4) / 10;
        }
        else
        {
          document.forms[0].elements["MaxSum"].value = "";
          document.forms[0].elements["MaxPay"].value = "";
        }
        zHCMinPay();
      } //zHCIncome
      /* -------------------------------------------------------------------------------- */      
      function zHCSum(vEvent)
      {
        //if (vEvent.propertyName != "value") return;
        var vSum = document.forms[0].elements["Sum"];
        var nIncome = zStrToInt(document.forms[0].elements["Income"].value);
        var nMaxSum = zStrToInt(document.forms[0].elements["MaxSum"].value);
        if (nIncome > 0 && zStrToInt(vSum.value) > nMaxSum)
          vSum.style.color = "red";
        else
          vSum.style.color = "#336633";
      } //zHCSum
      /* -------------------------------------------------------------------------------- */      
      function zHCMinPay()
      {
        var vMinPay = document.forms[0].elements["MinPay"];
        var nMinPay = zStrToInt(vMinPay.value);
        var nMaxPay = zStrToInt(document.forms[0].elements["MaxPay"].value);
        if (nMinPay > 0 && nMaxPay > 0 && nMaxPay < nMinPay)
          vMinPay.style.color = "red";
        else
          vMinPay.style.color = "gray";
      } //zHCMinPay
      /* -------------------------------------------------------------------------------- */      
      function zHCPeriod(obj)
      {
        //if (event.propertyName != "value") return;
        //if (zStrToInt(obj.value) < 1) obj.value = "";
        document.forms[0].elements["Res1"].value = "";
        document.forms[0].elements["OverPay"].value = "";
      } //zHCPeriod
      /* -------------------------------------------------------------------------------- */      
      function zHCPayment(obj)
      {
        //if (event.propertyName != "value") return;
        //if (zStrToInt(obj.value) < 1) obj.value = "";
        document.forms[0].elements["Res2"].value = "";
        document.forms[0].elements["OverPay"].value = "";
      } //zHCPayment
      /* -------------------------------------------------------------------------------- */      
      function zHCSource(vEvent)
      {
        //if (vEvent.propertyName != "value") return;
        var nSum = zStrToInt(document.forms[0].elements["Sum"].value);
        var nMonthly = zStrToInt(document.forms[0].elements["Percent"].value) / 1200;
        document.forms[0].elements["Res1"].value = "";
        document.forms[0].elements["Res2"].value = "";
        document.forms[0].elements["OverPay"].value = "";
        var nMinPay = Math.round(nSum * nMonthly);
        if (nMinPay > 0) nMinPay++;
        if (nMinPay < 1)
          document.forms[0].elements["MinPay"].value = "";
        else
          document.forms[0].elements["MinPay"].value = nMinPay;
        /*
        var vMaxPeriod = document.forms[0].elements["MaxPeriod"];
        if (nSum < 1 || nMonthly <= 0)
          vMaxPeriod.value = "";
        else
        {
          var nMaxPeriod = 1 - Math.log(1 - nSum * nMonthly / nMinPay) / Math.log(1 + nMonthly);
          nMaxPeriod = Math.round(nMaxPeriod / 12 * 10) / 10;
          vMaxPeriod.value = nMaxPeriod;
          if (nMaxPeriod > 20)
            vMaxPeriod.style.color = "red";
          else
            vMaxPeriod.style.color = "gray";
        }
        */
        zHCMinPay();
      } //zHCSource
      /* -------------------------------------------------------------------------------- */      
      function zHCLoan(nFlag)
      {
        var nSum = zStrToInt(document.forms[0].elements["Sum"].value);
        var nMonthly = zStrToInt(document.forms[0].elements["Percent"].value) / 1200;
        if (nSum < 1 || nMonthly <= 0) return(false);
        if (nFlag == 1)
        {
          var nMonthes = document.forms[0].elements["Period"].value * 12;
          if (nMonthes < 1) return(false);
          document.forms[0].elements["Payment"].value = "";
          document.forms[0].elements["Res2"].value = "";
          var vRes1 = document.forms[0].elements["Res1"];
          var nPayment = nSum * nMonthly / (1 - 1 / Math.pow((1 + nMonthly), nMonthes - 1));
          vRes1.value = Math.round(nPayment * 100) / 100;
          var nMaxPay = zStrToInt(document.forms[0].elements["MaxPay"].value);
          if (nMaxPay > 0 && zStrToInt(vRes1.value) > nMaxPay)
            vRes1.style.color = "red";
          else
            vRes1.style.color = "gray";
          document.forms[0].elements["OverPay"].value = Math.round(nPayment * nMonthes / nSum * 100) / 100;
          document.forms[0].elements["OverPay"].style.color = "gray";
        }  
        else if (nFlag == 2)
        {
          var nPayment = zStrToInt(document.forms[0].elements["Payment"].value);
          if (nPayment < 1) return(false);
          document.forms[0].elements["Period"].value = "";
          document.forms[0].elements["Res1"].value = "";
          var vRes2 = document.forms[0].elements["Res2"];
          if (nPayment > nSum * nMonthly)
          {
            var nMonthes = 1 - Math.log(1 - nSum * nMonthly / nPayment) / Math.log(1 + nMonthly);
            document.forms[0].elements["OverPay"].value = Math.round(nPayment * nMonthes / nSum * 100) / 100;
            document.forms[0].elements["OverPay"].style.color = "gray";
            vRes2.value = Math.round(nMonthes / 12 * 10) / 10;
            vRes2.style.color = "gray";
            if (zStrToInt(vRes2.value) > 20)
              vRes2.style.color = "red";
            else
              vRes2.style.color = "gray";
          }
          else
          {
            vRes2.value = document.getElementById("infin").innerText;
            document.forms[0].elements["OverPay"].value = document.getElementById("infin").innerText;
            vRes2.style.color = "red";
            document.forms[0].elements["OverPay"].style.color = "red";
          }  
        }
        return(false);  
      } //zHCLoan
      /* -------------------------------------------------------------------------------- */
      function zSearchLoad()
      {
        document.getElementsByTagName("select")["Type"].selectedIndex = 0;
      } //zSearchLoad
      /* -------------------------------------------------------------------------------- */
      function zSearchSize(obj)
      {
        if (obj.name == "Rooms")
          document.getElementsByTagName("select")["TotalSpace"].selectedIndex = 0;
        else   
          document.getElementsByTagName("select")["Rooms"].selectedIndex = 0;
      } //zSearchSize
      /* -------------------------------------------------------------------------------- */
      function zSearchAction(obj)
      {
        document.getElementsByTagName("input")["Action"].value = obj.id;
        if (obj.id == "Unit")
        { 
          document.getElementsByTagName("input")["Id"].value = obj.name;
          document.forms[0].action = "012.asp?Id=" + obj.name;
        }
        document.forms[0].submit();
        return(false);
      } //zSearchAction
      /* -------------------------------------------------------------------------------- */
      function zPhotoShow(obj, bNative, nWidth, nHeight)
      {
        if (obj.fileSize <= 0) return;
        if (!nWidth)  nWidth  = MAX_WIDTH;
        if (!nHeight) nHeight = MAX_HEIGHT;
        if (bNative)
        {
          nWidth  = obj.width;
          nHeight = obj.height;
        }
        if (oImgWin) oImgWin.close();
        oImgWin = window.open(obj.src, "_blank",
          "location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0,left=100,top=200,width=" + 
          (parseInt(nWidth) + 16) + ",height=" + (parseInt(nHeight) + 28), true);
      } //zPhotoShow
      /* -------------------------------------------------------------------------------- */
      function zBlock(nVisibility)
      {
        if (document.getElementById("trBlock") && !document.getElementById("chBlock").checked) 
            document.getElementById("trBlock").style.visibility = "hidden";
        
        var aVisibility = new Array("hidden", "visible");
        var vTD = document.getElementById("tdPrice");
        var vTR = null;
        if (vTD) vTR = vTD.parentElement;
        if (!vTR)
          ;
        else if (!document.getElementById("chBlock").checked)
          ;
        else if (vTR.getElementsByTagName("td")[0] == vTD)
          vTR.style.visibility = aVisibility[nVisibility];
        else
        {
          vTD.style.visibility = aVisibility[nVisibility];
          vTR.getElementsByTagName("td")[3] = aVisibility[nVisibility];
        }
      } //zBlock
      /* -------------------------------------------------------------------------------- */
      function zPrint(nFlag)
      {
        var nAux = nFlag;
        if (nAux > 1) nAux = 1;
        if (nAux < 0) nAux = 0;
        var aVisibility = new Array("hidden", "visible");
        for (var i=0;i<document.all.length;i++)
        {
          var vTag = document.all[i];
          if (vTag.tagName.toUpperCase() == "TD")
            switch (nFlag)
            {
              case 0: 
                vTag.style.borderColor = vTag.style.color;
                vTag.style.color = "black";
                break;
              case 1: 
                vTag.style.color = vTag.style.borderColor;
                break;
            }
          if (vTag.className == "ScreenOnly") vTag.style.visibility = aVisibility[nAux];
          if (vTag.className == "PrintOnly" ) vTag.style.visibility = aVisibility[1 - nAux];
        }
      } //zPrint
      /* -------------------------------------------------------------------------------- */
      function zPageSetup()
      {
        window.open("Images/012.gif", null, "location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,width=420,height=430");
      } //zPageSetup
      /* -------------------------------------------------------------------------------- */
      function zStrToInt(sPar, bFloat)
      {
        if (sPar.length == 0 || isNaN(sPar) || sPar == 0) return(0);
        while (sPar.substring(0, 1) == "0")
          sPar = sPar.substring(1, sPar.length);
        if (bFloat == true)
          return(parseFloat(sPar));
        else
          return(parseInt(sPar));
      } //zStrToInt
      /* -------------------------------------------------------------------------------- */      
      function zNumericField(obj, bFloat)
      {
        //if (event.propertyName != "value") return;
        if (bFloat == true) 
          var nValue = parseFloat(obj.value);
        else
          var nValue = parseInt(obj.value);
        
        if (obj.value.toString() == nValue.toString() || obj.value.length == 0)
          ; //do nothing
        else if (isNaN(nValue))
          obj.value = "";
        else if (bFloat && obj.value.toString() == nValue.toString() + ".")
          ; //do nothing
        else if (obj.value != nValue)
          obj.value = nValue;
      } //zNumericField
      /* -------------------------------------------------------------------------------- */
      function zRestDay(nMonth, nStart, nLen, sClassName, sTitle)
      {
        if (!nLen) nLen = 1;
        var oTable = document.getElementById("m" + (100+nMonth).toString().substring(1,3));
        if (!oTable) return;

        for (var nDay=nStart; nDay<nStart+nLen; nDay++)
          ext_circle:
          for (var i=0; i<oTable.rows.length; i++)
            for (var j=0; j<oTable.rows[i].cells.length; j++)
              if (parseInt(oTable.rows[i].cells[j].innerHTML) == nDay)
              {
                oTable.rows[i].cells[j].className = sClassName;
                if (sTitle)
                {
                  oTable.rows[i].cells[j].title = sTitle;
                  oTable.rows[i].cells[j].style.cursor = "default";
                }
                break ext_circle;
              }
      } //zRestDay
      /* -------------------------------------------------------------------------------- */
      function zCalendar()
      {
        var aDay = new Array("L", "M", "M", "J", "V", "S", "D");
        var aMonth = new Array("", "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie");
        for (var nMonth=1; nMonth<aMonth.length; nMonth++)
        {
          var oMonth = document.getElementById("tm" + (100+nMonth).toString().substring(1,3));
          if (oMonth) oMonth.innerHTML = aMonth[nMonth];
          var oTable = document.getElementById("m" + (100+nMonth).toString().substring(1,3));
          if (oTable)
          { 
            var oTR = oTable.getElementsByTagName("tr")[0];
            for (var i=0; i<aDay.length; i++)
              oTR.getElementsByTagName("td")[i].innerHTML = aDay[i];
          }
        }
      } //zCalendar
      /* -------------------------------------------------------------------------------- */
