<?php

/*

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

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from Zac
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('includes/classes/split_page_results_event.php');
	tep_get_last_access_file();
	$admin_check_query=tep_db_query("select admin_groups_name from " . TABLE_ADMIN_GROUPS . " where admin_groups_id='" . $login_groups_id . "'");
	$admin_check_result=tep_db_fetch_array($admin_check_query);
	$login_groups_name=$admin_check_result['admin_groups_name'];

	$error = false; 
	$search_fnd=false;
	$command=(isset($HTTP_GET_VARS['command'])?tep_db_prepare_input($HTTP_GET_VARS['command']):'');
	$id=(isset($HTTP_GET_VARS['id'])?(int)$HTTP_GET_VARS['id']:'');
	$page=(isset($HTTP_GET_VARS['page'])?(int)$HTTP_GET_VARS['page']:'1');
	$keywords=(isset($HTTP_GET_VARS['search'])?tep_db_prepare_input($HTTP_GET_VARS['search']):'');
	if($command!=''){ $details=false;
		echo $command . '{}' . $id . '||';
		switch ($command){
			case 'get_details':
				$details=true;
				$result='get_details';
				echo get_head_details($id);
				break;
			case 'edit_instructor':
			case 'new_instructor':
				$details=false;
				echo get_edit_details($id);
				break;
			case 'update_instructor':
			case 'insert_instructor':
				$details=false;
				echo get_save_details($id);
			break;
			case 'delete_instructor_confirm':
				echo get_delete_details($id);
			break;
			case 'delete_instructor':
				echo 'delete_instructor';
				tep_db_query("delete from " . TABLE_INSTRUCTORS . " where admin_id = '" . $id . "'");
				tep_db_query("delete from " . TABLE_ADMIN . " where admin_id = '" . $id . "'");
				tep_db_query("delete from " . TABLE_INSTRUCTORS_OPTIONS_TO_OPTION_VALUES . " where instructors_id='" . $id . "'");
			break;	 
			case 'page_navigation':
			$search_fnd=false;
				echo display_instructor();
			break;
			case 'show_state':
				 $country=isset($HTTP_GET_VARS['instructors_country'])?$HTTP_GET_VARS['instructors_country']:0;
				 $zone_ids="";
				 $zone_name="";
			     $zones_query = tep_db_query("select zone_id,zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "' order by zone_name");
			     while ($zones_values = tep_db_fetch_array($zones_query)) {
			         $zone_ids.=$zones_values['zone_id'].",";
			         $zone_name.=$zones_values['zone_name'].",";
			     }
			   echo 'show_state'.substr($zone_ids,0,-1)."^".substr($zone_name,0,-1)."^".$zone;
		   break;
		}
		exit;
	}
	
	$admin_check_query=tep_db_query("select admin_groups_id from " . TABLE_ADMIN_GROUPS . " where admin_groups_name='" . TEXT_INSTRUCTOR_ENTRY . "'");
	$admin_check_result=tep_db_fetch_array($admin_check_query);
	
	$instructor_group_id=$admin_check_result['admin_groups_id'];
	
	$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
	$processed = false;
?>
<!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>
    var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
	var prev_id='';
	var page_id=1;
	var prev_page_id='';
	var ajx_start=false;
	var row_expand=false;
	var close_obj=false;
	var form_obj=false;
	function do_page_fetch(id,action){ 
		if(ajx_start) return;
		else {
			ajx_start=true;
		} 
		if(action!='new_instructor' && action!='insert_instructor'){ 
			document.getElementById('new_details').style.display="none";
			document.getElementById('span_new').style.display="none";
			document.getElementById('span_new').innerHTML="";
			
		}	
		document.getElementById('instructor_id').value=id;
		var command=''; 
		var temp_action=action;
		if(action=='search')
			temp_action='page_navigation';
		command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=' + temp_action + '&id=' + id +  '&page=' + page_id;
		switch (action){
			case 'get_details' :
				var head=document.getElementById('head_' + id);
				var data=document.getElementById('data_' + id);
				if(prev_id!=id) {
					row_expand=false;
					close_obj=false;
					form_obj=false;
				}	
				if(head.style.display=='' && document.getElementById('head_' + id).innerHTML!='' && close_obj==false)  {
					head.style.display="none";
					head.innerHTML='';
					document.getElementById('head_' + id).innerHTML='';
					data.style.display='';
					row_expand=false;
					ajx_start=false;
					prev_id='';
					return;
				}if(head.style.display=="none" && row_expand==false){ 
					row_expand=true;
					head.style.display="";
					head.innerHTML=document.getElementById("loading").innerHTML;
					if(prev_id!='' && id!=prev_id){ 
									document.getElementById('head_' + prev_id).style.display="none";
									document.getElementById('head_' + prev_id).innerHTML='';
									document.getElementById('data_' + prev_id).style.display="";
					}
					prev_id=id;
					prev_page_id=page_id;
					data.style.display="none";
					if(document.getElementById('img_new'))
						document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
					display_flag=1;
				}	
				close_obj=false;
				if(form_obj==true){
				 ajx_start=false;
				 return;
				 }
			break;	
			case 'edit_instructor':
				document.getElementById('instructor').value="edit_instructor";
				//document.getElementById('instructor_id').value=id;
				document.getElementById('span_details').style.display="none";
				document.getElementById('span_edit').style.display="";
				document.getElementById('span_delete').style.display="none";
				document.getElementById('span_edit').innerHTML=document.getElementById('loading').innerHTML;			
			break;
			case 'update_instructor':
				document.getElementById('span_edit').style.display="";
				document.getElementById('span_delete').style.display="none";
				document.getElementById('span_details').style.display="none";
				//document.getElementById('span_edit').innerHTML=document.getElementById('loading').innerHTML;
				do_post_command('instructors',command);
				return;
			break;
			case 'insert_instructor':
				document.getElementById('instructor').value="insert_instructor";
				if(document.getElementById('span_edit')) document.getElementById('span_edit').style.display="none";
				if(document.getElementById('span_details')) document.getElementById('span_details').style.display="none";
				if(document.getElementById('span_delete')) document.getElementById('span_delete').style.display="none";
				do_post_command('instructors',command);
				return;
			break;
			case 'close_instructor': close_obj=true;
				var span_details=document.getElementById("span_details");
				var span_edit=document.getElementById("span_edit");				
				var span_delete=document.getElementById("span_delete");
				var img_save = document.getElementById('img_save');
				document.getElementById('new_details').style.display="none";
				document.getElementById('span_new').style.display="none";
				
				if(span_edit.style.display=="") span_edit.style.display="none";
				if(span_delete.style.display=="") span_delete.style.display="none"; 	 			   	  	 	 			   	  	
				span_details.style.display="";
				if(img_save) img_save.style.display="none"; 
				if(document.getElementById("img_ids")){
					var tr_obj=document.getElementById("img_ids");
					if(tr_obj.childNodes[1].childNodes[0].src==img_src+'template/img_edit_hover.gif')	
						tr_obj.childNodes[1].childNodes[0].src=img_src+'template/img_edit.gif';
					if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_trash_hover.gif')	
						tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_trash.gif';	 	 			   	  			
					 }	 			   	  	  	 			   	  	 	 			   	  	
				
					ajx_start=false;
				return;
			break;
			case 'new_instructor':
				document.getElementById('instructor').value='insert_instructor';
				if(document.getElementById('span_details')) document.getElementById('span_details').style.display="none";
				if(document.getElementById('span_edit')) document.getElementById('span_edit').style.display="none";
				if(document.getElementById('span_delete')) document.getElementById('span_delete').style.display="none";
					if(prev_id!='' && document.getElementById('head_' + prev_id)){
						document.getElementById('head_' + prev_id).style.display="none";
						document.getElementById('head_' + prev_id).innerHTML="";
						document.getElementById('data_' + prev_id).style.display="";
					}
					prev_id='';
					document.getElementById('new_details').style.display="";
					document.getElementById('span_new').style.display="";
					document.getElementById('span_new').innerHTML=document.getElementById('loading').innerHTML;
					display_flag=0;
					if(document.getElementById('no_instructors')) document.getElementById('no_instructors').style.display="none";
			break;
			case 'close': 
					document.getElementById('new_details').style.display="none";
					document.getElementById('span_new').style.display="none";
					ajx_start=false;
					if(document.getElementById('img_new'))
						document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
					display_flag=1;
					if(document.getElementById('no_instructors')) document.getElementById('no_instructors').style.display="";
			return;
			break;
		    case 'delete_instructor_confirm':	
				document.getElementById('instructor').value="delete_instructor";
				document.getElementById('span_delete').style.display="";
				document.getElementById('span_delete').innerHTML=document.getElementById("loading").innerHTML;
				document.getElementById('span_details').style.display="none";
				
			break;
			case 'delete_instructor': 
				document.getElementById('span_delete').style.display="";
				document.getElementById('span_delete').innerHTML=document.getElementById("loading").innerHTML;
				document.getElementById('span_details').style.display="none";
				prev_id='';
			break;
			case 'search':
				prev_id='';
				var ssearch=document.getElementById('search_instructor').value;
				if(document.getElementById('img_new'))
					document.getElementById('img_new').style.display="";
				command=command+ '&search=' + ssearch;
			break;
		}
		do_get_command(command);
	}
	 
	function show_state(){
		var this_=document.instructors.instructors_country;
		id=this_.options[this_.selectedIndex].value;
		if(id){
			command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=show_state&instructors_country='+id;
			do_get_command(command);
			if(document.getElementById("instructors_state"))document.getElementById("instructors_state").innerHTML="Loading...";
		}else{
			element=document.getElementById("instructors_state").innerHTML="";
		}
	}
	
	function do_result(result){ 
		var splt=Array();
		splt=result.split("{}");
		var spl_arr=Array();
		var sp1=splt[1];
		spl_arr=sp1.split("||"); 
		switch (splt[0]){ 
			case 'get_details':
				var head=document.getElementById('head_' + spl_arr[0]);
				var data=document.getElementById('data_' + spl_arr[0]);
				head.innerHTML=spl_arr[1];
				document.getElementById('span_details').style.display="";
				document.getElementById('img_save').style.display="none";
				
				if(return_flag==1){
					ajx_start=false;
					do_page_fetch(spl_arr[0],'edit_instructor');
				}
				return_flag=0;
				
			break;
			case 'edit_instructor':
				if(document.getElementById('img_save'))
					document.getElementById('img_save').style.display="";
				document.getElementById('span_edit').innerHTML=spl_arr[1];
			break;
			case 'update_instructor':	
				close_obj=true;
				document.getElementById('img_save').style.display="none";
				if(document.getElementById("img_ids")){
					var tr_obj=document.getElementById("img_ids");
					if(tr_obj.childNodes[1].childNodes[0].src==img_src+'template/img_edit_hover.gif')	
						tr_obj.childNodes[1].childNodes[0].src=img_src+'template/img_edit.gif';
					if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_trash_hover.gif')	
						tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_trash.gif';	 	 			   	  			
				}	 			   	  	  	 			   	  	 	 			   	  	
				
				var details=Array();
				details=spl_arr[1].split("{#}");
				if(details[0].substr(0,5)=='error'){ details[0]=details[0].substr(5);
					document.getElementById('img_save').style.display="";
					//document.getElementById('span_details').innerHTML="";
					document.getElementById('span_details').style.display="none";
					document.getElementById('span_edit').style.display="";
					document.getElementById('span_delete').style.display="none";
					document.getElementById('span_edit').innerHTML=details[0];
				} else {
					document.getElementById('span_edit').style.display="none";
					document.getElementById('span_edit').innerHTML="";
					document.getElementById("row_heading").innerHTML=details[1];
					document.getElementById("data_" + spl_arr[0]).innerHTML='<table cellpadding="0" cellspacing="0" border="0" width="100%">'+
											'<tr height="25">'+
												'<td class="dataTableContent" width="200">'+ details[1]+'</td>'+
												'<td class="dataTableContent">'+details[2] +'</td>'+
											'</tr>'+
										'</table>';
					document.getElementById('img_save').style.display="none";
					document.getElementById('span_details').style.display="";
					document.getElementById('span_details').innerHTML=details[0];

				}
			break;
			case 'insert_instructor': close_obj=true;
				if(spl_arr[1].substr(0,5)=='error'){
				spl_arr[1]=spl_arr[1].substr(5);
					document.getElementById('new_details').style.display="";
					document.getElementById('span_new').style.display="";
					document.getElementById('span_new').innerHTML=spl_arr[1];
				} else {
				document.getElementById('span_new').style.display="none";
				document.getElementById('span_new').innerHTML="";
				document.getElementById('new_details').style.display="none";
				var id_value=Array();
				id_value=spl_arr[1].split('{|}');
				var details=Array();
				details=id_value[1].split("{#}");				
				var row=document.getElementById('instruct_table');
				var row_obj=row.insertRow(row.rows.length-3);
				var row_len=(row.rows.length-3);
				var cell_obj=row_obj.insertCell(0);
				var classname;
				cell_obj.innerHTML=details[0];  
				row_obj.onmouseover=function (){rowOverEffect(this)};
				row_obj.onmouseout=function (){rowOutEffect(this)};
				row_obj.id="row_" + id_value[0];
				row_obj.onclick=function(){ ((document.getElementById("head_" + id_value[0]).style.display=='none')?do_page_fetch(id_value[0],'get_details'):'')};
				if((row_len % 2) == 0) classname="dataTableRowEven";
				else classname="dataTableRowOdd";
				row_obj.className=classname;
				row_obj.height="25px";
				command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=page_navigation&page=1';
				do_get_command(command);
				if(document.getElementById('search_instructor')) document.getElementById('search_instructor').value="";
				}					
			break;
			case 'new_instructor':
				document.getElementById('span_new').innerHTML=spl_arr[1];
				//SetCategories();
				if(document.getElementById("instructors_country")) show_state();
			break;
			case 'delete_instructor_confirm':
				document.getElementById("span_edit").style.display="none";
				document.getElementById('span_delete').style.display="";
				document.getElementById('span_delete').innerHTML=spl_arr[1];
				document.getElementById('img_save').style.display="";
				
			break;
			case 'delete_instructor':
				command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=page_navigation&page=1';
				do_get_command(command);
				if(document.getElementById('search_instructor')) document.getElementById('search_instructor').value="";
			break;
			case 'page_navigation': 
				document.getElementById('ajax_details').innerHTML=spl_arr[1];
			break;
			case 'show_state':
					result=result.substr(result.indexOf('show_state')+10,result.length);
					var textArr=new Array();
					var valueArr=new Array();
					splt=result.split("^");
					valueArr=splt[1].split(",");
					textArr=splt[1].split(",");
					sel_zone=splt[2];
					var sel=document.getElementById("instructors_state");
					if(valueArr.length==1) {
						if(document.getElementById("instructors_state1")) document.getElementById("instructors_state1").style.display="";
						if(sel)	sel.style.display="none";
					}else if(valueArr.length>1){
							document.getElementById("instructors_state1").value="";
							document.getElementById("instructors_state1").style.display="none";
							sel.style.display="";
							optionElement=sel;
							// clear the previous details
							while(optionElement.options.length>0){
								optionElement.remove(optionElement.options.length - 1);
							}
							//create the new details
							for (icnt=0;icnt<textArr.length;icnt++){
							  var option = document.createElement('option');
							  option.text = textArr[icnt];
							  option.value = valueArr[icnt];
							  try {
								optionElement.add(option, null); // standards compliant; doesn't work in IE
							  }
							  catch(ex) {
								optionElement.add(option); // IE only
							  }
						}
						if(typeof(default_zone) != "undefined")
						for(i=0;i<optionElement.options.length;i++){
							if(optionElement.options[i].value==default_zone)
								optionElement.options[i].selected = true;
						}
						if(document.getElementById("instructors_state1") && typeof(default_country) != "undefined")
						if(default_country!=document.getElementById("instructors_country"))
							document.getElementById("instructors_state1").value="";
				   }					
			break;
		}	
		ajx_start=false;
	}
	
 function do_hover_change(element,eve){ 
	 var span_details=document.getElementById("span_details"); 
	 var span_edit=document.getElementById("span_edit");
	 var span_delete=document.getElementById("span_delete");
	 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 check_form() { 
  var error = 0;
  var error_message = "<?php echo JS_ERROR; ?>";
  var admin_firstname = document.instructors.admin_firstname.value;
  var admin_lastname = document.instructors.admin_lastname.value;
  var instructors_dob = document.instructors.instructors_dob.value;
  var admin_email_address = document.instructors.admin_email_address.value;
  var admin_password;
  if(document.instructors.admin_password)
 	 admin_password=document.instructors.admin_password.value;
  var instructors_street_address = document.instructors.instructors_street_address.value;
  var instructors_postcode = document.instructors.instructors_postcode.value;
  var instructors_city = document.instructors.instructors_city.value;
  var instructors_telephone = document.instructors.instructors_telephone.value;
  if (document.instructors.genderflag.value=="1"){
	  if (document.instructors.instructors_gender[0].checked || document.instructors.instructors_gender[1].checked) {
	  } else {
	
		error_message = error_message + "<?php echo JS_GENDER; ?>";
		error = 1;
	  }
  }
    if (admin_firstname == "" || str_trim(admin_firstname) == "" || admin_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";
    error = 1;
  }


  if (admin_lastname == "" || str_trim(admin_lastname) == "" || admin_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_LAST_NAME; ?>";
    error = 1;
  }

  if (instructors_dob == "" || str_trim(instructors_dob) == "" || instructors_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_DOB; ?>";
    error = 1;
  }

  if (admin_email_address == "" || str_trim(admin_email_address) == "" || admin_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";
    error = 1;
  }
  
  if(admin_password!='*****' && pwdValidation('<?php echo MODULE_CUSTOMERS_PASSWORD_STRENGTH;?>',admin_password)==false){
	  switch ('<?php echo MODULE_CUSTOMERS_PASSWORD_STRENGTH;?>'){	
		case '1':
			error_message = error_message + '<?php echo ERR_PWD_EMPTY;?>';
			error=1;
			break;
		case '2':
			error_message = error_message + '<?php echo ERR_PWD_ALPHANUMERIC;?>';
			error=1;
			break;
		case '3':
			error_message = error_message + '<?php echo ERR_PWD_ALPHA_SYMBOLS;?>';
			error=1;
			break;
		case '4':
			error_message = error_message + '<?php echo ERR_PWD_DICTIONARY_WORDS;?>';
			error=1;
			break;
	  }
 } 
  

  if (instructors_street_address == "" || str_trim(instructors_street_address)=="" || instructors_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_ADDRESS; ?>";
    error = 1;
  }

  if (instructors_postcode == "" || str_trim(instructors_postcode)=="" || instructors_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_POST_CODE; ?>";
    error = 1;
  }

  if (instructors_city == "" || str_trim(instructors_city)=="" || instructors_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_CITY; ?>";
    error = 1;
  }
  if (document.instructors.elements['instructors_state'].style.display != "none" || document.instructors.elements['instructors_state1'].style.display != "none") {
    var state_obj=document.instructors.elements['instructors_state'];
    if(state_obj.style.display=='none') state_obj=document.instructors.instructors_state1;
    if(state_obj.value == '' || str_trim(state_obj.value)=='' || state_obj.value.length < <?php echo ENTRY_STATE_MIN_LENGTH;?>){
       error_message = error_message + "<?php echo sprintf(JS_STATE_MIN_LENGTH,ENTRY_STATE_MIN_LENGTH); ?>";
       error = 1;
    } 
  }

  if (document.instructors.elements['instructors_country'].type != "hidden") {
    if (document.instructors.instructors_country.value == 0) {
      error_message = error_message + "<?php echo JS_COUNTRY; ?>";
      error = 1;
    }
  }

  if (instructors_telephone == "" || str_trim(instructors_telephone)=="" || instructors_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {
    error_message = error_message + "<?php echo JS_TELEPHONE; ?>";
    error = 1;
  }
  if (error == 1) {
    alert(error_message);
	close_obj=true;
	form_obj=true;
    return false;
  } else {
    if(document.getElementById('img_new'))
  		document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
	display_flag=1;
    return true;
  }
}
function do_form(){ 
close_obj=true;
	var id=document.getElementById('instructor_id').value;
	var action=document.getElementById('instructor');
	if(action && action.value=='delete_instructor'){ 
		action.value='';
		do_page_fetch(id,'delete_instructor'); 
	} else if(check_form() ==true){ 
			form_obj=true;
			if(action.value=='insert_instructor'){
				prev_id=''; 
					var command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=insert_instructor&page=1';
					do_post_command('instructors',command);
			}	
 			else if(action.value='edit_instructor'){
				do_page_fetch(id,'update_instructor');
			}
			}
	return false;
}

function do_page_navigation(value,params,name,plink){ 
	if(params=='page_navigation' && document.getElementById("page_''") && plink!=''){
		 page_id = parseInt(document.getElementById("page_''").options[document.getElementById("page_''").selectedIndex].value);
		if(plink=='next')
			page_id=page_id+1;
		else if(plink=='prev')
			page_id=page_id-1;
	}
	prev_page_id=page_id;
	prev_id='';
	command='<?php echo tep_href_link(FILENAME_INSTRUCTORS);?>' + '?command=page_navigation&page=' + page_id;
	do_get_command(command);
}
 function do_pwd_check(obj)
 {
 	pwd=obj.value;
	if(pwd.length==0)
	  document.all.pwd_str.innerHTML='';
	else if(pwd.length<<?php echo ENTRY_PASSWORD_MIN_LENGTH;?>)
		document.all.pwd_str.innerHTML='<?php echo ENTRY_PASSWORD_STRENGTH_ERROR;?>';
	else if(!check_password_strength(pwd))
		document.all.pwd_str.innerHTML='<?php echo ENTRY_PASSWORD_STRENGTH_ERROR;?>';
	else
		document.all.pwd_str.innerHTML='';
 }
	     function check_key(e){
     var kc=0;
   	  if (window.event)
	    kc=window.event.keyCode;
	  else if (e)
	 	kc=e.which;
	  else
		kc=0;
	  if(kc==13) do_page_fetch('','search');
   }
    var display_flag=1;	
	function do_hover_change1(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;
	} 

//--></script>
</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 //-->

<!-- 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 height="25" valign="top"><?php // echo tep_draw_form('search_instructor', FILENAME_INSTRUCTORS, '', 'post'); ?>
				<table border="0" width="100%" cellspacing="0" cellpadding="0">
				<?php if ($login_groups_name==TEXT_ADMINISTRATOR_ENTRY) { ?>
          		<tr class="dataTableHeadingRow">
					<td  align="left" valign="bottom"><?php //if ($login_groups_name==TEXT_ADMINISTRATOR_ENTRY)
					 echo  '<a  id="img_new"  href="javascript:do_page_fetch(\'\',\'new_instructor\');" onmouseover="javascript:do_hover_change1(this,2);" onmouseout="javascript:do_hover_change1(this,1);">' . tep_image('images/template/img_new.gif','New','22','22') . '</a>';?></td>
            		<td class="dataTableHeadingContent" align="right" valign="absmiddle"><?php //if ($login_groups_name==TEXT_ADMINISTRATOR_ENTRY) 
					echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search_instructor','','onkeyup="javascript:check_key(event)"') . '&nbsp;'; ?></td>
					<td valign="absmiddle" width="25" align="center"><?php echo '<a href="javascript:if(document.getElementById(\'search_instructor\').value!=\'\') do_page_fetch(\'\',\'search\');">' .tep_image(DIR_WS_IMAGES.'template/img_search.gif','','','',' align=absmiddle') . '</a>';?></td>
         		</tr>
				<?php } ?>	
			 	<tr>	
		 			<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif','1','5'); ?></td>
		 		</tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_form('instructors', FILENAME_INSTRUCTORS, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onSubmit="return do_form();"'); ?>
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
				  <tr>
					<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
					  <tr class="dataTableHeadingRow">
						<td>
							<table cellpadding="0" cellspacing="0" border="0" width="100%">
								<tr>
									<td class="dataTableHeadingContent" width="200"><?php echo TABLE_HEADING_NAME; ?></td>
									<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_EMAIL; ?></td>
								</tr>
							</table>
						</td>			
					  </tr>
<?php
    if ($login_groups_name==TEXT_INSTRUCTOR_ENTRY)
        $query_instructor=" and a.admin_id='" . (int)$login_id . "'";
		echo '<tr><td id="ajax_details">';
			display_instructor();
		echo '</td></tr>';
		
?> 
            </table></td>
          </tr>
        </table>
		<?php 		echo '<input type="hidden" id="instructor_id">';
		
		echo '<input type="hidden" id="instructor">';
?>
		</form>
		</td>
		
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); 
function get_head_details($iID){
	global $details,$display,$login_groups_name;
	$instructor_query=tep_db_query("select admin_firstname,admin_lastname, admin_email_address from " . TABLE_INSTRUCTORS ." i, " . TABLE_ADMIN ." a where a.admin_id=i.admin_id and a.admin_id='" . $iID . "'");
	$instructor_result=tep_db_fetch_array($instructor_query);
		$result='<table width="100%" border="0" cellspacing="0" cellpadding="0" class="openContent">'.
				'<tr heigth="40" bgcolor="#EDF1FE"  class="openContent_top"  onclick="javascript:do_page_fetch(\'' . $iID. '\',\'get_details\');">';  	
						  							  
		$result.=		  '<td width="40" valign="top" align="center">&nbsp;</td>'.
				  '<td align="left" valign="middle" width="350" class="inner_title" id="row_heading">'. $instructor_result['admin_firstname']. ' ' . $instructor_result['admin_lastname'].'</td>'.
				  '<td width="470" align="left" 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>';
							$result.=     '<td width="15" onclick="javascript:do_hover_change(this,1);do_page_fetch(' . $iID . ',\'edit_instructor\');" 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>';
						 if ($login_groups_name==TEXT_ADMINISTRATOR_ENTRY) 
				  	 		 $result.= '<td width="15" onclick="javascript:do_hover_change(this,1);do_page_fetch(' . $iID . ',\'delete_instructor_confirm\');" 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>';
				  	    $result.= '<td class="cell_bg_popm_right" width="10">&nbsp;</td>'.
				  	  '</tr>'.
				  	'</table>'.
				  '</td>';
			//$result.=	 '<td width="240" align="right" id="img_save" style="display:none;"><input type="image" src="images/template/img_savel.gif" alt="save" title="save" border="0">&nbsp;&nbsp;<a href="javascript:do_page_fetch(' . $iID .',\'close_instructor\');"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>'.
			$result.=	 '<td width="70" align="right" id="img_save" style="display:none">' . 
							'<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td  align="right">' .'<img  src="images/template/img_savel.gif" onclick="do_form();" alt="save" title="save" border="0"></td><td  align="right"><img src="images/template/img_closel.gif" alt="close" onclick="do_page_fetch(' . $iID . ',\'close_instructor\');" title="close" border="0">&nbsp;&nbsp;</td></tr></table>'.
							'</td>';
				$result.='</tr>';
				if($details){
					$result.= '<tr><td width="40" valign="top" align="center">&nbsp;</td><td colspan="4"><div id="span_details" style="display:none"><table cellpadding="2" cellspacing="2" border="0" width="100%">';
					$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr>';
					$result.='<tr><td class="main" width="125">' . TEXT_INSTRUCTOR_NAME . '</td><td class="main">' . $instructor_result['admin_firstname'] . ' ' . $instructor_result['admin_lastname'] . '</td><td class="main" width="125">' . TEXT_EMAIL_ADDRESS . '</td><td class="main">' . $instructor_result['admin_email_address'] . '</td></tr>';
							
					$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr></table></div></td></tr>';
					$result.='<tr><td colspan="5"><span id="span_edit" style="display:none"  class="openContent">2</span></td></tr>';
					$result.='<tr><td colspan="5"><span id="span_delete" style="display:none"  class="openContent">3</span></td></tr>';
				}
			$reuslt .='</table>';
			
			return $result;
	}		
	
	function get_edit_details($iID){
		global $command, $itInfo, $error,$HTTP_POST_VARS,$entry_firstname_error,$entry_lastname_error,$entry_email_address_error,$login_groups_type;
		global $entry_date_of_birth_error,$entry_email_address_check_error,$entry_street_address_error,$entry_post_code_error,$entry_city_error;
		global $entry_country_error,$entry_state_error,$entry_telephone_error,$entry_email_address_exists;
			if($error==false){										 
				$instructors_query = tep_db_query("select a.admin_id, i.instructors_gender, a.admin_firstname, a.admin_lastname, i.instructors_dob, a.admin_email_address, i.instructors_street_address, i.instructors_suburb, i.instructors_postcode, i.instructors_city, i.instructors_state, i.instructors_country,i.instructors_telephone, i.instructors_fax, " .
										  "i.instructors_description,i.instructors_payment from " . TABLE_ADMIN . " a, " . TABLE_INSTRUCTORS . " i  where a.admin_id = '" . $iID . "'" . " and i.admin_id=a.admin_id");
				$instructors = tep_db_fetch_array($instructors_query);
				$instruct_query=tep_db_query("select op2v.* from " . TABLE_INSTRUCTORS_OPTIONS_TO_OPTION_VALUES . " op2v, " . TABLE_ADMIN . " a, " . TABLE_INSTRUCTORS . " i   where a.admin_id=i.admin_id and i.instructors_id=op2v.instructors_id and i.admin_id='" . $iID . "'");
				while($instruct_result=tep_db_fetch_array($instruct_query)){
					$instruct_array[$instruct_result['options_id']]=$instruct_result['options_values_id'];
				}
				if (!is_array($instructors)) $instructors=array();
				if (!is_array($instruct_array)) $instruct_array=array();
				
				$instructors=array_merge($instructors,$instruct_array);
				
				$itInfo = new objectInfo($instructors);
				
		} else if ($error==true && isset($HTTP_POST_VARS)) {  $itInfo = new objectInfo($HTTP_POST_VARS); }
		else {
		$itInfo = array();  $iID=0;
		}
		if($error==true) echo 'error';
		
			$instructor_option_query=tep_db_query("select options_key,options_id,options_name from " . TABLE_INSTRUCTORS_OPTIONS . " where options_display='Y'");
			while ($instructor_option_result=tep_db_fetch_array($instructor_option_query)){
				
				$options_array[$instructor_option_result['options_key']]=array('field_name'=>'instructors_' . $instructor_option_result['options_key'],'text'=>'','values' =>array(array('id'=>'','text'=>TEXT_NONE)));
				$options_array[$instructor_option_result["options_key"]]['text']=$instructor_option_result["options_name"];
			}
				$options_values_query=tep_db_query("SELECT options_key,options_values_text from " . TABLE_INSTRUCTORS_OPTIONS_VALUES  . "  where options_values_display='Y' order by options_key,options_values_text"); 
				while($options_values=tep_db_fetch_array($options_values_query)){
					$options_array[$options_values['options_key']]['values'][]=array('id'=>$options_values['options_values_text'],'text'=>$options_values['options_values_text']);
				}
			
			/*$optionss_array=array(	'DE'=>array('field_name'=>'instructors_department','text'=>'','values'=>array(array('id'=>'','text'=>TEXT_NONE))),
									'QA'=>array('field_name'=>'instructors_qualifications','text'=>'','values'=>array(array('id'=>'','text'=>TEXT_NONE))),
									'PO'=>array('field_name'=>'instructors_position','text'=>'','values'=>array(array('id'=>'','text'=>TEXT_NONE))));
			//tep_db_query("select * from " . TABLE_INSTRUCTORS_OPTIONS . " where options_key in('DE','QA','PO')");
			$optionss_query=tep_db_query("select * from " . TABLE_INSTRUCTORS_OPTIONS . " where options_display='Y'" );
			while($optionss=tep_db_fetch_array($optionss_query)){
				$optionss_array[$optionss["options_key"]]['text']=$optionss["options_name"];
			}echo '<br><br><br><br>';print_r($optionss_array);
			$optionss_values_query=tep_db_query("SELECT options_key,options_values_text from " . TABLE_INSTRUCTORS_OPTIONS_VALUES  . "  where options_values_display='Y' order by options_key,options_values_text"); 
			while($optionss_values=tep_db_fetch_array($optionss_values_query)){
				$optionss_array[$optionss_values['options_key']]['values'][]=array('id'=>$optionss_values['options_values_text'],'text'=>$optionss_values['options_values_text']);
			}
			echo '<br><br><br><br>';
			//print_r($optionss_array);*/
			$is_read_only=false;	
			if($error) $show_hidden=false; else $show_hidden=true;	
	?>

			<table border="0" width="100%" cellspacing="0" cellpadding="0">
		<?php tep_content_title_top("Personal"); ?>
		<tr>
			<td >
			<table border="0" cellspacing="2" cellpadding="2" width="100%">
			
			
			
				<tr>
					<td class="main" width="150"><?php echo TEXT_GENDER; ?></td>
					<td class="main">
					<?php
						if ($is_read_only) {
					   		echo ($itInfo->instructors_gender == 'm' ? MALE : FEMALE);
						} else if ($error == true) {
						  if ($entry_gender_error == true) {
							echo tep_draw_radio_field('instructors_gender', 'm', false, $itInfo->instructors_gender) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('instructors_gender', 'f', false, $itInfo->instructors_gender) . '&nbsp;&nbsp;' . FEMALE . '&nbsp;' . ENTRY_GENDER_ERROR;
							echo tep_draw_hidden_field('genderflag',"1");
						  } else {
							echo ($itInfo->instructors_gender == 'm') ? MALE : FEMALE;
							echo tep_draw_hidden_field('instructors_gender',$itInfo->instructors_gender);
							echo tep_draw_hidden_field('genderflag',"0");
						  }
						} else {
						  echo tep_draw_radio_field('instructors_gender', 'm', true, $itInfo->instructors_gender) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . tep_draw_radio_field('instructors_gender', 'f', false, $itInfo->instructors_gender) . '&nbsp;&nbsp;' . FEMALE;
						  echo tep_draw_hidden_field('genderflag',"1");
						}
					?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_FIRSTNAME; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->admin_firstname;
  } else if ($error == true) {
    if ($entry_firstname_error == true) {
      echo tep_draw_input_field('admin_firstname', $itInfo->admin_firstname, 'maxlength="32" size="32"') . '&nbsp;' . ENTRY_FIRST_NAME_ERROR;
    } else {
      echo $itInfo->admin_firstname . tep_draw_hidden_field('admin_firstname');
    }
  } else {
    echo tep_draw_input_field('admin_firstname', $itInfo->admin_firstname, 'maxlength="32" size="32"') .  '&nbsp;' . ENTRY_FIRST_NAME_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_LASTNAME; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->admin_lastname;
  } else if ($error == true) {
    if ($entry_lastname_error == true) {
      echo tep_draw_input_field('admin_lastname', $itInfo->admin_lastname, 'maxlength="32" size="32"') . '&nbsp;' . ENTRY_LAST_NAME_ERROR;
    } else {
      echo $itInfo->admin_lastname . tep_draw_hidden_field('admin_lastname');
    }
  } else {
    echo tep_draw_input_field('admin_lastname', $itInfo->admin_lastname, 'maxlength="32" size="32"') .'&nbsp;' . ENTRY_LAST_NAME_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_DATE_BIRTH; ?></td>
            <td class="main">

<?php
	if ($is_read_only){
		echo format_date($itInfo->instructors_dob);
    } else if ($error == true) {
      if ($entry_date_of_birth_error == true) {
        echo tep_draw_input_field('instructors_dob', $itInfo->instructors_dob, 'maxlength="10"') . '&nbsp;' . ENTRY_EVENT_DATE_OF_BIRTH_ERROR;
      } else {
        echo $itInfo->instructors_dob . tep_draw_hidden_field('instructors_dob');
      }
    } else {
      echo tep_draw_input_field('instructors_dob', format_date($itInfo->instructors_dob), 'maxlength="10"') . '&nbsp;' . ENTRY_EVENT_DATE_OF_BIRTH_TEXT;
    }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_EMAIL_ADDRESS; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->admin_email_address;
  } else if ($error == true) {
    if ($entry_email_address_error == true) {
      echo tep_draw_input_field('admin_email_address', $itInfo->admin_email_address, 'maxlength="96" size="32"') . '&nbsp;' . ENTRY_EMAIL_ADDRESS_ERROR;
    } elseif ($entry_email_address_check_error == true) {
      echo tep_draw_input_field('admin_email_address', $itInfo->admin_email_address, 'maxlength="96" size="32"') . '&nbsp;' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;
    } elseif ($entry_email_address_exists == true) {
      echo tep_draw_input_field('admin_email_address', $itInfo->admin_email_address, 'maxlength="96" size="32"') . '&nbsp;' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;
    } else {
      echo $itInfo->admin_email_address . tep_draw_hidden_field('admin_email_address');
    }
  } else {
    echo tep_draw_input_field('admin_email_address', $itInfo->admin_email_address, 'maxlength="96" size="32"') . '&nbsp;' . ENTRY_EMAIL_ADDRESS_TEXT;
  }
?></td>
          </tr>
<?php 		if($iID >0){   ?>
       <tr>
            <td class="main"><?php echo ENTRY_PASSWORD; ?></td>
            <td class="main">
<?php   if ($is_read_only){
  	echo $itInfo->admin_password;

  } else if ($error == true) {
    if ($entry_password_error == true) {
      echo tep_draw_input_field('admin_password', '*****', 'maxlength="40" onKeyUp=javascript:do_pwd_check(this);') . '&nbsp;' . ENTRY_PASSWORD_ERROR;
    }
	elseif ($entry_password_strength_error == true) {
      echo tep_draw_input_field('admin_password', '*****', 'maxlength="40" onKeyUp=javascript:do_pwd_check(this);') . '&nbsp;' . ENTRY_PASSWORD_STRENGTH_ERROR;
  } else {
      echo '*****'. tep_draw_hidden_field('admin_password');
    }
  } else {
    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"></span>
</td>
          </tr>
		  <?php }?>
        </table></td>
      </tr>
	  <?php tep_content_title_bottom(); ?>
      
	  <?php tep_content_title_top("Address",'',false,$show_hidden); ?>
      
      <tr>
        <td ><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main" width="150"><?php echo TEXT_STREET_ADDRESS; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->instructors_street_address;
  } else if ($error == true) {
    if ($instructors_street_address_error == true) {
      echo tep_draw_input_field('instructors_street_address', $itInfo->instructors_street_address, 'maxlength="64" size=64') . '&nbsp;' . ENTRY_STREET_ADDRESS_ERROR;
    } else {
      echo $itInfo->instructors_street_address . tep_draw_hidden_field('instructors_street_address');
    }
  } else {
    echo tep_draw_input_field('instructors_street_address', $itInfo->instructors_street_address, 'maxlength="64" size=64') . '&nbsp;' . ENTRY_STREET_ADDRESS_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_SUBURB; ?></td>
            <td class="main">
<?php
	if ($is_read_only){
		echo $itInfo->instructors_suburb;
    } else if ($error == true) {
      if ($entry_suburb_error == true) {
        echo tep_draw_input_field('instructors_suburb', $itInfo->instructors_suburb, 'maxlength="32"') . '&nbsp;' . ENTRY_SUBURB_ERROR;
      } else {
        echo $itInfo->instructors_suburb . tep_draw_hidden_field('instructors_suburb');
      }
    } else {
      echo tep_draw_input_field('instructors_suburb', $itInfo->instructors_suburb, 'maxlength="32"') .  '&nbsp;' . ENTRY_SUBURB_TEXT;
    }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_POST_CODE; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->instructors_postcode;
  } else if ($error == true) {
    if ($entry_postcode_error == true) {
      echo tep_draw_input_field('instructors_postcode', $itInfo->instructors_postcode, 'maxlength="8"') . '&nbsp;' . ENTRY_POSTCODE_ERROR;
    } else {
      echo $itInfo->instructors_postcode . tep_draw_hidden_field('instructors_postcode');
    }
  } else {
    echo tep_draw_input_field('instructors_postcode', $itInfo->instructors_postcode, 'maxlength="8"')  . '&nbsp;' . ENTRY_POST_CODE_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_CITY; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->instructors_city;
  } else if ($error == true) {
    if ($entry_city_error == true) {
      echo tep_draw_input_field('instructors_city', $itInfo->instructors_city, 'maxlength="32"') . '&nbsp;' . ENTRY_CITY_ERROR;
    } else {
      echo $itInfo->instructors_city . tep_draw_hidden_field('instructors_city');
    }
  } else {
    echo tep_draw_input_field('instructors_city', $itInfo->instructors_city, 'maxlength="32"')  . '&nbsp;' . ENTRY_CITY_TEXT;
  }
?></td>
          </tr>          
          <tr>
            <td class="main" width="150"><?php echo TEXT_COUNTRY; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->instructors_country;
  } else if ($error == true) {
    if ($entry_country_error == true) {
      echo tep_draw_pull_down_menu('instructors_country', tep_get_countries(), $itInfo->instructors_country,' id="instructors_country" onchange="javascript:show_state();" ') . '&nbsp;' . ENTRY_COUNTRY_ERROR;
    } else {
      echo tep_get_country_name($itInfo->instructors_country) . tep_draw_hidden_field('instructors_country');
    }
  } else {
    echo tep_draw_pull_down_menu('instructors_country', tep_get_countries(), (($itInfo->instructors_country)?$itInfo->instructors_country:STORE_COUNTRY),' id="instructors_country" onchange="javascript:show_state();" ') . '&nbsp;' . ENTRY_COUNTRY_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_STATE; ?></td>
            <td class="main">
<?php	
	$instructors_state = tep_get_zone_name($itInfo->instructors_country, $itInfo->instructors_zone_id, $itInfo->instructors_state);
	$state_load=false;
	$display_text= "";
	$zones_array = array();
	  $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($itInfo->instructors_country) . "' order by zone_name");
	  while ($zones_values = tep_db_fetch_array($zones_query)) {
	    $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
	  }
	if ($is_read_only){
		echo $instructors_state;
    } else if ($error == true) {
      if ($entry_state_error == true) {
        if ($entry_state_has_zones == true) {
          $display_text= '&nbsp;' . ENTRY_STATE_ERROR;
          $state_load=true;
        } else {
          $display_text= '&nbsp;' . ENTRY_STATE_ERROR;
          $state_load=true;
        }
      } else {
        echo $instructors_state . tep_draw_hidden_field('instructors_zone_id') . tep_draw_hidden_field('instructors_state');
      }
    } else {
      $state_load=true;
      $display_text='&nbsp;' . ENTRY_STATE_TEXT;
    }
	if($state_load){
		echo tep_draw_pull_down_menu('instructors_state', $zones_array,$itInfo->instructors_state,' id="instructors_state" '.((count($zones_array)>0)?'':' style="display:none" '));
	    echo tep_draw_input_field('instructors_state1',((count($zones_array)>0)?'':$instructors_state),' id="instructors_state1" '.((count($zones_array)<=0)?'':' style="display:none" '));
	    echo $display_text;
	}
	?>
	</td>
         </tr>
        </table></td>
      </tr>
	   <?php tep_content_title_bottom();
       		 tep_content_title_top("Contact",'',false,$show_hidden);
       ?>
      <tr>
        <td ><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main" width="150"><?php echo TEXT_TELEPHONE; ?></td>
            <td class="main">
<?php
  if ($is_read_only){
  	echo $itInfo->instructors_telephone;	
  } else if ($error == true) {
    if ($instructors_telephone_error == true) {
      echo tep_draw_input_field('instructors_telephone', $itInfo->instructors_telephone, 'maxlength="32"') . '&nbsp;' . ENTRY_TELEPHONE_NUMBER_ERROR;
    } else {
      echo $itInfo->instructors_telephone . tep_draw_hidden_field('instructors_telephone');
    }
  } else {
    echo tep_draw_input_field('instructors_telephone', $itInfo->instructors_telephone, 'maxlength="32"') . '&nbsp;' . ENTRY_TELEPHONE_NUMBER_TEXT;
  }
?></td>
          </tr>
          <tr>
            <td class="main" width="150"><?php echo TEXT_MOBILE_NUMBER; ?></td>
            <td class="main">
<?php

  if ($is_read_only){
  	echo $itInfo->instructors_fax;	
  } else if ($error == true) {
    if ($processed == true) {
      echo tep_draw_input_field('instructors_fax', $itInfo->instructors_fax, 'maxlength="32"') . '&nbsp;' ;
    } else {
      echo $itInfo->instructors_fax . tep_draw_hidden_field('instructors_fax');
    }
  } else {
    echo tep_draw_input_field('instructors_fax', $itInfo->instructors_fax, 'maxlength="32"');
  }

  if ($login_groups_type==TEXT_INSTRUCTOR_ENTRY) $is_read_only=true;
?></td>
          </tr>
        </table></td>
      </tr>
	  
     <?php tep_content_title_bottom(); ?>
     <?php tep_content_title_top("Details",'',false,$show_hidden); ?>
			<tr>
			<td >
			<table border="0" cellspacing="2" cellpadding="2">
              <?php reset($options_array);
					while(list($oid,)=each($options_array)){
						if ($options_array[$oid]['text']!=""){
			?>
              <tr> 
                <td class="main"><?php echo $options_array[$oid]['text'] . ": "; ?></td>
                <td class="main"> 
                  <?php
									  if ($is_read_only){
									  	if ($error==true){
										  	echo $itInfo->$options_array[$oid]['field_name'] . tep_draw_hidden_field($options_array[$oid]['field_name']);
										} else {
											echo $itInfo->$options_array[$oid]['field_name'] . '<input type="hidden" name="' . $options_array[$oid]['field_name'] . '" value="' . tep_output_string($itInfo->$options_array[$oid]['field_name']) . '">';
										}
									  } else {
											if ($error == true){
											 echo $itInfo->$options_array[$oid]['field_name'] . tep_draw_hidden_field($options_array[$oid]['field_name']);
										  } else {
											 echo tep_draw_pull_down_menu($options_array[$oid]['field_name'], $options_array[$oid]['values'], $itInfo->$options_array[$oid]['field_name']);
										  }
									  }
									?>
                </td>
              </tr>
              <?php		}
					}
			?>
              <tr> 
                <td class="main" width="150"><?php echo TEXT_DESCRIPTION; ?></td>
                <td class="main"> 
                  <?php
						  if ($is_read_only){
						  	if ($error){
							  	echo $itInfo->instructors_description  . tep_draw_hidden_field('instructors_description');
							} else {
						    	echo $itInfo->instructors_description  . '<input type="hidden" name="instructors_description" value="' . tep_output_string($itInfo->instructors_description) . '">';
							}
						  } else  {
							  if ($error == true) {
								 echo $itInfo->instructors_description . tep_draw_hidden_field('instructors_description');
							  } else {
								 echo tep_draw_input_field('instructors_description', $itInfo->instructors_description,'maxlength=200 size=50');
							  }
						  }
						?>
                </td>
              </tr>
            </table>
			</td>
		</tr>
     <?php tep_content_title_bottom(); ?>
	 	<tr><td><?php echo tep_draw_separator('pixel_trans.gif','20','20');?></td></tr>
	  </table>
<?php	}

	function get_save_details($iID){
		global $HTTP_POST_VARS,$login_groups_type,$error,$entry_firstname_error,$entry_lastname_error,$entry_email_address_error; 
		global $entry_date_of_birth_error,$entry_email_address_check_error,$entry_street_address_error,$entry_post_code_error,$entry_city_error;
		global $entry_country_error,$entry_state_error,$entry_telephone_error,$entry_email_address_exists; 
		$error=false;
		
			$admin_firstname = tep_db_prepare_input($HTTP_POST_VARS['admin_firstname']);
			$admin_lastname = tep_db_prepare_input($HTTP_POST_VARS['admin_lastname']);
			$admin_email_address=$HTTP_POST_VARS['admin_email_address'];
		  	$admin_password = tep_db_prepare_input($HTTP_POST_VARS['admin_password']);
			
			$instructors_gender = tep_db_prepare_input($HTTP_POST_VARS['instructors_gender']);
			$instructors_street_address = tep_db_prepare_input($HTTP_POST_VARS['instructors_street_address']);
			$instructors_suburb = tep_db_prepare_input($HTTP_POST_VARS['instructors_suburb']);
			$instructors_city = tep_db_prepare_input($HTTP_POST_VARS['instructors_city']);
			$instructors_state = tep_db_prepare_input($HTTP_POST_VARS['instructors_state']);						
      		if($instructors_state=='' || $HTTP_POST_VARS['instructors_state1']!="") $instructors_state = tep_db_prepare_input($HTTP_POST_VARS['instructors_state1']);
      		
			$instructors_country = tep_db_prepare_input($HTTP_POST_VARS['instructors_country']);
			$instructors_postcode = tep_db_prepare_input($HTTP_POST_VARS['instructors_postcode']);
			$instructors_suburb = tep_db_prepare_input($HTTP_POST_VARS['instructors_suburb']);
			
			$instructors_telephone = tep_db_prepare_input($HTTP_POST_VARS['instructors_telephone']);
			$instructors_fax = tep_db_prepare_input($HTTP_POST_VARS['instructors_fax']);
			/*$instructors_department = tep_db_prepare_input($HTTP_POST_VARS['instructors_department']);
			$instructors_position = tep_db_prepare_input($HTTP_POST_VARS['instructors_position']);
			$instructors_qualifications = tep_db_prepare_input($HTTP_POST_VARS['instructors_qualifications']);*/
			
			$instructors_description=tep_db_prepare_input($HTTP_POST_VARS['instructors_description']);
			$instructors_payment=tep_db_prepare_input($HTTP_POST_VARS['instructors_payment']);

			$instructors_dob = tep_db_prepare_input($HTTP_POST_VARS['instructors_dob']);
			
			if (strlen($admin_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
				$error = true;
				$entry_firstname_error = true;
			} else {
				$entry_firstname_error = false;
			}
			
			if (strlen($admin_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
				$error = true;
				$entry_lastname_error = true;
			} else {
				$entry_lastname_error = false;
			}
			
			if (tep_check_date_raw($instructors_dob,EVENTS_DATE_FORMAT)) {
				$entry_date_of_birth_error = false;
			} else {
				$error = true;
				$entry_date_of_birth_error = true;
			}
			
			
			if (!tep_validate_email($admin_email_address)) { 
				$error = true;
				$entry_email_address_check_error = true;
			} else {
				$entry_email_address_check_error = false;
			}
			
			if (strlen($instructors_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
				$error = true;
				$entry_street_address_error = true;
			} else {
				$entry_street_address_error = false;
			}

			if (strlen($instructors_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
				$error = true;
				$entry_post_code_error = true;
			} else {
				$entry_post_code_error = false;
			}

			if (strlen($instructors_city) < ENTRY_CITY_MIN_LENGTH) {
				$error = true;
				$entry_city_error = true;
			} else {
				$entry_city_error = false;
			}

			if ($instructors_country == false) {
				$error = true;
				$entry_country_error = true;
			} else {
				$entry_country_error = false;
			}

			if (ACCOUNT_STATE == 'true') { 
				if ($entry_country_error == true) {
					$entry_state_error = true;
				} else { 
					$zone_id = 0;
					$entry_state_error = false;
					$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$instructors_country . "'");
					$check_value = tep_db_fetch_array($check_query);
					$entry_state_has_zones = ($check_value['total'] > 0);
					if ($entry_state_has_zones == true) {
						$zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$instructors_country . "' and zone_name = '" . tep_db_input($instructors_state) . "'");
						if (tep_db_num_rows($zone_query) == 1) {
							$zone_values = tep_db_fetch_array($zone_query);
							$entry_zone_id = $zone_values['zone_id'];
						} else { 
							$error = true;
							$entry_state_error = true;
						}
					} else {
						if ($instructors_state == false) {
							$error = true;
							$entry_state_error = true;
						}
					}
				}
			}
			if (strlen($instructors_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
				$error = true;
				$entry_telephone_error = true;
			} else {
				$entry_telephone_error = false;
			}

			$check_email = tep_db_query("select admin_email_address from " . TABLE_ADMIN . " where admin_email_address = '" . tep_db_input($admin_email_address) . "' and admin_id != '" . $iID . "'");
			if (tep_db_num_rows($check_email)) {
				$error = true;
				$entry_email_address_exists = true;
			} else {
				$entry_email_address_exists = false;
			} 
				
			if ($error == false) {
				if($iID>0){

				$sql_data_array = array('admin_firstname' => $admin_firstname,
										'admin_lastname' => $admin_lastname,
										'admin_email_address' =>$admin_email_address);
				$admin_id = tep_db_prepare_input($iID); 
					if (!($admin_password == '*****' || $admin_password == '')) {
					 $sql_data_array['admin_password'] = tep_encrypt_password($admin_password);
				}	 
				
				tep_db_perform(TABLE_ADMIN, $sql_data_array, 'update', "admin_id = '" . (int)$admin_id . "'"); 
				} else {
					$makePassword = randomize();
					$encription_style=(defined('ENCRYPTION_STYLE'))?ENCRYPTION_STYLE:'O';
					$sql_data_array = array('admin_groups_id' => '2',
										  'admin_firstname' => $admin_firstname,
										  'admin_lastname' => $admin_lastname,
										  'admin_email_address' => $admin_email_address,
										  'admin_hide_backend'=>'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();
				}
				
				$sql_data_array1=array();
				$sql_data_array = array('instructors_dob' => tep_convert_date_raw($instructors_dob,EVENTS_DATE_FORMAT),
										'instructors_gender'=>$instructors_gender,
										'instructors_street_address'=>$instructors_street_address,
										'instructors_suburb'=>$instructors_suburb,
										'instructors_city'=>$instructors_city,
										'instructors_state'=>$instructors_state,
										'instructors_country'=>$instructors_country,
										'instructors_postcode'=>$instructors_postcode,
										'instructors_telephone'=>$instructors_telephone,
										'instructors_fax' => $instructors_fax);
				if ($login_groups_type!=TEXT_INSTRUCTOR_ENTRY) {										
					/*$sql_data_array['instructors_department']=$instructors_department;
					$sql_data_array['instructors_position']=$instructors_position;
					$sql_data_array['instructors_qualifications']=$instructors_qualifications;*/
					$sql_data_array['instructors_description']=$instructors_description;
					$sql_data_array['instructors_payment']=$instructors_payment;
					$instructs_query=tep_db_query("select * from " . TABLE_INSTRUCTORS_OPTIONS . " where options_display='Y'");
					//$sql_data_array1['']
				}
				if ($iID>0){ 
					tep_db_perform(TABLE_INSTRUCTORS, $sql_data_array, 'update', "admin_id = '" . (int)$admin_id . "'");
					$id_query=tep_db_query("select instructors_id from " . TABLE_INSTRUCTORS . " where admin_id='" . $admin_id . "'");
					$id_result=tep_db_fetch_array($id_query);
				if($login_groups_type!=TEXT_INSTRUCTOR_ENTRY) { 	
					tep_db_query("delete from " . TABLE_INSTRUCTORS_OPTIONS_TO_OPTION_VALUES . " where instructors_id='" . $id_result['instructors_id']. "'");
					while($instructs_result=tep_db_fetch_array($instructs_query)){
						$sql_data_array1['options_id']='instructors_' . $instructs_result['options_key'];
						$sql_data_array1['options_values_id']=$HTTP_POST_VARS['instructors_' . $instructs_result['options_key']];
						$sql_data_array1['instructors_id']=$id_result['instructors_id'];
						tep_db_perform(TABLE_INSTRUCTORS_OPTIONS_TO_OPTION_VALUES,$sql_data_array1);
					}
				}	
					$new_id=false;
					echo get_updated_details($iID,$new_id);
				} else {
					$sql_data_array['admin_id']=$admin_id;
					tep_db_perform(TABLE_INSTRUCTORS, $sql_data_array, 'insert');
					$id = tep_db_insert_id();
					if($login_groups_type!=TEXT_INSTRUCTOR_ENTRY) { 
						while($instructs_result=tep_db_fetch_array($instructs_query)){
							$sql_data_array1['options_id']='instructors_' . $instructs_result['options_key'];
							$sql_data_array1['options_values_id']=$HTTP_POST_VARS['instructors_' . $instructs_result['options_key']];
							$sql_data_array1['instructors_id']=$id;
							echos($sql_data_array1);
							tep_db_perform(TABLE_INSTRUCTORS_OPTIONS_TO_OPTION_VALUES,$sql_data_array1);
						}
					}
					//send mail
					$merge_details=array(TEXT_FN=>$admin_firstname,
										TEXT_LN=>admin_lastname ,
										TEXT_LE=>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'=>$admin_firstname . ' ' . $admin_lastname,
											 'to_email'=>$admin_email_address,
											 'from_name'=>STORE_OWNER,
											 'from_email'=>STORE_OWNER_EMAIL_ADDRESS));
					tep_send_default_email("AUT",$merge_details,$send_details);
					
					$new_id=true;
					echo $admin_id. '{|}';
					echo get_updated_details($admin_id,$new_id);
				}
				
		
		} elseif ($error == true) { 
				$itInfo = new objectInfo($HTTP_POST_VARS); 
				$processed = true;
				echo  get_edit_details($iID);
		}
	}
	
	function get_updated_details($iID,$new_row){
	$instructor_query=tep_db_query("select admin_firstname,admin_lastname, admin_email_address from " . TABLE_INSTRUCTORS ." i, " . TABLE_ADMIN ." a where a.admin_id=i.admin_id and a.admin_id='" . $iID . "'");
	$instructor_result=tep_db_fetch_array($instructor_query);
	if($new_row){
		$result='<div id="data_'. $iID . '"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr height="25">' .
									'<td class="dataTableContent" width="200">'. $instructor_result['admin_firstname'] . ' ' . $instructor_result['admin_lastname'] .'</td><td class="dataTableContent">'. $instructor_result['admin_email_address'] .'</td></tr></table></div>'.
									'<div id="head_' .$iID. '" style="display:none"></div></td></tr>';
	} else {
	$result .='<table cellpadding="2" cellspacing="2" border="0" width="100%">';
					$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr>';
					$result.='<tr><td class="main" width="125">' . TEXT_INSTRUCTOR_NAME . '</td><td class="main">' . $instructor_result['admin_firstname'] . ' ' . $instructor_result['admin_lastname'] . '</td><td class="main" width="125">' . TEXT_EMAIL_ADDRESS . '</td><td class="main">' . $instructor_result['admin_email_address'] . '</td><tr>';
					$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr></table>';
	}				
	echo $result . '{#}' .$instructor_result['admin_firstname'] . ' ' . $instructor_result['admin_lastname'] . '{#}' . $instructor_result['admin_email_address'] ;				
	}
	
	function get_delete_details($iID){
		$result.='<table cellpadding="2" cellspacing="2" border="0" width="100%">'.
					'<tr><td width="15">' . tep_image('images/template/img_trash.gif') . '</td><td class="inner_title">' . TEXT_INFO_HEADING_DELETE_INSTRUCTOR . '</td></tr>'.
					'<tr><td width="15"></td><td class="main">' . TEXT_DELETE_INTRO . '</td></tr>'.
					'<tr><td colspan="2">'. tep_draw_separator('pixel_trans.gif','10','10') . '</td<tr>'.
					'</table>' ;
		return $result;			
	}
	
	function display_instructor(){
		global $keywords,$query_instructor,$page,$instructors_split,$instructors_query_numrows,$search_fnd,$login_groups_id,$HTTP_GET_VARS; 
		
   	 $search = ''; 
	 if($keywords!=''){
	 	$search_fnd=true;
      $search = " and (a.admin_lastname like '%" . tep_db_input($keywords) . "%' or a.admin_firstname like '%" . tep_db_input($keywords) . "%' or a.admin_email_address like '%" . tep_db_input($keywords) . "%')";
    }
		$instructors_query_raw = "select a.admin_id, a.admin_lastname, a.admin_firstname, a.admin_email_address from " . TABLE_INSTRUCTORS . " i, " .TABLE_ADMIN . " a, " . TABLE_ADMIN_GROUPS . " ag where ag.admin_groups_name='" . TEXT_INSTRUCTOR_ENTRY . "' and i.admin_id=a.admin_id and a.admin_groups_id=ag.admin_groups_id " . $search . $query_instructor . " order by a.admin_id desc";
		
		$instructors_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $instructors_query_raw, $instructors_query_numrows);
		$instructors_query = tep_db_query($instructors_query_raw);
		$it_total=0;
	$admin_check_query=tep_db_query("select admin_groups_name from " . TABLE_ADMIN_GROUPS . " where admin_groups_id='" . $login_groups_id . "'");
	$admin_check_result=tep_db_fetch_array($admin_check_query);
	$login_groups_name=$admin_check_result['admin_groups_name'];
		echo '<table cellpadding="0" cellspacing="0" border="0" width="100%" id="instruct_table">';
		if(tep_db_num_rows($instructors_query)>0){
			while ($instructors = tep_db_fetch_array($instructors_query)) {
				if(($it_total % 2) == 0) $class="dataTableRowEven";
				else $class="dataTableRowOdd";
			  $it_total++;
				echo '          <tr class="' . $class . '" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" id="row_' .$instructors['admin_id'].'" onclick="javascript:if(document.getElementById(\'head_' . $instructors['admin_id'] . '\').style.display==\'none\') do_page_fetch(\''. $instructors['admin_id'].'\',\'get_details\');" height="25">' . "\n";
				?>				<td><div id="data_<?php echo $instructors['admin_id']; ?>">
										<table cellpadding="0" cellspacing="0" border="0" width="100%">
											<tr height="25">
												<td class="dataTableContent" width="200"><?php echo $instructors['admin_firstname']; ?>&nbsp;<?php echo $instructors['admin_lastname']; ?></td>
												<td class="dataTableContent"><?php echo $instructors['admin_email_address']; ?></td>
											</tr>
										</table>
									</div>
									<div id="head_<?php echo $instructors['admin_id'];?>" style="display:none" class="openContent"></div>
								</td>	
							  </tr>
		<?php $instructor_id=$instructors['admin_id'];
			}
			if($instructor_id>0) echo '<script>var instuct_id="' . $instructor_id . '"</script>';
		} else echo '<tr><td class="main" align="center" id="no_instructors">' . TEXT_NO_INSTRUCTORS . '</td></tr>';  ?>
			<div id="loading" style="display:none"><div style="height:30px;margin-left:30px"><img src="images/24-1.gif"></div></div>
						<tr id="new_details" style="display:none" class="openContent">
							<td>	
								<table cellpadding="1" cellspacing="0" border="0" width="100%">
									<tr class="openContent_top">
										<td class="inner_title" width="90%"><?php echo HEADING_NEW_INSTRUCTOR;?></td>
										<td width="10%" align="right"><input type="image" src="images/template/img_savel.gif" alt="save" title="save" border="0">&nbsp;&nbsp;<a href="javascript:do_page_fetch('','close');"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>
									</tr>
									<tr><td colspan="2"><div id="span_new" style="display:none"></div></td></tr>
								</table>
							</td>
						</tr>			<!--	<tr><td><div id="span_new_loading"></div><div id="span_new" style="display:none" class="openContent"></div> </td></tr>-->
						<tr><td><?php echo tep_draw_separator('pixel_trans.gif',5,10); ?></td></tr>
							<tr><td><table border="0" width="100%" cellspacing="0" cellpadding="2">
							  <tr>
								<td class="smallText" valign="top"><?php echo $instructors_split->display_count($instructors_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page, TEXT_DISPLAY_NUMBER_OF_INSTRUCTORS); ?></td>
								<td class="smallText" align="right"><?php echo $instructors_split->display_script_links($instructors_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page, 'page_navigation','do_page_navigation(\'\'' ,'\'\''); ?></td>
                  			</tr>	
						</table>
					</td>
				</tr>			
				  	          <tr><td ><table border="0" width="100%" cellspacing="0" cellpadding="0">
		  <tr><td><?php echo tep_draw_separator('pixel_trans.gif',5,10); ?></td></tr>
		  <tr><td align="right">
                  <?php  
                     if (($search_fnd)) 
                          echo '<a href="javascript:document.getElementById(\'img_new\').style.display=\'\';document.getElementById(\'search_instructor\').value=\'\';do_page_fetch(\'\',\'page_navigation\')">' . tep_image_button('button_reset.gif', IMAGE_RESET) . '</a>';
	          ?></td>
                  </tr>
                </table></td>
              </tr>

				 </table>
		
	<?php }
	
		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;
	}
	
?>			
<script language="javascript">
var return_flag = '';
<?php if($HTTP_GET_VARS['actions']=='edit_instructors'){ ?>
	return_flag = 1;
	do_page_fetch('<?php echo $HTTP_GET_VARS['instuctors_id']; ?>','get_details');
<?php } ?>
</script>