<?php

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");



$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");


$querylog="SELECT Currency as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$HTTP_SESSION_VARS['dbName']."')	";
	$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
	while($rows=mysql_fetch_array($resultlog)){
		extract($rows);
	}

if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	
$query_language  = "select user_account, Language from ".$_SESSION['dbLabel'].".login  where user_account = '".$_SESSION['useraccount']."'";
		 $result_language = mysql_query($query_language, $connection); 
		 $row_language    = mysql_fetch_array($result_language);
		 extract($row_language);

$query_labels  = "SELECT Language, CURFORM_CODE as Code1, CURFORM_NAME as Name1, MultiplierOf, Currency as Currency1, CreationDate as CreationDate1, CURFORM_DATE as Date1, CURFORM_RATE as Rate1, CURFORM_PARITY as Parity1, AddCurrency as AddCurrency1
                  From ".$_SESSION['dbLabel'].".currency_label
                  where language = '".$Language."'";
$result_labels = mysql_query($query_labels, $connection);
$row_labels    = mysql_fetch_array($result_labels);
extract($row_labels);


$query_navigator = "SELECT LANGUAGE,
       ClearPage,
       Excel,
       Save,
       Print,
       Addd,
       SEARCH,
       Pending,
       CopyJV,
       PaymentRequests,
       ExportExcel
FROM ".$_SESSION['dbLabel'].".mainform_label
WHERE LANGUAGE = '".$Language."'";
$result_navigator = mysql_query($query_navigator, $connection);
$row_navigator    = mysql_fetch_array($result_navigator);
extract($row_navigator);

$query_currency  = "select currency as Currency1, ResultsPage as ResultsPage1 from ".$_SESSION['dbLabel'].".mainform_label where Language = '".$Language."'";
$result_currency = mysql_query($query_currency, $connection); 
$row_currency    = mysql_fetch_array($result_currency);
extract($row_currency);


	
	
//Read From Setup Table							
$querysetup= " select grid_color1, grid_color2,maxperpage from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}
	
//User Access
$querylog=" select ifNull(FA_CurrencyApp,0) As FA_CurrencyApp, ifNull(FA_CurrencyDel,0) As FA_CurrencyDel, ".
          " ifNull(FA_CurrencyMod,0) As FA_CurrencyMod from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());

while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}
//echo $mainmode;
//Access Mode On Insert/Edit/Delete
$InsMode = '';
if ($FA_CurrencyApp == 0)
	$InsMode = ' disabled ';
if(!isset($mainmode)) $mainmode='';

$saveEnabled = 0;
if ( ($FA_CurrencyMod == 1 && $Currency_Id !='') || ($FA_CurrencyApp == 1))
	$saveEnabled = 1;

//if($mainmode=='editmode' or $mainmode=='view' ){

	$query_edit=" select Currency_Id, Currency_code, Currency_name, ifNull(Currency_nature,0), date_format(Currency_CreationDate,'%d-%m-%Y')".
				" from currency where Currency_Id='".$Currency_Id."'";

	//echo $query_edit;
	$resultedit = mysql_query($query_edit, $connection);
	while($row=mysql_fetch_array($resultedit)){
        
		$Currency_Id=$row[0];
		$Currency_code=$row[1];
		$Currency_name=$row[2];
		$Currency_nature=$row[3];
	    $Currency_CreationDate=$row[4];
	}
	//$mainmode='edit';
//}


if($actionmode=='editdt'){
	$querydt = " select Curdt_id,Currency_code, date_format(Curdt_date,'%d-%m-%Y'), Curdt_rate, Curdt_parity".
			   " from Curdt ".
			   " where Curdt_id='".$Curdt_increment."'";
		   	
	//echo $querydt;
	$resultdt = mysql_query($querydt, $connection);
	while($rowdt=mysql_fetch_array($resultdt)){
        
		$Curdt_date=$rowdt[2];
		$Curdt_rate=$rowdt[3];
		$Curdt_parity=$rowdt[4];
	}
}

if($mainmode=='') $mainmode='insert';

print <<<HERE

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 


<script type="text/javascript" language="javascript">

function CheckNature() {
	if(document.Currency.Nature.checked){
		document.Currency.Currency_nature.value=1;

	}
	else
	{
		document.Currency.Currency_nature.value=0;

	}
}

function editmode () {
	document.Currency.mainmode.value='edit';
	document.Currency.action="Form_Currency.php?mainmode=edit";
	document.Currency.submit();
}

function AddCurrency() {

	document.Currency.mainmode.value='insert';
	document.Currency.action="Form_Currency.php";
	document.Currency.submit();
}

function ExportExcel() {
	var str = 'Form_CurrencyExcel.php';
	window.open(str);
}

function CancelRecord () {


	if (confirm ( "Are you sure you want to Cancel Page?")){
		ClearForm('All');
		document.Currency.action="Form_Currency.php?mainmode=";
		document.Currency.submit();
	}
}


function SubmitRecord(option) {
	var Parity=document.Currency.Curdt_parity.value;
	var Rate=document.Currency.Curdt_rate.value;
	
	if (document.Currency.Currency_code.value=='' )
	{
		alert('Unable to save : check missing field Code ');
		document.Currency.Currency_code.focus();
	}
		
	else 
	if (document.Currency.Currency_name.value=='' )
	{
		alert('Unable to save : check missing field Name ');
		document.Currency.Currency_name.focus();
	}

	else
	if (document.Currency.Curdt_rate.value=='' && option == 2)
	{
		alert('Unable to save : check missing field Rate ');
		document.Currency.Curdt_rate.focus();
		
	}
	else
	if (document.Currency.Curdt_parity.value=='' && option == 2)
	{
		alert('Unable to save : check missing field Parity ');
		document.Currency.Curdt_parity.focus();
	
	}
	else
	if (Parity*1/1!=Parity && option == 2)
	{
		alert('Unable to save : Parity Must be number ! ');
		document.Currency.Curdt_parity.focus();

	}
	else
	if (Rate*1/1!=Rate && option == 2)
	{
		alert('Unable to save : Rate Must be number ! ');
		document.Currency.Curdt_rate.focus();

	}	
	else {
		vMainMode = document.Currency.mainmode.value;
		document.Currency.action="Form_Currency_Actions.php?mainmode1="+vMainMode;
		document.Currency.submit();
	}
}

function DeleteDetail(CurdtIn){

	if (confirm ( "Are you sure you want to Delete record?"))
	{
		vMainMode = document.Currency.mainmode.value;
		document.Currency.Curdt_increment.value = CurdtIn;
		document.Currency.actionmode.value = 'deletedt';
		
		document.Currency.action="Form_Currency_Actions.php?mainmode1="+vMainMode+"&actionmode1=deletedt";
		document.Currency.submit();
		
	}	

}

function UpdateDetail(CurdtIn){
	vMainMode = document.Currency.mainmode.value;
	document.Currency.Curdt_increment.value = CurdtIn;
	document.Currency.actionmode.value = 'editdt';
		
	document.Currency.action="Form_Currency.php?mainmode="+vMainMode+"&actionmode=editdt";
	document.Currency.submit();

}

function ClearPage(){
	if (confirm ( "Are you sure you want to Clear Page?"))
	{
		ClearForm('All');
		
		
		
		x.Currency_Id.value='';
		x.mainmode.value='';
		x.message.value='';
		x.action='Form_Currency.php';
		x.submit();
	}	
}

function cleardetail() {
	x = document.Currency;
	x.Curdt_increment.value='';
	x.Curdt_date.value='';
	x.Curdt_rate.value='';
	x.Curdt_parity.value='';
	
	x.submit();

}

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.Currency;
	x.Currency_Id.value='';
	x.Currency_code.value='';
	x.Currency_name.value='';
	x.Currency_nature.value='';
	//x.Currency_CreationDate.value='';
	x.message.value='';
	x.Curdt_date.value='';
	x.Curdt_rate.value='';
	x.Curdt_parity.value='';

	x.mainmode.value='';
}

/*
function SearchForCurrency(){
    ClearForm('All');
    x = document.Currency;
    win = window.open('Form_CurrencySearch.php', 'Form_CurrencySearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=630,height=450,top=100,left=100');		
	win.creator = self;
	win.focus();		
			
}*/

   function PrintPreview() {
	var str = '';
	
	str = 'Form_CurrencyPreview.php';
	window.open(str);

}

 function Printdt() {
	var str = '';
	
	str = 'Form_CurrencyPreviewDt.php';
	window.open(str);

}

function SetCur(CurId){
	
	document.Currency.Currency_Id.value=CurId;
	document.Currency.message.value='';
	document.Currency.actionmode.value='';
	cleardetail();
	document.Currency.mainmode.value='edit';
	document.Currency.submit();
}

function SetNextPage(startrange,perpage){
	document.Currency.action='Form_Currency.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.Currency.submit();
}

function SetPrvPage(startrange,perpage){
	document.Currency.action='Form_Currency.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.Currency.submit();
}

function SearchForCur(){
	x = document.Currency;
	document.Currency.action='Form_Currency.php?startrange=0';
	document.Currency.submit();
}

function ClearKeyword(){
	x = document.Currency;
	x.txtKeyword.value='';
	document.Currency.submit();
}

function submitenter(myfield,e){
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   	document.Currency.action='Form_Currency.php?startrange=0';
	document.Currency.submit();
  
   return false;
   }
else
   return true;
}

function confirm_delete(Code) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		//window.event.returnValue = true;
		document.Currency.actionmode.value='delete';	
		
		document.Currency.action='Form_Currency_Actions.php?CurrencyId='+Code;
		document.Currency.submit();
	}
					
}

function set_limit(){

	perpage=document.Currency.perpage.value;
	document.Currency.action='Form_Currency.php?perpage='+perpage+'&startrange=0';
	document.Currency.submit();
}

function returnMsg(){
	alert('Access Denied!');
	return 0;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>$AddCurrency1</title>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style1 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">

<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
</head>
<body >
<form name='Currency' method='post' onKeyPress="return submitenter(this,event)">
<input type='hidden' name='mainmode' value='$mainmode'>
<input type=hidden name='actionmode' value='$actionmode'>
<input type=hidden name='message' value='$message'>
<input type=hidden name='Currency_Id' value='$Currency_Id'>

HERE;



if($mainmode==''){
$status='disabled';
$dis='disabled';

}


if($mainmode=='view'){

$status='readonly';
$dis='disabled';

}


if($mainmode=='insert')
$status='';

//$style= "style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'";

echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title' style='text-transform: uppercase'>".$Currency1."</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";


echo"<tr>
		<td  height='34'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				<td width='38'  height='34'>&nbsp;</td>
				<td valign='middle' height='34' width='720px'>";
echo"		<button type='button' id='btnClear' name='btnClear' onclick='ClearPage(); return false;' title='Clear Page'><span><span>$ClearPage</span></span></button>";


echo"		<button type='button' id='btnPost' name='btnPost' onclick=\"";
if ($saveEnabled == 1)
	echo "SubmitRecord(); ";
else
		echo "returnMsg(); ";
	echo "return false;\" title='Save Changes' $Insmode><span><span>$Save</span></span></button>
			<button  type='button'  value='Print' onclick='PrintPreview();return false;' title='print' ><span><span>$Print</span></span></button>
			<button type='button' id='btnExcel' name='btnExcel' onclick='ExportExcel(); return false;' title='Export Excel' ><span><span>$Excel</span></span></button>";


				
echo"   </td><td align='left' width='240px'>
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:105px;' onKeyPress='return submitenter(this,event)'>
<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForCur(); return false;' title='Search CostCenter'><span><span>Find</span></span></button>
<button type='button' id='btnClear' name='btnClear' onclick='ClearKeyword(); return false;' title='Clear Keyword'><span><span>Clear</span></span></button>
</td><td align='left'>
	 <span class='style1'><b>".$ResultsPage1."</b></span>
	 <span class='style1'><select name='perpage' id='perpage' value='$perpage' onchange=set_limit();>";
	 
	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
		
	for($i=10;$i<=$maxperpage;$i=$i+10){
		if($i==$perpage)
			echo "<option value='$i'  selected>$i</option>";
		else echo "<option value='$i'>$i</option>";
		
	} 
	 echo"</td></tr>";
echo"	</table>";
echo"</td></tr>";

echo"<tr><td id='content-body'>";		
echo"<table border='0'  align='center' valign='top' width=100% class='tablecontent'>
	<col width=65%>";
		
	echo"   <tr bgcolor='#F7F7F7'><td valign='top'  align='left'>";	  
echo"<table border='0' style='table-layout:fixed' align='left' valign='top' width='700px'>
      <col width=130>";
	  
echo"<tr bgcolor='#F7F7F7' height='25'>
     <td valign='center' align='left' ><span class='style1'>".$CreationDate1."&nbsp;<span class='style26'>*</span></span>";
	echo"</td>";
			 
	if($mainmode!=''){
		$today = date('d-m-Y');
		$Currency_CreationDate = $today;
	}			
				
	echo"<td ><input type='text' name='Currency_CreationDate' id='Currency_CreationDate' value='$Currency_CreationDate' style='font-size:12px; width:100px; height:18px;' readonly /> ";
			
	if ($mainmode!=''){
	    $Currency_CreationDate = "disabled";
	}
echo" </td></tr>";

echo"<tr bgcolor='#F7F7F7'  height='25'><td valign='center' align='left' ><span class='style1'>".$Code1."&nbsp;<span class='style26'>*</span></span></td>";
echo"<td  height='25'>";
if (empty($Currency_code))
	echo"<input type='text' name='Currency_code'  value='".htmlspecialchars($Currency_code, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;'  $status maxlength='6' />";
else
	echo " <span class='style1'><b>$Currency_code</b></span><input type='hidden' name='Currency_code'  value='".htmlspecialchars($Currency_code, ENT_QUOTES)."'  />";

echo"<tr bgcolor='#F7F7F7'  height='25'><td valign='center' align='left' ><span class='style1'>".$Name1."&nbsp;<span class='style26'>*</span></span></td>";
echo"<td ><input type='text' name='Currency_name' value='".htmlspecialchars($Currency_name, ENT_QUOTES)."' style='font-size:12px; width:408px; height:18px;'  $status maxlength='30' /></td></tr>";

	
$NatureMode = '';
if (empty($Currency_nature)) $Currency_nature = 0;
if($Currency_nature== 1) $NatureMode = '  checked  ';


$query2= "select BASE2 from setup";
$result2=mysql_query($query2, $connection);
$row2=mysql_fetch_array($result2);
extract($row2);


echo"<tr bgcolor='#F7F7F7'  height='25'><td valign='center' align='left' ><span class='style1'>".$MultiplierOf." $BASE2</span></td>";
echo"	  <td valign='center' align='left' ><span class='style1'><input type=checkbox name='Nature' onclick='CheckNature();' $NatureMode $dis> ".$Currency1." < $BASE2 </span>
		  <input type='hidden' name='Currency_nature' value='$Currency_nature' /></td></tr> ";
	
echo"<tr height='20'><td>&nbsp;</td></tr>";

echo"<tr><td valign='top' colspan=2>";
echo "<table style='position:relative; width:1050px; left:15px;' border=0>
		<col width=20>
		<col width=20>
		<col width=140>
		<col width=160>
		<col width=200>
		";
				
echo "<tr bgcolor='#D0D0D0' height='25px'><td>&nbsp;</td>
		<td>&nbsp;</td><td align='center'><span class='style27'>".$Date1."&nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>".$Rate1."&nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>".$Parity1."&nbsp;<span class='style26'>*</span></span></td>
		<td>&nbsp;</td>
</tr>";
							
echo "<tr bgcolor='#F7F7F7'><td>&nbsp</td><td>&nbsp;<input type='hidden' name ='Curdt_increment' value='$Curdt_increment'></td>";

			if($mainmode!=''){
				if (empty($Curdt_date)){
					$today = date('d-m-Y');
					$Curdt_date = $today;
				}
			}
			 
			 
echo" <td align='center'><input type='text' name='Curdt_date' id='Curdt_date' value='$Curdt_date' size='10'  readonly />";
		
		 if($mainmode!='view' && $mainmode!='')
print<<< HERE
&nbsp;<A HREF="#" onClick="displayCalendar(document.Currency.Curdt_date,'dd-mm-yyyy',this); return false;" NAME="anchor1" ID="anchor1"><image src='./img/cal.gif' border=0 align=center></image></A></td>
HERE;

echo " <td align='center'><input type='text' name='Curdt_rate'  value='".htmlspecialchars($Curdt_rate, ENT_QUOTES)."' $status maxlength='10' size='10'>";
echo"<td align='center'><input type='text' name='Curdt_parity'  value='".htmlspecialchars($Curdt_parity, ENT_QUOTES)."' $status maxlength='10' size='10'></td>";
			
echo " 	<td align='center'><button type='button' id='submitrecord' name='submitrecord' onclick='SubmitRecord(2); return false;' title='Save Changes' $Insmode><span><span>Submit</span></span></button>&nbsp;&nbsp;";
echo"<button type='button' id='clearbutton' name='clearbutton' onclick='cleardetail(); return false;' title='Clear Detail' $Insmode><span><span>Clear</span></span></button>&nbsp;&nbsp;";

echo" <button type='button' id='btnPrint' name='btnPrintdt' onclick='Printdt(); return false;' title='Print' ><span><span>Print</span></span></button>";

echo "</tr>";	

$querydt = " select Curdt_id, Currency_code, Date_Format(Curdt_date, '%d/%m/%Y'), Curdt_rate, Curdt_parity".
		   " from Curdt ".
		   " where Currency_id='".$Currency_Id."'";

//echo $querydt;
$resultdt = mysql_query($querydt, $connection);
while($rowsdt=mysql_fetch_array($resultdt)){
			    
	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";	
						
				
	echo "<tr ".$Color." >";
	echo "	<td align='center' valign='center'><span class='style15'><img src='img/button_edit.png'  onMouseOver=\"style.cursor='hand'\" onclick=UpdateDetail('".$rowsdt[0]."') title='Edit Record'  ></span></td>";
	echo "	<td align='center' valign='center'><span class='style15'><img src='img/c_delete.png'  onMouseOver=\"style.cursor='hand'\" onclick=DeleteDetail('".$rowsdt[0]."') title='Delete Record'  ></span></td>";
	echo "	<td align='left'><span class='style15'>".$rowsdt[2]."</span></td>";
	echo "	<td align='right'><span class='style15'>".$rowsdt[3]."</span></td>";
	echo "	<td align='right'><span class='style15'>".$rowsdt[4]."</span></td>";
	echo "	<td align='left'><span class='style15'>&nbsp;</span></td>";
	echo "</tr>";
						
}					
							
echo"</table></td></tr>";
	// richard
echo"</table></td></tr><tr><td  valign='top'>";

echo"<table style='width:1050px;' border='0' cellspacing=0><col width=220>";				
echo"<tr><td id='' style='width:1050px;height:15px;' colspan='4'></td>
	</tr>
	 <tr><td  valign='top' colspan=3 id='' style='width:1050px;'>";

echo"<table style='width:1050px; position:relative; left:15px;' border='0' cellspacing=0>
	<col width=50>
	<col width=500>
	<col width=500>

	 <tr height='30px' style='background-color:darkgray;'>
	 <td>&nbsp;</td>
	 <td align='center' ><span class='style1'><b>".$Code1."</b></td>
	 <td align='center' ><span class='style1'><b>".$Name1."</b></td></tr>";
	
	 
	echo"<tr><td  colspan=4 id=''><div style='overflow-y:scroll;height:250px;width:1060px;border:0px solid #000000;'>
	<table  border='0' width='1050px'>
	<col width=50>
	<col width=500>
	<col width=500>";
	
	$querysearch="select currency_id,currency_code,currency_name from currency ";
	$querysearch=$querysearch." where (currency_code like"."('%".$txtKeyword."%') or currency_name like"."('%".$txtKeyword."%')) ";

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
	$totalrows = mysql_num_rows($resultsearch);
	
	if ($startrange=='')
		$startrange = 0;
	if ($perpage=='')
		$perpage = 20;
	
	$querysearch = $querysearch." limit ".$startrange.",".$perpage;
	

	$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());	
	while($rows=mysql_fetch_array($resultsearch)){
		$ct+=1;
		$stylefont='style15';
		if($ct%2==0)
			$Color="style='background-color:".$grid_color1."'";
		else			
			$Color="style='background-color:".$grid_color2."'";	
				
		if($mainmode=='edit' && $Currency_Id==$rows[0]){
			
			$Color="style='background-color:#1e87a5'";
			$stylefont='style28';
	}	
		
	echo'<tr '.$Color.' height="20px" >';
	
	if($FA_CurrencyDel==1)	
print<<<HERE

<td align=center ><img border='0' src='img/c_delete.png' width='9' height='10' title='Delete Detail' onmouseover="this.style.cursor='pointer'" OnClick="confirm_delete('$rows[0]')" $DelMode></td>

HERE;
else print<<<HERE
<td align=center >&nbsp;</td>
HERE;

echo"";

	echo"<td style='cursor:pointer;' ";if($FA_CurrencyMod==1) echo " onclick=SetCur('$rows[0]');";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
		<td style='cursor:pointer;' ";if($FA_CurrencyMod==1) echo " onclick=SetCur('$rows[0]');";echo"><font face='Arial' size='2' color='#186194'><span class='$stylefont'>$rows[2]&nbsp;</span></font></td>";
	echo"";
	


	echo"	</tr>";
}		
	
echo"</table></div></td></tr>";

echo"<tr><td >&nbsp;</td><td align='center'>";
		
		$diff= $startrange - $perpage;
		
		if (($diff) >= 0 ){
			$prvstartrange = $startrange - $perpage;
			echo"<img src='img/arrowleft.jpg' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center'>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.jpg' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextPage('".$startrange."','".$perpage."')>";
		} else
			echo "&nbsp;";
			
		echo"</td></tr>";

echo"</table></td></tr><tr>
					<td id='' style='width:1050px;height:20px;' colspan='4'></td>
				</tr></table></td></tr></table></td></tr>";		

/*
echo"<tr><td colspan='2'><table border=0 align=left width=100%> <tr bgcolor=#D8D8D8 height='35'>";
echo"<tr bgcolor=#D8D8D8 height='35'> ";				
echo"	<td align=center><input type='button'  value='Add Currency'";  	
			
if($mainmode=='insert' or $mainmode=='edit' or $mainmode=='view')
	echo "disabled ";
			
	echo"onclick='AddCurrency()' $style title='Add Currency' $InsMode >&nbsp;";
				
echo"<input type='button' id='btnClear' name='BtnClear' value='Clear Page'   onclick='ClearPage();' $style title='Clear Page'>&nbsp;";
				
	if($mainmode=='view'){
		echo"           <input type='button' name='btnEdit' id='btnEdit' value='Edit' ";//Edit
				
				
		echo" onclick='editmode();' $style	title='Edit Currency' />";
	}
else	{
	echo"<input type='button' name='btnPost' id='btnPost' value='Save' ";//post
		if ($mainmode=='')
			echo " disabled ";
				
				echo" onclick='SubmitRecord(1);' $style	title='Save Changes' />";}



				
echo" 			&nbsp;<input name='btnPrint' type='button' id='btnPrint' value='Print' onclick='PrintPreview();' $style title='Print' ";
				if ($mainmode=='edit' or $mainmode=='insert' or $mainmode=='view') echo " disabled ";
						echo" onclick='PrintPreview();' $style	title='Print' />";

						echo"</td>";
echo"  </tr></table> ";*/
	  
 echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	

print <<< HERE
      
	  </table>
HERE;


print <<<HERE
</form>
</body>

HERE;

?>