
function closeWindow(windowId) {
      var event;
      if (windowId==undefined) {
          Windows.close("dflatWindow", event);
      }
      else {
          Windows.close(windowId, event);
      }
  }

  function includeMediumFlatBox(context, boxName, flatId, showCalendar, showOffers, offerList) {
      var sURLAux="";
      if (showCalendar) {
          sURLAux+="&showCalendar=1";
      }
      if (showOffers) {
          sURLAux+="&showOffers=1";
      }
      if (offerList) {
          sURLAux+="&offerList="+offerList;
      }
      var sUrl = context+"/secure/boxes/showFlatDetailMediumBox.do?flatId="+flatId+sURLAux;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }    
  
  function includeMediumFlatCalendarBox(context, boxName, flatId, initDate, endDate, paintSearch, showSmallOffers) {
      var sURLAux="";
      sURLAux+="&showCalendar=1";
      if (initDate!=undefined) {
        sURLAux+="&initDate="+initDate;
      }
      if (endDate!=undefined) {
        sURLAux+="&endDate="+endDate;
      }
      if (paintSearch != undefined) {
          sURLAux+="&paintSearch="+paintSearch;
      }
      else {
          sURLAux+="&paintSearch=true";
      }
      if (showSmallOffers) {
          sURLAux+="&showSmallOffers=1";
      }
      var sUrl = context+"/secure/boxes/showFlatDetailMediumBox.do?flatId="+flatId+sURLAux;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }    
  
  function includeMediumRoomCalendarBox(context, boxName, roomId, initDate, endDate, paintSearch) {
      var sURLAux="";
      sURLAux+="&showCalendar=1";
      if (initDate!=undefined) {
        sURLAux+="&initDate="+initDate;
      }
      if (endDate!=undefined) {
        sURLAux+="&endDate="+endDate;
      }
      if (paintSearch != undefined) {
          sURLAux+="&paintSearch="+paintSearch;
      }
      else {
          sURLAux+="&paintSearch=true";
      }
      var sUrl = context+"/secure/boxes/showRoomDetailMediumBox.do?roomId="+roomId+sURLAux;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }    
  
  function includeBigFlatBox(context, boxName, flatId) {      
      var sUrl = context+"/secure/boxes/showFlatDetailBigBox.do?flatId="+flatId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }   
  
  function includeBigRoomBox(context, boxName, roomId) {
      var sUrl = context+"/secure/boxes/showRoomDetailBigBox.do?roomId="+roomId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }   

  function includeSmallFlatBox(context, boxName, flatId) {
      if (flatId<=0) {
          $(boxName).innerHTML="<B>No flat available</B>";
          return;
      }
      var sUrl = context+"/secure/boxes/showFlatDetailSmallBox.do?flatId="+flatId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }    
  
  function includeSmallRoomBox(context, boxName, roomId) {
      if (roomId<=0) {
          $(boxName).innerHTML="<B>No room available</B>";
          return;
      }
      var sUrl = context+"/secure/boxes/showRoomDetailSmallBox.do?roomId="+roomId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }   

  function includeSearchFlatBox(context, boxName, typeNumber) {
      var sUrl;
      if (typeNumber) {
        sUrl = context+"/secure/boxes/showWebFlatSearcher"+typeNumber+"Form.do";
      }
      else {
          sUrl = context+"/secure/boxes/showWebFlatSearcherForm.do";
      }
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  }    
  
  function includeSmallOffersBox(context, boxName) {
      var sUrl = context+"/secure/boxes/showSmallOfferBox.do";
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeRequestInfoBox(context, boxName, flatId) {
      var sUrl = context+"/secure/boxes/requestInfoForm.do?flatId="+flatId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeRequestInfoBoxForRoom(context, boxName, roomId) {
      var sUrl = context+"/secure/boxes/requestInfoForm.do?roomId="+roomId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeRequestInfoExtendedBox(context, boxName, flatId) {
      var sUrl = context+"/secure/boxes/requestInfoExtendedForm.do?flatId="+flatId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeRequestInfoExtendedBoxForRoom(context, boxName, roomId) {
      var sUrl = context+"/secure/boxes/requestInfoExtendedForm.do?roomId="+roomId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
    
  function includeRequestInfoAdminBox(context, boxName, area) {
      var sUrl = context+"/secure/boxes/requestInfoAdminForm.do?area="+area;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeFlatPhotoBox(context, boxName, flatId, defaultPhotoId) {
      var sUrl = context+"/secure/boxes/showFlatPhotoBox.do?flatId="+flatId;
      if (defaultPhotoId != undefined) {
          sUrl+="&photoId="+defaultPhotoId;
      }
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeRoomPhotoBox(context, boxName, roomId, defaultPhotoId) {
      var sUrl = context+"/secure/boxes/showFlatPhotoBox.do?roomId="+roomId;
      if (defaultPhotoId != undefined) {
          sUrl+="&photoId="+defaultPhotoId;
      }
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeFlatReviewFormBox(context, boxName, flatId) {
      var sUrl = context+"/secure/boxes/showWebFlatReviewFormBox.do";
      if (flatId != undefined) {
          sUrl+="?flatId="+flatId;
      }
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
      
  function includeForOwnersFormBox(context, boxName) {
      var sUrl = context+"/secure/boxes/showWebForOwnersFormBox.do";
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function includeFlatReviewDetailBox(context, boxName, reviewId) {
      var sUrl = context+"/secure/boxes/showWebFlatReviewDetailBox.do?flatReviewId="+reviewId;
      new Ajax.Updater(boxName,sUrl,{
          parameters:{}, 
          asynchronous:true,
          evalScripts:true
          ,onComplete:function() { }
      });                  
  } 
  
  function getFunctionValidateDate(initDate, endDate) {
      if (endDate==undefined) {
          return function valid(date) { return initDate==undefined || initDate=="" || new Date(date)>new Date(initDate);}
      }
      return function valid(date) { return initDate==undefined || initDate=="" || new Date(date)>new Date(initDate) && new Date(date)<=new Date(endDate);}
  }

