  <script type="text/javascript" src="calendar1.js"></script>
  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <form action="controllers/inputController.php" method="post" name="projectform" id="projectform">
  <input name="projectpkey" id="projectpkey" type="hidden" value="<?=$project_data['projectpkey'];?>">
  <input name="projectmanual" id="projectmanual" type="hidden" value="<?=$project_data['projectmanual'];?>">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project ID *</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectid" id="projectid" type="text" value="<?=$project_data['projectid'];?>" maxlength=100 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Name *</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectname1" id="projectname1" type="text" value="<?=$project_data['projectname'];?>" style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Description</td>
  <td valign=top width=610 class=formvalue>
  <textarea name="projectdescription" id="projectdescription" rows=4 style="width: 360px;"><?=$project_data['projectdescription'];?></textarea>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Client Name</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectclientname" id="projectclientname" type="text" value="<?=$project_data['projectclientname'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Client Contact No</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectclientphone" id="projectclientphone" type="text" value="<?=$project_data['projectclientphone'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Value</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectvalue" id="projectvalue" type="text" value="<?=$project_data['projectvalue'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Start Date</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectcommencementdate" id="projectcommencementdate" type="text" value="<?=$project_data['projectcommencementdate'];?>" maxlength=10 style="width: 90px;" onKeypress="dateOnly();">
  <a href="javascript:cal1.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project End Date</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectcompletiondate" id="projectcompletiondate" type="text" value="<?=$project_data['projectcompletiondate'];?>" maxlength=10 style="width: 90px;" onKeypress="dateOnly();">
  <a href="javascript:cal2.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Quantity Surveyor</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectqsname" id="projectqsname" type="text" value="<?=$project_data['projectqsname'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>QS Contact No</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectqsphone" id="projectqsphone" type="text" value="<?=$project_data['projectqsphone'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>Project Manager</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectpmname" id="projectpmname" type="text" value="<?=$project_data['projectpmname'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>PM Contact No</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectpmphone" id="projectpmphone" type="text" value="<?=$project_data['projectpmphone'];?>" maxlength=40 style="width: 180px;">
  </td>
  </tr>
  </table>
  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=150 class=formlabel>In-House Project</td>
  <td valign=top width=610 class=formvalue>
  <select name="projectinhouse" id="projectinhouse" style="width: 60px;">
  <option value="1" <? if ($project_data['projectinhouse']==1) echo "selected"; ?>>Yes</option>
  <option value="0" <? if ($project_data['projectinhouse']==0) echo "selected"; ?>>No</option>
  </select>
  </td>
  </tr>
  <tr valign=top>
  <td valign=top width=150 class=formlabel>C/O</td>
  <td valign=top width=610 class=formvalue>
  <input name="projectco" id="projectco" type="text" value="<?=$project_data['projectco'];?>" maxlength=200 style="width: 360px;">
  </td>
  </tr>
  </table>

  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=50 class=formlabel>No.</td>
  <td valign=top width=500 class=formlabel>Personnel Name</td>
  <td valign=top width=210 class=formlabel>Contact No</td>
  </tr>
  <? $cindex=0; ?>
  <? foreach ($personnel_list as $mypersonnel) { ?>
    <? $cindex++; ?>
    <tr valign=top>
    <input name="personnelpkey<?=$cindex;?>" id="personnelpkey<?=$cindex;?>" type="hidden" value="<?=$mypersonnel['personnelpkey'];?>">
    <td valign=top width=50 class=listnumber><?=$cindex;?>&nbsp;</td>
    <td valign=top width=500 class=formvalue><input name="personnelname<?=$cindex;?>" id="personnelname<?=$cindex;?>" type="text" value="<?=$mypersonnel['personnelname'];?>" maxlength=200 style="width: 460px;"></td>
    <td valign=top width=210 class=formvalue><input name="personnelphone<?=$cindex;?>" id="personnelphone<?=$cindex;?>" type="text" value="<?=$mypersonnel['personnelphone'];?>" maxlength=40 style="width: 180px;"></td>
    </tr>
  <? } ?>
  <? for ($i=$cindex+1;$i<=10;$i++) { ?>
    <tr valign=top>
    <input name="personnelpkey<?=$i;?>" id="personnelpkey<?=$i;?>" type="hidden" value="">
    <td valign=top width=50 class=listnumber><?=$i;?>&nbsp;</td>
    <td valign=top width=500 class=formvalue><input name="personnelname<?=$i;?>" id="personnelname<?=$i;?>" type="text" value="" maxlength=200 style="width: 460px;"></td>
    <td valign=top width=210 class=formvalue><input name="personnelphone<?=$i;?>" id="personnelphone<?=$i;?>" type="text" value="" maxlength=40 style="width: 180px;"></td>
    </tr>
  <? } ?>
  <input name="job" id="job" type="hidden" value="">
  </form>
  </table>

  <script language="javascript">
    var cal1 = new calendar1(document.forms['projectform'].elements['projectcommencementdate']);
    cal1.year_scroll = true;
    cal1.time_comp = false;
    var cal2 = new calendar1(document.forms['projectform'].elements['projectcompletiondate']);
    cal2.year_scroll = true;
    cal2.time_comp = false;
  </script>

  <script type="text/javascript">

  function validateForm() {

    // NOTE: THIS IS AMAZING!! JS JUST WON'T ACCEPT projectname FOR VALIDATION.. ALWAYS SAYS UNDEFINED!
    var isvalid=true;
    var errmsg="";
    var projectid=document.getElementById('projectid');
    var projectname=document.getElementById('projectname1');
    if ((projectid.value=="")||(projectname.value=="")) {
      errmsg='Project ID and Project Name must be specified!\n';
      isvalid=false;
    }
    if (isvalid==false) alert('Error:\n'+errmsg);
    return isvalid;

  }

  </script>
