<?php
/*
 osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

osCommRes, Services Online 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	require('includes/application_top.php');
	require('includes/classes/split_page_results_event.php');
	
	$command=isset($HTTP_GET_VARS['command'])?tep_db_prepare_input($HTTP_GET_VARS['command']):'';
	if($command!=''){
	 switch($command){
	 	case 'admin_members_page_navigation':
			global $admin_members_page;
			echo 'load_admin_groups_details^';
			$admin_members_page=isset($HTTP_GET_VARS['admin_members_page'])?tep_db_prepare_input($HTTP_GET_VARS['admin_members_page']):'';
			$admin_groups_id=isset($HTTP_GET_VARS['admin_groups_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_groups_id']):'';
			echo $admin_groups_id.'^';
			load_admin_groups_details($admin_groups_id);
			break;
	 	case 'load_admin_groups_details':
			echo 'load_admin_groups_details^';
			$admin_groups_id=isset($HTTP_GET_VARS['admin_groups_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_groups_id']):'';
			echo $admin_groups_id.'^';
			load_admin_groups_details($admin_groups_id);
			break;
		case 'load_admin_member_details':
			$admin_id=isset($HTTP_GET_VARS['admin_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_id']):'';
			echo 'load_admin_member_details^'.$admin_id.'^';
			load_admin_member_details($admin_id);
			break;
		case 'save_edit_admin_member': 
			$admin_id=isset($HTTP_POST_VARS['admin_id'])?tep_db_prepare_input($HTTP_POST_VARS['admin_id']):'';
			$admin_first_name=isset($HTTP_POST_VARS['admin_first_name'])?tep_db_prepare_input($HTTP_POST_VARS['admin_first_name']):'';
			$admin_last_name=isset($HTTP_POST_VARS['admin_last_name'])?tep_db_prepare_input($HTTP_POST_VARS['admin_last_name']):'';
			$admin_email_address=isset($HTTP_POST_VARS['admin_email_address'])?tep_db_prepare_input($HTTP_POST_VARS['admin_email_address']):'';
			$admin_hide=isset($HTTP_POST_VARS['admin_hide'])?$HTTP_POST_VARS['admin_hide']:'N';
			tep_db_query('update '.TABLE_ADMIN." set admin_firstname='$admin_first_name', admin_lastname='$admin_last_name', admin_email_address='$admin_email_address', admin_hide_backend='$admin_hide',admin_modified=now() where admin_id='$admin_id'");
			$password=isset($HTTP_POST_VARS['admin_password'])?tep_db_prepare_input($HTTP_POST_VARS['admin_password']):'';			
				if ($password!='*****' && $password!='') {
				$admin_password=tep_encrypt_password($password);
				$encription_style=(defined('ENCRYPTION_STYLE'))?ENCRYPTION_STYLE:'O';
				tep_db_query('update '.TABLE_ADMIN." set admin_password='$admin_password',encryption_style='$encription_style' where admin_id='$admin_id'");
				}
			$admin_groups_id_query=tep_db_query('select admin_groups_id from '.TABLE_ADMIN." where admin_id='$admin_id'");
			$admin_groups_id_array=tep_db_fetch_array($admin_groups_id_query);
			$admin_groups_id=$admin_groups_id_array['admin_groups_id'];
			
			if(isset($HTTP_SESSION_VARS['admin_search_string'])){
			echo 'admin_member_search^';
			echo admin_member_search($HTTP_SESSION_VARS['admin_search_string']);
			}
			else{
			echo 'load_admin_groups_details^';
			echo $admin_groups_id.'^';
			load_admin_groups_details($admin_groups_id);
			}
			//echo 'load_admin_member_details^'.$admin_id.'^';
			//load_admin_member_details($admin_id); 
			break;
		case 'save_move_admin_member':
			$admin_id=isset($HTTP_GET_VARS['admin_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_id']):'';
			$move_admin_groups_id=isset($HTTP_GET_VARS['move_admin_groups_id'])?tep_db_prepare_input($HTTP_GET_VARS['move_admin_groups_id']):'';
			tep_db_query('update '.TABLE_ADMIN." set admin_groups_id='$move_admin_groups_id',admin_modified=now() where admin_id='$admin_id' ");
			if(isset($HTTP_SESSION_VARS['admin_search_string'])){
			echo 'admin_member_search^';
			echo admin_member_search($HTTP_SESSION_VARS['admin_search_string']);
			}else{		
			echo 'save_move_admin_member^';	
			echo $move_admin_groups_id.'^';
			load_admin_groups_details($move_admin_groups_id);
			}
			break;
		case 'save_new_admin_member':
			$admin_groups_id=isset($HTTP_POST_VARS['new_admin_groups_id'])?tep_db_prepare_input($HTTP_POST_VARS['new_admin_groups_id']):'';
			$admin_firstname=isset($HTTP_POST_VARS['new_admin_firstname'])?tep_db_prepare_input($HTTP_POST_VARS['new_admin_firstname']):'';
			$admin_lastname=isset($HTTP_POST_VARS['new_admin_lastname'])?tep_db_prepare_input($HTTP_POST_VARS['new_admin_lastname']):'';
			$admin_email_address=isset($HTTP_POST_VARS['new_admin_email_address'])?tep_db_prepare_input($HTTP_POST_VARS['new_admin_email_address']):'';
			$admin_hide=isset($HTTP_POST_VARS['admin_hide'])?tep_db_prepare_input($HTTP_POST_VARS['admin_hide']):'N';
			
			$check_email_query = tep_db_query("select admin_email_address from " . TABLE_ADMIN . "");
				while ($check_email = tep_db_fetch_array($check_email_query)) {
					$stored_email[] = $check_email['admin_email_address'];
				}
			if (in_array($HTTP_POST_VARS['new_admin_email_address'], $stored_email)) {
			echo 'save_new_admin_member_fails^'; exit;
			}
			
			$makePassword = randomize();
				$encription_style=(defined('ENCRYPTION_STYLE'))?ENCRYPTION_STYLE:'O';
				$sql_data_array = array('admin_groups_id' => tep_db_prepare_input($HTTP_POST_VARS['new_admin_groups_id']),
									  'admin_firstname' => tep_db_prepare_input($HTTP_POST_VARS['new_admin_firstname']),
									  'admin_lastname' => tep_db_prepare_input($HTTP_POST_VARS['new_admin_lastname']),
									  'admin_email_address' => tep_db_prepare_input($HTTP_POST_VARS['new_admin_email_address']),
									  'admin_hide_backend'=>(isset($HTTP_POST_VARS['new_admin_hide'])?'Y':'N'),
									  'admin_password' => tep_encrypt_password($makePassword), 'admin_created' => 'now()',
									  'encryption_style'=>$encription_style);
        	
			tep_db_perform(TABLE_ADMIN, $sql_data_array);
			$admin_id = tep_db_insert_id();
			$check_query=tep_db_query("select admin_groups_name from " . TABLE_ADMIN_GROUPS . " where admin_groups_id='" . $admin_groups_id . "'");
	  
				if($check_result=tep_db_fetch_array($check_query))
					$admin_groups_name=$check_result['admin_groups_name'];
				
				if ($admin_groups_name==TEXT_INSTRUCTOR_ENTRY){
					$sql_data_array=array('admin_id'=>$admin_id);
					tep_db_perform(TABLE_INSTRUCTORS,$sql_data_array);
				}
			
			//send email to admin account user
			$merge_details=array(TEXT_FN=>$HTTP_POST_VARS['new_admin_firstname'],
									TEXT_LN=>$HTTP_POST_VARS['new_admin_lastname'] ,
									TEXT_LE=>$HTTP_POST_VARS['new_admin_email_address'],
									TEXT_LP=>$makePassword,
									TEXT_SM=>STORE_NAME,
									TEXT_SN=>STORE_OWNER,
									TEXT_SE=>STORE_OWNER_EMAIL_ADDRESS,
									TEXT_AL=>HTTP_SERVER . DIR_WS_ADMIN);
			$send_details=array(array('to_name'=>$HTTP_POST_VARS['new_admin_firstname'] . ' ' . $HTTP_POST_VARS['new_admin_lastname'],
									 'to_email'=>$HTTP_POST_VARS['new_admin_email_address'],
									 'from_name'=>STORE_OWNER,
									 'from_email'=>STORE_OWNER_EMAIL_ADDRESS));
			tep_send_default_email("AUT",$merge_details,$send_details);
			
			echo 'load_admin_groups_details^';
			echo $admin_groups_id.'^';
			load_admin_groups_details($admin_groups_id);
			break;
		case 'drop_confirm_admin_member':
			$admin_id=isset($HTTP_GET_VARS['admin_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_id']):'';
			$admin_groups_query=tep_db_query('select admin_groups_id from '.TABLE_ADMIN." where admin_id='$admin_id'");
			$admin_groups_array=tep_db_fetch_array($admin_groups_query);
			$admin_groups_id=$admin_groups_array['admin_groups_id'];
			tep_db_query('delete from '.TABLE_ADMIN." where admin_id='$admin_id'");
			if(isset($HTTP_SESSION_VARS['admin_search_string'])){
			echo 'admin_member_search^';
			echo admin_member_search($HTTP_SESSION_VARS['admin_search_string']);
			}else{
			echo 'load_admin_groups_details^';
			echo $admin_groups_id.'^';
			load_admin_groups_details($admin_groups_id);
			}
			break;
		case 'save_new_admin_group':
			$new_admin_group_name=isset($HTTP_GET_VARS['new_admin_group_name'])?tep_db_prepare_input($HTTP_GET_VARS['new_admin_group_name']):'';
			tep_db_query('insert into '.TABLE_ADMIN_GROUPS." (admin_groups_name) values('$new_admin_group_name')");
			echo 'save_new_admin_group^';
			load_admin_groups();
			break;
		case 'save_edit_admin_group':
			$admin_group_name=isset($HTTP_GET_VARS['admin_group_name'])?tep_db_prepare_input($HTTP_GET_VARS['admin_group_name']):'';
			$admin_groups_id=isset($HTTP_GET_VARS['admin_groups_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_groups_id']):'';
			tep_db_query('update '.TABLE_ADMIN_GROUPS." set admin_groups_name='$admin_group_name' where admin_groups_id='$admin_groups_id'");
			echo 'save_new_admin_group^';
			load_admin_groups();
			break;
		case 'drop_confirm_admin_groups':
			$admin_groups_id=isset($HTTP_GET_VARS['admin_groups_id'])?tep_db_prepare_input($HTTP_GET_VARS['admin_groups_id']):'';
			tep_db_query('delete from '.TABLE_ADMIN_GROUPS." where admin_groups_id='$admin_groups_id'");
			tep_db_query('delete from '.TABLE_ADMIN." where admin_groups_id='$admin_groups_id'");
			echo 'save_new_admin_group^';
			load_admin_groups();
			break;
		case 'admin_member_search':
			echo 'admin_member_search^';
			$search_string=isset($HTTP_GET_VARS['search_string'])?tep_db_prepare_input($HTTP_GET_VARS['search_string']):'';
			$HTTP_SESSION_VARS['admin_search_string']=$search_string;
			global $search_page_no;
			$search_page_no=isset($HTTP_GET_VARS['search_page_no'])?tep_db_prepare_input($HTTP_GET_VARS['search_page_no']):1;
			echo admin_member_search($search_string);
			break;
		case 'search_reset':
			echo 'search_reset^';
			unset($HTTP_SESSION_VARS['admin_search_string']);
			echo load_admin_groups();
			break;
	 } // switch end
	exit;
	} // if end

	function admin_member_search($search_string){
	global $search_page_no;
	$search_condition=" admin_firstname like '%" . tep_db_input($search_string) . "%' or admin_lastname like '%" . tep_db_input($search_string) . "%' or admin_email_address like '%" . tep_db_input($search_string) . "%' ";
	$admin_members_query_raw='select admin_id,admin_firstname,admin_lastname from '.TABLE_ADMIN." where ".$search_condition."  order by admin_firstname";
	$admin_members_split = new splitPageResultsEvent($search_page_no, MAX_DISPLAY_SEARCH_RESULTS, $admin_members_query_raw, $admin_members_numrows);	    	
	$admin_members_query=tep_db_query($admin_members_query_raw);
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
		if(tep_db_num_rows($admin_members_query)<=0)
			echo '<tr><td colspan="2" class="main" style="color:#FF0000;" align="center">No Records Found</td></tr>';
	$class_name='dataTableRowOdd';
	while($admin_members_array=tep_db_fetch_array($admin_members_query)){
	$class_name=($class_name=='dataTableRowOdd')?'dataTableRowEven':'dataTableRowOdd';
	?>
	<tr id="admin_members_row_<?php echo $admin_members_array['admin_id']; ?>">
	<td>
		<div onClick="javascript: load_admin_member_details(<?php echo $admin_members_array['admin_id']; ?>)" id="admin_members_<?php echo $admin_members_array['admin_id']; ?>" class="<?php echo $class_name; ?>" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);">
		<?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$admin_members_array['admin_firstname'].'&nbsp;'.$admin_members_array['admin_lastname']; ?>
		</div>
		<div id="ajax_admin_members_<?php echo $admin_members_array['admin_id']; ?>">
		</div>
	</td>
	</tr>
	<?php
	}	
	echo '<tr><td colspan="2"><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td class="smallText" width="300">'.$admin_members_split->display_count($admin_members_numrows, MAX_DISPLAY_SEARCH_RESULTS, $search_page_no, TEXT_DISPLAY_NUMBER_OF_MEMBERS).'</td><td class="smallText" align="right">'.
  	$admin_members_split->display_script_links($admin_members_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $search_page_no,1,'admin_search_page_navigation(\'\'','1').'</td></tr></table><br> </td></tr>';
	echo '<tr><td align="right" colspan="2"><a href="javascript: reset_search();">'.tep_image_button('button_reset.gif').'</a>&nbsp;&nbsp;</td></tr>';
	echo '</table>';
	}	

	function randomize() {
		$salt = "abchefghjkmnpqrstuvwxyz0123456789";
		srand((double)microtime()*1000000); 
		$i = 0;
		while ($i <= 7) {
			$num = rand() % 33;
			$tmp = substr($salt, $num, 1);
			$pass = $pass . $tmp;
			$i++;
		}
		return $pass;
	}

?>

	<?php
	function load_admin_groups(){

	$admin_groups_query=tep_db_query('select admin_groups_id,admin_groups_name,admin_groups_type from '.TABLE_ADMIN_GROUPS.' order by admin_groups_id');
	$cnt=0; 
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
	while($admin_groups_array=tep_db_fetch_array($admin_groups_query)){ 
	$class_name=($cnt%2==0)?'dataTableRowEven':'dataTableRowOdd'; $cnt++;
	?>
	<tr id="admin_row_<?php $admin_groups_array['admin_groups_id']; ?>">
	<td width="10">&nbsp;</td>
	<td>
		<div onClick="javascript: admin_groups_focus(<?php echo $admin_groups_array['admin_groups_id']; ?>);" id="admin_groups_<?php echo $admin_groups_array['admin_groups_id']; ?>" class="<?php echo $class_name; ?>" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);">
		<?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$admin_groups_array['admin_groups_name']; ?>
		</div>
		<div id="ajax_admin_groups_<?php echo $admin_groups_array['admin_groups_id']; ?>" style="display:none;">
		</div>
	</td>
	</tr>
	<?php
	}
	echo '</table>';
	}
	
	function load_admin_groups_details($admin_groups_id){
	global $admin_members_page,$HTTP_SESSION_VARS;
	$HTTP_SESSION_VARS['shop_admin_groups_id']=$admin_groups_id;
	$admin_groups_name_query=tep_db_query("select admin_groups_name,admin_groups_type from ".TABLE_ADMIN_GROUPS." where admin_groups_id='$admin_groups_id'");
	$admin_groups_name_array=tep_db_fetch_array($admin_groups_name_query);
	$admin_members_query_raw='select admin_id,admin_firstname,admin_lastname from '.TABLE_ADMIN." where admin_groups_id='$admin_groups_id' order by admin_firstname";
	$admin_members_split = new splitPageResultsEvent($admin_members_page, MAX_DISPLAY_SEARCH_RESULTS, $admin_members_query_raw, $admin_members_numrows);	    
    $admin_members_query = tep_db_query($admin_members_query_raw);	
	if($admin_groups_name_array['admin_groups_type']=='E')
		$width="50";
	else 
		$width="80";
		//javascript: close_admin_groups('<?php echo $admin_groups_id;');
	?>
	<table border="0" cellpadding="0" cellspacing="0" width="100%" class="openContent">
	<tr class="openContent_top" style="">
	<td width="470" class="main"><?php echo tep_image(DIR_WS_IMAGES . "template/icon_active.gif").'&nbsp;&nbsp;'.$admin_groups_name_array['admin_groups_name']; ?></td>			
	<td  width="<?php echo $width; ?>" align="center">
	<?php if($admin_groups_name_array['admin_groups_type']=='D') { ?>
	<table style="background:#DEE4F5;cursor:pointer;" width="100%" border="0" cellpadding="0" id="admin_group_header_operation" cellspacing="0">
	<tr>
		<td class="cell_bg_popm_left" width="10%">&nbsp;</td>
		<?php echo   '<td width="10%" onClick="javascript:do_hover_change1(this,1);admin_group_edit('.$admin_groups_id.');" onMouseOver="javascript:do_hover_change1(this,2);" onMouseOut="javascript:do_hover_change1(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'; ?>
		<?php echo   '<td width="10%" onClick="javascript:do_hover_change1(this,1);drop_admin_groups('.$admin_groups_id.');" onMouseOver="javascript:do_hover_change1(this,2);" onMouseOut="javascript:do_hover_change1(this,3);"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'; ?>
	<td class="cell_bg_popm_right" width="10">&nbsp;</td>
	</tr>
	</table>
	<?php } ?>
	</td>
	<td align="right"><?php 
	echo '<a id="admin_group_operation" style="display:none;">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','').'</a>&nbsp;&nbsp;';
	echo '<a href="javascript: close_admin_groups('.$admin_groups_id.');">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','').'</a>'; ?>&nbsp;</td>
	</tr>
	<tr>
	<td colspan="4" id="admin_group_edit_details" style="display:none;" align="center"><br><?php echo TABLE_HEADING_GROUPS_NAME.'&nbsp;&nbsp;'.tep_draw_input_field('edit_admin_groups_name',$admin_groups_name_array['admin_groups_name']); ?><br></td>
	</tr>
	<tr>
	<td colspan="4" id="admin_group_delete_details" style="display:none;" align="center"><br><?php echo TEXT_INFO_DELETE_GROUPS_INTRO; ?><br></td>
	</tr>
	<tr>
	<td colspan="4" style="padding-top:5px;padding-bottom:5px;">
	<?php
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
		if(tep_db_num_rows($admin_members_query)<=0)
			echo '<tr><td align="center" class="main" style="color:#FF0000;">'.TEXT_NO_ADMIN_MEMBER_FOUND.'</td></tr>';
	$cnt=0;
	while($admin_members_array=tep_db_fetch_array($admin_members_query)){
	$class_name=($cnt%2==0)?'subdataTableRowEven':'subdataTableRowOdd'; $cnt++;
	?>
	<tr id="admin_members_row_<?php echo $admin_members_array['admin_id']; ?>" style="cursor:hand; cursor:pointer">

	<td style="padding-left:40px;">
		<div onClick="javascript: load_admin_member_details(<?php echo $admin_members_array['admin_id']; ?>)" id="admin_members_<?php echo $admin_members_array['admin_id']; ?>" class="<?php echo $class_name; ?>" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);">
		<?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$admin_members_array['admin_firstname'].'&nbsp;'.$admin_members_array['admin_lastname']; ?>
		</div>
		<div id="ajax_admin_members_<?php echo $admin_members_array['admin_id']; ?>">
		</div>
	</td>
	</tr>
	<?php	
	}
	echo '<tr><td><table width="100%" cellpadding="0" style="padding-top:5px;" cellspacing="0" border="0"><tr><td width="15"></td><td class="smallText" width="300">'.$admin_members_split->display_count($admin_members_numrows, MAX_DISPLAY_SEARCH_RESULTS, $admin_members_page, TEXT_DISPLAY_NUMBER_OF_MEMBERS).'</td><td class="smallText" align="right">'.
  	$admin_members_split->display_script_links($admin_members_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $admin_members_page,1,'admin_member_page_navigation(\'\'','1').'</td></tr></table><br> </td></tr>';
  	echo '</table> </td></tr> <tr><td colspan="4">';
		//if(tep_db_num_rows($admin_members_query)<=0){
		load_new_admin_member($admin_groups_id);
		//}
	//load_new_admin_group();
	}
	function load_new_admin_member($admin_groups_id){
	?>
		<table style="background:#DEE4F5;display:none;" width="100%" cellpadding="2" id="new_admin_member_id" cellspacing="2" border="0">
		<tr><td width="300"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.TEXT_INFO_HEADING_NEW; ?></td>
		<td align="right"><?php echo '<a href="javascript: save_new_admin_member()">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','').'</a>&nbsp;&nbsp;<a href="javascript: new_admin_member_close();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','').'</a>'; ?></td>
		</tr>
		<tr>
		<td colspan="2">
		<?php echo tep_draw_form('new_admin_member_form',FILENAME_SHOP_ADMIN_MEMBERS,'','post').tep_draw_hidden_field('new_admin_groups_id',$admin_groups_id); ?>
		<table width="100%" cellpadding="2" cellspacing="2" border="0">
		<tr>
		<td width="200" align="right"><?php echo TEXT_INFO_FIRSTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('new_admin_firstname'); ?></td>
		<td width="200" align="right"><?php echo TEXT_INFO_LASTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('new_admin_lastname'); ?></td>
		</tr>
		<tr>
		<td align="right"><?php echo TEXT_INFO_EMAIL; ?></td>
		<td><?php echo tep_draw_input_field('new_admin_email_address'); ?></td>
		<td align="right"><?php echo TEXT_ADMIN_HIDE; ?></td>
		<td><?php echo tep_draw_checkbox_field('new_admin_hide','Y'); ?></td>
		</tr>
		</table><br></form></td>
		</tr>
		</table>
	<?php
		echo '</td></tr></table>';
	}
	
	function load_new_admin_group(){
	?>
	<table style="background:#DEE4F5;display:none;" id="new_admin_group_id" width="100%" border="0"  cellpadding="0" cellspacing="0" border="0">
	<tr>
	<td width="20">&nbsp;</td>
	<td width="300"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.TEXT_INFO_HEADING_GROUPS; ?></td>
	<td align="right"><?php echo '<a href="javascript: save_new_admin_group();">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','').'</a>&nbsp;&nbsp;<a href="javascript: new_admin_groups_close();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','').'</a>'; ?></td>
	</tr>
	<tr>
	<td colspan="3" align="center"><?php echo TEXT_GROUP_NAME.'&nbsp;&nbsp;'.tep_draw_input_field('new_admin_group_name'); ?></td>
	</tr>
	<tr><td colspan="3"><br></td></tr>
	</table>
	<?php
	}
	
	function load_admin_member_details($admin_id){ global $HTTP_SESSION_VARS;
	$global_login_id=isset($HTTP_SESSION_VARS['login_id'])?$HTTP_SESSION_VARS['login_id']:'';
	$admin_query=tep_db_query('select admin_groups_id,admin_firstname,admin_lastname,admin_email_address,admin_created,admin_modified,admin_lognum,admin_hide_backend from '.TABLE_ADMIN." where admin_id='$admin_id'");
	$admin_array=tep_db_fetch_array($admin_query);
	$admin_obj=new objectInfo($admin_array);
	$admin_groups_query=tep_db_query('select admin_groups_name from '.TABLE_ADMIN_GROUPS." where admin_groups_id='$admin_obj->admin_groups_id'");
	$admin_groups_array=tep_db_fetch_array($admin_groups_query);
	?>
	<table border="0" cellpadding="0" cellspacing="0" width="100%" class="openContent">
<!--	<tr class="openContent_top" onClick="javascript: close_admin_groups('<?php //echo $admin_groups_id;?>');" style="cursor:hand; cursor:pointer">
-->	
	<tr>
	<td width="400" class="main"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$admin_obj->admin_firstname.'&nbsp;'.$admin_obj->admin_lastname; ?></td>			
	<td width="100" align="center">
	<table style="background:#DEE4F5;cursor:pointer;" width="100%" border="0" cellpadding="0" id="header_operation_id" cellspacing="0">
	<tr>
	<td class="cell_bg_popm_left" width="10">&nbsp;</td>
	<!-- <td> !--><?php //echo '<a onClick="javascript: new_admin_member('.$admin_id.');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,1);">'.tep_image(DIR_WS_IMAGES.'template/img_copy.gif').'</a>';
	echo '<td width="10%" OnClick="javascript: do_hover_change(this,1); edit_admin_member('.$admin_id.');"  onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'; ?>

	<?php if($global_login_id!=$admin_id)
	echo '<td OnClick="javascript: do_hover_change(this,1); move_admin_member('.$admin_id.');" onMouseOut="javascript:do_hover_change(this,3);" onMouseOver="javascript:do_hover_change(this,2);"><img alt="Move" title="Move" src="images/template/img_move.gif"></td>';?>
	<?php
	echo '<td onclick="javascript: do_hover_change(this,1); drop_admin_member('.$admin_id.');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'; ?>
	<td class="cell_bg_popm_right" width="10">&nbsp;</td>
	</tr>
	</table>
	</td>
<!--	<td width="570" align="right"><?php //echo '<a id="admin_member_operation" style="display:none;">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','').'</a>'.'&nbsp;&nbsp;<a id="admin_member_close_button" style="display:none;" href="javascript: do_member_close();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','').'</a>'; ?>&nbsp;</td>
-->	
	<td width="570" align="right"><a href="#" id="admin_member_operation" style="display:none;"><?php echo tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','');?></a>&nbsp;&nbsp;<a href="javascript: do_member_close();" id="admin_member_close_button" style="display:none;"><?php echo tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','',''); ?></a></td>
 </tr>
	<tr id="preview_details">
		<td colspan="4"><table width="100%" cellpadding="2" cellspacing="2" border="0">
		<tr>
		<td width="80" align="right"><?php echo TEXT_INFO_FULLNAME; ?></td>
		<td align="left" width="100"><?php echo $admin_obj->admin_firstname.'&nbsp;'.$admin_obj->admin_lastname; ?></td>
		<td width="80" align="right"><?php echo TEXT_INFO_EMAIL; ?></td>
		<td width="80" align="left"><?php echo $admin_obj->admin_email_address; ?></td>
		<td width="100" align="right"><?php echo TEXT_INFO_GROUP; ?></td>
		<td width="150" align="left"><?php echo $admin_groups_array['admin_groups_name']; ?></td>
		</tr>
		<tr>
		<td align="right"><?php echo TEXT_INFO_CREATED; ?></td>
		<td align="left"><?php echo $admin_obj->admin_created; ?></td>
		<td align="right"><?php echo TEXT_ADMIN_HIDE; ?></td>
		<td align="left"><?php echo ($admin_obj->admin_hide_backend=='N')?'No':'Yes'; ?></td>
		<td align="right"><?php echo TEXT_INFO_LOGNUM; ?></td>
		<td align="left"><?php echo $admin_obj->admin_lognum; ?></td>
		</tr>
		</table><br></td>
	</tr>
	<tr id="admin_member_edit_details" style="display:none;">
		<td colspan="4">
		<?php echo tep_draw_form('edit_admin_member_form',FILENAME_SHOP_ADMIN_MEMBERS,'','post').tep_draw_hidden_field('admin_id',$admin_id); ?>
		<table width="100%" cellpadding="2" cellspacing="2" border="0">
		<tr>
		<td width="200" align="right"><?php echo TEXT_INFO_FIRSTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('admin_first_name',$admin_obj->admin_firstname); ?></td>
		<td width="200" align="right"><?php echo TEXT_INFO_LASTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('admin_last_name',$admin_obj->admin_lastname); ?></td>
		</tr>
		<tr>
		<td align="right"><?php echo TEXT_INFO_EMAIL; ?></td>
		<td><?php echo tep_draw_input_field('admin_email_address',$admin_obj->admin_email_address); ?></td>
		<td align="right"><?php echo TEXT_ADMIN_HIDE; ?></td>
		<td><?php echo tep_draw_checkbox_field('admin_hide','Y',($admin_obj->admin_hide_backend=='Y')?' checked ':''); ?></td>
		</tr>
		<?php if($admin_groups_array['admin_group_name']!=TEXT_ADMINISTRATOR_ENTRY){ ?>
		<tr>
		<td align="right"><?php echo TABLE_HEADING_PASSWORD; ?></td>
		<td colspan="3"><?php echo tep_draw_input_field('admin_password','*****','maxlength="40"  onKeyUp="javascript:do_pwd_check(this);" onfocus="this.value=\'\'"; onblur="if (this.value==\'\') this.value=\'*****\';"', false); ?><span id = "pwd_str" style="font-color:red;font-size:14;display:none;" ></span></td>
		</tr>
		<?php } ?>
		</table><br></form></td>
	</tr>
	<tr id="new_admin_member_details" style="display:none;">
		<td colspan="4">
		<!-- <?php echo tep_draw_form('new_admin_member_form',FILENAME_SHOP_ADMIN_MEMBERS,'','post').tep_draw_hidden_field('new_admin_groups_id',$admin_obj->admin_groups_id); ?>
		<table width="100%" cellpadding="2" cellspacing="2" border="0">
		<tr>
		<td width="200" align="right"><?php echo TEXT_INFO_FIRSTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('new_admin_firstname'); ?></td>
		<td width="200" align="right"><?php echo TEXT_INFO_LASTNAME; ?></td>
		<td width="200"><?php echo tep_draw_input_field('new_admin_lastname'); ?></td>
		</tr>
		<tr>
		<td align="right"><?php echo TEXT_INFO_EMAIL; ?></td>
		<td><?php echo tep_draw_input_field('new_admin_email_address'); ?></td>
		<td align="right"><?php echo TEXT_ADMIN_HIDE; ?></td>
		<td><?php echo tep_draw_checkbox_field('new_admin_hide','Y'); ?></td>
		</tr>
		</table><br></form></td> -->
	</tr>
	<tr id="admin_member_move_details" style="display:none;">
	<?php $admin_groups_array=array();
		$admin_groups_name_query=tep_db_query('select admin_groups_id,admin_groups_name from '.TABLE_ADMIN_GROUPS." where admin_groups_id!='$admin_obj->admin_groups_id'");
		
		while($admin_groups_name_array=tep_db_fetch_array($admin_groups_name_query)){
		$admin_groups_array[]=array('id'=>$admin_groups_name_array['admin_groups_id'],'text'=>$admin_groups_name_array['admin_groups_name']);
		}
	?>
		<td colspan="4" align="center"><br>
		<?php echo TABLE_HEADING_GROUPS.'&nbsp;&nbsp;'.tep_draw_pull_down_menu('move_admin_groups_id',$admin_groups_array); ?>
		<br><br>
		</td>
	</tr>
	<tr id="admin_member_delete_warning" style="display:none;"> 
		<td colspan="4" align="center"><br>
		<?php echo sprintf(TEXT_INFO_DELETE_INTRO,$admin_obj->admin_firstname.'	'.$admin_obj->admin_lastname); ?>
		<br><br></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/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>
<?php require('includes/password_strength.js.php');?>
<script>
 function do_pwd_check(obj)
 { 
  <?php //if((MODULE_ADMIN_PASSWORD_STRENGTH=){?>	
 	pwd=obj.value;
	var password=document.getElementById('pwd_str');
	password.style.display="";
	if(pwd.length==0)
	  password.innerHTML='';
	else if(pwd.length<<?php echo ENTRY_PASSWORD_MIN_LENGTH;?>)
		password.innerHTML='<?php echo ENTRY_PASSWORD_STRENGTH_ERROR;?>';
	else if(!check_password_strength(pwd))
		password.innerHTML='<?php echo ENTRY_PASSWORD_STRENGTH_ERROR;?>';
	else
		password.innerHTML='';
   <?php //} ?>	 
 }
</script>

<?php require('includes/account_check.js.php'); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<?php
	$admin_groups_query=tep_db_query('select admin_groups_id,admin_groups_name from '.TABLE_ADMIN_GROUPS.' order by admin_groups_id');
	$admin_groups_array=array();
	while($groups_array=tep_db_fetch_array($admin_groups_query))
		$admin_groups_array[]=array('id'=>$groups_array['admin_groups_id'],'text'=>$groups_array['admin_groups_name']);
?>

<!-- Ajax Work Starts -->
<div id="error_message" style="color:red;"></div>
<table width="100%" cellpadding="5" cellspacing="3" border="0">
<tr height="40px;" style="padding-top:5px;"><td align="right"><table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr class="dataTableHeadingRow">
	<td  width="200" valign="middle"><?php echo '<a onMouseOver="new_do_hover_change(this,2);" onMouseOut="new_do_hover_change(this,1);" id="header_new_operation" href="javascript: new_admin_groups();">'.tep_image(DIR_WS_IMAGES.'template/img_new.gif','New','','','align="absmiddle"').'</a>'; ?></td>
	<td class="main" align="right">
	<?php echo HEADING_TITLE_SEARCH.'&nbsp;&nbsp;'.tep_draw_form('admin_member_search_form',FILENAME_SHOP_ADMIN_MEMBERS,'','post','onSubmit="javascript: return searchValidation();"').tep_draw_input_field('admin_member_search').'&nbsp;&nbsp;<a href="javascript: button_searchValidation();">'.tep_image(DIR_WS_IMAGES.'template/img_search.gif','Search','','','align="absbottom"').'</a></form>&nbsp;&nbsp;'.HEADING_TITLE_GOTO.'&nbsp;&nbsp;'.tep_draw_pull_down_menu('to_admin_groups_id',$admin_groups_array,'1',' onChange="javascript: admin_groups_focus(this.value);" ') . '&nbsp;'; ?>
	</td></tr></table></td></tr>
<tr>
	<td id="heading_title" class="pageHeading"><?php echo HEADING_TITLE; ?></td>
</tr>
<tr>
	<td id="primary_admin_group_table">
	<?php load_admin_groups(); ?>
	</td>
</tr>
	<tr>
	<td>
	<?php load_new_admin_group(); ?>
	</td>
	</tr>
</table>
<?php  unset($HTTP_SESSION_VARS['shop_admin_groups_id']); unset($HTTP_SESSION_VARS['admin_search_string']);  ?>

<!-- Ajax Work Ends -->

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

<script language="javascript">
var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>",search_string='';
var ajax_image_load='<?php echo tep_image(DIR_WS_IMAGES.'24-1.gif'); ?>',previous_admin_groups_id='',previous_admin_id='';
	var display_flag=1;
	var close_obj=false;
		function new_do_hover_change(element,mode){
		if(display_flag==1){
		if (element.mode && mode==element.mode) return;
		if (mode==2)
			element.firstChild.src=element.firstChild.src.replace(".gif","_hover.gif");
		else
			element.firstChild.src=element.firstChild.src.replace("_hover.gif",".gif");
		}
		element.mode=mode;
		}

	function searchValidation(){
	search_string=document.getElementById('admin_member_search').value;	
		if(search_string!=''){
		document.getElementById('header_new_operation').style.visibility='hidden';
		document.getElementById('to_admin_groups_id').disabled=true;
		document.getElementById('primary_admin_group_table').innerHTML=ajax_image_load;
		do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_member_search&search_string='); ?>'+search_string);
		document.getElementById('heading_title').innerHTML='Admin Members';
		}
	return false;
	}
	function button_searchValidation(){
	search_string=document.getElementById('admin_member_search').value;	
		if(search_string!=''){
		document.getElementById('header_new_operation').style.visibility='hidden';
		document.getElementById('to_admin_groups_id').disabled=true;
		document.getElementById('primary_admin_group_table').innerHTML=ajax_image_load;
		do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_member_search&search_string='); ?>'+search_string);
		document.getElementById('heading_title').innerHTML='Admin Members';
		}
	}
	function admin_search_page_navigation(arg1,agr2,agr3,agr4){
		var page_no=1;
		if(agr2==1) var obj=document.getElementById("page_1");
		else if(agr2==2) var obj=document.getElementById("page_2");
		if(agr2 && agr4){
			if(obj){
 	 			page_no=parseInt(obj.options[obj.selectedIndex].value);
 	 			if(agr4=='next') {
 	 				if(obj.length==obj.selectedIndex+1) return;
 	 				page_no+=1;
 	 			}else if(agr4=='prev') {
	 	 			if(obj.selectedIndex==0) return;
 		 			page_no-=1;
 	 			}
 	 			if(page_no<=1) page_no=1;
 	 		} 	 		
		}				
		if(agr2==1) command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_member_search'); ?>&search_page_no="+page_no+'&search_string='+search_string;
		else if(agr2==2) command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_member_search'); ?>&search_page_no="+page_no+'&search_string='+search_string;
		if(command!=""){
		document.getElementById('primary_admin_group_table').innerHTML=ajax_image_load;
		 do_get_command(command);
		}
	}
	
	function reset_search(){
	document.getElementById('header_new_operation').style.visibility='visible';
	document.getElementById('admin_member_search').value='';
	document.getElementById('to_admin_groups_id').disabled=false;
	document.getElementById('primary_admin_group_table').innerHTML=ajax_image_load;
	document.getElementById('header_new_operation').href="javascript: new_admin_groups();";
	do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=search_reset'); ?>');
	document.getElementById('heading_title').innerHTML='<?php echo HEADING_TITLE; ?>';
	}
	
	function admin_groups_focus(admin_groups_id){
	new_admin_groups_close();
		if(previous_admin_groups_id!='')
			close_admin_groups(previous_admin_groups_id);
	document.getElementById('ajax_admin_groups_'+admin_groups_id).style.display='';
	document.getElementById('ajax_admin_groups_'+admin_groups_id).innerHTML=ajax_image_load;
	var command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=load_admin_groups_details&admin_groups_id='); ?>"+admin_groups_id;
	do_get_command(command);
	previous_admin_groups_id=admin_groups_id;	
		document.getElementById('header_new_operation').href='javascript: new_admin_member();';
	}
admin_groups_focus(1);
	function new_admin_member(){
	display_flag=0;
		document.getElementById('new_admin_member_id').style.display='';
		/*if(document.getElementById('header_operation_id'))
			document.getElementById('header_operation_id').style.display='none';*/
			if(previous_admin_id!='')
			close_admin_member(previous_admin_id);
	}
	function new_admin_member_close(){
	change_new_image();
		document.getElementById('new_admin_member_id').style.display='none';
		if(document.getElementById('header_operation_id'))
			document.getElementById('header_operation_id').style.display='';
		document.getElementById('new_admin_firstname').value='';
		document.getElementById('new_admin_lastname').value='';
		document.getElementById('new_admin_email_address').value='';
		document.getElementById('new_admin_hide').checked=false;
	}
	function close_admin_groups(admin_groups_id){
	change_new_image();
		if(document.getElementById('admin_groups_'+admin_groups_id) && document.getElementById('ajax_admin_groups_'+admin_groups_id)){
		document.getElementById('ajax_admin_groups_'+admin_groups_id).innerHTML='';
		document.getElementById('ajax_admin_groups_'+admin_groups_id).style.display='none';
		document.getElementById('admin_groups_'+admin_groups_id).style.display='';
		}	
	document.getElementById('header_new_operation').href='javascript: new_admin_groups();';
	}
	function new_admin_groups(){
	display_flag=0;
		/*document.getElementById('admin_group_edit_details').style.display='none';
		document.getElementById('admin_group_operation').style.display='none';
		document.getElementById('admin_group_delete_details').style.display='none';*/
	document.getElementById('new_admin_group_id').style.display='';
		/*if(document.getElementById('new_admin_member_id'))
		document.getElementById('new_admin_member_id').style.display='none';*/
	}
	function change_new_image(){
	display_flag=1;
	document.getElementById('header_new_operation').firstChild.src=document.getElementById('header_new_operation').firstChild.src.replace('_hover.gif','.gif');
	}
	function new_admin_groups_close(){
	change_new_image();
	document.getElementById('new_admin_group_id').style.display='none';
	document.getElementById('new_admin_group_name').value='';
	}
	function save_new_admin_group(){
	var error=false,error_message='';
	var new_admin_group_name=document.getElementById('new_admin_group_name').value;
		if(new_admin_group_name=='' || str_trim(new_admin_group_name)==''){ error=true;
		error_message='<?php echo ERROR_ADMIN_GROUP; ?>';
		}
		if(new_admin_group_name.length<5){ error=true;
		error_message+='\n<?php echo ERROR_ADMIN_GROUP_LENGTH; ?>';
		}
		if(error==true)
			alert(error_message);
		else{ 
			change_new_image();
			do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=save_new_admin_group&new_admin_group_name='); ?>'+new_admin_group_name);
		}
	}
	function save_edit_admin_group(admin_groups_id){
	var group_name=document.getElementById('edit_admin_groups_name').value;
	var error=false,error_message='';
		if(group_name=='' || str_trim(group_name)==''){ error=true;
		error_message='<?php echo ERROR_ADMIN_GROUP; ?>';
		}
		if(group_name.length<5){ error=true;
		error_message+='\n<?php echo ERROR_ADMIN_GROUP_LENGTH; ?>';
		}
		if(error==true)
			alert(error_message);
		else
			do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=save_edit_admin_group&admin_groups_id='); ?>'+admin_groups_id+'&admin_group_name='+group_name);
	}
	function admin_group_edit(admin_groups_id){
		document.getElementById('admin_group_edit_details').style.display='';
		document.getElementById('admin_group_operation').style.display='';
		document.getElementById('admin_group_operation').href="javascript: save_edit_admin_group("+admin_groups_id+")";
		if(document.getElementById('new_admin_member_id'))
			document.getElementById('new_admin_member_id').style.display='none';
		if(document.getElementById('new_admin_group_id'))
			document.getElementById('new_admin_group_id').style.display='none';
		document.getElementById('admin_group_delete_details').style.display='none';
	}
	function drop_admin_groups(admin_groups_id){
		document.getElementById('admin_group_edit_details').style.display='none';
		document.getElementById('admin_group_operation').style.display='';
		document.getElementById('admin_group_operation').href="javascript: drop_confirm_admin_groups("+admin_groups_id+")";
		if(document.getElementById('new_admin_member_id'))
			document.getElementById('new_admin_member_id').style.display='none';
		if(document.getElementById('new_admin_group_id'))
			document.getElementById('new_admin_group_id').style.display='none';
		document.getElementById('admin_group_delete_details').style.display='';
	}
	function drop_confirm_admin_groups(admin_groups_id){
	do_get_command('<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=drop_confirm_admin_groups&admin_groups_id='); ?>'+admin_groups_id);
	}
	function load_admin_member_details(admin_id){
	new_admin_member_close();
		if(previous_admin_id!='') {
			close_obj=false;
			close_admin_member(previous_admin_id);
		}	
		document.getElementById('ajax_admin_members_'+admin_id).style.display='';
		document.getElementById('ajax_admin_members_'+admin_id).innerHTML=ajax_image_load;
		var command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=load_admin_member_details&admin_id='); ?>"+admin_id;
		do_get_command(command);
		previous_admin_id=admin_id;
		if(document.getElementById('admin_group_header_operation'))	
			document.getElementById('admin_group_header_operation').style.display='none';
		if(document.getElementById('admin_group_edit_details'))
			document.getElementById('admin_group_edit_details').style.display='none';
	}
	function close_admin_member(admin_id){ 
		if(document.getElementById('ajax_admin_members_'+admin_id) && document.getElementById('admin_members_'+admin_id)){
		document.getElementById('ajax_admin_members_'+admin_id).innerHTML='';
		document.getElementById('ajax_admin_members_'+admin_id).style.display='none';
		document.getElementById('admin_members_'+admin_id).style.display='';
		}
	if(document.getElementById('admin_group_header_operation'))	
	document.getElementById('admin_group_header_operation').style.display='';
	}
	function edit_admin_member(admin_id){ close_obj=true;
		close_all_admin_member_panel();
		document.getElementById('admin_member_edit_details').style.display='';
		document.getElementById('admin_member_operation').style.display='';
		document.getElementById('admin_member_close_button').style.display='';
		document.getElementById('admin_member_operation').href="javascript: save_edit_admin_member();";
	}
	function save_new_admin_member(){
	var error=false,error_message='';
	var adminEmail=document.getElementById('new_admin_email_address').value;
	var firstname=document.getElementById('new_admin_firstname').value;
	var lastname=document.getElementById('new_admin_lastname').value;

		if(firstname=='' || str_trim(firstname)==''){ error=true;
		error_message='<?php echo ERROR_FIRST_NAME; ?>';
		}
		if(lastname=='' || str_trim(lastname)==''){ error=true;
		error_message+='\n<?php echo ERROR_LAST_NAME; ?>';
		}
		if( (adminEmail=='') || (str_trim(adminEmail)=="") ) { error=true;
   		error_message+='\n<?php echo JS_ALERT_EMAIL; ?>';
 		} else if (adminEmail.indexOf("@") <= 1 || adminEmail.indexOf("@") >= (adminEmail.length - 3) || adminEmail.indexOf(".") <= 3 || adminEmail.indexOf(".") >= (adminEmail.length - 2) || adminEmail.indexOf("@.") >= 0 ) {
		error=true;
    	error_message+='\n<?php echo JS_ALERT_EMAIL_FORMAT; ?>';
  		} else if (adminEmail.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
		error=true;
    	error_message+='\n<?php echo JS_ALERT_EMAIL_FORMAT; ?>';
  		}

		if(error==true)
			alert(error_message);
		else{
			change_new_image();
			do_post_command('new_admin_member_form','<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=save_new_admin_member'); ?>');
		}
	//if(previous_admin_id!='' && document.getElementById('admin_members_'+previous_admin_id))
		//document.getElementById('admin_members_'+previous_admin_id).innerHTML=ajax_image_load;	
	}
	
	/*function new_admin_member(admin_id){
	close_all_admin_member_panel();
	document.getElementById('new_admin_member_details').style.display='';
	document.getElementById('admin_member_operation').href="javascript: save_new_admin_member();";
	}*/
	function save_edit_admin_member(){
	var adminEmail=document.edit_admin_member_form.admin_email_address.value;
	var firstname=document.edit_admin_member_form.admin_first_name.value;
	var lastname=document.edit_admin_member_form.admin_last_name.value
	var error=false,error_message='';
		if(firstname=='' || str_trim(firstname)==''){ error=true;
		error_message='<?php echo ERROR_FIRST_NAME; ?>';
		}
		if(lastname=='' || str_trim(lastname)==''){ error=true;
		error_message+='\n<?php echo ERROR_LAST_NAME; ?>';
		}
		if( (adminEmail=='') || (str_trim(adminEmail)=="") ) { error=true;
   		error_message+='\n<?php echo JS_ALERT_EMAIL; ?>';
 		} else if (adminEmail.indexOf("@") <= 1 || adminEmail.indexOf("@") >= (adminEmail.length - 3) || adminEmail.indexOf(".") <= 3 || adminEmail.indexOf(".") >= (adminEmail.length - 2) || adminEmail.indexOf("@.") >= 0 ) {
		error=true;
    	error_message+='\n<?php echo JS_ALERT_EMAIL_FORMAT; ?>';
  		} else if (adminEmail.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
		error=true;
    	error_message+='\n<?php echo JS_ALERT_EMAIL_FORMAT; ?>';
  		}
		if(error==true)
			alert(error_message);
		else{
			do_post_command('edit_admin_member_form','<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=save_edit_admin_member'); ?>');
		}
	}
	function save_move_admin_member(admin_id){
	var move_admin_groups_id=document.getElementById('move_admin_groups_id').value;
	var command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=save_move_admin_member&admin_id='); ?>"+admin_id+'&move_admin_groups_id='+move_admin_groups_id;
	do_get_command(command);
	}
	function move_admin_member(admin_id){ 
		close_obj=true;
		close_all_admin_member_panel();
		document.getElementById('admin_member_move_details').style.display='';
	//	alert(document.getElementById('admin_member_operation'));
		document.getElementById('admin_member_operation').href="javascript:save_move_admin_member("+admin_id+")";	
		document.getElementById('admin_member_operation').style.display='';
		document.getElementById('admin_member_close_button').style.display='';
	}
	function drop_admin_member(admin_id){close_obj=true;
		close_all_admin_member_panel();
	document.getElementById('admin_member_delete_warning').style.display='';
	document.getElementById('admin_member_operation').href="javascript: drop_confirm_admin_member("+admin_id+")";
	document.getElementById('admin_member_operation').style.display='';
	document.getElementById('admin_member_close_button').style.display='';
	}
	function drop_confirm_admin_member(admin_id){
	var command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=drop_confirm_admin_member&admin_id='); ?>"+admin_id;
	do_get_command(command);
	}
	function close_all_admin_member_panel(){
	document.getElementById('preview_details').style.display='none';
	document.getElementById('admin_member_edit_details').style.display='none';
	document.getElementById('admin_member_move_details').style.display='none';
	//document.getElementById('new_admin_member_details').style.display='none';
	document.getElementById('admin_member_delete_warning').style.display='none';
		if(document.getElementById('admin_group_edit_details')){
		document.getElementById('admin_group_edit_details').style.display='none';
		document.getElementById('admin_group_operation').style.display='none';
		new_admin_groups_close();
		document.getElementById('admin_group_delete_details').style.display='none';
		}
	}
	function do_result(result){ 
	var token=result.split('^');
		switch(token[0]){
			case 'load_admin_groups_details':
					document.getElementById('new_admin_group_id').style.display='none';
				var admin_groups_id=token[1];
				document.getElementById('admin_groups_'+admin_groups_id).style.display='none';
				document.getElementById('ajax_admin_groups_'+admin_groups_id).innerHTML=token[2];	
				new_admin_member_close();
				break;
			case 'load_admin_member_details':
				var admin_id=token[1];
				document.getElementById('admin_members_'+admin_id).style.display='none';
				document.getElementById('ajax_admin_members_'+admin_id).innerHTML=token[2];
				break;
			case 'save_move_admin_member':
				if(previous_admin_groups_id!='')
					close_admin_groups(previous_admin_groups_id);
				var admin_groups_id=token[1];
				document.getElementById('admin_groups_'+admin_groups_id).style.display='none';
				document.getElementById('ajax_admin_groups_'+admin_groups_id).style.display='';
				document.getElementById('ajax_admin_groups_'+admin_groups_id).innerHTML=token[2];
				previous_admin_groups_id=admin_groups_id;
				break;
			case 'save_new_admin_member_fails':
				document.getElementById('error_message').innerHTML='<?php echo EMAIL_ADDRESS_ALREADY_EXIST; ?>';
				setTimeout('save_new_admin_member_fails()',3000);
				break;
			case 'save_new_admin_group':
				new_admin_groups_close();
				document.getElementById('primary_admin_group_table').innerHTML=token[1];
				break;
			case 'admin_member_search':
			case 'search_reset':
				document.getElementById('primary_admin_group_table').innerHTML=token[1];
				break;
		}
	}
	function save_new_admin_member_fails(){ 
	document.getElementById('error_message').innerHTML="";
	}
	
	function admin_member_page_navigation(arg1,agr2,agr3,agr4){
		var page_no=1;
		if(agr2==1) var obj=document.getElementById("page_1");
		else if(agr2==2) var obj=document.getElementById("page_2");
		if(agr2 && agr4){
			if(obj){
 	 			page_no=parseInt(obj.options[obj.selectedIndex].value);
 	 			if(agr4=='next') {
 	 				if(obj.length==obj.selectedIndex+1) return;
 	 				page_no+=1;
 	 			}else if(agr4=='prev') {
	 	 			if(obj.selectedIndex==0) return;
 		 			page_no-=1;
 	 			}
 	 			if(page_no<=1) page_no=1;
 	 		} 	 		
		}				
		if(agr2==1) command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_members_page_navigation'); ?>&admin_members_page="+page_no+'&admin_groups_id='+previous_admin_groups_id;
		else if(agr2==2) command="<?php echo tep_href_link(FILENAME_SHOP_ADMIN_MEMBERS,'command=admin_members_page_navigation'); ?>&admin_members_page="+page_no+'&admin_groups_id='+previous_admin_groups_id;
		if(command!="") do_get_command(command);
	}
	

	 function do_hover_change(element,eve){ 
		 var span_details=document.getElementById("admin_member_move_details"); 
		 var span_edit=document.getElementById("admin_member_edit_details");
		 var span_delete=document.getElementById("admin_member_delete_warning");
	  	 if(element){		   		    		    
		    var img_get_src=element.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_edit_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
			    if(img_get_src.src==img_src+'template/img_trash.gif') {
					if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_trash_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && span_delete && span_delete.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';
			    if(img_get_src.src==img_src+'template/img_move.gif') {
					if(span_details && span_details.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_move_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_move_hover.gif' && span_details && span_details.style.display=="none") img_get_src.src=img_src+'template/img_move.gif';
		  }
		 }		 
	 }
	 
	 function do_hover_change1(element,eve){ 
		 var span_details=document.getElementById("span_details"); 
		 var span_edit=document.getElementById("admin_group_edit_details");
		 var span_delete=document.getElementById("admin_group_delete_details");
	  	 if(element){		   		    		    
		    var img_get_src=element.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_edit_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
			    if(img_get_src.src==img_src+'template/img_trash.gif') {
					if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_trash_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && span_delete && span_delete.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';
		  }
		 }		 
	 }  	
	 
	 function do_close(id) {
	 	if(close_obj==false) {
			close_admin_member(id);
			previous_admin_id='';
		}
		close_obj=false;	
	 }
	 
	 function do_member_close() { close_obj=true;
		document.getElementById('admin_member_edit_details').style.display='none';
		document.getElementById('admin_member_operation').style.display='none';
		document.getElementById('admin_member_close_button').style.display='none';
		//document.getElementById('preview_details').style.display='';
	 }
	   	
</script>