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

  Copyright (c) 2005 osCommRes

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

Copyright 2007 ZacWare Pty. Ltd
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
  require('includes/application_top.php');
  require('includes/classes/split_page_results_event.php');
  $command=isset($HTTP_GET_VARS["command"])?$HTTP_GET_VARS["command"]:'';
  $zone_id=isset($HTTP_GET_VARS["zone_id"])?$HTTP_GET_VARS["zone_id"]:'';
  $page=isset($HTTP_GET_VARS["page"])?$HTTP_GET_VARS["page"]:1;
  $country_id=isset($HTTP_GET_VARS["country_id"])?$HTTP_GET_VARS["country_id"]:'';
  $assoc_id=isset($HTTP_GET_VARS['assoc_id'])?$HTTP_GET_VARS['assoc_id']:'';
  $c_id=isset($HTTP_GET_VARS['c_id'])?$HTTP_GET_VARS['c_id']:'';
//  $move_zone_country_id=isset($HTTP_GET_VARS['move_zone_country_id'])?$HTTP_GET_VARS['move_zone_country_id']:'';
  
  $sh_country_id=isset($HTTP_GET_VARS['sh_country_id'])?$HTTP_GET_VARS['sh_country_id']:'';
  $server_date = getServerDate(true);
  $languages = tep_get_languages();
  switch($command){
  	case 'page_navigation_zone':
		echo 'page_navigation_zone^';
  		shop_countries_list();
		exit;
  		break;
   	case 'load_details':
		echo 'load_details^';
		echo $sh_country_id.'^';
		$countries_name="";
	  	$countries_query = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3, country_code, address_format_id from " . TABLE_COUNTRIES . " where countries_id='" . $sh_country_id . "' order by countries_name");
		if(tep_db_num_rows($countries_query)>0){
		$countries_array=tep_db_fetch_array($countries_query);
		$countries_name=$countries_array["countries_name"];
		$countries_iso_code_2=$countries_array['countries_iso_code_2'];
		$countries_iso_code_3=$countries_array['countries_iso_code_3'];
		$countries_code=$countries_array['country_code'];
		$address_format_id=$countries_array['address_format_id'];
		}
	  	$zones_list_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $sh_country_id. "' order by c.countries_name, z.zone_name");
		while($zone_list_array=tep_db_fetch_array($zones_list_query)) {
			$gInfo[] = $zone_list_array;
		}
	//	$move_option="";	
	//	if(tep_db_num_rows($zones_list_query)>0) 
	//		$move_option='&nbsp;&nbsp;<a onClick="javascript:move_zone_value(' . $zone_id . ');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,1);">'.tep_image(DIR_WS_IMAGES.'template/img_move.gif').'</a>';
		$function_name="";
			if(tep_db_num_rows($zones_list_query)>0)
				$function_name=" new_zone($zone_id); ";
			else 
				$function_name=" new_zone_value($zone_id); ";
		?>
		<table border="0" cellpadding="0" class="openContent" cellspacing="0" width="100%">
		<tr class="openContent_top" onClick="javascript:do_close('<?php echo $sh_country_id;?>');">
		<td class="main" width="150" id="row_heading_<?php echo $sh_country_id;?>"><?php echo tep_image(DIR_WS_IMAGES . "template/icon_active.gif").'&nbsp;&nbsp;' .$countries_name; ?>
		</td>	
		<td align="left" width="100" valign="top">
			<table style="background:#DEE4F5;cursor:pointer;" width="50" border="0" cellpadding="0" id="header_operation_id" cellspacing="0">
				<tr id="img_ids">
				<td width="10%" class="cell_bg_popm_left">&nbsp;</td>
					<?php echo  '<td width="10%" onClick="javascript:do_hover_change(this,1);void countries_edit();" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'; ?>
					<?php echo  '<td width="10%" onClick="javascript:do_hover_change(this,1);drop_countries(' . $sh_country_id . ');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'; ?>
				<td width="10%" class="cell_bg_popm_right">&nbsp;</td>	
				</tr>
			</table>
			<table style="background:#DEE4F5;cursor:pointer;display:none;" width="50" border="0" cellpadding="0" id="icon_operation" cellspacing="0">
				<tr>
				<td class="cell_bg_popm_left" width="10%"></td>
					<?php echo   '<td width="10%" onClick="javascript:do_hover_change(this,1);void countries_edit();" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'; ?>
					<?php echo   '<td width="10%" onClick="javascript:do_hover_change(this,1);drop_countries(' . $sh_country_id . ');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'; ?>
				<td width="10%" class="cell_bg_popm_right">&nbsp;</td>	
				</tr>
			</table>
		</td>	
		
		<td id="header_edit_display" style="display:none;"  align="right"><?php echo tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','onClick="javascript: save_countries('.$sh_country_id.')"').'&nbsp;&nbsp;'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','onClick="javascript: base_country_close('.$sh_country_id.');"'); ?></td>
		<td id="header_delete_display" style="display:none;" align="right"  >&nbsp;</td>
		</tr>
		<tr><td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr>	
		<tr id="edit_details_id" style="display:none;" align="center">
			<td colspan="3">
				<form name="edit_country_detail" action="shop_zones.php">
				<table cellpadding="5" cellspacing="0" border="0" width="100%">
					<tr class="main">
						<td><?php echo 'Country Name&nbsp;&nbsp;'.tep_draw_input_field('countries_name',$countries_name); ?></td>
						<td><?php echo 'ISO Code(2)&nbsp;&nbsp;'.tep_draw_input_field('countries_iso_code_2', $countries_iso_code_2,'maxlength="2"'); ?></td>
						<td><?php echo 'ISO Code(3)&nbsp;&nbsp;' . tep_draw_input_field('countries_iso_code_3', $countries_iso_code_3,'maxlength="3"'); ?></td>
					</tr>
					<tr  class="main">
						<td colspan="3" align="center"><?php echo 'Country Code&nbsp;&nbsp;' . tep_draw_input_field('countries_code', $countries_code) . '&nbsp;&nbsp;Address Format&nbsp;&nbsp;' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats(), $address_format_id) ; ?></td> 
					</tr>
				</table></form>
			</td>		
		</tr>
		<tr> <td colspan="3" class="main"><table width="100%" cellpadding="5" cellspacing="5" border="0"> 
		<tr><td width="150">&nbsp;</td><td id="option_value_details_content">
		<?php $row=1; $class_name="";
		for($i=0;$i<sizeof($gInfo);$i++) {
			//if(isset($HTTP_GET_VARS['country_id']) && $zones_country_array['zone_country_id']==$HTTP_GET_VARS['country_id']) {
			//	$zInfo = new objectInfo($zones_country_array);
			//}
			if($row%2==0) $class_name='dataTableRowEven'; else $class_name='dataTableRowOdd';
		?>
		<div class="main"  id="opt_row_<?php echo $gInfo[$i]['zone_id']; ?>" onClick="javascript:opt_row_focus(<?php echo $gInfo[$i]['zone_id']; ?>,<?php echo $sh_country_id; ?>);">
		<div class="<?php echo $class_name; ?>" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" id="opt_<?php echo $gInfo[$i]['zone_id']; ?>"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$gInfo[$i]['zone_name']; ?></div>
		</div>
		<div id="ajax_opt_row_<?php echo $gInfo[$i]['zone_id']; ?>">
		<div id="ajax_opt_<?php echo $gInfo[$i]['zone_id']; ?>" style="display:none;"></div>
		</div>
		<?php }
		 ?>  </td></tr>
		<tr>
			<td>&nbsp;</td>
			<td>
				<div id="new_zone_content" style="display:none; background:#DEE4F5;">
					<form name="country_detail" action="shop_zones.php" method="post">
					<table width="100%" cellpadding="2" cellspacing="2" border="0">
						<tr>
							<td colspan="2" class="main"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;New Zone';	?></td>
							<td align="right"><?php echo '<a href="javascript:void save_new_zone_value(' . $sh_country_id .');">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','Save').'</a>&nbsp;&nbsp;<a href="javascript: close_new_zone_value();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','Close').'</a>'; ?></td>
						</tr>
						<tr>
						  <td class="main" align="left"><?php echo 'Zone Name &nbsp;' . tep_draw_input_field('zone_name');?></td>
						  <td class="main" align="left"><?php echo 'Zone Code &nbsp;' . tep_draw_input_field('zone_code');?></td>
						  <td class="main" align="left"><?php echo 'Country Name &nbsp;' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(),$sh_country_id);?></td>
						</tr>
					</table>
					</form>
				</div>
			</td>
		</tr>  
	<!--	<tr>
			<td>&nbsp;</td>
			<td><div id="move_zone_content" style="display:none; background:#dee4f5;">
				<table cellpadding="3" cellspacing="0" border="1">
					<tr><td colspan="2" align="right"><?php echo '<a href="javascript:void save_move_zone_value(' . $sh_country_id .');">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','Save').'</a>&nbsp;&nbsp;<a href="javascript: close_move_zone_value();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','Close').'</a>'; ?></td></tr>
					<tr class="main"><td><b>Moving Zones : </b></td><td>Please Select the country under which the zones to be moved</td></tr>
					<tr class="main"><td>&nbsp;</td><td><?php echo 'Country Name &nbsp;' . tep_draw_pull_down_menu('move_zone_country_id', tep_get_countries(),$sh_country_id); ?></td></tr>
				</table>
			</div></td>
		</tr> -->
		</table>
		</td></tr>
		</table>
		<?php
	
		exit;
		break;
	 case 'save_countries':
	 	echo 'save_countries^';
		$countries_name=isset($HTTP_POST_VARS["countries_name"])?$HTTP_POST_VARS["countries_name"]:'';
		$countries_iso_code_2=isset($HTTP_POST_VARS["countries_iso_code_2"])?$HTTP_POST_VARS["countries_iso_code_2"]:'';
		$countries_iso_code_3=isset($HTTP_POST_VARS["countries_iso_code_3"])?$HTTP_POST_VARS["countries_iso_code_3"]:'';
		$countries_code=isset($HTTP_POST_VARS["countries_code"])?$HTTP_POST_VARS["countries_code"]:'';
		$address_format_id=isset($HTTP_POST_VARS["address_format_id"])?$HTTP_POST_VARS["address_format_id"]:'';
        tep_db_query("update " . TABLE_COUNTRIES . " set countries_name = '" . tep_db_input($countries_name) . "', countries_iso_code_2 = '" . tep_db_input($countries_iso_code_2) . "', countries_iso_code_3 = '" . tep_db_input($countries_iso_code_3) ."',country_code='".tep_db_prepare_input($countries_code)."', address_format_id = '" . (int)$address_format_id . "' where countries_id = '" . (int)$sh_country_id . "'");
		echo $sh_country_id.'^';
		echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$countries_name;
		exit;
		break;
	case 'drop_countries':
		$countries_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $sh_country_id. "'order by c.countries_name, z.zone_name");
		if(tep_db_num_rows($countries_query)<=0) {
			echo 'drop_countries^';
			echo $sh_country_id.'^';
    	    tep_db_query("delete from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$sh_country_id . "'");
		}
		else {
			echo 'drop_countries_fail^';
			echo $sh_country_id;
		}
		exit;
		break;
	case 'opt_load_details':
		echo 'load_opt_details^';
		echo $zone_id.'^'; 
		$zInfo="";
	 	$zones_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $HTTP_GET_VARS['c_id'] . "' order by c.countries_name, z.zone_name");
		if(tep_db_num_rows($zones_query)>0) {
			while($zones_array=tep_db_fetch_array($zones_query)) {
				if(isset($HTTP_GET_VARS['zone_id']) && $zones_array['zone_id']==$HTTP_GET_VARS['zone_id'])
					$zInfo = new objectInfo($zones_array);
			}
		}	
		?>
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
		<!--<tr style="background:#DEE4F5;">
		<td colspan="3" class="main"><?php echo tep_image(DIR_WS_IMAGES . "template/icon_active.gif").'&nbsp;&nbsp;'.$zInfo->zone_name; ?></td>
		</tr>-->
		<tr class="openContent_top" onClick="do_opt_close('<?php echo $zone_id;?>');">
		<td width="365" class="main"><?php echo tep_image(DIR_WS_IMAGES . "template/icon_active.gif").'&nbsp;&nbsp;'.$zInfo->zone_name; ?></td>
		<td align="center">
		<table width="50%" border="0" style="background:#DEE4F5;cursor:pointer;" cellpadding="0" cellspacing="0">
		<tr>
		<td width="10%" class="cell_bg_popm_left">&nbsp;</td>
		<?php echo  '<td onclick="javascript:do_hover_change1(this,1);drop_zone_countries(' . $zone_id . ',' . $HTTP_GET_VARS['c_id'] . ');" onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,3);" align="center"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'; ?>
		<td width="10%" class="cell_bg_popm_right">&nbsp;</td>
		</tr>
		</table>
		</td>
		<td width="365" align="right" style="cursor:hand;cursor:pointer"><?php echo tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','onClick="javascript: save_zone_countries('. $zone_id . ',' . $HTTP_GET_VARS['c_id'] . ');"').'&nbsp;'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','onClick="javascript:close_option_value(' . $zone_id . ');"'); ?></td>
		</tr>
		<tr><td colspan="3">
			<form name="zone_country_detail" action="shop_geo_zones.php">
				<table cellpadding="2" cellspacing="0">
				<tr>
					<td class="main" align="left"><?php echo 'Zone Name &nbsp;' . tep_draw_input_field('zone_name', $zInfo->zone_name); ?></td>
      				<td class="main" align="left"><?php echo 'Zone Code &nbsp;' . tep_draw_input_field('zone_code', $zInfo->zone_code); ?></td>
      				<td class="main" align="left"><?php echo 'Country Name &nbsp;' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(), $zInfo->countries_id); ?></td>
				</tr>
				</table>
			</form>	
		<tr>
		</tr>
		<tr>
		<td id="delete_options" style="display:none" class="main">&nbsp;</td> 
		<tr>
		</table>
		<?php
		exit;
		break;
	case 'save_zone_countries':
		echo 'save_zone_countries^';
		$zone_name=isset($HTTP_POST_VARS['zone_name'])?$HTTP_POST_VARS['zone_name']:'';
		$zone_code=isset($HTTP_POST_VARS['zone_code'])?$HTTP_POST_VARS['zone_code']:'';
		$zone_country_id=isset($HTTP_POST_VARS['zone_country_id'])?$HTTP_POST_VARS['zone_country_id']:'';
		echo $zone_id.'^';
        tep_db_query("update " . TABLE_ZONES . " set zone_country_id = '" . (int)$zone_country_id . "', zone_code = '" . tep_db_input($zone_code) . "', zone_name = '" . tep_db_input($zone_name) . "' where zone_id = '" . (int)$zone_id . "'");
		$zones_query = tep_db_query("Select zone_id, zone_name from " . TABLE_ZONES . " where zone_id='" . $zone_id . "' and zone_country_id='" . $sh_country_id . "' ");
		$zones_array=tep_db_fetch_array($zones_query);
		if(tep_db_num_rows($zones_query)>0)
			echo '<div class="dataTableRowOdd" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" id="opt_'.$zone_id.'">'.tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$zones_array['zone_name'].'</div>';
		$zones_count_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $sh_country_id. "'order by c.countries_name, z.zone_name");	
		if(tep_db_num_rows($zones_count_query)<=0) {
			echo '^show_header_icon';
		}
		exit;
		break;
	case 'save_new_country':
		echo 'save_new_country^';
		$countries_name=isset($HTTP_POST_VARS["countries_name"])?$HTTP_POST_VARS["countries_name"]:'';
		$countries_iso_code_2=isset($HTTP_POST_VARS["countries_iso_code_2"])?$HTTP_POST_VARS["countries_iso_code_2"]:'';
		$countries_iso_code_3=isset($HTTP_POST_VARS["countries_iso_code_3"])?$HTTP_POST_VARS["countries_iso_code_3"]:'';
		$countries_code=isset($HTTP_POST_VARS["countries_code"])?$HTTP_POST_VARS["countries_code"]:'';
		$address_format_id=isset($HTTP_POST_VARS["address_format_id"])?$HTTP_POST_VARS["address_format_id"]:'';
        tep_db_query("insert into " . TABLE_COUNTRIES . " (countries_name, countries_iso_code_2, countries_iso_code_3,country_code, address_format_id) values ('" . tep_db_input($countries_name) . "', '" . tep_db_input($countries_iso_code_2) . "', '" . tep_db_input($countries_iso_code_3) . "','" .tep_db_prepare_input($countries_code). "', '" . (int)$address_format_id . "')");
		exit;
		break;
	 case 'save_new_zone_value':
	 	echo 'save_new_zone_value^'; 
		$zone_name=isset($HTTP_POST_VARS['zone_name'])?$HTTP_POST_VARS['zone_name']:'';
		$zone_code=isset($HTTP_POST_VARS['zone_code'])?$HTTP_POST_VARS['zone_code']:'';
		$zone_country_id=isset($HTTP_POST_VARS['zone_country_id'])?$HTTP_POST_VARS['zone_country_id']:'';
        tep_db_query("insert into " . TABLE_ZONES . " (zone_country_id, zone_code, zone_name) values ('" . (int)$zone_country_id . "', '" . tep_db_input($zone_code) . "', '" . tep_db_input($zone_name) . "')");

		$zones_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $sh_country_id. "' order by c.countries_name, z.zone_name");
		?>
		<?php while($zones_array=tep_db_fetch_array($zones_query)){ ?>
		<div class="main" id="opt_row_<?php echo $zones_array["zone_id"]; ?>" onClick="javascript:opt_row_focus(<?php echo $zones_array["zone_id"]; ?>,<?php echo $zones_array["countries_id"]; ?>);">
		<div class="dataTableRowOdd" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" id="opt_<?php echo $zones_array["zone_id"]; ?>"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;'.$zones_array["zone_name"]; ?></div>
		</div>
		<div id="ajax_opt_row_<?php echo $zones_array["zone_id"]; ?>">
		<div id="ajax_opt_<?php echo $zones_array["zone_id"]; ?>" style="display:none;"></div>
		</div>
		<?php } ?>
		<?php
		echo '^'.$zones_array["zone_id"];
	 	exit;
		break;
	/* case 'save_move_zone_value':	
	 	echo 'save_move_zone_value^';
		tep_db_query("update " . TABLE_ZONES . " set zone_country_id='" . $move_zone_country_id . "' where zone_country_id='" . $sh_country_id . "' ");
		echo $sh_country_id. '^';
		echo $move_zone_country_id;	
		exit;
	 break; */
	 case 'drop_zone_countries':
		echo 'drop_zone_countries^';
        tep_db_query("delete from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");
		echo $zone_id;
	 	$zones_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id and c.countries_id='". $sh_country_id. "'order by c.countries_name, z.zone_name");
		if(tep_db_num_rows($zones_query)<=0) {
			echo '^show_header_icon';
		}	
	 	exit;
		break;
	 }
  tep_get_last_access_file();                                              
  $languages = tep_get_languages();
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html;" charset="<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language="javascript" src="includes/menu.js"></script>
	<script language="javascript">
	function update_zone(theForm) {
  var NumState = theForm.sel_zone_id.options.length;
  var SelectedCountry = "";

  while(NumState > 0) {
    NumState--;
    theForm.sel_zone_id.options[NumState] = null;
  }         

  SelectedCountry = theForm.zone_country_id.options[theForm.zone_country_id.selectedIndex].value;

<?php echo tep_js_zone_list('SelectedCountry', 'theForm', 'sel_zone_id'); ?>

}
</script>
<script language="javascript">
  var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
 	<?php 
	 $countries_query = tep_db_query("select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3,country_code, address_format_id from " . TABLE_COUNTRIES . " order by countries_name");
	 $zones_query = tep_db_query("select z.zone_id, c.countries_id, c.countries_name, z.zone_name, z.zone_code, z.zone_country_id from " . TABLE_ZONES . " z, " . TABLE_COUNTRIES . " c where z.zone_country_id = c.countries_id order by c.countries_name, z.zone_name");
	?>
	var countries_array=new Array();
	var zone_id_array=new Array();
	var coun_id="";
	var zoneId="";

	<?php $icnt=0; while($zones_array=tep_db_fetch_array($zones_query)){ ?>
	zone_id_array[<?php echo $icnt; ?>]=<?php echo $zones_array["zone_id"]; ?>;
	<?php $icnt++; } ?>
	<?php $cnt=0; while($countries_details=tep_db_fetch_array($countries_query)){ ?>
	countries_array[<?php echo $cnt; ?>]=<?php echo $countries_details["countries_id"]; ?>;
	<?php $cnt++; } ?>
	</script>
<script language="javascript">
	var close_obj=false;
	var opt_close_obj=false;
	function opt_row_focus(zid,cid){ 
		if(zoneId!=zid && zoneId!='') {
			close_option_value(zoneId);
			opt_close_obj=false;
		}	
		zoneId=zid;
		document.getElementById('header_operation_id').style.display='none';
		document.getElementById('edit_details_id').style.display='none';
		document.getElementById('header_edit_display').style.display='none';
		document.getElementById('header_delete_display').style.display='none';
		for(i=0,len=zone_id_array.length;i<len;i++){
			if(zone_id_array[i]!=zid && document.getElementById('ajax_opt_'+zone_id_array[i])){
			document.getElementById('ajax_opt_'+zone_id_array[i]).innerHTML='';
			document.getElementById('ajax_opt_'+zone_id_array[i]).style.display='none';
			if(document.getElementById('opt_'+zone_id_array[i]))
				document.getElementById('opt_'+zone_id_array[i]).style.display='';
			}
		}
	if(document.getElementById('ajax_opt_'+zid)){	
		if(document.getElementById('new_country_content'))
			document.getElementById('new_country_content').style.display="none"; 
		document.getElementById('ajax_opt_'+zid).style.display='';
		document.getElementById('ajax_opt_'+zid).innerHTML=document.getElementById('ajax_image_load').innerHTML; 
	}
	var command="<?php echo tep_href_link(FILENAME_ZONES,'command=opt_load_details&zone_id='); ?>"+zid+"&c_id="+cid;
	do_get_command(command);
			document.getElementById('new_zone_content').style.display='none';
	}
	function close_option_value(opt_id){
		var tr1=document.getElementById("img_ids");
		var imgsrc;
		var node;
		if(tr1)
		for(var j=0;j<tr1.cells.length;j++){
			td=tr1.cells[j];
			imgsrc='';
			for(var i=0;i<td.childNodes.length;i++){
				node=td.childNodes[i];
				if(node.tagName=='IMG'){
					imgsrc=node.src;
					if(imgsrc==img_src+'template/img_edit_hover.gif')
					   td.childNodes[i].src = img_src+'template/img_edit.gif';
					else if(imgsrc==img_src+'template/img_trash_hover.gif')
					   td.childNodes[i].src = img_src+'template/img_trash.gif';
					break;
				}
			}
		}
		
		document.getElementById('ajax_opt_'+opt_id).innerHTML='';
		document.getElementById('opt_'+opt_id).style.display='';
		document.getElementById('icon_operation').style.display='none';
		document.getElementById('header_operation_id').style.display='';
		document.getElementById('header_edit_display').style.display='none';
		document.getElementById('header_delete_display').style.display='none';
		zoneId='';
	}

	function row_focus(cid){ 
		if(coun_id!=cid){
			close_obj=false;
		}
		coun_id=cid;
		
		close_new_zone(); 
	//	close_new_service_attribute();
		for(i=0,len=countries_array.length;i<len;i++){
			if(cid!=countries_array[i] && document.getElementById('ajax_'+countries_array[i])){
			document.getElementById('ajax_'+countries_array[i]).innerHTML='';
			document.getElementById('ajax_'+countries_array[i]).style.display='none';
			document.getElementById('attrib_'+countries_array[i]).style.display='';
			}
		}
		if(document.getElementById('ajax_'+cid)){
		document.getElementById('ajax_'+cid).style.display='';
		document.getElementById('ajax_'+cid).innerHTML=document.getElementById('ajax_image_load').innerHTML; 
		}
	var command="<?php echo tep_href_link(FILENAME_ZONES,'command=load_details&sh_country_id='); ?>"+cid;
	do_get_command(command);
	
	}
	
	function do_close(id) {
		if(close_obj==false) {
			document.getElementById('ajax_'+id).innerHTML='';
			document.getElementById('ajax_'+id).style.display='none';
			document.getElementById('attrib_'+id).style.display='';
			coun_id='';
		}
		close_obj=false;
	}
	
	function do_opt_close(id) {
		if(opt_close_obj==false)
			close_option_value(id)
		opt_close_obj=false;	
	}
	
	function validate_country() {
		var countries_name=document.getElementById('countries_name').value;
		var countries_iso_code_2=document.getElementById('countries_iso_code_2').value;
		var countries_iso_code_3=document.getElementById('countries_iso_code_3').value;
		var countries_code=document.getElementById('countries_code').value;
		var address_format_id=document.getElementById('address_format_id').value;
		error=false; error_result="";
		if(countries_name=="" || str_trim(countries_name)=="") {
			error=true;
			error_result="<?php echo ERR_TEXT_COUNTRIES_NAME; ?>\n";
		} else if(countries_iso_code_2=="" || str_trim(countries_iso_code_2)=="") {
			error=true;
			error_result="<?php echo ERR_TEXT_ISO_CODE_2; ?>\n";
		} else if(countries_iso_code_3==""|| str_trim(countries_iso_code_3)=="") {
			error=true;
			error_result="<?php echo ERR_TEXT_ISO_CODE_3; ?>\n";
		} else if(countries_code=="" || isNaN(countries_code)) {
			error=true;
			error_result="<?php echo ERR_TEXT_COUNTRIES_CODE; ?>\n";
		} else if(address_format_id=="" || str_trim(address_format_id)=="") {
			error=true;
			error_result="<?php echo ERR_TEXT_ADDRESS_FORMAT; ?>\n";
		}
		return error_result;
	}
	function save_countries(option_id){ close_obj=true;
		var error_result=validate_country();
		if(error_result!="") {
			alert(error_result);
		}
		else {
		var command="<?php echo tep_href_link(FILENAME_ZONES,'command=save_countries&sh_country_id='); ?>"+option_id;
		//document.getElementById('attrib_'+option_id).style.background="#FFFFFF";
		//document.getElementById('attrib_'+option_id).style.display='';
		//document.getElementById('ajax_'+option_id).innerHTML=document.getElementById('ajax_image_load').innerHTML;
		do_post_command('edit_country_detail', command);
		}
	}
	function save_zone_countries(opt_id, cid){//opt_close_obj=true;
	var zone_name=document.getElementById('zone_name').value;
	var zone_code=document.getElementById('zone_code').value;
	var zone_country_id=document.getElementById('zone_country_id').value;
	var error_result="";
		if(zone_name=='' || str_trim(zone_name)=='')
			error_result="Please enter Zone Name";
		else if(zone_code=='' || str_trim(zone_code)=='')
			error_result="Please enter Zone Code";
		else if(zone_country_id=='' || str_trim(zone_country_id)=='')
			error_result="Please Select Zone Country";
		if(error_result!="")		
			alert(error_result);	
		else{
			var command="<?php echo tep_href_link(FILENAME_ZONES,'command=save_zone_countries&zone_id='); ?>"+opt_id+"&sh_country_id="+cid;
			//document.getElementById('opt_'+opt_id).style.background="#FFFFFF";
			//document.getElementById('opt_'+opt_id).style.display=''; 
			do_post_command('zone_country_detail', command);	
		}
	}
	function drop_countries(option_id){
	close_obj=true;
	document.getElementById('header_delete_display').style.display='';
	var command="<?php echo tep_href_link(FILENAME_ZONES,'command=drop_countries&sh_country_id='); ?>"+option_id;
	do_get_command(command);
	}
	
	function drop_zone_countries(zid,cid){
	document.getElementById('header_delete_display').style.display='';
	var command="<?php echo tep_href_link(FILENAME_ZONES,'command=drop_zone_countries&zone_id='); ?>"+zid+"&sh_country_id="+cid;
	do_get_command(command);
	}
	function drop_fail(){
	document.getElementById('attrib_delete_flag').innerHTML='';
	document.getElementById('attrib_delete_flag').style.display='';
	}
	
	function page_navigation(arg1,agr2,agr3,agr4){
		var page_no=1;
		if(agr2==1) var obj=document.getElementById("page_1");
		else if(agr2==2) var obj=document.getElementById("page_2");
		if(agr2 && agr4){
			if(obj){
 	 			page_no=parseInt(obj.options[obj.selectedIndex].value);
 	 		if(agr4=='next') {
 	 			if(obj.length==obj.selectedIndex+1) return;
 	 			page_no+=1;
 	 		}else if(agr4=='prev') {
 	 			if(obj.selectedIndex==0) return;
 	 			page_no-=1;
 	 		}
 	 		if(page_no<=1) page_no=1;
 	 		}
 	 		
		}
		if(agr2==1) command="<?php echo tep_href_link(FILENAME_ZONES,'command=page_navigation_zone'); ?>&page="+page_no;
		else if(agr2==2) command="<?php echo tep_href_link(FILENAME_ZONES,'command=page_navigation_attribute'); ?>&page="+page_no;		
		if(command!="") do_get_command(command);
	}	
	function do_result(result){
	var token=result.split('^');
	var page_no=1;
	var option_id=token[1]; var opt_id=token[1]; var attributes_id=token[1];
		switch(token[0]){
		case 'load_details':
			document.getElementById('attrib_'+option_id).style.display='none';
			document.getElementById('ajax_'+option_id).innerHTML=token[2];
			break;
		case 'save_countries':
			document.getElementById('attrib_'+option_id).innerHTML=token[2];
			document.getElementById('row_heading_'+option_id).innerHTML=token[2];
			/*document.getElementById('attrib_'+option_id).style.display='';
			document.getElementById('ajax_'+option_id).innerHTML='';
			document.getElementById('ajax_'+option_id).style.display='none';*/
			document.getElementById('edit_details_id').style.display='none';
			document.getElementById('header_edit_display').style.display='none';
			break;
		case 'drop_countries':
			var row_index=document.getElementById('countries_row_'+option_id).rowIndex;
			document.getElementById('header_delete_display').style.display='';
			document.getElementById('services_option_table').deleteRow(row_index);
			if(document.getElementById("page_1")){
 	 			page_no=parseInt(document.getElementById("page_1").options[document.getElementById("page_1").selectedIndex].value); 	 			
 	 			if(page_no<=1) page_no=1;
 	 		}
			var command="<?php echo tep_href_link(FILENAME_ZONES,'command=page_navigation_zone');?>&page="+page_no;
			do_get_command(command);
			break;
		case 'drop_countries_fail':
			document.getElementById('header_delete_display').style.display='none';
			document.getElementById('attrib_delete_flag').style.display='';
			document.getElementById('attrib_delete_flag').innerHTML="<?php echo TEXT_WARNING_OF_DELETE; ?>";
			setTimeout('drop_fail()',2000);
			var tr1=document.getElementById("img_ids");
			var imgsrc;
			var node;
			if(tr1)
			for(var j=0;j<tr1.cells.length;j++){
				td=tr1.cells[j];
				imgsrc='';
				for(var i=0;i<td.childNodes.length;i++){
					node=td.childNodes[i];
					if(node.tagName=='IMG'){
						imgsrc=node.src;
						if(imgsrc==img_src+'template/img_edit_hover.gif')
						   td.childNodes[i].src = img_src+'template/img_edit.gif';
						else if(imgsrc==img_src+'template/img_trash_hover.gif')
						   td.childNodes[i].src = img_src+'template/img_trash.gif';
						break;
					}
				}
			}
			break;	
		case 'load_opt_details':
			document.getElementById('opt_'+opt_id).style.display='none';
			document.getElementById('ajax_opt_'+opt_id).innerHTML=token[2];
			break;
		case 'save_zone_countries':// opt_close_obj=true;
			document.getElementById('opt_row_'+opt_id).innerHTML=token[2];
			document.getElementById('ajax_opt_'+opt_id).innerHTML='';
			document.getElementById('ajax_opt_'+opt_id).style.display='none';
			if(token[3]!="" && token[3]=='show_header_icon')
				document.getElementById('icon_operation').style.display='';
			break;
		case 'save_new_country':
			if(document.getElementById("page_1")){
 	 			page_no=parseInt(document.getElementById("page_1").options.length)+1;
 	 			if(page_no<=1) page_no=1;
 	 		}
			command="<?php echo tep_href_link(FILENAME_ZONES,'command=page_navigation_zone'); ?>&page="+page_no;
			do_get_command(command);
			break;
		case 'save_new_zone_value': 
			close_new_zone_value();
			document.getElementById('option_value_details_content').innerHTML=token[1];
			zone_id_array[countries_array.length-1]=token[2];
			document.getElementById('icon_operation').style.display='none';
			document.getElementById('header_operation_id').style.display='';
			break;
		/*case 'save_move_zone_value':
			row_focus(token[2]);
			break;			*/
		case 'drop_zone_countries':opt_close_obj=true;
				close_new_zone_value();
				//if(token[2]!="" && token[2]=='show_header_icon')
				//		document.getElementById('icon_operation').style.display='';
				document.getElementById('opt_row_'+opt_id).innerHTML='';
				document.getElementById('ajax_opt_'+opt_id).innerHTML='';
				document.getElementById('ajax_opt_'+opt_id).style.display='none';
				document.getElementById('header_edit_display').style.display='none';
				document.getElementById('header_delete_display').style.display='none';
			break;
		case 'page_navigation_zone':			
			document.getElementById('main_options_value_table').innerHTML=token[1];
			coun_id='';
			break;	
		}
	}

	function do_hover_change(element,eve){
		 var edit_display=document.getElementById('header_edit_display');
		 var delete_display=document.getElementById('header_delete_display');
	  	 if(element){		   		    		    
		    var img_get_src=element.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(edit_display && edit_display.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' && edit_display && edit_display.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(delete_display && delete_display.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' && delete_display && delete_display.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';
		  }
		}		 
	}
	
	function do_hover_change1(element,eve){
		 var delete_display=document.getElementById('delete_options');
	  	 if(element){		   		    		    
		    var img_get_src=element.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_trash.gif') {
					if(delete_display && delete_display.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' && delete_display && delete_display.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';
		  }
		}		 
	}
	function new_zone(option_id){
	display_flag=0;
		if(coun_id!="") {
			new_zone_value(zoneId);
			return;
		}
		if(document.getElementById('attrib_'+option_id) && document.getElementById('ajax_'+option_id) ){
			document.getElementById('ajax_'+option_id).innerHTML='';
			document.getElementById('ajax_'+option_id).style.display='none';
			document.getElementById('attrib_'+option_id).style.display='';
		}
		if(document.getElementById('new_country_content')) document.getElementById('new_country_content').style.display='';
	}
	function new_zone_value(opt_id){
		if(document.getElementById('opt_'+opt_id) && document.getElementById('ajax_opt_'+opt_id)){
			document.getElementById('opt_'+opt_id).style.display='';
			document.getElementById('ajax_opt_'+opt_id).innerHTML='';
			document.getElementById('ajax_opt_'+opt_id).style.display='none';
		}
		if(document.getElementById('new_zone_content'))
		 document.getElementById('new_zone_content').style.display='';
		
	}
/*	function move_zone_value(opt_id) {
		if(document.getElementById('opt_'+opt_id) && document.getElementById('ajax_opt_'+opt_id)){
			document.getElementById('opt_'+opt_id).style.display='';
			document.getElementById('ajax_opt_'+opt_id).innerHTML='';
			document.getElementById('ajax_opt_'+opt_id).style.display='none';
			}
		if(document.getElementById('move_zone_content'))
		 document.getElementById('move_zone_content').style.display='';
	}*/
	function save_new_country(frm_name){
		var error_result="";
		var frm=document.new_country_detail;
		if(frm.countries_name.value=="" || str_trim(frm.countries_name.value)=="" )
			error_result="Please enter countries name";
		else if(frm.countries_iso_code_2.value=="" || str_trim(frm.countries_iso_code_2.value)=="" )
			error_result="Please enter countries ISO Code(2)";
		else if(frm.countries_iso_code_3.value=="" || str_trim(frm.countries_iso_code_3.value)=="")
			error_result="Please enter countries ISO Code(3)";
		else if(frm.countries_code.value=="" || str_trim(frm.countries_code.value)=="")
			error_result="Please enter countries code";
		else if(isNaN(frm.countries_code.value))
			error_result="Please enter countries code as Number";	
		else if(frm.address_format_id.value=="" || str_trim(frm.address_format_id.value)=="")
			error_result="Please select address format";
						
		if(error_result!="") {
			alert(error_result);
		}
		else{
		change_new_image();
		var command="<?php echo tep_href_link(FILENAME_ZONES,'command=save_new_country'); ?>";
		close_new_zone();
		do_post_command("new_country_detail", command);
		}
	}
	function save_new_zone_value(opt_id){
	var zone_name=document.getElementById('zone_name').value;
	var zone_code=document.getElementById('zone_code').value;
	var zone_country_id=document.getElementById('zone_country_id').value;
	var error_result="";
		if(zone_name=='')
			error_result="Please enter Zone Name";
		else if(zone_code=='')
			error_result="Please enter Zone Code";
		else if(zone_country_id=='')
			error_result="Please Select Zone Country";
		if(error_result!="")		
			alert(error_result);	
		else{
			change_new_image();
			var command="<?php echo tep_href_link(FILENAME_ZONES,'command=save_new_zone_value&sh_country_id='); ?>"+opt_id;
			do_post_command('country_detail',command);
		}
	}
	/*function save_move_zone_value(opt_id){
	var move_zone_country_id=document.getElementById('move_zone_country_id').value;
		var command="<?php echo tep_href_link(FILENAME_ZONES,'command=save_move_zone_value&sh_country_id='); ?>"+opt_id+"&move_zone_country_id="+move_zone_country_id;
		do_get_command(command);
	}*/
	
	function close_new_zone(){
	change_new_image();
	if(document.getElementById('new_country_content')) document.getElementById('new_country_content').style.display='none';
	}
	function close_new_zone_value(){
	change_new_image();
	document.getElementById('new_zone_content').style.display='none';
	document.getElementById('zone_name').value='';
	document.getElementById('zone_code').value='';
	document.getElementById('zone_country_id').value='';
	}
	/*function close_move_zone_value(){
	document.getElementById('move_zone_content').style.display='none';
	}*/
	function countries_edit(){
	close_obj=true;
	document.getElementById('edit_details_id').style.display='';
	document.getElementById('header_edit_display').style.display='';
	document.getElementById('header_delete_display').style.display='none';
	}
</script>
<script language=JavaScript>

function base_country_close(option_id){
	close_obj=true;
	/*document.getElementById('attrib_'+option_id).style.display='';
	document.getElementById('ajax_'+option_id).innerHTML='';
	document.getElementById('ajax_'+option_id).style.display='none';*/
	document.getElementById('edit_details_id').style.display='none';
	document.getElementById('header_edit_display').style.display='none';
	
}
function change_new_image(){
display_flag=1;
document.getElementById('header_new_operation').firstChild.src=document.getElementById('header_new_operation').firstChild.src.replace('_hover.gif','.gif');
}
</script>   
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- Ajax Work Starts -->
<table border="0" width="100%" cellpadding="3" cellspacing="6">
<tr ><td align="left" valign="bottom">
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr class="dataTableHeadingRow"><td valign="middle"><?php echo '<a id="header_new_operation" href="javascript:new_zone();" onClick="javascript:do_hover_change(this,1);" onMouseOut="javascript:do_hover_change1(this,1);" onMouseOver="javascript:do_hover_change1(this,2);">'.tep_image(DIR_WS_IMAGES.'template/img_new.gif','','22','22',' align="absbottom"').'</a>'; ?></td></tr>
	</table>
</td></tr>
<tr class="dataTableHeadingRow">
	<td width="100%" class="main"><b><?php echo HEADING_TITLE; ?></b></td>
</tr>
<tr>
<td id="main_options_value_table">
	<?php echo shop_countries_list();?>			
</td>
</tr>
	
</table>
<div id="ajax_image_load" style="display:none;"><?php echo tep_image(DIR_WS_IMAGES.'24-1.gif'); ?></div>

<div id="new_service_attribute_content" style="display:none;"></div>
<!-- Ajax Works Ends -->
<?php $zone_query=tep_db_query("Select * from geo_zones");
if(tep_db_num_rows($zone_query)<=0) {
?>
<script language="javascript">
	document.getElementById('new_country_content').style.display='';
</script>
<?php } ?>
<!-- body_text_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>



<?php
function shop_countries_list(){  
	global	$languages_id,$page;
	 $countries_query_raw = "select countries_id, countries_name, countries_iso_code_2, countries_iso_code_3,country_code, address_format_id from " . TABLE_COUNTRIES . " order by countries_name";
    $countries_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $countries_query_raw, $countries_query_numrows);
    $countries_query = tep_db_query($countries_query_raw);
	$row_count=0;	
	?>
	<div style="color:#FF0000;" id="attrib_delete_flag"></div>   	
	<table id="services_option_table" width="100%" cellpadding="2" cellspacing="2" border="0">
	<?php $row=1; while($countries_array=tep_db_fetch_array($countries_query)){ 
		if($row%2==0) $class_name="dataTableRowEven"; else $class_name="dataTableRowOdd";
		$row++;
	?>
	<tr id="countries_row_<?php echo $countries_array["countries_id"]; ?>" style="cursor:hand; cursor:pointer">
	<td class="main">
	<div id="attrib_row_<?php echo $countries_array["countries_id"]; ?>" onClick="javascript:row_focus(<?php echo $countries_array["countries_id"]; ?>);">
	<div onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" id="attrib_<?php echo $countries_array["countries_id"]; ?>" class="<?php echo $class_name; ?>"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif') .'&nbsp;&nbsp;'. $countries_array["countries_name"]; ?></div>
	</div>
	<div id="ajax_row_<?php echo $countries_array["countries_id"]; ?>"></div>
	<div id="ajax_<?php echo $countries_array["countries_id"]; ?>" style="display:none;"></div>
	</div> 
	</td>
	<!-- <td class="dataTableContent" align="center" width="40"><?php echo $countries_array['countries_iso_code_2']; ?></td>
    <td class="dataTableContent" align="center" width="40"><?php echo $countries_array['countries_iso_code_3']; ?></td>-->
	</tr>
	<?php } ?>	
	</table>
	<table border="0" width="100%" cellpadding="0"cellspacing="2">
		<tr>
      	<td colspan="4">
   	   	<table border="0" width="100%" cellpadding="0"cellspacing="2">
		 <tr>
            <td class="smallText" valign="top"><?php echo $countries_split->display_count($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page, TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?></td>
            <td class="smallText" align="right"><?php echo $countries_split->display_script_links($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page,1,'page_navigation(\'\'','1'); ?></td>
          </tr>
	   </table>
	  </td>
	</tr>
	</table>
	<div id="new_country_content" style="display:none;" class="openContent">
		<form name="new_country_detail" method="post" action="shop_zones.php">
		<table width="100%" cellpadding="2" cellspacing="2" border="0">
			<tr>
				<td class="main"><?php echo tep_image(DIR_WS_IMAGES.'template/icon_active.gif').'&nbsp;&nbsp;New Country';	?></td>
				<td align="right"><?php echo '<a href="javascript:void save_new_country(\'new_country_detail\');">'.tep_image(DIR_WS_IMAGES.'template/img_savel.gif','Save','','','Save').'</a>&nbsp;&nbsp;<a id="close_new_zone_id" href="javascript: close_new_zone();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','Close').'</a>'; ?></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
				<table cellpadding="5" cellspacing="0" border="0">
					<tr class="main">
						<td class="main" align="left"><?php echo 'Country Name ' . tep_draw_input_field('countries_name','');?></td>
						<td class="main" align="left"><?php echo 'ISO Code (2):' . tep_draw_input_field('countries_iso_code_2','','maxlength="2"');?></td>
						<td class="main" align="left"><?php echo 'ISO Code (3):' . tep_draw_input_field('countries_iso_code_3','','maxlength="3"');?></td>
					</tr>
					<tr class="main">
						<td colspan="3" align="center"><?php echo 'Country Code&nbsp;' . tep_draw_input_field('countries_code','') . '&nbsp;&nbsp;Address Format&nbsp;' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats(), '');?></td>
					</tr>
				</table>
				</td>		
			</tr>
		</table>
		</form>
	</div>
<?php }
?>

<script language="javascript">
	var display_flag=1;
		function do_hover_change1(element,mode){
		if(display_flag==1){
		if (element.mode && mode==element.mode) return;
		if (mode==2)
			element.firstChild.src=element.firstChild.src.replace(".gif","_hover.gif");
		else
			element.firstChild.src=element.firstChild.src.replace("_hover.gif",".gif");
		}
		element.mode=mode;
		}
</script>