<?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');
  include(DIR_WS_CLASSES . 'split_page_results_event.php');
  include(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();
  include('services_create_ajax.php');
  include('includes/functions/categories_description.php');
 include(DIR_WS_INCLUDES."languages/".$language."/services_create.php");
  $command=(isset($HTTP_GET_VARS['command'])?$HTTP_GET_VARS['command']:'');
  $page=(isset($HTTP_GET_VARS['page'])?$HTTP_GET_VARS['page']:1);
  $cID=(isset($HTTP_GET_VARS['cID'])?$HTTP_GET_VARS['cID']:0);
  $check_ID=(isset($HTTP_GET_VARS['chk_ID'])?$HTTP_GET_VARS['chk_ID']:0);  
  $level=(isset($HTTP_GET_VARS['level'])?$HTTP_GET_VARS['level']:0);
  $show_order=(isset($HTTP_GET_VARS['show_order'])?$HTTP_GET_VARS['show_order']:'AN');
  $open_ids=isset($HTTP_GET_VARS["open_ids"])?$HTTP_GET_VARS["open_ids"] . ",":'';
  //actions start
  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_products':
			echo 'command||fetch_sub_products{}category||' . $cID . '{}page||' . $page . '{}result||';
			echo output_services_result($cID,$page,$show_order);
			break;
		case 'service_search':
			echo 'service_search^';
			global $languages_id,$global_categories_id;			
			$service_search=isset($HTTP_GET_VARS['service_search'])?tep_db_prepare_input($HTTP_GET_VARS['service_search']):'';
			$global_categories_id=0;
			$categories_sql = tep_db_query("select c.services_categories_id, cd.services_categories_name, c.parent_id 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 = 0 and cd.services_categories_name like '%" . tep_db_input($service_search) . "%' order by c.sort_order, cd.services_categories_name");
			if(tep_db_num_rows($categories_sql)>0){
				$categories_array=tep_db_fetch_array($categories_sql);
				$global_categories_id=$categories_array['services_categories_id'];				
			}
			output_sub_result(0,1,'A',0,'',1);
			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;	
	  }
   }	
	exit;  
  }  
  tep_get_service_cat_ajax_list(0,0,"open_ids",$jmp_results,$jmp_open_ids);
  tep_get_last_access_file();
  $pro_id=isset($HTTP_GET_VARS['sID'])?$HTTP_GET_VARS['sID']:0;
  function output_services_search_result($search_item){ //print search service details
	global $languages_id,$global_categories_id;
		if($search_item!='') $search_criteria=" and pd.service_name like '%" . tep_db_input($search_item) . "%' ";
		$products_query=tep_db_query('select pd.service_id,pd.service_name,p.service_status from '.TABLE_SERVICES.' p, '.TABLE_SERVICES_DESCRIPTION." pd where p.service_id=pd.service_id and pd.language_id='$languages_id'".$search_criteria." order by service_name");
		echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';			
		if (tep_db_num_rows($products_query)>0){
				$i=0;
				while ($products = tep_db_fetch_array($products_query)){
					$products_id=$products['service_id'];
					$categories_query=tep_db_query('select services_categories_id from '.TABLE_SERVICES_TO_SERVICES_CATEGORIES." where service_id='$products_id'");				
					while($categories_array=tep_db_fetch_array($categories_query)){
						$categories_id=$categories_array['services_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_'.$products['service_id'].'_'.$categories_id.'\').style.display==\'none\') services_actions('.$products['service_id'].',\'get_details\','.$categories_id.');"><td class="main"><div id="data_'.$products['service_id'].'_'.$categories_id.'">';
							echo  ($products['service_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  $products['service_name'] . '</div><div class="openContent" id="head_'.$products['service_id'].'_'.$categories_id.'" style="display:none"></div></td></tr>';					
							$i++;	
						}
					}// while categories loop
			    } 	
		 }
		 echo '</table>';
	}	
	function tep_get_service_cat_ajax_list($parent_id,$level=0,$value_assign_type='default',&$results,&$open_ids){ //service categories listing
		global $languages_id;
		$categories_sql = "select c.parent_id,c.services_categories_id as categories_id,cd.services_categories_name as categories_name  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 . "' order by c.sort_order, cd.services_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_service_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 assign_sort_order($parent_id,$show_order){ //sort order functions
		global $languages_id,$selected_name,$login_id,$login_groups_type,$HTTP_GET_VARS,$page,$command;
		$order_by='ASC';
		if($show_order=='DN') 	$order_by='DESC';
		$categories_sortorder_sql = "select c.parent_id,c.services_categories_id as categories_id,c.sort_order,cd.services_categories_name as categories_name  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 cd.services_categories_name $order_by";
		$old_service_sort_array=array();
			$old_sort_array_assign=array();
			$check_query=tep_db_query($categories_sortorder_sql);
			while($check_products=tep_db_fetch_array($check_query))	 $old_service_sort_array[$check_products['categories_id']]=$check_products['sort_order'];
			$std_array=&$old_service_sort_array;
			$old_sort_array_assign=$old_service_sort_array;
			$sort_order=SORT_ASC;
			array_multisort($old_sort_array_assign,$sort_order);
			$i=0;
			while(list($key,)=each($std_array)){
				tep_db_query("update ". TABLE_SERVICES_CATEGORIES ." set sort_order='".(int)$old_sort_array_assign[$i]."' where services_categories_id='".(int)$key."'");
				$i++;
			}
	}
	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.parent_id,c.services_categories_id as categories_id,c.sort_order,cd.services_categories_name as categories_name  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 . "' ".$search_criteria." order by c.parent_id,cd.services_categories_name $sort_by ";		
		$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 services_categories set sort_order= ". $sort_orders[$categories_sort["parent_id"]] ." where services_categories_id= ". $categories_sort['categories_id']);
			$sort_orders[$categories_sort["parent_id"]]++;
		}		
		$services_sql = "select pd.service_name as services_name,pd.service_id as services_id ,s.service_status from " . TABLE_SERVICES_DESCRIPTION . " pd, "  . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " pcd , " . TABLE_SERVICES ." s where s.service_id=pcd.service_id and pd.service_id=pcd.service_id and pd.language_id = '" . (int)$languages_id . "'"  .$prd_where . " ORDER BY pd.service_name $sort_by ";
		$services_query=tep_db_query($services_sql);
		if(tep_db_num_rows($services_query)>0){
			$i=1;
			while($result=tep_db_fetch_array($services_query)){
				tep_db_query("update ".TABLE_SERVICES." set services_sort_order='".$i."' where service_id='". (int)$result['services_id']."'");	
				$i++;													 																																
			}
		}
	}
	function  output_sub_result($parent_id,$page,$show_order,$level,$open_ids,$start_up=0) { //service product listing
		global $languages_id,$selected_name,$login_id,$login_groups_type,$HTTP_GET_VARS,$page,$command,$service_search;
		output_category_details($parent_id);
		echo '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr style="height:10"><td></td></tr></table>';
		$search_criteria="";
		if($service_search!='') $search_criteria=" and services_categories_name like '%" . tep_db_input($service_search) . "%' ";
		$open_ids="," . $open_ids;
		// first fetch the products in this category
		if ($parent_id>0) output_services_result($parent_id,$page,$show_order);
	//	$order='asc';
	//	if($show_order=='DN') $order='desc';
		$categories_sql = "select c.parent_id,c.services_categories_id as categories_id,c.sort_order,cd.services_categories_name as categories_name  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 ";
		$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_services_result($categories_id,$page,$show_order){
		global $languages_id,$command;
			$result="";
			$prd_where="";
			$prd_order=" ASC ";
		//	if (substr($show_order,0,1)=="D") $prd_order=" DESC ";
			if (substr($show_order,1,1)=="V") $prd_where=" AND s.service_status=1 ";
			$services_sql = "select pd.service_name as services_name,pd.service_id as services_id ,s.service_status from " . TABLE_SERVICES_DESCRIPTION . " pd, "  . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " pcd , " . TABLE_SERVICES ." s where s.service_id=pcd.service_id and pcd.services_categories_id='" . $categories_id . "' and pd.service_id=pcd.service_id and pd.language_id = '" . (int)$languages_id . "'"  .$prd_where . " ORDER BY s.services_sort_order " . $prd_order;
			$query_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $services_sql, $query_split_numrows);
			$services_query=tep_db_query($services_sql);
			if ($command!='fetch_sub_products'){
				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_products\'',$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($services_query)>0){
				$i=0;
				while ($services = tep_db_fetch_array($services_query)){					
					$class="dataTableRowEven";
					if($i%2==0) $class="dataTableRowOdd";					
					echo '<tr class="'.$class.'"  height="18" onclick="javascript:if(document.getElementById(\'head_'.$services['services_id'].'_'.$categories_id.'\').style.display==\'none\') do_actions(\'get_details\','.$services['services_id'].','.$categories_id.');"><td class="main"><div style="cursor:pointer;cursor:hand;" id="data_'.$services['services_id'].'_'.$categories_id.'">';
					echo  ($services['service_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  $services['services_name'] . '</div><div class="opencontent" id="head_'.$services['services_id'].'_'.$categories_id.'" style="display:none"></div></td></tr>';														
					$i++;
				}
			}
			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.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.services_categories_id='".(int)$cID."'");
	if(tep_db_num_rows($product_categories)>0){
		$category_check_sql = "select count(*) as count from " . TABLE_SERVICES_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_SERVICES . " s," . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " ssc," . TABLE_SERVICES_CATEGORIES . " sc where s.service_id=ssc.service_id and sc.services_categories_id=ssc.services_categories_id and sc.services_categories_id=" . $cID;
		$check_query = tep_db_query($check_sql);
		$check_result = tep_db_fetch_array($check_query);
		echo tep_draw_hidden_field('has_services_' . $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['services_categories_id'];?>">
			<tr heigth='40' class='openContent_top'>
				  <td width='10'></td>
				  <td align='left' valign='middle' width='350' class='main'><?php echo $product['services_categories_name'];?></td>
				  <td width='445' align='left' style="cursor:pointer;" class='main' valign='top'>
				  	<table border='0' width='100%' 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);do_actions('edit_category',<?php echo $product['services_categories_id'];?>);"><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);do_actions('delete_category',<?php echo $product['services_categories_id'];?>);"><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);do_actions('move_category',<?php echo $product['services_categories_id'];?>);"><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='170' align='right' id='img_save_<?php echo $product['services_categories_id'];?>' style='visibility:hidden;'><input id="save_button_<?php echo $product['services_categories_id'];?>" type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href="javascript:do_actions('get_details',<?php echo $product['services_categories_id'];?>)"><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['services_categories_id']);?>">
				  		<span id="span_details_<?php echo $product['services_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['services_categories_image']!="")?tep_image(HTTP_SERVER.DIR_WS_CATALOG.'images/'.$product['services_categories_image'],$product['services_categories_image'],'100','100'):'');?></td>
					<td width='500' valign='top'>
						<table width='80%' border='0' cellspacing='5' cellpadding='0' class='main'>
							<?php if($product['date_added']){?>
							<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>
							<?php } ?>
							<?php if($product['last_modified']){?>
							<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>								
							<?php  } ?>					
						</table>
				</tr>
				<tr><td><?php echo tep_draw_separator('pixel_trans.gif','1','5');?></td></tr>
			</table>
		</td>
	</tr>
  </table>
<?php } ?>
<!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>
<?php 
 $file_name=FILENAME_SERVICES_MAINPAGE;
 include(DIR_WS_INCLUDES."date_format_js.php");
 include(DIR_WS_INCLUDES."services.js.php");
 include(DIR_WS_INCLUDES."header.php");
?>
</head> 
<body marginwidth="0"  marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<!-- 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="0" cellpadding="0">
				<tr>
					<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td>
								 <table width="100%" cellpadding="0" cellspacing="0" border="0">
									   <!-- head_1 start -->
									   <tr>
						                 	<td colspan="5">
						                 		<table border="0" cellspacing="0" cellpadding="0" width="100%">
						                 			<tr class="dataTableHeadingRow">
						                 				<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" title="New" id="img_new" href="javascript:do_actions(\'new_category\');">'.tep_image(DIR_WS_IMAGES.'template/img_new.gif','','22','22',' align=absmiddle').'</a>'; ?>
									                 	<td class="dataTableHeadingContent" align="right" valign="bottom" width="300" ><?php echo tep_draw_form('service_search_form',FILENAME_SERVICE_MAINPAGE,'','post','onSubmit="javascript: return service_search_validation();"').'&nbsp;'.TEXT_SEARCH.tep_draw_input_field('service_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="200" ><?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>
						               <!-- head_1 end -->
						               <!-- head_2 start -->
										   <tr class="dataTableHeadingRow" style="height:25">
										   		<td width="3%" class="main">
												<?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">';
													$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="4" width="92%" align="left" class="dataTableHeadingContent"><?php echo TABLE_HEADING_CATEGORIES_SERVICES; ?></td>	
										  </tr>
									  <!-- head_2 end -->
								</table>
						    </td>
						</tr>
						<!-- content start-->											
						<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_SERVICES_MAINPAGE, 'action=file_upload', 'post', ' onSubmit="javascript:return AIM.submit(document.new_product, {\'onStart\' : startCallback_service, \'onComplete\' : completeCallback_service});" enctype="multipart/form-data"'); 							 		  	
										echo '<input type="hidden" name="product_id" id="product_id">' .
											 '<input type="hidden" id="action_type" name="action_type">'.
											 '<input type="hidden" id="image_type" name="image_type">'.
											 '<input type="hidden" id="rec_type" name="rec_type">';
											 echo tep_draw_hidden_field('no_booking_dates');	
									  ?>
									 <div id="new_category"></div>																	
									 <div id="search_result_details"><?php output_sub_result(0,1,'A',0,'',1); ?></div>
									</form>
								  </td>
								</tr>
						     </table>
						  </td>
					   </tr>						
					  <!-- content end-->				
					 </table>
				   </td>
				  </tr>
				<tr>
				<table border="0" width="100%" cellspacing="0" cellpadding="0">
					<tr>
						<td>
						<!-- bottom detalis start -->
						<table border="0" width="100%" cellpadding="5" cellspacing="0">
							<tr style="height:25"><td></td></tr>													
							<tr>
								<td>
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr class="product_title"><td colspan="2"><?php echo '<b>' . TABLE_SERVICE . '</b>'; ?></td></tr>										
									<tr height="7"></tr>									
									<tr>
										<td width="7%">
										<table border="0" cellpadding="0" cellspacing="0">
											<tr><td><?php echo tep_image(DIR_WS_IMAGES . 'services.png', Services);?></td></tr>
										</table>
										</td>
										<td width="93%" valign="top">
											<table width="100%" class="info_content">
												<tr><td class="info_content"><?php echo '<a id="link_categories" href="javascript:do_actions(\'new_category\');">' . IMAGE_NEW_CATEGORY . '</a>'; ?></td></tr>
												<tr><td class="info_content"><?php echo '<a id="link_product" href="javascript:do_actions(\'new_product\');">' . IMAGE_NEW_SERVICE . '</a>';?></td></tr>
											</table>
										</td>
									</tr>	
								  </table>
								 </td>								
							  </tr>																
							  <tr>
								<td>
									<table cellpadding="0" cellspacing="0" width="100%" border="0">
										<tr class="product_title">
											<td colspan="2"><?php echo '<b>' . TABLE_RESOURCE . '</b>'; ?></td>
										</tr>	
										
										<tr height="7"></tr>
										<tr>
											<td width="7%"><?php echo tep_image(DIR_WS_IMAGES . 'resources.png', Resources,'58','70');?></td>		
											<td width="93%" valign="top">
												<table  class="info_content">
													<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_RESOURCES,'top=1') . '">' . RESOURCES . '</a>'; ?></td></tr>
													<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_SERVICES_LOCATIONS,'top=1') . '">' . LOCATIONS . '</a>'; ?></td></tr>
													<tr><td class="info_content"><?php echo '<a href="' . tep_href_link(FILENAME_SERVICES_VIWED,'top=1') . '">' . BEST_VIEWED_SERVICES. '</a>'; ?></td></tr>
											</td>
										</tr>
									</table>
								  </td>
								  <td height="5"></td>
								</tr>
								</table>
							  </td>
						 	</tr>
						 </table>
				 	<!-- bottom detalis end -->
				 	  </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'); ?> 	 
<?php if(isset($HTTP_GET_VARS['create_category']) && tep_db_prepare_input($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_SERVICES_MAINPAGE,'action=edit_category&return=menu');?>');
	</script>
<?php } 
  if(isset($HTTP_GET_VARS['create_service']) && tep_db_prepare_input($HTTP_GET_VARS['create_service'])=='new'){ ?>
	<script langauge="javascript">
	if(document.getElementById("action_type")) document.getElementById("action_type").value='new';
	do_get_command('<?php echo tep_href_link(FILENAME_SERVICES_MAINPAGE,'action=edit_product&return=menu');?>');
	</script>
<?php } ?>