
<?php 
include("../includes/site_config.php");

$title=$_REQUEST['title'];
$values=addslashes($_REQUEST['value']);
$tit=addslashes($_REQUEST['tit']);
 $mode=$_REQUEST['mode'];


switch ($mode) {
	case 'edit':
	
	$titl=mysql_query("select * from language where lan_id='$tit'");
	$edit = mysql_fetch_object($titl);	
		break;

		
		
}
//echo "select count(*) as total from language where title = '" . $title . "'";
if(isset($_REQUEST['insert']))
		{
$ret=mysql_query("select count(*) as total from language where title = '" . $title . "'");

$check_title = mysql_fetch_array($ret);

if($check_title[total] > 0){?>
<DIV align=center>

						

						<font color="#FF0000"><?=ALREADY_EXIST?></font><BR>
						<HR width="100%" color=#c0c0c0 SIZE=0>
</DIV><?

}
else{


			$ins=mysql_query("insert into language(language_id, title, value) values('EN','$title','$values') ") OR die('Cant Insert!'); ?>
			<DIV align=center> 
		
		<font color="#FF0000"><?=LANG_INSERTED?></font><BR>
		</DIV>
		
		<?
		}
}


if(isset($_REQUEST['update']))
		{
			 $ins="update language set title='$title', value='$values' where lan_id='$tit' ";
			
			$up_key=mysql_query($ins); ?>
			<DIV align=center> 
		
		<font color="#FF0000"><?=KEY_UPDATE?></font><BR>
		</DIV>
		<script> setTimeout('window.close();',2000) </script>
		<?
		
}

?>

<style>
body{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
}
.text{
font-size:11px;
}
</style>

<script><!-- 
function Validate() 
{ 
	
	 if (document.EditLang.title.value.length < 2)
   {
     alert("Title Field can't be Blank!");
     document.EditLang.title.focus();
     return (false);
   }
   
   if (document.EditLang.value.value.length < 2)
   {
     alert("Value Field can't be Blank!");
     document.EditLang.value.focus();
     return (false);
   }
   
} 
//--></script> 
<html>
<head>
<title>Add/Update Language</title>
<body onLoad="return MyReload();">
<table width="100%" border="0" cellpadding="3" cellspacing="2">
<form name="EditLang" action="<?=$_SERVER['PHP_SELF']?>" method="post" onSubmit="return Validate();">
<input type="hidden" name="tit" value="<?=$tit?>">
  <tr>
    <td width="96" valign="top" bgcolor="#e6e6e6" class="text"><div align="center"><strong>
      <?=LANG_CODE?>
    </strong></div></td>
    <td width="972" bgcolor="#e6e6e6"><label>
      <input type="text" name="title" value="<?=$edit->title?>" size="50">
    </label></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#e6e6e6" class="text"><div align="center"><strong>
      <?=HTML_TEXT?>
    </strong> </div></td>
    <td  valign="top" bgcolor="#e6e6e6"><textarea name="value"  rows="10" cols="40" wrap="soft"><?=$edit->value?></textarea></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#e6e6e6" class="text"><input type="checkbox" name="checkbox" value="checkbox" />
    Recompile corresponding language file to apply changes. </td>
    </tr>
  <tr> 
  <? if($mode=='edit'){?>
<td colspan="2" bgcolor="#e6e6e6" align="center"><input type="submit" value="Update" name="update" /></td>
<? } else { ?>
    <td colspan="2" bgcolor="#e6e6e6" align="center"><input type="submit" value="Insert" name="insert" /></td>
	<? }?>
    </tr>
  </form>
</table>
 </body>
 </head>
</html>