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

  Copyright (c) 2005 osCommRes

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

Copyright 2007 ZacWare Pty. Ltd 

*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
   require('includes/application_top.php');
   require('includes/classes/split_page_results_event.php');
   tep_get_last_access_file();// get input entries to find type of entry
   $action = (isset($HTTP_GET_VARS['action']) ? tep_db_prepare_input($HTTP_GET_VARS['action']) : '');
   $action_value = (isset($HTTP_GET_VARS['action_value']) ? $HTTP_GET_VARS['action_value'] : '');
   $language_id=(isset($HTTP_GET_VARS['language_id'])?(int)$HTTP_GET_VARS['language_id']:'');
   //echo $language_id;
   $page = (isset($HTTP_GET_VARS['page']) ? (int)$HTTP_GET_VARS['page'] :1);
  // echo $page;
   $position=isset($HTTP_GET_VARS['position'])?$HTTP_GET_VARS['position']:1;
   if($action!=""){
   	  if($action=='get_details'){
   	  	  echo_get_details();
   	  }else if($action=='page_navigation'){
   	  		echo $action;
   	  		table_write();
   	  }else if($action=='edit'){
		    $cnt=0;
			$lang_query = tep_db_query("select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " where languages_id='" . $language_id ."' order by sort_order");
			//echo "select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " where languages_id='" . $language_id ."' order by sort_order";
			 $lang_result=tep_db_fetch_array($lang_query);
			echo 'edit';
		?>        				   		
			<table border="0" cellspacing="2" cellpadding="4" width="100%" align="left">
			    <tr>
				 <td align="center">
					  <table border="0" cellspacing="2" cellpadding="4" width="70%">							     
						<tr valign="top">
							<td align="center" width="10%"></td>
							<td class="main" align="right" width="15%">Name</td><td align="left" width="10%"><?php echo tep_draw_input_field('name', $lang_result['name'],'maxlength=32');?></td>
							<td class="main" align="right" width="15%">Code</td><td align="left" width="10%"><?php echo tep_draw_input_field('code', $lang_result['code'],'maxlength=2');?></td>
							<td align="center" width="10%"></td>
						</tr>
						<tr valign="top">
							<td align="center" width="10%"></td>
							<td class="main" align="right" width="15%">Image</td><td align="left" width="10%"><?php echo tep_draw_input_field('image',$lang_result['image'],'maxlength=64');?></td>
							<td class="main" align="right" width="15%">Directory</td><td align="left" width="10%"><?php echo tep_draw_input_field('directory',$lang_result['directory'],'maxlength=32');?></td>
							<td align="center" width="10%"></td>
						</tr>
						</table>
					</td>
					</tr>
					
						<tr valign="top">
							<!-- <td class="main" align="left">Sort Order</td><td class="main"><?php echo  tep_draw_input_field('sort_order', $lang_result['sort_order'],'maxlength=3');?></td> -->
							<td class="main"><?php  if (DEFAULT_LANGUAGE !=$lang_result['code']) 
								echo tep_draw_separator('pixel_trans.gif', '10', '10') . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT?>
							</td> 
						</tr>
			<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr>		
 		 </table>      
<?php   }else if($action=='pos_down' || $action=='pos_up'){ 		
			  $result='sort_order_error';	
			  $position = isset($HTTP_GET_VARS['pos'])?(int)$HTTP_GET_VARS['pos']:0;
			  if (trim($action) == 'pos_up')
					$sort_query=tep_db_query("select sort_order, languages_id from " . TABLE_LANGUAGES . " where  sort_order<" . $position . " order by sort_order desc limit 1");
			  else if($action=='pos_down')
					$sort_query=tep_db_query("select sort_order, languages_id from " . TABLE_LANGUAGES. " 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_LANGUAGES . " set sort_order='" . $position ."' where languages_id='" . (int)$sort_result['languages_id'] . "'");
						//echo "update " . TABLE_LANGUAGES . " set sort_order='" . $position ."' where languages_id='" . (int)$sort_result['languages_id'] . "'";
						if($result<0) $result='error';												
						$result = tep_db_query("update " . TABLE_LANGUAGES . " set sort_order='" . (int)$sort_result['sort_order'] . "' where languages_id='" . $languages_id ."'");
						if($result<0) $result='error';
						$result="sort_order_success".$prev_order;						
			    }	
			   echo $result; 	 	
		 }else if($action=='delete'){
		 global $error,$remove_language;
			  //echo DEFAULT_LANGUAGE;
		   $lng_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$language_id . "'");
      	   $lng = tep_db_fetch_array($lng_query);
			if($lng['code']==DEFAULT_LANGUAGE)
			{
			$lang_class_string='deleteclose';
			$lang_class_string.="<table border='0' cellspacing='2' cellpadding='2' width='100%'><tr><td width='5' align='center'>".tep_image('images/template/img_trash.gif').'</td>';
			$lang_class_string.='<td width="400" align="left" class="inner_title">'. TEXT_INFO_HEADING_DELETE_LANGUAGE  .'</td></tr>';
			$lang_class_string.='<tr><td >&nbsp;</td><td width="400" align="left" class="main">' . ERROR_REMOVE_DEFAULT_LANGUAGE .'<br></td></tr>';
			$lang_class_string.='<tr><td colspan="2">'.tep_draw_separator('pixel_trans.gif',60,20).'</td></tr></table>';
			echo $lang_class_string;
			}else {
			$lang_class_string='delete';
			$lang_class_string.="<table border='0' cellspacing='2' cellpadding='2' width='100%'><tr><td width='17' align='center'>".tep_image('images/template/img_trash.gif').'</td>';
			$lang_class_string.='<td width="500" align="left" class="inner_title">'. TEXT_INFO_HEADING_DELETE_LANGUAGE  .'</td></tr>';
			$lang_class_string.='<tr><td></td><td width="500" align="left" class="main">' . TEXT_INFO_DELETE_INTRO .'<br></td></tr><tr><td>&nbsp;</td></tr></table>';
			echo $lang_class_string;
			}
        }else if($action=='update'){ 
		$language_id = tep_db_prepare_input($HTTP_GET_VARS['language_id']);
        $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
        $code = tep_db_prepare_input($HTTP_POST_VARS['code']);
        $image = tep_db_prepare_input($HTTP_POST_VARS['image']);
        $directory = tep_db_prepare_input($HTTP_POST_VARS['directory']);
       // $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
	   $sort_order=$position;		 	
				$max_sql = "select max(sort_order) as max_sort from " . TABLE_LANGUAGES;
   			$max_query = tep_db_query($max_sql);	
			$max_total = tep_db_fetch_array($max_query);
			$sort_id=1;
			$sort_id=($max_total['max_sort']+1);				
			$sort_order_array = array('sort_order'=>$sort_id);

		if ($language_id>0 && $HTTP_POST_VARS['action_type']=='edit')   {
		
	   tep_db_query("update " . TABLE_LANGUAGES . " set name = '" . tep_db_input($name) . "', code = '" . tep_db_input($code) . "', image = '" . tep_db_input($image) . "', directory = '" . tep_db_input($directory) . "' where languages_id = '" . (int)$language_id . "'");
		//$prev_id=
		$sql=tep_db_query("select languages_id from languages where code  ='" . DEFAULT_LANGUAGE ."'");
		$sql_result=tep_db_fetch_array($sql);
		$prev_id=$sql_result['languages_id'];
        if ($HTTP_POST_VARS['default'] == 'on') {
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
        }
		}	
		else  if($HTTP_POST_VARS['action_type']=='new'){
	   $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
        $code = tep_db_prepare_input($HTTP_POST_VARS['code']);
        $image = tep_db_prepare_input($HTTP_POST_VARS['image']);
        $directory = tep_db_prepare_input($HTTP_POST_VARS['directory']);
       // $sort_order = tep_db_prepare_input(($HTTP_POST_VARS['sort_order']) ? $HTTP_POST_VARS['sort_order'] : '0');
	   $sort_order=$position;		 	
			$max_sql = "select max(sort_order) as max_sort from " . TABLE_LANGUAGES;
   			$max_query = tep_db_query($max_sql);	
			$max_total = tep_db_fetch_array($max_query);
			$sort_id=1;
			$sort_id=($max_total['max_sort']+1);	

        tep_db_query("insert into " . TABLE_LANGUAGES . " (name, code, image, directory, sort_order) values ('" . tep_db_input($name) . "', '" . tep_db_input($code) . "', '" . tep_db_input($image) . "', '" . tep_db_input($directory) . "', '" . $sort_id . "')");
        $insert_id = tep_db_insert_id();

// create additional categories_description records

        $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id where cd.language_id = '" . (int)$languages_id . "'");
        while ($categories = tep_db_fetch_array($categories_query)) {
          tep_db_query("insert into " . TABLE_CATEGORIES_DESCRIPTION . " (categories_id, language_id, categories_name) values ('" . (int)$categories['categories_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($categories['categories_name']) . "')");
        }

// create additional products_description records
        $products_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where pd.language_id = '" . (int)$languages_id . "'");
        while ($products = tep_db_fetch_array($products_query)) {
          tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url) values ('" . (int)$products['products_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products['products_name']) . "', '" . tep_db_input($products['products_description']) . "', '" . tep_db_input($products['products_url']) . "')");
        }

// create additional products_options records
        $products_options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "'");
        while ($products_options = tep_db_fetch_array($products_options_query)) {
          tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$products_options['products_options_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products_options['products_options_name']) . "')");
        }

// create additional products_options_values records
        $products_options_values_query = tep_db_query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . (int)$languages_id . "'");
        while ($products_options_values = tep_db_fetch_array($products_options_values_query)) {
          tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$products_options_values['products_options_values_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products_options_values['products_options_values_name']) . "')");
        }

// create additional manufacturers_info records
        $manufacturers_query = tep_db_query("select m.manufacturers_id, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on m.manufacturers_id = mi.manufacturers_id where mi.languages_id = '" . (int)$languages_id . "'");
        while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
          tep_db_query("insert into " . TABLE_MANUFACTURERS_INFO . " (manufacturers_id, languages_id, manufacturers_url) values ('" . $manufacturers['manufacturers_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($manufacturers['manufacturers_url']) . "')");
        }

// create additional orders_status records
        $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
        while ($orders_status = tep_db_fetch_array($orders_status_query)) {
          tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . (int)$orders_status['orders_status_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($orders_status['orders_status_name']) . "')");
         }
       	echo 'new_lang';				
       }
        if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
          echo 'page_navigation';
		  table_write();
		}else
		echo_get_details();  	  	  		    
   	 }else if($action=='delete_confirm'){   	    
		$language_id = tep_db_prepare_input($HTTP_GET_VARS['language_id']);
		 $lang_query = tep_db_query("select languages_id from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_CURRENCY . "'");
        $lang = tep_db_fetch_array($lang_query);
        if ($lang['languages_id'] == $language_id) {
          tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
        }

        tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where language_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_MANUFACTURERS_INFO . " where languages_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$language_id . "'");
        tep_db_query("delete from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$language_id . "'");
		

        $lng_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$language_id . "'");
        $lng = tep_db_fetch_array($lng_query);

        $remove_language = true;
        if ($lng['code'] == DEFAULT_LANGUAGE) {
          $remove_language = false;
         // $messageStack->add(ERROR_REMOVE_DEFAULT_LANGUAGE, 'error');
		  $error=ERROR_REMOVE_DEFAULT_LANG;
        }
	    echo 'delete_success';	     
	 }
   	 exit;
   }        
   function echo_get_details(){
  	 global $language_id,$prev_id;	
	 //echo "select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " where languages_id='" . $language_id ."' order by sort_order";
  		$lang_query = tep_db_query("select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " where languages_id='" . $language_id ."' order by sort_order");
		//if(tep_db_num_rows($lang_query)>0){
			$lang_class=tep_db_fetch_array($lang_query);
			
			$config=tep_db_query("select * from configuration where configuration_value='" .$lang_class['code'] ."'");
			$config_value=tep_db_fetch_array($config);
			$con_value=$config_value['configuration_value'];
			//if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
			 if ($con_value == $lang_class['code']) {
			 $lang_name='<b>'.$lang_class['name'].'(default)'.'<b>';
			 } else {
			 $lang_name=$lang_class['name'];
			 }
			 //}
			$str_vals.=$lang_class['languages_id']."||".$lang_name."||".$lang_class['image']."||".$lang_class['directory'] ."||".$lang_class['sort_order']."||".$lang_class['code']."||".$prev_id;
		//}else $str_vals="No Record Found";	
		//}
		echo 'get_details'.$str_vals;
  } 
   function table_write(){
    global $page;	
   ?>
  	<table border="0" cellpadding="0" cellspacing="0" width="100%" id="language_table">
	<?php   $languages_query_raw = "select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " order by sort_order";
 		    $languages_query = tep_db_query($languages_query_raw);		   
		   if(tep_db_num_rows($languages_query)>0){ 
		    while ($lang = tep_db_fetch_array($languages_query)) {					 
				 $class="dataTableRowEven";
  				 if($rows%2==0) $class="dataTableRowOdd"; 					
  				 $rows++;
  				 echo '  <tr style="height:25" class="'.$class.'" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'head_'.$lang['languages_id'].'\').style.display==\'none\') expand_category(' . $lang['languages_id'] . ',3);">' . "\n"; 
			   ?>  			      
		   	  <td colspan="4" width="100%">
		   	  	<div id="data_<?php echo $lang['languages_id'];?>">
		   	  	 <table border="0" cellspacing="0" cellpadding="0" width="100%">
		   	  		<tr>
					<?php $config=tep_db_query("select * from configuration where configuration_value='" .$lang['code'] ."'");
						  $config_value=tep_db_fetch_array($config);
						  $con_value=$config_value['configuration_value'];
						  //if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
					   	 if ($con_value == $lang['code']) {
						 $lang_name='<b>'.$lang['name'].'(default)'.'</b>';
						 } else {
						 $lang_name=$lang['name'];
						 }
						 
			 ?>
					
                   <td class="dataTableContent" id="lname_<?php echo $lang['languages_id'];?>" width="50%"><?php echo $lang_name; ?></td>
             			   <td width="50%" class="dataTableContent" align="left"><?php echo $lang['code']; ?></td>
             		</tr>
		   	  	</table>
		   	   </div>
		   	   <div class="openContent" id="head_<?php echo $lang['languages_id'];?>" style="display:none"></div>
		   	  </td>					      
      		</tr>
      	<?php }
			 }else echo '<tr><td id="no_language" class="smallText">' . TEXT_NO_LANGUAGES . '</td></tr>'; ?>
			 
			 <tr id="new_language" style="display:none" >
			<td colspan="5" >	
				<table cellpadding="1" cellspacing="0" border="0" width="100%" class="openContent">
					<tr class="openContent_top" valign="top">
						<td class="inner_title" valign="bottom"><?php echo 'New Language';?></td>
						<td width='40%' align='right' ><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:drop_new_Language();'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td>
					</tr>
					<tr><td colspan='5' ><div id="span_new" style="display:none"></div></td></tr>
				</table>
			</td>
		</tr>	
		</table>

<?php  } ?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language=javascript>
   var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
   function validateForm(lfrm){
      var error_result="";
      if(lfrm.action_type) var action_type=lfrm.action_type.value;
	  if(lfrm && lfrm.language_id) id=lfrm.language_id.value;
	  var span_details=document.getElementById("span_details");
	   var span_new=document.getElementById("span_new");
	  var span_edit=document.getElementById("span_edit");				
	  var span_delete=document.getElementById("span_delete");
	  var loadings=document.getElementById("loading");
	  var ids="";
	  if(span_edit)
	  details=span_edit;	
	  else details=span_new;  	  	
	   if(details.style.display==""){	
			 if( (lfrm.name.value=="") || (str_trim(lfrm.name.value)=="") )
			  		error_result+="Please Enter Language Name\n";
			 if( (lfrm.code.value=="") || (str_trim(lfrm.code.value)=="") )
			  		error_result+="Please Enter Language Code\n";
			  if( (lfrm.image.value=="") || (str_trim(lfrm.image.value)=="") )
			 		error_result+="Please Enter Image Name\n";	
			  if( (lfrm.directory.value=="") || (str_trim(lfrm.directory.value)=="") )
			 		error_result+="Please Enter Directory\n";
			//  if (lfrm.sort_order.value=="")
			 //		error_result+="Please Enter Sort Order\n";											   	       		  
	 	 if (error_result!=""){
    	    alert(error_result);
	 		 return false;
	     }else{      							
			if(lfrm.action_type && lfrm.action_type.value=='edit')  ids="&language_id="+id;
			command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=update');?>"+ids;
			
			if(loadings) loadings.style.display="";
			if(span_edit) span_edit.style.display="none";
			if(document.getElementById("new_language")){document.getElementById("new_language").style.display="none";
			document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
			display_flag=1;
			}
	      }
	}else if(span_delete.style.display==""){      							
			ids="&language_id="+id;
			command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=delete_confirm');?>"+ids;
			if(loadings) loadings.style.display="";
			if(span_delete) span_delete.style.display="none";
     }
	do_post_command('shop_language',command);
    return false;
   }
   var previous_id='';
  function expand_category(id,category,r_type,sta){ 	
  
  if(id==0 && category==2){
	display_flag=0;
	if(document.getElementById('no_language'))
		document.getElementById('no_language').style.display='none';
	}
	if(id==0 && category==1){
	if(document.getElementById('no_language'))
		 document.getElementById('no_language').style.display='';
	document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
	display_flag=1;
	}
  
      document.getElementById('span_new').style.display="none";
	 document.getElementById('new_language').style.display="none";
	  document.getElementById('span_new').innerHTML='';
	  if( document.getElementById('new_language_button'))
  	 	document.getElementById('new_language_button').style.display=''; 
   
		//if(category==3 && document.getElementById('head_'+id) && document.getElementById('head_'+id).style.display!='none' && document.getElementById("span_edit") && document.getElementById("span_edit").style.display=='none' && document.getElementById("span_delete") && document.getElementById("span_delete").style.display=='none') return;
		var sta;
		if(!sta) sta="";
		var frm=document.shop_language;
		if(category=='1' && document.getElementById("page_''") && sta!=""){
 	 		id=parseInt(document.getElementById("page_''").options[document.getElementById("page_''").selectedIndex].value);
 	 		if(sta=='next' && document.getElementById("page_''")) {
 	 			if(document.getElementById("page_''").length==document.getElementById("page_''").selectedIndex+1) return;
 	 			id+=1;
 	 		}else if(sta=='prev') {
 	 			if(document.getElementById("page_''").selectedIndex==0) return;
 	 			id-=1;
 	 		}
 	 		if(id<=1) id=1;
 	 	}else if(category=='1' && sta=="") id="";
 	 	var res_display=document.getElementById("res_display"); 	 	 	 	 	 	 	 	 	 		 	  	 	
 	 	if(res_display) res_display.style.display="none"; 	 		 	 	
 	 	 if(frm && frm.language_id && frm.language_id.value>0)  {
			var old_ids=frm.language_id.value;			
			var pre_data_id=document.getElementById("data_"+old_ids);
			var pre_head=document.getElementById("head_"+old_ids);			
			var loadings=document.getElementById("loading");
			if(loadings) loadings.style.display="none";
			if(category==1 && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }		 	 
			if(id>0 && frm.language_id.value>0 && frm.language_id.value!=id){			   
			   if(pre_head && pre_head.style.display=="") pre_head.style.display="none";
			   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
			   frm.language_id.value=id;			   
			}							
		if(category!=1 && frm && frm.language_id && frm.language_id.value=="") frm.language_id.value=id;		 								 	 	 	 
 	 	if(category){
 	 		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_"+id);						
			var head=document.getElementById("head_"+id);
			var img_save=document.getElementById("img_save");	
			var def_close=document.getElementById("def_close");		
			var command="";																		 
 	 		switch(category){ 
				case '1': 	 			       
 	 			       var page=""; 
					   var ser="";
					    if(document.getElementById("search") && document.getElementById("search").value!="" && sta=="" && !r_type) {
					   	ser="&search="+document.getElementById("search").value;
						id="";
					   }else if(document.getElementById("search") && document.getElementById("search").value=="" && sta=="" && !r_type) return;
					    else if(document.getElementById("search") && document.getElementById("search").value=="" && sta=="" && r_type=='reset') id=1;	 			       
 	 			       if(id!="") page="&page="+id; 
 	 			       command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=page_navigation');?>"+page;
 	 			   	   if(document.getElementById("ajax_details")) document.getElementById("ajax_details").innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>"; 	 			   	    	 			   					   
 	 			break;	 			 	 			
 	 			case 2:
 	 				 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(frm.action_type) frm.action_type.value='new'; 	 					
 	 				 command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=edit');?>"; 	
				break; 	 			
 	 			case 3:
				 if(document.getElementById("new_language")){ document.getElementById("new_language").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(def_close) def_close.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(previous_id!='')
						if(document.getElementById('head_'+previous_id))
							document.getElementById('head_'+previous_id).innerHTML='';	 	 	 			 	
 	 			 	if(data_id && data_id.style.display=="") data_id.style.display="none";
 	 			 	if(pre_head && pre_head.style.display=="") pre_head.style.display="none"; 	 			 	
 	 			 	if(head) {
 	 			 	 	head.style.display=""; 	 			 	 	 	 			 	  	 			
 	 			 		head.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	 			 		
 	 			 	}
 	 			 	command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=get_details');?>&language_id="+id; 	 			 	
					previous_id=id;
 	 			 }
 	 			break;
 	 			case 4:
 	 					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(frm.action_type) frm.action_type.value='edit'; 	 					
 	 					command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=edit');?>&language_id="+id; 	
 	 			break; 	 			
 	 			case 5:	 	 				 	 				 	 		 	 				
 	 					span_delete.style.display="";
 	 					span_edit.style.display=span_details.style.display="none";
 	 					span_delete.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
 	 					command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=delete');?>&language_id="+id; 	 	 	 					 	 					 	 			
 	 			break;
				case 6:				 																
				case 7:
					var s_order=frm.sort_order;															
					if(head) var tbl_tr_obj=head.parentNode.parentNode;																									
					var pos_cnt=0;																																	
					pos="pos_up";
					if(category==7) pos="pos_down";
					command="<?php echo tep_href_link(FILENAME_LANGUAGES);?>?language_id="+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;		
				case 8:
		 	 			  if(head && data_id){
		 	 			  	head.style.display="none";
		 	 			  	head.innerHTML="";
		 	 			  	data_id.style.display="";	
		 	 			  } 
		 	 			break;		 	
 	 		}
 	 		if(command!="") do_get_command(command);
 	 	}		
 	 }  	
   function do_result(result){
   	  var frm=document.shop_language;
   	  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,5)=='close') print_details('close',result.substr(5));	
		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,8)=='new_lang') print_details('new_lang',result.substr(8));
		else if(result.substr(0,6)=='delete') print_details('delete',result.substr(6));	
			
   	  }
   }
   function print_details(category,result){ 	 	 	 	 	 	 	 	 	 	
 	 	var no_result="";
	 	var frm=document.shop_language;
		if(result.substr(0,15)=='No Record Found'){
 	 		no_result="No Record Found";
 	 	}else if(result!='' && result.length>0 && category!='edit' && result.substr(0,15)!='No Record Found'){
 	 		splt_str=result.split("||"); 	
			var language_id=""; 		  	 		
 	 		var language_name="";
			var language_image="";
			var language_directory="";
			var language_sort_order="";
			var language_code="";
			
 	 		language_id=splt_str[0]; 	 		
 	 		language_name=splt_str[1];
 	 		language_image=splt_str[2]; 	 
			language_directory=splt_str[3]; 
			language_sort_order=splt_str[4]; 
			language_code=splt_str[5]; 
			pp_id=splt_str[6]; 
			
			//var defaultlang="<?php echo DEFAULT_LANGUAGE;?>";
			//if (defaultlang==language_code){
			//language_name=language_name+'(Default)';
			//}
			//else{
			//language_name=language_name;
			//}
				 	
					//alert(document.getElementById('data_' + pp_id)); 		 	 								
 	 	}	  	 		  	 		 	 	 	  	 		 	  	 
 		if(frm && frm.language_id) var id=frm.language_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 equip=document.getElementById("equip");
 		var img_save=document.getElementById("img_save");
		var def_close=document.getElementById("def_close");
/*					if(document.getElementById('lname_' + pp_id)) { alert("hai");
					var innerhtml=document.getElementById('lname_' + pp_id).innerHTML;
					var obj=document.getElementById('lname_' + pp_id);
					str=obj.innerHTML;
					alert(str);
					//obj.innerHTML=str.replace('(default)',''); 
					
					}
*/		if(img_save && category!='get_details') img_save.style.visibility="visible";
	//	if(d && category!='get_details') img_save.style.visibility="visible";		
 	 	switch(category){ 	 		 	 		 	 		 	 		
 	 		case 'get_details': 
	 		if(head  && no_result!="")
				head.innerHTML=no_result; 	 			 	 		
 	 		else if(head && no_result==""){	 	 		
	 	 		if(data_id){		 	 		
		 	 		data_id.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						         '<tbody><tr>'+
						         	'<td class="dataTableContent" width="50%" align="left" id="lname_'+language_id+'" >'+language_name+'</td>'+
									'<td class="dataTableContent" width="50%" align="left">'+language_code+'</td>'+
							    '</tr>'+
						      '</tbody></table>';	
	 	 		}		 	 			
	 	 		include ="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				"<tr height='40' class='openContent_top' valign='top'>"+				  				  							  
				  "<td width='30' valign='top' align='center'><a href='javascript:expand_category("+language_id+",6,"+language_sort_order+");'><img border='0' src='images/template/img_arrow_up.gif'></a>&nbsp;<a href='javascript:expand_category("+language_id+",7,"+language_sort_order+");'><img border='0' src='images/template/img_arrow_down.gif'></a></td>"+
				  "<td align='left' valign='top' width='280' class='inner_title' onclick='javascript:expand_category("+language_id+",8);'>"+language_name+"</td>"+
				  "<td width='100' align='left' class='main' valign='top'>"+
				  	"<table border='0' cellspacing='0' cellpadding='0' style='height:30px;display:inline;position:relative;'>"+
				  	  "<tr class='img_move' id='img_ids'>"+
				  	  	"<td class='cell_bg_popm_left' width='10'>&nbsp;</td>"+
				  	    "<td width='10%' onclick='javascript:change_class(this,1);expand_category("+language_id+",4);' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);'><img alt='Edit' title='Edit' src='images/template/img_edit.gif'></td>"+
				  	    "<td width='10%' onclick='javascript:change_class(this,1);expand_category("+language_id+",5);' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);'><img alt='Delete' title='Delete' src='images/template/img_trash.gif'></td>"+				  	    
				  	    "<td class='cell_bg_popm_right' width='10'>&nbsp;</td>"+
				  	  "</tr>"+
				  	"</table>"+
				  "</td><td width='245' onclick='javascript:expand_category("+language_id+",8);'>&nbsp;</td>"+
				 "<td width='75' align='right' nowrap='nowrap'><span id='img_save' style='visibility:hidden; width=80; align=right'><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href='javascript:expand_category("+language_id+",3);'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</span><span id='def_close' style='visibility:hidden;'><img src='images/template/img_closel.gif' onclick='javascript:declose();' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</span></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 valign='top'>"+
				  			"<td>"+				  							  			
				  				"<table width='90%' border='0' cellspacing='2' cellpadding='2' class='main'>"+
								"<tr valign='top'>"+
								"<td  nowrap='nowrap' width='10%' >&nbsp;</td>"+
											"<td align='right' nowrap='nowrap' width='10%'><b><?php echo 'Name:';?></b></td>"+
											"<td nowrap='nowrap'  align='left'  width='15%'>"+language_name+"</td>"+
											"<td align='right'  nowrap='nowrap' width='10%'><b><?php echo 'Code:';?></b></td>"+
											"<td nowrap='nowrap' align='left' width='15%'>"+language_code+"</td>"+
											"</tr>"+
										
										"<tr>"+
										"<td nowrap='nowrap' width='10%'>&nbsp;</td>"+
											"<td align='right' nowrap='nowrap' width='10%'><b><?php echo 'Image:';?></b></td>"+
											"<td nowrap='nowrap' align='left' width='15%'><img src='<?php echo DIR_WS_CATALOG_LANGUAGES;?>"+language_directory+"/images/"+language_image+"'>"+language_image+"</img></td>"+
											"<td align='right'  nowrap='nowrap' width='10%'><b><?php echo 'Directory:';?></b></td>"+
											"<td nowrap='nowrap' align='left' width='15%'><?php echo DIR_WS_CATALOG_LANGUAGES; ?>"+language_directory+"</td>"+
											"</tr><tr><td colspan='5'>&nbsp;</td></tr>";
						 include+="</table></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';
 	 		}									  
 	 	break;
 	 	case 'delete': 	 				 	 	
 	 		if(span_delete) span_delete.style.display="";
			if(result.substr(0,5)=='close'){
			document.getElementById("img_save").style.display='none';
			
			if(def_close) { 
			def_close.style.visibility="visible";	
			}
			result=result.substr(5);
			}
 	 		if(span_delete){ 	 			
 	 			span_delete.innerHTML=result; 	 
 	 			span_details.style.display=span_edit.style.display='none';
 	 		} 	 
											   			   
 	 	break; 	 	
 	 	case 'delete_success':			 
 	    	 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_DELETED_SUCCESSFULLY;?>";
 	    	 	res_display.style.display="";
				var obj=document.getElementById("page_''");
 	    	 	if(obj){  	    	 		
 	    	 		var len=obj.options[obj.selectedIndex].value;
				}	
					command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=page_navigation');?>&page="+len;
					do_get_command(command);
 	    	} 	    	 			 			 			
 	 	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(frm.sort_order) var s_order=frm.sort_order.value;															
			if(category=='sort_order_success'){			  			   
			   if(head)  {
				var tbl_obj=head.parentNode.parentNode;
				var up_href=head.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
			    var down_href=head.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[2];			    
			    var new_pos=result.substr(result.indexOf('sort_order_success'));			    
			    if(up_href && down_href && new_pos){
					up_href.href="javascript:expand_category("+id+",6,"+new_pos+")";
					down_href.href="javascript:expand_category("+id+",7,"+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(category=='sort_order_error'){
				res_display.style.display=""; 	    	 	
			    res_display.innerHTML="<?php echo 'Error in DB Please Try Again';?>"; 	    	 	 	    	 	 	    	 	 	    	 	 
			}
		break; 	
		case 'new_lang':
				var len=1;
				if(result!=""){
					result_splt=result.split('||');
					if(result_splt[0]>0){						
						var id=result_splt[0];
						var tax_class_title=result_splt[1];	
						var tax_class_description=result_splt[2];						
						if(head) {    						
    						var tbl_obj=head.parentNode.parentNode.parentNode.parentNode;    						
    						var row_obj=tbl_obj.insertRow(tbl_obj.rows.length);
    						var row_cell=row_obj.insertCell(0);
    						row_cell.innerHTML='<div id="data_'+id+'">'+
						       '<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						         '<tbody><tr>'+
						         	'<td class="dataTableContent" width="150" align="left">'+language_title+'</td>'+
						          '</tr>'+
						      '</tbody></table>'+
						      '</div>'+
						      '<div style="display:none;" class="openContent" id="head_'+id+'"></div>';						    						      
    						var rows_cnt=tbl_obj.rows.length-1;
    						var tbl=tbl_obj.rows[rows_cnt];
    						tbl.onclick=function () {((document.getElementById("head_"+id) && document.getElementById("head_"+id).style.display=='none')?expand_category(id,3):'')};
    						tbl.style.height="25px"; 
    						if(rows_cnt%2==0) tbl.className="dataTableRowOdd";
    						else tbl.className="dataTableRowEven";
    						tbl.onmouseover=function (){rowOverEffect(this)};
    						tbl.onmouseout=function (){rowOutEffect(this)};
    						if(head && data_id){
    							head.style.display="none";
    							data_id.style.display="";
    						}
    						if(res_display){
					    	 res_display.innerHTML="<?php echo 'insert success';?>";
				 	    	 res_display.style.display=""; 	    	 	
 	    	 				}
						}    					
					}
					command="<?php echo tep_href_link(FILENAME_LANGUAGES,'action=page_navigation');?>&page="+len;
					do_get_command(command);
				}																			 						
		break;
		}
 	 	if(res_display && res_display.style.display=="") setTimeout("res_display.style.display='none'",2000); 	 	 	 	 	 	
 	 	clearTimeout();
	  } 
	  var display_flag=1;
	  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(display_flag==1){
		if (obj.eve && mode==obj.eve) return;
		if (eve==2)
			obj.firstChild.src=obj.firstChild.src.replace(".gif","_hover.gif");
		else
			obj.firstChild.src=obj.firstChild.src.replace("_hover.gif",".gif");
	 } */			 		 			 
		 if(obj){		   		    		    
		    var img_get_src=obj.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_edit_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
			    if(img_get_src.src==img_src+'template/img_trash.gif') {
					if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_trash_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && span_delete && span_delete.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';		    		    		     		   	
		  }
		 }		 
	  }	
	  
	  function new_language(){
	  	if(document.getElementById('no_language'))
			document.getElementById('no_language').style.display='none';
	  display_flag=0;
	  var frm=document.shop_language;
	  id=frm.language_id.value;
	  
	    if(frm && frm.language_id && frm.language_id.value>0)  {
			var old_ids=frm.language_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( pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		 }		 	 
			if(id>0 && frm.language_id.value>0 && frm.language_id.value!=id){			   
			   if(pre_head && pre_head.style.display=="") pre_head.style.display="none";
			   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
			   frm.language_id.value=id;			   
			}
	
	  document.getElementById('span_new').style.display="";
	  
	   if(pre_head && pre_head.style.display=="") pre_head.style.display="none";
	   if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
	  document.getElementById('span_new').innerHTML="";
	  document.getElementById('new_language').style.display="";
	  if(frm.action_type) frm.action_type.value='new'; 
	  
	  document.getElementById('span_new').innerHTML='<table border="0" cellspacing="2" cellpadding="4" width="100%" align="left">'+
			   ' <tr><td align="center"><table border="0" cellspacing="2" cellpadding="4" align="center" width="70%"><tr valign="top"> '+
					'<td class="main" align="right" width="15%">Name</td><td align="left" width="10%"><?php echo tep_draw_input_field('name', '','maxlength=32');?></td> '+
					 '<td class="main" align="right" width="15%">Code</td><td align="left" width="10%"><?php echo tep_draw_input_field('code', '','maxlength=2');?></td>'+
						'</tr><tr valign="top">'+
							'<td class="main" align="right" width="15%">Image </td><td align="left" width="10%"><?php echo tep_draw_input_field('image','','maxlength=64');?></td>'+
							'<td class="main" align="right" width="15%">Directory </td><td align="left" width="10%"> <?php echo tep_draw_input_field('directory','','maxlength=32');?></td>'+
						'</tr></table></td></tr> '+
						'<tr valign="top"><td align="left"><table border="0" cellspacing="2" cellpadding="4" align="center" width="100%"><tr valign="top"> '+
						'<td class="main" align="left"><?php echo tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT?></td> '+
						'</tr></td></tr>'+
			'<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr> '+		
 		' </table> ';
		// document.getElementById('new_language_button').style.display='none';
	  }
	  
	 function drop_new_Language(){
	if(document.getElementById('no_language'))
		document.getElementById('no_language').style.display='';

	 change_new_image(document.getElementById('img_new'));
	  document.getElementById('new_language').style.display="none"
	  document.getElementById('new_language_button').style.display='';
	
	if(document.getElementById('new_customers_row_id')){
	customer_row_index=document.getElementById('new_customers_row_id').rowIndex;
	ajax_row_index=document.getElementById('new_ajax_row_id').rowIndex;
		var r1=document.getElementById('language_table').deleteRow(customer_row_index);
		var r2=document.getElementById('language_table').deleteRow(ajax_row_index-1);
	}
	}
	
	function declose(){
	var frm=document.shop_language;
	var id=frm.language_id.value;
	var head=document.getElementById("head_"+id); 
	 if(head) {
	head.style.display="none";
	}
	}
	  
</script>
<?php  // WebMakers.com Added: Java Scripts   
      include(DIR_WS_INCLUDES . 'javascript/' . 'webmakers_added_js.php')
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="4">
  <tr> 
 
<!-- body_text //-->   
             <td valign="top">
             <?php echo tep_draw_form('shop_language',FILENAME_LANGUAGES, '' ,'post','onsubmit="javascript:return validateForm(this);"');?>
	       	<table border="0" cellspacing="0" cellpadding="0" width=100%>
                 <tr><td id="res_display" class="main" style="display:none"></td></tr>
				 <tr  class="dataTableHeadingRow"><td align="left" colspan="2">
					 <div id="new_language_button" align="left">
						<?php echo '<a href="javascript:void new_language();" id="img_new"  onMouseOver="javascript:do_hover_change(this,2);" onMouseOut="javascript:do_hover_change(this,1);">' . tep_image('images/template/img_new.gif','New Language','22','22') . '</a>'; ?>
					</div> 
					</td>
				</tr>
				<tr><td colspan="2" ><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td></tr>
				
                 <tr class="dataTableHeadingRow" height=20 valign="top">
				  	 <td class="main" align="left" width="50%"><b>Language</b></td>
               		 <td class="main" align="left" width="50%"><b>Code</b></td>
               	 </tr>
                 <tr>
                	  <td colspan="4" id="ajax_details" >
	       	   			 <?php table_write(); ?>	  
		  			 </td>
				 </tr>        
       			<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '2', '10'); ?></td></tr>	
      	  </table>
        <input type="hidden" name="language_id" id="language_id">
	    <input type="hidden" name="action_type" id="action_type">
	    <input type="hidden" name="icnt" id="icnt">
		  <input type="hidden" id="sort_order">
        </form>
        </td>   
<!-- body_text_eof //-->
<!-- body_eof //-->
	</tr>
  </table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
<script language="javascript">
	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;
	}
	function change_new_image(element){
	display_flag=1;
	element.firstChild.src=element.firstChild.src.replace('_hover.gif','.gif');
	}
</script>
