<?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');
	tep_get_last_access_file();
	require(DIR_WS_CLASSES . 'currencies.php');
	require('includes/classes/split_page_results_event.php');
	$currencies = new currencies();
	$server_date = getServerDate(true);
	$language_query=tep_db_query("select * from ".TABLE_LANGUAGES);
	$language_count=tep_db_num_rows($language_query);
	$resource_id = tep_db_prepare_input($HTTP_GET_VARS['itID']);
	$current_date=date('Y-m-d');
	$page = isset($HTTP_GET_VARS['page'])?$HTTP_GET_VARS['page']:1;
	$position=isset($HTTP_GET_VARS['position'])?$HTTP_GET_VARS['position']:$HTTP_POST_VARS['sort_order_id'];
	$action=(($HTTP_GET_VARS['action'])?$HTTP_GET_VARS['action']:'');
	if($action!=""){
		  $languages = tep_get_languages();
		  $search = '';
		  $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));
		  $resource_id = tep_db_prepare_input($HTTP_GET_VARS['itID']);
		  #get tax descriptions to display in tax selection
		  $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
		  $tax_class_query = tep_db_query("SELECT tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
		  while ($tax_class = tep_db_fetch_array($tax_class_query)) {
			$tax_class_array[] = array('id' => $tax_class['tax_class_id'],
										 'text' => $tax_class['tax_class_title']);
		  }		 		  
		  if($action=='get_details') echo_get_details();			     		    
		  else if($action=='update'){		 	
		 	if(!$resource_id) $action='insert';  
		 	$sort_id=1;
		 	if($action=='update')  $sort_id=$position;		 	
			$max_sql = "select max(sort_order) as max_total from " . TABLE_RESOURCES;
   			$max_query = tep_db_query($max_sql);	
			$max_total = tep_db_fetch_array($max_query);			
			if($action!='update') $sort_id=($max_total['max_total']+1);
			$sql_data_array = array('resource_tax_class_id'=>tep_db_prepare_input($HTTP_POST_VARS['resource_tax_class_id']),
									'resource_costs'=>tep_db_prepare_input($HTTP_POST_VARS['resource_costs_net']),
									'sort_order'=>$sort_id);
			$resource_id = tep_db_prepare_input($HTTP_GET_VARS['itID']);					
			if ($action == 'insert') {
				$insert_sql_data = array('resource_date_added' => $server_date);
				$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
				tep_db_perform(TABLE_RESOURCES, $sql_data_array);
				$resource_id = tep_db_insert_id();
			} elseif ($action == 'update') {
				$update_sql_data = array('resource_last_modified' => $server_date);
				$sql_data_array = array_merge($sql_data_array, $update_sql_data);
				tep_db_perform(TABLE_RESOURCES, $sql_data_array, 'update', "resource_id = '" . (int)$resource_id . "'");
			}
			$languages = tep_get_languages();			
					
			for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
				$language_id = $languages[$i]['id'];
				$sql_data_array = array('resource_name' => tep_db_prepare_input($HTTP_POST_VARS['resource_name'][$language_id]),
			 					       'resource_description' => tep_db_prepare_input($HTTP_POST_VARS['resource_description'][$language_id]));
				if ($action == 'insert') {
				$insert_sql_data = array(	'resource_id' => $resource_id,
									'language_id' => $language_id);
					
				$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
					tep_db_perform(TABLE_RESOURCES_DESCRIPTION, $sql_data_array);
				  } elseif ($action == 'update') {
					tep_db_perform(TABLE_RESOURCES_DESCRIPTION, $sql_data_array, 'update', "resource_id = '" . (int)$resource_id . "' and language_id = '" . (int)$language_id . "'");
				  }				
				}	
			  if(!$HTTP_GET_VARS['itID']) {
				 echo 'new_resource'.$resource_id.'||'.$HTTP_POST_VARS['resource_name'][$languages_id].'||'.$currencies->format(tep_add_tax($HTTP_POST_VARS['resource_costs_net'],tep_get_tax_rate($HTTP_POST_VARS['resource_tax_class_id'])));;
			  }	
			  else echo_get_details(); 		  								  			  	  		 
		  }else if($action=='edit'){	
			if (!is_array($resources)) $resources=array();			
			$resources_query = tep_db_query("select rd.language_id,r.resource_id, r.resource_costs,  r.resource_tax_class_id, rd.resource_name,  rd.resource_description,r.sort_order from  ". TABLE_RESOURCES_DESCRIPTION . " rd," . TABLE_RESOURCES . " r where r.resource_id='" . $HTTP_GET_VARS['itID'] . "' and r.resource_id=rd.resource_id");
			if(tep_db_num_rows($resources_query)>0)
				$resources = tep_db_fetch_array($resources_query);
			else{
				$resources=array(
		  	  		'resource_id'=>'',
		  	  		'resource_tax_class_id'=>'',
		  	  		'resource_costs'=>'',
		  	  		'resource_date_added'=>'0000-00-00'		  	  		
		  	  	  );
			}									
		  }else if($action=='pos_down' || $action=='pos_up'){ 		
			  $result='sort_order_error';	
			  $position = isset($HTTP_GET_VARS['pos'])?$HTTP_GET_VARS['pos']:0;
			  if (trim($action) == 'pos_up')
					$sort_query=tep_db_query("select sort_order, resource_id from " . TABLE_RESOURCES . " where  sort_order<" . $position . " order by sort_order desc limit 1");
			  else if($action=='pos_down')
					$sort_query=tep_db_query("select sort_order, resource_id from " . TABLE_RESOURCES. " where sort_order>" . $position . " order by sort_order limit 1");							
				if (tep_db_num_rows($sort_query)>0){						
						$sort_result = tep_db_fetch_array($sort_query);
						$prev_order=$sort_result['sort_order'];
						$result = tep_db_query("update " . TABLE_RESOURCES . " set sort_order='" . $position ."' where resource_id='" . (int)$sort_result['resource_id'] . "'");
						if($result<0) $result='error';												
						$result = tep_db_query("update " . TABLE_RESOURCES . " set sort_order='" . (int)$sort_result['sort_order'] . "' where resource_id='" . $resource_id ."'");
						if($result<0) $result='error';
						$result="sort_order_success^".$prev_order;						
			    }	
			   echo $result; 	 	
		 }else if($action=='delete_confirm'){		 	
			tep_db_query("delete from " . TABLE_RESOURCES . " where resource_id = '" . (int)$resource_id . "'");
			tep_db_query("delete from " . TABLE_RESOURCES_DESCRIPTION . " where resource_id = '" . (int)$resource_id . "'");
			echo 'delete_success'; 
		  }else if($total_rows==0 && $action=='search' && $keywords==""){?>
		 	 <table border="0" cellpadding="0" cellspacing="0" width="100%">
		 	 	<tr>
		 	 		<td align="center" class="main" align><?php echo TEXT_NO_RECORD_FOUND;?></td>
		 	 	</tr>
		 	 </table>
		 <?php }
	 	 if($action=='page_navigation'){	 	  	
		    echo $action;
		    table_write();	 	   
	 	 }
	   if($action=='edit') {
			if(!$HTTP_GET_VARS['itID']) echo 'new';
			else if($HTTP_GET_VARS['itID']>0) echo 'edit';
			create_new_resource();
	   }	   	
	  exit;
   }		
  function echo_get_details(){
  	 global $resource_id,$languages_id,$currencies;	
  		$resource_query = tep_db_query("select r.resource_id, rd.resource_name,rd.resource_description,r.resource_date_added,r.resource_last_modified,r.resource_tax_class_id,r.resource_costs,r.sort_order from " . TABLE_RESOURCES . " r, " . TABLE_RESOURCES_DESCRIPTION . " rd where r.resource_id=rd.resource_id and language_id='" . (int)$languages_id . "' and r.resource_id='".(int)$resource_id."' order by r.sort_order,rd.resource_name");
		if(tep_db_num_rows($resource_query)>0){
			$resource=tep_db_fetch_array($resource_query);
			while(list($key,$vals)=each($resource)){						
			 	if($key=='resource_date_added' || $key=='resource_last_modified')
					$vals=format_date($vals);													
				if($key=='resource_tax_class_id')
					$tax_id = $vals;												
				if($key=='resource_costs')			 		
					$vals = $currencies->format(tep_add_tax($vals,tep_get_tax_rate($tax_id)));
								 		
				$str_vals.=$vals."||";	
			}
		}else $str_vals="No Record Found";	
		echo 'get_details'.$str_vals;
  }
  
  function table_write(){
  global $HTTP_GET_VARS,$languages_id,$page,$currencies,$action;  
  ?>
   <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 = " and (rd.resource_name like '%" . tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search'])) . "%' )";    
    $resource_query_raw = "select r.resource_id, rd.resource_name,r.resource_costs,r.resource_tax_class_id,r.sort_order from " . TABLE_RESOURCES . " r, " . TABLE_RESOURCES_DESCRIPTION . " rd where r.resource_id=rd.resource_id ".$search." and language_id='" . (int)$languages_id . "' order by r.sort_order,rd.resource_name";    
    $resource_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $resource_query_raw, $resource_query_numrows);  
    $resource_query = tep_db_query($resource_query_raw);
    $total_rows=tep_db_num_rows($resource_query);
    $it_total=0;
      if($total_rows>0){
	    while ($resource = tep_db_fetch_array($resource_query)) {
	      $class="dataTableRowEven";
		  if($it_total%2==0) $class="dataTableRowOdd";
	      $it_total++;
	      if ((!isset($HTTP_GET_VARS['itID']) || (isset($HTTP_GET_VARS['itID']) && ($HTTP_GET_VARS['itID'] == $resource['resource_id']))) && !isset($itInfo)) {
	        $itInfo = new objectInfo($resource);
	      }      
	      echo '  <tr class="'.$class.'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$resource['resource_id'].'\').style.display==\'none\') get_resource_details(\'get_details\',' . $resource['resource_id'] . ');">' . "\n";      
		 ?>
			    <td>
			      <div id="data_<?php echo $resource['resource_id'];?>">
			       <table border="0" cellspacing="0" cellpadding="0" width="100%">
			         <tr height="25">		         	
			         	<td class="dataTableContent" width="50%"><?php echo tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '&nbsp;' . $resource["resource_name"] ; ?></td>
			         	<td class="dataTableContent" width="50%"><?php  echo $currencies->display_price($resource["resource_costs"],tep_get_tax_rate($resource["resource_tax_class_id"])); ?></td>			         		  			 	 
			         </tr>
			      </table>
			      </div>
			      <div style="display:none" class="openContent" id="head_<?php echo $resource['resource_id'];?>"></div> 
			    </td>		 		  	 	  	
	       </tr>              
		 <?php
	    	}
      } else if($HTTP_GET_VARS['search']==''){ ?>
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr>
				<td class="main" id="no_record" align="center"><?php echo TEXT_NO_RECORD_FOUND;?></td>
			</tr>
		</table>
<?php }	 if($HTTP_GET_VARS['search']!=""){ ?>
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<?php if($total_rows<=0){?>
			<tr>
				<td class="main" align="center"><?php echo N0_SEARCH_RESULT;?></td>
			</tr>
			<?php } ?>
			<tr>
				<td><?php echo tep_draw_separator('pixel_trans.gif','10','10');?></td>
			</tr>	
			<tr>
				<td align="right"><a href="javascript:get_resource_details('page_navigation',1,'reset')"><?php echo tep_image_button('button_reset.gif', IMAGE_RESET);?></a>		</td>
			</tr>
		</table>		      	
<?php }
	 	  ?>    <tr><td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td></tr>
                <tr>
                	<td colspan="4">
                		<table border="0" width="100%" cellspacing="0" cellpadding="2">
		                  <tr>				  
		                    <td class="smallText" valign="top"><?php echo (($total_rows)?$resource_split->display_count($resource_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page,TEXT_DISPLAY_NUMBER_OF_RESOURCES):''); ?></td>
		                    <td class="smallText" align="right"><?php echo (($total_rows)?$resource_split->display_script_links($resource_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page,1,'get_resource_details(\'page_navigation\'',1):''); ?></td>		                    
		                  </tr>
		  				  <tr><td><?php  echo tep_draw_separator('pixel_trans.gif',5,10); ?></td></tr>		  		 			 	
				  		  <tr>
				  		  	 <td align="right"><?php echo (($search_fnd)?"<a href='javascript:get_resource_details(\'page_navigation\',1,\'reset\');'>" . tep_image_button("button_reset.gif", IMAGE_RESET) . "</a>":"");?></td>
				  		  </tr>
             		   </table>
             		</td>
                </tr>
		</table>		
 <?php  }	
 function create_new_resource(){
  global $HTTP_GET_VARS,$languages,$tax_class_array,$resources;
  $itInfo = new objectInfo($resources);
  ?>    
	<table border="0" cellspacing="0" cellpadding="0" width="100%">
	 <?php if(!$HTTP_GET_VARS['itID']) { ?><tr class="openContent_top"><td class="inner_title"><?php echo TEXT_CREATE_NEW_RESOURCE;?></td><td width='80%' align='right' id='img_save' style="visibility:display"><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href="javascript:get_resource_details('get_details');"><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td></tr><?php } ?>
	   <?php tep_content_title_top("General");?>		
		<tr>
			<td>
			   <table border="0" cellspacing="2" cellpadding="2" width="75%">
					<tr>
					    <td>
						    <table border="0" cellpadding="0" cellspacing="4">
									<?php
									for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
									?>
											<tr>
												<td class="main" width="150"><?php if ($i == 0) echo TEXT_RESOURCE_NAME;?></td>
												<td class="main"><?php 
												echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' .
												tep_draw_input_field('resource_name[' . $languages[$i]['id'] . ']', (isset($resource_name[$languages[$i]['id']]) ? $resource_name[$languages[$i]['id']] :  tep_get_resource_name($itInfo->resource_id, $languages[$i]['id'])),'id=resource_name_value[] size=40');
											 ?></td>
											</tr>
									<?php
									}
									?>
								</table>
								</td>
							</tr>
						<tr>
							<td>
							<table border="0" cellpadding="4" cellspacing="0">
								<?php
								for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
								?>
									<tr>
										<td class="main" valign="top" width="150"><?php if ($i == 0) echo TEXT_RESOURCE_DESCRIPTION; ?></td>
										<td>
										<table border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
												<td class="main"><?php echo tep_draw_textarea_field('resource_description[' . $languages[$i]['id'] . ']', 'soft', '80', '24', (isset($resource_description[$languages[$i]['id']]) ? $resource_description[$languages[$i]['id']] : tep_get_resource_description($itInfo->resource_id, $languages[$i]['id'])),'id="resource_description[' . $languages[$i]['id'] . ']"'); ?></td>
											</tr>
										</table>
										</td>
									</tr>
								<?php
								}
								?>
							</table>
							</td>
						</tr>
				 
			</table></td>
      </tr>
	  <?php 
	  tep_content_title_bottom(); 
	  tep_content_title_top("Fees"); 
	  ?>				
		<tr>
			<td valign="top" colspan="2">
				<table cellpadding="4" cellspacing="0" border="0" width="100%">
						<tr>
							<td class="main" width="100" align="center"><?php echo TEXT_RESOURCE_TAX_CLASS; ?></td>
							<td class="main" width="150"><?php echo tep_draw_pull_down_menu('resource_tax_class_id', $tax_class_array, $itInfo->resource_tax_class_id, 'onchange="updateGross()"'); ?></td>
							<td class="main" width="100" align="center"><?php echo TEXT_RESOURCE_FEES_NET_INFO; ?></td>
							<td class="main" width="150"><?php echo tep_draw_input_field('resource_costs_net',$itInfo->resource_costs, 'onKeyUp="updateGross()"'); ?></td>				
							<td class="main" width="100" align="center"><?php echo TEXT_RESOURCE_FEES_GROSS_INFO; ?></td>
							<td class="main"><?php echo tep_draw_input_field('resource_costs_gross', $itInfo->resource_costs, 'OnKeyUp="updateNet()"'); ?></td>
						</tr>												 													
				</table>
			</td>
	  </tr>		   
	  <?php tep_content_title_bottom(); ?>         
      <tr>
      	 <td colspan="2">
      	 	 <table cellpadding="0" cellspacing="0" border="0" width="100%">	  	
	   	 		<tr align="right">
	   	 			<td width='1200' colspan="2" align='right'><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href="javascript:get_resource_details('get_details'<?php echo (($HTTP_GET_VARS['itID'])?','.$HTTP_GET_VARS['itID']:'');?>);"><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>
	   			</tr>
	         </table>
	     </td>
  	  </tr>
  	  <tr><td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); 
  	  if($itInfo->sort_order!="") echo "<input type='hidden' name='sort_order_id' id='sort_order_id' value='".$itInfo->sort_order."'>"; 
  	  ?></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 type="text/javascript" src="htmlarea/htmlarea.js"></script>
<script type="text/javascript" src="htmlarea/editor.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language="javascript"> 
		var tax_rates = new Array();
		var lang = new Array();
		var max_display="<?php echo MAX_DISPLAY_SEARCH_RESULTS;?>";
		var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
		<?php
		  $tax_class_query = tep_db_query("SELECT tax_class_id from " . TABLE_TAX_CLASS . " order by tax_class_title");
		  while ($tax_class = tep_db_fetch_array($tax_class_query)) {
			echo 'tax_rates["' . $tax_class['tax_class_id'] . '"] = ' . tep_get_tax_rate_value($tax_class['tax_class_id']) . ';' . "\n";
		  }
		  $languages = tep_get_languages();
		  for($i=0;$i<sizeof($languages);$i++){?>
		  		lang[<?php echo $i;?>]="<?php echo $languages[$i]['id'];?>";	
	<?php  } ?>	
		function updateGross() {
		   var taxRate = getTaxRate();		   
		   var grossValue = document.getElementById("resource_costs_net").value;
		   		
		  if (taxRate > 0) {
			grossValue = grossValue * ((taxRate / 100) + 1);
		  }		
		  document.getElementById("resource_costs_gross").value = doRound(grossValue, 4);		  
		  if (grossValue==""){
		   document.getElementById("resource_costs_gross").value="";
		  }
		}
	function updateNet() {
		  var taxRate = getTaxRate();
		  
		  var netValue = document.resource.resource_costs_gross.value;
		
		  if (taxRate > 0) {
			netValue = netValue / ((taxRate / 100) + 1);
		  }
		  document.resource.resource_costs_net.value = doRound(netValue, 4);
		}		
	function doRound(x, places) {
		  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
		}	
	function getTaxRate() {  		
  		var sel_obj=document.getElementById("resource_tax_class_id");
  		var selected_value = sel_obj.selectedIndex;  			  	
   		var parameterVal = sel_obj[selected_value].value;
	  	if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
	    	return tax_rates[parameterVal];
	  	} else {
	    	return 0;
	  	}
	}	
	function isNumeric(value,minimumValue,maximumValue){
		value=parseFloat(value);
		if (isNaN(value)) return false;
		if (value<minimumValue) return false;

		if (maximumValue>0 && value>maximumValue) return false;
		return true;
	}
	function ValidateForm() 
	 {
	 var frm=document.resource;	 
	 var error_result="";	 
	 if(document.resource.action_type) var action_type=document.resource.action_type.value;
	 if(frm && frm.resource_id) id=frm.resource_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").innerHTML!=""){ 		 
		 if (lang[1]>0){
		      if(lang.length>0){
			      for (icnt=0;icnt<lang.length;icnt++){
					obj="resource_name["+lang[icnt]+"]";
					if ( (document.getElementById(obj).value=="") || (str_trim(document.getElementById(obj).value)=="") )
					   error_result="<?php echo tep_db_input(TEXT_ERR_EMPTY_ALL_RESOURCE_NAME); ?>\n";			
			      }
			  }	     
	 	 }else{
	 	  var obj="resource_name["+lang[0]+"]";
	 	  if (lang[0]>0 && ( (document.getElementById(obj).value=="") || (str_trim(document.getElementById(obj).value)=="") ) ) 
			  	error_result="<?php echo tep_db_input(TEXT_ERR_EMPTY_RESOURCE_NAME); ?>\n";
		 } 	 		
		 if(document.getElementById("resource_costs_net").value<=0)
				error_result+="<?php echo tep_db_input(TEXT_ERR_EMPTY_NET_COSTS); ?>\n";
		 else if(isNaN(parseInt(document.getElementById("resource_costs_net").value)))
				error_result+="<?php echo tep_db_input(TEXT_ERR_EMPTY_NET_COSTS); ?>\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(frm.action_type && frm.action_type.value=='edit')  ids="&itID="+id;													
				command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=update');?>"+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 && span_delete.style.display==""){								
				span_details.innerHTML=span_edit.innerHTML="";
				command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=delete_confirm');?>&itID="+id;						
				if(loadings) loadings.style.display=""; 					
				if(span_delete) span_delete.style.display="none";			
	 } 
	 	do_post_command('resource',command);
	 return false;
	}
   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) get_resource_details('search',1,'search');
   }	 
   
  function get_resource_details(action,resource_id,r_type,sta_type){
    if(resource_id==0 && action=='edit'){
 		if(document.getElementById('no_record'))
			document.getElementById('no_record').style.display='none';
		display_flag=0;
	}if(resource_id==0 && action=='page_navigation'){
 		if(document.getElementById('no_record')) document.getElementById('no_record').style.display='';
		document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
		display_flag=1;
	} 	 		
		var span_details=document.getElementById("span_details");
 	 	var span_edit=document.getElementById("span_edit");			
		var span_delete=document.getElementById("span_delete");								
		var data_id=document.getElementById("data_"+resource_id);						
		var head=document.getElementById("head_"+resource_id);
		var img_save=document.getElementById("img_save");
		if(!sta_type) sta_type="";
		var obj=document.getElementById("page_1");
		if(action=='page_navigation' &&  obj && sta_type!=""){
 	 		resource_id=parseInt(obj.options[obj.selectedIndex].value);
 	 		if(sta_type=='next') {
 	 			if(obj.length==obj.selectedIndex+1) return;
 	 			resource_id+=1;
 	 		}else if(sta_type=='prev') {
 	 			if(obj.selectedIndex==0) return;
 	 			resource_id-=1;
 	 		}
 	 		if(resource_id<=1) resource_id=1;
 	 	}else if(action=='page_navigation' && sta_type=="") resource_id="";
 	 	if(action=='page_navigation' && document.getElementById("new_create").style.display=="")	{
 	 		document.getElementById("new_create").innerHTML="";
 	 		document.getElementById("new_create").style.display="none";	
 	 	}
 	 	if(action=='new' && resource_id==0 && document.resource.resource_id && document.resource.resource_id.value>0 && document.getElementById("head_"+document.resource.resource_id.value) && document.getElementById("data_"+document.resource.resource_id.value)){
			if(span_edit) span_edit.innerHTML="";
			document.getElementById("head_"+document.resource.resource_id.value).style.display="none";
			document.getElementById("data_"+document.resource.resource_id.value).style.display="";
			if(document.getElementById("new_create")) document.getElementById("new_create").style.display="";						
 	 	}		 
 	 	var res_display=document.getElementById("res_display");
 	 	if(res_display) res_display.style.display="none";
 	 	 if(action!='page_navigation' && document.resource && document.resource.resource_id && document.resource.resource_id.value>0)  {
			var old_ids=document.resource.resource_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(action=='page_navigation' && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }
		 if(resource_id>0 && document.resource.resource_id.value>0 && document.resource.resource_id.value!=resource_id){			   
			   if(pre_head && pre_head.style.display=="") {
			   		pre_head.innerHTML="";
			   		pre_head.style.display="none";
			   }
			   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
			   document.resource.resource_id.value=resource_id;
		 }
		if(action!='page_navigation' && document.resource && document.resource.resource_id) document.resource.resource_id.value=resource_id;								 								 	 	 	 
 	 	if(action){ 	 		
			var command="";
 	 		switch(action){
 	 			case 'search':
 	 			case 'page_navigation':
 	 			       var ser="";
 	 			       var page="";
 	 			       if(document.getElementById("search") && document.getElementById("search").value!="" && sta_type=="" && r_type=='search') {
					   	ser="&search="+document.getElementById("search").value;
						resource_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') resource_id=1;
 	 			       if(resource_id!="") page="&page="+resource_id; 
 	 			       command="<?php echo tep_href_link(FILENAME_RESOURCES,'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 'new':
					 document.getElementById("new_create").style.display="";
					 document.getElementById("new_create").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 				 if(document.resource.action_type) document.resource.action_type.value='new'; 	 					
 	 				 command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=edit');?>";
 	 			break; 	 			
 	 			case 'get_details':
 	 			   if(document.getElementById("new_create")) {
 	 			   		document.getElementById("new_create").innerHTML="";
 	 			   		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.visibility="hidden"; 
 	 			   	  	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(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_RESOURCES,'action=get_details');?>&itID="+resource_id; 	 			 	 	 			 	
 	 			 }
 	 			break;
 	 			case 'edit':
 	 					span_edit.style.display=""; 	 					
 	 					span_details.style.display=span_delete.style.display="none";
 	 					span_edit.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					if(document.resource.action_type) document.resource.action_type.value='edit'; 	 					
 	 					command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=edit');?>&itID="+resource_id; 	 		 	 					 	 					 	 				 	 		
 	 			break;
 	 			case 'delete':
 	 					span_delete.style.display="";
 	 					span_edit.style.display=span_details.style.display="none"; 	 					
 	 					span_delete.innerHTML='<table border="0" cellspacing="2" cellpadding="1" width="100%"><tr><td width="17" align="center"><?php echo tep_image('images/template/img_trash.gif')?></td>'+
											  '<td width="500" align="left" class="inner_title"><?php echo TEXT_HEADING_DELETE_RESOURCES;?></td></tr>'+
											  '<tr><td></td><td width="500" align="left" class="main"><?php echo TEXT_DELETE_INTRO;?></td></tr>'+											  				      					       
											  '<tr><td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif',50,10);?></td></tr></table>';
						if(img_save) img_save.style.visibility="visible";											   	 					 	 	 	 					 	 					 	 		
 	 			break;
 	 			case 'pos_up':
				case 'pos_down':
					var s_order=document.resource.sort_order;															
					if(head) var tbl_tr_obj=head.parentNode.parentNode;																									
					var pos_cnt=0;																																	
					pos="pos_up";
					if(action=='pos_down') pos="pos_down";
					command="<?php echo tep_href_link(FILENAME_RESOURCES);?>?itID="+resource_id+"&pos="+r_type+"&action="+pos;					
					if(s_order) s_order.value=pos;					
					var tpl_cnt=tbl_tr_obj.parentNode.rows.length;
					tpl_cnt=tpl_cnt-2;										
					if(tbl_tr_obj && (tbl_tr_obj.rowIndex==0 && pos=='pos_up' || tpl_cnt==tbl_tr_obj.rowIndex && pos=='pos_down')) return;
				break;										
 	 		}
 	 		if(command!="") do_get_command(command);
 	 	}		
 	 }  	
   function do_result(result){
   	  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,15)=='page_navigation') print_details('page_navigation',result.substr(15));
		else if(result.substr(0,16)=='sort_order_error') print_details('sort_order_error',result.substr(16));
		else if(result.substr(0,18)=='sort_order_success') print_details('sort_order_success',result.substr(18));
		else if(result.substr(0,12)=='new_resource') print_details('new_resource',result.substr(12));
		else if(result.substr(0,3)=='new' && result!="" && document.getElementById("new_create")) {
			document.getElementById("new_create").style.display="";
			document.getElementById("new_create").innerHTML=result.substr(3);
			<?php $languages = tep_get_languages();
		   	if (HTML_AREA_WYSIWYG_DISABLE=='Enable') { 
				 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
		 			initEditor('resource_description[<?php echo $languages[$i]['id']; ?>]');
  	   	<?php 	 } 
			}?>			
		}				
   	  }
   }
   function print_details(action,result){ 	 	 	 	 	 	 	 	 	 	
 	 	var no_result="";
		if(result.substr(0,15)=='No Record Found')
 	 		no_result="No Record Found";
 	 	else if(result!='' && result.length>0 && action!='edit' && result.substr(0,15)!='No Record Found'){
 	 		splt_str=result.split("||");
 	 		var  resource_id="";
			var  resource_name="";
			var  resource_description="";
			var  resource_date_added="";
			var  resource_last_modified="";
			var  resource_costs="";
			var  sort_order="";
 	 		resource_id=splt_str[0]; 	 		
 	 		resource_name=splt_str[1];
 	 		resource_description=splt_str[2]; 	 		 	 						
			resource_date_added=splt_str[3];
 	 		resource_last_modified=splt_str[4];
			resource_costs=splt_str[6];
			sort_order=splt_str[7];
 	 	}
 		if(document.resource && document.resource.resource_id) var id=document.resource.resource_id.value;
 		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 img_save=document.getElementById("img_save"); 		
		if(img_save && action!='get_details') img_save.style.visibility="visible";					
 	 	switch(action){
 	 		case 'get_details':
 	 		if(head  && no_result!="")
				head.innerHTML=no_result; 	 			 	 		
 	 		else if(head && no_result==""){ // <img src="images/icon_info.gif" alt="Info" title=" Info " border="0">
	 	 		if(data_id){ 
	 	 			data_id.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						          '<tbody><tr>'+
						         	'<td class="dataTableContent" width="50%"><img src="images/icons/preview.gif" alt="Preview" title=" Preview " border="0">&nbsp;'+resource_name+'</td>'+
						         	'<td class="dataTableContent" width="50%">'+resource_costs+'</td>'+			         						  			 	  
						         '</tr>'+
						      	'</tbody></table>';
	 	 		}	
	 	 		include="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				"<tr heigth='40' class='openContent_top'>"+
				  "<td width='10'></td>"+				  							  
				  '<td width="30" valign="top" align="center"><a id="up_'+resource_id+'" href="javascript:get_resource_details(\'pos_up\','+resource_id+','+sort_order+');"><img border="0" src="images/template/img_arrow_up.gif"></a>&nbsp;<a id="down_'+resource_id+'" href="javascript:get_resource_details(\'pos_down\','+resource_id+','+sort_order+');"><img border="0" src="images/template/img_arrow_down.gif"></a></td>'+
				  "<td align='left' valign='middle' width='350' class='inner_title'>"+resource_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);get_resource_details(\'edit\','+resource_id+');" 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);get_resource_details(\'delete\','+resource_id+');" 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="visibility:hidden"><input type="image" src="images/template/img_savel.gif" alt="save" title="save" border="0">&nbsp;&nbsp;<a href="javascript:get_resource_details(\'get_details\','+resource_id+');"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>'+
				"</tr>"+
				"<tr style='height:10'><td id='loading' style='display:none' colspan='5'><img src='images/24-1.gif' alt='Loading...' title='Loading...'></td></tr>"+				
				"<tr>"+
				  "<td colspan='8' class='main'><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'>"+
				  		"<tr>"+
				  			"<td width='50'><img src='images/pixel_trans.gif' border='0' alt='' width='50' height='1'></td>"+				  							  			
							"<td width='100%'>"+				  							  			
				  				"<table width='50%' border='0' cellspacing='0' cellpadding='3' class='main'>";
				  					if(resource_date_added!=""){
				  						include+="<tr>"+
					  						"<td align='left' width='10%' valign='top'><b><?php echo TEXT_DATE_ADDED;?></b></td>"+
					  						"<td align='left' width='35%' valign='top'>"+resource_date_added+"</td>"+
				  						"</tr>";
				  					}	
				  					if(resource_last_modified!=""){		  					
					  					include+="<tr>"+
					  						"<td align='left' width='10%'><b><?php echo TEXT_LAST_MODIFIED;?></b></td>"+
					  						"<td align='left' width='35%'>"+resource_last_modified+"</td>"+
					  					"</tr>";						
				  					}			
				  					if(resource_costs!=""){
									include+="<tr>"+
											"<td align='left' width='10%'><b><?php echo TEXT_PRICE;?></b></td>"+
											"<td align='left' width='35%'>"+resource_costs+"</td>"+
										"</tr>";
				  					}
				  			  include+="</table></td></tr>";
				  			  if(resource_description.length>0){							  
							  	include+="<tr>"+
				  					"<td width='50'></td><td align='left' valign='top' class='main'><div style='width:693;height:50;overflow:auto;'>"+
				  						resource_description+
				  					"</div></td>"+			  			
								"</tr>";
				  			 }				  							
					include+="<tr><td colspan='8'><img src='images/pixel_trans.gif' border='0' alt='' width='100%' height='20'></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';
 	 		}									
       <?php 	$languages = tep_get_languages();
		   if (HTML_AREA_WYSIWYG_DISABLE=='Enable') { 
			 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
		 		initEditor('resource_description[<?php echo $languages[$i]['id']; ?>]');
  	   <?php } 
		  }?>					 		  						
		updateGross();				
 	 	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_SERVICE_DELETE_SUCCESS;?>";
 	    	 	res_display.style.display="";
 	    	 	var obj=document.getElementById("page_1");
 	    	 	if(obj)	 len=obj.options[obj.selectedIndex].value; 	    	 		
 	    	 	 command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=page_navigation');?>&page="+len;
				 do_get_command(command);	    	 	
 	    	 }
			if(document.getElementById("search")) document.getElementById("search").value=""; 								   			   
 	 	break;	
 	 	case 'page_navigation':
 	 		if(document.getElementById("ajax_details"))
 	 		 document.getElementById("ajax_details").innerHTML=result;
 	 	break;	
 	 	case 'sort_order_success':
		case 'sort_order_error':
			if(document.resource.sort_order) var s_order=document.resource.sort_order.value;															
			if(action=='sort_order_success'){			  			   
			   if(head)  {
				var tbl_obj=head.parentNode.parentNode;
				var up_href=document.getElementById("up_"+id);
			    var down_href=document.getElementById("down_"+id);			    
			    new_pos_splt=result.split('^');
			    var new_pos=new_pos_splt[1];			    
			    if(up_href && down_href && new_pos){					
					up_href.href="javascript:get_resource_details('pos_up',"+id+","+new_pos+")";
					down_href.href="javascript:get_resource_details('pos_down',"+id+","+new_pos+")";					
			    }
				var x=1;
				if(s_order && s_order!="" && s_order=="pos_up") x=-1;								
				var row=tbl_obj;
				var index=row.rowIndex;
				var count=tbl_obj.parentNode.rows.length;				
				if (x==-1 && index==0) return;
				if (x==1 && index==count-1) return;
				if (x==-1){
				   row.parentNode.insertBefore(row,row.parentNode.rows[index-1]);
				} else {
					if (index==row.parentNode.rows.length-2)
						row.parentNode.appendChild(row);
					else
						row.parentNode.insertBefore(row,row.parentNode.rows[index+2]);
				}																 							
  		      }			   			   					            	            	      		               	      	    	 	 			  
			}else if(action=='sort_order_error'){
				res_display.style.display=""; 	    	 	
			    res_display.innerHTML="<?php echo ERROR_IN_DATABASE_TRY_AGAIN;?>"; 	    	 	 	    	 	 	    	 	 	    	 	 
			}
		break;
		case 'new_resource':	//<img src="images/icon_info.gif" alt="Info" title=" Info " border="0">		
				var obj=document.getElementById("page_1");
				var len=1;
				if(data_id) {
					var tbl_obj=data_id.parentNode.parentNode.parentNode.parentNode;
					var tbl_obj_rows=tbl_obj.rows.length-1; 		
				}			
				if(res_display){
		    	 	res_display.innerHTML="<?php echo TEXT_RESOURCE_INSERT_SUCCESS;?>";
	 	    	 	res_display.style.display=""; 	    	 	
 	    	 	}	
				if(obj && obj.options.length>0 || tbl_obj_rows==max_display){
				 	if(obj) len=obj.options.length;				 						 	
				 	if(!obj && tbl_obj_rows==max_display) len=2; 				 	
				}
				command="<?php echo tep_href_link(FILENAME_RESOURCES,'action=page_navigation');?>&page="+len;
				do_get_command(command);
				if(document.getElementById("search")) document.getElementById("search").value=""; 								   			   
		break;
 	 	}
 	 	if(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.gif'){				   		
			   		if(eve==1 || eve==2) img_get_src.src=img_src+'template/img_new_hover.gif';					
			   }else if(eve==3 && img_get_src.src==img_src+'template/img_new_hover.gif') 
			    	img_get_src.src=img_src+'template/img_new.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>		
</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>
	<td width="100%" valign="top">
	<table border="0" width="100%" cellspacing="0" cellpadding="0">	  
      <tr>
        <td>
         <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr class="dataTableHeadingRow" style="height:23px">           
            <td class="pageHeading" align="left" valign="bottom"><a id="img_new" title="New Resource" onMouseOver="javascript: do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,1);" alt="New Resource" href="javascript:get_resource_details('new',0);"><?php echo tep_image('images/template/img_new.gif');?></a></td>
            <td class="dataTableHeadingContent" align="right" valign="absmiddle">
            <?php 				
				echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search','','onkeyup="javascript:check_key(event)"') . '&nbsp;'; 
			?></td>
			<td align="left" valign="absmiddle" width="25"><a alt="Search" title="Search" href="javascript:get_resource_details('page_navigation',1,'search');"><?php echo tep_image('images/template/img_search.gif');?></a></td>
          </tr>
		  <tr><td><?php  echo tep_draw_separator('pixel_trans.gif',5,10); ?></td></tr>	
        </table></td>
      </tr>	  	 
      <tr>
        <td>
        <?php echo tep_draw_form('resource', FILENAME_RESOURCES, '', 'post', ' onsubmit="javascript:return ValidateForm();"'); ?>	
          <table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr><td id="res_display" class="main" style="display:none"></td></tr>
          <tr>
            <td valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="2">
			  <tr class="dataTableHeadingRow">
                	<td class="dataTableHeadingContent" width="50%"><?php echo TEXT_RESOURCE_NAME; ?></td>
					<td class="dataTableHeadingContent" width="50%"><?php echo TEXT_RESOURCE_COSTS;?></td>								
         		</tr>                           
         		<tr>
         			<td colspan="3" id="ajax_details"><?php table_write();?></td>
  				</tr>
				<tr><td colspan="3" style="display:none" class="openContent" id="new_create"></td></tr>				
		  </table>  			
  		</td>
  	   </tr>
  	  </table>	
  	  <input type="hidden" name="resource_id" id="resource_id">
  	  <input type="hidden" name="action_type" id="action_type">
  	  <input type="hidden" name="sort_order" id="sort_order">
  	  </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'); ?>
