<?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");



$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2 from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
extract($rowsetup);
}

$query_login="select login_belongstogrp,ifNull(FI_SalesmenDel,0),ifNull(FI_SalesmenMod,0) from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlogin=mysql_query($query_login,$connection) or die(mysql_error());

$row_login=mysql_fetch_row($resultlogin);
$belongstogroup=$row_login[0];
$FI_Salesman_Del=$row_login[1];
$FI_Salesman_Mod=$row_login[2];


//// Delete   Edit 
$DeleteMode=' ';
if($FI_Salesman_Del==0)
$DeleteMode ='disabled';

$EditMode=' ';
if($FI_Salesman_Mod==0)
$EditMode = ' disabled ';






print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="default.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Manifest</title>
<script type="text/javascript" language="javascript">

function confirmall(){
	if(document.getElementById('chkedRec').value <= 0){
		alert('No Record was selected!');
		return 0;
	} else {
	if (confirm ( "Are you sure you want to confirm all checked Records " + "?")) {
		document.search.action='Form_manifestconfirm_Actions.php?mode=confirmallmanifests';
		document.search.submit();
					
	}
	}
	
}
function confirm_delete(Code,confirmation) {
	
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
				window.event.returnValue = true;
		if (confirmation=='confirmed'){
			alert(' make sure that this manifest is confirmed if you want to delete it');
		}
		
		document.search.action='Form_Manifests_Action.php?mode=delete&Manifest_Auto='+Code;
		document.search.submit();
		
	}
		
}
				
				

function clearform()
{var vessel_auto=document.search.vessel_auto.value;
  document.search.PRef.value='';
  document.search.PortRef.value='';
  document.search.LocalRef.value='';
  document.search.BLRef.value='';
  document.getElementById('chkedRec').value = 0;
  document.search.action='Form_ManifestsSearch.php';
  document.search.submit();

}

function LoadForm() 
{
	x=document.search;
	x.PRef.focus();
	

}

function SetNextPage(startrange,perpage){
	var PRef = document.search.PRef.value;
	var PortRef = document.search.PortRef.value;
	var LocalRef = document.search.LocalRef.value;
	var BLRef = document.search.BLRef.value;
	document.getElementById('chkedRec').value = 0;
	document.search.action='Form_ManifestsSearch.php?PRef='+PRef+'&PortRef='+PortRef+'&LocalRef='+LocalRef+'&BLRef='+BLRef+'&startrange='+startrange+'&perpage='+perpage;
	document.search.submit();
}

function SetPrvPage(startrange,perpage){
	var PRef = document.search.PRef.value;
	var PortRef = document.search.PortRef.value;
	var LocalRef = document.search.LocalRef.value;
	var BLRef = document.search.BLRef.value;
	document.getElementById('chkedRec').value = 0;
	document.search.action='Form_ManifestsSearch.php?PRef='+PRef+'&PortRef='+PortRef+'&LocalRef='+LocalRef+'&BLRef='+BLRef+'&startrange='+startrange+'&perpage='+perpage;
	document.search.submit();
}

function set_limit(){
	var vessel_auto=document.search.vessel_auto.value;
	document.getElementById('chkedRec').value = 0;
	perpage=document.search.perpage.value;
	document.search.action='Form_ManifestsSearch.php?perpage='+perpage;
	document.search.submit();
}






function Choosemanifest(manifest_auto,confirmation){

if (confirmation=='confirmed'){alert('Make sure that this manifest is confirmed if you want to edit it');
			//	return false;
				}

opener.document.Manifest.Manifest_Auto.value=manifest_auto;
opener.document.Manifest.mode.value="editmode";
opener.document.Manifest.searchpol.value = document.getElementById('PortRef').value;
opener.document.Manifest.searchlagent.value = document.getElementById('LocalRef').value;
opener.document.Manifest.searchtbl.value = document.getElementById('BLRef').value;
opener.document.Manifest.action='Form_Manifest.php?Manifest_Auto='+manifest_auto;
opener.document.Manifest.submit();
//opener.document.Manifest.submit();
self.close();
}
function printmanifest(Manifest_Auto,port_carrier){
	var withprice=document.search.withorwithout.checked;
	if (withprice){withprice=1;}
	else withprice=0;
	var preprinted=document.search.preprinted.checked;
	if (preprinted){preprinted=1;}
	else preprinted=0;
	
		/* var str = '';
	if(port_carrier=='TARROS'){
		if(preprinted==1)
			str = 'Form_ManifestTarrosPreview1.php?Manifest_Auto='+Manifest_Auto+'&withprice='+withprice;
		else
		str = 'Form_ManifestTarrosPreview.php?Manifest_Auto='+Manifest_Auto+'&withprice='+withprice;}
	else{ */
		if(preprinted==1)
		str = 'Form_ManifestMedlogPreview1.php?Manifest_Auto='+Manifest_Auto+'&withprice='+withprice;
		else str = 'Form_ManifestMedlogPreview.php?Manifest_Auto='+Manifest_Auto+'&withprice='+withprice;
	//}
	window.open(str);
	
}

function printinvoice(manid){
	str = 'Form_DeliveryPreview.php?manid='+manid+'&printlogo=0';
		window.open(str);
}


function printjournal(manid){
	str = 'Form_JournalPreview.php?manid='+manid+'&belongstogroup=0';
		window.open(str);
	
}
function ConfirmManifest(Manifest_Auto){
	
	document.search.action='Form_Manifests_action.php?Manifest_Auto='+Manifest_Auto+'&confirm_mode=confirm';
	document.search.submit();

}
function printso(man_id){
	str = 'Form_ManifesSorderPreview.php?man_id='+man_id+'&belongstogroup=0';
	window.open(str);	
}

function setChk(auto){
	var val = 'chkid'+auto;
	var chkedRec = parseInt(document.getElementById('chkedRec').value);
	if(document.getElementById(val).checked){
		document.getElementById(val).value=1;
		document.getElementById('chkedRec').value=chkedRec+1;
	}
	else {
		document.getElementById(val).value=0;
		document.getElementById('chkedRec').value=chkedRec-1;
	}
}
function refreshSearch(){
	 document.getElementById('chkedRec').value = 0;
	document.search.submit();
}

function printRep(){
	var x = document.search;
	var rep;
	var str = '';
	
	var withprice = 0;
	if(document.search.withorwithout.checked)
		withprice = 1;
	
	var preprinted = 0;
	if(document.search.preprinted.checked)
		preprinted = 1;
	
	rep = document.querySelector('input[name = "pb"]:checked').value;
	
	var cnter = 0;
	
	if(rep == 'manifest'){
		if(preprinted==1)
			str = 'Form_ManifestMedlogPreview1.php?checkprint=1&withprice='+withprice;
		else str = 'Form_ManifestMedlogPreview.php?checkprint=1&withprice='+withprice;
	
	} else if(rep == 'invoice'){
		str = 'Form_DeliveryPreview.php?checkprint=1&printlogo=0';
	} else if(rep == 'jv'){
		str = 'Form_JournalPreview.php?checkprint=1&belongstogroup=0';
	} else if (rep == 'so'){
		str = 'Form_ManifesSorderPreview.php?checkprint=1';
	}	
	
	if(str != ''){
		x.target= '_blank';
		x.action = str;
		x.submit();
		x.target= '';
		x.action = '';
	}
}

function setAllChk(tot){
	
	if(document.getElementById('chkall').checked){
		for(i=1; i<=tot ;i++) {
			var val = 'chkid'+i;
			document.getElementById(val).value=1;
			document.getElementById(val).checked=true;
			document.getElementById('chkedRec').value= parseInt(document.getElementById('chkedRec').value) +1;
		}
	} else {
		for(i=1;i<=tot;i++){
			var val = 'chkid'+i;
			document.getElementById(val).value=0;
			document.getElementById(val).checked=false;
			document.getElementById('chkedRec').value= parseInt(document.getElementById('chkedRec').value)-1;
		}
	}
}

function kd(e)
{
	x=document.search;
    var intKey = (window.Event) ? e.which : e.keyCode;
	
    if (intKey == 13) { //enter key
        x.buttonSearch.click();
		return false;
    }
    return true;
}

</script>

<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;
}
.style11 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; }
.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: #000000 ;font-size: 10px;}

</style>

</head>
<body onLoad='LoadForm();'>
<form name='search' id='search' method='post' action=''>
<input type='hidden' name=vessel_auto value='$vessel_auto'>
HERE;
//$perpage = 100;
if ($perpage=='')
	$perpage = 100;
echo"<table border='0' style='table-layout:fixed'>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=20>
	  <col width=25>
	  <col width=25>
	  <col width=25>
	  <col width=25>
	  <col width=25>
	  
	  <col width=50>
	  <col width=150>
	  <col width=350>
	  <col width=350>
	  <col width=100>
	 
		     
	  <tr bgcolor='#DDDDDD'>
	    <td align='center' colspan='18'><span class='style16'>List of Manifest</span></td></tr>
	  <tr bgcolor='#DDDDDD' height=30px>
	    <td align='left' colspan='6'><span class='style11'>Search by </span>";
	
	echo "</td>
		<td align='left' colspan=12><span class='style11'><input type='text' name='PRef' id='PRef' value='$PRef' size='15'  onkeydown=\"return kd(event);\"/>
			&nbsp; Port of Loading &nbsp; <input type='text' name='PortRef' id='PortRef' value='$PortRef' size='15' title='Port of Loading' onkeydown=\"return kd(event);\" />
			&nbsp; Local Agent &nbsp; <input type='text' name='LocalRef' id='LocalRef' value='$LocalRef' size='15' title = 'Local Agent' onkeydown=\"return kd(event);\" />
			&nbsp; Type of BL &nbsp; <input type='text' name='BLRef' id='BLRef' value='$BLRef' size='15' title = 'Type of BL' onkeydown=\"return kd(event);\" />
			<input type='hidden' name='PMode' id='PMode' value='$PMode' size='15' maxlength='30'/></span>
		    <input type='button' name='buttonSearch' value='Find' onclick=\"refreshSearch();\" style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
			<input type='button' name='btnCancel' value='Cancel' onclick='clearform();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/></td>
	</tr>";	
	echo "  <tr bgcolor='#FFFFF' height=30px>	
		<td colspan=8></td><td align='left' colspan=10 valign='center'><span class='style25'>Result per page </span><span class='style11'>
		<select name='perpage' id='perpage' value='$perpage' onchange=set_limit();>";
              


        if ($perpage==20)
			$s20 = 'selected';
		else if ($perpage==50)
			$s30 = 'selected';
		else if ($perpage==100)
			$s40 = 'selected';
		else if ($perpage==1000)
			$s50 = 'selected';

			
				
        echo'<option '.$s20.' value="20">20</option>
			 <option '.$s30.' value="50">50</option>
			 <option '.$s40.' value="100">100</option>
			 <option '.$s50.' value="1000">1000</option>
			 </select></span>';
			 echo "
			 <input type='checkbox' name='withorwithout'><span class='style11'>with price</span>";
			 	 echo "
			 <input type='checkbox' name='preprinted'><span class='style11'>preprinted</span>";
		echo "	 &nbsp;&nbsp;&nbsp;&nbsp;<input type='button' name='confirmallmanifest' value='Confirm Checked' onclick='confirmall();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>";
		echo " &nbsp;&nbsp;&nbsp;&nbsp; <span class='style11'>Show </span>&nbsp;&nbsp; <select name='manifeststatus' onchange=\"refreshSearch();\">";
		echo "<option value='' ".($manifeststatus == ''?'selected':'').">All</option>";
		echo "<option value='1' ".($manifeststatus == '1'?'selected':'').">Confirmed</option>";
		echo "<option value='0' ".($manifeststatus == '0'?'selected':'').">Unconfirmed</option>";
		echo "</select></td>";
			 
echo "<tr bgcolor='#ADADAD' height='30px'>
		<td height='15' align='left' colspan='18'><span class='style11'>
		<input type='radio' name='pb' value='manifest' checked><font size='1' color='#000000' face='Verdana'> Manifest Detail &nbsp;&nbsp;
		<input type='radio' name='pb' value='invoice' ><font size='1' color='#000000' face='Verdana'> Invoice &nbsp;&nbsp;
		<input type='radio' name='pb' value='jv' ><font size='1' color='#000000' face='Verdana'> Journal &nbsp;&nbsp;
		<input type='radio' name='pb' value='so' ><font size='1' color='#000000' face='Verdana'> Sales Order &nbsp;&nbsp;
		</span><input type='button' name='btnPrint' value='Print' onclick='printRep();'style=' background-color:#4069A7; color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;'/>
		</td>
	  </tr>	";	
if($chkall == '') $chkall = 0;	  
if($PRef == '') $PRef = "NULL";
else $PRef = "'".$PRef."'";

$querysearch = " select agent_id,BOL_identification,manifest_auto,consignee1,shipper1,Portofloading,voyage_number,received_date,client_code,ifnull(manifest_confirm,0),
				delivery_id,manifest_auto,voyage_year
				from manifest ";

$querysearch=$querysearch." WHERE  ( (manifest_auto like Concat(ifNull($PRef, manifest_auto),'%')) or (Voyage_year like Concat(ifNull($PRef, Voyage_year),'%')) or
									(voyage_number like Concat(ifNull($PRef, voyage_number),'%')) or (BOL_identification like Concat(ifNull($PRef, BOL_identification),'%')) or
									(BOL_type like Concat(ifNull($PRef, BOL_type),'%')) or (Portofloading like Concat(ifNull($PRef, Portofloading),'%')) or
									(PortofDischarge like Concat(ifNull($PRef, PortofDischarge),'%'))
									) ";

if ($PortRef != '') 	$querysearch=$querysearch." and Portofloading like '%".$PortRef."%' ";
if ($LocalRef != '') 	$querysearch=$querysearch." and localagent_code like '%".$LocalRef."%' ";
if ($BLRef != '') 	$querysearch=$querysearch." and BOL_type like '%".$BLRef."%' ";

if($manifeststatus != '')
	$querysearch=$querysearch." and ifnull(manifest_confirm,0) = '$manifeststatus' ";
$querysearch=$querysearch." order by manifest_auto desc";
//echo $querysearch;
$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());
$totalrows = mysql_num_rows($resultsearch);
echo" </tr>
	  <tr bgcolor='#DDDDDD'>
		<td height='15' align='center' colspan='18'><font size='1' color='#FFFFF' face='Verdana'><b>".$message."</b></font></td>
	  </tr>	
	  <tr bgcolor='ADADAD'>
		<td  height='25' align='center'><span class='style25'><input type='checkbox' name='chkall' id='chkall' value='$chkall' onclick=\"setAllChk('$totalrows');\"></span></td>
		<td  height='25' align='center'><span class='style25'>&nbsp;</span></td>
		<td  height='25' align='center'><span class='style25'><font size='1' color='#000000' face='Verdana'>Inv</span></td>
		<td  height='25' align='center'><span class='style25'><font size='1' color='#000000' face='Verdana'>Jv</span></td>
		<td  height='25' align='center'><span class='style25'><font size='1' color='#000000' face='Verdana'>So</span></td>
		<td  height='25' align='center'><span class='style25'>&nbsp;</span></td>
		<td  height='25' align='center'><span class='style25'>&nbsp;</span></td>
		<td  height='25' align='center'><span class='style25'>&nbsp;</span></td>
		<td  height='25' align='left'><span class='style25'><font size='1' color='#000000' face='Verdana'>JV Ref</span></td>
		<td  height='25' align='left'><span class='style25'><font size='1' color='#000000' face='Verdana'>Inv Ref </span></td>
		<td  height='25' align='left'><span class='style25'><font size='1' color='#000000' face='Verdana'>Manifest id </span></td>
		<td  height='25' align='left'><span class='style25'><font size='1' color='#000000' face='Verdana'>voyage year </span></td>
		<td  height='25' align='center' ><span class='style25'><font size='1' color='#000000' face='Verdana'>Voyage Number </span></td>
		<td  height='25' align='left'><span class='style25'><font size='1' color='#000000' face='Verdana'>Agent Id </span></td>
		<td  height='25' align='center' ><span class='style25'><font size='1' color='#000000' face='Verdana'>Bill Of lading </span></td>
		<td  height='25' align='center' ><span class='style25'><font size='1' color='#000000' face='Verdana'>Consignee </span></td>
		<td  height='25' align='center' ><span class='style25'><font size='1' color='#000000' face='Verdana'>Shipper </span></td>
		
		<td  height='25' align='center' ><span class='style25'><font size='1' color='#000000' face='Verdana'>Status </span></td>
		
		
		
	  </tr>";

	
if ($startrange=='')
	$startrange = 0;
if ($perpage=='')
	$perpage = 100;
		
$querysearch = $querysearch." limit ".$startrange.",".$perpage;
echo"<input type='hidden' name='startranger' id='startranger' value='$startrange'>";

$resultsearch=mysql_query($querysearch,$connection) or die(mysql_error());		


while($rows=mysql_fetch_array($resultsearch)){
	
	$port_carrier='';
	$jv='';
	$reference='';
	
	$port="select port_carrier from port where port.port_name='$rows[5]'";
	$result=mysql_query($port,$connection) or die(mysql_error());
	$row=mysql_fetch_row($result);
	$port_carrier=$row[0];

	extract($rows);
	
	$delivery="select Journal_refgovernment,delivery_reference,delivery_id 
				from deliveries 
				left join journal on deliveries.journal_id=journal.journal_id where manifest_auto='$manifest_auto'";
//echo $delivery;
	$cc=0;
	$querydeliv=mysql_query($delivery,$connection) or die(mysql_error());		
	while($ref=mysql_fetch_row($querydeliv)){
		if ($cc == 0) {
			$jv = $ref[0];
			$reference = $ref[1];
		} else {
			$jv .= "<br>".$ref[0];
			$reference .= "<br>".$ref[1];
		}
		$cc++;
	}
	
	$ct+=1;

	if($ct%2==0)
		$Color="style='background-color:".$grid_color1."'";
	else			
		$Color="style='background-color:".$grid_color2."'";	
			

	echo'<tr '.$Color.'>';




print<<<HERE
	


HERE;
	if ($rows[9]==1)$confirm="confirmed";
else if ($rows[9]==0)$confirm="not confirmed";
	
	$id=ereg_replace(" ","",$rows[0]);	
	$identification=ereg_replace(" ","",$rows[1]);	
	$auto=ereg_replace(" ","",$rows[2]);	
	$chkval = 'chkval'.$auto;
	if($$chkval == '') $$chkval = 0;
	$chkid = 'chkid'.$ct;
echo "<td><input type='checkbox' name='$chkval' id='$chkid' value='".$$chkval."' onclick=\"setChk('$ct');\"></td>";	
	
print<<<HERE
<td align=center ><img border='0' src='img/mag.jpg' width='9' height='10' title='print Detail' onmouseover=this.style.cursor='pointer' OnClick=printmanifest('$rows[2]','$port_carrier'); ></td>
<td align=center ><img border='0' src='img/mag.jpg' width='9' height='10' title='print Invoice' onmouseover=this.style.cursor='pointer' OnClick=printinvoice('$manifest_auto'); ></td>
<td align=center ><img border='0' src='img/mag.jpg' width='9' height='10' title='print Journal' onmouseover=this.style.cursor='pointer' OnClick=printjournal('$manifest_auto'); ></td>
<td align=center ><img border='0' src='img/mag.jpg' width='9' height='10' title='print Sorder' onmouseover=this.style.cursor='pointer' OnClick=printso('$rows[2]'); ></td>
<td align=center width='3%'><img border='0' src='img/button_edit.png' width='12' height='13' title='Edit Detail' onmouseover="this.style.cursor='pointer'" onclick="Choosemanifest('$rows[2]','$confirm')"; $EditMode ></td>
HERE;



	//if (($rows[7]!='')&&($rows[8]!=''))	
		print<<<HERE
	<td align="center"><span class="style5"><img src="img/confirmorder.png" onMouseOver="style.cursor=\'hand\'" onclick="ConfirmManifest('$rows[2]');" title="Confirm Manifest" style="width: 15px; height: 15px; "  ></span></td>

HERE;
//else echo "<td></td>";

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

	</td>
	<td><font face='Arial' size='2' color='#186194'><span class='style15'>$jv</span></td>
	<td><font face='Arial' size='2' color='#186194'><span class='style15'>$reference</span></td>
		<td><font face='Arial' size='2' color='#186194'><span class='style15'>$rows[11]</span></td>
			<td><font face='Arial' size='2' color='#186194'><span class='style15'>$rows[12]</span></td>
			<td ><font face='Arial' size='2' color='#186194'><span class='style15'>$rows[6]&nbsp;</span></font></td>
</font></td>
<td><font face='Arial' size='2' color='#186194'>

HERE;


print<<<HERE
<span class="style15">$id&nbsp;</span>

HERE;


echo"</font></td><td ><font face='Arial' size='2' color='#186194'><span class='style15'>$identification&nbsp;</span></font></td>";
echo"</font></td>";
echo "<td ><font face='Arial' size='2' color='#186194'><span class='style15'>$rows[3]&nbsp;</span></font></td>";
echo"</font></td>";
echo "<td ><font face='Arial' size='2' color='#186194'><span class='style15'>$rows[4]&nbsp;</span></font></td>";
echo"</font></td>";

echo "<td align='center' ><font face='Arial' size='2' color='#186194'><span class='style15'>$confirm</span></font></td>";
echo"</font></td>";

echo"</tr>";


}
			
if($chkedRec == '') $chkedRec = 0;		
echo"   <tr><td colspan='18'><input type='hidden' name='chkedRec' id='chkedRec' value='$chkedRec'>&nbsp;</td></tr>
		<tr><td colspan=18><table width='100%' border=0><tr><td width='260'>&nbsp;</td><td width='150' 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 width='150' 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><td width='170'>&nbsp;</td></tr>";
		echo"<table>";

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


          

		  

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

HERE;

?>