<?php

session_start();
if($HTTP_SESSION_VARS['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($HTTP_SESSION_VARS['dbName'],$connection) or die("Could not find DB");


$querylog="SELECT FI_Area 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");

//User Access
$querylog=" select ifNull(FI_AreaApp,0) As FI_AreaApp, ifNull(FI_AreaDel,0) As FI_AreaDel, ".
          " ifNull(FI_AreaMod,0) As FI_AreaMod from ".$HTTP_SESSION_VARS['dbLabel'].".login where user_account='".$HTTP_SESSION_VARS['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);
}


$query="select Module_Transportation as Module_Transportation from module";
	$result=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result)){
	extract($rows);
}
	
//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);
}

//Access mainmode On Insert/Edit/Delete
$Insmode = '';
if ($FI_AreaApp == 0)
	$Insmode = ' disabled ';




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

	$query_edit="select Increment, Area_Code, Area_Name, date_format(Area_CreationDate,'%d-%m-%Y')
				 from Area where Increment='".$Increment."'";

	 
	//echo $query_edit;
	$resultedit = mysql_query($query_edit, $connection);
	while($row=mysql_fetch_array($resultedit)){

		$Increment = $row[0];
		$Area_Code=$row[1];
		$Area_Name=$row[2];
		$Area_CreationDate=$row[3];
		$mainmode='edit';

	}
}

if($AreaTransp_ID!='' && $checkcode!=1){

	$query="select Transfer_Amount,Currency,Area_Code,CarType_code,Area_Tariff,area_tarrifvisit
			from areatransp where AreaTransp_ID='".$AreaTransp_ID."'";
	//echo$query;		
	$result=mysql_query($query, $connection);
	$row=mysql_fetch_row($result);
	
	$amount=$row[0];
	$currency=$row[1];
	$cartype=$row[3];
	$area_tarif=$row[4];
	$area_tarrifvisit=$row[5];
}

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

print <<<HERE
<html >
<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 editmainmode () {

	document.area.action="Form_Area.php?mainmode=edit";
	document.area.submit();
}

function AddArea () {
    ClearForm('All');

	document.area.mainmode.value='insert';
	document.area.action="Form_Area.php";
	document.area.submit();
}


function SubmitRecord(option) {

	var areatarif=document.area.area_tarif.value;
	var areatarif1=areatarif*1/1;
	
	var areatarifvisit=document.area.area_tarrifvisit.value;
	var areatarifvisit1=areatarifvisit*1/1;
	
	if (document.area.Area_Code.value=='' )
			{alert('Unable to save : check missing field Code ');
			document.area.Area_Code.focus();
	}
			
	else  if (document.area.Area_Name.value=='' )
			{alert('Unable to save : check missing field Name ');
			document.area.Area_Name.focus();
	}
	
	else  if (option==2 && document.area.cartype.value=='' )
			{alert('Unable to save : check missing field CarType ');
			document.area.cartype.focus();
	}
	else  if (option==2 && document.area.amount.value=='' )
			{alert('Unable to save : check missing field Amount ');
			document.area.amount.focus();
	}
	else  if (option==2 && document.area.currency.value=='' )
			{alert('Unable to save : check missing field Currency ');
			document.area.currency.focus();
	}
	else  if (option==2 && document.area.area_tarif.value=='' )
			{alert('Unable to save : check missing field Tarif ');
			document.area.area_tarif.focus();
	}
	else  if (option==2 && document.area.area_tarrifvisit.value=='' )
			{alert('Unable to save : check missing field Tarif Visit');
			document.area.area_tarrifvisit.focus();
	}
	
	else if(areatarif1!=areatarif)
		{alert('Unable to save : Tarif should contain Digits');
			document.area.area_tarif.focus();
	}
	else if(areatarifvisit1!=areatarifvisit)
		{alert('Unable to save : Tarif Visit should contain Digits');
			document.area.area_tarifvisit.focus();
	}
	
			
	else {
		if(option==2)
			document.area.actionmode.value='submitareatransp';
			
		document.area.action="Form_Area_Actions.php";
		document.area.submit();
	}
}


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

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.area;
	
	x.Increment.value=''
	x.Area_CreationDate.value='';
	x.Area_Code.value='';
	x.Area_Name.value='';
	
	
}

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

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

}

function SetArea(AreaId){
	
	document.area.Increment.value=AreaId;
	document.area.message.value='';
	document.area.actionmode.value='';
	//cleardetail();
	document.area.mainmode.value='editmode';
	document.area.submit();
}

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

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

function SearchForSup(){
	x = document.area;
	document.area.action='Form_Area.php?startrange=0';
	document.area.submit();
}

function ClearKeyword(){
	x = document.area;
	x.txtKeyword.value='';
	document.area.action='Form_Area.php?startrange=0';
	document.area.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.area.action='Form_Area.php?startrange=0';
	document.area.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.area.mainmode.value='delete';	
		
		document.area.action='Form_Area_Actions.php?IncrementId='+Code;
		document.area.submit();
	}
					
}

function set_limit(){

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


function UpdateDetail(areatransId){
	 x = document.area;
	 x.AreaTransp_ID.value=areatransId;
	x.actionmode.value='refresh';
	x.action='Form_Area.php';
	x.submit();
}

function DeleteDetail(areatransId){

	if (confirm ( "Are you sure you want to Delete record?"))
	{
		
		document.area.AreaTransp_ID.value = areatransId;
		document.area.actionmode.value = 'deleteareatransp';
		
		document.area.action="Form_Area_Actions.php";
		document.area.submit();
	}	
}

function cleardetail(){
	 x = document.area;

	x.AreaTransp_ID.value='';
	
	x.amount.value='';
	x.currency.value='';
	x.cartype.value='';
	x.area_tarif.value='';
	x.area_tarrifvisit.value='';
	x.submit();	
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Area</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="tabs.css">
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">

</head>
<body >
<form name='area' method='post'>

<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='Increment' value='$Increment'>
<input type=hidden name='AreaTransp_ID' value='$AreaTransp_ID'>
<input type=hidden name='Module_Transportation' value='$Module_Transportation'>
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'>AREA</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>Clear Page</span></span></button>";


echo"		<button type='button' id='btnPost' name='btnPost' onclick='SubmitRecord(1); return false;' title='Save Changes' $Insmode><span><span>Save</span></span></button>";

echo"	
<button  type='button'  value='Print' onclick='PrintPreview();return false;' title='print' ";


echo"><span><span>Print</span></span></button>";
				
echo"   </td><td align='left' width='250px'> 
	<input type='text' name='txtKeyword' value='$txtKeyword' style='width:105px;' onKeyPress='return submitenter(this,event)'>
	<button type='button' id='btnSearch' name='btnSearch' onclick='SearchForSup(); return false;' title='Search Area'><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>";
     echo"</td><td align='left'><span class='style1'><b>Results/page</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></tr>";
echo"	</table>";
echo"</td></tr>";


echo"<tr><td id='content-body'>";				
echo"<table border='0'  align='center' valign='top'  class='tablecontent' >
	<col width=64%>";

echo"   <tr bgcolor='#F7F7F7'  ><td valign='top' align='left'>";	 

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

echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>Code&nbsp;<span class='style26'>*</span></span>";
echo"<td><input type='text' name='Area_Code'  value='".htmlspecialchars($Area_Code, ENT_QUOTES)."' style='font-size:12px; width:100px; height:18px;'  $status maxlength='15' /></td></tr>";
echo"<tr bgcolor='#F7F7F7'><td valign='center' align='left' ><span class='style1'>Name&nbsp;<span class='style26'>*</span></span>";
echo"<td><input type='text' name='Area_Name' value='".htmlspecialchars($Area_Name, ENT_QUOTES)."' style='font-size:12px; width:400px; height:18px;'  $status maxlength='50' /></td></tr>";

echo"<tr height=15px><td colspan=3></td></tr>";


if($Module_Transportation==1){
echo"<tr><td colspan=3><table border=0 width=70%>
	<col width=40>
	<col width=40>
	
	<tr bgcolor='#D0D0D0' height='25px'>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	<td align='center'><span class='style27'>CarType &nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>Amount &nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>Currency &nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>Area Tarif &nbsp;<span class='style26'>*</span></span></td>
		<td align='center'><span class='style27'>Area Tarif Visit &nbsp;<span class='style26'>*</span></span></td>
	
	</tr>";

$query="Select cartype_code,cartype_desc from cartype ";
$resultcartype=mysql_query($query,$connection);

echo"<tr><td colspan=2>";

echo"<button type='button' id='submitrecord' name='submitrecord' onclick='SubmitRecord(2); return false;' title='Save Changes' $Insmode><span><span>Submit</span></span></button><Br>";
echo"<button type='button' id='clearbutton' name='submitrecord' onclick='cleardetail(); return false;' title='Clear Detail' ><span><span>Clear</span></span></button>";
   
echo"</td><td align='center'><select  name='cartype'  $dis style='width:70px;'>
				<option value=''></option>";
				while ($car=mysql_fetch_row($resultcartype))
				{
				if ($car[0]==$cartype)
				echo"<option selected value='$car[0]'>$car[0]</option>";
				else
				echo"<option value='$car[0]'>$car[0]</option>";
				}	
				echo"</select></td>
				<td align='center'><input type='text' name='amount'  value='".htmlspecialchars($amount, ENT_QUOTES)."' style='text-align:right;font-size:12px; width:100px; height:18px;'  $status /></td>";
				
	function get_currency($connection){		
		$query_cr = "select currency_code,currency_name from currency";
		//echo$query_cr;
		$result_cr=mysql_query($query_cr, $connection);
		return $result_cr;
	}
	$curr = get_currency($connection);			
				
			echo"<td align='center'><select  name='currency' $dis style='width:70px;'>
				<option value=''></option>";
				while ($cr=mysql_fetch_row($curr))
				{
				if ($cr[0]==$currency)
				echo"<option selected value='$cr[0]'>$cr[0]</option>";
				else
				echo"<option value='$cr[0]'>$cr[0]</option>";
				}	
				echo"</td>
				<td align='center'><input type='text' name='area_tarif'  value='".htmlspecialchars($area_tarif, ENT_QUOTES)."' style='text-align:right;font-size:12px; width:100px; height:18px;'  $status /></td>
				<td align='center'><input type='text' name='area_tarrifvisit'  value='".htmlspecialchars($area_tarrifvisit, ENT_QUOTES)."' style='text-align:right;font-size:12px; width:100px; height:18px;'  $status  maxlength=2/></td></tr>";


	$query="select  AreaTransp_ID,Transfer_Amount,Currency,CarType_code,Area_Tariff,area_tarrifvisit from areatransp
			where area_code='".$Area_Code."'";
	$result = mysql_query($query, $connection);		
	while($rowsdt=mysql_fetch_array($result)){
		$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='center'><span class='style15'>".$rowsdt[3]."</span></td>";
		echo "	<td align='right'><span class='style15'>".$rowsdt[1]."</span></td>";
		echo "	<td align='center'><span class='style15'>".$rowsdt[2]."</span></td>";
		echo "	<td align='right'><span class='style15'>".$rowsdt[4]."</span></td>";
		echo "	<td align='right'><span class='style15'>".$rowsdt[5]."</span></td>";
		
		echo "</tr>";
	}	

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

}
else {
echo"<input type='hidden' name='cartype' value='$cartype'>";
echo"<input type='hidden' name='amount' value='$amount'>";
echo"<input type='hidden' name='currency' value='$currency'>";
echo"<input type='hidden' name='area_tarif' value='$area_tarif'>";
echo"<input type='hidden' name='area_tarrifvisit' value='$area_tarrifvisit'>";
}
 

echo"</table></td></tr><tr><td  valign='top'>";

// Richard
echo"<table style='width:1050px;' border='0' cellspacing=0 cellpadding=0>
	<tr><td id='' style='width:1050px;height:15px;' colspan='3'></td>
	</tr>
	<tr bgcolor='#F7F7F7' > <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 style='background-color:darkgray;' height='30px' >
	 <td>&nbsp;</td>
	 <td align='center' ><span class='style1'><b>Code</b></td>
	 <td align='center' ><span class='style1'><b>Name </b></td> <td> </td>
	 </tr>";
	
	 
	echo"<tr><td  colspan=4 ><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 Increment,area_code,area_name from area ";
	$querysearch=$querysearch." where (area_code like"."('%".$txtKeyword."%') or area_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' && $Increment==$rows[0]){
			
			$Color="style='background-color:#1e87a5'";
			$stylefont='style28';
	}	
		
	echo'<tr '.$Color.' height="20px" >';
	
	if($FI_AreaDel==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"<td style='cursor:pointer;' ";if($FI_AreaMod==1) echo " onclick=SetArea('$rows[0]');";echo"><span class='$stylefont' >$rows[1]&nbsp;</span></font></td>
		<td style='cursor:pointer;' ";if($FI_AreaMod==1) echo " onclick=SetArea('$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.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvPage('".$prvstartrange."','".$perpage."')>";
		}
		else
			echo "&nbsp;";
		
		echo"</td><td  align='center' colspan=2>";
		
		
		if ($startrange <= $totalrows){
			$startrange = $startrange + $perpage;
			if  ($startrange <= $totalrows)
				echo"<img src='img/arrowright.png' 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:380px;height:20px;' colspan='3'></td>
				</tr></table></td></tr>";			
	/*			
echo"<table border=0 align=center width=100%> <tr bgcolor=#D8D8D8 height='35'> ";
echo"	<td align=center><input type='button'  value='Add Area'";  	
			
	if($mainmode=='insert' or $mainmode=='edit')
		echo "disabled ";
	echo"onclick='AddArea()' $style title='Add Area' $Insmode>" ;
	
echo"           <input type='button' id='btnClear' name='BtnClear' value='Clear Page' ";

echo"  onclick='ClearPage();' $style title='Clear Page'>";

				
				
		if($mainmode=='view'){
echo"           <input type='button' name='btnEdit' id='btnEdit' value='Edit' ";//Edit
				
				
				echo" onclick='editmainmode();' $style	title='Edit Area' />";
	}
else	{
echo"           <input type='button' name='btnPost' id='btnPost' value='Save' ";//post
				if ($mainmode=='')
						echo " disabled ";
				
				echo" onclick='SubmitRecord();' $style	title='Save Changes' />";}

/*echo"           <input name='btnSearch' type='button' id='btnSearch' value='Search' onclick='SearchForArea();' $style title='Search Area' ";
                if ($mainmode=='edit' or $mainmode=='insert') 
				    echo " disabled ";
			
		        echo " />";

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

						echo"</td>";
echo"  </tr></table>";*/

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

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



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

HERE;

?>
