Issue loading content into DIV with Jquery
I'm out of ideas and have been searching for awhile now, so hopefully someone can point me in the right direction.

I have a select box that allows a user to select a specific value. Then try to load a page using the URL/value and keep receiving a blank page.

Assuming no value is passed, it works. I've used this page in the same way quite a number of times in the past so I'm not certain whats wrong. Also, it only seems to fail if specific URL parameters are passed.  I remove a substantial amount of code outside of the problem area to make it a bit easier to read.

So 
$('#sheetDiv').load('loaddates.php');
will work
and 
$('#sheetDiv').load('loaddates.php?project_name=' + value);
will not


**Code for main page is below:**

    <?php
    session_start();
    include('db.php');
    
    if($_POST[submit]=="Submit")
    {
     
    mysql_query("INSERT INTO tblusers SET username='".$_POST[username]."',password='".$_POST[password]."',type='".$_POST[type]."'") or print mysql_error();
    }
    function make_star($x)
    {
    	$s="";
    	for($i=1;$i<=strlen($x);$i++)
    	{
    		$s.="*";
    	}
    	return $s;
    }
    ?>
    
    <head>
    <script language="javascript" src="jscript/jquery.js"></script>
    <script type="text/javascript" src="jscript/facefiles/jquery-1.2.2.pack.js"></script>
    <script type="text/javascript" src="jscript/ddaccordion.js"></script>
    <script type="text/javascript" language="javascript" src="jscript/jmenu.js"></script>
    
    <script language="javascript" src="jscript/user.js"></script>
    <script language="javascript" src="jscript/common.js"></script>
    <script type="text/javascript" src="calendarDateInput.js"></script>
    <script language="javascript">
    function selectProject() {
    	$('#selectProject').show();
    	$('#addProject').hide();
    }
    function selectDate() {
        $('#addProject').hide();
        $('#selectDate').show();
    	}
    function pdelete(id)
    {
    	if(confirm('Are sure to delete the data ?')==true)
    	{
    	$.ajax({
                               type: "GET",
                               url: "ajax.php",
                               data: "act=delete&tbl=timesheet"+"&id="+id,
                               success: function(result){
                                 $(".error").html(result);
    							 setTimeout('window.location.reload()',2000);
    						}
      	});
    	}	
    	
    
    }
    checked=false;
    function checkedAll (myfrm) {
    	var aa= document.getElementById('frm');
    	 if (checked == false)
              {
               checked = true
              }
            else
              {
              checked = false
              }
    	for (var i =0; i < aa.elements.length; i++) 
    	{
    	 aa.elements[i].checked = checked;
    	}
          }
    	  
    function del() 
    		 {
    		       var flag=false;
                    var pass ;
    				 for(var i=0; i<document.frm.length; i++) //check for all checkboxes
    				 {
    				   if( document.frm.elements[i].type=="checkbox" && document.frm.elements[i].checked==true )
    				   {
    						flag=true;
    
                       }
                     }
                        if(flag == true)
                        {
                          if(confirm("Do you sure to delete this?"))
                          {
                          return true;
                          }else
                          { return false;
                          }
                        }
    
    
    				 if( flag==false )  // if no checkbox selected
    				 {
    					   alert("Please select at least one checkbox to proceed.");
    					   return false;
    				 }
    		}
    
    function MM_openBrWindow(theURL,winName,features) {
      window.open(theURL,winName,features);
      return false;
    }
    function loadUsers(id) {
    if(id !=2) {
    var value = $('#selectValue').val();
    alert('loadates2.php?project_name=' + value);
    $('#sheetDiv').load('loaddates.php?project_name=' + value);
    
    }
    else if(id == 2) {
    var value = $('#f_new_age_date').val();
    $('#sheetDiv').load('loaddates.php?project_date=' + value);
    }
    }
    
    function addProject() {
    $('#selectProject').hide();
    $('#selectDate').hide();
    $('#addProject').show();
    }
    </script>
    <style>
    .selectday{
    	border-right:#CBCBCB 1px solid;
    	border-left:#CBCBCB 1px solid;
    	border-bottom:#CBCBCB 1px solid;
    	border-top:#CBCBCB 1px solid;
    	color:#666;
    	font-weight:bold;
    	padding-left:5px;
    	padding-right:5px;
    	}
    	.selectedday{
    	border-right:#CBCBCB 1px solid;
    	border-left:#CBCBCB 1px solid;
    	border-bottom:#CBCBCB 1px solid;
    	border-top:#CBCBCB 1px solid;
    	color:#666;
    	padding-left:15px;
    	padding-right:15px;
    	padding-top:7px;
    	}
    	.sday
    	{
    		color:#f69929;
    		font-family:Arial;
    		font-size:24px;
    		font-weight:bold;
    		}
    </style>
    <link href="css/menu.css" rel="stylesheet" type="text/css">
    
    <link rel="stylesheet" type="text/css" media="all" href="images/calendar.css" title="win2k-cold-1">
    <!-- main calendar program -->
    	<script type="text/javascript" src="images/calendar.js"></script>
    	<!-- language for the calendar -->
    	<script type="text/javascript" src="images/calendar-en.js"></script>
    <!-- the following script defines the Calendar.setup helper function, which makes
    	      adding a calendar a matter of 1 or 2 lines of code. -->
    	<script type="text/javascript" src="images/calendar-setup.js"></script>
    
    </head>
    <div id="newContainer">
    
    <?php if($_SESSION[usertype] == "A" || $_SESSION[usertype] == "S" ) { ?>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <table width="100%" style="position:relative; left:15px;" border="0" cellspacing="0" cellpadding="0">
      <?php include('header_project.php');?>
     <tr>
        <td  align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center"><div id="result" align="center" style="color:#FF0000; display:block;">&nbsp;</div></td>
          </tr>
          <tr>
            <td width="15%" height="395" align="left" valign="top" colspan="2"><? include('menu.php')?></td>
            <td width="100%"  valign="top">
              < <div id="form_news"  style="width:850px; position:relative;left:52px;">
    
    <div id="options" style="margin-left: 350px;margin-top:130px;position:absolute;z-index:2">        
    <a href="#" onclick="addProject()">Add New</a>   |  <a href="#" onclick="selectProject()">Select Project </a>
    </div>
    <div id="addProject" style="padding-top:15px; padding: 5px; display:none; height:500px; width:950px;position:relative; top:15px;">
    <table width="100%" style="position:relative; left:25px" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                     <tr><td colspan="8"> 
                     <form name="ff1" method="post" action="time.php">
                      <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
    				
                      <tr align="left">
                   <tr>
                     
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Project</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Work Code</span></td>
                        <td width="90" bgcolor="#e1e1e1" ><span class="text_pt space">Employee Name</span></td>
                        <td width="44" bgcolor="#e1e1e1" ><span class="text_pt space"> Billable Hours</span></td>
                        <td width="147" bgcolor="#e1e1e1" ><span class="text_pt space">Notes</span></td>
                        <td bgcolor="#e1e1e1" ><span class="text_pt space">Date</span></td>
                        <td  >&nbsp;</td>
                   </tr>
                      <tr align="left">
                        <td width="132" valign="top" class="f12b"><select name="project_number" id="project_name">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from projects");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['project_number']?>" ><?php echo $sql['project_name']?></option>
                      <?php } ?>
                  </select></td>
                        <td width="127" valign="top" class="f12b"><select name="task" id="task">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from work_codes");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['work_codes']?>"><?php echo $sql['work_codes']?></option>
                      <?php } ?>
                    </select> </td>
                        <td width="111" valign="top" class="login_fnt"><select name="staff_name" id="staff_name">
              		<option value="">Select</option>
                    <?php
                    	$aa=mysql_query("select * from staff_members");
    					while($sql_clients=mysql_fetch_array($aa))
    					{
    				?>
                 <option value="<?php echo $sql_clients['staff_id']?>" ><?php echo $sql_clients['staff_name']?></option>
                    <?php } ?>
              </select></td>
                        <td width="47" valign="top" class="f12b"><input type="text" name="bill_hours" id="bill_hours" value="" size="5" /></td>
                        <td width="136" valign="top" class="f12b"><textarea name="description" id="description" cols="20" rows="1"></textarea>
                        <input type="hidden" name="expense_date" value="<?php echo $currdate;?>" />                    </td>
                        <td width="185" valign="top" class="f12b">
                        <?php
    					$currdate=date('Y-m-d');
                        ?>
                        <input name="new_age_date" id="f_new_age_date" onChange="document.form_news.new_rem_age_date.value=document.form_news.new_age_date.value" size="10" readonly="yes" type="text" value="<?php echo $currdate;?>"> 
                  <img src="images/img.gif" id="trigger_new_age_date" style="cursor: pointer; border: medium none;" title="Select Date"> 
                  <script type="text/javascript">
    	Calendar.setup({
    	        inputField     :    "f_new_age_date",         
    	        ifFormat       :    "%Y-%m-%d",     
    	        button         :    "trigger_new_age_date",   
    	        singleClick    :    true                       
    	    });
    		  </script>                    </td>
                        <td width="41" valign="top" class="f12b">&nbsp;</td>
                        </tr>
                      <tr align="left">
                        <td valign="top">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="login_fnt">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr align="left">
                        <td valign="top">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="login_fnt">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b"></td>
                        <td valign="top" class="f12b"><input type="submit" name="submit" id="submit" value="Add Time" /></td>
                      </tr>
                      </table>
                  </form>
                   </td></tr>
                </table>
    </div>
    
    <div id="selectProject" style="position:relative; z-index:1; padding-top:15px; padding: 5px; display:none; height:500px; width:950px; top:125px;">
    <div style="position:relative;bottom:45px">
    <p style="padding:5px padding-bottom:0px;margin-left:50px; "> Select a Project:<p>
    <select id ="selectValue" style="margin-left:50px;position:relative;bottom:15px;width:150px;">
    <?php 
    $aa1 = mysql_query("select * from projects");
    while(@$sql=mysql_fetch_array($aa1)) {?>
    	<option value="<?php echo $sql[project_name]; ?>"><?php echo $sql[project_name]; ?> </option>
    <?php } ?>
    </select>
    <input type="button" id="selectProjectSubmit" value="Submit" onclick="loadUsers()" style="position:relative;bottom:15px;"/>
    
    
    </div>
    <div id="sheetDiv" style="height:500px;width:950px; border: solid 1px red; position:relative; bottom:70px;"> random </div>
    </div>
           
    </td></tr> 
                    </table>  
                    </td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
            </tr>
       
        </table></td>
      </tr>
    
    
    <?php }?>
    
    </div>
    



    
    *****Code for loaded div below:*******
    





    <?php
    session_start();
    include('db.php');
    ?>
    <head>
    <script type="text/javascript">
    function updateField(id, field, project_name, date) {
    if(id) {
    	$field = $('#'+id);
    	$value = $field.val();
    	$.ajax({
    		type: "GET",
    		url: "ajax2.php",
    		data: "rqt=time&idfield=" + id + "&valuefield="+$value });
    }
    else {
           
    	    $.ajax({
    		type: "GET",
    		url: "ajax2.php",
    		data: "rqt=updatetime&valuefield="+ field + "&date=" + date + "&project_name=" + project_name});
    }
    }
    function doit(id,fieldtype, newvalue) {
    if(fieldtype=="staff_name" || fieldtype=="task"){
    var newvalue = newvalue.options[newvalue.selectedIndex].value;
    }
    
    
    $.ajax({
                               type: "GET",
                               url: "ajax2.php",
                               data: "fieldtype=" + fieldtype + "&id=" + id + "&newvalue=" + newvalue,
    						   });
    }
    </script>
    </head>
    
    
    <?php if($_REQUEST[project_date]){
    $currDate = date('Y-m-d', strtotime($_REQUEST[project_date]));
    $dayOfWeek = date('N', strtotime($_REQUEST[project_date]));
    if($dayOfWeek == 7) { $dayOfWeek = 0;}
    $subtractTime = "-".(string)$dayOfWeek."days";
    $newdate = strtotime($subtractTime , strtotime ($currDate) ) ;
    $newdate = date ( 'Y-m-d' , $newdate );
    
    $enddate = $newdate;
    }
    ?>
    <?php
    if($_SESSION[usertype] == "E") { ?>
    <table width="875px"  style="position:relative; left:15px;" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                    
                       <td colspan="8"> 
                     <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
                   <tr>
                   
    					<td width="100" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Project Name</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Sunday</span></td>
    					<td width="100" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Monday</span></td>
                        <td width="100" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Tuesday</span></td>
                        <td width="100" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Wednesday</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Thursday</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Friday</span></td>
    					<td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Saturday</span></td>
                   </tr>
    			  <?php  
    			   $totalhrs=0;
                   $Query_dbl=mysql_query("select * from projects");
                    while($dbl_=mysql_fetch_array($Query_dbl))
    						    {
    							$counter = 0;
    							?>  <?php
    							$secondCounter = 0;
    							$starting = true;
                                while($secondCounter != 7 ) {
    							$newdate = $enddate;
    							$newdate = strtotime("".$secondCounter."day" , strtotime($newdate));
    							$newdate = date("Y-m-d", $newdate);
    							$Query_fql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."'");
    							if($secondCounter == 0 && mysql_num_rows($Query_fql) > 0 ) {
    							$PN_=mysql_fetch_array($Query_fql);
    							?>
    							<tr> <td> <?php echo $PN_['project_name']; ?> 
    							</td>
    							<?php $starting = false;}
    							$Query_sql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."' AND expense_date='".$newdate."'");
    							$Query_xql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."' AND expense_date='".$newdate."'");
    						    $secondCounter++;
    						    if(mysql_num_rows($Query_xql) > 0) {
    						    $currentDate = null;							
    							while($sql_=mysql_fetch_array($Query_sql))
    						    {
    					             if($currentDate != $sql_['expense_date']){
    						            $currentDate = $sql_['expense_date'];
    						            $cyell = mysql_query("SELECT SUM(bill_hours) AS newhours FROM timesheet WHERE expense_date='".$sql_['expense_date']."' and project_name='".$sql_['project_name']."' and staff_name='".$_SESSION['staff_id']."'");
                                        $cardyell=mysql_fetch_assoc($cyell);
    						            }
    						            else {
    						            continue;
    						            }
    				  ?>
    				 
    					<td align="left"> 
    					<select style="width:100px" name="billHours" id="<?php echo $sql_['id'] ?>" onchange="updateField(this.id)">
    					<?php $a = 0; while($a != 15) {?>
    					<option value="<?php echo $a; ?>" <?php if($sql_['bill_hours'] == $a) { echo "selected"; } ?>> <?php echo $a; ?> </option>
    					<?php $a = $a + .5;} ?>
    					
    					</select>
    </td>
                        <?php $totalhrs += $sql_['bill_hours']; } } else{ if($starting == false) { ?> <td>
                        
                        
                        
                        <select style="width:100px" name="billHours" id="" onchange="updateField(null, this.value, <?php echo "'".$dbl_['project_name']."'";?>, <?php echo "'".$newdate."'";?>)">
    					<?php $a = 0; while($a != 15) {?>
    					<option value="<?php echo $a; ?>" <?php if($sql_['bill_hours'] == $a) { echo "selected"; } ?>> <?php echo $a; ?> </option>
    					<?php $a = $a + .5;} ?>
    					
    					</select>
                        
                        
                        
                         </td> <?php }  } ?> 
    				  <?php } ?> </tr> <?php }
    				  ?>
                      <tr>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                        <td colspan="2" align="right" valign="top" class="f12b"><br/><strong>Total Hours</strong></td>
                        <td align="center" valign="top" class="f12b">
                          <strong>
                            <?php
                        echo "<br/>";
    					echo $totalhrs;
                        ?>
                          </strong></td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr>
                        <td colspan="7" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      
                      </table>
                    </td></tr> 
                    </table>
    
    </div>
    <?php } 
    if($_SESSION[usertype] == "S" || $_SESSION[usertype] == "A"){ ?>
    
    <table width="875px"  style="position:relative;left:15px; bottom:0px !important" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                    
                       <td colspan="8"> 
                     <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
                   <tr>
                        <td width="20" class="login_fnt"><span class="text_pt space">&nbsp;&nbsp;&nbsp;</span></td>
                        <td width="160" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Employee Name</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Date Worked</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Billable Hours</span></td>
                        <td width="90" bgcolor="#e1e1e1" ><span class="text_pt space">Work Code</span></td>
                        <td width="44" bgcolor="#e1e1e1" ><span class="text_pt space">Notes</span></td>
                   </tr>
                   <?php
    						$Query_sql=mysql_query("select * from timesheet where project_name='".$_REQUEST['project_name']."'");
    						$totalhrs=0;
    						while($sql_=mysql_fetch_array($Query_sql))
    						{
    					
    				  ?>
                      <tr>
     <td width="20" align="left" valign="top">
                        <a  href="time.php?del=del&id=<?php echo $sql_['id']?>" class="text_pt" style="position:relative; left:12px; title="Delete" onclick="return confirm('Are you sure you want to delete?')"><img src="redx.png" border="0" /></a></td>
    <td width="90" align="left" valign="top" class="login_fnt"><select onchange="doit(<?php echo $sql_['id']?>, 'staff_name', this)" name="staff_name" id="staff_name">
              		<option value="">Select</option>
                    <?php
                    	$aa=mysql_query("select * from staff_members");
    					while($sql_clients=mysql_fetch_array($aa))
    					{
    				?>
                 <option value="<?php echo $sql_clients['staff_id']?>" <?php if($sql_clients['staff_id']==$sql_['staff_name']) echo "selected";?>><?php echo $sql_clients['staff_name']?></option>
                    <?php } ?>
              </select></td>
    
            <td width="90" align="left" valign="top" class="login_fnt"> <input id="text" onblur="doit(<?php echo $sql_['id']?>, 'expense_date', this.value)" value="<?php echo $sql_['expense_date'];?>"/></td> 
    
                       
                       
                        <td width="44" align="left" valign="top" class="f12b"><input type="text" onblur="doit(<?php echo $sql_['id']?>, 'bill_hours', this.value)" name="bill_hours" id="bill_hours" value="<?php echo $sql_['bill_hours']?>" size="5" />
                        <?php
    					$totalhrs=$totalhrs+$sql_['bill_hours'];
                        ?>                    
                        </td>
     <td width="86" align="left" valign="top" class="f12b"><select name="task" id="task" onchange="doit(<?php echo $sql_['id']?>, 'task', this)">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from program_list");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['id']?>" <?php if($sql['id']==$sql_['task']) echo "selected";?>><?php echo $sql['sports']?></option>
                      <?php } ?>
                    </select> </td>
                        
                        <td width="147" align="left" valign="top" class="f12b"><textarea name="description" onblur="doit(<?php echo $sql_['id']?>, 'description', this.value)" style="height:20px" id="description" cols="20" rows="1"><?php echo $sql_['description']?></textarea></td>
                      </tr><?php  $i++; }  
    				  ?>
                      <tr>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                        <td colspan="2" align="right" valign="top" class="f12b"><br/><strong>Total Hours</strong></td>
                        <td align="center" valign="top" class="f12b">
                          <strong>
                            <?php
                        echo "<br/>";
    					echo $totalhrs;
                        ?>
                          </strong></td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr>
                        <td colspan="7" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      
                      </table>
                    </td></tr> 
                    </table>
    <?php } ?> 


Issue loading content into DIV with Jquery
===

I'm out of ideas and have been searching for awhile now, so hopefully someone can point me in the right direction.

I have a select box that allows a user to select a specific value. Then try to load a page using the URL/value and keep receiving a blank page.

Assuming no value is passed, it works. I've used this page in the same way quite a number of times in the past so I'm not certain whats wrong. Also, it only seems to fail if specific URL parameters are passed.  I remove a substantial amount of code outside of the problem area to make it a bit easier to read.

So 
$('#sheetDiv').load('loaddates.php');
will work
and 
$('#sheetDiv').load('loaddates.php?project_name=' + value);
will not


**Code for main page is below:**

    <?php
    session_start();
    include('db.php');
    
    if($_POST[submit]=="Submit")
    {
     
    mysql_query("INSERT INTO tblusers SET username='".$_POST[username]."',password='".$_POST[password]."',type='".$_POST[type]."'") or print mysql_error();
    }
    function make_star($x)
    {
    	$s="";
    	for($i=1;$i<=strlen($x);$i++)
    	{
    		$s.="*";
    	}
    	return $s;
    }
    ?>
    
    <head>
    <script language="javascript" src="jscript/jquery.js"></script>
    <script type="text/javascript" src="jscript/facefiles/jquery-1.2.2.pack.js"></script>
    <script type="text/javascript" src="jscript/ddaccordion.js"></script>
    <script type="text/javascript" language="javascript" src="jscript/jmenu.js"></script>
    
    <script language="javascript" src="jscript/user.js"></script>
    <script language="javascript" src="jscript/common.js"></script>
    <script type="text/javascript" src="calendarDateInput.js"></script>
    <script language="javascript">
    function selectProject() {
    	$('#selectProject').show();
    	$('#addProject').hide();
    }
    function selectDate() {
        $('#addProject').hide();
        $('#selectDate').show();
    	}
    function pdelete(id)
    {
    	if(confirm('Are sure to delete the data ?')==true)
    	{
    	$.ajax({
                               type: "GET",
                               url: "ajax.php",
                               data: "act=delete&tbl=timesheet"+"&id="+id,
                               success: function(result){
                                 $(".error").html(result);
    							 setTimeout('window.location.reload()',2000);
    						}
      	});
    	}	
    	
    
    }
    checked=false;
    function checkedAll (myfrm) {
    	var aa= document.getElementById('frm');
    	 if (checked == false)
              {
               checked = true
              }
            else
              {
              checked = false
              }
    	for (var i =0; i < aa.elements.length; i++) 
    	{
    	 aa.elements[i].checked = checked;
    	}
          }
    	  
    function del() 
    		 {
    		       var flag=false;
                    var pass ;
    				 for(var i=0; i<document.frm.length; i++) //check for all checkboxes
    				 {
    				   if( document.frm.elements[i].type=="checkbox" && document.frm.elements[i].checked==true )
    				   {
    						flag=true;
    
                       }
                     }
                        if(flag == true)
                        {
                          if(confirm("Do you sure to delete this?"))
                          {
                          return true;
                          }else
                          { return false;
                          }
                        }
    
    
    				 if( flag==false )  // if no checkbox selected
    				 {
    					   alert("Please select at least one checkbox to proceed.");
    					   return false;
    				 }
    		}
    
    function MM_openBrWindow(theURL,winName,features) {
      window.open(theURL,winName,features);
      return false;
    }
    function loadUsers(id) {
    if(id !=2) {
    var value = $('#selectValue').val();
    alert('loadates2.php?project_name=' + value);
    $('#sheetDiv').load('loaddates.php?project_name=' + value);
    
    }
    else if(id == 2) {
    var value = $('#f_new_age_date').val();
    $('#sheetDiv').load('loaddates.php?project_date=' + value);
    }
    }
    
    function addProject() {
    $('#selectProject').hide();
    $('#selectDate').hide();
    $('#addProject').show();
    }
    </script>
    <style>
    .selectday{
    	border-right:#CBCBCB 1px solid;
    	border-left:#CBCBCB 1px solid;
    	border-bottom:#CBCBCB 1px solid;
    	border-top:#CBCBCB 1px solid;
    	color:#666;
    	font-weight:bold;
    	padding-left:5px;
    	padding-right:5px;
    	}
    	.selectedday{
    	border-right:#CBCBCB 1px solid;
    	border-left:#CBCBCB 1px solid;
    	border-bottom:#CBCBCB 1px solid;
    	border-top:#CBCBCB 1px solid;
    	color:#666;
    	padding-left:15px;
    	padding-right:15px;
    	padding-top:7px;
    	}
    	.sday
    	{
    		color:#f69929;
    		font-family:Arial;
    		font-size:24px;
    		font-weight:bold;
    		}
    </style>
    <link href="css/menu.css" rel="stylesheet" type="text/css">
    
    <link rel="stylesheet" type="text/css" media="all" href="images/calendar.css" title="win2k-cold-1">
    <!-- main calendar program -->
    	<script type="text/javascript" src="images/calendar.js"></script>
    	<!-- language for the calendar -->
    	<script type="text/javascript" src="images/calendar-en.js"></script>
    <!-- the following script defines the Calendar.setup helper function, which makes
    	      adding a calendar a matter of 1 or 2 lines of code. -->
    	<script type="text/javascript" src="images/calendar-setup.js"></script>
    
    </head>
    <div id="newContainer">
    
    <?php if($_SESSION[usertype] == "A" || $_SESSION[usertype] == "S" ) { ?>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <table width="100%" style="position:relative; left:15px;" border="0" cellspacing="0" cellpadding="0">
      <?php include('header_project.php');?>
     <tr>
        <td  align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center"><div id="result" align="center" style="color:#FF0000; display:block;">&nbsp;</div></td>
          </tr>
          <tr>
            <td width="15%" height="395" align="left" valign="top" colspan="2"><? include('menu.php')?></td>
            <td width="100%"  valign="top">
              < <div id="form_news"  style="width:850px; position:relative;left:52px;">
    
    <div id="options" style="margin-left: 350px;margin-top:130px;position:absolute;z-index:2">        
    <a href="#" onclick="addProject()">Add New</a>   |  <a href="#" onclick="selectProject()">Select Project </a>
    </div>
    <div id="addProject" style="padding-top:15px; padding: 5px; display:none; height:500px; width:950px;position:relative; top:15px;">
    <table width="100%" style="position:relative; left:25px" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                     <tr><td colspan="8"> 
                     <form name="ff1" method="post" action="time.php">
                      <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
    				
                      <tr align="left">
                   <tr>
                     
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Project</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Work Code</span></td>
                        <td width="90" bgcolor="#e1e1e1" ><span class="text_pt space">Employee Name</span></td>
                        <td width="44" bgcolor="#e1e1e1" ><span class="text_pt space"> Billable Hours</span></td>
                        <td width="147" bgcolor="#e1e1e1" ><span class="text_pt space">Notes</span></td>
                        <td bgcolor="#e1e1e1" ><span class="text_pt space">Date</span></td>
                        <td  >&nbsp;</td>
                   </tr>
                      <tr align="left">
                        <td width="132" valign="top" class="f12b"><select name="project_number" id="project_name">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from projects");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['project_number']?>" ><?php echo $sql['project_name']?></option>
                      <?php } ?>
                  </select></td>
                        <td width="127" valign="top" class="f12b"><select name="task" id="task">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from work_codes");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['work_codes']?>"><?php echo $sql['work_codes']?></option>
                      <?php } ?>
                    </select> </td>
                        <td width="111" valign="top" class="login_fnt"><select name="staff_name" id="staff_name">
              		<option value="">Select</option>
                    <?php
                    	$aa=mysql_query("select * from staff_members");
    					while($sql_clients=mysql_fetch_array($aa))
    					{
    				?>
                 <option value="<?php echo $sql_clients['staff_id']?>" ><?php echo $sql_clients['staff_name']?></option>
                    <?php } ?>
              </select></td>
                        <td width="47" valign="top" class="f12b"><input type="text" name="bill_hours" id="bill_hours" value="" size="5" /></td>
                        <td width="136" valign="top" class="f12b"><textarea name="description" id="description" cols="20" rows="1"></textarea>
                        <input type="hidden" name="expense_date" value="<?php echo $currdate;?>" />                    </td>
                        <td width="185" valign="top" class="f12b">
                        <?php
    					$currdate=date('Y-m-d');
                        ?>
                        <input name="new_age_date" id="f_new_age_date" onChange="document.form_news.new_rem_age_date.value=document.form_news.new_age_date.value" size="10" readonly="yes" type="text" value="<?php echo $currdate;?>"> 
                  <img src="images/img.gif" id="trigger_new_age_date" style="cursor: pointer; border: medium none;" title="Select Date"> 
                  <script type="text/javascript">
    	Calendar.setup({
    	        inputField     :    "f_new_age_date",         
    	        ifFormat       :    "%Y-%m-%d",     
    	        button         :    "trigger_new_age_date",   
    	        singleClick    :    true                       
    	    });
    		  </script>                    </td>
                        <td width="41" valign="top" class="f12b">&nbsp;</td>
                        </tr>
                      <tr align="left">
                        <td valign="top">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="login_fnt">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr align="left">
                        <td valign="top">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="login_fnt">&nbsp;</td>
                        <td valign="top" class="f12b">&nbsp;</td>
                        <td valign="top" class="f12b"></td>
                        <td valign="top" class="f12b"><input type="submit" name="submit" id="submit" value="Add Time" /></td>
                      </tr>
                      </table>
                  </form>
                   </td></tr>
                </table>
    </div>
    
    <div id="selectProject" style="position:relative; z-index:1; padding-top:15px; padding: 5px; display:none; height:500px; width:950px; top:125px;">
    <div style="position:relative;bottom:45px">
    <p style="padding:5px padding-bottom:0px;margin-left:50px; "> Select a Project:<p>
    <select id ="selectValue" style="margin-left:50px;position:relative;bottom:15px;width:150px;">
    <?php 
    $aa1 = mysql_query("select * from projects");
    while(@$sql=mysql_fetch_array($aa1)) {?>
    	<option value="<?php echo $sql[project_name]; ?>"><?php echo $sql[project_name]; ?> </option>
    <?php } ?>
    </select>
    <input type="button" id="selectProjectSubmit" value="Submit" onclick="loadUsers()" style="position:relative;bottom:15px;"/>
    
    
    </div>
    <div id="sheetDiv" style="height:500px;width:950px; border: solid 1px red; position:relative; bottom:70px;"> random </div>
    </div>
           
    </td></tr> 
                    </table>  
                    </td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
            </tr>
       
        </table></td>
      </tr>
    
    
    <?php }?>
    
    </div>
    



    
    *****Code for loaded div below:*******
    





    <?php
    session_start();
    include('db.php');
    ?>
    <head>
    <script type="text/javascript">
    function updateField(id, field, project_name, date) {
    if(id) {
    	$field = $('#'+id);
    	$value = $field.val();
    	$.ajax({
    		type: "GET",
    		url: "ajax2.php",
    		data: "rqt=time&idfield=" + id + "&valuefield="+$value });
    }
    else {
           
    	    $.ajax({
    		type: "GET",
    		url: "ajax2.php",
    		data: "rqt=updatetime&valuefield="+ field + "&date=" + date + "&project_name=" + project_name});
    }
    }
    function doit(id,fieldtype, newvalue) {
    if(fieldtype=="staff_name" || fieldtype=="task"){
    var newvalue = newvalue.options[newvalue.selectedIndex].value;
    }
    
    
    $.ajax({
                               type: "GET",
                               url: "ajax2.php",
                               data: "fieldtype=" + fieldtype + "&id=" + id + "&newvalue=" + newvalue,
    						   });
    }
    </script>
    </head>
    
    
    <?php if($_REQUEST[project_date]){
    $currDate = date('Y-m-d', strtotime($_REQUEST[project_date]));
    $dayOfWeek = date('N', strtotime($_REQUEST[project_date]));
    if($dayOfWeek == 7) { $dayOfWeek = 0;}
    $subtractTime = "-".(string)$dayOfWeek."days";
    $newdate = strtotime($subtractTime , strtotime ($currDate) ) ;
    $newdate = date ( 'Y-m-d' , $newdate );
    
    $enddate = $newdate;
    }
    ?>
    <?php
    if($_SESSION[usertype] == "E") { ?>
    <table width="875px"  style="position:relative; left:15px;" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                    
                       <td colspan="8"> 
                     <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
                   <tr>
                   
    					<td width="100" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Project Name</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Sunday</span></td>
    					<td width="100" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Monday</span></td>
                        <td width="100" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Tuesday</span></td>
                        <td width="100" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Wednesday</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Thursday</span></td>
                        <td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Friday</span></td>
    					<td width="100" bgcolor="#e1e1e1" ><span class="text_pt space">Saturday</span></td>
                   </tr>
    			  <?php  
    			   $totalhrs=0;
                   $Query_dbl=mysql_query("select * from projects");
                    while($dbl_=mysql_fetch_array($Query_dbl))
    						    {
    							$counter = 0;
    							?>  <?php
    							$secondCounter = 0;
    							$starting = true;
                                while($secondCounter != 7 ) {
    							$newdate = $enddate;
    							$newdate = strtotime("".$secondCounter."day" , strtotime($newdate));
    							$newdate = date("Y-m-d", $newdate);
    							$Query_fql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."'");
    							if($secondCounter == 0 && mysql_num_rows($Query_fql) > 0 ) {
    							$PN_=mysql_fetch_array($Query_fql);
    							?>
    							<tr> <td> <?php echo $PN_['project_name']; ?> 
    							</td>
    							<?php $starting = false;}
    							$Query_sql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."' AND expense_date='".$newdate."'");
    							$Query_xql=mysql_query("select * from timesheet where staff_name='".$_SESSION['staff_id']."' AND project_name='".$dbl_['project_name']."' AND expense_date='".$newdate."'");
    						    $secondCounter++;
    						    if(mysql_num_rows($Query_xql) > 0) {
    						    $currentDate = null;							
    							while($sql_=mysql_fetch_array($Query_sql))
    						    {
    					             if($currentDate != $sql_['expense_date']){
    						            $currentDate = $sql_['expense_date'];
    						            $cyell = mysql_query("SELECT SUM(bill_hours) AS newhours FROM timesheet WHERE expense_date='".$sql_['expense_date']."' and project_name='".$sql_['project_name']."' and staff_name='".$_SESSION['staff_id']."'");
                                        $cardyell=mysql_fetch_assoc($cyell);
    						            }
    						            else {
    						            continue;
    						            }
    				  ?>
    				 
    					<td align="left"> 
    					<select style="width:100px" name="billHours" id="<?php echo $sql_['id'] ?>" onchange="updateField(this.id)">
    					<?php $a = 0; while($a != 15) {?>
    					<option value="<?php echo $a; ?>" <?php if($sql_['bill_hours'] == $a) { echo "selected"; } ?>> <?php echo $a; ?> </option>
    					<?php $a = $a + .5;} ?>
    					
    					</select>
    </td>
                        <?php $totalhrs += $sql_['bill_hours']; } } else{ if($starting == false) { ?> <td>
                        
                        
                        
                        <select style="width:100px" name="billHours" id="" onchange="updateField(null, this.value, <?php echo "'".$dbl_['project_name']."'";?>, <?php echo "'".$newdate."'";?>)">
    					<?php $a = 0; while($a != 15) {?>
    					<option value="<?php echo $a; ?>" <?php if($sql_['bill_hours'] == $a) { echo "selected"; } ?>> <?php echo $a; ?> </option>
    					<?php $a = $a + .5;} ?>
    					
    					</select>
                        
                        
                        
                         </td> <?php }  } ?> 
    				  <?php } ?> </tr> <?php }
    				  ?>
                      <tr>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                        <td colspan="2" align="right" valign="top" class="f12b"><br/><strong>Total Hours</strong></td>
                        <td align="center" valign="top" class="f12b">
                          <strong>
                            <?php
                        echo "<br/>";
    					echo $totalhrs;
                        ?>
                          </strong></td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr>
                        <td colspan="7" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      
                      </table>
                    </td></tr> 
                    </table>
    
    </div>
    <?php } 
    if($_SESSION[usertype] == "S" || $_SESSION[usertype] == "A"){ ?>
    
    <table width="875px"  style="position:relative;left:15px; bottom:0px !important" border="0" align="left" cellpadding="0" cellspacing="0">
                     
                    
                       <td colspan="8"> 
                     <table width="100%" border="0" align="left" cellpadding="5" cellspacing="3"> 
                   <tr>
                        <td width="20" class="login_fnt"><span class="text_pt space">&nbsp;&nbsp;&nbsp;</span></td>
                        <td width="160" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Employee Name</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Date Worked</span></td>
                        <td width="86" align="left" bgcolor="#e1e1e1" class="login_fnt"><span class="text_pt space">Billable Hours</span></td>
                        <td width="90" bgcolor="#e1e1e1" ><span class="text_pt space">Work Code</span></td>
                        <td width="44" bgcolor="#e1e1e1" ><span class="text_pt space">Notes</span></td>
                   </tr>
                   <?php
    						$Query_sql=mysql_query("select * from timesheet where project_name='".$_REQUEST['project_name']."'");
    						$totalhrs=0;
    						while($sql_=mysql_fetch_array($Query_sql))
    						{
    					
    				  ?>
                      <tr>
     <td width="20" align="left" valign="top">
                        <a  href="time.php?del=del&id=<?php echo $sql_['id']?>" class="text_pt" style="position:relative; left:12px; title="Delete" onclick="return confirm('Are you sure you want to delete?')"><img src="redx.png" border="0" /></a></td>
    <td width="90" align="left" valign="top" class="login_fnt"><select onchange="doit(<?php echo $sql_['id']?>, 'staff_name', this)" name="staff_name" id="staff_name">
              		<option value="">Select</option>
                    <?php
                    	$aa=mysql_query("select * from staff_members");
    					while($sql_clients=mysql_fetch_array($aa))
    					{
    				?>
                 <option value="<?php echo $sql_clients['staff_id']?>" <?php if($sql_clients['staff_id']==$sql_['staff_name']) echo "selected";?>><?php echo $sql_clients['staff_name']?></option>
                    <?php } ?>
              </select></td>
    
            <td width="90" align="left" valign="top" class="login_fnt"> <input id="text" onblur="doit(<?php echo $sql_['id']?>, 'expense_date', this.value)" value="<?php echo $sql_['expense_date'];?>"/></td> 
    
                       
                       
                        <td width="44" align="left" valign="top" class="f12b"><input type="text" onblur="doit(<?php echo $sql_['id']?>, 'bill_hours', this.value)" name="bill_hours" id="bill_hours" value="<?php echo $sql_['bill_hours']?>" size="5" />
                        <?php
    					$totalhrs=$totalhrs+$sql_['bill_hours'];
                        ?>                    
                        </td>
     <td width="86" align="left" valign="top" class="f12b"><select name="task" id="task" onchange="doit(<?php echo $sql_['id']?>, 'task', this)">
                      <option value="">Select</option>
                      <?php
                    	$aa=mysql_query("select * from program_list");
    					while($sql=mysql_fetch_array($aa))
    					{
    				?>
                      <option value="<?php echo $sql['id']?>" <?php if($sql['id']==$sql_['task']) echo "selected";?>><?php echo $sql['sports']?></option>
                      <?php } ?>
                    </select> </td>
                        
                        <td width="147" align="left" valign="top" class="f12b"><textarea name="description" onblur="doit(<?php echo $sql_['id']?>, 'description', this.value)" style="height:20px" id="description" cols="20" rows="1"><?php echo $sql_['description']?></textarea></td>
                      </tr><?php  $i++; }  
    				  ?>
                      <tr>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                        <td colspan="2" align="right" valign="top" class="f12b"><br/><strong>Total Hours</strong></td>
                        <td align="center" valign="top" class="f12b">
                          <strong>
                            <?php
                        echo "<br/>";
    					echo $totalhrs;
                        ?>
                          </strong></td>
                        <td align="left" valign="top" class="f12b">&nbsp;</td>
                      </tr>
                      <tr>
                        <td colspan="7" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      
                      </table>
                    </td></tr> 
                    </table>
    <?php } ?> 

