<?php
  // gantt_chart.php
  // Google Gantt Chart supervisor
  // RJM Programming
  // November, 2015
  // 
  if (file_exists("csv.php")) {
    include "csv.php";
  } else if (file_exists("../csv.php")) { 
    include "../csv.php";
  }
  if (file_exists("bigemail.php")) {
    include "bigemail.php";
  } else if (file_exists("../bigemail.php")) { 
    include "../bigemail.php";
  }

  function retval($inv) {
    if (strpos($inv, "E-") !== false) return "0";
    return $inv;
  }
  
  $nineh="900";
  $twoh="300";
?>
<!doctype html><html><head><meta charset='UTF-8' />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=4, user-scalable=yes" />
<script type="text/javascript" src="http://www.rjmprogramming.com.au/gchartgen.js"></script>
    <title>Gantt Chart - RJM Programming - http://www.rjmprogramming.com.au (Copyright &copy; 2015 rjmprogramming.com.au all rights reserved.)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo.js"></script> 
 <script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/event/event.js" ></script> 
 <script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/dom/dom.js" ></script> 
 <script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/calendar/calendar.js"></script> 
 <style>
 #chart_div { z-index: -2; 
              overflow: scroll; }
 #bitsatend { z-index: 2;  }
 .faded { opacity: 0.5; } 
 #cal1SContainer { opacity: 1.0; }
 </style>
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.9.0/build/calendar/assets/skins/sam/calendar.css"> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    var sd=false;
    var mainname='';
    var firstgo=true;
    var atc=[new Date(), '', '', '', '', '', new Date()];
    var num = 0;
    var retval = "";
    var ttitle = "";
    var ttask = "";
	    YAHOO.namespace("example.calendar"); 	 
	    //YAHOO.example.calendar.init = function() { 
	    // YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1SContainer"); 
	    // YAHOO.example.calendar.cal1.render(); 
	    //} 	 
	    //YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init); 	    
   
   var lastdate=new Date();
   var prevcdsnum=[""];
   var cdrnum=[0,0],cdnum=["",""],cdsnum=["",""],prevtlbit=[], thistlbit=[], prevdate=[], prevval='', ready=false, x=-1, y=-1, elemLeft=0, elemTop=0, ir=-1, ic=-1, talkingpoint='';
   var tlurls=document.URL.replace('/GanttChart/', '/CalendarChart/').replace('gantt_chart.php','calendar_chart.php').split('&data=');
   var tltwourls=document.URL.replace('/GanttChart/', '/TimelineChart/').replace('gantt_chart.php','timeline_chart.php').split('&data=');
   var tlthreeurls=document.URL.replace('/GanttChart/', '/AnnotatedTimelineChart/').replace('gantt_chart.php','annotatedtimeline_chart.php').split('&data=');
   var tlurl=tlurls[0];
   var tltwourl=tltwourls[0];
   var tlthreeurl=tlthreeurls[0];
   
   function fillindata() {
     var bed=document.getElementById('bdataval');
     if (bed == null) {
       document.getElementById('bitsatend').innerHTML+='<input type="hidden" id="bdataval" value="' + encodeURIComponent(paramdata) + '"></input>';
     }
   }
   
   function filldata() {
     var bed=document.getElementById('bedata');
     if (bed != null) {
       if (bed.value == '') {
         bed.value=encodeURIComponent(paramdata);
       }
     }
   }
   
   function numsinstr(viad) {
     cdrnum=[0,0];
     var numsofar=0, isn=false, snum='';
     viad+=' ';
     for (var ii=0; ii<viad.length; ii++) {
     //if (ii > 0) alert(viad.substring(0,ii));
     //if (ii == 0) alert(ii);
       if ((viad.substring(ii, eval(1 + ii)) >= '0' && viad.substring(ii, eval(1 + ii)) <= '9') || viad.substring(ii, eval(1 + ii)) == '-' || viad.substring(ii, eval(1 + ii)) == '.') {
//alert('+=' + viad.substring(ii, eval(1 + ii)));
        snum+=('' + viad.substring(ii, eval(1 + ii)));
//alert('snum=' + snum);
       } else if (snum.length >= 1 && snum.replace('-','').replace('.','') != '' && snum.indexOf('--') == -1 && snum.indexOf('..') == -1) {
//alert('SNUM=' + snum);
        cdrnum[numsofar]=eval(snum);
        snum='';
        numsofar++;
//alert('numsofar=' + numsofar + ' ... ' + viad);
        if (eval(numsofar) >= 2) return cdrnum;
       } else {
//alert('Snum was =' + snum);
        snum='';
       }
     }
     return cdrnum;
   }
   
   function retnum(viad) {
     var mths=["Jan", "Feb", "Mar", "Apr", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
     var retval=[], ioff=1;
     var hbits=document.head.innerHTML.split('["' + viad + '",');
     if (eval(hbits.length) == 1) hbits=document.head.innerHTML.split('[~' + viad + '~,');
//alert(75);
//http://localhost:8888/gantt_chart.php?title=Research&onclick=y&options=456&desc=Research&onclick=y&options=456
//&data=[~taskid1~,~ergerg~,newDate%282015,10,20%29,newDate%282015,10,21%29,null,0.0,~~],[~taskid2~,~rwgerg~,null,newDate%282015,10,22%29,86400000,0.0,~~],[~taskid3%22,%22erverv%22,null,newDate%282015,10,23%29,86400000,0.0,%22%22]
     cdrnum=numsinstr(viad);
     //alert('[~' + viad + '~,');
     if (eval(hbits.length) >= 2) {
     //alert(hbits[1]);
          
          var vls=hbits[1].replace(']]);',',').replace(']',',').split(',');
          if (eval(vls.length) >= 2) {
//alert(0);
          atc[1]=viad; // taskid
          atc[2]=vls[0].replace('"','').replace('"',''); // task description
//alert(1);
          if (eval(vls.length) >= 6 && vls[1] != 'null') {
//alert(12);
           sd=true;
           atc[6]=new Date(eval(vls[ioff + 0].replace('new Date(','')), eval(vls[ioff + 1]), eval(vls[ioff + 2].replace(')',''))); // start date
//alert(2);
           atc[3]=vls[ioff + 6].replace('"','').replace('"','');  // duration
           atc[4]=vls[ioff + 7].replace('"','').replace('"','');  // percent complete
           atc[5]=vls[ioff + 8].replace('"','').replace('"','').replace(/~/g,'');  // dependencies
           atc[0]=new Date(eval(vls[ioff + 3].replace('new Date(','')), eval(vls[ioff + 4]), eval(vls[ioff + 5].replace(')','')));  // end date
           if (eval(vls[ioff + 6].replace('"','').replace('"','').replace('null','0')) == 0) {
             atc[3] = Math.floor(( atc[0] - atc[6] )  / 86400000 );
           } else if (eval(vls[ioff + 6].replace('"','').replace('"','').replace('null','0')) >= 100000) {
             atc[3] = Math.floor(( atc[0] - atc[6] )  / 86400000 );
           }
           mainname='/' + vls[0].replace('"','').replace('"','');
     //alert(vls.length + ' ... ' + vls[0] + ',' + vls[1] + ',' + vls[2]);
     //alert(vls.length + ' ... ' + vls[1] + ',' + vls[2] + ',' + vls[3]);
           cdnum=[mths[eval(vls[ioff + 1])] + ' ' + vls[ioff + 2].replace(')','') + ', ' + vls[ioff + 0].replace('new Date(',''),  mths[eval(vls[ioff + 4])] + ' ' + vls[ioff + 5].replace(')','') + ', ' + vls[ioff + 3].replace('new Date(','')];
           cdsnum=[(vls[ioff + 0] + ',' + vls[ioff + 1] + ',' + vls[ioff + 2]), (vls[ioff + 3] + ',' + vls[ioff + 4] + ',' + vls[ioff + 5])];
           retval=[eval(vls[ioff + 0] + ',' + vls[ioff + 1] + ',' + vls[ioff + 2]), eval(vls[ioff + 3] + ',' + vls[ioff + 4] + ',' + vls[ioff + 5])];
//alert(177);
          } else if (eval(vls.length) >= 4 && vls[1] == 'null') {
          sd=false;
     //alert(vls.length + ' ... ' + vls[0] + ',' + vls[1] + ',' + vls[2]);
     //alert(vls.length + ' ... ' + vls[1] + ',' + vls[2] + ',' + vls[3]);
//alert(vls[ioff + 3 - 2].replace('new Date(','') + ' ... ' + vls[ioff + 5 - 2].replace(')','') + ' +++ ' + vls[ioff + 4 - 2]);
//alert(vls[ioff + 3 - 2].replace('new Date(','') + ' ... ' + vls[ioff + 5 - 2].replace(')','') + ' +++ ' + vls[ioff + 4 - 2]);
           atc[0]=new Date(eval(vls[ioff + 3 - 2].replace('new Date(','')), eval(vls[ioff + 4 - 2]), eval(vls[ioff + 5 - 2].replace(')','')));
//alert(22);
           if (eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0')) >= 100000) {
             vls[ioff + 4]=eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0') / 86400000 );
           }
           atc[3]=('' + vls[ioff + 4]).replace('"','').replace('"','');  // duration
//alert(222);
           atc[4]=vls[ioff + 5].replace('"','').replace('"','');  // percent complete
//alert(322);
           atc[5]=vls[ioff + 6].replace('"','').replace('"','').replace(/~/g,'');  // dependencies
//alert(422);
           atc[6]=new Date();  // start date
//alert(eval(vls[ioff + 4].replace('"','').replace('"','').replace('null','0')));
           if (eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0')) >= 100000) {
             atc[6].setDate(atc[0].getDate() - eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0') / 86400000));
           } else {
             atc[6].setDate(atc[0].getDate() - eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0')));
           }
//alert(atc[0].toLocaleString());
//alert(atc[6].toLocaleString());
           if (eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0')) == 0) {
             atc[3] = Math.floor(( atc[0] - atc[6] )  / 86400000 );
           } else if (eval(('' + vls[ioff + 4]).replace('"','').replace('"','').replace('null','0')) >= 100000) {
             atc[3] = Math.floor(( atc[0] - atc[6] )  / 86400000 );
           }
           mainname='/' + vls[0].replace('"','').replace('"','');
           cdnum=[-vls[ioff],  mths[eval(vls[ioff + 4 - 2])] + ' ' + vls[ioff + 5 - 2].replace(')','') + ', ' + vls[ioff + 3 - 2].replace('new Date(','')];
//alert(76);
           cdsnum=['0,0,0', (vls[ioff + 3 - 2] + ',' + vls[ioff + 4 - 2] + ',' + vls[ioff + 5 - 2])];
//alert(77);
           retval=[-vls[ioff], eval(vls[ioff + 3 - 2] + ',' + vls[ioff + 4 - 2] + ',' + vls[ioff + 5 - 2])];
//alert(78);
          }
          }
     }
     return retval;
   }

    function saveSelection(e) {
        ir=e.row; 
    }
   
   function oppretnum(viad) {
     var retval=0;
     var yrs=viad.split(',');
     if (yrs.length == 2) {
       var mts=yrs[0].split(' ');
       if (mts.length == 2) {
         var mth='';
         if (mts[0].substring(0,3).toLowerCase() == 'jan') mth=0;
         if (mts[0].substring(0,3).toLowerCase() == 'feb') mth=1;
         if (mts[0].substring(0,3).toLowerCase() == 'mar') mth=2;
         if (mts[0].substring(0,3).toLowerCase() == 'apr') mth=3;
         if (mts[0].substring(0,3).toLowerCase() == 'may') mth=4;
         if (mts[0].substring(0,3).toLowerCase() == 'jun') mth=5;
         if (mts[0].substring(0,3).toLowerCase() == 'jul') mth=6;
         if (mts[0].substring(0,3).toLowerCase() == 'aug') mth=7;
         if (mts[0].substring(0,3).toLowerCase() == 'sep') mth=8;
         if (mts[0].substring(0,3).toLowerCase() == 'oct') mth=9;
         if (mts[0].substring(0,3).toLowerCase() == 'nov') mth=10;
         if (mts[0].substring(0,3).toLowerCase() == 'dec') mth=11;
         //alert('[new Date(' + yrs[1].replace(' ','') + ',' + mth + ',' + mts[1] + '),');
         thistlbit='new Date(' + yrs[1].replace(' ','') + ',' + mth + ',' + mts[1] + ')';
         var hbits=document.head.innerHTML.split('[new Date(' + yrs[1].replace(' ','') + ',' + mth + ',' + mts[1] + '),');
         if (hbits.length == 2) {
          var vls=hbits[1].split(']');
          return eval(vls[0]);
         }
       }
     } 
     return retval;
   } 

<?php 
  echo "var dataTable, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata); \n";
 
      $GETtp="";
      if (isset($_GET['tp'])) $GETtp = urldecode($_GET['tp']);
      if (isset($_POST['tp'])) $GETtp = urldecode($_POST['tp']);
      if ($GETtp != "") echo "\n talkingpoint=String.fromCharCode(10) + String.fromCharCode(10) + " . '"' . str_replace("`", '" + String.fromCharCode(10) + "', str_replace("\n", '" + String.fromCharCode(10) + "', $GETtp)) . '"' . " + String.fromCharCode(10) + String.fromCharCode(10); \n";

      $GETr = "";
      $GETc = "";
      if (isset($_GET['r'])) $GETr = urldecode($_GET['r']);
      if (isset($_POST['r'])) $GETr = urldecode($_POST['r']);
      if (isset($_GET['c'])) $GETc = urldecode($_GET['c']);
      if (isset($_POST['c'])) $GETc = urldecode($_POST['c']);
      if ($GETr != "") echo "\n ir=eval('" . $GETr . "'); \n";
      if ($GETc != "") echo "\n ic=eval('" . $GETc . "'); \n";

      $GETx = "";
      $GETy = "";
      if (isset($_GET['x'])) $GETx = urldecode($_GET['x']);
      if (isset($_POST['x'])) $GETx = urldecode($_POST['x']);
      if (isset($_GET['y'])) $GETy = urldecode($_GET['y']);
      if (isset($_POST['y'])) $GETy = urldecode($_POST['y']);
      if ($GETx != "" && $GETy != "") {
        echo "\n x=eval('" . $GETx . "'); \n";
        echo "\n y=eval('" . $GETy . "'); \n";
      }

      $GETtitle = "Research";
      $GETtask = ""; //"Task";
      $GETdesc = "Find sources";
      $GETdata = '["Research", "Find sources", new Date(2015, 0, 1), new Date(2015, 0, 5), null,  100,  null], ["Write", "Write paper", null, new Date(2015, 0, 9), daysToMilliseconds(3), 25, "Research,Outline"], ["Cite", "Create bibliography", null, new Date(2015, 0, 7), daysToMilliseconds(1), 20, "Research"], ["Complete", "Hand in paper", null, new Date(2015, 0, 10), daysToMilliseconds(1), 0, "Cite,Write"], ["Outline", "Outline paper", null, new Date(2015, 0, 6), daysToMilliseconds(1), 100, "Research"]';



      if (isset($_POST['data'])) {
       $nineh="1200";
       $twoh="430";
       $GETdata = str_replace('~','"',urldecode(checkdatadata0('POST',$_POST['data'])));
       //echo "\n pardata = " . '"' . $_POST['data'] . '"; ' . " \n";
       echo "\n paramdata='" . $GETdata . "'; \n setTimeout(fillindata, 300); \n setTimeout(filldata, 3000); \n"; // = decodeURIComponent(pardata); " . " \n";
       
      } else if (isset($_GET['data'])) {
       $prevg=str_replace('~','"',urldecode($_GET['data'])); //$_GET['data'];
       $nineh="900";
       $twoh="300";
       $GETdata = str_replace('~','"',urldecode(checkdatadata0('GET',$_GET['data'])));
       if ($prevg != $GETdata) {
        $nineh="1200";
        $twoh="430";
        echo "\n paramdata='" . $GETdata . "'; \n setTimeout(fillindata, 300); \n setTimeout(filldata, 3000); \n"; // = decodeURIComponent(pardata); " . " \n";
       }
      }
      if (isset($_POST['title'])) {
       $GETtitle = str_replace("~~", "'", str_replace('~', '"', str_replace("`", "'", urldecode($_POST['title']))));
       $GETtask = urldecode($_POST['task']);
       $GETdesc = str_replace("~~", "'", str_replace('~', '"', str_replace("`", "'", urldecode($_POST['desc']))));
      } else if (isset($_GET['title'])) {
       //$GETtitle = str_replace("~~", "##", $_GET['title']);
       $GETtitle = str_replace("~~", "'", str_replace('~', '"', str_replace("`", "'", $_GET['title'])));
       //$GETtitle = str_replace("##", "'", $GETtitle);
       $GETtask = $_GET['task'];
       //$GETdesc = str_replace("~~", "##", $_GET['desc']);
       $GETdesc = str_replace("~~", "'", str_replace('~', '"', str_replace("`", "'", $_GET['desc'])));
       //$GETdesc = str_replace("##", "'", $GETdesc);
      } 

      echo " var colnames= '" . str_replace("'", "", $GETdesc) . "'; \n";

      echo " function myselectfunction() {
 if (ready) {
  var pstr='',relist=['remail',''],ire,thisval='',thisdate=[],ansbits,avblurb=talkingpoint,ioffset=0,ans=null,doit=true,kl,lk, thisnum, num=0,message = '', dparts, colparts=colnames.split(','), colav=new Array(), predparts, postdparts, diffcolnames=colnames,diffvalues;
  if (firstgo) {
      firstgo=false;
      if (eval(ir) >= 0 && eval(ic) < 0) {
      var str = dataTable.getFormattedValue(ir, 0);
//alert(71111 + ' ... ' + str);
      message += '{row:' + ir + ', column:none}; value (col 0) = ' + str;
          thisval=str;
          thisdate=retnum(str);
//alert(72111 + ' ... ' + str);
          pstr=str + ' ' + colparts[0];
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'On These Days=O' + String.fromCharCode(10);
          if (eval(thisdate[0]) >= 0) avblurb+='Show the Elapsed Number of Days=T' + String.fromCharCode(10);
          avblurb+='Add to a Calendar Representation=A[' + cdrnum[0] + ',' + cdrnum[1] + '] (anything after A overrides Calendar label of [' + cdrnum[0] + ',' + cdrnum[1] + '])' + String.fromCharCode(10);
          avblurb+='Add to a Calendar Representation and Show in New Window=N[' + cdrnum[0] + ',' + cdrnum[1] + '] (as above)' + String.fromCharCode(10);
//alert(73111 + ' ... ' + str);
          if (tlurl.indexOf('data=') != -1) avblurb+='Show the Current Calendar Representation on Top of This Gantt Chart=C ' + String.fromCharCode(10);
          avblurb+='Add to a Timeline=B[' + mainname.replace('/','') + '] (anything after B overrides Timeline label of ' + mainname.replace('/','') + ')' + String.fromCharCode(10);
          avblurb+='Add to a Timeline Representation and Show in New Window=W[' + mainname.replace('/','') + '] (as above)' + String.fromCharCode(10);
          if (tltwourl.indexOf('data=') != -1) avblurb+='Show the Current Annotated Timeline Representation on Top of This Gantt Chart=Y ' + String.fromCharCode(10);
          avblurb+='Add to a Annotated Timeline=F[' + atc[2] + '] (anything after F overrides Annotated Timeline label of ' + atc[2] + ')' + String.fromCharCode(10);
          avblurb+='Add to a Annotated Timeline Representation and Show in New Window=X[' + mainname.replace('/','') + '] (as above)' + String.fromCharCode(10);
          if (tlthreeurl.indexOf('data=') != -1) avblurb+='Show the Current Annotated Timeline Representation on Top of This Gantt Chart=Z ' + String.fromCharCode(10);
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10);
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          //ans=prompt('Regarding ' + colparts[0] + ' (' + thisval + mainname + ') you clicked date range ' + nxd + ' to ' + thisdate[1] + ' ' + avblurb, paramdata);
          if (sd == false) {
          ans=prompt('Regarding ' + colparts[0] + ' (' + thisval + mainname + ') you clicked end date ' + thisdate[1] + ' ' + avblurb, paramdata);
          } else {
          ans=prompt('Regarding ' + colparts[0] + ' (' + thisval + mainname + ') you clicked date ' + thisdate[0] + ' to ' + thisdate[1] + ' ' + avblurb, paramdata);
          }
//alert(74111 + ' ... ' + str);
          if (ans != null) {
//alert(75111 + ' ... ' + str);
            if (ans != '' && ans != paramdata) {
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             ansbits=ans.split(' ');
             if (ansbits[0].indexOf('@') != -1) {
              if (document.getElementById('altemail')) {
              document.getElementById('altemail').value=ansbits[0];
              document.getElementById('remail').href=document.getElementById('remail').href.replace('mt=','mt=' + ansbits[0] + '&junk=youshallneverfindthis').replace('get=','mt=' + ansbits[0] + '&junk=youshallneverfindthis');
              }
              if (document.getElementById('email')) relist[1]='email';
              for (ire=0; ire<2; ire++) {
              if (relist[ire] != '') {
              document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace('fillin.email@address', ansbits[0]);
              if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&r=') + ir) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&r=') + item.row;
              if (ansbits.length > 1) {
                ans=ans.replace(ansbits[0] + ' ','');
                while (ans.indexOf(' ') != -1) {
                  ans=ans.replace(' ','%20');
                }
                while (ans.indexOf('?') != -1) {
                  ans=ans.replace('?','%3f');
                }
                while (ans.indexOf('&') != -1) {
                  ans=ans.replace('&','%26');
                }
                if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) == -1 && document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) == -1) {
                  document.getElementById(relist[ire]).href+=encodeURIComponent('&tp=') + encodeURIComponent(ans);
                } else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('&tp='), encodeURIComponent('&tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
				} else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('?tp='), encodeURIComponent('?tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
                }
//alert(76111 + ' ... ' + str);
                while (document.getElementById(relist[ire]).href.indexOf(' ') != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(' ','%20');
                }
                //alert(document.getElementById(relist[ire]).href);
              }
              document.getElementById(relist[ire]).click();
              }
              }
             } else if (ans.substring(0,1).toLowerCase() == 'f' || ans.substring(0,1).toLowerCase() == 'x') {

              if (eval(ans.length) > 1) {
               //pstr=ans.substring(1);
               if (ans.substring(1,2) == '[') atc[2]=ans.substring(1);
              }
              if (eval(('' + atc[3]).replace('null','0')) >= 100000) {
                atc[3]=eval(('' + atc[3]).replace('null','0')) /  86400000;
              }
              if (tlthreeurl.indexOf('data=') == -1) {
               tlthreeurl=tlthreeurl.replace('&desc=','&olddesc=') + '&desc1=' + encodeURIComponent('Duration');
               tlthreeurl+='&title1=' + encodeURIComponent('Task ID');
               tlthreeurl+='&text1=' + encodeURIComponent('Task Description');
               tlthreeurl+='&desc2=' + encodeURIComponent('Percent Complete');
               tlthreeurl+='&title2=' + encodeURIComponent('Dependencies');
               tlthreeurl+='&text2=' + encodeURIComponent('Start Date');
               tlthreeurl+='&data=[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               lastdate=atc[0];
              } else {
               tlthreeurl+=',';
               if (eval(1900 + atc[6].getYear()) > eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               } else if (eval(0 + atc[6].getMonth()) > eval(0 + lastdate.getMonth()) && eval(1900 + atc[6].getYear()) == eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               } else if (eval(atc[6].getDate()) >= eval(lastdate.getDate()) && eval(0 + atc[6].getMonth()) == eval(0 + lastdate.getMonth()) && eval(1900 + atc[6].getYear()) == eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               }
               lastdate=atc[0];
              }
              tlthreeurl+='[' + cdsnum[1] + ',' + encodeURIComponent('-' + ('' + atc[3]).replace('null','0').replace('-','')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('Start Date is ' + atc[6].toLocaleString()) + '~]';
              if (ans.substring(0,1).toLowerCase() == 'x') window.open(iftoobig('',tlthreeurl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'b' || ans.substring(0,1).toLowerCase() == 'w') {
              if (eval(ans.length) > 1) {
               //pstr=ans.substring(1);
               if (ans.substring(1,2) == '[') mainname=ans.substring(1);
              }
              if (tltwourl.indexOf('data=') == -1) {
               tltwourl+='&data=';
              } else {
               tltwourl+=',';
              }
              if (eval(thisdate[0]) >= 0) {
              //alert('cdrnuM[0]=' + cdrnum[0] + ' cdsNum[0]=' + cdsnum[0]);
              tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + cdsnum[0] + '' + ',' + cdsnum[1] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              } else if (prevcdsnum[0].length > 0) {
              tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + prevcdsnum[0] + '' + ',' + cdsnum[1] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              } else {
              //alert('cdrNum[0]=' + cdrnum[0] + ' cdsNum[1]=' + cdsnum[1]);
              //tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + cdsnum[0] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              }
              if (ans.substring(0,1).toLowerCase() == 'w') window.open(iftoobig('',tltwourl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'a' || ans.substring(0,1).toLowerCase() == 'n') {
              if (eval(ans.length) > 1) {
               //pstr=ans.substring(1);
               if (ans.substring(1,2) == '[') eval('cdrnum=' + ans.substring(1));
              }
              if (tlurl.indexOf('data=') == -1) {
               tlurl+='&data=';
              } else {
               tlurl+=',';
              }
              if (eval(thisdate[0]) >= 0) {
              //alert(eval(thisdate[0]) + ' cdrnum[0]=' + cdrnum[0] + ' cdsNum[0]=' + cdsnum[0] + ' ' + 'cdrnum[1]=' + cdrnum[1] + ' cdsNum[1]=' + cdsnum[1]);
              tlurl+='[' + cdsnum[0] + ',' + cdrnum[0] + '' + '],[' + cdsnum[1] + ',' + cdrnum[1] + '' + ']';
              } else {
              //alert(eval(thisdate[0]) + ' Cdrnum[0]=' + cdrnum[0] + ' cdsNum[1]=' + cdsnum[1]);
              tlurl+='[' + cdsnum[1] + ',' + cdrnum[0] + '' + ']';
              }
              if (ans.substring(0,1).toLowerCase() == 'n') window.open(iftoobig('',tlurl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              location.href=iftoobig('',tlurl);
             } else if (ans.substring(0,1).toLowerCase() == 'y') {
              location.href=iftoobig('',tltwourl);
             } else if (ans.substring(0,1).toLowerCase() == 'z') {
              location.href=iftoobig('',tlthreeurl);
             } else if (ans.substring(0,1).toLowerCase() == 't') {
              var d1 = new Date(prevdate);
              var d2 = new Date(str);
              if (1 == 2) {
              document.getElementById('myf1').innerHTML=('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              } else {
              alert('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              //var wo=window.open('','_blank','top=200,left=200,width=300,height=50');
              //wo.document.write('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              //if (document.URL.indexOf('&qq=') == -1) {
              //  location.href=document.URL + '&qq=1';
              //} else {
              //  location.href=document.URL + '9';
              //}
              }
             } else if (ans.substring(0,1).toLowerCase() == 'o') {
              window.open('https://www.google.com/search?q=' + cdnum[0].replace(',','%2C').replace(' ','+').replace(' ','+'), '_blank', 'top=100,left=100,width=400,height=400');
              window.open('https://www.google.com/search?q=' + cdnum[1].replace(',','%2C').replace(' ','+').replace(' ','+'), '_blank', 'top=150,left=150,width=400,height=400');
             } else if (document.URL.indexOf('&data=') == -1) {
              location.href=iftoobig('',document.URL + '&data=' + ourencodeURIComponent(ans));
             } else {
              location.href=iftoobig('',document.URL.replace(pardata, ourencodeURIComponent(ans)));
             }
            }
          }
          prevdate=thisdate;
          prevval=str;
          prevtlbit=thistlbit;
       ir=-1;
       ic=-1;
       return;
      }
  }
  var selection = chart.getSelection();
   // console.log(selection);
  for (var i = 0; i < selection.length; i++) {
    var item = selection[i];
//alert(111);
//if (item.row != null) alert(121);
//if (item.column != null) alert(131);
    if ((item.row != null && item.column != null) || (eval(ir) >= 0 && eval(ic) >= 0)) {
//alert(1111);
      if (eval(ir) >= 0 && eval(ic) >= 0) {
  //alert(999);
        item.row=ir;
        item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
//alert(61111);
        ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      var str = dataTable.getFormattedValue(item.row, item.column);

    } else if ((item.row != null && item.column == null) || (eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=ir;
        //item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
//alert(61111);
        ir=item.row;
        ic=-1;
        //document.title=ir + ',' + ic;
      }
      var str = dataTable.getFormattedValue(item.row, 0);
//alert(71111 + ' ... ' + str);
      message += '{row:' + item.row + ', column:none}; value (col 0) = ' + str;
          thisval=str;
          thisdate=retnum(str);
          pstr=str + ' ' + colparts[0];
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'On These Days=O' + String.fromCharCode(10);
          if (eval(thisdate[0]) >= 0) avblurb+='Show the Elapsed Number of Days=T' + String.fromCharCode(10);
          avblurb+='Add to a Calendar Representation=A[' + cdrnum[0] + ',' + cdrnum[1] + '] (anything after A overrides Calendar label of [' + cdrnum[0] + ',' + cdrnum[1] + '])' + String.fromCharCode(10);
          avblurb+='Add to a Calendar Representation and Show in New Window=N[' + cdrnum[0] + ',' + cdrnum[1] + '] (as above)' + String.fromCharCode(10);
//alert(73111 + ' ... ' + str);
          if (tlurl.indexOf('data=') != -1) avblurb+='Show the Current Calendar Representation on Top of This Gantt Chart=C ' + String.fromCharCode(10);
          avblurb+='Add to a Timeline=B[' + mainname.replace('/','') + '] (anything after B overrides Timeline label of ' + mainname.replace('/','') + ')' + String.fromCharCode(10);
          avblurb+='Add to a Timeline Representation and Show in New Window=W[' + mainname.replace('/','') + '] (as above)' + String.fromCharCode(10);
          if (tltwourl.indexOf('data=') != -1) avblurb+='Show the Current Annotated Timeline Representation on Top of This Gantt Chart=Y ' + String.fromCharCode(10);
          avblurb+='Add to a Annotated Timeline=F[' + atc[2] + '] (anything after F overrides Annotated Timeline label of ' + atc[2] + ')' + String.fromCharCode(10);
          avblurb+='Add to a Annotated Timeline Representation and Show in New Window=X[' + mainname.replace('/','') + '] (as above)' + String.fromCharCode(10);
          if (tlthreeurl.indexOf('data=') != -1) avblurb+='Show the Current Annotated Timeline Representation on Top of This Gantt Chart=Z ' + String.fromCharCode(10);
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10);
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          if (sd == false) {
          ans=prompt('Regarding ' + colparts[0] + ' (' + thisval + mainname + ') you clicked end date ' + thisdate[1] + ' ' + avblurb, paramdata);
          } else {
          ans=prompt('Regarding ' + colparts[0] + ' (' + thisval + mainname + ') you clicked date ' + thisdate[0] + ' to ' + thisdate[1] + ' ' + avblurb, paramdata);
          }
          if (ans != null) {
            if (ans != '' && ans != paramdata) {
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             ansbits=ans.split(' ');
             if (ansbits[0].indexOf('@') != -1) {
              if (document.getElementById('altemail')) {
              document.getElementById('altemail').value=ansbits[0];
              document.getElementById('remail').href=document.getElementById('remail').href.replace('mt=','mt=' + ansbits[0] + '&junk=youshallneverfindthis').replace('get=','mt=' + ansbits[0] + '&junk=youshallneverfindthis');
              }
              if (document.getElementById('email')) relist[1]='email';
              for (ire=0; ire<2; ire++) {
              if (relist[ire] != '') {
              document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace('fillin.email@address', ansbits[0]);
              if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&r=') + item.row) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&r=') + item.row;
              //if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&c=') + item.column) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&c=') + item.column;
              if (ansbits.length > 1) {
                ans=ans.replace(ansbits[0] + ' ','');
                while (ans.indexOf(' ') != -1) {
                  ans=ans.replace(' ','%20');
                }
                while (ans.indexOf('?') != -1) {
                  ans=ans.replace('?','%3f');
                }
                while (ans.indexOf('&') != -1) {
                  ans=ans.replace('&','%26');
                }
                if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) == -1 && document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) == -1) {
                  document.getElementById(relist[ire]).href+=encodeURIComponent('&tp=') + encodeURIComponent(ans);
                } else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('&tp='), encodeURIComponent('&tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
				} else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('?tp='), encodeURIComponent('?tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
                }
                while (document.getElementById(relist[ire]).href.indexOf(' ') != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(' ','%20');
                }
                //alert(document.getElementById(relist[ire]).href);
              }
              document.getElementById(relist[ire]).click();
              }
              }
             } else if (ans.substring(0,1).toLowerCase() == 'f' || ans.substring(0,1).toLowerCase() == 'x') {
              if (eval(ans.length) > 1) {
               //pstr=ans.substring(1);
               if (ans.substring(1,2) == '[') atc[2]=ans.substring(1);
              }
              if (eval(('' + atc[3]).replace('null','0')) >= 100000) {
                atc[3]=eval(('' + atc[3]).replace('null','0')) /  86400000;
              }
              if (tlthreeurl.indexOf('data=') == -1) {
               tlthreeurl=tlthreeurl.replace('&desc=','&olddesc=') + '&desc1=' + encodeURIComponent('Duration');
               tlthreeurl+='&title1=' + encodeURIComponent('Task ID');
               tlthreeurl+='&text1=' + encodeURIComponent('Task Description');
               tlthreeurl+='&desc2=' + encodeURIComponent('Percent Complete');
               tlthreeurl+='&title2=' + encodeURIComponent('Dependencies');
               tlthreeurl+='&text2=' + encodeURIComponent('Start Date');
               tlthreeurl+='&data=[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               lastdate=atc[0];
              } else {
               tlthreeurl+=',';
               if (eval(1900 + atc[6].getYear()) > eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               } else if (eval(0 + atc[6].getMonth()) > eval(0 + lastdate.getMonth()) && eval(1900 + atc[6].getYear()) == eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               } else if (eval(atc[6].getDate()) >= eval(lastdate.getDate()) && eval(0 + atc[6].getMonth()) == eval(0 + lastdate.getMonth()) && eval(1900 + atc[6].getYear()) == eval(1900 + lastdate.getYear())) {
                tlthreeurl+='[newDate(' + eval(1900 + atc[6].getYear()) + ',' + eval(0 + atc[6].getMonth()) + ',' + atc[6].getDate() + '),' + encodeURIComponent(('' + atc[3]).replace('null','0')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('End Date is ' + atc[0].toLocaleString()) + '~],';
               }
               lastdate=atc[0];
              }
              tlthreeurl+='[' + cdsnum[1] + ',' + encodeURIComponent('-' + ('' + atc[3]).replace('null','0').replace('-','')) + ',~' + encodeURIComponent(atc[1]) + '~,~' + encodeURIComponent(atc[2]) + '~,' + encodeURIComponent(('' + atc[4]).replace('null','0')) + ',~' + encodeURIComponent(('' + atc[5]).replace('null','')) + '~,~' + encodeURIComponent('Start Date is ' + atc[6].toLocaleString()) + '~]';
              if (ans.substring(0,1).toLowerCase() == 'x') window.open(iftoobig('',tlthreeurl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'b' || ans.substring(0,1).toLowerCase() == 'w') {
              if (eval(ans.length) > 1) {
               //pstr=ans.substring(1);
               if (ans.substring(1,2) == '[') mainname=ans.substring(1);
              }
              if (tltwourl.indexOf('data=') == -1) {
               tltwourl+='&data=';
              } else {
               tltwourl+=',';
              }
              if (eval(thisdate[0]) >= 0) {
              //alert('cdrnuM[0]=' + cdrnum[0] + ' cdsNum[0]=' + cdsnum[0]);
              tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + cdsnum[0] + '' + ',' + cdsnum[1] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              } else if (prevcdsnum[0].length > 0) {
              tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + prevcdsnum[0] + '' + ',' + cdsnum[1] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              } else {
              //alert('cdrNum[0]=' + cdrnum[0] + ' cdsNum[1]=' + cdsnum[1]);
              //tltwourl+='[~' + encodeURIComponent(mainname.replace('/','')) + '~,' + cdsnum[0] + '' + ']';
              prevcdsnum[0]=cdsnum[1];
              }
              if (ans.substring(0,1).toLowerCase() == 'w') window.open(iftoobig('',tltwourl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'a' || ans.substring(0,1).toLowerCase() == 'n') {
              if (eval(ans.length) > 1) {
               pstr=ans.substring(1);
              }
              if (tlurl.indexOf('data=') == -1) {
               tlurl+='&data=';
              } else {
               tlurl+=',';
              }
              tlurl+='[~' + encodeURIComponent(pstr) + '~,' + prevtlbit + ',' + thistlbit + ']';
              if (ans.substring(0,1).toLowerCase() == 'w') window.open(iftoobig('',tlurl), '_blank', 'top=100,left=100,width=500,height=500');
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              location.href=iftoobig('',tlurl);
             } else if (ans.substring(0,1).toLowerCase() == 'y') {
              location.href=iftoobig('',tltwourl);
             } else if (ans.substring(0,1).toLowerCase() == 'z') {
              location.href=iftoobig('',tlthreeurl);
             } else if (ans.substring(0,1).toLowerCase() == 't') {
              var d1 = new Date(prevdate);
              var d2 = new Date(str);
              if (1 == 2) {
              document.getElementById('myf1').innerHTML=('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              } else {
              alert('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              //var wo=window.open('','_blank','top=200,left=200,width=300,height=50');
              //wo.document.write('It is ' + Math.floor((thisdate[1] - thisdate[0]) / (1000*60*60*24)) + ' days from ' + thisdate[0] + ' to ' + thisdate[1] + '.');
              //if (document.URL.indexOf('&qq=') == -1) {
              //  location.href=document.URL + '&qq=1';
              //} else {
              //  location.href=document.URL + '9';
              //}
              }
             } else if (ans.substring(0,1).toLowerCase() == 'o') {
              window.open('https://www.google.com/search?q=' + cdnum[0].replace(',','%2C').replace(' ','+').replace(' ','+'), '_blank', 'top=100,left=100,width=400,height=400');
              window.open('https://www.google.com/search?q=' + cdnum[1].replace(',','%2C').replace(' ','+').replace(' ','+'), '_blank', 'top=150,left=150,width=400,height=400');
             } else if (document.URL.indexOf('&data=') == -1) {
              location.href=iftoobig('',document.URL + '&data=' + ourencodeURIComponent(ans));
             } else {
              location.href=iftoobig('',document.URL.replace(pardata, ourencodeURIComponent(ans)));
             }
            }
          }
          prevdate=thisdate;
          prevval=str;
          prevtlbit=thistlbit;
    } else if ((item.row == null && item.column != null) || (eval(ir) < 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        //item.row=ir;
        item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
//alert(61111);
        ir=-1;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
//alert(61111);
      var str = dataTable.getFormattedValue(0, item.column);
      message += '{row:none, column:' + item.column + '}; value (row 0) = ' + str;
    }
  }
  if (message == '') {
    message = 'nothing';
  }
  if (1 == 2) console.log('You selected ' + message);
 }
       ir=-1;
       ic=-1;
}     
      //);  
      ";

      
      echo ' google.load("visualization", "1.1", {packages:["gantt"]}); ' . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n\nfunction daysToMilliseconds(days) { return days * 24 * 60 * 60 * 1000; }\n\n";
      
      echo ' function drawChart() { ' . "\n";
      echo " var container = document.getElementById('chart_div'); \n";

      echo " chart = new google.visualization.GanttChart(container); \n";
      $GETonclick = "";
      if (isset($_GET['onclick'])) $GETonclick = urldecode($_GET['onclick']);
      if (isset($_POST['onclick'])) $GETonclick = urldecode($_POST['onclick']);
      if ($GETonclick != "") {
      echo "google.visualization.events.addListener(chart, 'ready', function() {  ready=true;  }); \n";
      echo "google.visualization.events.addListener(chart, 'select', myselectfunction); \n";
      echo "google.visualization.events.addListener(chart, 'onmouseover', saveSelection); \n";
      //echo "google.visualization.events.addListener(chart, 'onmouseover', myselectfunction); \n";
      }
      
      

      echo ' dataTable = new google.visualization.DataTable(); ' . "\n";
      echo " dataTable.addColumn('string', 'Task ID'); \n";
      echo " dataTable.addColumn('string', 'Task Description'); \n";
      echo " dataTable.addColumn('date', 'Start Date'); \n";
      echo " dataTable.addColumn('date', 'End Date'); \n";
      echo " dataTable.addColumn('number', 'Duration'); \n";
      echo " dataTable.addColumn('number', 'Percent Complete'); \n";
      echo " dataTable.addColumn('string', 'Dependencies'); \n";

      echo ' dataTable.addRows([' . "\n";
      echo str_replace("~~", "'", str_replace("newDate", "new Date", str_replace("%2c", ",", str_replace("%27", "'", str_replace("%20", " ", str_replace("%28", "(", str_replace("%29", ")", str_replace("%5b", "[", str_replace("`", "'",str_replace("%5d", "]",str_replace('~,', '",', str_replace('[~', '["', str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", $GETdata)))))))))))))));

      $GEToptions="275";
      if (isset($_GET['options'])) {
        $huh=urldecode($_GET['options']);
        if ($huh != '') {
          if (substr($huh,0,1) == ';') {
            $GEToptions .= $huh;
          } else if (substr($huh,0,1) < '1' || substr($huh,0,1) > '9') {
            $GEToptions .= $huh;
          } else {
            $ws = explode(";", $huh);
            $twoh = $ws[0];
            $GEToptions = $huh;
          }
        }
      } else if (isset($_POST['options'])) {
        $huh=urldecode($_POST['options']);
        if ($huh != '') {
          if (substr($huh,0,1) == ';') {
            $GEToptions .= $huh;
          } else if (substr($huh,0,1) < '1' || substr($huh,0,1) > '9') {
            $GEToptions .= $huh;
          } else {
            $ws = explode(";", $huh);
            $twoh = $ws[0];
            $GEToptions = $huh;
          }
        }
      }

      echo "]);\n\n      var options = {  height: " . $GEToptions . "  };\n\n";

      //echo " var chart = new google.visualization.GanttChart(document.getElementById('chart_div')); \n";
      echo " chart.draw(dataTable, options); \n";
      if ($GETr != "" && $GETc == "") echo " chart.setSelection([{'row': " . $GETr . ", 'column': null}]); setTimeout(myselectfunction,4100); \n";
      if ($GETr == "" && $GETc != "") echo " chart.setSelection([{'row': null, 'column': " . $GETc . "}]);  setTimeout(myselectfunction,4100); \n";
      if ($GETr != "" && $GETc != "") echo " chart.setSelection([{'row': " . $GETr . ", 'column': " . $GETc . "}]);  setTimeout(myselectfunction,4100); \n";
      echo " } \n";
      
      $ic = 1;
      
      for ($ic=1; $ic<100; $ic++) {
 echo ' function cals' . $ic . '(inhuh,mode) {' . "\n";
 echo ' if (inhuh > ' . $ic . ') { return cals' . ($ic + 1) . '(inhuh,mode); } else if (inhuh < ' . $ic . ') { return cals' . ($ic - 1) . '(inhuh,mode); } else { ' . "\n";
 echo ' if (mode == 0) {YAHOO.example.calendar.cals' . $ic . ' = new YAHOO.widget.Calendar("cals' . $ic . '","cal' . $ic . 'SContainer");  ' . "\n";
 echo ' YAHOO.example.calendar.cals' . $ic . '.render();  ' . "\n";
 echo ' YAHOO.example.calendar.cale' . $ic . ' = new YAHOO.widget.Calendar("cale' . $ic . '","cal' . $ic . 'EContainer");  ' . "\n";
 echo ' YAHOO.example.calendar.cale' . $ic . '.render(); ' . "\n"; 
 echo ' } else { ' . "\n"; 
 echo ' retval = "";  ' . "\n"; 
 echo ' var pput = document.getElementById("p' . $ic . 'put"); ' . "\n"; 
 echo ' var dput = document.getElementById("d' . $ic . 'put"); ' . "\n"; 
 echo ' var lput = document.getElementById("l' . $ic . 'put"); ' . "\n"; 
 echo ' var sput = document.getElementById("s' . $ic . 'put"); ' . "\n"; 
 echo ' var iput = document.getElementById("i' . $ic . 'put"); ' . "\n"; 
 echo " retval = retval + '[" . '"' . "' + lput.value + '" . '"' . "," . '"' . "' + iput.value + '" . '"' . ",'; " . "\n"; 
 echo ' var pDates = YAHOO.example.calendar.cals' . $ic . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' var pDatee = YAHOO.example.calendar.cale' . $ic . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' if (pDates) { ' . "\n"; 
 echo ' retval = retval + "newDate(" + eval(1900 + pDates.getYear()) + ","; ' . "\n"; 
 echo ' retval = retval + eval(0 + pDates.getMonth()) + ","; ' . "\n"; 
 echo ' retval = retval + pDates.getDate() + "),"; ' . "\n"; 
 //echo ' retval = retval + pDates.getDate() + ".";	         ' . "\n"; 
 echo '      } else if (eval(sput.value.replace("null","0")) != 0) { ' . "\n"; 
 echo ' if (eval(sput.value.replace("null","0")) != 0) { ' . "\n";
 echo ' pDates=new Date();   pDates.setDate(pDatee.getDate() - eval(sput.value)); ' . "\n"; 
 echo ' retval = retval + "newDate(" + eval(1900 + pDates.getYear()) + ","; ' . "\n"; 
 echo ' retval = retval + eval(0 + pDates.getMonth()) + ","; ' . "\n"; 
 echo ' retval = retval + pDates.getDate() + "),"; ' . "\n"; 
 echo ' } else { ' . "\n";
 echo ' pDates = YAHOO.example.calendar.cale' . ($ic - 1) . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' retval = retval + "null,"; ' . "\n"; 
 echo ' } ' . "\n";
 echo '      } else if (eval(sput.value.replace("null","0")) == 0) { ' . "\n"; 
 echo ' pDates = YAHOO.example.calendar.cale' . ($ic - 1) . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' retval = retval + "null,"; ' . "\n"; 
 echo '      } else { ' . "\n"; 
 echo ' pDates = YAHOO.example.calendar.cale' . ($ic - 1) . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' if (pDates) { ' . "\n"; 
 echo ' retval = retval + "newDate(" + eval(1900 + pDates.getYear()) + ","; ' . "\n"; 
 echo ' retval = retval + eval(0 + pDates.getMonth()) + ","; ' . "\n"; 
 echo ' retval = retval + pDates.getDate() + "),"; ' . "\n"; 
 //echo ' retval = retval + pDates.getDate() + ".";	         ' . "\n"; 
 echo '      }  ' . "\n"; 
 echo '      } ' . "\n"; 
 echo ' if (pDatee) { ' . "\n"; 
 echo ' retval = retval + "newDate(" + eval(1900 + pDatee.getYear()) + ","; ' . "\n"; 
 echo ' retval = retval + eval(0 + pDatee.getMonth()) + ","; ' . "\n"; 
 echo ' retval = retval + pDatee.getDate() + ")]"; ' . "\n"; 
 //echo ' retval = retval + pDatee.getDate() + ".";	         ' . "\n"; 
 echo '     } else { ' . "\n"; 
 echo '  pDatee = YAHOO.example.calendar.cals' . ($ic + 1) . '.getSelectedDates()[0]; ' . "\n"; 
 echo ' if (pDatee) { ' . "\n"; 
 echo ' retval = retval + "newDate(" + eval(1900 + pDatee.getYear()) + ","; ' . "\n"; 
 echo ' retval = retval + eval(0 + pDatee.getMonth()) + ","; ' . "\n"; 
 echo ' retval = retval + pDatee.getDate() + ")]"; ' . "\n"; 
 //echo ' retval = retval + pDatee.getDate() + ".";	         ' . "\n"; 
 echo '     }  ' . "\n"; 
 echo '      }  ' . "\n"; 
 echo " if (sput.value == 'null') retval = retval.replace(')]',')," . '' . "null" . '' . "," . '' . "' + pput.value + '" . '' . "," . '"' . "' + ('' + dput.value).replace('null','') + '" . '"' . "]'); " . "\n"; 
 //echo " if (sput.value != 'null') retval = retval.replace(')]',')," . '' . "' + eval(60 * 60 * 24 * 1000 * sput.value) + '" . '' . "," . '' . "' + pput.value + '" . '' . "," . '"' . "' + dput.value + '" . '"' . "]'); " . "\n"; 
 echo " if (sput.value != 'null') retval = retval.replace(')]',')," . '' . "' + eval(1.0 * sput.value) + '" . '' . "," . '' . "' + pput.value + '" . '' . "," . '"' . "' + dput.value + '" . '"' . "]'); " . "\n"; 
 echo '  return retval;  } ' . "\n"; 
 echo ' } return ""; } ' . "\n";
      }
      
?>
   function cals0(huh,huh2) {
   }
   function cals100(huh,huh2) {
   }

   function goforth() {
   //alert(99);
     var ii=1;
     var dt = "";
     var ci = "";
     while (ii <= num) {
       dt = dt + ci + cals1(ii,1);
       dt = dt.replace("'", "~~").replace('"', '~');
       dt = dt.replace("'", "~~").replace('"', '~');
       dt = dt.replace("'", "~~").replace('"', '~');
       dt = dt.replace("'", "~~").replace('"', '~');
       ttitle = ttitle.replace("'", "~~").replace('"', '~');
       ttitle = ttitle.replace("'", "~~").replace('"', '~');
       ci = ",";
       ii = ii + 1;
       //alert(dt);
     }
     window.location = iftoobig("","./gantt_chart.php?title=" + ttitle.replace("'", "~~").replace('"', '~') + "&desc=" + ttitle.replace("'", "~~").replace('"', '~') + "&data=" + dt.replace("'", "~~").replace('"', '~'));
   }
<?php
      echo " </script> \n";
      echo " </head> \n";
      if (!isset($_GET['desc']) && !isset($_POST['desc'])) {
      echo " <body class='yui-skin-sam' onload='setTimeout(later, 2 * 1000);'> \n";
      } else {
      echo " <body class='yui-skin-sam'> \n";
      }
      echo " <h1 id='myh1'>" . $GETtitle . " Gantt Chart<font id='myf1' size=1></font></h1> \n";
?>
    <div id="chart_div" style="width: <?php echo $nineh; ?>px; height: <?php echo $twoh; ?>px; background-color: yellow;"></div><br><br><br><br><br><div id="bitsatend" style="display:inline;"></div>
    <div id="calendar_table"></div>
    <a title="Another Gantt Chart" href="./gantt_chart.php">Another gantt chart?</a>
    <?php 
      if (!isset($_GET['desc']) && !isset($_POST['desc'])) {
      
        echo '<' . 'script' . '>' . "\n " . " function later() { \n" . ' var datalineprefix = " "; ' . "\n";
        echo ' var datalinesuffix = ""; ' . "\n";
        echo ' var extra = ""; ' . "\n";
        echo ' var bits = ""; ' . "\n";
        echo ' var task = ""; ' . "\n";
        echo ' var ict = 0; ' . "\n";
        echo ' var thisline = 1; ' . "\n";
        echo ' var ctaskid=""; ' . "\n";
        echo ' var totalleft = 100.0; ' . "\n";
        echo ' var title = prompt("Enter Gantt Chart Title (suffix by &onclick=y for added onclick functionality, suffix &options=[287] controls chart height)", "Research"); ' . "\n";
        
        echo ' if (title != null) { ' . "\n";
        echo ' ttitle = title; ' . "\n" . ' task = prompt("Enter Number of " + title, "0"); ttask = task; ' . "\n";
        
        
        echo ' if (task == null) { ' . "\n";
        echo '  title = title; ' . "\n";
        echo ' } else if (task != "0" && task.indexOf("-") == -1 && (task.length == 1 || task.length == 2)) { ' . "\n";
        echo '  bits = "<br><a id=wafo href=# onclick=' . "'" . 'goforth();' . "'" . ' title=' . "'" . 'Show' . "'" . '>Click here to Show Chart when All Filled out Below ...</a><br><table border=1><tr><td>From</td><td>" + title + "</td><td>To</td></tr>";' . "\n";

        echo '  num = task;' . "\n" . 'while (ict != task) { ' . "\n";
        echo '    bits = bits + "<tr>";' . "\n";
        echo '    ict = ict + 1;' . "\n";
        echo '    ctaskid = "taskid" + ict;' . "\n";
        echo '    bits = bits + "<td><div class=faded id=cal" + ict + "SContainer></div></td>";' . "\n";
        echo '  if (ict == 1) { ' . "\n";
        echo '    bits = bits + "<td>Task ID: <input id=l" + ict + "put type=text value=" + ctaskid + "></input><br><br>Task Description: <input id=i" + ict + "put type=text></input><br><br>Duration (decimal days): <input id=s" + ict + "put type=text style=opacity:0.5 value=null></input><br><br>Percent Complete: <input id=p" + ict + "put type=number min=0 max=100 value=0.0 step=0.1></input><br><br>Task ID Dependencies <br>(comma separate): <input id=d" + ict + "put type=text value=null style=opacity:0.5></input></td>";' . "\n";
        echo '  } else { ' . "\n";
        echo '    bits = bits + "<td>Task ID: <input id=l" + ict + "put type=text value=" + ctaskid + "></input><br><br>Task Description: <input id=i" + ict + "put type=text></input><br><br>Duration (decimal days): <input id=s" + ict + "put type=number value=0.00 step=0.01></input><br><br>Percent Complete: <input id=p" + ict + "put type=number min=0 max=100 value=0.0 step=0.1></input><br><br>Task ID Dependencies <br>(comma separate): <input id=d" + ict + "put type=text></input></td>";' . "\n";
        echo '  } ' . "\n";
        echo '    bits = bits + "<td><div id=cal" + ict + "EContainer></div></td>";' . "\n";
        echo '    bits = bits + "</tr>";' . "\n";
        //echo '  alert(ict + " -- " + bits);' . "\n";
        echo '    } ' . "\n";

        echo '  } else { alert("Can only handle 99 or less."); window.location = "./gantt_chart.php"; }' . "\n";
        echo '  bits = bits + "</table>";' . "\n";
        //echo '  alert(bits);' . "\n";
        echo ' var ct = document.getElementById("calendar_table"); ' . "\n";
        echo '  ct.innerHTML = bits;    location.href="#wafo"; ' . "\n";
        //echo '  alert(ct.innerHTML);' . "\n";
        echo '    if (ict != 0) { ict = 0; ' . "\n";
        echo '  while (ict != task) { ' . "\n";
        echo '    ict = ict + 1;' . "\n";
        echo '    cals1(ict,0);' . "\n";
        echo '    } } ' . "\n";
        echo ' } ' . "\n";
        

        echo "} \n" . '</' . 'script' . '>' . "\n";
      } 
    ?>
  </body>
</html>
