// JavaScript Document
//<![CDATA[
 
      var SELECTED_RANGE = null;
      function getSelectionHandler() {
              var startDate = null;
              var ignoreEvent = false;
              return function(cal) {
                      var selectionObject = cal.selection;
 
                      // avoid recursion, since selectRange triggers onSelect
                      if (ignoreEvent)
                              return;
 
                      var selectedDate = selectionObject.get();
                      if (startDate == null) {
                              startDate = selectedDate;
                              SELECTED_RANGE = null;
                              //document.getElementById("info").innerHTML = "Click to select end date";
 
                              // comment out the following two lines and the ones marked (*) in the else branch
                              // if you wish to allow selection of an older date (will still select range)
                              cal.args.min = Calendar.intToDate(selectedDate);
                              cal.refresh();
                      } else {
                              ignoreEvent = true;
                              selectionObject.selectRange(startDate, selectedDate);
                              ignoreEvent = false;
                              SELECTED_RANGE = selectionObject.sel[0];
 
                              // alert(SELECTED_RANGE.toSource());
                              // alert(SELECTED_RANGE);
							  document.tarifas.f.value=selectionObject.print("%m-%d-%Y");//SELECTED_RANGE;
                              //
                              // here SELECTED_RANGE contains two integer numbers: start date and end date.
                              // you can get JS Date objects from them using Calendar.intToDate(number)
 
                              startDate = null;
                              //document.getElementById("info").innerHTML = selectionObject.print("%Y-%m-%d") +
                                      "<br />Click again to select new start date";
 
                              // (*)
                              cal.args.min = null;
                              cal.refresh();
                      }
              };
      };
 
      Calendar.setup({
              cont          : "cont",
              fdow          : 1,
              selectionType : Calendar.SEL_SINGLE,
              onSelect      : getSelectionHandler()
      });
 
    //]]>