<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}
include("config.inc.php");
include("Functions_Sales.php");
include("Forms_DataGrid_Manifest.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");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}



class tabs {
	var $name;
	var $tabs;
	var $active;
	var $current;
function start($name){
		if (empty($this->active)){ $this->active = $name; }
		$this->current = $name;
		ob_start();
	}
	function end(){
		$this->tabs[$this->current] = ob_get_contents();
		ob_end_clean();
	}
	function run(){
	
		if (count($this->tabs) > 0){
			echo "<DIV CLASS='tabs'>\n";
			$jsClear = "";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				$jsClear .= "\tdocument.getElementById('$tabid').className = 'tab_inactive';\n";
				$jsClear .= "\tdocument.getElementById('$contentid').style.display = 'none';\n";
			}
			echo "<script type=\"text/javascript\">\n";
			echo "function tab_".$this->name."(id,fieldname){\n";
			
			
			
			echo "$jsClear";
			echo "\tdocument.getElementById('tab_".$this->name."_'+id).className = 'tab_active';\n";
			echo "\tdocument.getElementById('tabcontent_".$this->name."_'+id).style.display = '';\n";
			echo"	
				//alert(fieldname);
				if(fieldname!='' && fieldname!=undefined)
					
					document.salesman[fieldname].focus();
				";
			echo "}\n";
			echo "</script>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV CLASS='";
				if ($this->active == $tabname){ echo "tab_active"; }else{ echo "tab_inactive"; }
				echo "' ID='$tabid' ";
				echo "onClick=\"tab_".$this->name."('$tabname');\">$tabname</DIV>\n";
			}
			echo "<DIV STYLE='float: center; clear:both;'></DIV>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV ID = '$contentid' CLASS='tab_content' STYLE='display: ";
				if ($this->active == $tabname){ echo "block"; }else{ echo "none"; }
				echo ";'>$tabcontent</DIV>\n";
			}
			echo "</DIV>\n";
			echo "<DIV STYLE='clear: both;'></DIV>\n";
		}}
}

	
$querysetup="select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, 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 Mode On Insert/Edit/Delete
$InsMode = '';

if(!isset($mode))
$mode='';


$columnsarrayhead = array("shipper1", "shipper2", "shipper3",
"shipper4","consignee1","consignee2","consignee3","consignee4","notify1","notify2","notify3","notify4","desc1","desc2","desc3","desc4","desc5",
"desc6","amount1","amount2","amount3","amount4","amount5","amount6","evidence1","evidence2","evidence3","evidence4","evidence5","evidence6",


);
	//array_push($columnsarrayhead, 'txtSalesmanName');
	$columnsarrayhead_list = implode(',', $columnsarrayhead);
	$i=1;
	$KeyDown   = 'onkeydown="return dokeysales(event,this,\''.$columnsarrayhead_list.'\')"';
	//$KeyDown   = 'onkeydown="alert(\' fg \')"';

//echo $mode."is mode"."$mode";
//if($mode=='editmode' or $mode=='view' or $mode=='edit'){
	$voyage_year=$_GET[voyage_year];
	
	$query = "select sum(cntr_tues)
			from manifestdt
			inner join container on Container.cntr_code=manifestdt.container
			where  manifest_manifestauto='$Manifest_Auto';";
	//echo $query;	
	
	
	$resultrank = mysql_query($query, $connection);
	
	if($rows=mysql_fetch_array($resultrank)){
		$nbofteus=$rows[0];
	}
	
if($Manifest_Auto=='') $voyage_type='I';	

if($actionmode1 == 'add' && $Manifest_Auto == ''){
	$queryDef = "select Voyage_year, voyage_number, line_operator, voyage_BOLnumber, voyage_destination, vessel_id, Portofloading, Freight_type, issued, 
				date_format(issued_date,'%d-%m-%Y'), date_format(Manifest_date,'%d-%m-%Y'), date_format(received_date,'%d-%m-%Y'), currency, Agent1_id, Negotiable_BOL, 
				term_of_carriage, linear_meters
				from default_vessel where ifnull(default_value,0) = 1;";
	$resDef = mysql_query($queryDef, $connection);
	$rwDef = mysql_fetch_row($resDef);
	$voyage_year 		= $rwDef[0];	
	$voyage_number 		= $rwDef[1];
	$lineoperator 		= $rwDef[2];

	$voyage_type 		= $rwDef[3];	
	$voyage_destination	= $rwDef[4];
	$vessel_id	 		= $rwDef[5];
	
	$portlading 		= $rwDef[6];	
	$freight_type		= $rwDef[7];
	$issuedat	 		= $rwDef[8];
	
	$issuedon	 		= $rwDef[9];	
	$manifest_date		= $rwDef[10];
	$received_date 		= $rwDef[11];
	
	$currency	 		= $rwDef[12];	
	$carriersign		= $rwDef[13];
	$nonegotiable 		= $rwDef[14];
	$termcarriage 		= $rwDef[15];
	$linearmeter 		= $rwDef[16];
	
	if($freight_type == 'CO' ) $freight = 'COLLECT';
	if($freight_type == 'PR' ) $freight = 'PREPAID';
	
	if($voyage_destination != ''){
		$query="select bl_code, agent1 from agent where code ='$voyage_destination'";
		$result1=mysql_query($query,$connection) or die(mysql_error());
		$rows=mysql_fetch_array($result1);
		$agent_id = $rows[0];
		$agentname = $rows[1];
	}
}	
	
if($Manifest_Auto!=''){
	$query_edit = " select date_format(manifest_date,'%d-%m-%Y'),Voyage_year, voyage_number, voyage_destination, voyage_BOLnumber,	BOL_type, BOL_identification, 
				Shipper1, shipper2, shipper3, shipper4, consignee1, consignee2, consignee3, consignee4,	Notify1, Notify2, Notify3, Notify4, Precarriage, PlaceofReceipt, Portofloading, 
				PortofDischarge, Placeofdelivery, BOL_freight, issued, date_format(date,'%d-%m-%Y'), Negotiable_BOL, term_of_carriage, manifest_id ,BOL_pagenumber,Freight_type,
				tax1_amount,tax2_amount,tax3_amount,tax4_amount,tax5_amount,tax6_amount, tax1_desc, tax2_desc, tax3_desc, tax4_desc, tax5_desc, tax6_desc,
				evidence1, evidence2, evidence3, evidence4, evidence5, evidence6,No_of_tues,currency,Offernumber,freetimedays,linear_meters,
				vessel_id,agent_id,agent1_id,status1,client_code,stamp1_id, stamp2_id, stamp3_id, stamp4_id, stamp5_id, stamp6_id,
				date_format(received_date,'%d-%m-%Y'),source_agentcode,line_operator, localagent_code, agent.agent1, declaredbyforwarder, 
				ifnull(manifest_emptyContainer,0), containeragent_code, agent2.agent1, other_remark
				from manifest 
				left join agent on agent.code = localagent_code
				left join agent as agent2 on agent2.code = containeragent_code ";
 //if ($voyage_year=='')
$query_edit=$query_edit." where manifest_auto='".$Manifest_Auto."'; ";

$queryrank="select Manifest_auto,(@rank := @rank + 1) AS rank from ( SELECT @rank := 0 ) as r, manifest where 1=1 ";

 $resultrank = mysql_query($queryrank, $connection);
	while($rows=mysql_fetch_array($resultrank)){
		//echo $rows[0]."&nbsp;".$rows[1]."<br>";
		
		if ($Manifest_Auto==$rows[0]){
			$rank=$rows[1];
		}
	}
	 $resultedit = mysql_query($query_edit, $connection);
	// echo $query_edit;
	while($row=mysql_fetch_array($resultedit)){

	
	$manifest_date		= $row[0];
	$voyage_year		= $row[1];
	$voyage_number		= $row[2];
	$voyage_destination	= $row[3];
	$bol_number			= $row[4];
	$voyage_type		= $row[5];

	$billoflading		= $row[6];
	$shipper1			= $row[7];
	$shipper2			= $row[8];
	$shipper3			= $row[9];
	$shipper4			= $row[10];
	$consignee1			= $row[11];
	$consignee2			= $row[12];
	$consignee3			= $row[13];
	$consignee4			= $row[14];
	$notify1			= $row[15];
	$notify2			= $row[16];
	$notify3			= $row[17];
	$notify4			= $row[18];
	$precarriage		= $row[19];
	
	$recieptplace		= $row[20];
	$portlading			= $row[21];
	$portdischarge		= $row[22];
	$placedelivery		= $row[23];
	$freight			= $row[24];
	$issuedat			= $row[25];
	$issuedon			= $row[26];
	$nonegotiable		= $row[27];
	$termcarriage		= $row[28];
	$manifest_id		= $row[29];
	$voyage_pagenumber	= $row[30];
	$freight_type		= $row[31];
	$amount1			= $row[32];
	$amount2			= $row[33];
	$amount3			= $row[34];
	$amount4			= $row[35];
	$amount5			= $row[36];
	$amount6			= $row[37];
	$desc1				= $row[38];
	$desc2				= $row[39];
	$desc3				= $row[40];
	$desc4				= $row[41];
	$desc5				= $row[42];
	$desc6				= $row[43];
	$evidence1			= $row[44];
	$evidence2			= $row[45];
	$evidence3			= $row[46];
	$evidence4			= $row[47];
	$evidence5			= $row[48];
	$evidence6			= $row[49];
	//$nbofteus=$row[50];
	$currency			= $row[51];
	$offer_number		= $row[52];
	$freetimedays		= $row[53];
	$linearmeter		= $row[54];
	$vessel_id			= $row[55];
	$agent_id			= $row[56];
	$carriersign		= $row[57];
	$status				= $row[58];
	$client_name		= $row[59];
	$stamp1				= $row[60];
	$stamp2				= $row[61];
	$stamp3				= $row[62];
	$stamp4				= $row[63];
	$stamp5				= $row[64];
	$stamp6				= $row[65];
	$received_date		= $row[66];
	$sourceagent		= $row[67];
	$lineoperator		= $row[68];
	$localagent_code	= $row[69];
	$localagent_name	= $row[70];
	$declaredbyforwarder = $row[71];
	$withEmptyContainer = $row[72];
	$containeragent_code = $row[73];
	$containeragent_name = $row[74];
	$otherRemark		 = $row[75];
	//$rank=$row[67];
	

	}
	$query="select bl_code, agent1 from agent where code ='$voyage_destination'";
//echo $query;exit;
$result1=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
    $agent_id=$rows[0];
	$agentname=$rows[1];
}
//	$query="select  Stamp1, Stamp2, Stamp3, Stamp4, Stamp5, Stamp6 From location where code='$placedelivery'";
$query="select  Stamp1, Stamp2, Stamp3, Stamp4, Stamp5, Stamp6 From location
        inner join port on location.code = port.port_location where port.port_name='$portdischarge'";
//echo $query;exit;
$result1=mysql_query($query,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($result1)){
	$stamp1=$rows[0];
	$stamp2=$rows[1];
	$stamp3=$rows[2];
	$stamp4=$rows[3];
	$stamp5=$rows[4];
	$stamp6=$rows[5];
}
	$mode='edit';
	//echo "client $client_name";
	$queryrank="select Manifest_auto,(@rank := @rank + 1) AS rank from ( SELECT @rank := 0 ) as r, manifest 
				where voyage_year ='$voyage_year' AND voyage_number='$voyage_number' ";
if ($searchpol != '')	 $queryrank .= " and Portofloading like '%".$searchpol."%' ";
if ($searchlagent != '') $queryrank .= " and localagent_code like '%".$searchlagent."%' ";
if ($searchlagent != '') $queryrank .= " and containeragent_code like '%".$searchlagent."%' ";
if ($searchtbl != '') 	 $queryrank .= " and BOL_type like '%".$searchtbl."%' "; 
 
 $resultrank = mysql_query($queryrank, $connection);
	while($rows=mysql_fetch_array($resultrank)){
		//echo $rows[0]."&nbsp;".$rows[1]."<br>";
		
		if ($Manifest_Auto==$rows[0]){
			$rank=$rows[1];
		}
	}
}
//echo "date=".$received_date;
if($mode=='') $mode='insert';
//echo "aftermode is ".$mode;

//echo $base1;
print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<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">

<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">
<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" language="javascript">

function checkDeposit(){
	
	var clientcode 	= document.Manifest.client_name.value;
	var voyyear		= document.Manifest.voyage_year.value;
	
	if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
	else
		{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText.split("[BRK]");
			
			if (data[1] == 0){
				document.Manifest.clientnote.value = "Client with no Deposit!";
			}			
		}
	}
	
	
	xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=chk_deposit"+"&clientcode="+clientcode+"&voyyear="+voyyear,true);
	xmlhttp.send();
}

function checkContainer(index,ftype){
	
	var container = document.getElementById('container['+index+']').value;
	
	var flag = 0;
	if(ftype == 1){
		var flagtemp = document.getElementById('flag['+index+']').value;
		if(flagtemp == '') flag = 1;
	}
	if(ftype == 2){
		if(document.getElementById('flag['+index+']').checked)
			flag = 1;
	}
	if(flag == 1 && container != ''){
		
		if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp=new XMLHttpRequest();
			}
		else
			{// code for IE6, IE5
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				var data = xmlhttp.responseText.split("[BRK]");
				if(data[1] == ''){
					alert("Container Code Entered doesn't Exist!");	
					document.getElementById('container['+index+']').value = '';
					return 0;
				}					
			}
		}
		
		
		xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=check_container"+"&container="+container,true);
		xmlhttp.send();
	}
}

function openoperator(){
	win = window.open('list_operator.php', 'containerlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=500,top=100');		
	
	win.focus();
}
function openlocation(str){
	win = window.open('list_location.php?str='+str, 'containerlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=500,top=100');		
	//win.creator = self;
	win.focus();
	
}
function opencontainer(str){
	
win = window.open('list_container.php?str='+str, 'containerlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=900,height=500,top=100');		
	//win.creator = self;
	win.focus();
}

function openvoyagedest(str){
	win = window.open('list_voydest.php?str='+str, 'clientlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=500,top=100');		
	//win.creator = self;
	win.focus();
}

function openAgent(str){
	win = window.open('list_agent.php?str='+str, 'agentlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=900,height=500,top=100');		
	//win.creator = self;
	win.focus();
}
function openclient(){
	 win = window.open('list_client.php', 'clientlist', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=900,height=500,top=100');		
	//win.creator = self;
	win.focus();
}

function setchkbox(val){
	if(document.getElementById(val).checked)
		document.getElementById(val).value=1;
	else document.getElementById(val).value=0;
}

function SetPrvManifest(manifest_auto){
	//document.getElementById('Manifest_Auto').value=manifest_auto-1;
	var Manifest_Auto	= manifest_auto-1;
	var voyage_year		= document.getElementById('voyage_year').value;
	var voyage_number	= document.getElementById('voyage_number').value;
	
	var searchpol 		= document.getElementById('searchpol').value;
	var searchlagent 	= document.getElementById('searchlagent').value;
	var searchtbl 		= document.getElementById('searchtbl').value;
	
	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					var data = xmlhttp.responseText.split("[BRK]");
									
					document.getElementById('Manifest_Auto').innerHTML=data[0]; 
					//document.getElementById('test').innerHTML=data[1];
					
					var str = "Form_Manifest.php?Manifest_Auto="+data[0];
					if (searchpol != '') str = str + "&searchpol="+encodeURIComponent(searchpol);
					if (searchlagent != '') str = str + "&searchlagent="+encodeURIComponent(searchlagent);
					if (searchtbl != '') str = str + "&searchtbl="+searchtbl;
					window.location = str;
					
								
//document.Manifest.action="Form_Manifest.php?Manifest_Auto="+data[0];
				//	document.Manifest.submit();
				
				
					
					
					
				}
		}
  }
xmlhttp.open("GET","Form_Manifests_Action.php?Manifest_Auto="+Manifest_Auto+"&mainmode=setprvmanifest"+"&voyage_year="+voyage_year+"&voyage_number="+voyage_number
			+"&searchpol="+searchpol+"&searchlagent="+searchlagent+"&searchtbl="+searchtbl,true);

xmlhttp.send();

	
	/*document.getElementById('Manifest_Auto').value=manifest_auto-1;
	 var manifest=manifest_auto-1;
	 var voyage_year=document.getElementById('voyage_year').value;
	document.Manifest.action="Form_Manifest.php?Manifest_Auto="+manifest+"&voyage_year="+voyage_year;
	document.Manifest.submit();
	*/
	
	//alert(11);
	//document.Manifest.action="Form_Manifest.php?Manifest_Auto=145";
					//document.Manifest.submit();
}
function SetNextManifest(manifest_auto){
	document.getElementById('Manifest_Auto').value=parseInt(manifest_auto)+1;
	
	var Manifest_Auto 	= parseInt(manifest_auto)+1;
	var voyage_year 	= document.getElementById('voyage_year').value;
	var voyage_number 	= document.getElementById('voyage_number').value;
	
	var searchpol 		= document.getElementById('searchpol').value;
	var searchlagent 	= document.getElementById('searchlagent').value;
	var searchtbl 		= document.getElementById('searchtbl').value;
	
	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					var data = xmlhttp.responseText.split("[BRK]");
							
					document.getElementById('Manifest_Auto').innerHTML=data[0];
					
					var str = "Form_Manifest.php?Manifest_Auto="+data[0];
					if (searchpol != '') str = str + "&searchpol="+encodeURIComponent(searchpol);
					if (searchlagent != '') str = str + "&searchlagent="+encodeURIComponent(searchlagent);
					if (searchtbl != '') str = str + "&searchtbl="+searchtbl;
					window.location = str;
				}
		}
  }

xmlhttp.open("GET","Form_Manifests_Action.php?Manifest_Auto="+Manifest_Auto+"&mainmode=setnextmanifest"+"&voyage_year="+voyage_year+"&voyage_number="+voyage_number
					+"&searchpol="+searchpol+"&searchlagent="+searchlagent+"&searchtbl="+searchtbl,true);

xmlhttp.send();
	
	

	
}
function selectitemname(options,index){
	
	
	var itemdesc     = options[options.selectedIndex].id;
document.getElementById('itemname['+index+']').value=itemdesc;
	
}

function addmanifest()
{
	ClearForm('All');
	x=document.Manifest;
	x.mode.value='insert';
	x.Manifest_Auto.value='';
	x.message.value='';
	x.actionmode1.value='add';
	x.action='Form_Manifest.php';
	x.submit();
}

function openarea(str){
	win = window.open('List_Area.php?str='+str, 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=400,top=100');		
	//win.creator = self;
	win.focus();
}
function viewUnconManife(str){
	win = window.open('form_manifestuncorfimed.php?str='+str, 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=400,top=100');		
	//win.creator = self;
	win.focus();
}
function openoffer(){
	win = window.open('List_Offer.php', 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=400,top=100');		
	//win.creator = self;
	win.focus();
}
function openvessel(){
	win = window.open('List_Vessel.php', 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=400,top=100');		
	//win.creator = self;
	win.focus();
}
function changefreight(fieldname,value){
	//alert('dfsdf');
	if (fieldname=='freight_type'){

			var elementvalue = document.getElementById('freight_type').value;
			if (elementvalue=='CO'){
			var freight = document.getElementById('freight');
			freight.value = 'COLLECT';
			}
			
			else if (elementvalue=='PR'){
			var freight = document.getElementById('freight');
			freight.value = 'PREPAID';
			}
	}
	
	if (fieldname=='freight'){

			var elementvalue = document.getElementById('freight').value;
			if (elementvalue=='COLLECT'){
			var freight = document.getElementById('freight_type');
			freight.value = 'CO';
			}
			
			else if (elementvalue=='PREPAID'){
			var freight = document.getElementById('freight_type');
			freight.value = 'PR';
			}
	}
}
function DeleteRecorditem(id){
	var Manifest_Auto=document.Manifest.Manifest_Auto.value;
		if (confirm ( "Are you sure you want to Delete this Record " + "?")){
	

	
	
		if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	var data = xmlhttp.responseText.split("[BRK]");
					document.getElementById('datagriditem').innerHTML=data[1];

					document.getElementById('amounttotal').innerHTML=data[0];
					
					//document.getElementById('datagriditem').innerHTML=data[1];
					
					
					
					
				}
		}
  }

 
xmlhttp.open("GET","Form_Manifestitem_Actions.php?manifestdtl_id="+id+"&mainmode=delete&Manifest_Auto="+Manifest_Auto

,true);
xmlhttp.send();

}

	
}




function SubmitRecorditemGrid(index,manifestdtlocal){
	
	 var mainmode='';
	 var vmode='';
	var errorEx = 0;
	var x = document.Manifest;
	
	
	if(x.voyage_year.value == ''){
		alert('Voyage Year Should not be Empty!');
		x.voyage_year.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_number.value == ''){
		alert('Voyage Number Should not be Empty!');
		x.voyage_number.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_type.value == ''){
		alert('BL Type Should not be Empty!');
		x.voyage_type.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_destination.value == ''){
		alert('Voyage Destination Should not be Empty!');
		x.voyage_destination.focus();
		errorEx = 1;
		return 0;
	}	

	
	if (manifestdtlocal==''){mainmode='insert';}
    else mainmode	= 'update';
	var itemcode	= document.getElementById('itemcode['+index+']').value;
	var itemname	= document.getElementById('itemname['+index+']').value;
	var description	= document.getElementById('description['+index+']').value;
	var amount		= document.getElementById('amount['+index+']').value;
	var quantity	= document.getElementById('quantity['+index+']').value;
	var discount	= document.getElementById('discount['+index+']').value;
	var txtcurr		= document.getElementById('curr['+index+']').value;
	
	var voyage_year		= document.Manifest.voyage_year.value;
	var voyage_number	= document.Manifest.voyage_number.value;
	var vessel_id		= document.Manifest.vessel_id.value;
	var billoflading	= document.Manifest.billoflading.value;
	var description 	= encodeURIComponent(description);
	
	if(isNaN(quantity)) {alert('Quantity should be a number'); return false;}
	if(isNaN(amount)) {alert('Amount should be a number'); return false;}
	if(isNaN(discount)) {alert('Discount should be a number'); return false;}
	if(itemcode==''){
		alert ("item code is mandatory");
		return false;
		//document.Agent.agent_code.focus();
		//document.getElementById('quantity['+index+']').focus;
	}
	if(txtcurr == '')  {alert('Item Currency is empty'); return false;}
	if(document.Manifest.currency.value == '') {alert('Manifest Currency is empty'); document.Manifest.currency.focus();return false;}
	var Manifest_Auto=document.Manifest.Manifest_Auto.value;
	
	
	var voyage_destination	= document.Manifest.voyage_destination.value;
	var bol_number			= document.Manifest.bol_number.value;
	var voyage_type			= document.Manifest.voyage_type.value;
	var voyage_pagenumber	= document.Manifest.voyage_pagenumber.value;
	
		if (Manifest_Auto==''){
			vmode='insertmanifest';
		}
		else vmode='updatemanifest';
	var shipper1	= encodeURIComponent(document.Manifest.shipper1.value);
	var shipper2	= encodeURIComponent(document.Manifest.shipper2.value);
	var shipper3	= encodeURIComponent(document.Manifest.shipper3.value);
	var shipper4	= encodeURIComponent(document.Manifest.shipper4.value);
	var consignee1	= encodeURIComponent(document.Manifest.consignee1.value);
	var consignee2	= encodeURIComponent(document.Manifest.consignee2.value);
	var consignee3	= encodeURIComponent(document.Manifest.consignee3.value);
	var consignee4	= encodeURIComponent(document.Manifest.consignee4.value);
	var notify1		= encodeURIComponent(document.Manifest.notify1.value);
	var notify2		= encodeURIComponent(document.Manifest.notify2.value);
	var notify3		= encodeURIComponent(document.Manifest.notify3.value);
	var notify4		= encodeURIComponent(document.Manifest.notify4.value);
	var desc1		= encodeURIComponent(document.Manifest.desc1.value);
	var desc2		= encodeURIComponent(document.Manifest.desc2.value);
	var desc3		= encodeURIComponent(document.Manifest.desc3.value);
	var desc4		= encodeURIComponent(document.Manifest.desc4.value);
	var desc5		= encodeURIComponent(document.Manifest.desc5.value);
	var desc6		= encodeURIComponent(document.Manifest.desc6.value);
	var otherRemark	= encodeURIComponent(document.Manifest.otherRemark.value);
	var lineoperator=document.Manifest.lineoperator.value;

	var nbofteus=document.Manifest.nbofteus.value;
	var freetimedays=document.Manifest.freetimedays.value;
	
	
	var offer_number	= document.Manifest.offer_number.value;
	offer_number		= encodeURIComponent(offer_number);
	var precarriage		= document.Manifest.precarriage.value;
	var recieptplace	= document.Manifest.recieptplace.value;
	var portlading		= document.Manifest.portlading.value;
	var placedelivery	= document.Manifest.placedelivery.value;
	var portdischarge	= document.Manifest.portdischarge.value;
	
	
	var amount1				= document.Manifest.amount1.value;
	var amount2				= document.Manifest.amount2.value;
	var amount3				= document.Manifest.amount3.value;
	var amount4				= document.Manifest.amount4.value;
	var amount5				= document.Manifest.amount5.value;
	var amount6				= document.Manifest.amount6.value;
	var evidence1			= document.Manifest.evidence1.value;
	var evidence2			= document.Manifest.evidence2.value;
	var evidence3			= document.Manifest.evidence3.value;
	var evidence4			= document.Manifest.evidence4.value;
	var evidence5			= document.Manifest.evidence5.value;
	var evidence6			= document.Manifest.evidence6.value;
	var carriersign			= document.Manifest.carriersign.value;
	var nonegotiable		= document.Manifest.nonegotiable.value;
	var termcarriage		= document.Manifest.termcarriage.value;
	var linearmeter			= document.Manifest.linearmeter.value;
	var issuedat			= document.Manifest.issuedat.value;
	var issuedon			= document.Manifest.issuedon.value;
	var manifest_date		= document.Manifest.manifest_date.value;
	var currency			= document.Manifest.currency.value;
	var client_name			= document.Manifest.client_name.value;
	var agent_id			= document.Manifest.agent_id.value;
	var freight_type		= document.Manifest.freight_type.value;
	var freight				= document.Manifest.freight.value;
	var stamp1				= document.Manifest.stamp1.value;
	var stamp2				= document.Manifest.stamp2.value;
	var stamp3				= document.Manifest.stamp3.value;
	var stamp4				= document.Manifest.stamp4.value;
	var stamp5				= document.Manifest.stamp5.value;
	var stamp6				= document.Manifest.stamp6.value;
	var sourceagent			= document.Manifest.sourceagent.value;
	var localagent_code 	= document.Manifest.localagent_code.value;
	var withEmptyContainer  = document.Manifest.withEmptyContainer.value;
	var containeragent_code	= document.Manifest.containeragent_code.value;
	
	var declaredbyforwarder = 0;
	if(document.getElementById('declaredbyforwarder').checked)
		declaredbyforwarder = 1;
	//var lineoperator=document.Manifest.lineoperator.value;
if(errorEx == 0){	
	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
			{ 	
				
				var data = xmlhttp.responseText.split("[BRK]");
				var newId = parseInt(index) + 1; 
				if(vmode=='insertmanifest'){
					//alert('bbb');
					document.getElementById('datagriditem').innerHTML=data[1];
					document.Manifest.Manifest_Auto.value= parseInt(data[0]);
					document.Manifest.mode.value='edit';
					document.getElementById('amounttotal').innerHTML=data[2];
					

					
				}
				else {
					
					document.getElementById('amounttotal').innerHTML=data[0];
					//alert(data[0]);
					document.getElementById('datagriditem').innerHTML=data[1];
					}
				
				document.getElementById('itemcode['+newId+']').focus();
				
			}
}
  }
 
xmlhttp.open("GET","Form_Manifestitem_Actions.php?index="+index+
		"&itemcode="+itemcode+"&itemname="+itemname+
		"&description="+description+
		"&amount="+amount+
		"&quantity="+quantity+
		"&discount="+discount+
		"&mainmode="+mainmode+
		"&manifestdtl_id="+manifestdtlocal+
		"&voyage_year="+voyage_year+
		"&voyage_number="+voyage_number+
		"&vessel_id="+vessel_id+
		"&billoflading="+billoflading+
		"&Manifest_Auto="+Manifest_Auto+
		"&voyage_destination="+voyage_destination+
		"&bol_number="+bol_number+
		"&voyage_type="+voyage_type+
		"&voyage_pagenumber="+voyage_pagenumber+
		"&localagent_code="+localagent_code+
		"&withEmptyContainer="+withEmptyContainer+
		"&containeragent_code="+containeragent_code+
		"&declaredbyforwarder="+declaredbyforwarder+
		"&mainmode="+mainmode+
		"&vmode="+vmode+
		"&shipper1="+shipper1+
		"&shipper2="+shipper2+
		"&shipper3="+shipper3+
		"&shipper4="+shipper4+
		"&consignee1="+consignee1+
		"&consignee2="+consignee2+
		"&consignee3="+consignee3+
		"&consignee4="+consignee4+
		"&notify1="+notify1+
		"&notify2="+notify2+
		"&notify3="+notify3+
		"&notify4="+notify4+
		"&desc1="+desc1+
		"&desc2="+desc2+
		"&desc3="+desc3+
		"&desc4="+desc4+
		"&desc5="+desc5+
		"&desc6="+desc6+
		"&lineoperator="+lineoperator+
		"&otherRemark="+otherRemark+
		"&nbofteus="+nbofteus+
		"&freetimedays="+freetimedays+
		
		"&offer_number="+offer_number+
		"&precarriage="+precarriage+
		"&recieptplace="+recieptplace+
		"&portlading="+portlading+
		"&placedelivery="+placedelivery+
		"&portlading="+portlading+
		"&portdischarge="+portdischarge+
		
		"&amount1="+amount1+
		"&amount2="+amount2+
		"&amount3="+amount3+
		"&amount4="+amount4+
		"&amount5="+amount5+
		"&amount6="+amount6+
		"&evidence1="+evidence1+
		"&evidence2="+evidence2+
		"&evidence3="+evidence3+
		"&evidence4="+evidence4+
		"&evidence5="+evidence5+
		"&evidence6="+evidence6+
		"&carriersign="+carriersign+
		"&nonegotiable="+nonegotiable+
		"&termcarriage="+termcarriage+
		"&linearmeter="+linearmeter+
		"&issuedat="+issuedat+
		"&issuedon="+issuedon+
		"&manifest_date="+manifest_date+
		"&currency="+currency+
		"&client_name="+client_name+
		"&agent_id="+agent_id+
		"&freight_type="+freight_type+
		"&freight="+freight+
		"&mainmode="+mainmode+
		"&stamp1="+stamp1+
		"&stamp2="+stamp2+
		"&stamp3="+stamp3+
		"&stamp4="+stamp4+
		"&stamp5="+stamp5+
		"&stamp6="+stamp6+
		"&sourceagent="+sourceagent+
		"&txtcurr="+txtcurr
		,true);

	xmlhttp.send();

}
	
}

function ReloadGrid(perpage){
	var perpage=document.Manifest.perpage.value;
		
	var Manifest_Auto=document.Manifest.Manifest_Auto.value;

		if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					document.getElementById('datagrid').innerHTML=xmlhttp.responseText;
					
				}
		}
  }

 
xmlhttp.open("GET","Form_Manifest.php?Manifest_Auto="+Manifest_Auto+"&perpage="+perpage+"&startrange=1",true);
xmlhttp.send();

}
	 


function dokeysales(e,obj,columnslist){

	
	
	if (!e) { var e = window.Events;}
    var intKey = (window.Events) ? e.which : e.keyCode;
	
	
	var columnsarray=new Array();
	columnsarray = columnslist.split(",");
	var firstcell = columnsarray[0];
	var lastcell  = columnsarray[columnsarray.length-1];
	
	
	var objname = obj.id;
	//alert(objname);
	//objname = objname.substring(0,objname.lastIndexOf("["));
	
	//alert(objname);
	if (( ((intKey == 37) || (intKey == 39)) && e.ctrlKey )  ||  (intKey == 13))
	{
		var cindx = columnsarray.indexOf(objname);
		
		if (intKey == 37) { //left key
			var nextindx = Number(cindx) - 1;
		}
		if (intKey == 13 || intKey == 39) { //right key
			var nextindx = Number(cindx) + 1;
			
			event.preventDefault();
     // return false;
		}

			
		var nextitem = columnsarray[nextindx]  ;
			
		if (document.getElementById(nextitem)) { 
			var nextobj = document.getElementById(nextitem);
			
			
			
				nextobj.focus();
				
			if (nextobj.type != 'select-one') nextobj.select();
		}
		else {
			var nextrow  = rowindx + 1;
			var nextcell = firstcell + '[' +  nextrow + ']';
				
			//if (document.getElementById(submitid))
			//	document.getElementById(submitid).click();
		
			MoveNextRecord(nextcell);
						
		}			
	}
	else if ( ((intKey == 38) || (intKey == 40)) && e.ctrlKey) {
		
		if (intKey == 38) 
			rowindx = rowindx - 1;
		if (intKey == 40) 
			rowindx = rowindx + 1;
			
		var nextitem =  objname ;
		if (document.getElementById(nextitem)) {
			var nextobj = document.getElementById(nextitem);
			nextobj.focus();
			
			if (nextobj.type != 'select-one') nextobj.select();
		}	
	}
	//return true;

}



function DeleteRecord(manifestdtauto){
	
	var Manifest_Auto=document.Manifest.Manifest_Auto.value;
	
	if (confirm ( "Are you sure you want to Delete this Record " + "?")){
	

	
	
		if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				{ 	
					document.getElementById('datagrid').innerHTML=xmlhttp.responseText;
					
				}
		}
  }

 
xmlhttp.open("GET","Form_Manifestdt_Actions.php?Manifest_Auto="+Manifest_Auto+"&manifestdtauto="+manifestdtauto+"&modemanifestdt=delete",true);
xmlhttp.send();

}

}




function SubmitRecordGrid(index,manifestdtauto,seq){
	
	var mainmode = '';
	document.getElementById('imgSubmit1['+index+']').disabled = true;
	var container	= document.getElementById('container['+index+']').value;
	var marks		= document.getElementById('marks['+index+']').value;
	var package		= document.getElementById('package['+index+']').value;
	var weight		= document.getElementById('weight['+index+']').value;
	var measurement = document.getElementById('measurement['+index+']').value;
	var seqdt 		= document.getElementById('txtseqdt['+index+']').value;
	var bctc_remark	= document.getElementById('bctc_remark['+index+']').value;
	var DetailType	= document.getElementById('txtDetailType['+index+']').value;
	var cntrtype	= document.getElementById('txtcntrtype['+index+']').value;
	cntrtype 		= encodeURIComponent(cntrtype);
	bctc_remark 	= encodeURIComponent(bctc_remark); 
	
	var txtdes=document.getElementById('txtdes['+index+']').value;
	
	var txtdes 	= encodeURIComponent(txtdes);
	var flag	= document.getElementById('flag['+index+']').checked;
	if(!flag)
		flag='*';
	else flag='';
	
	var Manifest_Auto		= document.Manifest.Manifest_Auto.value;
	var voyage_year			= document.Manifest.voyage_year.value;
	var voyage_number		= document.Manifest.voyage_number.value;
	var voyage_destination 	= encodeURIComponent(document.Manifest.voyage_destination.value);
	var bol_number			= document.Manifest.bol_number.value;
	var voyage_type			= document.Manifest.voyage_type.value;
	var voyage_pagenumber	= document.Manifest.voyage_pagenumber.value;
		if (Manifest_Auto==''){
			mainmode='insertmanifest';
		}
		else mainmode='updatemanifest';
	var shipper1	= encodeURIComponent(document.Manifest.shipper1.value);
	var shipper2	= encodeURIComponent(document.Manifest.shipper2.value);
	var shipper3	= encodeURIComponent(document.Manifest.shipper3.value);
	var shipper4	= encodeURIComponent(document.Manifest.shipper4.value);
	var consignee1	= encodeURIComponent(document.Manifest.consignee1.value);
	var consignee2	= encodeURIComponent(document.Manifest.consignee2.value);
	var consignee3	= encodeURIComponent(document.Manifest.consignee3.value);
	var consignee4	= encodeURIComponent(document.Manifest.consignee4.value);
	var notify1		= encodeURIComponent(document.Manifest.notify1.value);
	var notify2		= encodeURIComponent(document.Manifest.notify2.value);
	var notify3		= encodeURIComponent(document.Manifest.notify3.value);
	var notify4		= encodeURIComponent(document.Manifest.notify4.value);
	var desc1		= encodeURIComponent(document.Manifest.desc1.value);
	var desc2		= encodeURIComponent(document.Manifest.desc2.value);
	var desc3		= encodeURIComponent(document.Manifest.desc3.value);
	var desc4		= encodeURIComponent(document.Manifest.desc4.value);
	var desc5		= encodeURIComponent(document.Manifest.desc5.value);
	var desc6		= encodeURIComponent(document.Manifest.desc6.value);
	var lineoperator = document.Manifest.lineoperator.value;
	var otherRemark	= encodeURIComponent(document.Manifest.otherRemark.value);
	
	var nbofteus		= document.Manifest.nbofteus.value;
	var freetimedays 	= document.Manifest.freetimedays.value;
	var vessel_id		= document.Manifest.vessel_id.value;
	var offer_number	= document.Manifest.offer_number.value;
	var precarriage		= document.Manifest.precarriage.value;
	var recieptplace	= document.Manifest.recieptplace.value;
	var portlading		= document.Manifest.portlading.value;
	var placedelivery	= document.Manifest.placedelivery.value;
	var portdischarge	= document.Manifest.portdischarge.value;
	var billoflading	= document.Manifest.billoflading.value;
	
	var amount1				= document.Manifest.amount1.value;
	var amount2				= document.Manifest.amount2.value;
	var amount3				= document.Manifest.amount3.value;
	var amount4				= document.Manifest.amount4.value;
	var amount5				= document.Manifest.amount5.value;
	var amount6				= document.Manifest.amount6.value;
	var evidence1			= document.Manifest.evidence1.value;
	var evidence2			= document.Manifest.evidence2.value;
	var evidence3			= document.Manifest.evidence3.value;
	var evidence4			= document.Manifest.evidence4.value;
	var evidence5			= document.Manifest.evidence5.value;
	var evidence6			= document.Manifest.evidence6.value;
	var carriersign 		= document.Manifest.carriersign.value;
	var nonegotiable 		= document.Manifest.nonegotiable.value;
	var termcarriage		= document.Manifest.termcarriage.value;
	var linearmeter			= document.Manifest.linearmeter.value;
	var issuedat			= document.Manifest.issuedat.value;
	var issuedon			= document.Manifest.issuedon.value;
	var manifest_date		= document.Manifest.manifest_date.value;
	var currency			= document.Manifest.currency.value;
	var client_name			= document.Manifest.client_name.value;
	var agent_id			= document.Manifest.agent_id.value;
	var freight_type		= document.Manifest.freight_type.value;
	var freight				= document.Manifest.freight.value;
	var stamp1				= document.Manifest.stamp1.value;
	var stamp2				= document.Manifest.stamp2.value;
	var stamp3				= document.Manifest.stamp3.value;
	var stamp4				= document.Manifest.stamp4.value;
	var stamp5				= document.Manifest.stamp5.value;
	var stamp6				= document.Manifest.stamp6.value;
	var sourceagent			= document.Manifest.sourceagent.value;
	var localagent_code		= document.Manifest.localagent_code.value;
	var withEmptyContainer  = document.Manifest.withEmptyContainer.value;
	var containeragent_code	= document.Manifest.containeragent_code.value;
	
	var declaredbyforwarder = 0;
	if(document.getElementById('declaredbyforwarder').checked)
		declaredbyforwarder = 1;
	
	if(manifestdtauto != '')
		var vmode="edit";
	else var vmode="insert";
	
	
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				 	
		var data = xmlhttp.responseText.split("[BRK]");
		var newId = parseInt(index) + 1; 
		
		if(mainmode=='insertmanifest'){
			 document.getElementById('datagrid').innerHTML=data[1];
			if (data[2] == 0){
				var str = 'Form_Container.php';
				window.open(str);
			}
			
			document.Manifest.Manifest_Auto.value=parseInt(data[0]);
			document.Manifest.mode.value='edit'; 
			//document.Manifest.submit();
			
		}
		else { 
			document.getElementById('datagrid').innerHTML = xmlhttp.responseText;
		
			if(document.getElementById('cntrexist').value==0){
				var str = 'Form_Container.php';
				window.open(str);
			} 
		}
			document.getElementById('imgSubmit1['+index+']').disabled = false;
			
		if (vmode=="insert"){	
			if (document.getElementById('txtDetailType['+index+']').value == 1)
				document.getElementById('txtDetailType['+newId+']').value = 2;
			
			if (document.getElementById('txtDetailType['+index+']').value == 2)
				document.getElementById('txtDetailType['+newId+']').value = 3;
			
			if (document.getElementById('txtDetailType['+index+']').value == 3)
				document.getElementById('txtDetailType['+newId+']').value = 4;
			
			if (document.getElementById('txtDetailType['+index+']').value == 4)
				document.getElementById('txtDetailType['+newId+']').value = 5;
			
			if (document.getElementById('txtDetailType['+index+']').value == 5)
				document.getElementById('txtDetailType['+newId+']').value = 5;
		}
			document.getElementById('container['+newId+']').focus(); 
		}
  }
 offer_number		= encodeURIComponent(offer_number);
 
xmlhttp.open("GET","Form_Manifestdt_Actions.php?index="+index+"&manifestdtauto="+manifestdtauto+"&modemanifestdt="+vmode+"&container="+container+"&marks="+marks+"&package="+package+"&weight="+weight+
		"&measurement="+measurement+"&Manifest_Auto="+Manifest_Auto+"&voyage_year="+voyage_year+"&voyage_number="+voyage_number+"&voyage_destination="+voyage_destination+"&bol_number="+bol_number+
		"&voyage_type="+voyage_type+"&voyage_pagenumber="+voyage_pagenumber+"&txtdes="+txtdes+"&seq="+seq+"&flag="+flag+"&billoflading="+billoflading+"&mainmode="+mainmode+
		"&localagent_code="+localagent_code+"&withEmptyContainer="+withEmptyContainer+"&containeragent_code="+containeragent_code+"&declaredbyforwarder="+declaredbyforwarder+"&shipper1="+shipper1+
		"&shipper2="+shipper2+"&shipper3="+shipper3+"&shipper4="+shipper4+"&consignee1="+consignee1+"&consignee2="+consignee2+"&consignee3="+consignee3+"&consignee4="+consignee4+		
		"&notify1="+notify1+"&notify2="+notify2+"&notify3="+notify3+"&notify4="+notify4+"&desc1="+desc1+"&desc2="+desc2+"&desc3="+desc3+"&desc4="+desc4+"&desc5="+desc5+"&desc6="+desc6+"&otherRemark="+otherRemark+		
		"&nbofteus="+nbofteus+"&freetimedays="+freetimedays+"&vessel_id="+vessel_id+"&offer_number="+offer_number+"&precarriage="+precarriage+"&recieptplace="+recieptplace+"&portlading="+portlading+
		"&placedelivery="+placedelivery+"&portlading="+portlading+"&portdischarge="+portdischarge+"&lineoperator="+lineoperator+"&amount1="+amount1+"&amount2="+amount2+"&amount3="+amount3+
		"&amount4="+amount4+"&amount5="+amount5+"&amount6="+amount6+"&evidence1="+evidence1+"&evidence2="+evidence2+"&evidence3="+evidence3+"&evidence4="+evidence4+"&evidence5="+evidence5+
		"&evidence6="+evidence6+"&carriersign="+carriersign+"&nonegotiable="+nonegotiable+"&termcarriage="+termcarriage+"&linearmeter="+linearmeter+"&issuedat="+issuedat+"&issuedon="+issuedon+
		"&manifest_date="+manifest_date+"&currency="+currency+"&client_name="+client_name+"&agent_id="+agent_id+"&freight_type="+freight_type+"&freight="+freight+"&mainmode="+mainmode+
		"&stamp1="+stamp1+"&stamp2="+stamp2+"&stamp3="+stamp3+"&stamp4="+stamp4+"&stamp5="+stamp5+"&stamp6="+stamp6+"&sourceagent="+sourceagent+"&seqdt="+seqdt+"&bctc_remark="+bctc_remark+
		"&DetailType="+DetailType+"&cntrtype="+cntrtype,true);
xmlhttp.send();	
}

function ClearRecordItemGrid(index){
	document.getElementById('itemcode['+index+']').value='';
	document.getElementById('itemname['+index+']').value='';
	document.getElementById('description['+index+']').value='';
	document.getElementById('amount['+index+']').value='';
	document.getElementById('discount['+index+']').value='';
	document.getElementById('quantity['+index+']').value='';
}

function ClearRecordGrid(index){
	document.getElementById('container['+index+']').value='';
	document.getElementById('marks['+index+']').value='';
	document.getElementById('package['+index+']').value='';
	document.getElementById('weight['+index+']').value='';
	document.getElementById('measurement['+index+']').value='';
}


function editmode () {

	document.Manifest.action="Form_Manifest.php?mode=edit";
	document.Manifest.submit();
}



function SubmitRecord() {
	var errorEx = 0;
	var x = document.Manifest;
	
	if(x.voyage_year.value == ''){
		alert('Voyage Year Should not be Empty!');
		x.voyage_year.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_number.value == ''){
		alert('Voyage Number Should not be Empty!');
		x.voyage_number.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_type.value == ''){
		alert('BL Type Should not be Empty!');
		x.voyage_type.focus();
		errorEx = 1;
		return 0;
	} else if(x.voyage_destination.value == ''){
		alert('Voyage Destination Should not be Empty!');
		x.voyage_destination.focus();
		errorEx = 1;
		return 0;
	}
	
	if(errorEx  == 0){
		document.Manifest.action="Form_Manifests_Action.php";
		document.Manifest.submit();
	}
	
}

function export_manifest(){
	/*var filename=document.Manifest.file1.value;
	win = window.open('manifest_explodes.php?filename='+filename, 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1200,height=400,top=100');		
	win.creator = self;
	win.focus();
	*/
	//var file1=document.Manifest.file1.value;
	document.Manifest.action="Form_Manifestexport.php?file1="+file1;
				document.Manifest.submit();
	
}


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

//All= All form; D= Detail Part
function ClearForm(Option){
    x = document.Manifest;
	x.shipper1.value='';
	x.shipper2.value='';
	x.shipper3.value='';
	x.shipper4.value='';
	x.consignee1.value='';
	x.consignee2.value='';
	x.consignee3.value='';
	x.consignee4.value='';
	x.notify1.value='';
	x.notify2.value='';
	x.notify3.value='';
	x.notify4.value='';
	x.amount1.value='';
	x.amount2.value='';
	x.amount3.value='';
	x.amount4.value='';
	x.amount5.value='';
	x.amount6.value='';
	x.desc1.value='';
	x.desc2.value='';
	x.desc3.value='';
	x.desc4.value='';
	x.desc5.value='';
	x.desc6.value='';
	x.evidence1.value='';
	x.evidence2.value='';
	x.evidence3.value='';
	x.evidence4.value='';
	x.evidence5.value='';
	x.evidence6.value='';
	x.voyage_year.value='';
	x.bol_number.value='';
	x.lineoperator.value='';
	x.sourceagent.value='';
	x.voyage_number.value='';
	x.voyage_destination.value='';
	x.voyage_pagenumber.value='';
	x.voyage_type.value='';
	x.billoflading.value='';
	x.manifest_date.value='';
	x.issuedat.value='';
	x.issuedon.value='';
	x.freight.value='';
	x.freight_type.value='';
	x.termcarriage.value='';
	x.nonegotiable.value='';
	x.carriersign.value='';
	x.precarriage.value='';
	x.agent_id.value='';
	x.nbofteus.value='';
	x.freetimedays.value='';
	x.currency.value='';
	x.linearmeter.value='';
	x.offer_number.value='';
	x.vessel_id.value='';
	x.recieptplace.value='';
	x.portlading.value='';
	x.portdischarge.value='';
	x.placedelivery.value='';
	x.received_date.value='';
	x.Manifest_Auto.value='';
	x.client_name.value='';
	x.agentname.value='';
	x.localagent_code.value='';
	x.localagent_name.value='';
	x.containeragent_code.value='';
	x.containeragent_name.value='';
	x.declaredbyforwarder.value='';
	x.searchpol.value='';
	x.searchlagent.value='';
	x.searchtbl.value='';
	x.clientnote.value = '';
	x.otherRemark.value = '';
}



   function PrintPreview() {
	  // self.close;
	var str = '';
	
	str = 'Form_ManifestPreview.php';
	window.open(str);

}



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


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

function setManifest(Cntr_Auto){
	
	document.Manifest.Cntr_Auto.value=Cntr_Auto;
	document.Manifest.message.value='';
	document.Manifest.mode.value='editmode';
	document.Manifest.submit();
}
/* 
function SetNextPage(startrange,perpage){
	document.Manifest.action='Form_Manifest.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.Manifest.submit();
}

function SetPrvPage(startrange,perpage){
	document.Manifest.action='Form_Manifest.php?PRef=&startrange='+startrange+'&perpage='+perpage;
	document.Manifest.submit();
} */

function SearchForManifest(){
	x = document.Manifest;
	document.Manifest.action='Form_Manifest.php?startrange=0';
	document.Manifest.submit();
}
function Search_Manifest(){
	 x = document.Manifest;
    win = window.open('Form_ManifestsSearch.php', 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1450,height=500,top=100');		
	win.creator = self;
	win.focus();
}
function defaultManifest(){
	win = window.open('Form_ManifestDefaultVal.php', 'Form_ManifestDefaultVal', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1200,height=500,top=100');		
	win.creator = self;
	win.focus();
	
}
function addstamp(){
	x = document.Manifest;
	var Manifest_Auto=x.Manifest_Auto.value;
    win = window.open('Form_Manifest_stamp.php?Manifest_Auto='+Manifest_Auto, 'Form_ManifestsSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1200,height=400,top=100');		
	
	
	//win = window.open('Form_Manifest_stamp.php?Manifest_Auto='+Manifest_Auto, 'Form_Manifeststamp', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1000);
	//height=200,left=900,top=300');		
	win.creator = self;
	win.focus();
}



function ClearKeyword(){
	x = document.Manifest;
	x.txtKeyword.value='';
	document.Manifest.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)
	   {
	   event.preventDefault();
	  
	   return false;
	   }
	else
	   return true;

}  

function confirm_delete(Code) {
	
				
	if (confirm ( "Are you sure you want to Delete this Record " + "?")) {
		
		document.Manifest.mode.value='delete';	
		
		document.Manifest.action='Form_Manifest_Actions.php?Cntr_Auto='+Code;
		document.Manifest.submit();
		
	}
					
}
function getSrcAgent(){
		
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
				 	
		var data = xmlhttp.responseText.split("[BRK]");
		document.Manifest.sourceagent.value = data[1];
		
	}
  }

var portlading = document.Manifest.portlading.value;  
xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=getSrcAgent&portlading="+portlading,true);
xmlhttp.send();	
}


/* 
function set_limit(){

	perpage=document.Manifest.perpage.value;
	document.Manifest.action='Form_Manifest.php?perpage='+perpage+'&startrange=0';
	document.Manifest.submit();
} */

/* 
function dokeyCont(e, cellval, index){

	
	if (!e) { var e = window.Events;}
    var intKey = (window.Events) ? e.which : e.keyCode;
	
	
	
	if (( ((intKey == 37) || (intKey == 39)) && e.ctrlKey )  ||  (intKey == 13))
	{
		if (cellval == 'container'){
			document.getElementById('marks['+index+']').focus();
		} else if (cellval == 'marks'){
			document.getElementById('package['+index+']').focus();
		} else if (cellval == 'package'){
			document.getElementById('txtdes['+index+']').focus();
		} else if (cellval == 'txtdes'){
			document.getElementById('weight['+index+']').focus();
		} else if (cellval == 'weight'){
			document.getElementById('measurement['+index+']').focus();
		} else if (cellval == 'measurement'){
			document.getElementById('imgSubmit2['+index+']').click();
		}
	}

} */

function getAmount(nbr){
	var desc 	= 'desc'+nbr;
	var amount 	= 'amount'+nbr;
	
	var descval   = document.getElementById(desc).value;
	var amountval = document.getElementById(amount).value;
	var currency  = document.Manifest.currency.value;
	
	if (descval == ''){
		alert('Tax Description is Empty!');
		return 0;
	} 
	else if (currency == ''){
		alert('Currency is Empty!');
		document.Manifest.currency.focus();
		return 0;
	} else {
		if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
							
				var data = xmlhttp.responseText.split("[BRK]");
				if (data[1] == '1')
					document.getElementById(amount).value = data[2];
			}
		  }

		var offer_number  = document.Manifest.offer_number.value;  
		var Manifest_Auto = document.Manifest.Manifest_Auto.value; 
		
		offer_number = encodeURIComponent(offer_number);
		
		xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=getAmount&descval="+descval+"&amountval="+amountval+"&currency="+currency+"&Manifest_Auto="+Manifest_Auto+"&offer_number="+offer_number,true);
		xmlhttp.send();	
	}
	
}

function changeOffer(){
	var offer_number  = document.Manifest.offer_number.value;  
	var Manifest_Auto = document.Manifest.Manifest_Auto.value; 
	
	offer_number = encodeURIComponent(offer_number);
	
	var desc1	    = document.getElementById('desc1').value;
	var amount1 	= document.getElementById('amount1').value;
	var desc2	    = document.getElementById('desc2').value;
	var amount2 	= document.getElementById('amount2').value;
	var desc3	    = document.getElementById('desc3').value;
	var amount3 	= document.getElementById('amount3').value;
	
	var desc4	    = document.getElementById('desc4').value;
	var amount4 	= document.getElementById('amount4').value;
	var desc5	    = document.getElementById('desc5').value;
	var amount5 	= document.getElementById('amount5').value;
	var desc6	    = document.getElementById('desc6').value;
	var amount6 	= document.getElementById('amount6').value;
	
	var currency  	= document.Manifest.currency.value;
	
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
							
				var data = xmlhttp.responseText.split("[BRK]");
				if (data[1] == 1)
					document.Manifest.submit();
				else if (data[1] == 2){
					document.getElementById('amount1').value = data[2];
					document.getElementById('amount2').value = data[3];
					document.getElementById('amount3').value = data[4];
					document.getElementById('amount4').value = data[5];
					document.getElementById('amount5').value = data[6];
					document.getElementById('amount6').value = data[7];
				}
			}
		  }

		
		xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=changeOffer&desc1="+desc1+"&amount1="+amount1+"&desc2="+desc2+"&amount2="+amount2+"&desc3="+desc3+"&amount3="+amount3+
					"&desc4="+desc4+"&amount4="+amount4+"&desc5="+desc5+"&amount5="+amount5+"&desc6="+desc6+"&amount6="+amount6+"&offer_number="+offer_number+"&Manifest_Auto="+Manifest_Auto+
					"&currency="+currency,true);
		xmlhttp.send();	
	
}

function getSize(index, vfield){
	var containercode = document.getElementById('container['+index+']').value;
	var txtcntrtype   = document.getElementById('txtcntrtype['+index+']').value;
		if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
							
				var data = xmlhttp.responseText.split("[BRK]");
				if (vfield == 's' && txtcntrtype != data[1]){
					alert('Wrong Size was submitted!');
				}
				if (data[1] != '')
					document.getElementById('txtcntrtype['+index+']').value=data[1];
			}
		  }

		
		xmlhttp.open("GET","Form_Manifests_Action.php?actionmode=getSize&containercode="+containercode,true);
		xmlhttp.send();	
	
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Manifest</title>

<style type="text/css">
.itemgrid{
	height:90px;
	position: relative;
    /* top: 30px; */
    overflow-y: scroll;
    overflow-x: auto;
    width: 1090px;
   // height: 220px;
    z-index: 1;
}
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='Manifest' method='post' >
<input type=hidden name='mode' value='$mode'>
<input type=hidden name='message' value='$message'>
<input type=hidden name='Manifest_Auto' value='$Manifest_Auto' id='Manifest_Auto'>
<input type='hidden' name='actionmode1' value='$actionmode1'>
<input type='hidden' name='searchpol' id='searchpol' value='$searchpol'>
<input type='hidden' name='searchlagent' id='searchlagent' value='$searchlagent'>
<input type='hidden' name='searchtbl' id='searchtbl' value='$searchtbl'>
HERE;

echo "<div id='test'></div>";

if($mode==''){
//$status='disabled';
//$dis='disabled';

}

if($mode=='view'){

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

}

if($mode=='insert')
//$status='';
$selectitem="select item_code from default_charges where subgroup='TARROS'";
//ECHO $selectitem;
$resultselect=mysql_query($selectitem,$connection);
$i=0;
$tarrositem=array();
while($row=mysql_fetch_array($resultselect)){
	$tarrositem[$i]=$row[0];
	$i++;
	
}
if($Manifest_Auto==''){
	$desc1=$tarrositem[0];
	$desc2=$tarrositem[1];
	$desc3=$tarrositem[2];
	$desc4=$tarrositem[3];
	$desc5=$tarrositem[4];
	$desc6=$tarrositem[5];
}
//print_R($tarrositem);
$arrayitem = implode(',', $tarrositem);
//$arrayitem = $tarrositem;
//$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'>Manifest</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'>
									<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='SubmitRecord(); return false;' title='Save Changes' $Insmode><span><span>Save</span></span></button>&nbsp;";

print <<<HERE
					 
									<button type='button' id='btnadd' name='btnadd' onclick="addmanifest(); return false;" title='Print' $Insmode><span><span>Add</span></span></button>&nbsp;
HERE;
					 
//<button type='button' id='unconfirmedmanifest' name='btnadd' onclick="viewUnconManife(); return false;" title='Print' $Insmode><span><span>Unconfirmed Manifest</span></span></button>&nbsp;

echo " <button type='button' id='search' name='search' onclick='Search_Manifest(); return false;' title='Export Excel' ><span><span>Search</span></span></button> ";
echo " <button type='button' id='addDefault' name='addDefault' onclick='defaultManifest(); return false;' title='Default' ><span><span>Default</span></span></button>";
if ($Manifest_Auto!=''){
						$query="select count(*) from manifest where Voyage_year='$voyage_year'and voyage_number='$voyage_number' ";
						if ($searchpol != '')	 $query .= " and Portofloading like '%".$searchpol."%' ";
						if ($searchlagent != '') $query .= " and localagent_code like '%".$searchlagent."%' ";
						//if ($searchlagent != '') $query .= " and containeragent_code like '%".$searchlagent."%' ";
						if ($searchtbl != '') 	 $query .= " and BOL_type like '%".$searchtbl."%' ";
						$result_query=mysql_query($query,$connection);
						if ($row=mysql_fetch_array($result_query)){
							$countmanifest=$row[0];
						}
						echo "&nbsp; &nbsp; &nbsp;";
						if ($rank>1)
						echo"<img src='img/arrowleft.png' title='Previous' onMouseOver=\"style.cursor='hand'\"  onclick=SetPrvManifest('".$Manifest_Auto."')>";
						
							echo $rank." out of ";
							echo $countmanifest;
							
						if (($rank<$countmanifest)&&($rank!=''))
						echo"<img src='img/arrowright.png' title='Next' onMouseOver=\"style.cursor='hand'\" onclick=SetNextManifest('".$Manifest_Auto."')>";
}				
				if ($client_name != ''){
					$query = "select count(1)
							from Manifest_Deposit where voy_year = '$voyage_year' and client_code = '$client_name' group by client_code ";
					$res = mysql_query($query, $connection);
					$num = mysql_num_rows($res);
					if ($num == 0) $clientnote = "Client with no Deposit!";
				}
				echo "&nbsp; &nbsp; &nbsp; &nbsp; <input type='text' name='clientnote' value='$clientnote' style='border:none; width:150px;color:#ff0000;font-weight:bold;' readonly>";
						echo"</td><td><b>Manifest id: &nbsp; &nbsp; &nbsp; $Manifest_Auto</b> ";
							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='SearchForManifest(); return false;' title='Search Manifest'><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>".$ResultsPage1."</b></span>
								//	<span class='style1'><select name='perpage' id='perpage' value='$perpage' onchange=set_limit();>";
									//if ($startrange=='')
								//		$startrange = 0;
									//if ($perpage=='')
									//	$perpage = 20;
									//row limit loop
									//foreach ($config['trowlimit'] as $value) {
									//	echo "<option value='$value' ";
									//	if($value==$perpage) echo "selected";
									//	echo " >$value</option>";
									//}
echo"							</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td id='content-body'>";
			///		
					$tabs = new tabs("Manifest");	
//$tabs->start("Main Page");
				echo "		<table border='0'  align='center' valign='top'  class='tablecontent' >
							<col width=100%>
							<tr bgcolor='#F7F7F7' >
								<td valign='top' align='left' >
									<table border='1' style='table-layout:fixed; width=20000px' align='left' valign='top' cellspacing=0>
										<col width=10>
										<col width=350>
										<col width=160>
										<col width=170>
										<col width=150>
										<col width=150>";
										
										
								echo "<input type=hidden name='stamp1' value='$stamp1'>";
								echo "<input type=hidden name='stamp2' value='$stamp2'>";
								echo "<input type=hidden name='stamp3' value='$stamp3'>";
								echo "<input type=hidden name='stamp4' value='$stamp4'>";
								echo "<input type=hidden name='stamp5' value='$stamp5'>";
								echo "<input type=hidden name='stamp6' value='$stamp6'>";
				
				
					echo "
										<tr bgcolor='#F7F7F7' height='40'>
										<td><span class='style1'>Shipper</span></td>
											<td valign='center' align='left' >
											<table border=0>
											<tr><td align='left'> &#9679;<input type='text' name='shipper1' id='shipper1' ".$KeyDown." value='".htmlspecialchars($shipper1, ENT_QUOTES)."'    style='width:330; border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='shipper2' id='shipper2' ".$KeyDown." value='".htmlspecialchars($shipper2, ENT_QUOTES)."'    style='width:330; border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='shipper3' id='shipper3' ".$KeyDown." value='".htmlspecialchars($shipper3, ENT_QUOTES)."'   $status  style='width:330; border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='shipper4' id='shipper4'".$KeyDown." value='".htmlspecialchars($shipper4, ENT_QUOTES)."'   $status  style='width:330; border:none;'/></td>
										</tr>
										</table>
										</td>";
										echo "	<td valign='top'>
										<table border=0><tr><td>
										<span class='style1'>Voy Year</span> </td>";
										$current_year= date("y");
										if($Manifest_Auto=='')$voyage_year=$current_year;
									echo "	<td><input type='text' name='voyage_year'  size=2 maxlength='2' value='".htmlspecialchars($voyage_year, ENT_QUOTES)."' id='voyage_year' onKeyPress=\"return submitenter(this,event);\">
									</td></tr>
									<tr><td>
										<span class='style1'>Voy No  </span></td>
										<td>
										<input type='text' name='voyage_number' id=voyage_number size=3 maxlength='3' value='".htmlspecialchars($voyage_number, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										</td>
									
									
									
									</tr>
										<tr><td>
											<span class='style1'>Line Op</span>
										</td>";
										/*echo "<td><select name='status'>
										<option value=''></option>
										<option value='P'";
										if($status=='P')echo "selected";
										echo ">P</option>
										<option value='S'";
										if($status=='S')echo "selected";
										echo "
										>S</option>
										<option value='X'
										";
										if($status=='X')echo "selected";
										echo ">X</option>
										</select>*/
										echo "<td><input type=text name='lineoperator' size=2 value=$lineoperator>";
										ECHO "&nbsp;";
										
										echo "<input type='image' src='img/btnopen.jpg' title='Select client ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openoperator(); return false' style='cursor: pointer;'>";
											
										ECHO "</td></tr></table></td>";
										
										
										echo "<td valign='top'>
										<table><tr><td><span class='style1'>BL No </span></td>
										<td><input type='text' name='bol_number' size=3  maxlength='3' value='".htmlspecialchars($bol_number, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										</td></tr>
										<tr><td><span class='style1'>BL Type </span></td>
										<td> <select name='voyage_type' >";
										
										//echo date("Y");
										echo "<option value=''></option>";
										echo "<option value='I'";
										if ($voyage_type=='I')
											echo "selected";
											echo ">I</option>
										<option value='E'";
										if ($voyage_type=='E')
											echo "selected";
										echo ">E</option>
										<option value='G'
										";
										if ($voyage_type=='G')
											echo "selected";
										echo ">G</option>";
										echo "<option value='T'
										";
										if ($voyage_type=='T')
											echo "selected";
										echo ">T</option>";
										echo "<option value='S'
										";
										if ($voyage_type=='S')
											echo "selected";
										echo ">S</option>";
										echo "</select></td></tr>
										<tr><td>
										<span class='style1' >BL P.No </span></td>
										<td><input type='text' name='voyage_pagenumber' value='".htmlspecialchars($voyage_pagenumber, ENT_QUOTES)."' maxlength='2' size=2 onKeyPress=\"return submitenter(this,event);\">
										</td>
										
										
										
										
										</tr></table></td>
										
										<td valign='top' >
										<table><tr><td>
										
										<span class='style1'>Voy Dest </span>
										</td>
										<td>";
										//$voyagedest="select port_code from port ";
									/*	echo "<select name='voyage_destination' style='width:70px'>";
										$query="select port_code,port_name from port";
											$res=mysql_query($query,$connection);
											echo "<option value='$voyage_destination'>$voyage_destination</option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$voyage_destination)echo "selected";
											echo ">$row[0]</option>";
											}
											echo "</select>
											";  */
											print <<<HERE
												<input type="text" name="voyage_destination" style="width:50px" value="$voyage_destination" onchange="changeagent('$voyage_destination')" onKeyPress=\"return submitenter(this,event);\">
HERE;
											//echo "<input type='text' name='voyage_destination' style='width:50px' value='$voyage_destination' onchange='changeagent(\" $voyage_destination \")'>";
											echo "<input type='image' src='img/btnopen.jpg' title='Select client ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openvoyagedest(2); return false' style='cursor: pointer;'>";
											
									
										//<input type='text' name='voyage_destination' size=3 maxlength='3' value='".htmlspecialchars($voyage_destination, ENT_QUOTES)."'>
									echo "	</td></tr>
										<tr><td>
										<span class='style1'>Nb Of Teus</span></td>
										<td><input type='text' name='nbofteus' size=3 value='".htmlspecialchars($nbofteus, ENT_QUOTES)."' readonly>
										</td></tr>
										<tr><td>
										<span class='style1'>Free T. D.</span>
										</td>
										<td>
										<input type='text' name='freetimedays' size=3 value='".htmlspecialchars($freetimedays, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										</td>
										</tr>
										</table></td>
										<td>
										<table>
										<tr>
										<td>
											
										<span class='style1'>BL</span></td>
										<td><input type='text' name='billoflading' size=13 maxlength='16' value='".htmlspecialchars($billoflading, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										</td></tr>
										<tr><td>
										<span class='style1'>Vessel</span></td>
										<td><input type='text' name='vessel_id' size=8 value='".htmlspecialchars($vessel_id, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										<input type='image' src='img/btnopen.jpg' title='Select Vessel ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openvessel(); return false' style='cursor: pointer;'>
											
										</td></tr>
										<tr><td>
										<span class='style1'>Offer</span></td>
										
										<td><input type='text' name='offer_number' size=10 value='".htmlspecialchars($offer_number, ENT_QUOTES)."' onchange=\"changeOffer();\" onKeyPress=\"return submitenter(this,event);\">
										
										<input type='image' src='img/btnopen.jpg' title='Select Offer ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\"  onclick='openoffer(7); return false' style='cursor: pointer;'>
											
										</td>									
										</tr>
										</tr></table></td></tr>";
										
										echo "
										<tr bgcolor='#F7F7F7' height='40'><td><span class='style1'>Consignee</span></td>
											<td valign='center' align='left'   colspan='1'>
											<table border=0>
											
											
											<tr><td align='left'> &#9679;<input type='text' id='consignee1' ".$KeyDown."  name='consignee1'  value='".htmlspecialchars($consignee1, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='consignee2' ".$KeyDown." name='consignee2'  value='".htmlspecialchars($consignee2, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='consignee3'  ".$KeyDown." name='consignee3'  value='".htmlspecialchars($consignee3, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='consignee4' ".$KeyDown."  name='consignee4'  value='".htmlspecialchars($consignee4, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										</table>
										</td>
										
										<td colspan=2 >
										<table ><tr>										
										<td  align='left' ><span class='style1'> PRECARRIAGE/CARRIAGE</span>
											</td><td><input type='text' name='precarriage' style='width:160px;'  value='".htmlspecialchars($precarriage, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\"></td>
										</tr><tr>
										<td  align='left' ><span class='style1' >PLACE OF RECEIPT</span></td><td>
											<input type='text' name='recieptplace' style='width:140px;' value='".htmlspecialchars($recieptplace)."' onKeyPress=\"return submitenter(this,event);\">
											<input type='image' src='img/btnopen.jpg' title='Select Area ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openarea(7); return false' style='cursor: pointer;'>
											
											</td>
										</tr><tr>
										<td <span class='style1' >PORT OF LOADING</span></td><td>	

										<select name='portlading' style='width:160px' onchange=\"getSrcAgent();\">";
											$query="select port_name from port order by  port_name";
											$res=mysql_query($query,$connection);
											echo "<option value=''></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$portlading)echo "selected";
											echo ">$row[0]</option>";
											}
											echo "</select>
											";  
											//<input type='text' name='portlading' value='".htmlspecialchars($portlading, ENT_QUOTES)."'  style='width:160px'></td>
										//<td>Number Of NegotiableB/L Issued <input type='text' name='nonegotiable' value='".htmlspecialchars($nonegotiable, ENT_QUOTES)."'    >
										//</span></td>
										echo"</tr>
										</table></td>
										<td colspan=2 >
										<table >
										<tr><td><span class='style1' >Source Agent Code</span>
										
										<td><input type='text' name='sourceagent' value='".htmlspecialchars($sourceagent, ENT_QUOTES)."' style='width:160px' onKeyPress=\"return submitenter(this,event);\">
											<input type='image' src='img/btnopen.jpg' title='Select Source Agent ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openAgent(2); return false' style='cursor: pointer;'>
											</span>
											</td>	
										</td></tr>
										<tr>	
										<td align=left>
										
										<span class='style1' >
											PLACE OF DELIVERY</span></td><td><input type='text' name='placedelivery' value='".htmlspecialchars($placedelivery, ENT_QUOTES)."' style='width:160px' onKeyPress=\"return submitenter(this,event);\">
											<input type='image' src='img/btnopen.jpg' title='Select Area ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openarea(8); return false' style='cursor: pointer;'>
											</span>
											</td>
											
											
										</tr><tr>
                                        <td  align='left' ><span class='style1' >PORT OF DISCHARGE</span></td><td>
											<select name='portdischarge' style='width:160px'>";
											$query="select port_name from port order by port_name";
											$res=mysql_query($query,$connection);
											echo "<option value=''></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$portdischarge)echo "selected";
											echo ">$row[0]</option>";
											}
											echo "</select></td></tr><tr><td  align='left' ><span class='style1' ></span></td></td></table></td>";
											
					
										echo "
										<tr bgcolor='#F7F7F7' height='40'>
										<td><span class='style1'>Notify</span></td>
											<td valign='center' align='left' colspan=1>
											<table border=0>
											
											<tr><td align='left'> &#9679;<input type='text' id='notify1' ".$KeyDown."  name='notify1'  value='".htmlspecialchars($notify1, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='notify2'  ".$KeyDown."  name='notify2'  value='".htmlspecialchars($notify2, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='notify3' ".$KeyDown."  name='notify3'  value='".htmlspecialchars($notify3, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' id='notify4'  ".$KeyDown." name='notify4'  value='".htmlspecialchars($notify4, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										</table>
										</td>
											
											
											";
											
										
										
										echo"	
											<td colspan=2 >
										      <table ><tr>

										<td><span class='style1'>Client</span></td>
										<td>";
										
										
										echo "<input type='text' name='client_name' style='width:230px;' value='$client_name' onchange=\"checkDeposit();\" onKeyPress=\"return submitenter(this,event);\">";
										echo "<input type='image' src='img/btnopen.jpg' title='Select client ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openclient(); return false' style='cursor: pointer;'>";
											
										
										
										//<input type='text' name='client_name'  value='".htmlspecialchars($client_name, ENT_QUOTES)." ' style='width:250px;'>
										echo "</td>
										</tr><tr>
										 <td><span class='style1'>Agent Name</span></td><td>";
										 echo "<input type='text' name='agent_id' value='$agent_id' style='width:50px;' onKeyPress=\"return submitenter(this,event);\">";
										echo " &nbsp;";
										 echo "<input type='text' name='agentname' value='$agentname' style='width:150px;' onKeyPress=\"return submitenter(this,event);\">";
										// echo "<input type='hidden' name='agent_id' value='$agent_id' style='width:230px;'>";
										/* echo "<select name='agent_id' >";
											$query="select agent1 from agent";
											$res=mysql_query($query,$connection);
											echo "<option value=''></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$agent_id)echo "selected";
											echo ">$row[0]</option>";
											}
											echo "</select>";*/
										 echo "<input type='image' src='img/btnopen.jpg' title='Select Agent ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openAgent(1); return false' style='cursor: pointer;'>";
										
										
										//<input type='text' name='agent_id' size=6 value='".htmlspecialchars($agent_id, ENT_QUOTES)."'style='width:250px;'>
										echo "</td></tr>	
										
										
										<tr><td>
										<span class='style1'>Freight</span></td><td>";
											//<input type='text' name='freight_type'  size=3  value='".htmlspecialchars($freight_type, ENT_QUOTES)."'>
print <<<HERE
<select name="freight_type" id='freight_type' onchange="changefreight('freight_type')">
HERE;
										ECHO "<option value='CO'";
										if ($freight_type=='CO')echo "selected=true";
										echo ">CO</option>
										<option value='PR'";
										if ($freight_type=='PR')echo "selected=true";
										echo ">PR</option>
										</select>";
										echo "</td></tr><tr><td>
										<span class='style1'>BL Freight</span></td><td>";	
										
										
print <<<HERE
<select name="freight" id='freight' onchange="changefreight('freight')">
HERE;
													
										ECHO "
										<option value='COLLECT'";
										if ($freight=='COLLECT')echo "selected";
										echo ">COLLECT</option>
										<option value='PREPAID'";
										if ($freight=='PREPAID')echo "selected";
										echo ">PREPAID</option>
										</select>";										
										
											//<input type='text' name='freight'   value='".htmlspecialchars($freight, ENT_QUOTES)."'></td>
											  
										echo "</tr></table></td>";
										
										
										echo"	
											<td colspan=2 >
										      <table  border=0>
											  <col width=80><tr>
                                         <td>
										<span class='style1' >Issue At</td><td colspan=2>";
										
										
										
										echo "<input type='text' name='issuedat' size='12' value='".htmlspecialchars($issuedat, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										<input type='image' src='img/btnopen.jpg' title='Select Location ' width='15' height='17 border='0' onmouseover=\"style.cursor='hand'\" onclick='openlocation(10); return false' style='cursor: pointer;'>";
										
										echo "&nbsp;&nbsp;";
										//<input type='text' name='issuedat' value='".htmlspecialchars($issuedat)."'
										//style='width:125px;'>&nbsp;&nbsp;
										
										/*
											echo "<select name='issuedat' style='width:80px'>";
										$query="select port_code,port_name from port";
											$res=mysql_query($query,$connection);
											echo "<option value=''></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$issuedat)echo "selected";
											echo ">$row[0]</option>";
											}
											echo "</select>
											";  */
											
										
										echo "<button type='button' id='stamp' name='stamp' onclick='addstamp(); return false;' title='Clear Page'><span><span>add stamp</span></span></button>
										
										</td></tr>
										<tr><td>
										<span class='style1' >On </td><td>
										<input type='text' name='issuedon' size=6 value='".htmlspecialchars($issuedon)."' onKeyPress=\"return submitenter(this,event);\">
										<a HREF='#' onClick=\"displayCalendar(document.Manifest.issuedon,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

										echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
 
										</tr><tr>";
										echo "<td>
										<span class='style1'>Date</span> </td>
										<td><input type='text' name='manifest_date' size='6' value='".htmlspecialchars($manifest_date, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										<a HREF='#' onClick=\"displayCalendar(document.Manifest.manifest_date,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

										echo"<image src='./img/cal.gif' border=0 align=center ></image></a>
									  &nbsp;&nbsp;&nbsp;<span class='style1'>Currency</span>
										</td>
										<td>
										<SELECT name='currency'>
										<option value=''></option>";
										
										$cur="select currency_code from currency";
										$resultcur=mysql_query($cur);
										while($rowcur=mysql_fetch_array($resultcur)){
											
											echo "<option value='$rowcur[0]'";
											if ($rowcur[0]==$currency)echo "selected " ;
											echo ">$rowcur[0]</option>";
										}
										//echo "<input type='text' name='currency' size='3' value='".htmlspecialchars($currency, ENT_QUOTES)."'>
										echo "</td>
										
										
										</tr><tr> <td><span class='style1'>received date</span></td>
										<td>
										
										<input type='text' name='received_date' size='6' value='".htmlspecialchars($received_date, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										<a HREF='#' onClick=\"displayCalendar(document.Manifest.received_date,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

										echo"<image src='./img/cal.gif' border=0 align=center ></image></a>
									  &nbsp;&nbsp;&nbsp;
										
										</td>
										
										
											  
										</tr></table></td>";
											
									// Other Remarks
									echo "<tr>
											<td><span class='style1'>Other Remark</span></td>
											<td colspan='5'><textarea name='otherRemark' id='otherRemark' rows='3' cols='130' onkeydown=\"return submitenter2(this,event)\">".htmlspecialchars($otherRemark, ENT_QUOTES)."</textarea></td>
										 </tr>";		
										
										echo "<tr>";
										
										
										echo "<td></td>
										<td valign='center' align='left' >
											<table border=0><tr><td>
											<span class='style1'>Tax Description&nbsp;</span></td></tr>";
											echo "<tr><td><select name='desc1' style='width:330px' id='desc1' onchange=\"getAmount('1');\" ".$KeyDown.">";
											$query="select item_code,item_description from items where SubGroup_code='TARROS'";
											//echo $query;
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc1 == ''?'selected':'')."></option>";
											
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc1)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
											echo "
										<tr><td>";
											echo "<select name='desc2'  id='desc2' onchange=\"getAmount('2');\" style='width:330px' ".$KeyDown.">";
											$query="select item_code,item_description from items where SubGroup_code='TARROS'";
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc2 == ''?'selected':'')."></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc2)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
										
										
										
											echo "
										<tr><td>";
											echo "<select name='desc3' id='desc3' onchange=\"getAmount('3');\" style='width:330px' ".$KeyDown.">";
											$query="select item_code,item_description from items where SubGroup_code='TARROS'";
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc3 == ''?'selected':'')."></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc3)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
											echo "
										<tr><td>";
											echo "<select name='desc4' id='desc4' onchange=\"getAmount('4');\" style='width:330px' ".$KeyDown.">";
											$query="select item_code ,item_description from items where SubGroup_code='TARROS'";
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc4 == ''?'selected':'')."></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc4)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
											echo "
										<tr><td>";
											echo "<select name='desc5' id='desc5' onchange=\"getAmount('5');\" style='width:330px' ".$KeyDown.">";
											$query="select item_code,item_description from items where SubGroup_code='TARROS' ";
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc5 == ''?'selected':'')."></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc5)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
											echo "
										<tr><td>";
											echo "<select name='desc6' id='desc6' onchange=\"getAmount('6');\" style='width:330px' ".$KeyDown.">";
											$query="select item_code,item_description from items where SubGroup_code='TARROS' ";
											$res=mysql_query($query,$connection);
											echo "<option value='' ".($desc6 == ''?'selected':'')."></option>";
											while($row=mysql_fetch_array($res)){
												echo "<option value='$row[0]'";
											
											if ($row[0]==$desc6)echo "selected";
											echo ">$row[1]</option>";
											}
											echo "</select></td></tr>";
										
											
											
											/*<tr><td align='left'> &#9679;<input type='text' name='desc1'  value='".htmlspecialchars($desc1, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='desc2'  value='".htmlspecialchars($desc2, ENT_QUOTES)."'    style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='desc3'  value='".htmlspecialchars($desc3, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='desc4'  value='".htmlspecialchars($desc4, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='desc5'  value='".htmlspecialchars($desc5, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='desc6'  value='".htmlspecialchars($desc6, ENT_QUOTES)."'   $status  style='width:330;border:none;'/></td>
										</tr>*/
										echo"</table>
										</td>
										
										
										<td valign='center' align='left' >
											<table border=0><tr><td>
											<span class='style1'>Tax Amount&nbsp;<span class='style26'></span></span></td></tr>
											<tr><td align='left'> &#9679;<input type='text' name='amount1' id='amount1' onkeyup=\"getAmount('1');\" ".$KeyDown." value='".htmlspecialchars($amount1, ENT_QUOTES)."'    style='width:120;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='amount2' id='amount2' onkeyup=\"getAmount('2');\" ".$KeyDown." value='".htmlspecialchars($amount2, ENT_QUOTES)."'    style='width:120;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='amount3' id='amount3' onkeyup=\"getAmount('3');\" ".$KeyDown." value='".htmlspecialchars($amount3, ENT_QUOTES)."'   $status  style='width:120;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='amount4' id='amount4' onkeyup=\"getAmount('4');\" ".$KeyDown." value='".htmlspecialchars($amount4, ENT_QUOTES)."'   $status  style='width:120;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='amount5' id='amount5' onkeyup=\"getAmount('5');\" ".$KeyDown." value='".htmlspecialchars($amount5, ENT_QUOTES)."'   $status  style='width:120;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='amount6' id='amount6' onkeyup=\"getAmount('6');\" ".$KeyDown." value='".htmlspecialchars($amount6, ENT_QUOTES)."'   $status  style='width:120;border:none;'/></td>
										</tr>
										</table>
										</td>
											
											<td valign='center' align='left' >
											<table border=0><tr><td>
											<span class='style1'>Evidence&nbsp;<span class='style26'></span></span></td></tr>
											<tr><td align='left'> &#9679;<input type='text' name='evidence1' id='evidence1'  ".$KeyDown." value='".htmlspecialchars($evidence1, ENT_QUOTES)."'    style='width:150;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='evidence2' id='evidence2'  ".$KeyDown." value='".htmlspecialchars($evidence2, ENT_QUOTES)."'    style='width:150;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='evidence3' id='evidence3'  ".$KeyDown." value='".htmlspecialchars($evidence3, ENT_QUOTES)."'   $status  style='width:150;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='evidence4' id='evidence4'  ".$KeyDown." value='".htmlspecialchars($evidence4, ENT_QUOTES)."'   $status  style='width:150;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='evidence5' id='evidence5' ".$KeyDown." value='".htmlspecialchars($evidence5, ENT_QUOTES)."'   $status  style='width:150;border:none;'/></td>
										</tr>
										<tr><td align='left'> &#9679;<input type='text' name='evidence6' id='evidence6'  ".$KeyDown." value='".htmlspecialchars($evidence6, ENT_QUOTES)."'   $status  style='width:150;border:none;'/></td>
										</tr>
										</table>
										</td>
										
										
										<td colspan=2 align='left' >
											<table border=0><tr>
										<td ><span class='style1' >Carrier Signature/the Agent of the carrier</span></td></tr><tr><td>
										<input type='text' name='carriersign' value='".htmlspecialchars($carriersign, ENT_QUOTES)."' size=10 onKeyPress=\"return submitenter(this,event);\"></td>";
										$query="select code from toc";
											//echo $query;
										$res=mysql_query($query,$connection) or die(mysql_error());	
										echo "</tr>";
										echo "</td><tr>
											<td >
											<span class='style1' >Number Of NegotiableB/L Issued</span></td></tr><tr><td> <input type='text' name='nonegotiable' value='".htmlspecialchars($nonegotiable, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\" >
										</span>";
										
										echo "</td>	</tr><tr>
                                        <td  align='left' ><div style='width: 120px;float: left;'><span class='style1' >TOC</span>
											<SELECT name='termcarriage' >";
										echo "<option value=''></option>";
											while($row=mysql_fetch_array($res)){
										echo "<option value='$row[0]' ";
									
									
									    if ($row[0]==$termcarriage) echo selected;
									        echo ">$row[0]</option>";
											}
										//<input type='text' name='termcarriage' value='".htmlspecialchars($termcarriage)."' style='width:150px' ></td>
										
								   	   echo "</select>
                                       </div><div>
										<span class='style1'>Linear Meters</span>
										
										<input type='text' name='linearmeter' size=6 value='".htmlspecialchars($linearmeter, ENT_QUOTES)."' onKeyPress=\"return submitenter(this,event);\">
										</div></td>
									   
										
										</tr>";
							echo "<tr><td><span class='style1'>Local Agent</span>
										 <input type='text' name='localagent_code' id='localagent_code' value='$localagent_code' style='width:70px;' onKeyPress=\"return submitenter(this,event);\">
										 <input type='text' name='localagent_name' id='localagent_name' value='$localagent_name' style='width:120px;' onKeyPress=\"return submitenter(this,event);\">
										 <input type='image' src='img/btnopen.jpg' title='Select Agent ' width='15' height='17' border='0' onmouseover=\"style.cursor='hand';\" onclick=\"openAgent(3); return false;\" style='cursor: pointer;'>
										 </td></tr>";
							echo "<tr><td><span class='style1'>Container Agent</span>
										 <input type='text' name='containeragent_code' id='containeragent_code' value='$containeragent_code' style='width:70px;' onKeyPress=\"return submitenter(this,event);\">
										 <input type='text' name='containeragent_name' id='containeragent_name' value='$containeragent_name' style='width:120px;' onKeyPress=\"return submitenter(this,event);\">
										 <input type='image' src='img/btnopen.jpg' title='Select Agent ' width='15' height='17' border='0' onmouseover=\"style.cursor='hand';\" onclick=\"openAgent(6); return false;\" style='cursor: pointer;'>
										 </td></tr>";
							if($declaredbyforwarder == '') $declaredbyforwarder=0;				
							if($withEmptyContainer == '') $withEmptyContainer=0;	
							echo "<tr><td><div style='float: left;width: 120px;'><span class='style1'>
										<input type='checkbox' name='declaredbyforwarder' id='declaredbyforwarder' value='$declaredbyforwarder' onclick=\"setchkbox('declaredbyforwarder');\" ".($declaredbyforwarder=='1'?'checked':'')."> 
										Forwarder</span></div>
										<div style='float: right;width: 170px;'><span class='style1'>
										<input type='checkbox' name='withEmptyContainer' id='withEmptyContainer' value='$withEmptyContainer' onclick=\"setchkbox('withEmptyContainer');\" ".($withEmptyContainer=='1'?'checked':'')."> 
										With Empty Containers</span></div></td></tr>";								
							echo "	</table></td>";
									echo "
									</table>
								</td>
							</tr>
							
							<tr><td>";
							
							
							echo "<div id='datagriditem' class='grid' style='width:1090px; height:120px' >";




//Show Items Grid
ShowitemGrid($connection,'Manifest_Dt',$Manifest_Auto,$_SESSION['gdl_parameters'],$_SESSION['gdl_arrayaccess'],'ManifestDt.DeliveryDt_ID');

echo"	  </div>"; 


//show total amount grid
echo "<div id='amounttotal'>";

Showtotalamount($connection,$Manifest_Auto);


echo "
</div>";
							
							echo "<div id='datagrid' class='grid' style='width:1090px;' >";

//echo "<tr></tr>";


//Show Container Grid
ShowDeliveryDtGrid($connection,'Manifest_Dt',$Manifest_Auto,$_SESSION['gdl_parameters'],$_SESSION['gdl_arrayaccess'],'ManifestDt.DeliveryDt_ID');

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

echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	
echo" </table>  ";//end of last table menu		 
	if($vTabFocus!=''){
					echo'<script type="text/javascript" language="javascript">';
					echo"tab_('$vTabFocus','');";
					echo'</script>';	
				}	


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

HERE;



?>














