<?php
/*
  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd 

*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
   require('includes/application_top.php');
   require('includes/classes/split_page_results_event.php');
   tep_get_last_access_file();// get input entries to find type of entry
   $action = (isset($HTTP_GET_VARS['action']) ? tep_db_prepare_input($HTTP_GET_VARS['action']) : '');
   $action_value = (isset($HTTP_GET_VARS['action_value']) ? tep_db_prepare_input($HTTP_GET_VARS['action_value']) : '');
   $location_id=(isset($HTTP_GET_VARS['lID'])?(int)$HTTP_GET_VARS['lID']:'');
   $page = (isset($HTTP_GET_VARS['page']) ? (int)$HTTP_GET_VARS['page'] :1);
   if($action!=""){
   	  if($action=='get_details'){
   	  	  echo_get_details();
   	  }else if ($action=='option_add'){
	     $sql_data=array('equipment_name'=>tep_db_prepare_input($HTTP_GET_VARS['edit_equipment']));
	     tep_db_perform(TABLE_EVENTS_LOCATIONS_OPTIONS,$sql_data);
	     echo 'option_add'.$HTTP_GET_VARS['edit_equipment'];
	  } else if ($action=='option_update'){
	     $sql_data=array('equipment_name'=>tep_db_prepare_input($HTTP_GET_VARS['edit_equipment']));
	     tep_db_perform(TABLE_EVENTS_LOCATIONS_OPTIONS,$sql_data,'update','equipment_name="' . tep_db_input($HTTP_GET_VARS['cbo_equipment']) . '"');
	     echo 'option_update'.tep_db_prepare_input($HTTP_GET_VARS['edit_equipment']);
	  } else if ($action=='option_delete'){
	   	 $sql_data=tep_db_query("DELETE FROM " . TABLE_EVENTS_LOCATIONS_OPTIONS . " where equipment_name='" . tep_db_input($HTTP_GET_VARS['cbo_equipment']) . "'");
	   	 echo 'delete_option';	   	
	  }else if($action=='page_navigation'){ 
	     echo $action;
		 table_write(); 
	  }else if($action=='edit_location'){ 
		    $equipment_query=tep_db_query("SELECT equipment_name from " . TABLE_EVENTS_LOCATIONS_OPTIONS . ' order by equipment_name');
		    $ecnt=tep_db_num_rows($equipment_query);
		    $equipment_array=array();			
			$equipment_modified_array=array();
			$equipment_array[]=array('id'=>"",'text'=>'none');
		    while ($result=tep_db_fetch_array($equipment_query)){
		      $equipment_array[]=array('id'=>$result['equipment_name'],'text'=>$result['equipment_name']);
			  $equipment_modified_array[]=array('id'=>$result['equipment_name'],'text'=>$result['equipment_name']);
		    }				
		    $cnt=0;
		    $location_info=array('location_id'=>0,
								 'location_name'=>'',
								 'location_details'=>'',
								 'location_travel_directions'=>'',
								 'location_equipment'=>'',
								 'location_contact_person'=>'',
								 'location_seats'=>'1'
					 			);					 			  
		     if($location_id){
		        $location_info_query=tep_db_query("SELECT * from " . TABLE_EVENTS_LOCATIONS . " where location_id='" . (int)$HTTP_GET_VARS['lID'] . "'");
			 	$location_info=tep_db_fetch_array($location_info_query);				
				$cnt=tep_db_num_rows($location_info_query);
			}
		    $lInfo=new objectInfo($location_info);		    
		    if($location_id) echo 'edit';
		    else echo 'new';		    
			tep_create_location();		        				   					    
		  }else if($action=='delete_location'){
			$location_string = 'delete';
		 	$location_string .="<table border='0' cellspacing='2' cellpadding='2' width='100%'><tr><td width='17' align='center'>".tep_image('images/template/img_trash.gif').'</td>';
		 	$location_string .='<td width="500" align="left" class="inner_title">'.IMAGE_DELETE_LOCATION . '</td></tr>';
		 	$location_string .='<tr><td></td><td width="500" align="left" class="main">'.TEXT_DELETE_INTRO. '<br></td></tr></table>';
			$location_string .='<tr><td colspan="2">'.tep_draw_separator('pixel_trans.gif',60,20).'</td></tr></table>';
		 	echo $location_string;
        }else if($action=='update_location'){
			$location_name=(isset($HTTP_POST_VARS['location_name'])?$HTTP_POST_VARS['location_name']:'');
			$location_details=(isset($HTTP_POST_VARS['location_details'])?$HTTP_POST_VARS['location_details']:'');
			$location_travel_directions=(isset($HTTP_POST_VARS['location_travel_directions'])?$HTTP_POST_VARS['location_travel_directions']:'');
			
			$location_equipment=(isset($HTTP_POST_VARS['equipment_name'])? @implode(",", $HTTP_POST_VARS['equipment_name']) : '');
			$location_contact_person=(isset($HTTP_POST_VARS['location_contact_person'])?$HTTP_POST_VARS['location_contact_person']:'');
			$location_seats=(isset($HTTP_POST_VARS['location_seats'])?$HTTP_POST_VARS['location_seats']:''); 			

			$sql_data = array(  'location_name' => $location_name,
								'location_details' =>$location_details,
								'location_travel_directions'=>$location_travel_directions,
								'location_equipment'=>$location_equipment,
								'location_contact_person'=>$location_contact_person,
								'location_seats'=>(int)$location_seats
							 );
		if ($location_id>0 && $HTTP_POST_VARS['action_type']=='edit'){  
			tep_db_perform(TABLE_EVENTS_LOCATIONS, $sql_data, 'update', "location_id = '" . $location_id . "'");				
		}
		else  if($HTTP_POST_VARS['action_type']=='new'){
			tep_db_perform(TABLE_EVENTS_LOCATIONS, $sql_data);
			$location_id = tep_db_insert_id();
			echo 'new_location';				
		}				  		
		echo_get_details();  	  	  		    
   	 }else if($action=='delete_confirm'){   	    
	 	// check child entries in events table.	 	
		$child_query=tep_db_query("SELECT count(*) as total_count from " . TABLE_EVENTS . " where events_location='" . (int)$location_id . "'");
		$child_result=tep_db_fetch_array($child_query);
		if ((int)$child_result['total_count']<=0){
	           tep_db_query("DELETE from " . TABLE_EVENTS_LOCATIONS . " where location_id='" . $location_id . "'");	           
	           echo 'delete_success';	     
		}else  echo 'delete_error'.ERROR_LOCATIONS_CHILD_FOUND;		
   	 }
   	 exit;
   }        
   function echo_get_details(){
  	 global $location_id;	
  		$location_query = tep_db_query("select * from " . TABLE_EVENTS_LOCATIONS . " where location_id='".(int)$location_id."' order by location_name");
		if(tep_db_num_rows($location_query)>0){
			$location=tep_db_fetch_array($location_query);
			while(list($key,$vals)=each($location)){						
			 	if($key=='location_details' || $key=='location_travel_directions')								
		 			$vals = str_replace("\n","", $vals);			 																							 	
				$str_vals.=$vals."||";	
			}
		}else $str_vals="No Record Found";	
		echo 'get_details'.$str_vals;
  }

  function table_write(){
    global $page,$HTTP_GET_VARS;	
   ?>
  	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<?php
		$search = '';
    	if (isset($HTTP_GET_VARS['search']) && tep_not_null($HTTP_GET_VARS['search']))  $search = " where  (location_name like '%" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search'])) . "%' OR (location_contact_person like '%".tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']))."%') )";  
	 	$location_query_raw="select location_id,location_name,location_details,location_contact_person,location_seats from " . TABLE_EVENTS_LOCATIONS . $search.' order by location_id desc';
		$resource_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $location_query_raw, $resource_query_numrows);
		$location_query = tep_db_query($location_query_raw);		   
		if(tep_db_num_rows($location_query)>0){ 
		  while ($locations = tep_db_fetch_array($location_query)) {					 
				 $class="dataTableRowEven";
  				 if($rows%2==0) $class="dataTableRowOdd"; 					
  				 $rows++;
  				 echo '  <tr style="height:25" class="'.$class.'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$locations['location_id'].'\').style.display==\'none\') expand_category(' . $locations['location_id'] . ',3);">' . "\n"; 
			   ?>  			      
		   	  <td colspan="4" width="100%">
		   	  	<div id="data_<?php echo $locations['location_id'];?>">
		   	  	 <table border="0" cellspacing="0" cellpadding="0" width="100%">
		   	  		<tr>
		   	  			<td class='dataTableContent' width="150" align="left"><?php echo $locations['location_name']; ?></td>
		      			<td class='dataTableContent' width="250" align="left"><?php echo ((strlen($locations['location_details'])>50)?substr($locations['location_details'],0,50).'...':$locations['location_details']); ?></td>
		      			<td class='dataTableContent' width="150" align="left"><?php echo $locations['location_contact_person']; ?></td>				      			
		   	  		</tr>
		   	  	</table>
		   	   </div>
		   	   <div class="openContent" id="head_<?php echo $locations['location_id'];?>" style="display:none"></div>
		   	  </td>					      
      		</tr>
      	<?php } echo '<tr><td colspann="4">' . tep_draw_separator('pixel_trans.gif','1','10') . '</td></tr>';
		  } else if($HTTP_GET_VARS['search']=='') { ?>
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr>
				<td class="main" id="empty_location" align="center"><?php echo TEXT_EMPTY_LOCATION;?></td>
			</tr>
		</table>
<?php }	 if($HTTP_GET_VARS['search']!=""){?>
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
		<?php if(tep_db_num_rows($location_query)<=0){ ?>
			<tr>
				<td class="main" align="center"><?php echo N0_SEARCH_RESULT;?></td>
			</tr>
		<?php } ?>	
			<tr>
				<td class="main" align="center"><?php echo tep_draw_separator('pixel_trans.gif','10','10');?></td>
			</tr>
			<tr>
				<td align="right"><a href="javascript:expand_category(1,'1','reset')"><?php echo tep_image_button('button_reset.gif', IMAGE_RESET);?></a></td>
			</tr>
		</table>	
<?php } ?>			      	
		</table>
<?php 	if(tep_db_num_rows($location_query)>0){ ?>	
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr>				  
		         <td class="smallText" valign="top"><?php echo $resource_split->display_count($resource_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page,TEXT_DISPLAY_NUMBER_OF_LOCATIONS); ?></td>
		    	 <td class="smallText" align="right"><?php echo $resource_split->display_script_links($resource_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page,1,'expand_category(\'\'','\'\''); ?></td>
		    </tr>
		</table>
<?php  } 
  }

function tep_create_location(){ 
	global 	$HTTP_GET_VARS,$HTTP_POST_VARS;	
	$equipment_array=array();			
	$equipment_modified_array=array();
	//$equipment_array[]=array('id'=>"",'text'=>'none');
	$equipment_array_selected = array(array('id' => ''));
	$equipment_array_selected[] = array('id' => $HTTP_POST_VARS['location_equipment']);
	
	$equipment_query=tep_db_query("SELECT equipment_name from " . TABLE_EVENTS_LOCATIONS_OPTIONS . ' order by equipment_name');
    while ($result=tep_db_fetch_array($equipment_query)){
	
	//$equipment_array_selected[]=array('id'=>$result['equipment_name'],'text'=>$result['equipment_name']);
      $equipment_array[]=array('id'=>$result['equipment_name'],'text'=>$result['equipment_name']);
	  
	  $equipment_modified_array[]=array('id'=>$result['equipment_name'],'text'=>$result['equipment_name']);
    }
    $location_info=array();
    $location_info_query=tep_db_query("SELECT * from " . TABLE_EVENTS_LOCATIONS . " where location_id='" . (int)$HTTP_GET_VARS['lID'] . "'");
	if(tep_db_num_rows($location_info_query)>0) $location_info=tep_db_fetch_array($location_info_query);
	$lInfo=new objectInfo($location_info);
?>

	<table border="0" cellspacing="0" cellpadding="4" width="100%">
			   <?php if(!$HTTP_GET_VARS['lID']) { ?><tr class="openContent_top">					
			   		<td class="inner_title"><?php echo HEADING_NEW_TITLE;?></td>
					<td width='100%' align='right' id='img_save'><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:expand_category(0,1);'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td></tr><?php } ?>			   
			    <tr>
				 <td valign="top">
				  <table border="0" cellspacing="2" cellpadding="4"  >							     
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_NAME;?></td>
						<td class="main"><?php echo tep_draw_input_field('location_name',$lInfo->location_name,'size=42 maxlength=100');?></td>
					</tr>
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_MAX_SEATS;?></td>
						<td class="main"><?php echo tep_draw_input_field('location_seats',$lInfo->location_seats,'size=7 maxlength=6');?></td>
					</tr>
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_CONTACT; ?></td>
						<td class="main"><?php	echo tep_draw_input_field('location_contact_person',$lInfo->location_contact_person,'size=42 maxlength=64'); ?></td>
					</tr>	
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_DETAILS; ?></td>
						<td class="main"><?php echo tep_draw_textarea_field('location_details','true','39','4',$lInfo->location_details);?></td>
					</tr>					
				</table>
			</td>
			<td>
				  <table border="0" cellspacing="2" cellpadding="4">
				 				 	 
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_EQUIPMENT; ?></td>
						<td class="main"><?php
						$sel_str_array=split(",",$lInfo->location_equipment);

						$equipment_query=tep_db_query("SELECT equipment_name from " . TABLE_EVENTS_LOCATIONS_OPTIONS . ' order by equipment_name');
						?>
						<div class="inputNormal" style="width:240px;height:100px;overflow:auto;border:solid 1px #CCCCCC;">
						<?php 
						while($equipment_array=tep_db_fetch_array($equipment_query)){
						$check_flag="";
						for($i=0;$i<sizeof($sel_str_array);$i++)
							if(strtolower($sel_str_array[$i])==strtolower($equipment_array['equipment_name']))
								$check_flag=" checked ";
						?>
						<input name="equipment_name[]" value="<?php echo $equipment_array['equipment_name']; ?>" type="checkbox" <?php echo $check_flag; ?>><?php echo $equipment_array['equipment_name']; ?><br>
						<?php } ?>
						</div>
						</td>					
					</tr>
					<tr valign="top">
						<td class="main"><?php echo TEXT_LOCATION_DIRECTIONS; ?></td>
						<td class="main"><?php echo tep_draw_textarea_field('location_travel_directions',true,'35','4',$lInfo->location_travel_directions); ?></td>
					</tr>
				  </table>
			</td>
		</tr>		
<?php tep_content_title_top(TEXT_LOCATION_EQUIPMENT); ?>
		<tr>
			<td>
				<table cellpadding="2" cellspacing="0" border="0" width="50%">					
					<tr valign="top">
						<td class="main" width="130" align="left"><?php echo TEXT_EQUIPMENT_NAME; ?></td>
						<td valign="top" align="left" width="190"><?php echo tep_draw_pull_down_menu('cbo_equipment',$equipment_modified_array,'',' size ="8" style="width:155" onChange="show_equipment()"') ?></td>
						<td class="main" width="100" align="left">
							<table cellpadding="2" cellspacing="0" border="0" width="100%">
								<tr><Td>
										<?php echo tep_image_button('button_insert.gif',IMAGE_INSERT_EQUIPMENT,'class="cursorHand" align="absmiddle" onClick="javascript:expand_category(\'\',6)"') . '<br><br>' ; 
											  if (sizeof($equipment_array)>0) echo tep_image_button('button_update.gif',IMAGE_UPDATE_EQUIPMENT,'class="cursorHand" align="absmiddle" onClick="javascript:expand_category(\'\',7)"'). '<br><br>' ;
											  if (sizeof($equipment_array)>0) echo tep_image_button('button_delete.gif',IMAGE_DELETE_EQUIPMENT,'class="cursorHand" align="absmiddle" onClick="javascript:expand_category(\'\',8);"'); ?>
									</td>
								</tr>
						    </table>				  		
						</td>
					</tr>
					<tr>						
						<td>&nbsp;</td>
						<td class="main" align="left" colspan="2"><?php  echo tep_draw_input_field('edit_equipment','','style="width:155" maxlength="64"') ; ?></td>						
					</tr>    
				</table>
			</td>
		</tr> 
<?php  	tep_content_title_bottom(); ?>
	  <tr><td colspan='8'><img src='images/pixel_trans.gif' border='0' alt='' width='100%' height='20'></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>
<script language=javascript>
   var action_types=new Array();
   action_types[1]='location';
   action_types[2]='option_add';
   action_types[3]='option_update';
   action_types[4]='option_delete';
   var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
   function validateForm(lfrm){
      var error_result="";
      if(document.getElementById("action_type")) var action_type=document.getElementById("action_type").value;
	  if(document.getElementById("location_id")) id=document.getElementById("location_id").value;
	  var span_details=document.getElementById("span_details");
	  var span_edit=document.getElementById("span_edit");				
	  var span_delete=document.getElementById("span_delete");
	  var loadings=document.getElementById("loading");
	  var ids="";	  		 
	 
	  if(span_edit && span_edit.style.display=="" || document.getElementById("new_create") && document.getElementById("new_create").style.display==""){		  		  
	  obj= document.getElementById("location_name").value;
	  obj1=document.getElementById("location_contact_person").value;
	  
			  if (obj=="" ||  str_trim(obj)=='' ) 
				   error_result+="<?php echo tep_output_string(ERR_EMPTY_LOCATION_NAME); ?>\n";		      
			  if (document.getElementById("location_seats").value=="" || document.getElementById("location_seats").value<=0) 
				   error_result+="<?php echo tep_output_string(ERR_INVALID_LOCATION_SEATS); ?>\n";		       		  
			  
			  /*if (document.getElementById("location_equipment") && document.getElementById("location_equipment").selectedIndex<=0)
				   error_result+="<?php //echo tep_output_string(ERR_EMPTY_EQUIPMENT_NAME); ?>\n";		  	  */
			  var equip_flag=0;
			  for(i=0;i<document.getElementsByName('equipment_name[]').length;i++){
			  		if(document.getElementsByName('equipment_name[]')[i].checked==true)
						equip_flag=1;
			  }
			  if(equip_flag==0)
			  	error_result+="<?php echo tep_output_string(ERR_EMPTY_EQUIPMENT_NAME); ?>\n";
			  if (obj1=="" ||  str_trim(obj1)=='' ) 
				   error_result+="<?php echo tep_output_string(ERR_EMPTY_CONTACT_PERSON); ?>\n";		       		  
	  if (error_result!=""){
         alert(error_result);
	 	 return false;
      }else if(span_edit && span_edit.style.display=="" || document.getElementById("new_create") && document.getElementById("new_create").style.display==""){      							
			if(action_type=='edit')  ids="&lID="+id;
			command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=update_location');?>"+ids;
			if(loadings) loadings.style.display="";
			if(span_edit) span_edit.style.display="none";
			if(document.getElementById("new_create")){ document.getElementById("new_create").style.display="none";
			document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
			display_flag=1;
			}
      }
	}else if(span_delete.style.display==""){      							
			ids="&lID="+id;
			command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=delete_confirm');?>"+ids;
			if(loadings) loadings.style.display="";
			if(span_delete) span_delete.style.display="none";
     }
	do_post_command('location_detail',command);	
    return false;
   }
	 
   function check_data_exists(dataAdd,mode){
		frm=document.location_detail;
		sIndex=-1;
		dataAdd2=dataAdd.toLowerCase();
		if (mode=="option_update") sIndex=frm.cbo_equipment.selectedIndex;
		for (icnt=0;icnt<frm.cbo_equipment.length;icnt++){
		dataAdd1=frm.cbo_equipment.options[icnt].text;
		dataAdd1=dataAdd1.toLowerCase();
		if(icnt!=sIndex && dataAdd1 == dataAdd2){
			return true;
		}
	}
	return false;
	}
	
	function setFormAction(lvalue){ 
  		var frm=document.location_detail;
		var dataAdd=frm.edit_equipment.value;
		var sIndex=frm.cbo_equipment.selectedIndex;
		 	 if (check_data_exists(dataAdd,action_types[lvalue])){
				alert('<?php echo TEXT_EQUIPMENT_ALREADY_EXISTS; ?>');
				return false;	
			}	else return true;
    }
	
   function show_equipment(){
	  var index=document.location_detail.cbo_equipment.selectedIndex;
      	if (index>=0) document.location_detail.edit_equipment.value=document.location_detail.cbo_equipment.options[index].value;
   		}
  
   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) expand_category(1,'1','search');
   }
var previous_id='';  
   function expand_category(id,category,r_type,sta_type){ 	 
		//if(category==3 && document.getElementById('head_'+id) && document.getElementById('head_'+id).style.display!='none' && document.getElementById("span_edit") && document.getElementById("span_edit").style.display=='none' && document.getElementById("span_delete") && document.getElementById("span_delete").style.display=='none') return;
	if(id==0 && category==2){
		if(document.getElementById('empty_location'))
				document.getElementById('empty_location').style.display='none';
		display_flag=0;
	}
	if(id==0 && category==1){
		if(document.getElementById('empty_location'))
				document.getElementById('empty_location').style.display='';
		document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
		display_flag=1;
	}
		var sta_type;
		var span_details=document.getElementById("span_details");
 	 	var span_edit=document.getElementById("span_edit");			
		var span_delete=document.getElementById("span_delete");
		if(!sta_type) sta_type="";
		var frm=document.location_detail;
		if(category=='1' && document.getElementById("page_''") && sta_type!=""){
 	 		id=parseInt(document.getElementById("page_''").options[document.getElementById("page_''").selectedIndex].value);
 	 		if(sta_type=='next' && document.getElementById("page_''")) {
 	 			if(document.getElementById("page_''").length==document.getElementById("page_''").selectedIndex+1) return;
 	 			id+=1;
 	 		}else if(sta_type=='prev') {
 	 			if(document.getElementById("page_''").selectedIndex==0) return;
 	 			id-=1;
 	 		}
 	 		if(id<=1) id=1;
 	 	}else if(category==1 && sta_type=="") id="";
 	 	
 	 	if(category=='1' && document.getElementById("new_create").style.display=="")	 	 		
 	 		document.getElementById("new_create").style.display="none";	 	 	
 	 	if(category==2 && id==0 && frm && frm.location_id.value>0 && document.getElementById("head_"+frm.location_id.value) && document.getElementById("data_"+frm.location_id.value)){
			if(span_edit) span_edit.innerHTML="";
			document.getElementById("head_"+frm.location_id.value).style.display="none";
			document.getElementById("data_"+frm.location_id.value).style.display="";
 	 	}
		
		var res_display=document.getElementById("res_display"); 	 	 	 	 	 	 	 	 	 		 	  	 	
 	 	if(res_display) res_display.style.display="none"; 	 		 	 	
 	 	 if(frm && frm.location_id && frm.location_id.value>0)  {
			var old_ids=frm.location_id.value;			
			var pre_data_id=document.getElementById("data_"+old_ids);
			var pre_head=document.getElementById("head_"+old_ids);			
			var loadings=document.getElementById("loading");
			if(loadings) loadings.style.display="none";
			//if(category==1 && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }		 	 
			if(id>0 && frm.location_id.value>0 && frm.location_id.value!=id){			   
			   if(pre_head && pre_head.style.display=="") pre_head.style.display="none";
			   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
			   frm.location_id.value=id;			   
			}							
		//if(category!=1 && frm && frm.location_id && frm.location_id.value=="") frm.location_id.value=id;		 								 	 	 	 
		if(id>0 && category!=1 && frm && frm.location_id) frm.location_id.value=id;		 								 	 	 	 
		if(category){
			var data_id=document.getElementById("data_"+id);						
			var head=document.getElementById("head_"+id);
			var img_save=document.getElementById("img_save");			
			var command="";																		 
 	 		switch(category){
 	 			case '1': 	 			       
 	 			       var ser="";
 	 			       var page=""; 	 			       
 	 			       if(document.getElementById("search") && document.getElementById("search").value!="" && sta_type=="" && r_type=='search') {
					   	ser="&search="+document.getElementById("search").value;
						id="";
 	 			       }else if(document.getElementById("search") && document.getElementById("search").value!="" && sta_type=="" && r_type=='reset') {
					   	document.getElementById("search").value="";
					   }else if(document.getElementById("search") && document.getElementById("search").value=="" && sta_type=="" && r_type=='search'){
						display_flag=1;
						document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
						return;
					   }else if(document.getElementById("search") && document.getElementById("search").value=="" && sta_type=="" && r_type=='reset') id=1;
 	 			       if(id!="") page="&page="+id;
 	 			       command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=page_navigation');?>"+page+ser;
 	 			   	   if(document.getElementById("ajax_details")) document.getElementById("ajax_details").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 			break;
 	 			case 2: 	 				  	 				  	 				  	 					
 	 				 if(span_details) span_details.style.display="none";
 	 				 if(frm.action_type) frm.action_type.value='new';
 	 				 document.getElementById("new_create").style.display="";
 	 				 document.getElementById("new_create").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 				 command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=edit_location');?>"; 	 				   	 				  	 				  	 				  	 				  	 		
 	 			break; 	 			
 	 			case 3:
 	 			   if(document.getElementById("new_create")){ document.getElementById("new_create").style.display="none"; 	 			   
				   document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
					display_flag=1;
				   }
 	 			   if(head && head.style.display==""){
 	 			   	  if(span_details.style.display==""){
 	 			   	    head.style.display="none"; 	 			   	    
 	 			   	  	data_id.style.display=""; 	 			   	  	
 	 			   	  }else {
 	 			   	  	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';	 	 			   	  			
 	 			   	  	}	 			   	  	  	 			   	  	 	 			   	  	
 	 			   	  }	 	 			    			   	   	 			   
 	 			 }else { 	 		
				 	if(previous_id!='')
						if(document.getElementById('head_'+previous_id))
							document.getElementById('head_'+previous_id).innerHTML='';	 	 	 			 	
 	 			 	if(data_id && data_id.style.display=="") data_id.style.display="none";
 	 			 	if(pre_head && pre_head.style.display=="") pre_head.style.display="none"; 	 			 	
 	 			 	if(head) {
 	 			 	 	head.style.display=""; 	 			 	 	 	 			 	  	 			
 	 			 		head.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	 			 		
 	 			 	}
 	 			 	command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=get_details');?>&lID="+id; 
					 previous_id=id;			 	
 	 			 }
 	 			break;
 	 			case 4:
 	 					if(span_edit)span_edit.style.display=""; 	 					
 	 					if(span_details)span_details.style.display="none";
						if(span_delete)span_delete.style.display="none";
 	 					if(span_edit)span_edit.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					if(document.getElementById("new_create"))document.getElementById("new_create").innerHTML="";
 	 					if(frm.action_type) frm.action_type.value='edit'; 	 					
 	 					command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=edit_location');?>&lID="+id; 	 		 	 					 	 					 	 				 	 		
 	 			break; 	 			
 	 			case 5:	 	 				 	 				 	 		 	 				
 	 					span_delete.style.display="";
 	 					span_edit.style.display=span_details.style.display="none";
 	 					span_delete.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=delete_location');?>&lID="+id; 	 	 	 					 	 					 	 			
 	 			break; 	
 	 			case 6:
 	 				if(frm.edit_equipment){
 	 					if(frm.edit_equipment.value==""){
 	 						alert("<?php echo ERR_EMPTY_EQUIPMENT_NAME;?>");
 	 						return false;
 	 					}else if(frm.edit_equipment.value!=""){
						 if(setFormAction(frm.edit_equipment.value)){
 	 						if(document.getElementById("equip")) {
 	 							document.getElementById("equip").style.display="";
 	 							document.getElementById("equip").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	
 	 						} 	 						 	 					
 	 						command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=option_add');?>&edit_equipment="+frm.edit_equipment.value;
 	 						if(document.getElementById("icnt")) document.getElementById("icnt").value=""; 
 	 					}
						}
 	 				}	
 	 			break;				 																
				case 7:
					if(frm.edit_equipment){
 	 					if(frm.edit_equipment.value==""){
 	 						alert("<?php echo ERR_EMPTY_EQUIPMENT_NAME;?>");
 	 						return false;
 	 					}else if(frm.cbo_equipment.selectedIndex>=0 && frm.edit_equipment.value!="" && frm.cbo_equipment.options[frm.cbo_equipment.selectedIndex].value!=frm.edit_equipment.value){
						  if(setFormAction(frm.edit_equipment.value)){
							if(document.getElementById("equip")) {
 	 							document.getElementById("equip").style.display="";
 	 							document.getElementById("equip").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	
 	 						}
 	 						command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=option_update');?>&edit_equipment="+frm.edit_equipment.value+"&cbo_equipment="+frm.cbo_equipment.options[frm.cbo_equipment.selectedIndex].value;
 	 						if(document.getElementById("icnt")) document.getElementById("icnt").value=frm.cbo_equipment.selectedIndex;
 	 					}
					  }	
 	 				}
				break;								
				case 8:			
					if(frm.cbo_equipment.selectedIndex==-1){
						alert("<?php echo ERR_EMPTY_EQUIPMENT_NAME;?>");
 	 						return false;
					}if(document.getElementById("icnt") && frm.cbo_equipment.selectedIndex>=0){
 	 						command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=option_delete');?>&cbo_equipment="+frm.cbo_equipment.options[frm.cbo_equipment.selectedIndex].value;
 	 						document.getElementById("icnt").value=frm.cbo_equipment.selectedIndex;
 	 						if(document.getElementById("equip")) {
 	 							document.getElementById("equip").style.display="";
 	 							document.getElementById("equip").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	
 	 						}
 	 					}  	 				
				break;							
 	 		}
 	 		if(command!="") do_get_command(command);
 	 	}		
 	 }  	
   function do_result(result){
   	  var frm=document.location_detail;
   	  if(result!=""){
   	    if(result.substr(0,11)=='get_details') print_details('get_details',result.substr(11));
   	    else if(result.substr(0,4)=='edit') print_details('edit',result.substr(4));  	 		 				 				
		else if(result.substr(0,14)=='delete_success') print_details('delete_success',result.substr(14));		
		else if(result.substr(0,12)=='delete_error') print_details('delete_error',result.substr(13)); 										
		else if(result.substr(0,15)=='page_navigation') print_details('page_navigation',result.substr(15));
		else if(result.substr(0,12)=='new_location') print_details('new_location',result.substr(23));
		else if(result.substr(0,3)=='new' && document.getElementById("new_create"))
			document.getElementById("new_create").innerHTML=result.substr(3);
		else if(result.substr(0,10)=='option_add')	print_details('option_add',result.substr(10));						   	  
		else if(result.substr(0,13)=='option_update')	print_details('option_add',result.substr(13));
		else if(result.substr(0,13)=='delete_option') print_details('delete_option',result.substr(13));			
		else if(result.substr(0,6)=='delete') print_details('delete',result.substr(6));		
   	  }
   }
   function print_details(category,result){  	 	 	 	 	 	 	 	 	
 	 	var no_result="";
 	 	var frm=document.location_detail;
		if(result.substr(0,15)=='No Record Found'){
 	 		no_result="No Record Found";
 	 	}else if(result!='' && result.length>0 && category!='edit' && result.substr(0,15)!='No Record Found'){
 	 		splt_str=result.split("||"); 	 		  	 		
 	 		var  location_id="";
			var  location_name="";
			var  details="";						
			var  equipment="";
			var  contact_person="";																				
			var  seats="";
 	 		location_id=splt_str[0]; 	 		
 	 		location_name=splt_str[1];
 	 		details=splt_str[2]; 	 		 	 		 	 								
 	 		equipment=splt_str[4];
			contact_person=splt_str[5];
			seats=splt_str[6];
 	 	}	 		  	 		 	 	 	  	 		 	  	 
 		if(frm && frm.location_id) var id=frm.location_id.value; 		
 		//if(frm && frm.location_id) var id=location_id;
		//alert(id);
		var span_details=document.getElementById("span_details");	
 		var span_edit=document.getElementById("span_edit"); 	 		 	 		
 		var span_delete=document.getElementById("span_delete");				 	
 		var head=document.getElementById("head_"+id); 		 		 		  
 		var data_id=document.getElementById("data_"+id);
 		var res_display=document.getElementById("res_display");
 		var equip=document.getElementById("equip");
 		var img_save=document.getElementById("img_save");
		if(img_save && category!='get_details') img_save.style.display="";		
 	 	switch(category){ 	 		 	 		 	 		 	 		
 	 		case 'get_details': 	
 	 		if(head  && no_result!="")
				head.innerHTML=no_result; 	 			 	 		
 	 		else if(head && no_result==""){	 		
	 	 		if(data_id){		 	 		
		 	 		data_id.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						         '<tbody><tr>'+
						         	'<td class="dataTableContent" width="230" align="left">'+location_name+'</td>'+
						         	'<td class="dataTableContent" align="left" width="380">'+((details.length>50)?details.substr(0,50)+"...":details)+'</td>'+			         	
					  			 	'<td class="dataTableContent" align="left">'+contact_person+'</td>'+  
						         '</tr>'+
						      '</tbody></table>';	
	 	 		}		 	 			
	 	 		include ="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				"<tr heigth='40' class='openContent_top'>"+				  				  							  
				  "<td align='left' valign='middle' width='350' class='inner_title'>"+location_name+"</td>"+
				  "<td width='470' align='left' class='main' valign='top'>"+
				  	"<table border='0' cellspacing='0' cellpadding='0' style='width:100;height:30px;display:inline;position:relative;'>"+
				  	  "<tr class='img_move' id='img_ids'>"+
				  	  	"<td class='cell_bg_popm_left' width='10'>&nbsp;</td>"+
				  	    "<td width='10%' onclick='javascript:change_class(this,1);expand_category("+location_id+",4);' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);'><img alt='Edit' title='Edit' src='images/template/img_edit.gif'></td>"+
				  	    "<td width='10%' onclick='javascript:change_class(this,1);expand_category("+location_id+",5);' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(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='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:expand_category("+location_id+",3);'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>"+
				"</tr>"+
				"<tr style='height:10'><td id='loading' style='display:none' colspan='5'><img src='images/24-1.gif' alt='Loading...' title='Loading...'></td></tr>"+				
				"<tr>"+
				  "<td colspan='8' class='main'><span style='display:none' id='span_edit'></span><span style='display:none' id='span_delete'></span><span id='span_details'>"+	
				  "<table width='100%' border='0' cellspacing='0' cellpadding='0' border='2'>"+
				  		"<tr>"+
				  			"<td><img src='images/pixel_trans.gif' border='0' alt='' width='50' height='10'></td>"+				  							  			
							"<td>"+				  							  			
				  				"<table width='50%' border='0' cellspacing='0' cellpadding='2' class='main'>";				  														
									if(equipment!=""){
									include+="<tr>"+
											"<td align='left' width='35%'><b><?php echo TEXT_LOCATION_EQUIPMENT;?></b></td>"+
											"<td align='left' width='65%'>"+equipment+"</td>"+
										"</tr>";
									}
									if(contact_person!=""){
										include+="<tr>"+
											"<td align='left' width='35%'><b><?php echo TEXT_LOCATION_CONTACT;?></b></td>"+
											"<td align='left' width='65%'>"+contact_person+"</td>"+
										"<tr>";
									}
									if(seats!=""){
										include+="</tr>"+
											"<td align='left' width='35%'><b><?php echo TEXT_LOCATION_MAX_SEATS;?></b></td>"+
											"<td align='left' width='65%'>"+seats+"</td>"+
										"</tr>";
									}
				  			  include+="</table></td></tr>"+
							  "<tr>"+
				  				"<td><img src='images/pixel_trans.gif' border='0' alt='' width='10' height='10'></td><td align='left' valign='middle' class='main'><div style='width:500;height:50;overflow:auto;'>"+
				  					details
				  				"</div></td>"+
							  "</tr>"+							  							  							
					"</span>"+
				  "</td>"+
				"</tr>"+
			"</table>";
			head.innerHTML=include;
 	 		} 	 			 	 		
 	 	break;
 	 	case 'edit': 	 		 	 		 	 		 	 		
			if(span_edit) span_edit.style.display="";			
 	 		if(span_edit && span_details){ 	 			 	 			
 	 			span_edit.innerHTML=result; 	 			
 	 			span_details.style.display='none';
 	 		}									  
 	 	toggle_panel('Equipment:_','false','','0');	     					 		  												
 	 	break;
 	 	case 'delete': 	 				 	 	
 	 		if(span_delete) span_delete.style.display="";
 	 		if(span_delete){ 	 			
 	 			span_delete.innerHTML=result; 	 			
 	 			span_details.style.display=span_edit.style.display='none';
 	 		} 	 								   			   
 	 	break; 	 	
 	 	case 'delete_success':			 
 	    	 var len=1;
			 if(head && data_id) {
			 	var tbl_obj=head.parentNode.parentNode.parentNode.parentNode;			 				 				 	
			 	if(tbl_obj) tbl_obj.deleteRow(head.parentNode.parentNode.rowIndex);
			 	data_id.innerHTML=head.innerHTML="";
			 	data_id.style.display=head.style.display="none";			 				 			
			 }
			 if(res_display){
	    	 	res_display.innerHTML="<?php echo TEXT_EVENT_DELETE_SUCCESS;?>";
 	    	 	res_display.style.display="";
				var obj=document.getElementById("page_''");
 	    	 	if(obj) 
				    len=obj.options[obj.selectedIndex].value;
 	    	 		command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=page_navigation');?>&page="+len;
					do_get_command(command); 
			 }
			 if(document.getElementById("search")) document.getElementById("search").value=""; 								   			   
 	 	break;	
 	 	case 'delete_error':
 	 		if(document.getElementById("location_id") && document.getElementById("location_id").value>0) expand_category(document.getElementById("location_id").value,3);
			document.getElementById("res_display").style.display="";
			document.getElementById("res_display").innerHTML=result.substr(12);
 	 	break;
 	 	case 'page_navigation':
 	 		if(document.getElementById("ajax_details"))
 	 		 document.getElementById("ajax_details").innerHTML=result;
 	 	break;	 	 	
		case 'new_location':
				var len=1;
			/*	if(result!=""){
					result_splt=result.split('||');
					if(result_splt[0]>0){						
						var id=result_splt[0];
						var location_name=result_splt[1];	
						var resource_costs=result_splt[2];						
						if(head) {    						
    						var tbl_obj=head.parentNode.parentNode.parentNode.parentNode;    						
    						var row_obj=tbl_obj.insertRow(tbl_obj.rows.length);
    						var row_cell=row_obj.insertCell(0);
    						row_cell.innerHTML='<div id="data_'+id+'">'+
						       '<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						         '<tbody><tr>'+
						         	'<td class="dataTableContent" width="150" align="left">'+location_name+'</td>'+
						         	'<td class="dataTableContent" width="250" align="left">'+details+'</td>'+			         	
					  			 	'<td class="dataTableContent" width="150" align="left">'+contact_person+'</td>'+  
						         '</tr>'+
						      '</tbody></table>'+
						      '</div>'+
						      '<div style="display:none;" class="openContent" id="head_'+id+'"></div>';						    						      
    						var rows_cnt=tbl_obj.rows.length-1;
    						var tbl=tbl_obj.rows[rows_cnt];
    						tbl.onclick=function () {((document.getElementById("head_"+id) && document.getElementById("head_"+id).style.display=='none')?expand_category(id,3):'')};
    						tbl.style.height="25px"; 
    						if(rows_cnt%2==0) tbl.className="dataTableRowOdd";
    						else tbl.className="dataTableRowEven";
    						tbl.onmouseover=function (){rowOverEffect(this)};
    						tbl.onmouseout=function (){rowOutEffect(this)};
    						if(head && data_id){
    							head.style.display="none";
    							data_id.style.display="";
    						}
    						if(res_display){
					    	 res_display.innerHTML="<?php echo TEXT_LOCATION_INSERT_SUCCESS;?>";
				 	    	 res_display.style.display=""; 	    	 	
 	    	 				}
						}    					
					}   */
				 command="<?php echo tep_href_link(FILENAME_EVENTS_LOCATIONS,'action=page_navigation');?>&page="+len;
				 do_get_command(command);
				 if(document.getElementById("search")) document.getElementById("search").value=""; 								   			   
				//}																			 						
		break;
		case 'option_add':
			if(frm.cbo_equipment && result!=""){
				var option = document.createElement('option');
				var option1 = document.createElement('option');				
				var pos=null;
				if(document.getElementById("icnt") && document.getElementById("icnt").value!="") pos=document.getElementById("icnt").value;
				option.text = option1.text = result;
				option.value = option1.value = result;				
				var optionElement = document.getElementById("cbo_equipment");
				var optionElement1=frm.location_equipment;
				if(equip) equip.innerHTML="<?php echo EQUIPMENT_ADDED_SUCCESS;?>";
				if(equip && pos!=null && result!="") equip.innerHTML="<?php echo EQUIPMENT_UPDATED_SUCCESS;?>";
				try {										
					if(pos!=null) {
						optionElement1.options[parseInt(pos)+1].text=optionElement1.options[parseInt(pos)+1].value=optionElement.options[pos].text=optionElement.options[pos].value=result; // standards compliant; doesn't work in IE												
					}else {
						//optionElement1.add(option,null);
						optionElement.add(option1,null); // standards compliant; doesn't work in IE
					}					  
				}catch(ex) {
					if(pos==null) {
						//optionElement1.add(option);
						optionElement.add(option1); // IE only
					}					 
				}								
				optionElement.selectedIndex=((pos==null)?optionElement.length-1:pos);
			}
			expand_category(id,4);
			if(equip && equip.style.display=="") setTimeout("equip.style.display='none'",2000);
		break;
		case 'delete_option':
			if(document.getElementById("icnt")) pos=document.getElementById("icnt").value;
			 var optionElement = document.getElementById("cbo_equipment");
			 var optionElement1=frm.location_equipment;
			 if(optionElement && optionElement1) {
			 	optionElement.remove(pos);			 	
			 	optionElement1.remove(parseInt(pos)+1);			 	
			 	if(equip && equip.style.display=="") {
			 		equip.innerHTML="<?php echo EQUIPMENT_DELETED_SUCCESS;?>";
			 		setTimeout("equip.style.display='none'",2000);
			 		if(document.getElementById("edit_equipment")) document.getElementById("edit_equipment").value="";	
			 	}
			 }
		expand_category(id,4);
		break;
 	 	}
 	 	if(res_display && res_display.style.display=="") setTimeout("res_display.style.display='none'",2000); 	 	 	 	 	 	
 	 	clearTimeout();
	  } 
	  function change_class(obj,eve){ 		 		 	 	
		 var span_details=document.getElementById("span_details"); 
		 var span_edit=document.getElementById("span_edit");
		 var span_delete=document.getElementById("span_delete");				 		 			 
		 if(obj){		   		    		    
		    var img_get_src=obj.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_new_hover.gif'){				   		
			   		if(eve==1 || eve==2) img_get_src.src=img_src+'template/img_new.gif';					
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_new.gif') 
			    	img_get_src.src=img_src+'template/img_new_hover.gif';			    
			    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';		    		    		     		   	
		  }
		 }		 
	  }	
	 
	 var display_flag=1;	
	function 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;
	} 
	 
</script>
<?php  // WebMakers.com Added: Java Scripts   
      include(DIR_WS_INCLUDES . 'javascript/' . 'webmakers_added_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 //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="4">
  <tr> 
<!-- body_text //-->   
             <td valign="top">
              <table border="0" cellspacing="0" cellpadding="0" width=100%>
              <tr class="dataTableHeadingRow">
                 	<td colspan="3">
                 		<table border="0" cellspacing="0" cellpadding="0" width=100%>	
                 			<tr>
                 				<td valign="bottom" class="pageHeading" align="left" width="10%"><a alt="New Location" title="New Location" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,1);" id="img_new" href="javascript:expand_category(0,2);"><?php echo tep_image('images/template/img_new.gif','New Location','22','22');?></a></td>
							 	<td class="dataTableHeadingContent" align="right" valign="absmiddle" width="60%"></td>
							 	<td class="dataTableHeadingContent" align="right" valign="absmiddle" width="25%"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search','','onkeyup="javascript:check_key(event)"') . '&nbsp;';?><a alt="Search" title="Search" href="javascript:expand_category(1,'1','search');"><?php echo tep_draw_separator('pixel_trans.gif','5','5') . tep_image('images/template/img_search.gif','Search','','',' align=absmiddle');?></a></td>
                 			</tr>
                 		</table>
                 	</td>                 	
               </tr>
			   <tr><td><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td></tr>
               <tr>
                <td>
            
			
             <?php echo tep_draw_form('location_detail',FILENAME_EVENTS_LOCATIONS, '' ,'post','onsubmit="javascript:return validateForm(this);"');?>
	       		<table border="0" cellspacing="0" cellpadding="0" width=100%>                 
                 <tr><td id="res_display" class="main" style="display:none" width="250"></td></tr>
                 <tr class="dataTableHeadingRow" height=20 valign="top">
				     <td class="main" width="150"><b><?php echo TABLE_HEADING_NAME; ?></b></td>
				     <td class="main" width="250"><b><?php echo TABLE_HEADING_DETAILS; ?></b></td>
				     <td class="main" width="150"><b><?php echo TABLE_HEADING_CONTACT; ?></b></td>				     
                 </tr>
                 <tr>
                  	<td colspan="3" id="ajax_details">
						<?php table_write(); ?>
					</td>
		 		 </tr>	
		 		 <tr>
		 		 	<td colspan="3">
		 		 		<table border="0" cellspacing="0" cellpadding="0" width="100%">
		 		 				<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '2', '10'); ?></td></tr>
							    <tr><td colspan="3" style="display:none" class="openContent" id="new_create"><?php tep_create_location();?></td></tr>
		 		 		</table>
		 		 	</td>
		 		 </tr>	 		                			 		 		 
        </table>
        </td></tr></table>
        <input type="hidden" name="location_id" id="location_id">
	    <input type="hidden" name="action_type" id="action_type">
	    <input type="hidden" name="icnt" id="icnt">
        </form>
        </td>      
<!-- body_text_eof //-->
<!-- body_eof //-->
	</tr>			
  </table>
<!-- footer //-->
			
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>