<?php
/*

osCommRes, Services Online
http://www.oscommres.com

Copyright (c) 2005 osCommRes

Released under the GNU General Public License

Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
  require('includes/application_top.php');
  require(DIR_WS_CLASSES . 'split_page_results_event.php'); 
  require('includes/functions/events_description.php');  	
  require('includes/languages/'.$language.'/events_create.php');
  require('includes/functions/subscription_tree.php');
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();
  require('events_create_ajax.php'); 
  $command=(isset($HTTP_GET_VARS['command'])?tep_db_prepare_input($HTTP_GET_VARS['command']):'');
  $page=(isset($HTTP_GET_VARS['page'])?(int)$HTTP_GET_VARS['page']:'1');
  $cID=(isset($HTTP_GET_VARS['cID'])?(int)$HTTP_GET_VARS['cID']:0);
  $level=(isset($HTTP_GET_VARS['level'])?tep_db_prepare_input($HTTP_GET_VARS['level']):0);
  $show_order=(isset($HTTP_GET_VARS['show_order'])?tep_db_prepare_input($HTTP_GET_VARS['show_order']):'AN');
  $open_ids=isset($HTTP_GET_VARS["open_ids"])?$HTTP_GET_VARS["open_ids"] . ",":'';
  $languages = tep_get_languages();
  
  if($command!=''){
  $commands[]=$command;
	for($icnt=0;$icnt<count($commands);$icnt++){
  	switch($commands[$icnt]){
		case 'fetch_sub_list':
		case 'fetch_sub_list_open':
			echo 'command||fetch_sub_list{}category||' . $cID . '{}page||' . $page . '{}result||';
			echo output_sub_result($cID,$page,$show_order,$level,$open_ids);
			break;
		case 'fetch_all_list':
			$cID=substr($open_ids,0,strpos($open_ids,","));
			if($cID=='') $cID=str_replace(",","",$open_ids);
			if($icnt==1) $cID=0;
			echo 'command||' . $command . '{}category||' . $cID . '{}page||' . $page . '{}result||';
			echo output_sub_result($cID,$page,$show_order,$level,$open_ids);
			break;
		case 'do_sort_list':	
			do_sort($show_order,$level);
			$commands[]="fetch_all_list";
			break;
		case 'fetch_sub_events':
			echo 'command||fetch_sub_events{}category||' . $cID . '{}page||' . $page . '{}result||';
			echo output_events_result($cID,$page,$show_order);
			break;
		case 'events_search':
			echo 'events_search^';
			$events_search_criteria=isset($HTTP_GET_VARS['events_search_criteria'])?tep_db_prepare_input($HTTP_GET_VARS['events_search_criteria']):'';

			$global_categories_id=0;
			$categories_query = tep_db_query("select c.events_categories_id as categories_id from " . TABLE_EVENTS_CATEGORIES . " c, " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " cd where c.events_categories_id = cd.events_categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = 0 and cd.events_categories_name like '%" . tep_db_input($events_search_criteria) . "%' order by c.sort_order, cd.events_categories_name");
				if(tep_db_num_rows($categories_query)>0){
				$categories_array=tep_db_fetch_array($categories_query);
				$global_categories_id=$categories_array['categories_id'];
				}
		
			output_sub_result(0,1,'A',0,'',1,$events_search_criteria);
			//output_events_search_result($events_search_criteria);
			echo '<div align="right"><a href="javascript: reset_search();">'. tep_image_button('button_reset.gif', IMAGE_RESET).'</a></div>';
			break;
		case 'reset_search':
			echo 'reset_search^';
			output_sub_result(0,1,'A',0,'',1);
			break;
	  }
	} //for loop
	exit;  
   }  
	
	tep_get_event_cat_ajax_list(0,0,"open_ids",$jmp_results,$jmp_open_ids);
	tep_get_last_access_file();
	$pro_id=isset($HTTP_GET_VARS['eID'])?$HTTP_GET_VARS['eID']:0;
	
	$languages = tep_get_languages();
    $location_query=tep_db_query("SELECT * from " . TABLE_EVENTS_LOCATIONS . ' order by location_name');
    $location_array=array();
    while($location_result=tep_db_fetch_array($location_query)){
       $location_array[]=array('id'=>$location_result['location_id'],'text'=>$location_result['location_name'],'seats'=>$location_result["location_seats"]);
    }
	
    $service_location_query=tep_db_query("SELECT sl.*,s.service_id from " . TABLE_SERVICES." s, ". TABLE_SERVICES_LOCATIONS . ' sl where s.service_location=sl.service_location_id order by service_location_name');
    $service_location_array=array();
    while($service_location_result=tep_db_fetch_array($service_location_query)){
       $service_location_array[]=array('id'=>$service_location_result['service_id'],'seats'=>$service_location_result["service_location_seats"]);
    }
	#get tax descriptions to display in tax selection
	$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
	$tax_class_query = tep_db_query("SELECT tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
	while ($tax_class = tep_db_fetch_array($tax_class_query)) {
	  $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
								 'text' => $tax_class['tax_class_title']);
	}   

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language="javascript" src="includes/menu.js"></script>
<script language="JavaScript" src="includes/date-picker.js"></script>
<script type="text/javascript" src="htmlarea/htmlarea.js"></script>
<script type="text/javascript" src="htmlarea/editor.js"></script>
<script language="javascript" src="includes/aim.js"></script>
<script>
var locations=Array();
var tax_rates = new Array();
var lang=new Array();
var sel_object="";
var service_locations = new Array();
<?php
    for ($i=0, $n=sizeof($location_array); $i<$n; $i++) {
		if ($location_array[$i]['id'] > 0) {
	        echo 'locations[' . $location_array[$i]['id'] . '] = ' . $location_array[$i]['seats'] . ';' . "\n";
		}
    }
    for ($i=0, $n=sizeof($service_location_array); $i<$n; $i++) {
		if ($service_location_array[$i]['id'] > 0) {
	        echo 'service_locations[' . $service_location_array[$i]['id'] . '] = ' . $service_location_array[$i]['seats'] . ';' . "\n";
		}
    }
?>
<?php
    for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
      if ($tax_class_array[$i]['id'] > 0) {
        echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
      }
    }
    $j=0;
	for ($l=0; $l<sizeof($languages); $l++) { ?>
	lang[<?php echo $j;?>]="<?php echo $languages[$l]['id'];?>";	
<?php $j++; 	
	}	
?>	
</script>

<script>
var cat_expand;
var count = 0;
var id = new Array();
var category_list = new Array();
var default_category = '';
var panel_expand;
var panel_expand_id;
var ids = new Array();
var page='<?php echo $page;?>';
var order='<?php echo $order;?>';
var prev_value;
 
function getdetails(page,orders){
	order=orders;
	if(document.getElementById("load_details")) document.getElementById("load_details").style.display="";
	command="<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'command=fetch_details');?>&page="+ page + "&panel="+panel_expand+ '&cID='+panel_expand_id + '&order=' +order;
	
	do_get_command(command);
}
	function get_details(type,cID,eID,page,params){
		//if(type=='CAT')
		//	command="<?php //echo tep_href_link(FILENAME_CATEGORIES,'command=fetch_details');?>&page="+ page + "&panel="+panel_expand+ '&cID='+panel_expand_id+'&eID='+eID + params;
		//else
			if(document.getElementById("load_details")) document.getElementById("load_details").style.display="";
		 if(type=='PM')
			command="<?php echo tep_href_link(FILENAME_CATEGORIES,'command=fetch_details');?>&page="+ page + "&panel="+panel_expand+ '&cID='+panel_expand_id+'&eID='+eID ;
		do_get_command(command);
	}
	function display_popup(){
		if(document.getElementById("display_menu"))document.getElementById("display_menu").style.display = "";
	}
	function display_null(){
		if(document.getElementById("display_menu"))document.getElementById("display_menu").style.display = "none";
	}

</script>
</head>
<body marginwidth="0"  marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php
$file_name=FILENAME_EVENTS_MAINPAGE;
require(DIR_WS_INCLUDES . 'events_mainpage.js.php');
require(DIR_WS_INCLUDES . 'mainpage.js.php');
require(DIR_WS_INCLUDES . 'header.php'); 
?>
<div id="test" style="width:500px;overflow:auto"></div>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="4">
  <tr>
	<!-- body_text //-->
	<td width="100%" valign="top">
	 <table border="0" width="100%" cellspacing="2" cellpadding="2">
	  <tr>
	 <!-- body_text //-->
		<td width="100%" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="2">
				<tr>
					<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
					<tr>
					<td><table width="100%" cellpadding="0" cellspacing="0" border="0">
					<!--<tr class="dataTableHeadingRow" style="height:25px">
					<td width="30"><?php echo '<a onMouseOver="javascript:change_class(this,2);" onMouseOut="javascript:change_class(this,3);" alt="New Event" title="New Event" id="img_new" href="javascript:expand_category(0,2);">'.tep_image(DIR_WS_IMAGES.'template/img_new.gif','','22','22').'</a>'; ?></td>
					<td valign="middle" width="600" class="dataTableHeadingContent" align="right"><?php echo tep_draw_form('search_form',FILENAME_EVENTS_MAINPAGE,'','post',' onSubmit="javascript: return search_event();" ').'&nbsp;'.TEXT_SEARCH.tep_draw_input_field('events_search').'&nbsp;';?></td>
					 <td  valign="middle"  width="80"><input  type="image" src="<?php echo DIR_WS_IMAGES.'template/img_search.gif';?>" alt="Search" title="Search"></form></td>
					 <td  valign="middle"  width="60" align="right" class="dataTableHeadingContent"><?php echo TEXT_JUMP_TO; ?></td>
					 <td valign="middle"  width="60" class="dataTableHeadingContent"><?php echo '&nbsp;&nbsp;'.tep_draw_pull_down_menu("cbo_jumpto",$jmp_results,'',' style="width:100px;" onChange="javascript:do_jump_list(this.value)"'); ?></td>
					</tr> -->
					
					 <tr class="dataTableHeadingRow">
                 	<td colspan="4">
                 		<table border="0" cellspacing="0" cellpadding="0" width=100%>	
                 			<tr>
                 				<td valign="bottom" class="pageHeading" align="left" width="500" ><?php echo '<a onMouseOver="javascript:change_class(this,2);" onMouseOut="javascript:change_class(this,3);" alt="New Event" title="New Event" id="img_new" href="javascript:expand_category(0,2);">'.tep_image(DIR_WS_IMAGES.'template/img_new.gif','','','22','22').'</a>'; ?></td>
			                 	<td class="dataTableHeadingContent" align="right" valign="bottom" width="300"><?php echo tep_draw_form('search_form',FILENAME_EVENTS_MAINPAGE,'','post',' onSubmit="javascript: return search_event();" ').'&nbsp;'.TEXT_SEARCH.tep_draw_input_field('events_search').'&nbsp;';?>
								<input  type="image" align="absbottom" src="<?php echo DIR_WS_IMAGES.'template/img_search.gif';?>" alt="Search" title="Search"></form></td>	
								<td valign="bottom" class="dataTableHeadingContent" align="right" width="300"><?php echo TEXT_JUMP_TO.'&nbsp;&nbsp;'.tep_draw_pull_down_menu("cbo_jumpto",$jmp_results,'',' style="width:100px;" onChange="javascript:do_jump_list(this.value)"'); ?></td>
								
                 			</tr>
                 		</table>
                 	</td>                 	
               </tr>
					<tr class="dataTableHeadingRow" style="height:25px">
						<td width="8%" align="left">
						<?php 
												echo tep_image(DIR_WS_IMAGES . 'template/icon_ascending.gif',IMAGE_ASCENDING,'','',' id="pop_common_sort_display_con" onMouseOver="javscript:javascript:show_cpopup(\'sort_display\',0,20);"');
												echo '<input type="hidden" name="show_sort_order" id="show_sort_order" value="AN">';
												echo "<div id='pop_common_sort_display' style='position:absolute;display:none;width:110px;height:70px;z-index:999;border:1px solid;border-color:#6883CA;background-color:#FFFFFF;padding:3px;' >";
												echo tep_draw_separator('pixel_trans.gif','10','5');
												echo '<br><table class="main" cellpadding="0" cellspacing="0" border="0">';
												$popup=array(array("img"=>'icon_ascending.gif',"txt"=>TEXT_ASCENDING,'id'=>'AN'),array("img"=>'icon_descending.gif',"txt"=>TEXT_DESCENDING,'id'=>'DN'),array('img'=>'icon_active.gif',"txt"=>TEXT_SHOW_AVAILABLE,"id"=>'AV'));
											
												for ($icnt=0,$n=count($popup);$icnt<$n;$icnt++){
													echo '<tr height="20" class="tableMenuItem" onMouseOver="javascript:rowOverEffect(this)" onMouseOut="javascript:rowOutEffect(this)"><td valigm="middle" width="18">' . tep_image(DIR_WS_IMAGES . "template/" .$popup[$icnt]["img"],$popup[$icnt]["txt"],'','','align=absmiddle') . '</td><td>';
													echo '<a style="color:#000000;text-decoration:none" href="javascript:do_page_fetch(\'fetch_all_list\',\'' . $popup[$icnt]["id"] . '\');">' . $popup[$icnt]["txt"] . '</a></td></tr>';
													echo '<tr height="3"><td></td></tr>';
												}
												echo "</td></tr></table></div>";
											?>
					</td>
					<td colspan="3" width="92%" align="left" class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_EVENTS;?></td>
					</tr>
					</table></td>
					</tr>						 
					</table></td>
					</tr>						
						<tr>
						   <td valign="top">
							<table border="0" width="100%" cellspacing="0" cellpadding="2">
								<tr><td class="dataTableHeadingContent" colspan="2" id="res_display" style="display:none"></td></tr>
								<tr>
									<td id="get_details" colspan="2">
										<?php
											set_time_limit(5);
											echo tep_draw_form('new_product', FILENAME_EVENTS_MAINPAGE, 'action=file_upload', 'post', ' onSubmit="return AIM.submit(document.new_product, {\'onStart\' : startCallback_events, \'onComplete\' : completeCallback_events});" enctype="multipart/form-data"'); 
							 		  	?>
										<input type='hidden' name='product_id' id='product_id'>
										<input type="hidden" name="sort_order" id="sort_order">
										<input type="hidden" name="action_type" id="action_type">
										<input type="hidden" name="image_type" id="image_type">
										<span id="new_category"></span>
										<span id="search_result_details"><?php 
/*										if(isset($HTTP_GET_VARS['actions']) && $HTTP_GET_VARS['actions']=='edit_products')
											output_sub_result(0,1,'A',0,'',0); 
										else
*/											output_sub_result(0,1,'A',0,'',1); 
										
										?></span>
										</form>
									</td>
								</tr>	
							</table>
							</td>
						</tr>						
						<!-- New Category Work Starts -->
						<tr>
						<td>
						<?php //load_new_category_event(); ?>
						</td>
						</tr>
						<!-- New Category Work Ends -->
						
					<!--	<tr>
							<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="0">
								<tr>
									<td>
									<table border="0" width="100%" cellpadding="5" cellspacing="0">
										<tr>
											<td>
											<table cellpadding="0" cellspacing="0" border="0" width="100%">
												<tr class="event_title">
													<td colspan="2"><?php echo '<b>' . TABLE_EVENT_MANAGEMENT . '</b>'; ?></td>
												</tr>	
												<tr>
													<td>
													<table border="0" cellpadding="0" cellspacing="0">
														<tr>
															<td><?php echo tep_image(DIR_WS_IMAGES . 'event_mgt.gif', eventManagement);?></td>
														</tr>
													</table>
													</td>
													<td>
														<table width="100%" class="info_content">
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_EVENTS_CATEGORIES,'cPath='.$categories['categories_id'].'&action=new_event') . '">' . IMAGE_NEW_event . '</a>'; ?></td></tr>
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_EVENTS_CATEGORIES,'cPath='.$categories['categories_id'].'&action=new_category') . '">' . IMAGE_NEW_CATEGORY . '</a>'; ?></td></tr>
														</table>
													</td>
												</tr>	
											</table>
											</td>
											<td>
											<table cellpadding="0" cellspacing="0" width="100%" border="0">
												<tr class="event_title">
													<td colspan="2"><?php echo '<b>' .TABLE_event_MARKETING . '</b>'; ?></td>
												</tr>	
												<tr>
													<td>
														<table border="0"><tr><td><?php echo tep_image(DIR_WS_IMAGES . 'pdt_marketing.gif', eventMarketing);?></td></tr></table>
													</td>
													<td>
														<table border="0" class="info_content" >
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_SALEMAKER,'top=1') . '">' . IMAGE_DISCOUNTS . '</a>'; ?></td></tr>
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_eventS_SALES,'top=1') . '">' . PROMOTE_EVENTS_SALE . '</a>'; ?></td></tr>
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES,'cPath='.$categories['categories_id'].'&action=new_event') . '">' . event_STATUS_CHANGE . '</a>'; ?></td></tr>
															<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_REVIEWS,'top=1') . '">' . EVENTS_REMINDERS . '</a>'; ?></td></tr>
														</table>
													</td>
												</tr>
											</table>	
											</td>
										</tr>
										<tr>
											<td>
												<table cellpadding="0" cellspacing="0" width="100%" border="0">
													<tr class="event_title">
														<td colspan="2"><?php echo '<b>' . TABLE_event_REPORTS . '</b>'; ?></td>
													</tr>	
													<tr>
														<td>
															<table border="0">
																<tr><td><?php echo tep_image(DIR_WS_IMAGES . 'reports.gif', Reports);?></td></tr>
															</table>
														</td>		
														<td>
															<table  class="info_content">
																<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_STATS_eventS_VIEWED,'top=1') . '">' . BEST_VIEWED_eventS . '</a>'; ?></td></tr>
																<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_INVENTORY,'top=1') . '">' . SEE_INVENTORY . '</a>'; ?></td></tr>
																<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_CART_DROP_REPORT,'top=1') . '">' . DROPPED_CART . '</a>'; ?></td></tr>
																<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_REPORTS_FULFILLER,'top=1') . '">' . FULLFILLER . '</a>'; ?></td></tr>
															</table>
														</td>
													</tr>
												</table>
											</td>
											<td height="5"></td>
										</tr>
									</table>
									</td>
								</tr>-->
							</table>		
							</td>
						</tr>
					
					
			<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '2', '10'); ?></td></tr>	 
		 
			 <tr>
		 		<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td>
								<table border="0" width="100%" cellpadding="0" cellspacing="0">
									<tr>
									 <td>
										<table border="0" width="100%" cellpadding="0" cellspacing="0">
											<tr class="product_title">
												<td colspan="2"><?php echo '<b>' . HEADING_TITLE . '</b>'; ?></td>
											 </tr>
											 <tr height="7"></tr>	
											<tr>
											  	<td valign="top" width="7%">
													<table border="0" cellpadding="0" cellspacing="0" width="59px" height="73px">
													<tr> 
														<td valign="top"><img src="<?php echo DIR_WS_IMAGES . 'categories/events.png'; ?>" height="63px" width="55px" >
															<?php //echo tep_image(DIR_WS_IMAGES . 'categories/events.png', Events);?>
														</td>
													</tr>
													</table>
												</td> 
														
												 <td width="93%" valign="top">
												 <table  border="0" width="100%" class="info_content">
												 <tr>
													<td class="info_content"><?php echo '<a id="link_categories" href="javascript:expand_category(0,2);">' . IMAGE_NEW_CATEGORY . '</a>'; ?></td>
												</tr>
												<tr>	
													<td class="info_content"><?php echo '<a id="link_product" href="javascript:expand_category(0,6);">' . IMAGE_NEW_EVENT . '</a>'; ?></td>
												 </tr>	
												 </table>
											 </td>
										  </tr>	
										 </table>
										 </td>
									   </tr>
					
									<tr>
									 <td>
										<table border="0" width="100%" cellpadding="0" cellspacing="0">
											<tr class="product_title">
												<td colspan="2"><?php echo '<b>' . TEXT_INFO_INSTRUCTOR . '</b>'; ?></td>
											 </tr>
											 <tr height="7"></tr>	
											<tr>
											  	<td valign="top" width="7%">
													<table border="0" cellpadding="0" cellspacing="0" width="59px" height="73px">
													<tr> 
														<td valign="top"><img src="<?php echo DIR_WS_IMAGES . 'categories/instructor.png'; ?>" height="63px" width="55px" >
															<?php //echo tep_image(DIR_WS_IMAGES . 'categories/instructor.png', Instructor);?>
														</td>
													</tr>
													</table>
												</td> 
														
												 <td width="93%" valign="top">
												 <table border="0" width="100%" class="info_content" cellpadding="0" cellspacing="0">
												 <tr>
													<td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_EVENTS_ADMIN_MESSAGES,'top=1') . '">' . TEXT_INFO_MESSAGES . '</a>'; ?></td>
												</tr>
											   <tr>
												 <td class="info_content"><?php echo '<a href="'. tep_href_link(FILENAME_STATS_EVENTS_VIEWED,'top=1').'">'. TEXT_INFO_VIEW_EVENTS . '</a>';?></td>
											   </tr>
											   <tr>	
												  <td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_INSTRUCTORS_OPTIONS,'top=1') . '">' . TEXT_INFO_ADVANCED . '</a>'; ?></td>
											  </tr>	
											   <tr>
												 <td class="info_content"><?php echo '<a href="'. tep_href_link(FILENAME_EVENTS_ADMIN_PAYMENTS,'top=1').'">'. TEXT_INFO_PAYMENTS . '</a>';?></td>
											   </tr>	 
											    </table>
											 </td>
										  </tr>	
										 </table>
										 </td>
										</tr>	
										
									<tr>
									 <td>
										<table border="0" width="100%" cellpadding="0" cellspacing="0">
											<tr class="product_title">
												<td colspan="2"><?php echo '<b>' . TEXT_INFO_WAIT_LIST . '</b>'; ?></td>
											 </tr>
											 <tr height="7"></tr>	
											<tr>
											  	<td valign="top" width="7%">
													<table border="0" cellpadding="0" cellspacing="0" width="59px" height="73px">
													<tr>  
														<td valign="top"><img src="<?php echo DIR_WS_IMAGES . 'categories/wait_list.png'; ?>" height="63px" width="55px" >
															<?php //echo tep_image(DIR_WS_IMAGES . 'categories/wait_list.png',WaitList);?>
														</td>
													</tr>
													</table>
												</td> 
														
												 <td width="93%" valign="top">
												 <table border="0" width="100%" class="info_content">
												 <tr>
													<td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_WAITLISTS,'top=1') . '">' . TEXT_INFO_WAITLIST . '</a>'; ?></td>
												</tr>
											   <tr>
												 <td class="info_content"><?php echo '<a href="'. tep_href_link(FILENAME_PENDING_WAITLIST_PAYMENTS,'top=1').'">'. TEXT_INFO_WAITLIST_PAYMENTS . '</a>';?></td>
											   </tr>
											  </table>
											 </td>
										  </tr>	
										</table>
									  </td>
									</tr>
								
								</table>
							 </td>
						  </tr>
					  </table>
				 </td>
			 </tr>  	  		
		</table>
<div id="ajax_load_img" style="display:none">
	<?php echo tep_image(DIR_WS_IMAGES . '24-1.gif') ;?>
</div>
<!-- body_text_eof //-->
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); 

	function tep_get_event_cat_ajax_list($parent_id,$level=0,$value_assign_type='default',&$results,&$open_ids){
		global $languages_id;
		$categories_sql = "select c.events_categories_id as categories_id, cd.events_categories_name as categories_name, c.parent_id from " . TABLE_EVENTS_CATEGORIES . " c, " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " cd where c.events_categories_id = cd.events_categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "'  order by c.sort_order, cd.events_categories_name";
		$categories_query = tep_db_query($categories_sql);
		if (tep_db_num_rows($categories_query)<=0) return;
		while ($category_result = tep_db_fetch_array($categories_query)) {
			$open_ids.="," . $category_result["categories_id"];
			switch($value_assign_type){
				case 'open_ids':
					$id=substr($open_ids,1);
					break;
				default:
					$id=$category_result["categories_id"];
			}
			$name=$category_result["categories_name"];
			$style="";
			if ($level>0) $style='padding-left:' . ($level*10) . "px";
			
			$results[]=array('id'=>$id,'text'=>$name,'style'=>$style);
			tep_get_event_cat_ajax_list($category_result["categories_id"],$level+1,$value_assign_type,$results,$open_ids);
			$open_ids=substr($open_ids,0,strrpos($open_ids,","));
		}
	}
	function do_sort($show_order,$level){
		global $languages_id,$selected_name,$login_id,$login_groups_type,$HTTP_GET_VARS,$page,$command;
		
		$sort_by='ASC';
		if($show_order=='DN') 	$sort_by='DESC';
		$categories_sort_sql = "select c.events_categories_id as categories_id,c.sort_order, cd.events_categories_name as categories_name, c.parent_id from " . TABLE_EVENTS_CATEGORIES . " c, " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " cd where c.events_categories_id = cd.events_categories_id and cd.language_id = '" . (int)$languages_id . "' ".$search_criteria." order by c.parent_id,cd.events_categories_name $sort_by ";		
		//echo $categories_sort_sql;
		$categories_sort_query = tep_db_query($categories_sort_sql);
		$sort_orders=array();
		
		while($categories_sort=tep_db_fetch_array($categories_sort_query)){
			if (!$sort_orders[$categories_sort["parent_id"]]) $sort_orders[$categories_sort["parent_id"]]=1;
				tep_db_query("UPDATE events_categories set sort_order= ". $sort_orders[$categories_sort["parent_id"]] ." where events_categories_id= ". $categories_sort['categories_id']);
				$sort_orders[$categories_sort["parent_id"]]++;
		}
		$events_sql = "select ed.events_name as events_name,ed.events_id as events_id,e.events_status  from " . TABLE_EVENTS_DESCRIPTION . " ed, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " ecd, " . TABLE_EVENTS . " e where e.events_id=ecd.events_id  and ed.events_id=ecd.events_id and ed.language_id = '" . (int)$languages_id . "'" .$prd_where . " ORDER BY ed.events_name $sort_by" ;
		$events_query=tep_db_query($events_sql);
		if(tep_db_num_rows($events_query)>0){
			$i=1;
			while($result=tep_db_fetch_array($events_query)){
				tep_db_query("update ".TABLE_EVENTS." set events_sort_order='".$i."' where events_id='". (int)$result['events_id']."'");	
				$i++;													 																																
			}
		}
		
	}
	
	function output_sub_result($parent_id,$page,$show_order,$level,$open_ids,$start_up=0,$events_search='') {
		global $languages_id,$selected_name,$login_id,$login_groups_type,$HTTP_GET_VARS,$page;
		output_category_details($parent_id);
		echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr style="height:10"><td></td></tr></table>';
		$events_search_criteria="";
			if($events_search!='')
				$events_search_criteria=" and cd.events_categories_name like '%" . tep_db_input($events_search) . "%' ";
		
		$open_ids="," . $open_ids;
		// first fetch the events in this category
		if ($parent_id>0) { 
			output_events_result($parent_id,$page,$show_order);
		}	
		$categories_sql = "select c.events_categories_id as categories_id,c.sort_order, cd.events_categories_name as categories_name, c.parent_id from " . TABLE_EVENTS_CATEGORIES . " c, " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " cd where c.events_categories_id = cd.events_categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' ".$events_search_criteria."  order by c.sort_order,cd.events_categories_name ";
		$categories_query = tep_db_query($categories_sql);		
		if (tep_db_num_rows($categories_query)<=0) return;
		else $category_ids = tep_db_fetch_array(tep_db_query($categories_sql));
		echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" id="parent_'.$category_ids['categories_id'].'">';
		// fetch the sub category
		// iterate with nested category
		$icnt=0; $toggle_flag=0;
		while ($category_result = tep_db_fetch_array($categories_query)) {
			$show=false;
			if (($open_ids!='' && strpos($open_ids,"," . $category_result["categories_id"] . ",")!==false) || $start_up) {
				if ($start_up){
					echo '<script language="javascript">prev_category='. $category_result["categories_id"] . ';open_ids[0]=' . $category_result["categories_id"] . ';</script>';
				}
				$start_up=false;
				$show=true;
			}
			tep_category_title_top($category_result['categories_name'],$category_result['categories_id'],$show,$level);
				if ($show) output_sub_result($category_result['categories_id'],$page,$show_order,$level+1,$open_ids);			
			tep_category_title_bottom();
		}
		echo '</table>';
	}
	
	function output_events_result($categories_id,$page,$show_order){ 
		global $languages_id,$command;
			$result="";
			
			if (substr($show_order,1,1)=="V") $prd_where=" AND e.events_status=1 ";
			
			$events_sql = "select ed.events_name as events_name,ed.events_id as events_id,e.events_status  from " . TABLE_EVENTS_DESCRIPTION . " ed, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " ecd, " . TABLE_EVENTS . " e where e.events_id=ecd.events_id and ecd.events_categories_id='" . $categories_id . "' and ed.events_id=ecd.events_id and ed.language_id = '" . (int)$languages_id . "'" .$prd_where . " ORDER BY e.events_sort_order ASC "; 
		//	echo $events_sql;
			$query_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $events_sql, $query_split_numrows);
			$events_query=tep_db_query($events_sql);
			
			if ($command!='fetch_sub_events'){
				echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
				if($query_split_numrows>MAX_DISPLAY_SEARCH_RESULTS){
					echo '<tr>
							<td align="right">
								<table border="0" cellspacing="0" cellpadding="2">
									<tr> 
										<td class="smallText" align="left">'.													
											$query_split->display_script_links($query_split_numrows, MAX_DISPLAY_SEARCH_RESULTS, REPORT_MAX_LINKS_PAGE, $page,'cID=' . $categories_id,'do_page_fetch(\'fetch_sub_events\'',$categories_id).
										'</td>
									</tr>
								</table>
							</td>
						</tr>';
				} 
				echo '</table><div id="panel_' . $categories_id . '_contentp">';
			}
			echo '<table cellpadding="0" cellspacing="0" border="0" width="100%" id="id_product_list_'.$categories_id.'">';
			
			if (tep_db_num_rows($events_query)>0){
				$i=0;
				$events_ids="";
				while ($events = tep_db_fetch_array($events_query)){
					$check_sql = "select count(*) as count from " . TABLE_EVENTS_SESSIONS . " where events_id=" . $events['events_id'];
					$check_query = tep_db_query($check_sql);
					$check_result = tep_db_fetch_array($check_query);
					$check_recursive_sql = "select count(*) as count from " . TABLE_RECURSIVE_SESSIONS . " where events_id=" . $events['events_id'];
					$check_recursive_query = tep_db_query($check_recursive_sql);
					$check_recursive_result = tep_db_fetch_array($check_recursive_query);
					echo tep_draw_hidden_field('has_sessions_' . $events['events_id'],$check_result['count']+$check_recursive_result['count']);
					$class="dataTableRowEven";
					if($i%2==0) $class="dataTableRowOdd";					
					echo '<tr class="'.$class.'" class="dataTableRow" height="18" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript: if(document.getElementById(\'head_'.$events['events_id'].'_'.$categories_id.'\').style.display==\'none\') expand_category('.$events['events_id'].',1,'.$categories_id.');"><td class="main"><div id="data_'.$events['events_id'].'_'.$categories_id.'">';
					echo  ($events['events_status']==1)?tep_image(DIR_WS_IMAGES  . 'template/icon_active.gif', '') . tep_draw_separator('pixel_trans.gif', '5', '10'):tep_image(DIR_WS_IMAGES  . 'template/icon_inactive.gif', '') . tep_draw_separator('pixel_trans.gif', '5', '10');
					echo  $events['events_name'] . '</div><div class="openContent" style="display:none" id="head_'.$events['events_id'].'_'.$categories_id.'"></div></td></tr>';															
					$i++;
					$events_ids.=$events['events_id'].",";				
				} 	
			}
			echo '</table>';
		  
	}
	
	function output_events_search_result($search_item){
	global $languages_id,$global_categories_id;  
		if($search_item!='')
			$search_criteria=" and ed.events_name like '%" . tep_db_input($search_item) . "%' ";
	$events_query=tep_db_query('select ed.events_id,ed.events_name,e.events_status from '.TABLE_EVENTS.' e, '.TABLE_EVENTS_DESCRIPTION." ed where e.events_id=ed.events_id and ed.language_id='$languages_id'". $search_criteria ." order by events_name");


		echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';			
			if (tep_db_num_rows($events_query)>0){
				$i=0;												
				while ($events = tep_db_fetch_array($events_query)){
				$events_id=$events['events_id'];
				$categories_query=tep_db_query('select events_categories_id as categories_id from '.TABLE_EVENTS_TO_EVENTS_CATEGORIES." where events_id='$events_id'");
				
				while($categories_array=tep_db_fetch_array($categories_query)){
				$categories_id=$categories_array['categories_id'];

				if($categories_id!=$global_categories_id){					
					$class="dataTableRowEven";
					if($i%2==0) $class="dataTableRowOdd";					
					echo '<tr class="'.$class.'" height="18" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$events['events_id'].'_'.$categories_id.'\').style.display==\'none\') expand_category('.$events['events_id'].',1,'.$categories_id.');"><td class="main"><div id="data_'.$events['events_id'].'_'.$categories_id.'">';
					echo  ($events['events_status']==1)?tep_image(DIR_WS_IMAGES  . 'template/icon_active.gif', '') . tep_draw_separator('pixel_trans.gif', '5', '10'):tep_image(DIR_WS_IMAGES  . 'template/icon_inactive.gif', '') . tep_draw_separator('pixel_trans.gif', '5', '10');
					echo  $events['events_name'] . '</div><div class="openContent" id="head_'.$events['events_id'].'_'.$categories_id.'" style="display:none"></div></td></tr>';					
					$i++;	
				}
				}		// while categories loop
				} 	
			}
		 echo '</table>';
	}
	
	
	
function output_category_details($cID){
	global $languages_id,$search_criteria;
	$product_categories=tep_db_query("select c.parent_id,date_format(c.date_added,'%Y-%m-%d') as date_added,date_format(c.last_modified,'%Y-%m-%d') as last_modified,cd.events_categories_id,cd.events_categories_name,c.sort_order,c.events_categories_image from ".TABLE_EVENTS_CATEGORIES ." c,".TABLE_EVENTS_CATEGORIES_DESCRIPTION." cd where c.events_categories_id=cd.events_categories_id and cd.language_id='".(int)$languages_id."' and c.events_categories_id='".(int)$cID."'");
	//$product_categories=tep_db_query("select c.parent_id,date_format(c.date_added,'%Y-%m-%d') as date_added,date_format(c.last_modified,'%Y-%m-%d') as last_modified,cd.services_categories_id,cd.services_categories_name,c.sort_order,c.services_categories_image from " . TABLE_SERVICES_CATEGORIES . " c," . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " cd where c.services_categories_id=cd.services_categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' ". $search_criteria." order by c.sort_order, cd.services_categories_name");
	if(tep_db_num_rows($product_categories)>0){
		$category_check_sql = "select count(*) as count from " . TABLE_EVENTS_CATEGORIES . " where parent_id=" . $cID;
		$category_check_query = tep_db_query($category_check_sql);
		$category_check_result = tep_db_fetch_array($category_check_query);
		$check_sql = "select count(*) as count from " . TABLE_EVENTS . " e," . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " eec," . TABLE_EVENTS_CATEGORIES . " ec where e.events_id=eec.events_id and ec.events_categories_id=eec.events_categories_id and ec.events_categories_id=" . $cID;
		$check_query = tep_db_query($check_sql);
		$check_result = tep_db_fetch_array($check_query);
		echo tep_draw_hidden_field('has_events_' . $cID,$check_result['count']+$category_check_result['count']);
		$product=tep_db_fetch_array($product_categories);?>
		<table width='100%' border='0' cellspacing='0' cellpadding='0' class="openContent_top" id="category_details_<?php echo $product['events_categories_id'];?>">
			<tr heigth='40' class='openContent_top'>
				  <td width='10'></td>
				  <td align='left' valign='middle' width='350' class='main'><?php echo $product['events_categories_name'];?></td>
				  <td width='470' align='left' style="cursor:pointer;" class='main' valign='top'>
				  	<table border='0' cellspacing='0' cellpadding='0' style='height:30px;display:inline;position:relative;'>
				  	 <tr class='img_move' id='img_ids'>
						 <td class='cell_bg_popm_left' width='10'>&nbsp;</td>						 
						 <td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category(<?php echo $product['events_categories_id'];?>,3);'><img alt='Edit Category' title='Edit Category' src='images/template/img_edit.gif'></td>
						 <td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category(<?php echo $product['events_categories_id'];?>,4);'><img alt='Delete Category' title='Delete Category' src='images/template/img_trash.gif'></td>						 
						 <td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category(<?php echo $product['events_categories_id'];?>,5);'><img alt='Move Category' title='Move Category' src='images/template/img_move.gif'></td>
						 <td class='cell_bg_popm_right' width='10'>&nbsp;</td>
				  	 </tr>
				  	</table>
				  </td>
				  <td width='240' align='right' id='img_save_<?php echo $product['events_categories_id'];?>' style='display:none'><input id="save_button_<?php echo $product['events_categories_id'];?>" type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:expand_category(<?php echo $product['events_categories_id'];?>,1)'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>
				  </tr>
			  <tr style='height:10'><td id='loading' style='display:none' colspan='5'><img src='images/24-1.gif' alt='Loading...' title='Loading...'></td></tr>
			  <tr>
				  	<td colspan="8" class="main">
				  	<input type="hidden" name="cPath" id="cPath" value="<?php echo tep_output_string($product['events_categories_id']);?>">
				  		<span id="span_details_<?php echo $product['events_categories_id'];?>">
							<?php echo get_category_details($product);?>							
						</span>
					</td>
			  </tr>				   
		</table>
<?php } 
	}
	function get_category_details($product){				
?>
	<table width='100%' border='0' cellspacing='0' cellpadding='0' class='openContent'>
	  <tr>
		<td colspan='2' valign='top'>
			<table width='50%' border='0' cellspacing='5' cellpadding='3'>
				<tr>
					<td width="30"><?php echo (($product['events_categories_image']!="")?tep_image(HTTP_SERVER.DIR_WS_CATALOG.'images/'.$product['events_categories_image'],$product['events_categories_image'],'100','100'):'');?></td>
					<td width='500' valign='top'>
						<table width='80%' border='0' cellspacing='5' cellpadding='0' class='main'>
							<tr>
								<td align='left' width='100' valign='top' nowrap="true"><?php echo TEXT_DATE_ADDED;?></td>
								<td align='left'  valign='top' nowrap="true"><?php echo format_date($product['date_added']);?></td>
							</tr>
							<tr>
								<td align='left' width='100' nowrap="true"><?php echo TEXT_LAST_MODIFIED;?></td>
								<td align='left' nowrap="true"><?php echo format_date($product['last_modified']);?></td>
							</tr>	
						</table>
				</tr>
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif','1','5');?></td></tr>
			</table>
		</td>
	</tr>
  </table>
<?php } ?>
<?php function load_new_category(){  ?>
		<br>
		<table width="100%" id="new_category" cellpadding="0" class="openContent" cellspacing="0" border="0">
		<tr>
		<td><table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="200"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.IMAGE_NEW_CATEGORY; ?></td>
			<td align="right"><?php echo '<a href="javascript: new_category_submit();">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif').'</a>&nbsp;&nbsp;<a href="javascript: close_new_category();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif').'</a>'; ?></td>
		</tr>
		</table></td>
		</tr>
		<tr>
    	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
   		</tr>
		<tr><?php //echo tep_draw_form('new_events_category', FILENAME_EVENTS_CATEGORIES, 'ecPath=' . $ecPath . '&ecID=' . $HTTP_GET_VARS['ecID'] . '&action=new_events_category_preview', 'post', 'enctype="multipart/form-data" onSubmit="javascript:return validate_image()"'); ?>
		<td>
		<table border="0" cellspacing="0" cellpadding="2">
		<?php
		$languages = tep_get_languages();
		for ($i=0; $i<sizeof($languages); $i++) { 
		?>
			<tr>
				<td class="main"><?php if ($i == 0) echo TEXT_EDIT_EVENTS_CATEGORIES_NAME; ?></td>
				<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('events_categories_name[' . $languages[$i]['id'] . ']', (tep_not_null($events_categories_name[$languages[$i]['id']]) ? stripslashes($events_categories_name[$languages[$i]['id']]) : tep_get_events_category_name($ecInfo->events_categories_id, $languages[$i]['id']))); ?></td>
			</tr>
		<?php
		}
		?>
		<tr>
			<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
		<?php
		for ($i=0; $i<sizeof($languages); $i++) {
		?>
		<tr>
			<td class="main"><?php if ($i == 0) echo TEXT_EDIT_EVENTS_CATEGORIES_HEADING_TITLE; ?></td>
			<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('events_categories_heading_title[' . $languages[$i]['id'] . ']', (tep_not_null($events_categories_heading_title[$languages[$i]['id']]) ? stripslashes($events_categories_heading_title[$languages[$i]['id']]) : tep_get_events_category_heading_title($ecInfo->events_categories_id, $languages[$i]['id']))); ?></td>
		</tr>
		<?php
		}
		?>
		<tr>
			<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
		<?php
		for ($i=0; $i<sizeof($languages); $i++) {
		?>
		<tr>
			<td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_EVENTS_CATEGORIES_DESCRIPTION; ?></td>
			<td>
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
					<td class="main"><?php echo tep_draw_textarea_field('events_categories_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (tep_not_null($events_categories_description[$languages[$i]['id']]) ? stripslashes($events_categories_description[$languages[$i]['id']]) : tep_get_events_category_description($ecInfo->events_categories_id, $languages[$i]['id']))); ?></td>
				</tr>
			</table>
			</td>
		</tr>
		<?php
		}
		?>
		<tr>
			<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
		<tr>
			<td class="main"><?php echo TEXT_EDIT_EVENTS_CATEGORIES_IMAGE; ?></td>
			<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_file_field('events_categories_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $ecInfo->events_categories_image . tep_draw_hidden_field('events_categories_previous_image', $ecInfo->events_categories_image); ?></td>
		</tr>
		<tr>
			<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
		<tr>
			<td class="main"><?php echo TEXT_EDIT_EVENTS_CATEGORIES_SORT_ORDER; ?></td>
			<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('sort_order', $ecInfo->sort_order, 'size="2"'); ?></td>
		</tr>
		<tr>
			<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
	</table>
	</td>
	</tr>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	</tr>
	<tr>
		<td class="main" align="right"><?php echo tep_draw_hidden_field('events_categories_date_added', (($ecInfo->date_added) ? $ecInfo->date_added : getServerDate())) . tep_draw_hidden_field('parent_id', $ecInfo->parent_id); ?></td>
	</tr>
	</table>
<?php
	//echo "</form>";
	}
	
	// New Event Function Begin
	function load_new_event(){
	?>
	 <?php echo tep_draw_form('new_event', FILENAME_EVENTS_CATEGORIES, 'ecPath=' . $ecPath . '&eID=' . $HTTP_GET_VARS['eID'] . '&action='. $form_action, 'post', 'onSubmit="return ValidateForm();" enctype="multipart/form-data"'); ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo sprintf(TEXT_NEW_EVENT, tep_output_generated_events_category_path($current_events_category_id)); ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
	  
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
	   <tr>
			<td>
			<table border="0" cellspacing="0" cellpadding="2">
				<tr>
					<td>
					<table border=0 cellpadding="0" cellspacing="0">
						<tr>
							<td class="main" width="150" valign="top"><?php echo TEXT_EVENTS_STATUS; ?></td>
							<td class="main" width="200" valign="top"><?php echo tep_draw_pull_down_menu('events_status', $status_array, ($pID!='' && $pID>0)?$eInfo->events_status:1); ?></td>
							<?php $_array=array('d','m','Y');  $replace_array=array('DD','MM','YYYY'); 	$date_format=str_replace($_array,$replace_array,EVENTS_DATE_FORMAT);?>
							<td class="main" width="150" valign="top"><?php echo TEXT_EVENTS_DATE_AVAILABLE; ?><br><small>(<?php echo $date_format;?>)</small></td>
							<td class="main" width="200" valign="top"><?php echo tep_draw_input_field("events_date_available",(tep_not_null($eInfo->events_date_available)?format_date($eInfo->events_date_available):format_date($current_date)),"size=10",false,'text',false);?>
							<a href="javascript:show_calendar('new_event.events_date_available',null,null,'<?php echo $date_format;?>');"
							onmouseover="window.status='Date Picker';return true;"
							onmouseout="window.status='';return true;"><img border="none" src="images/icon_calendar.gif"/>  
							</a>
							
						</tr>
					</table>
					</td>
				</tr>
				<tr>
					<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
				<tr>
					<td>
					<table border=0 cellpadding="0" cellspacing="0">
						<tr>
							<td class="main" width="150" valign="top"><?php echo TEXT_EVENTS_CATEGORIES; ?></td>
							<td class="main" width="200"><?php echo tep_draw_mselect_menu('events_categories_ids[]', $events_categories_array, $events_categories_array_selected, 'size=10 id=events_categories_ids style="width:400"'); ?></td>
						</tr>
					</table>
					</td>
				</tr>
				<tr>
					<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
				<?php tep_content_title_top("General"); ?>
				<tr>
					<td>
					<table border="0" cellpadding="4" cellspacing="0">
						<tr>
							<td>
							<table border="0" cellpadding="0" cellspacing="0">
								<?php
								for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
								?>
										<tr height="30">
											<td class="main" width="150"><?php if ($i == 0) echo TEXT_EVENTS_NAME; ?></td>
											<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']);?></td>
											<td class="main"><?php echo tep_draw_input_field('events_name[' . $languages[$i]['id'] . ']', (isset($events_name[$languages[$i]['id']]) ? $events_name[$languages[$i]['id']] : tep_get_events_name($eInfo->events_id, $languages[$i]['id'])),' size=40');?></td>
										</tr>
								<?php
								}
								?>
							</table>
							</td>
						</tr>
						<tr>
							<td>
							<table border="0" cellpadding="0" cellspacing="0">
								<?php
								for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
								?>
									<tr>
										<td class="main" valign="top" width="150"><?php if ($i == 0) echo TEXT_EVENTS_DESCRIPTION; ?></td>
										<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
										<td>
										<table border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td class="main"><?php echo tep_draw_textarea_field('events_description[' . $languages[$i]['id'] . ']', 'soft', '80', '24', (isset($events_description[$languages[$i]['id']]) ? $events_description[$languages[$i]['id']] : tep_get_events_description($eInfo->events_id, $languages[$i]['id'])),'id="events_description[' . $languages[$i]['id'] . ']"'); ?></td>
											</tr>
										</table>
										</td>
									</tr>
									<tr height="10"></tr>
								<?php
								}
								?>
							</table>
							</td>
						</tr>
						
						<tr>
							<td  width="100%">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<?php
								for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
								?>
									<tr height="30">
										<td class="main" width="100">
										<table border="0" cellpadding="0" cellspacing="0">
											<tr>
												<td class="main" width="100" nowrap="nowrap"><?php if ($i == 0) echo TEXT_EVENTS_URL . tep_draw_separator('pixel_trans.gif', '2', '10') . '<br><small>' . TEXT_EVENTS_URL_WITHOUT_HTTP . '</small>' . tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
												<td class="main" align="right"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']);?></td>
												<td class="main" align="right">&nbsp;&nbsp;&nbsp;<?php echo tep_draw_input_field('events_url[' . $languages[$i]['id'] . ']', (isset($events_url[$languages[$i]['id']]) ? $events_url[$languages[$i]['id']] : tep_get_events_url($eInfo->events_id, $languages[$i]['id'])),'size=40');?></td>
											</tr>
										</table>
										</td>
										
										<?php if($i==0){?>
										<td class="main" colspan="2" nowrap="nowrap" valign="middle"><?php echo "&nbsp;&nbsp;" . TEXT_EVENTS_IMAGE . "&nbsp;&nbsp;" . tep_draw_file_field('events_image') . '&nbsp;&nbsp;' . $eInfo->events_image . tep_draw_hidden_field('events_previous_image', $eInfo->events_image); ?></td>
										<?php }else{echo "<td class='main' colspan='2'>&nbsp;</td>";}?>
									</tr>
								<?php
								}
								?>
								<tr>
									<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>		  
								<tr>
									<?php $time_split=explode(":",$eInfo->events_start_time); 
									if ($time_split[2]=='PM' && $time_split[0]>12) $time_split[0]=$time_split[0]-12;?>
									
										<td class="main" width="300">
													<?php echo TEXT_EVENTS_START_TIME . '&nbsp;'; 
													 echo tep_draw_pull_down_menu('start_time_hours',$hour_array,$time_split[0]) . ' : ' . tep_draw_pull_down_menu('start_time_minutes',$minute_array,$time_split[1]) . ' ' . tep_draw_pull_down_menu('start_time_session',$day_session_array,$time_split[2]); ?></td>
													<?php $time_split=explode(":",$eInfo->events_end_time); 
															if ($time_split[2]=='PM' && $time_split[0]>12) $time_split[0]=$time_split[0]-12;?>
											
										<td class="main"  align="left" nowrap="nowrap">
										<?php echo tep_draw_radio_field('link_service','L',($eInfo->link_service=='L')?true:false,'','onClick="javascript:do_change(this);"').'&nbsp;'.TEXT_CHOOSE_LOCATIONS.'&nbsp;'.tep_draw_radio_field('link_service','S',($eInfo->link_service=='S')?true:false,'','onClick="javascript:do_change(this);"').'&nbsp;'.TEXT_LINK_SERVICES;?></td>
								</tr>
								<tr>
									<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
									<td class="main" width="350" nowrap="nowrap"><?php //echo tep_draw_separator('pixel_trans.gif','90','10')?><?php echo TEXT_EVENTS_END_TIME . "&nbsp;&nbsp;"; ?>
									<?php echo tep_draw_pull_down_menu('end_time_hours',$hour_array,$time_split[0]) . ' : ' . tep_draw_pull_down_menu('end_time_minutes',$minute_array,$time_split[1]) . '  ' . tep_draw_pull_down_menu('end_time_session',$day_session_array,$time_split[2]); ?></td>
									<td class="main"  align="left">
										<table border="0"  cellpadding="0" cellspacing="0">
											<tr>
												<td class="main" id="locations" align="left"><?php 
												echo '&nbsp;'.TEXT_EVENTS_LOCATION;
												echo tep_draw_separator('pixel_trans.gif', '15', '10') . tep_draw_pull_down_menu('events_location', $location_array,$eInfo->events_location);?>
												</td>
												<td  id="customers" style="display:none" class="main"><?php
												echo TEXT_CHOOSE_CUSTOMER;
												echo tep_draw_pull_down_menu('sel_customers',array(),$service_customer_selected,'onChange=javascript:do_submit(this.value);');
												?>
												</td>
											</tr>
										</table>
								</tr>	
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>		
								<tr id="services" style="display:none">
									<td class="main" width="350"><?php echo TEXT_CHOOSE_SERVICE;?>
									<?php echo tep_draw_separator('pixel_trans.gif', '1', '10') . tep_draw_pull_down_menu('sel_services',$services_array,$eInfo->service_id);?></td>
								</tr>	
								<tr>
									<td class="main" nowrap="nowrap"><?php echo TEXT_EVENTS_MAX_RESERVE; ?>
									<?php 
										echo tep_draw_input_field('events_max_reserve',(tep_not_null($eInfo->events_max_reserve) ? $eInfo->events_max_reserve:''),'size=10 maxlength=6');
										echo tep_draw_hidden_field('old_max_reserve',$eInfo->events_max_reserve);
									?>
									</td>
									<td class="main" nowrap="nowrap" align="left"><?php echo  TEXT_EVENTS_OVERBOOK_RESERVE . "&nbsp;"; ?>
									<?php 
										echo tep_draw_input_field('events_overbook_reserve',(tep_not_null($eInfo->events_overbook_reserve) ? $eInfo->events_overbook_reserve:0),'size=10 maxlength=6');
									?>
									</td>
								</tr>
							</table>
							</td>
						</tr>
					</table>
					</td>
				</tr>
				<?php tep_content_title_bottom(); ?>
				<?php tep_content_title_top("Costs"); ?>
					<tr>
						<td>
						<table border="0"  cellpadding="4" cellspacing="0" width="100%">
							
							<tr>
								<td class="main"><?php 
								 	  $price=$eInfo->events_fees;
			           				  if(strpos($price,".") && substr($price,strpos($price,"."))<=0) $price=(int)$price;
								 	  echo TEXT_EVENTS_TAX_CLASS .tep_draw_separator('pixel_trans.gif',10,10) . tep_draw_pull_down_menu('events_tax_class_id', $tax_class_array, $eInfo->events_tax_class_id, 'onchange="updateGross()"');
									  echo tep_draw_separator('pixel_trans.gif',30,10).TEXT_EVENTS_FEES_NET_INFO . tep_draw_separator('pixel_trans.gif',10,10). tep_draw_input_field('events_fees_net', $price, 'onKeyUp="updateGross()"'); 
									  echo tep_draw_separator('pixel_trans.gif',30,10).TEXT_EVENTS_FEES_GROSS_INFO .tep_draw_separator('pixel_trans.gif',10,10). tep_draw_input_field('events_fees_gross', $eInfo->events_fees, 'OnKeyUp="updateNet()"');
								?>
								</td>
							</tr>
							<tr>
								
								<td class="main"><?php echo TEXT_EVENTS_REFUND_PAYMENT; 
								 $events_refund_pay = $events_payment_array;
									  $events_refund_length = count($events_refund_pay);
								      for($k=0;$k<$events_refund_length;$k++)
										  $events_refund_pay[$k]['text'] = strip_tags($events_refund_pay[$k]['text']);
								 echo tep_draw_separator('pixel_trans.gif',10,10).tep_draw_pull_down_menu('events_payment', $events_refund_pay,$eInfo->events_payment); ?></td>
							</tr>
						</table>
						</td>
					</tr>
				<?php tep_content_title_bottom(); ?>	  
				
				<?php tep_content_title_top("Instructor"); ?>
				<tr>
					<td>
					<table border="0"  cellspacing="0" cellpadding="4" width="70%">
						<tr>
							
							<td align=left class="main" ><?php
							 echo TEXT_RATE_TYPE .tep_draw_separator('pixel_trans.gif',10,10) .tep_draw_pull_down_menu('instructors_rate_type',$rate_type_array,$eInfo->instructors_rate_type);
							 echo tep_draw_separator('pixel_trans.gif',20,10).TEXT_RATE .tep_draw_separator('pixel_trans.gif',10,10). tep_draw_input_field('instructors_rate',number_format($eInfo->instructors_rate,2),'size=10 maxlength=10');
							 echo tep_draw_separator('pixel_trans.gif',20,10).TEXT_BASE_RATE .tep_draw_separator('pixel_trans.gif',10,10). tep_draw_input_field('instructors_base_rate',number_format($eInfo->instructors_base_rate,2),'size=10 maxlength=10');?>
							</td>
						</tr>
						<tr>
							<td class="main" ><?php 
							echo TEXT_EVENTS_INSTRUCTOR .tep_draw_separator('pixel_trans.gif',10,10). tep_draw_pull_down_menu('events_instructor', $instructor_array, $eInfo->events_instructor);
							echo tep_draw_separator('pixel_trans.gif',20,10).TEXT_EVENTS_BACKUP_INSTRUCTOR . tep_draw_separator('pixel_trans.gif',10,10).tep_draw_pull_down_menu('events_backup_instructor', $instructor_array, $eInfo->events_backup_instructor); ?>
							</td>
						</tr>
					</table>
					</td>
				</tr>
			<?php tep_content_title_bottom(); ?>
			<script language=javascript>
				function doCheck(bolEnable){
					document.new_event.priority_vip.disabled=!bolEnable;
					document.new_event.session_style[0].disabled=!bolEnable;
					document.new_event.session_style[1].disabled=!bolEnable;
					document.new_event.priority_firstcome.disabled=!bolEnable;
					document.new_event.priority_custom.disabled=!bolEnable;
					document.new_event.priority_question.disabled=!bolEnable;
					document.new_event.waitsize_vip.disabled=!bolEnable;
					document.new_event.waitsize_firstcome.disabled=!bolEnable;
					document.new_event.waitsize_custom.disabled=!bolEnable;
					document.new_event.waitfee_vip.disabled=!bolEnable;
					document.new_event.waitfee_firstcome.disabled=!bolEnable;
					document.new_event.waitfee_custom.disabled=!bolEnable;
					document.new_event.events_forward_period.disabled=!bolEnable;    
					document.new_event.events_forward_length.disabled=!bolEnable;
					document.new_event.events_pending_period.disabled=!bolEnable;
				}
				function enableGroup(){
					var frm=document.new_event;
					frm.events_group_max.disabled=!frm.events_group_bookings.checked;
					frm.events_group_min.disabled=!frm.events_group_bookings.checked;
				}
			</script>
				<?php tep_content_title_top("WaitingList"); ?>
				<tr>
					<td>
					<table border="0" width=100% cellspacing="0" cellpadding="4">
						<tr>
							<td class="main" align=left colspan="2"><?php echo tep_draw_checkbox_field('events_wait_list','Y',($eInfo->events_wait_list=='Y'?true:false),'','onClick="doCheck(this.checked)"') . TEXT_PRESENT_WAITLIST; ?></td>
						</tr>
						<tr>
							<td class="main" align="left" colspan="2"><?php echo TEXT_WAITLIST_STYLE . tep_draw_separator('pixel_trans.gif', '24', '1') . tep_draw_radio_field('session_style','S',($eInfo->session_style=="S"?true:false)) . TEXT_STYLE_SESSION . '&nbsp;' . tep_draw_radio_field('session_style','E',($eInfo->session_style=="E"?true:false)) . TEXT_STYLE_EVENT;?></td>
						</tr>
						<tr>
						   <td colspan="2">
							 <table border="0" width="100%" cellspacing="0" cellpadding="4">
								<tr valign=top>
									<td class="main" align=left width=20%><?php echo '<b>' . HEADING_TYPE . '</b>'; ?></td>
									<td class="main" align=left><?php echo '<b>' . HEADING_PRIORITY . '</b>'; ?></td>
									<td class="main" align=left><?php echo '<b>' . HEADING_SIZE . '</b>'; ?></td>
									<td class="main" align=left><?php echo '<b>' . HEADING_FEE . '</b>'; ?></td>
									<td class="main" align=left><?php echo '<b>' . HEADING_APPLY_TO . '</b>'; ?></td>
									<td class="main" align=left><?php echo '<b>' . HEADING_DESCRIPTION . '</b>'; ?></td>
								</tr>
								<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td></tr>
								<tr  valign=top>
									<td class="main"><?php echo TEXT_PRIORITY_VIP; ?></td>
									<td class="main"><?php echo tep_draw_pull_down_menu('priority_vip',$priority_array,((int)$eInfo->priority_vip!=0)?$eInfo->priority_vip:'1'); ?></td>
									<td class="main"><?php echo tep_draw_input_field('waitsize_vip',$eInfo->waitsize_vip,'size=5 maxlength=6'); ?></td>
									<td class="main"><?php echo tep_draw_input_field('waitfee_vip',$eInfo->waitfee_vip,'size=5 maxlength=6 onKeyUp="change_waitfee(this)"'); ?></td>
									<td class="main"><?php echo APPLY_TO_VIP ?></td>
									<td class="main" align=justify><?php echo DESCRIPTION_VIP ?></td>
								</tr>
								<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td></tr>
								<tr  valign=top><td class="main"><?php echo TEXT_PRIORITY_FIRSTCOME; ?></td>
									<td class="main"><?php echo tep_draw_pull_down_menu('priority_firstcome',$priority_array,((int)$eInfo->priority_firstcome!=0)?$eInfo->priority_firstcome:'2'); ?></td>
									<td class="main"><?php echo tep_draw_input_field('waitsize_firstcome',$eInfo->waitsize_firstcome,'size=5 maxlength=6'); ?></td>
									<td class="main"><?php echo tep_draw_input_field('waitfee_firstcome',$eInfo->waitfee_firstcome,'size=5 maxlength=6 onKeyUp="change_waitfee(this)"'); ?></td>
									<td class="main"><?php echo APPLY_TO_FIRSTCOME ?></td>
									<td class="main" align=justify><?php echo DESCRIPTION_FIRSTCOME ?></td>
								</tr>
								<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td></tr>
								<tr  valign=top>
									<td class="main"><?php echo TEXT_PRIORITY_CUSTOM; ?></td>
									<td class="main"><?php echo tep_draw_pull_down_menu('priority_custom',$priority_array,((int)$eInfo->priority_custom!=0)?$eInfo->priority_custom:'3');?></td>
									<td class="main"><?php echo tep_draw_input_field('waitsize_custom',$eInfo->waitsize_custom,'size=5 maxlength=6'); ?></td>
									<td class="main"><?php echo tep_draw_input_field('waitfee_custom',$eInfo->waitfee_custom,'size=5 maxlength=6 onKeyUp="change_waitfee(this)"'); ?></td>
									<td class="main"><?php echo tep_draw_pull_down_menu('priority_question',$questions_array,$eInfo->priority_question); ?></td>
									<td class="main" align=justify><?php echo DESCRIPTION_CUSTOM ?></td>
								</tr>
							</table>
							</td>
						</tr>
					</table>
        			</td>
				</tr>
				<?php tep_content_title_bottom(); ?>	  
				
				<?php tep_content_title_top("Conditions"); ?>
				<tr>
					<td>
					<table border="0"  width=100% cellspacing="0" cellpadding="4">
						<tr>
							<td>
							<table border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="main" width="150"><?php echo TEXT_PENDING_PERIOD . '&nbsp;'; ?></td>
									<td class="main"><?php echo tep_draw_input_field('events_pending_period',$eInfo->events_pending_period,'size=7 maxlength=6')  . TEXT_DAYS; ?></td>
								</tr>
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
									<td align=left class="main" valign="top"><?php echo TEXT_RENEWAL_START; ?></td>
									<td align=left class="main" valign="top"><?php echo tep_draw_pull_down_menu('events_renewal_start',$renewal_array,$eInfo->events_renewal_start); ?></td>
								</tr>
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
									<td align=left class="main" valign="top"><?php echo TEXT_RENEWAL_END; ?></td>
									<td align=left class="main" valign="top"><?php echo tep_draw_input_field('events_renewal_end',$eInfo->events_renewal_end,'size=10 maxlength=6')  . TEXT_DAYS; ?></td>
								</tr>
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
									<td class="main"><?php echo TEXT_EVENTS_REFUND_PERCENTAGE; ?></td>
									<td class="main">
										<?php echo TEXT_EVENTS_REFUND_PERCENTAGE1 . '&nbsp;' . tep_draw_pull_down_menu('refund_percentage1',$events_percent_array,(tep_not_null($eInfo->refund_percentage1) ? $eInfo->refund_percentage1:'10')) . '%'
												. '&nbsp;' . TEXT_EVENTS_REFUND_PERCENTAGE2 . '&nbsp;' . tep_draw_pull_down_menu('refund_percentage2',$events_percent_array,(tep_not_null($eInfo->refund_percentage2) ? $eInfo->refund_percentage2:'30')) . '%'
												. '&nbsp;' . TEXT_EVENTS_REFUND_PERCENTAGE3 . '&nbsp;' . tep_draw_pull_down_menu('refund_percentage3',$events_percent_array,(tep_not_null($eInfo->refund_percentage3) ? $eInfo->refund_percentage3:'50')) . '%'; 
										?>
									</td>
								</tr>
							</table>
							</td>
						</tr>
						<tr>
							<td>
							<table border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td align="left" class="main" valign="top" width="150">&nbsp;</td>
									<td align="left" class="main" valign="top">
										<?php 	echo tep_draw_checkbox_field('session_gaps','Y',($eInfo->session_gaps=='Y'?true:false)) . '&nbsp;' . TEXT_SESSION_GAPS;
												echo '&nbsp;' . tep_draw_checkbox_field('session_reduction','Y',($eInfo->session_reduction=='Y'?true:false));
												echo '&nbsp;' . TEXT_SESSION_REDUCTION;
										?>
									</td>
								</tr>
								<tr>
									<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
									<td align="left" class="main" valign="top" width="150">&nbsp;</td>
									<td class="main">
										<?php echo tep_draw_checkbox_field('events_forward_period','Y',($eInfo->events_forward_period=='Y'?true:false),'','onClick=""') . TEXT_FORWARD_PERIOD;
											echo '.&nbsp;&nbsp;&nbsp;' . TEXT_PERIOD_LENGTH . '&nbsp;' .  tep_draw_input_field('events_forward_length',$eInfo->events_forward_length,'size=7 maxlength=6') . TEXT_DAYS; ?>
									</td>
								</tr>
							</table>
							</td>
						</tr>
						<tr>
							<td>
							<table border="0" cellspacing="0" cellpadding="0">
								<tr>
								    <td align=left class="main"  valign="top" colspan="2">
								    <?php echo tep_draw_checkbox_field('events_group_bookings','Y',($eInfo->events_group_bookings=="Y"?true:false),false,'onClick="javascript:enableGroup();"') . TEXT_ALLOW_GROUP_BOOKINGS;?>
								    </td>
								</tr>
								<tr> 
								   <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr>
								<tr>
								    <td align=left class="main" valign="top"><?php echo TEXT_MIN_GROUP_SIZE ;?>
									<?php echo tep_draw_separator('pixel_trans.gif', '10', '5') . tep_draw_input_field('events_group_min',$eInfo->events_group_min,'size=7 maxlength=6');?></td>
									
								   <td align=left class="main" valign="top"><?php echo tep_draw_separator('pixel_trans.gif', '40', '10') . TEXT_MAX_GROUP_SIZE;?>
								  <?php echo tep_draw_separator('pixel_trans.gif', '10', '5') .tep_draw_input_field('events_group_max',$eInfo->events_group_max,'size=7 maxlength=6');?></td>
								</tr>
								<script lnguage="javascript">
									enableGroup();
								</script>
								<tr>
								    <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
								</tr> 
								<tr>
									<td align=left class="main"  valign="top" width="150"><?php echo TEXT_CONDITION_DESC;?></td>
									<td class="main"><?php echo tep_draw_textarea_field('events_conditions','soft','100%',10,$eInfo->events_conditions); ?></td>
								</tr>
							</table>
							</td>
						</tr>
						
						
					</table>
					</td>
	  				<script language=javascript>
						doCheck(document.new_event.events_wait_list.checked);
					</script>
				</tr>
				<?php tep_content_title_bottom(); ?>
				
				<?php tep_content_title_top("Subscription"); ?>
				<tr>
					<td>
					<table border=0 cellpadding="4" cellspacing="0" width="50%">
						<tr>
							<td class="main" width="150" valign="top"><?php echo TEXT_SUBSCRIPTION_CATEGORIES; ?></td>
							<td class="main" width="200"><?php 
							$events_link=true;
							echo tep_draw_subscription_select_menu('subscription_categories_ids[]',$subscription_array, $subscription_categories_array_selected, 'size=10 id=subscription_categories_ids style="width:350"');
							?></td>
						</tr>
						<tr>
							<td class="main" nowrap="nowrap" width="150"><?php echo TEXT_SUBSCRIPTION_OVERBOOK_RESERVE; ?></td>
							<td class="main" align="left">
							<?php 
								echo tep_draw_input_field('subscription_overbook_reserve',(tep_not_null($eInfo->subscription_overbook_reserve) ? $eInfo->subscription_overbook_reserve:0),'size=10 maxlength=6');
							?>
							</td>
						</tr>
					</table>
					</td>
				</tr>	  
				<?php tep_content_title_bottom(); ?>
				<tr>
					<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
				
				
				
				<tr>
					<td class="main" align="right"><?php echo tep_draw_hidden_field('events_date_added', (tep_not_null($eInfo->events_date_added) ? $eInfo->events_date_added : getServerDate())); ?></td>
				</tr>
		</table>
		
		
		</form>

	<?php }  
	// New Events Function End
	?>
	
<?php  
	$events_categories_id=0; $function_name='';
	$events_categories_query=tep_db_query('select ec.events_categories_id from '.TABLE_EVENTS_CATEGORIES.' ec, '.TABLE_EVENTS_CATEGORIES_DESCRIPTION.' ecd where ec.events_categories_id=ecd.events_categories_id order by ecd.events_categories_name');
	if(tep_db_num_rows($events_categories_query)>0){
	$events_categories_array=tep_db_fetch_array($events_categories_query);
	$events_categories_id=$events_categories_array['events_categories_id'];
	}
	$events_check_query=tep_db_query('select count(*) as total from '.TABLE_EVENTS_TO_EVENTS_CATEGORIES." where events_categories_id='$events_categories_id'");
	$events_check_array=tep_db_fetch_array($events_check_query);
	$function_name=($events_check_array['total']<=0)?'javascript: new_event_category('.$events_categories_id.');':'javascript: new_event('.$events_categories_id.');';
?>


 <script language="javascript">
 //document.getElementById('base_header_new_operation').href='<?php echo $function_name; ?>';
 	function close_new_category(){
	document.getElementById('new_category').style.display='none';
	}
 	function new_event_category(events_categories_id){
	alert(events_categories_id);
	}
	function new_category_submit(){
	document.forms['new_event'].submit();
	}
	function search_event(){
	var events_search_criteria=str_trim(document.getElementById('events_search').value);
	if(events_search_criteria!=''){
		document.getElementById('search_result_details').innerHTML=document.getElementById('ajax_load_img').innerHTML;
		do_get_command('<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'command=events_search&events_search_criteria='); ?>'+events_search_criteria);
	}
	return false;
	}
	function reset_search(){
	document.getElementById('search_result_details').innerHTML=document.getElementById('ajax_load_img').innerHTML;
	do_get_command('<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'command=reset_search') ?>');
	document.getElementById('events_search').value="";
	}
 	
	function do_jump_list(nopen_ids){
		document.getElementById('events_search').value='';
		if (open_ids.join(",")==nopen_ids) return;
		nopen_idsb=nopen_ids.split(",");
		nopen_ids=nopen_ids.split(",");
		for (icnt=0,n=nopen_ids.length;icnt<n;icnt++){
			if(icnt>=open_ids.length || nopen_ids[icnt]!=open_ids[icnt]){
				open_cat=nopen_ids[icnt];
				nopen_ids=nopen_ids.slice(icnt);
				break;
			}
		}
		if (open_ids[icnt]) hide_cat_panel(open_ids[icnt]);
		if(icnt<=open_ids.length && open_ids[nopen_ids.length-1]==nopen_ids[nopen_ids.length-1]) {
			hide_cat_panel(open_ids[nopen_ids.length]);
			open_ids=nopen_idsb;
		} else {
			open_ids=nopen_idsb;
			show_cat_panel(open_cat);
			do_page_fetch('fetch_sub_list_open','',open_cat,1,icnt);
		}
	}
	
	
  	function do_page_fetch(cmd,params,category,page,level){
		command="<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'do=1');?>&command="+cmd;
		if(document.getElementById("img_new") && category) {
			document.getElementById("img_new").href="javascript:expand_category("+category+",2);";
			if(document.getElementById("link_category")) document.getElementById("link_category").href="javascript:expand_category("+category+",2);";
			if(document.getElementById("link_product")) document.getElementById("link_product").href="javascript:expand_category(0,6,"+category+");";
		}				
		if(cmd=="fetch_sub_list" && document.getElementById("cPath") && document.getElementById("product_id")) {
			c_ids=document.getElementById("cPath").value;
			p_ids=document.getElementById("product_id").value;
			if(document.getElementById("data_"+p_ids+"_"+c_ids)) document.getElementById("data_"+p_ids+"_"+c_ids).style.display="";
			if(document.getElementById("head_"+p_ids+"_"+c_ids)) document.getElementById("head_"+p_ids+"_"+c_ids).style.display="none";			
			if(c_ids && document.getElementById("category_details_"+c_ids)) document.getElementById("category_details_"+c_ids).style.display="none";						
		}				
		if(document.getElementById("cPath")) document.getElementById("cPath").value=category;
		show_order=document.getElementById("show_sort_order");
		if (cmd=="fetch_sub_list" || cmd=="fetch_sub_list_open"){
			if(document.getElementById('new_category'))document.getElementById('new_category').innerHTML = "";
			command=command+"&cID="+category+"&level="+ level+"&show_order="+show_order.value;
			if (cmd=="fetch_sub_list_open") command=command+"&open_ids="+open_ids.join(",");
			if(document.getElementById("panel_"+category+"_content")) document.getElementById("panel_"+category+"_content").innerHTML=document.getElementById("ajax_load_img").innerHTML;
		} else if (cmd=="fetch_all_list"){
			show_order.value=params;
			command=command+"&cID=-1&page=1&level=1&open_ids="+open_ids.join(",")+"&show_order="+params;
			hide_cpopup(true);
			if(!document.getElementById("panel_"+open_ids[0]+"_content")) {
				cmd = "do_sort_list" ;
				command="<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'do=1');?>&command="+cmd;
				command=command+"&cID=-1&page=1&level=1&open_ids="+open_ids.join(",")+"&show_order="+params;
				//document.getElementById("search_result_details").innerHTML=document.getElementById("ajax_load_img").innerHTML;
			}else
				document.getElementById("panel_"+open_ids[0]+"_content").innerHTML=document.getElementById("ajax_load_img").innerHTML;
		} else {
			if (page=='next') {
				pgCombo=document.getElementById("page_"+category);
				selIndex=pgCombo.selectedIndex+1;
				if (selIndex>=pgCombo.options.length) return;
				pgCombo.selectedIndex=selIndex;
			} else if (page=='previous'){
				pgCombo=document.getElementById("page_"+category);
				selIndex=pgCombo.selectedIndex-1;
				if (selIndex<0) return;
				pgCombo.selectedIndex=selIndex;
			} 
			page=document.getElementById("page_"+category).value;
			command=command+'&page='+page+'&'+params+"&show_order="+show_order.value;
			document.getElementById("panel_"+category+"_contentp").innerHTML=document.getElementById("ajax_load_img").innerHTML;
		}
		do_get_command(command);
	}
	function do_submit(customers_id){
	if(customers_id!=-1){
		document.getElementById('sel_services_id').innerHTML=document.getElementById('ajax_load_img').innerHTML;
		do_get_command('<?php echo tep_href_link(FILENAME_EVENTS_CATEGORIES,'command=fetch_service_details&customers_id='); ?>'+customers_id);
	}
	}
	function do_result(result){ 
		if (result=="") return;	   	
		var token=result.split('^^');
	switch(token[0]){
		case 'fetch_customer_details':
			document.getElementById('sel_customers_id').innerHTML=token[1];
			if(document.getElementById('services')) document.getElementById('services').style.display="";
			return;
			break;
		case 'fetch_service_details':
			document.getElementById('sel_services_id').innerHTML=token[1];
			return;
			break;

	}
		if(result.indexOf('#*#')>=0){ 
			var customers=new Array();
			var result=result.substring(0,result.length-3);
			 if(result.indexOf('#')>=0 && result.length>0){
				temp=result.split('#');
				for(i=0;i<temp.length-1;i++)
				{
					content=temp[i];
					temp2=content.split(':');
					customers[i]=new Array(2);
					customers[i][0]=temp2[0];
					customers[i][1]=temp2[1];
				}
				if(document.getElementById('services')) document.getElementById('services').style.display="";
				fill_customers(customers);
			} else{
					var Option_value=new Option('<?php echo TEXT_NO_CUSTOMERS_AVAILABLE;?>','nil');
					document.new_event.sel_customers.options[0] = Option_value;
					alert('<?php echo TEXT_ERR_NO_BOOKINGS_EXIST;?>');
			}
		} else if(result.indexOf('^*^')>=0){
		var result=result.substring(0,result.length-3);
		if(result.indexOf('^')>=0)
		{
			temp=result.split('^');
			for(i=0;i<temp.length-1;i++)
			{
				content=temp[i];
				temp2=content.split(':');
				customers[i]=new Array(2);
				customers[i][0]=temp2[0];
				customers[i][1]=temp2[1];
			}
			fill_services(customers);
			}
		}		

		if(result.substr(0,7)=='command'){
			result_splt=result.split("{}");
			command="";
			category_id="";
			for (icnt=0;icnt<result_splt.length;icnt++){
				command_splt=result_splt[icnt].split("||");
				
				switch (command_splt[0]){
					case 'category':
						category_id=command_splt[1];
						break;
					case 'command':
						command=command_splt[1];
						break;
					case "page":
					 	if(document.getElementById("panel_"+category_id+"_pgno"))
						   document.getElementById("panel_"+category_id+"_pgno").value=command_splt[1];
						break;
					case "result":
						if (command=="fetch_sub_events"){
							document.getElementById("panel_"+category_id+"_contentp").innerHTML=command_splt[1];
						} else {
							if(!document.getElementById("panel_"+category_id+"_content"))
								document.getElementById("search_result_details").innerHTML=command_splt[1];
							else
								document.getElementById("panel_"+category_id+"_content").innerHTML=command_splt[1];
						}
						if(return_flag==1){
							expand_category(p_id,1,c_id);
							return_flag==0;
							
						}
				}
			}
	 	 } else if(result.length>1){
		 	var res_display=document.getElementById("res_display");
		 	var span_product="";
		 	var span_category="";
		 	var action_type="";			 			 		
		 	if(document.getElementById("cPath")) var category_id=document.getElementById("cPath").value;		 			 			 	
		 	if(document.getElementById("product_id").value) var pID=document.getElementById("product_id").value;
		 	if(document.getElementById("action_type"))  action_type=document.getElementById("action_type").value;
		 	if(document.getElementById("span_details_"+category_id)) span_category=document.getElementById("span_details_"+category_id);
		 	if(document.getElementById("span_details")) span_product=document.getElementById("span_details");// && !document.getElementById("search_result_details").childNodes[1] 
		 	if(action_type=='new_category' && document.getElementById("search_result_details")&&  result!="" && document.getElementById("new_category")){
				if(result.indexOf("^")>0 || result.indexOf("{}")>0 || result.indexOf("||")>0 || document.getElementById("span_details_"+category_id)){
				}else{ 
					document.getElementById("new_category").innerHTML=result;
					document.getElementById("new_category").style.display = "";
				}
			}
		 	result_split=result.split('^');
		 	res=result;
		 	splt="";
		 	 if(result_split.length>1){
		 		splt=result_split[0];
			 	res=result_split[1];
		 	 }
			 if(splt=='get_details'){ print_details('get_details',res); if(return_flag==1) {
				 expand_category(pID,7,category_id); 
				 return_flag=0;
			    }
			  }
			 else if(splt=='events_search' || splt=='reset_search') document.getElementById('search_result_details').innerHTML=res;			 			
			 else if(splt=='new_main_category') print_details('new_main_category',res);
			 else if(splt=='new_category') print_details('new_category',res);
			 else if(splt=='edit_category') print_details('edit_category',res);			 	
			 else if(splt=='move_category_success') print_details('move_category_success',res);
			 else if(splt=='sort_order_success') print_details('sort_order_success',res);
			 else if(splt=='delete_category_success') print_details('delete_category_success',res);		 	
			 else if(splt=='sort_order_error') print_details('sort_order_error',res);
			 else if(splt=='new_product') print_details('new_product',res);			 				 
			 else if(splt=='copy_details') print_details('copy_details',res);
			 else if(splt=='move_success') print_details('move_success',res);
			 else if(splt=='delete_success') print_details('delete_success',res);
			 else if(splt=='copy_error') print_details('copy_error',res);
			 else if(splt=='copy_success') print_details('copy_success',res);	
			 else if(splt=='move_category_failure') print_details('move_category_failure',res);
			 		
			 else if(splt=='diff_category') {	 	 			
	 	 			result_splt=res.split('#'); 	 			
	 	 			if(result_splt[0]>0)  toggle_category_panel(result_splt[0],0,true);
	 	 	}else if(res!="" && (action_type=='new' && !document.getElementById("data_"+pID+"_"+category_id)) || action_type=='new_category' || action_type=='edit_category' || action_type=='delete_category' || action_type=='move_category') {
					// For Event Present on Category
					if(document.getElementById('save_button_'+category_id))
					if(action_type == 'delete_category' && document.getElementById('has_events_'+category_id) && document.getElementById('has_events_'+category_id).value >0)document.getElementById('save_button_'+category_id).style.display = 'none';
					else  document.getElementById('save_button_'+category_id).style.display = '';
					
					span_category.innerHTML=res;
					if(document.getElementById("img_save_"+category_id))
						document.getElementById("img_save_"+category_id).style.display='';
						
					if(splt=='new') {
						if(document.getElementById("action_type")) document.getElementById("action_type").value='new';
						else if(document.getElementById("img_save_"+category_id)) document.getElementById("img_save_"+category_id).style.display="";
					}					
	 	 	}else if(action_type=='new' || action_type=='edit' || action_type=='delete' || action_type=='copy' || action_type=='move'){ 
					if(document.getElementById('product_save_button_'+pID))
					if(action_type == 'delete' && document.getElementById('has_sessions_'+pID) && document.getElementById('has_sessions_'+pID).value >0)document.getElementById('product_save_button_'+pID).style.display = 'none';
					else document.getElementById('product_save_button_'+pID).style.display = '';
		 	 		if(document.getElementById("img_save")) document.getElementById("img_save").style.display="";
		 	 		span_product.innerHTML=res;
					if(action_type=='edit') updateGross();
			}
			if(action_type=='new' || action_type=='edit' || splt=='new'){					
					<?php $languages = tep_get_languages();
					    if (HTML_AREA_WYSIWYG_DISABLE=='Enable') {
						 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
						 	if(document.getElementById("events_description["+<?php echo $languages[$i]['id']; ?>+"]"))
					 		initEditor('events_description[<?php echo $languages[$i]['id']; ?>]');
			  	   <?php }
					  }?>
					toggle_panel('Costs','false','','0');
					toggle_panel('Instructor','false','','0');		
					toggle_panel('WaitingList','false','','0');
					toggle_panel('Conditions','false','','0');
					toggle_panel('Subscription','false','','0');	
					if(document.getElementById('display_instructor'))
						hide_instruct(document.getElementById('display_instructor').checked);
			}
		 }
	}
	 function fill_customers(customers){
			with (document.new_product) {	
				for(i=sel_customers.options.length;i>=0;i--) {
					sel_customers.options[i]=null;
				}
				var Option_value=new Option('<?php echo TEXT_SELECT;?>','-1');
				document.new_product.sel_customers.options[0] = Option_value;
				for(i=0; i < customers.length; i++){
						var Option_value=new Option(customers[i][1],customers[i][0]);
						sel_customers.options[sel_customers.options.length] = Option_value;
				}
				if (customers.length>1 && sel_customers.selectedIndex<0) sel_customers.selectedIndex=0;
			}
				
	}
	 function fill_services(customers){
			with (document.new_product) {	
				for(i=sel_services.options.length;i>=0;i--) {
					sel_services.options[i]=null;
				}
				var Option_value=new Option('<?php echo TEXT_SELECT;?>','-1');
				document.new_product.sel_services.options[0] = Option_value;
				for(i=0; i < customers.length; i++){
						var Option_value=new Option(customers[i][1],customers[i][0]);
						sel_services.options[sel_services.options.length] = Option_value;
				}
				if (customers.length>1 && sel_services.selectedIndex<0) sel_services.selectedIndex=0;
			}
				
	} 
var return_flag = '',p_id='',c_id='';
</script>
<?php if(isset($HTTP_GET_VARS['create_category']) && $HTTP_GET_VARS['create_category']=='new'){ ?>
	<script langauge="javascript">
	if(document.getElementById("action_type")) document.getElementById("action_type").value='new_category';
	if(document.getElementById("cPath")){
			var cPath=document.getElementById("cPath").value;
			toggle_category_panel(cPath,0);
	}

	do_get_command('<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'action=edit_category&return=menu');?>');
	</script>
<?php } 
  if(isset($HTTP_GET_VARS['create_event']) && $HTTP_GET_VARS['create_event']=='new'){ ?>
	<script langauge="javascript">
	if(document.getElementById("action_type")) document.getElementById("action_type").value='new';
	do_get_command('<?php echo tep_href_link(FILENAME_EVENTS_MAINPAGE,'action=edit_product&return=menu');?>');
	</script>
<?php } 
  if(isset($HTTP_GET_VARS['actions']) && $HTTP_GET_VARS['actions']=='edit_products'){ ?>
	<script langauge="javascript">
	//javascript: 
	p_id = <?php echo $HTTP_GET_VARS['p_id']; ?>;
	c_id = <?php echo $HTTP_GET_VARS['c_id']; ?>;
	return_flag=1;
	toggle_category_panel('<?php echo $HTTP_GET_VARS['c_id']; ?>',0);
	</script>
<?php } ?>