<?php
/**
 * unit_resadd_view.php - View for the resource add opoup. This is not a typical view file.
 * 							  This is template driven and has a lot of coding and logics
 *
 * @author $Author: wichai $
 * @version $Id: unit_resadd_view.php,v 1.79 2011/05/31 07:57:32 wichai Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/
	if (!isset($resobj)) {
		$resobj = FALSE;
	}
	//TODO: Do something about this unitid is zero
	if ( $unitid != 0 ) {
		if ( isset($_divid) && $_divid !== FALSE ) {
	   	$divid = $_divid;
		}
		if ( isset($_stage_num) && $_stage_num !== FALSE ) {
	   	$stagenum = $_stage_num;
		}
		$url_refresh_unitid = $unitid;
		if ( isset($refresh_unitid) && osa_is_int_one($refresh_unitid) ) {
			//This is for static resources to refresh the stage properly
			$url_refresh_unitid = $refresh_unitid;
		}
		$update_jscript_params =
			"'" . base_url() . "unit/resource/updateres/{$url_refresh_unitid}/{$type}','resource_form','" .
			base_url() . "$refresh_url_part/{$stagenum}/" . CMS_ACTION_EDIT . "/{$url_refresh_unitid}','{$divid}'";
	}
	else { //unit id is 0 so we know it is ict, gc or tail upload
		if ( isset($_divid) && $_divid !== FALSE )
	        $divid = $_view_divid;
	   /*
		//fix for ICT/Lib Uploads only
		if ($type == CMS_ITSTANDARDS_RESOURCE_TYPE) {
			$schoolid = FALSE;
			if  ($resobj === FALSE)
				$schoolid = $pid2;
			else
				$schoolid = $pid1;
			$update_jscript_params =
	        "'" . base_url() . "unit/resource/updateres/{$unitid}/{$type}','resource_form','" .
	        base_url() . "unit/itstd/sample/" . CMS_ITSTANDARDS_TYPE . "/" . CMS_ITSTANDARDS_RESOURCE_TYPE . "/{$schoolid}','{$divid}'";
		}
		*/
		if (isset($_ict_type) && $_ict_type != FALSE && isset($_typeid) && $_typeid != FALSE ){
			/*
			$schoolid = FALSE;
			if  ($resobj === FALSE)
				$schoolid = $pid2;
			else
				$schoolid = $pid1;
				*/
			$update_jscript_params =
		        "'" . base_url() . "unit/resource/updateres/{$unitid}/{$type}','resource_form','" .
		        base_url() . "unit/itstd/sample/" . $_ict_type . "/" . $_typeid . "/{$schoolid}/{$role_type}','{$divid}'";
		}
	} //else
	$max_selects = $this->config->item('cms_max_selects');
	$multi_msg = FALSE;
?>
<html>
<head>
<?php
if (isset($_date_flag) && $_date_flag !== FALSE) { ?>
	<link rel="stylesheet" href='<?php echo osa_include_path()?>js/calendar/calendar-win2k-1.css' type="text/css" media="screen" />
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/calendar/calendar_stripped.js"></script>
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/calendar/lang/calendar-en.js"></script>
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/calendar/calendar-setup.js"></script>
<?php } ?>
<script type="text/javascript" src="<?php echo osa_include_path()?>js/sys.js"></script>
<script type="text/javascript" src="<?php echo osa_include_path()?>js/app.js"></script>
<?php $this->load->view('template/dhtmlxwindows_js_view')?>

<!-- TinyMCE -->
<script type="text/javascript" src="<?php echo osa_include_path()?>js/tiny_mce/plugins/asciimath/js/ASCIIMathMLwFallback.js"></script>
<script type="text/javascript">
	hiddenOBJ('');	//fix bug IE when used ASCIIMath
</script>
<script type="text/javascript" src="<?php echo osa_include_path()?>js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	var tinymce_backgroundcolor = '';
	<?php if ( $this->config->item('cms_site_image_folder') == 'site' ) {
		//Set the tinymce textarea background color. This color is also in the style_site.css
		echo "tinymce_backgroundcolor='#E1F2FF';";
	}?>
	init_tinymce('<?php echo base_url();?>',
		 '<?php echo $this->config->item('cms_svg_graph'); ?>',
		 '<?php echo $this->config->item('cms_svg_graph_file'); ?>',
		 '<?php echo $this->config->item('cms_svg_graph_css'); ?>' );
</script>
<!-- /TinyMCE -->
<?php if (isset($_upload_flag) && $_upload_flag !== FALSE ) {?>
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/jstree/lib/jquery.js"></script>
	<!-- Plupload -->
	<link rel="stylesheet" href="<?php echo osa_include_path()?>css/plupload/css/plupload.queue.css" type="text/css" media="screen" />
	<style type="text/css">
		.plupload_start, .plupload_header_content, .plupload_filelist_header  { display: none; }
		.plupload_scroll .plupload_filelist { height: <?php echo $upload_queuelist_height; ?>px; }
		.plupload_filelist_footer { height: 20px; }
		li.plupload_droptext { line-height : 0px; }
		input[type=file] { cursor: pointer};
	</style>
	<!--[if lte IE 8]> <?php //Conditional comment: IE version detect - http://en.wikipedia.org/wiki/Conditional_comment ?>
		<style type="text/css">
		.plupload_wrapper, .plupload_scroll .plupload_filelist { height: <?php echo $upload_queuelist_height; ?>px; }
		</style>
	<![endif]-->
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/plupload/gears_init.js"></script>
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/plupload/plupload.full.js"></script>
	<script type="text/javascript" src="<?php echo osa_include_path()?>js/plupload/jquery.plupload.queue.js"></script>
	<!-- /Plupload -->
<?php } ?>
<?php
	$this->load->view('template/jscript_globalvars_view');
	osa_appcss_include();
?>
<title></title>
</head>
<body onkeydown="update_parent_session_event('1');" onmousedown="update_parent_session_event('1');">
<div class="reswin_title"><?php echo @$title?></div>
<center>
<form style="margin:0px;padding:0px" method="POST" action="<?php echo base_url() . "unit/resource/adddb/{$unitid}/{$type}"?>" name="resource_form">
<table style="margin:0px;padding:0px;max-width:96%">
	<tr><td align="left">
		<input type="hidden" name="resid" value="<?php echo @$resid?>" />
		<input type="hidden" name="courseid" value="<?php echo @$courseid?>" />
		<input type="hidden" name="benchmarkid" value="<?php echo @$benchmarkid?>" />
		<input type="hidden" name="schoolid" value="<?php echo @$schoolid?>" />
		<?php if ( isset($_checkpublic_flag) && $_checkpublic_flag !== FALSE ) { ?>
				<div class='reswin_public'><input type="checkbox" name="ispublic" value="1" <?php
				//$checkbox_default_value is only available when adding new resource
					if ( $resobj && osa_value($resobj,'ispublic',FALSE) || ( !$resobj && isset($checkbox_default_value) && $checkbox_default_value ) )
						echo 'checked="checked"';
			?>/> <?php echo lang('unit_makepublic') . " <i>{$publicflag_extra_msg}</i>"?></div>
		<?php }
				else { //No Check box but hidden value, no html hidden means private
					if ( isset($checkbox_default_value) && $checkbox_default_value )
						echo '<input type="hidden" name="ispublic" value="1" />';
		}?>
		<?php if ($_text_flag){ ?>
			<div class="reswin_textarea">
			<?php
				if ($_text_title !== FALSE) echo $_text_title . ':<br />';
				$tmp_text_rows = $_text_rows;
				$CI = & get_instance();
				$CI->load->library('user_agent');
				if ( strtolower($CI->agent->browser()) == 'firefox' ) {
					//Firefox 4 has bigger textarea box so make it fit.
					//Older Firfox versions will have smaller textarea and it should be OK.
					$tmp_text_rows -= 2;
				}
			?>
			<textarea rows="<?php echo $tmp_text_rows?>" id="text1" name="text1" cols="<?php echo $_text_cols?>"><?php
				//fix default font style & font size
				if ($resobj == FALSE)
					echo '<span style="font-family:verdana,arial,helvetica,sans-serif;font-size:11px"></span>';
				else
					osa_value($resobj,'text1');
			?></textarea>
			</div>
			<div>&nbsp;</div>
		<?php }?>
		<table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px">
		<?php
			//Drop down options
			//for ($i=1; $i<=$max_selects; $i++) {
			$print_multi_msg = FALSE;
			if ( !isset($_select_order) ) {
				//This is done to support template without _select_order
				$_select_order = array();
				for ($i=1; $i<=$max_selects; $i++) {
					$_select_order[] = $i;
				}
			}
			if ( is_array($_select_order) ) {
				$skipped_newline = FALSE;
				foreach($_select_order as $i) {
					$sel_flag_tag = '_select_flag' . $i;
					$sel_title_tag = '_select_title' . $i;
					$sel_options_tag = '_select' . $i; //This is same as the DB column name
					$sel_size = '_select_size' . $i;
					$sel_title = '_select_title' . $i;
					$sel_multi = '_select_multi' . $i;
					$sel_checkbox = '_select_checkbox_type' . $i;
					$sel_default = '_select_default' . $i;
					$sel_formfield = 'select' . $i;
					$select_help = '_select_help' . $i;
					$select_skip_newline = '_select_skip_newline' . $i;

					if (isset($$sel_checkbox) && $$sel_checkbox === TRUE) {
						//This is a checkbox
						$selected_value = osa_value($resobj,$sel_formfield, FALSE);
						if ( $resobj == FALSE && isset($$sel_default))
							$selected_value = $$sel_default;
						$checked = '';
						if ( $selected_value == TRUE ) {
							$checked = 'checked="checked"';
						}
						if ( !$skipped_newline ) {
							echo '<tr>';
						}
						else {
							echo '<td width="30">&nbsp;</td>';
						}
						echo '<td colspan="2" class="reswin_select_title_left">';
						echo "<input type=\"checkbox\" name=\"{$sel_formfield}[]\" value=\"1\" $checked /> ";
						if ( isset($$sel_title) && $$sel_title !== FALSE ) {
							echo $$sel_title;
						}
						if ( isset($$select_skip_newline) && $$select_skip_newline === TRUE ) {
							echo '</td>';
							$skipped_newline = TRUE;
						}
						elseif ($skipped_newline) {
							echo '</td></tr>';
							$skipped_newline = FALSE;
						}
						else {
							echo '</td><td colspan="3"></td></tr>';
							$skipped_newline = FALSE;
						}
					}
					else { //This is a selection box
						if ( !isset($$sel_flag_tag) || $$sel_flag_tag === FALSE ||
							  !isset($$sel_options_tag) || !is_array($$sel_options_tag) ||
							  !isset($$sel_size) || !is_numeric($$sel_size) ) {
							continue;
						}
						if ( !$skipped_newline ) {
							echo '<tr>';
						}
						else {
							echo '<td width="30">&nbsp;</td>';
						}
						echo '<td class="reswin_select_title">';
						if ( isset($$sel_title) && $$sel_title !== FALSE ) {
								echo $$sel_title . ':';
						}
						echo '</td><td class="reswin_select_dropdown">';
						//watch out for the array order
						if ( $$sel_size == 1 )
							$selarray = array(0=>lang('unit_selectchoose'));
						else
							$selarray = array();
						$tmp = $$sel_options_tag;
						//In order to keep the original key values and element order
						//becuase form_dropdown() uses foreach and array[] assing and array combine will mess the order
						foreach(array_keys($tmp) as $key) {
							$selarray[$key] = $tmp[$key];
						}
						//$selarray = $$sel_options_tag;
						//$selarray[0] = lang('unit_selectchoose');
						$selected_value = osa_value($resobj,$sel_formfield, FALSE);
						if ( $resobj == FALSE && isset($$sel_default))
							$selected_value = $$sel_default;
						$sel_multitext = '';
						$multi_msg = FALSE;
						if ( isset($$sel_multi) && $$sel_multi === TRUE ) {
							$sel_multitext = ' multiple="multiple"';
							$multi_msg = TRUE;
						}
						echo form_dropdown($sel_formfield . '[]', $selarray, $selected_value, 'size="' . $$sel_size . '"' . $sel_multitext);
						if ( isset($$select_help) && $$select_help !== FALSE ) {
								echo "&nbsp;".$$select_help;
						}
						if ( $multi_msg ) {
							$print_multi_msg = TRUE;
						}
						//echo "<div style=\"font-size:9px;margin-top:5px\">" . lang('unit_res_multiselect'). "</div>";
						//echo '</td><td colspan="3"></td></tr>';
						if ( isset($$select_skip_newline) && $$select_skip_newline === TRUE ) {
							echo '</td>';
							$skipped_newline = TRUE;
						}
						elseif ($skipped_newline) {
							echo '</td></tr>';
							$skipped_newline = FALSE;
						}
						else {
							echo '</td><td colspan="3"></td></tr>';
							$skipped_newline = FALSE;
						}
					} //else
				} //foreach
			}
		?>
		</table>
		<?php
		if ( $multi_msg ) {
			echo '<div style="font-size:9px;margin:-3px;margin-bottom:10px;font-style:italic;color:#B0B0B0">(' . lang('unit_res_multiselect'). ')</div>';
		}
		if (isset($_upload_flag) && $_upload_flag !== FALSE ) {
			//Start of file upload unit_uploadedfile
			//$uploadname = osa_value($resobj,'upload1',FALSE);
			//if ( !is_null($uploadname) && $uploadname != '' ) {
			//$href= base_url() . "unit/resource/file/{$resobj->courseid}/{$resobj->unitid}/{$resobj->type}/" . $uploadname;
			//		echo lang('unit_uploadedfile') . ': <b>';
			//		echo "<a onclick=\"return downloadWindow('{$href}')\" target=\"_blank\" href=\"" . $href . '">' .
			//									$uploadname . '</a></b> (' . osa_filesizestr($resobj->uploadsize1) . ')<br /><br />';
			if ( $uploadfiles != FALSE ) {
				if ( count($uploadfiles) > 0 )
					echo lang('unit_checkboxdelete') . ':<div style="margin-bottom:10px"></div>';
				foreach ($uploadfiles as $file) {
					//$href= base_url() . "unit/resource/file/{$resobj->courseid}/{$resobj->unitid}/{$resobj->type}/" . $file->filename;
					//$href= base_url() . "unit/resource/file/{$file->id}/" . urlencode($file->filename);
					//Fix (issue: 85)
					$href= base_url() . "unit/resource/file/{$file->id}/" . osa_filename_hash($file->filename) . "/" . urlencode($file->filename);
					echo "<input type=\"checkbox\" name=\"delfile_{$file->id}\" value=\"{$file->id}\" /> ";
					echo lang('unit_uploadedfile') . ': <b>';
					echo "<a onclick=\"return downloadWindow('{$href}')\" target=\"_blank\" href=\"" . $href . '">' .
												$file->filename . '</a></b> (' . osa_filesizestr($file->size) . ')<br />';
				}
				//echo lang('unit_uploadedfile') . ': <b>' . $uploadname . '</b><br /><br />';
				echo "<br /><div style=\"text-align:left\">" . lang('unit_uploadtitle_edit') . ":";
			}
			else {
				echo "<div style=\"text-align:left\">" . lang('unit_uploadtitle_new') . ":";
			}
			echo "<div id='uploader'></div>";
			echo "</div>";
		} ?>
		<?php if (isset($_upload_flag) && $_upload_flag !== FALSE )  {
			/*
			$has_no_select = ((!isset($_select_flag1) || $_select_flag1 === FALSE) &&
								  (!isset($_select_flag2) || $_select_flag2 === FALSE) &&
								  (!isset($_select_flag3) || $_select_flag3 === FALSE) &&
								  (!isset($_select_flag4) || $_select_flag4 === FALSE) &&
								  (!isset($_select_flag5) || $_select_flag5 === FALSE));
			*/
			$has_no_select = TRUE;
			for($i=1; $i<=$max_selects; $i++){
				$tmpvar = '_select_flag' . $i;
				if ( isset($$tmpvar) ) {
					$has_no_select = FALSE;
					break;
				}
			}
		?>
		<input type="hidden" name="uploadfilename" value="" />
		<?php
		$runtimes = $this->config->item('cms_plupload_runtimes'); // if one fails it will move on to the next one.
		if ($runtimes === FALSE){
			$runtimes = "html5,html4,flash,gears,browserplus";
		}
		$upload_url =  base_url() . "unit/resource/upload/{$unitid}/{$type}"; // Page URL to where the files will be uploaded to.
		$max_file_size = $this->config->item('cms_max_uploadsize');
		$flash_swf_url = osa_include_path() . 'js/plupload/plupload.flash.swf'; // URL to where the SWF file is for the Flash runtime.
		$silverlight_xap_url =  osa_include_path() . 'js/plupload/plupload.silverlight.xap'; // URL to where the XAP file is for the Silverlight runtime.
		$unit_duplicate_text1 = lang('unit_upload_dupfile1');
		$unit_duplicate_text2 = lang('unit_upload_dupfile2');
		?>
		<script type='text/javascript'>
			var clickadd_count = 0;
			var prev_queued_length = 0;
			var current_queue_length = 0;
			var current_queue = [];

			// config
			$('#uploader').pluploadQueue({
				// General settings
				runtimes : '<?php echo $runtimes?>',
				url : '<?php echo $upload_url?>',
				max_file_size : '<?php echo $max_file_size?>mb',
				flash_swf_url : '<?php echo $flash_swf_url?>',
				silverlight_xap_url : '<?php echo $silverlight_xap_url?>'
			});

			var uploader = $('#uploader').pluploadQueue();

			// autoload: validates that no duplicate files are added
			(function add_handle() {
				uploader.bind('FilesAdded', function(up, files) {
					current_queue = up['files'];
					current_queue_length = up['files'].length;
					if (clickadd_count >= 1){
						var i = 0;
						while ( i < prev_queued_length ) {
							$.each(files, function(count, file) {
									if (up['files'][i].name == file.name){
										uploader.removeFile(files[count]);
										alert('<?php echo $unit_duplicate_text1?>' + file.name + '<?php echo $unit_duplicate_text2?>');
										return false;
									}
							});
							i++;
						}
					}
					prev_queued_length = current_queue_length;
					clickadd_count++;
				});
			})();

			// autoload: remove queue
			(function remove_queue(){
				// IE using mousedown event
				$('.plupload_delete a').live($.browser.msie? 'mousedown': 'click', function(){
					prev_queued_length--;
				});
				uploader.bind('FilesRemoved', function(up, files) {
					current_queue_length--;
				});
			})();

			// get current queue object
			function get_fileobj(){
				return current_queue;
			}

			// Fix text below upload box issue
			var set_uploadbox = {
				'height': '<?php echo $upload_height?>',
				'width': '<?php echo $upload_width?>'
			}
			$('div#uploader').css( set_uploadbox );
			$('div#uploader').css('marginLeft', -7);
		</script>
		<script type="text/javascript">
			var uploadsep = '';
			var uploaderror = false;
			var uploadcount = 0;
			var uploadedcount = 0;
			function submitUpload() {
				resource_form.save.disabled=true;
				//resource_form.save.style.color='grey';
				resource_form.close.disabled=true;
				//resource_form.close.style.color='grey';
				uploadsep = '';
				uploaderror = false;
				resource_form.uploadfilename.value = '';
				// var items = kupload.getItems();
				var items = get_fileobj();
				//tiny mce
				var text1 = document.getElementById('text1')
					if ( text1 != 'undefined' ) {
					text1.value = tinyMCE.get('text1').getContent();
				}
				//tiny mce

				if (text1.value == '') { //if (resource_form.text1.value == '') {
					<?php if ($has_no_select) {?>
						alert('<?php echo lang('unit_enter_upload_description')?>');
					<?php } else { ?>
						alert('<?php echo lang('unit_enterdescmsg')?>');
					<?php }?>
					resource_form.save.disabled=false;
					resource_form.close.disabled=false;
					resource_form.text1.focus();
					return false;
				}
				if ( items.length <= 0 && <?php //if ( !is_null($uploadname) && $uploadname != '' )
					if ($uploadfiles !== FALSE )
						echo 'true'; else echo 'false'; ?> ) {
					resource_form.save.disabled=false;
					resource_form.close.disabled=false;
					submitIframe(<?php echo $update_jscript_params?>);
					return false;
				}

				if ( items.length <= 0 ) {
					resource_form.save.disabled=false;
					resource_form.close.disabled=false;
					submitIframe(<?php echo $update_jscript_params?>);
					return false;
				}

				//var items = kupload.getItems();
				uploadedcount = 0;
				uploadcount = items.length;
				parent.ajax_is_running++;
				force_update_session();
				uploader.start();
				parent.ajax_is_running--;
				//if ( !uploaderror ) {
					//submitIframe(<?php echo $update_jscript_params?>);
					//kupload.clearAll();
				//}
				return false;
			}

			(function error_handle() {
				uploader.bind('Error', function(up, err) {
					uploaderror = true;
					$("#uploader").pluploadQueue().splice();
					resource_form.save.disabled=false;
					resource_form.close.disabled=false;
					return false;
				});
				//alert('<?php echo lang('unit_kuploaderrormsg')?>');
				//uploaderror = true;
				//resource_form.save.disabled=false;
				//resource_form.close.disabled=false;
				//return false;
			})();

			(function uploaddone_handle() {
				uploader.bind('FileUploaded', function(up, file) {
					uploadedcount++;
				//resource_form.uploadfilename.value = arg.FileName;
					var itemobj = file;
				//resource_form.uploadfilename.value = itemobj.getFileName();
					resource_form.uploadfilename.value += uploadsep + itemobj.name;
				//var uploaded_filename = itemobj.getFileName();
				//resource_form.uploadfilename.value += uploadsep + uploaded_filename.replace(/'/gi,'');
					uploadsep = '<?php echo CMS_UPLOAD_SEPARATOR;?>';
					if ( uploadedcount >= uploadcount ) {
						$("#uploader").pluploadQueue().splice();
						resource_form.save.disabled=false;
						resource_form.close.disabled=false;
						submitIframe(<?php echo $update_jscript_params?>);
					}
					return true;
				});
			})();

			//hideDiv('kupload');
			//shrinkMenuDiv('kupload');
		</script>
		<?php } //if (isset($_upload_flag) && $_upload_flag !== FALSE )?>
		<?php if (isset($_url_flag) && $_url_flag !== FALSE ) {
			//URL stuff
			//multi url
			echo '<div style="margin-bottom:5px"></div>'.lang('unit_checkboxdelete_url') . ':';
			$max_urls = $this->config->item('cms_max_multi_url');
			$url = base_url().'unit/resource/render_input/';
			if ($action == CMS_ACTION_EDIT && isset($res_urls) && $res_urls != FALSE){//Edit
				foreach ($res_urls as $value ){
					echo "<div style=\"padding-top:5px;\" /> ";
					echo "<input type=\"checkbox\" name=\"delurl_[][{$value->id}]\" /> ";
					echo "{$_url_title}: ";
					echo "http://<input type='text' name='url_[][{$value->id}]' size='40' value='$value->url'/>";
				}
			}

			for ($i=1;$i<= $max_urls;$i++) {
				echo "<div style=\"padding-top:5px;\" /> ";
				echo "<input type=\"checkbox\" name=\"delurl_[]\" /> ";
				echo "{$_url_title}: ";
				echo "http://<input type='text' name='url_[]' size='40' value='' />";
			}
		} ?>

		<?php if (isset($_date_flag) && $_date_flag !== FALSE) {
			//Date field
			echo "<b>$_date_title</b>";
			$date = '';
			if ($resobj != FALSE) {
				 $date = osa_value($resobj,'date1',FALSE);
				 if ($date != FALSE)
				 	  $date = osa_date_format($date);
			}
		?>
			<input id="fielddate" name="fielddate" size="20" readonly="readonly" value="<?php echo $date ?>" type="text">&nbsp;
			<a class="buttonalink"><img id="datebutton" title="Select Date" src="<?php echo osa_imagepath()?>calen.gif" border="0" /></a>
		<?php } ?>

		<div class="reswin_buttons">
		<?php if ($_cancel_text !== FALSE) {?>
			<input type="button" value="<?php echo $_cancel_text?>" name="close" <?php osa_btn()?>
				onClick="cancelIframe('resource');" />
			<span style="margin-left:30px">&nbsp;</span>
		<?php }?>
		<?php if ($_delete_text !== FALSE && $action == CMS_ACTION_EDIT) {?>
			<input type="button" value="<?php echo $_delete_text?>" name="delete" <?php osa_btn()?>
				onClick="return delUnitItemNorefresh('<?php echo base_url() . "unit/resource/delete/{$unitid}/{$resid}/{$type}"?>',
							'<?php echo lang('unit_delete_resource_confirm')?>', 'resource');" />
			<span style="margin-left:30px">&nbsp;</span>
		<?php }?>
		<?php if ( $_save_text !== FALSE ){?>
			<?php if (isset($_upload_flag) && $_upload_flag !== FALSE ) {?>
				<input type="button" value="<?php echo $_save_text?>" name="save" <?php osa_btn()?>
					onClick="submitUpload();" />
			<?php } else { ?>
				<input type="button" value="<?php echo $_save_text?>" name="save" <?php osa_btn()?>
					onClick="submitIframe(<?php echo $update_jscript_params?>);" />
			<?php }?>
		<?php }?>
		</div>
</td></tr></table></form>
</center>
</body>
<script type="text/javascript">
<?php if (isset($_date_flag) && $_date_flag !== FALSE) {
	echo "miniSetupCalendar('fielddate','datebutton');";
} ?>
</script>
</html>