<?php

// -----------------------------------------------------------------------
// This file is part of Igloo
// 
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<form action="sch_edit.php" method="post" name="frm" id="id_frm">
<input type="hidden" name="display" value="<?php if(isset($display)) { echo $display;}?>" />
<input type="hidden" name="schedule_id" value="<?php if(isset($schedule['schedule_id'])) { echo $schedule['schedule_id'];}?>" />
<input type="hidden" name="schedule_type_id" value="<?php if(isset($schedule['schedule_type_id'])) { echo $schedule['schedule_type_id'];}?>" />
<input type="hidden" name="language_id" value="<?php if(isset($schedule['language_id'])) { echo $schedule['language_id'];}?>" />


<?php
if (isset($display) && $display == "allocation") {
?>
	<input type="hidden" name="allocation" value="1" />
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_allocation'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<tr>
						<td colspan="5">
							<?php echo $lang['txt_applicants'];?><br />
						</td>
					</tr>
					<tr>
						<td colspan="5">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						</td>
					</tr>
					<?php
					if (isset($schedule_allocation)) {
					?>
					<tr>
						<td>
							<?php echo $lang['txt_profile_nic'];?><br />
						</td>
						<td>
							<?php echo $lang['txt_hometown'];?><br />
						</td>
						<td>
							<br />
						</td>
						<td>
							<?php echo $lang['txt_date'];?><br />
						</td>
						<td>
							<br />
						</td>
					</tr>
					<?php
					foreach($schedule_allocation as $key => $i):
					?>
					
					<tr>
						<td valign="top">
							<?php echo $i['profile']['profile_nic'];?><br />
						</td>
						<td valign="top">
							<?php echo $i['profile']['profile_hometown'];?><br />
						</td>
						<td valign="top">
							<a href="msg_edit.php?to_user_id=<?php echo $i['user_id'];?>"><img src="<?php echo $templatePath;?>img/unopenned_mail.png" title="<?php echo $lang['href_send_message'];?>" border="0" alt="" /></a>&nbsp;
						</td>
						<td valign="top">
							<?php echo $i['schedule_allocation_create_datetime'];?><br />
						</td>
						<td align="right">
							<?php
							if (isset($i['status_id']) && $i['status_id'] == $schedule_config['allocation_status']['confirmed']) {
								echo $lang['schedule']['allocation_status'][$schedule_config['allocation_status']['confirmed']];
							}
							elseif (isset($i['status_id']) && $i['status_id'] == $schedule_config['allocation_status']['withdrawn']) {
								echo $lang['schedule']['allocation_status'][$schedule_config['allocation_status']['withdrawn']];
							}
							else {
							$show_submit_button = 1;
							?>
							<input type="hidden" name="user_ids[]" value="<?php echo $i['user_id'];?>" />
							<select name="status_ids[]" class="formInput">
							<option value="0" selected><?php echo $lang['txt_none'];?></option>
							<?php
							foreach($lang['schedule']['allocation_status'] as $key => $r):
								$selected="";
								if ($key == $i['status_id']) {
									$selected = "selected";
								}
								echo "<option value='" . $key . "' " . $selected . ">" . $r . "</option>";
							endforeach;
							}
							?>
							<br />
						</td>
					</tr>
					<?php
					endforeach;
					}
					if (isset($show_submit_button) && $show_submit_button > 0) {
					?>
					<tr>
						<td colspan="5">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="3" alt="" /><br />
						</td>
					</tr>
					<?php
					}
					?>
					<tr>
						<td align="right" colspan="5">
							<div class="box_edit">
								<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>" class="link_stnd"><?php echo $lang['href_view_schedule'];?></a>
								&nbsp;
								<input type="submit" name="update_allocations" value="<?php echo $lang['sub_update'];?>" class="button_urgent" />
								<br />
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	</form>
<?php
}
else {
?>

<script language="JavaScript" src="js/imageHandling.js" type="text/javascript"></script>
<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="<?php echo $languagePath;?>calendar/calendar-lang.js"></script>
<script type="text/javascript" src="js/calendar-setup.js"></script>

<div class="box">
	<div class="box_top">
		<?php echo $lang['hdr_schedule'];?><br />
	</div>
	
	<div class="box_mid">
		<div class="content">
			
			<?php
			if (isset($display) && $display == "edit_overview") {
			?>
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td>
						<b>
						<?php echo $lang['hdr_schedule'];?></b><br />
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="12" alt="" /><br />
						
					</td>
					<td colspan="2">
						<br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<fieldset>
						<legend><?php echo $lang['txt_header_1'];?></legend>
						<p>
						<?php echo $lang['txt_overview_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<table border="0" cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td valign="top" width="310">
									<p>
									<label for="id_schedule_title"><?php echo $lang['form_label_title'];?></label>
									<input id="id_schedule_title" type="text" name="schedule_title" size="35" value="<?php if (isset($schedule['schedule_title'])) { echo $schedule['schedule_title'];}?>" /><br />
									</p>
									
									<p>
									<label for="id_schedule_synopsis"><?php echo $lang['form_label_synopsis'];?></label>
									<textarea id="id_schedule_synopsis" name="schedule_synopsis" cols="32" rows="2"><?php if (isset($schedule['schedule_synopsis'])) { echo $schedule['schedule_synopsis'];}?></textarea><br />
									</p>
						
									<p>
									<label for="id_schedule_location"><?php echo $lang['form_label_location'];?></label>
									<input id="id_schedule_location" type="text" name="schedule_location" size="35" value="<?php if (isset($schedule['schedule_location'])) { echo $schedule['schedule_location'];}?>"><br />
									</p>
								</td>
								<td>
									<img src="<?php echo $templatePath;?>img/pixel.png" width="10" height="1" alt="" /><br />
								</td>
								<td valign="top">
									<p>
									<label for="id_schedule_category"><?php echo $lang['form_label_category'];?></label>
									<select id="id_schedule_category" name="schedule_category_id">
									<?php
									if ($schedule['schedule_type_id'] == 2) { //task
										$arr_category = $lang['schedule']['arr_task_category'];
									}
									else {
										$arr_category = $lang['schedule']['arr_event_category'];
									}
									
									
									foreach($arr_category as $key => $i):
									$selected = "";
					
									if (isset($schedule['schedule_category_id']) && $schedule['schedule_category_id'] == $i['arr_schedule_category']) {
									    $selected = " selected=\"selected\"";
									}
									?>
									<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
									<?php endforeach; ?>
									</select>
									</p>
									
									<p>
									<label for="id_schedule_status"><?php echo $lang['form_label_status'];?></label>
									<select id="id_schedule_status" name="schedule_status_id">
									<?php
									foreach($lang['schedule']['arr_event_status'] as $key => $i):
									$selected = "";
					
									if (isset($schedule['schedule_status_id']) && $schedule['schedule_status_id'] == $i['arr_schedule_status']) {
									    $selected = " selected=\"selected\"";
									}
									?>
									<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
									<?php endforeach; ?>
									</select>
									</p>
									
									<?php
									if ($schedule['schedule_type_id'] == 2) { //task
									?>
									<p>
									<label for="id_schedule_priority"><?php echo $lang['form_label_priority'];?></label>
									<select id="id_schedule_priority" name="schedule_priority_id">
									<?php
									foreach($lang['schedule']['arr_priority'] as $key => $i):
									$selected = "";
					
									if (isset($schedule['schedule_priority_id']) && $schedule['schedule_priority_id'] == $i['arr_schedule_priority']) {
									    $selected = " selected=\"selected\"";
									}
									?>
									<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
									<?php endforeach; ?>
									</select>
									</p>
									<?php }?>
									
									<?php
									if ($schedule['schedule_type_id'] == 2) { //task
									?>
									<script type="text/javascript">
									function setPComplete(id) {
										var displaystate = 'block';
										
										if (id.checked) {
											displaystate = 'none';
										}
										
										objShowHide('div_schedule_p_complete', displaystate);
									}
									</script>
									<label for="id_schedule_complete"><?php echo $lang['form_label_complete'];?></label>
									<table border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td valign="top" width="25">
												<input type="checkbox" name="schedule_complete" value="1"<?php echo $selected;?> onClick="javascript:setPComplete(this);" /><br />
											</td>
											<td valign="top">
												<div id="div_schedule_p_complete">
												&#37;
												<select id="id_schedule_p_complete" name="id_schedule_p_complete">
												<?php
												$i = 0;
												while ($i<101):
													echo "<option value='" . $i . "'>" . $i . "</option>";
												    $i = $i+10;
												endwhile;
												?>
												</select>
												</div>
												<br />
											</td>
										</tr>
									</table>
									<?php }?>
									
									<p>
									<label for="id_schedule_allocation"><?php echo $lang['form_label_allocation'];?></label>
									<input id="id_schedule_allocation" type="text" name="schedule_allocation" size="5" value="<?php if (isset($schedule['schedule_allocation'])) { echo $schedule['schedule_allocation'];}?>"><br />
									</p>
									
								</td>
							</tr>
						</table>
						</fieldset>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_2'];?></legend>
						<p>
						<?php echo $lang['txt_date_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<?php
						if ($schedule['schedule_type_id'] == 1) { //event
						$selected = "";
		
						if (isset($schedule['schedule_all_day']) && $schedule['schedule_all_day'] == 1) {
						    $selected = " checked=\"checked\"";
						}
						?>		
						<script type="text/javascript">
						function setAllDay(id) {
							var displaystate = 'block';
							
							if (id.checked) {
								displaystate = 'none';
								document.frm.id_schedule_start_time.value = "";
								document.frm.id_schedule_end_time.value = "";
							}
							
							objShowHide('starttime', displaystate);
							objShowHide('endtime', displaystate);
						}
						</script>
						<p>
						<?php
						$selected ="";
						$selected_value = 0; 
						if (isset($schedule['schedule_all_day_item']) && $schedule['schedule_all_day_item'] == 1) { 
							$selected = " checked=\"checked\"";
							$selected_value = 1; 
						}
						?>
						<input type="checkbox" id="id_schedule_all_day_item" name="schedule_all_day_item" value="1" onChange="javascript:setAllDay(this);"<?php echo $selected;?> />&nbsp;<?php echo $lang['form_all_day'];?><br />
						</p>
						<?php }?>
						
						
						<?php
						if ($schedule['schedule_type_id'] == 2) { //task
						$selected = "";
		
						if (isset($schedule['schedule_no_start_datetime']) && $schedule['schedule_no_start_datetime'] == 1) {
						    $selected = " checked=\"checked\"";
						}
						?>		
						<script type="text/javascript">
						function setNoStartDateTime(id) {
							var displaystate = 'block';
							
							if (id.checked) {
								displaystate = 'none';
								document.frm.id_schedule_start_date.value = "";
								document.frm.id_schedule_start_time.value = "";
							}
							
							objShowHide('startdate', displaystate);
							objShowHide('starttime', displaystate);
						}
						
						function setNoEndDateTime(id) {
							var displaystate = 'block';
							
							if (id.checked) {
								displaystate = 'none';
								document.frm.id_schedule_end_date.value = "";
								document.frm.id_schedule_end_time.value = "";
							}
							
							objShowHide('enddate', displaystate);
							objShowHide('endtime', displaystate);
						}
						</script>
						<p>
						<input type="checkbox" id="id_schedule_no_start_datetime" name="schedule_no_start_datetime" value="1"<?php echo $selected;?> onClick="javascript:setNoStartDateTime(this);" />&nbsp;<?php echo $lang['form_no_start'];?>&nbsp;&nbsp;
						
						<input type="checkbox" id="id_schedule_no_end_datetime" name="schedule_no_end_datetime" value="1"<?php echo $selected;?> onClick="javascript:setNoEndDateTime(this);" />&nbsp;<?php echo $lang['form_no_end'];?><br />
						</p>
						<?php }?>
								
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
								
						<table border="0" cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td>
									<div id="startdate">
			  						<p>
			  						<label for="id_schedule_start_date"><?php echo $lang['form_label_start_date'];?></label>
			  						<input id="id_schedule_start_date" type="text" maxlength="10" name="schedule_start_date" size="11" value="<?php if(isset($schedule['schedule_start_date'])) { echo $schedule['schedule_start_date'];}?>" />
			  						<img src="<?php echo $templatePath;?>img/cal_icon.png" id="id_cal_pop1" width="34" height="21" border="0" alt=""onmouseover="this.style.background='red';" onmouseout="this.style.background=''" />
			  						</p>
									
			  						<script type="text/javascript">
			  							function dateChanged1(calendar) {
			  							 	if (calendar.dateClicked) {
			  							   		var y = calendar.date.getFullYear();
			  							   		var m = calendar.date.getMonth()+1;     // integer, 0..11
			  							   		var d = calendar.date.getDate();      // integer, 1..31
			  									var h = calendar.date.getHours();      // integer, 1..31
			  									var i = calendar.date.getMinutes();      // integer, 1..31
			  							
			  									document.frm.id_schedule_start_date.value = y + '-' + m + '-' + d;
			  									document.frm.id_schedule_start_time.value = h + ':' + i;
			  									calendar.callCloseHandler();
			  							 	}
			  							};
			  							
			  						  	Calendar.setup({           // our callback function
			  						        ifFormat       :    "%m-%d-%Y %k:%M",
			  						        button         :    "id_cal_pop1",
			  						        align          :    "Tl", // popup alignment
			  						        singleClick    :    true,
			  								showsTime      :    true,
			  						      	onSelect    : dateChanged1
			  						    });
			  						</script>
									</div>
								</td>
								<td>
									<div id="starttime">
									<p>
									<label for="id_schedule_start_time"><?php echo $lang['form_label_start_time'];?></label>
									<input id="id_schedule_start_time" type="text" maxlength="5" name="schedule_start_time" size="6" value="<?php if(isset($schedule['schedule_start_time'])) { echo $schedule['schedule_start_time'];}?>" />
									</p>
									</div>
								</td>
							</tr>
							<tr>
								<td>
									<div id="enddate">
									<p>
									<label for="id_schedule_end_date"><?php echo $lang['form_label_end_date'];?></label>
									<input id="id_schedule_end_date" type="text" maxlength="10" name="schedule_end_date" size="11" value="<?php if(isset($schedule['schedule_end_date'])) { echo $schedule['schedule_end_date'];}?>" />
									<img src="<?php echo $templatePath;?>img/cal_icon.png" id="id_cal_pop2" width="34" height="21" border="0" alt=""onmouseover="this.style.background='red';" onmouseout="this.style.background=''" />
								  	</p>
									
									<script type="text/javascript">
										function dateChanged2(calendar) {
										 	if (calendar.dateClicked) {
										   		var y = calendar.date.getFullYear();
										   		var m = calendar.date.getMonth()+1;     // integer, 0..11
										   		var d = calendar.date.getDate();      // integer, 1..31
												var h = calendar.date.getHours();      // integer, 1..31
												var i = calendar.date.getMinutes();      // integer, 1..31
										
												document.frm.id_schedule_end_date.value = y + '-' + m + '-' + d;
												document.frm.id_schedule_end_time.value = h + ':' + i;
												calendar.callCloseHandler();
										 	}
										};
										
									  	Calendar.setup({           // our callback function
									        ifFormat       :    "%m-%d-%Y %k:%M",
									        button         :    "id_cal_pop2",
									        align          :    "Tl", // popup alignment
									        singleClick    :    true,
											showsTime      :    true,
									      	onSelect    : dateChanged2
									    });
									  
									</script>
									</div>
								</td>
								<td>
									<div id="endtime">
									<p>
									<label for="id_schedule_end_time"><?php echo $lang['form_label_end_time'];?></label>
									<input id="id_schedule_end_time" type="text" maxlength="5" name="schedule_end_time" size="6" value="<?php if(isset($schedule['schedule_end_time'])) { echo $schedule['schedule_end_time'];}?>" />
									</p>
									</div>
								</td>
							</tr>
						</table>
						<script type="text/javascript"> //check at load and hide if nesessary
						 if (document.frm.id_schedule_all_day_item.checked) {
						 	objShowHide('starttime', 'none');
							objShowHide('endtime', 'none');
						}
						</script>
						
						<?php
						if (empty($schedule['schedule_start_datetime'])) {
						?>
						<script type="text/javascript"> //check at load and hide if nesessary
							document.getElementById('id_schedule_no_start_datetime').checked=true;
							objShowHide('startdate', 'none');
							objShowHide('starttime', 'none');
						</script>
						<?php }?>
						
						<?php
						if (empty($schedule['schedule_end_datetime'])) {
						?>
						<script type="text/javascript"> //check at load and hide if nesessary
							document.getElementById('id_schedule_no_end_datetime').checked=true;
							objShowHide('enddate', 'none');
							objShowHide('endtime', 'none');
						</script>
						<?php }?>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<?php
						if (isset($lang['schedule']['occurrence'])) {
						?>
						<p>
						<label for="id_occurence"><?php echo $lang['form_label_occurence'];?></label>
						<select name="schedule_occurence">
						<?php
						foreach ($lang['schedule']['occurrence'] as $key => $i):
						$selected = "";
						
						if (isset($schedule['schedule_occurence']) && $schedule['schedule_occurence'] == $key) {
							$selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $i;?></option>
						<?php
						endforeach;
						?>
						</select>
						&nbsp;until&nbsp;
						 <input id="id_schedule_repeat_until" type="text" maxlength="10" name="schedule_repeat_until" size="11" value="<?php if(isset($schedule['schedule_repeat_until'])) { echo $schedule['schedule_repeat_until'];}?>" />
						<img src="<?php echo $templatePath;?>img/cal_icon.png" id="id_cal_pop3" width="34" height="21" border="0" alt=""onmouseover="this.style.background='red';" onmouseout="this.style.background=''" />
						</p>
						<?php }?>
						
						<script type="text/javascript">
							function dateChanged3(calendar) {
								if (calendar.dateClicked) {
									var y = calendar.date.getFullYear();
									var m = calendar.date.getMonth()+1;     // integer, 0..11
									var d = calendar.date.getDate();      // integer, 1..31
							
									document.frm.id_schedule_repeat_until.value = y + '-' + m + '-' + d;
									calendar.callCloseHandler();
								}
							};
							
							Calendar.setup({           // our callback function
								ifFormat       :    "%m-%d-%Y",
								button         :    "id_cal_pop3",
								align          :    "Tl", // popup alignment
								singleClick    :    true,
								showsTime      :    true,
								onSelect    : dateChanged3
							});
						  
						</script>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<?php
						if (isset($lang['schedule']['alarm'])) {
						?>
						<p>
						<label for="id_alarm"><?php echo $lang['form_label_alarm'];?></label>
						<select name="schedule_alarm">
						<?php
						foreach ($lang['schedule']['alarm'] as $key => $i):
						$selected = "";
						
						if (isset($schedule['schedule_alarm']) && $schedule['schedule_alarm'] == $key) {
							$selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $i;?></option>
						<?php
						endforeach;
						?>
						</select>
						<br />
						</p>
						<?php }?>
						</fieldset>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_3'];?></legend>
						<p>
						<?php echo $lang['txt_detail_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<table border="0" cellspacing="0" cellpadding="2" width="10%">
							<tr>
								<td valign="top">
									<label for="id_schedule_body"><?php echo $lang['form_body'];?></label>
									<div id="gui_wiki" align="right" valign="bottom">
										<script language="JavaScript" type="text/javascript" src="js/gui_wiki.js"></script>
									</div>
								</td>
							</tr>
							<tr>
								<td>
									<textarea id="id_schedule_body" name="schedule_body" cols="78" rows="10" onchange="textChanged = true;" tabindex="1"><?php if (isset($schedule['schedule_body'])) { echo $schedule['schedule_body'];}?></textarea><br />
									<script language="JavaScript" type="text/javascript">
										var txtarea = document.frm.schedule_body;
									</script>
								</td>
							</tr>
							<tr>
								<td align="right">
									<input type="submit" name="preview" value="<?php echo $lang['form_submit_preview'];?>" class="button_light" />
									
									<?php 
									if (isset($allow_spellcheck)) {
									?>
									&nbsp;&nbsp;
									<input type="button" value="<?php echo $lang['sub_check_spelling'];?>" onClick="openSpellChecker();" class="button_light" />
									<?php }?>
									<br />
								</td>
							</tr>
							
							<?php
							if (!empty($schedule['schedule_body_preview'])) {
							?>
							
							<tr>
								<td>
									<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $lang['form_label_preview'];?><br />
								</td>
							</tr>
							<tr>
								<td class="picture_light">
									<?php echo $schedule['schedule_body_preview'];?><br />
								</td>
							</tr>
							<?php }?>
						</table>
						</fieldset>
						
					</td>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="10" height="1" alt="" /><br />
					</td>
					<td valign="top" width="200">
						<fieldset>
						<legend><?php echo $lang['txt_header_4'];?></legend>
						<p>
						<?php echo $lang['txt_image_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<?php
						if (isset($images)) {
						?>
						<p>
						<?php echo $lang['form_label_file'];?></label><br />
						</p>	
						
						<div>
						<p>
						<select id="id_file_id" size=4 name="file_id" onChange='javascript:setimg(this)'>
						<option value="0" selected="selected"><?php echo $lang['txt_none'];?></option>
						<?php
						$img_divs = "";
						foreach($images as $key => $i):
						$display_state = "none";
						$selected = "";
						if (isset($schedule['file_id']) && $schedule['file_id'] == $i['file_id']) {
						    $selected = "selected=\"selected\"";
							$display_state = "block";
						}
						?>
						<option value="<?php echo $i['file_id'];?>" <?php echo $selected;?>><?php echo $i['file_name'];?></option>
						<?php
						$img_divs .= "<div style=\"display:" . $display_state . ";\" id=img" . $i['file_id'] . "><img src=\"get_file.php?file=" . $i['file'] . "\" border=\"0\" class=\"picture\" /><br />" . $i['file_title'] . "</div>";
						endforeach;
						?>
						</select>
						</p>
						</div>
						<?php echo $img_divs;?>
						<?php }?>
						</fieldset>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_5'];?></legend>
						<p>
						<?php echo $lang['txt_publishing_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<?php
						//find out what value rsp has
						if (isset($schedule['rsp'])) {
							foreach($schedule['rsp'] as $key => $rsp):
								if ($rsp['level_id'] == $rspconfig['rsp_level']['degree']) {
									$rsp_degree_set = 1;
									$rsp_degree = $rsp['degree_id'];
								}
								elseif ($rsp['level_id'] == $rspconfig['rsp_level']['node']) {
									$rsp_node = 1;
								}
								elseif ($rsp['level_id'] == $rspconfig['rsp_level']['public']) {
									$rsp_public = 1;
								}
							endforeach;
						}
						?>
						
						<script type="text/javascript">
						function setDegreeEveryone(id) {
							if (id.checked) {
								document.getElementById('id_degree_id').checked=true;
							}
						}
						function setPublishingOff() {
							document.getElementById('id_level_id_node').checked=false;
							document.getElementById('id_level_id_public').checked=false;
							
						}
						</script>
						
						<table border="0" cellspacing="0" cellpadding="2" width="100%">
							<tr>
								<td width="1">
									<input type="radio" class="checkbox" name="rsp_degree" value="" checked="checked" onClick="javascript:setPublishingOff();" /><br />
								</td>
								<td>
									<?php echo $lang['form_just_me'];?><br />
								</td>
							</tr>
							
							
							<?php
							if ($this->user_acs->checkPermission($resource_ids['rsp'], $privilege_ids['allow_rsp_network'])) { //resourece_id, Priv_id
							$selected="";
							if (isset($rsp_degree)) {
								$selected=" checked=\"checked\"";
							}
							?>
							<tr>
								<td width="1">
									<input type="radio" name="rsp_degree" class="checkbox" value="1"<?php echo $selected;?> onClick="javascript:setPublishingOff();" /><br />
								</td>
								<td>
									<?php echo $lang['txt_degree_nw'];?><br />
								</td>
							</tr>
							<?php }?>
							
							<?php
							$selected="";
							if (isset($rsp_degree_set) && empty($rsp_degree)) {
								$selected=" checked=\"checked\"";
							}
							?>
							<tr>
								<td>
									<input id="id_degree_id" type="radio" class="checkbox" name="rsp_degree" value="all"<?php echo $selected;?> /><br />
								</td>
								<td>
									<?php echo $lang['txt_publish_all'];?><br />
								</td>
							</tr>
							
							<?php
							if ($this->user_acs->checkPermission($resource_ids['rsp'], $privilege_ids['allow_rsp_node'])) { //resourece_id, Priv_id
							$selected="";
							if (isset($rsp_node) && $rsp_node == 1) {
								$selected=" checked=\"checked\"";
							}
							?>
							<tr>
								<td valign="top">
									<input type="checkbox" id="id_level_id_node" name="rsp_node" value="1"<?php echo $selected;?> class="checkbox" onChange="javascript:setDegreeEveryone(this);" /><br />
								</td>
								<td>
									<?php 
									if (isset($rspconfig['node']['auto_publish'])) {
										echo $lang['txt_publish_auto_node_help'];
									}
									else {
										echo $lang['txt_publish_node_help'];
									}
									?><br />
								</td>
							</tr>
							<?php
							}
							
							if ($this->user_acs->checkPermission($resource_ids['rsp'], $privilege_ids['allow_rsp_public'])) { //resourece_id, Priv_id
							$selected="";
							if (isset($rsp_public) && $rsp_public == 1) {
								$selected=" checked=\"checked\"";
							}
							?>
							<tr>
								<td valign="top">
									<input type="checkbox" id="id_level_id_public" name="rsp_public" value="1"<?php echo $selected;?> class="checkbox" onChange="javascript:setDegreeEveryone(this);" /><br />
								</td>
								<td>
									<?php 
									if (isset($rspconfig['node']['auto_publish'])) {
										echo $lang['txt_publish_auto_public_help'];
									}
									else {
										echo $lang['txt_publish_public_help'];
									}
									?><br />
								</td>
							</tr>
							<?php }?>
							<tr>
								<td valign="top">
									<input id="id_allow_comments" type="checkbox" name="schedule_allow_comments" class="checkbox" value="1" <?php if (isset($schedule['schedule_allow_comments']) && $schedule['schedule_allow_comments'] == 1) { echo "checked=\"checked\"";}?> /><br />
								</td>
								<td valign="top">
									<label style="width:100%" for="id_allow_comments"><?php echo $lang['form_label_comments'];?></label><br />
								</td>
							</tr>
						</table>
						</fieldset>
						
						<script type="text/javascript">
						//check php did not set either of the publishing buttons
						if (document.getElementById('id_level_id_public').checked) {
							document.getElementById('id_degree_id').checked=true;
						}
						if (document.getElementById('id_level_id_node').checked) {
							document.getElementById('id_degree_id').checked=true;
						}
						</script>
						
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_6'];?></legend>
						<p>
						<?php echo $lang['txt_save_intro'];?><br />
						</p>
					
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<input type="submit" name="save_overview" class="button_urgent" value="<?php echo $lang['form_submit_save'];?>" />&nbsp;
						<input type="submit" name="save_go_overview" class="button_urgent" value="<?php echo $lang['form_submit_save_go'];?>" /><br />
					
						</fieldset>
					</td>
				</tr>
			</table>
			
			<?php
			}
			else { //no edit allowed
			?>
			
			<?php echo $lang['err_schedule_item_edit'];?><br />
			
			<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>
<?php }?>
</form>
