<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$estimatetype = $_REQUEST['estimatetype'];
$_SESSION['selBType'] = $_REQUEST['estimatetype'];
if(isset($_REQUEST['selFCAList']) && $_REQUEST['selFCAList']!="")
{
	$id = $_REQUEST['selFCAList'];
}
else
{
	$sql = "select * from freight_cost_estimete_master WHERE MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and ESTIMATE_TYPE='".$estimatetype."' and SHEET_NO is NULL order by FCAID desc";
	$result = mysql_query($sql);
	$num = mysql_num_rows($result);
	if($num==0){header('Location:./addestimate.php?estimatetype='.$estimatetype);}
	else
	{
		$row = mysql_fetch_assoc($result);
		$id = $row['FCAID'];
	}
}
if(@$_REQUEST['action'] == 'submit')
{
	$msg = $obj->insertTCITemplateDetailsNew($id);
	header('Location:./estimate_list.php?msg='.$msg);
}
$obj->viewFreightCostEstimationTempleteRecordsNew($id);

$pagename = basename($_SERVER['PHP_SELF'])."?id=".$id."&estimatetype=".$estimatetype;
$rdoCap = $obj->getFun12();
$rdoMMarket= $obj->getFun45();
$rdoDWT =$obj->getFun46();
$rdoQty = $obj->getFun96();
$rdoQtyType = $obj->getFun155();
if($rdoQtyType ==""){$rdoQtyType = 1;}
$display1 = '';
$display2 = '';
if($rdoQtyType ==1){$display1 = 'style="display:none;"';$display2 = '';}
if($rdoQtyType ==2){$display1 = '';$display2 = 'style="display:none;"';}
$rdoEstimateType = $obj->getFun158();
$rdoQtyMar =$obj->getFun159();
if($rdoQtyMar=='')
{$rdoQtyMar=1;}
$rdoTankQtyType = $obj->getFun228();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<link rel="stylesheet" href="../../css/select2.css" type="text/css"/>
<link rel="stylesheet" href="../../css/select2-bootstrap.css" type="text/css"/>
<?php $display->js(); ?>
<script src="../../js/select2.min.js" type="text/javascript"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
<style>
.animated {
	vertical-align: top; 
	transition: height 0.2s;
	-webkit-transition: height 0.2s; 
	-moz-transition: height 0.2s; 
}

form.cmxform label.error, label.error {
	/* remove the next line when you have trouble in IE6 with labels in list */
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:10px;
	color: red;
	font-style:normal;
	font-weight:lighter;
	margin:5px;
	vertical-align:top; 
}
table {border-collapse:separate;}
select{height:19px;}
.select {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #333333;
    /* color: #FBC763; */
    text-decoration: none;
    line-height: 13px;
	height:13px;
}

.input-text {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: normal;
	color: #333333;
	text-decoration: none;
	/*text-transform:uppercase;
	line-height: 15px;*/
}

.input-textsmall {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	font-weight: normal;
	color: #333333;
	text-decoration:none;
	text-transform:uppercase;
}


.input 
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
color: #333333;
text-decoration: none;
}


.benchclass{
	color:#CC4200;
	font-weight:bold;
}

</style>
</head>
	<div id="basic-modal-content" style="display:none;" align="center">
	<table cellpadding="1" cellspacing="4" border="0" align="center">
	<tr><td align="center"><img src="../../img/loading.gif" /><br /></td></tr>
	</table>
	</div>
	
    <body class="skin-blue fixed">
		<a href="#" id="trigger1" title="Calculate" onClick="getFinalCalculation();">Calculate</a>
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(9); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                 <section class="content-header">
                    <h1>
                        <i class="fa fa-leaf"></i>&nbsp;VC Estimates&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="../"><i class="fa fa-home"></i> Home</a></li>
                        <li class="active">VC Estimates</li>
                    </ol>
                </section>
                
                <div align="right" style="margin-top:5px;margin-bottom:5px;margin-right:5px;"><a href="estimate_list.php"><button class="btn btn-info btn-flat">Back</button></a></div>
                <form role="form" name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">
                   <table width="100%" style="margin-bottom:5px; padding:0px 5px 0px 5px;">
                       <tr>
                           <td width="12%" class="input-text" style="color:#367fa9;font-size:11px;"><strong >Fixture&nbsp;Type&nbsp;:</strong>&nbsp;VC&nbsp;Out&nbsp;<input type="hidden" name="selFType" id="selFType" value="2"></td>
                           
                           <td class="input-text" style="color:#367fa9;font-size:11px;">
                           <strong>Vessel&nbsp;:&nbsp;</strong><select name="selVName" class="input-text" id="selVName" style="width:120px;color:#367fa9;" onChange="getData();">
                                <?php 
                                $obj->getVesselTypeListMemberWise($estimatetype);
                                ?>
                                </select>
                           </td>
                           <td class="input-text" style="color:#367fa9;font-size:11px;"><strong>Vessel&nbsp;Type&nbsp;:</strong><input type="text" name="txtVType" id="txtVType" style="width:90px;color:#367fa9;font-size:11px;" class="input-text" readonly value="<?php echo $obj->getFun6();?>" />
                            <select  name="selVendor" style="display:none;"  id="selVendor" >
                            <?php $obj->getVendorListNewUpdate();	?>
                            </select> 
                            
                            <select name="selOwnerCost" id="selOwnerCost" style="display:none;">
                            <?php $obj->getOwnerRelatedCostList();?>
                            </select>
                            <select name="selMaterial1" id="selMaterial1" style="display:none;">
							<?php $obj->getCargoNameListForMultiple(1);?>
                            </select>
                            <select name="selMaterial2" id="selMaterial2" style="display:none;">
                            <?php $obj->getCargoNameListForMultiple(2);?>
                            </select>
                            <select name="selMaterial3" id="selMaterial3" style="display:none;">
                            <?php $obj->getCargoNameListForMultiple(3);?>
                            </select>
							<select  name="selCharterer" style="display:none;"  id="selCharterer">
							<?php $obj->getVendorListNewForCOA('7,11,10');?>
							</select> 
                           </td>
                           <td class="input-text" style="color:#367fa9;font-size:11px;"><strong>Flag&nbsp;:</strong><input type="text" name="txtFlag" id="txtFlag" style="width:100px;color:#367fa9;font-size:11px;" class="input-text" readonly value="<?php echo $obj->getFun7();?>" /></td>
                           <?php if($obj->getFun3()!=""){$date = date('d-m-Y',strtotime($obj->getFun3()));}else{$date = "";}?>
                            <td class="input-text" style="color:#367fa9;font-size:11px;"><strong>CP Date&nbsp;:</strong><input type="text" name="txtDate" id="txtDate" style="width:90px;color:#367fa9;font-size:11px;" class="input-text" value="<?php echo $date ;?>" placeholder"dd-mm-yy" /></td>
                            <td class="input-text" style="color:#367fa9;font-size:11px;"><strong>Voyage&nbsp;No.&nbsp;:</strong><input type="text" name="txtVNo" id="txtVNo" style="width:90px;color:#367fa9;font-size:11px;" class="input-text" value="<?php echo $obj->getFun8();?>" placeholder"" /></td>
							<td class="input-text" style="color:#367fa9;"><strong>TC&nbsp;No.&nbsp;:</strong><input type="text" required name="txtTCNo" id="txtTCNo" style="width:90px;color:#175c84;" class="input-text" value="<?php echo $obj->getFun229();?>" placeholder"" /></td>
                            <td class="input-text" style="color:#367fa9;font-size:11px;"><strong>Voyage&nbsp;Financials&nbsp;Name&nbsp;:</strong><input type="text" name="txtENo" id="txtENo" style="width:115px;color:#367fa9;font-size:11px;" class="input-text" value="<?php echo $obj->getFun9();?>" placeholder="" /></td>
                       </tr>
                   </table>
                <div id="tabs" class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tabs_2" data-toggle="tab">Voyage Financials : Estimate</a></li>
                        <li><a href="#tabs_3" data-toggle="tab">Commercial Parameters</a></li>
                        <li><a href="#tabs_4" data-toggle="tab">Open Vessel Details</a></li>
                        <li><a href="#tabs_5" data-toggle="tab">Planned Cargo/Intake</a></li>
                    </ul>
                    
                    <div class="tab-content">
                    <!----------------------------------------------- Start 1------------------------------------------------->
                    <div id="tabs_2" class="tab-pane active" style="overflow:auto;">
                       <table width="100%">
                          <tr>
                           <td colspan="2">
                               <table class='tablesorter' width="100%">
                                  <tbody>
                                      <tr>
                                       <td colspan="2">
                                           <table width="100%">
                                           <tr>
                                           <td width="21%" style="color:#367fa9;font-size:11px;"><strong>Select Previous Sheet : </strong><select name="selFCAList" class="input-text" id="selFCAList" style="width:120px;" onChange="getSubmitForm();";>
												<?php 
                                                $obj->getSheetNameFromTCEListNew($estimatetype);
                                                ?>
                                            </select></td>
                                            <script>$("#selFCAList").val(<?php echo $id;?>);</script>
                                            <td style="width:7%;"><strong>Cargo Type&nbsp;:</strong></td>
                                            <td style="width:7%;"><strong>&nbsp;<span id="cargotypespan"><?=$obj->getBusinessTypeBasedOnID1($rdoEstimateType);?></span></strong></td>
                                            <td style="width:8%;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;Cargo Name&nbsp;:</strong><input type="hidden" name="rdoEstimateType" id="rdoEstimateType" value="<?=$rdoEstimateType;?>"/></td>
                                            <td style="width:24%;">
                                             <select data-placeholder="Choose Cargo Name..." class="input-text chzn-select" style="width:300px;" multiple name="selCName[]" onChange="getMaterialCode();" id="selCName"><?php $obj->getCargoNameListForMultiple($rdoEstimateType,$obj->getFun52());?></select>
                                            </td>
                                            <td style="width:8%;"><span id="cargoplan_1">Cargo Planning:</span></td>
                                            <td style="width:22%;"><span id="cargoplan_2"><input type="hidden" name="selCargoPlanning" class="input-text" id="selCargoPlanning" value=""/><textarea class="input-text" readonly name="txtCargoPlanDetails" id="txtCargoPlanDetails" cols="45" rows="3" placeholder="Cargo Planning Details..." ></textarea></span></td>
                                            <td><span id="cargoplan_3"><button type="button" data-toggle="modal" data-target="#compose-modal" class="btn btn-primary btn-flat" style="font-size:12px">Search Cargo</button></span></td>
                                           </tr>
                                           </table>
                                       </td>
                                     </tr>    
                                     <tr id="distypeDiv1">
                                       <td colspan="2">      
                                         <table class='tablesorter' width="100%">
                                          <tbody>
                                            <tr>
                                                <td><strong>Market</strong>&nbsp;&nbsp;</td>
                                                <td><input name="rdoQtyMar" class="checkbox" id="rdoQtyMar1" type="radio" value="1"  <?php if($rdoQtyMar == 1) echo "checked"; ?>  onclick="showGasMarket(1);"  /></td>
                                                <td>Base&nbsp;Freight&nbsp;<span style="font-size:10px; font-style:italic;">(USD/MT)</span>&nbsp;</td>
                                                <td><input type="text"  name="txtBaseRate" id="txtBaseRate" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun162();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
                                                <td><input name="rdoQtyMar" class="checkbox" id="rdoQtyMar2" type="radio" value="2"  <?php if($rdoQtyMar == 2) echo "checked"; ?> onClick="showGasMarket(2);" />&nbsp;&nbsp;</td>
                                                <td>Lumpsum&nbsp;<span style="font-size:10px; font-style:italic;">(USD)</span>&nbsp;&nbsp;</td>
                                                <td><input type="text" name="txtGASLumpsum" id="txtGASLumpsum" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun164();?>" placeholder="0.00" disabled="disabled" onKeyUp="getFinalCalculation();"/></td>
                                                <td>Quantity&nbsp;<span style="font-size:10px; font-style:italic;">(MT)</span>&nbsp;&nbsp;</td>
                                                <td><input type="text" name="txtGasCQMT" id="txtGasCQMT" class="input-text" size="13" autocomplete="off" value="<?php echo $obj->getFun163();?>" placeholder="0.00"  onkeyup="getFinalCalculation();" /></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                             </tr>
                                            </tbody>
                                        </table>                                           
                                       </td>
                                   </tr>
                                   
                                   <tr id="distypeDiv2" style="display:none;">
                                       <td colspan="2">    
									       <table width="100%">
											   <tr><td width="20%"><input name="rdoTankType" id="rdoTankType1" type="radio" style="cursor:pointer;" value="1" class="input-text"  <?php if($rdoTankQtyType == 1) echo "checked"; ?> onClick="showHideTankQtyVendorDiv(1);"  /> <strong>Single</strong></td>
											   <td width="20%"><input name="rdoTankType" id="rdoTankType2" type="radio" style="cursor:pointer;" value="2"  <?php if($rdoTankQtyType == 2) echo "checked"; ?> onClick="showHideTankQtyVendorDiv(2);"  /> <strong>Distributed</strong></td>
											   <td width="60%"></td>
											   </tr>
										   </table>
										   <div id="divTankDistributed">
											   <table width="100%">
														<tr>
														<td><strong style="font-size:12px;">Main Cargo Details</strong></td>
														<td class="input-text"></td>
														<td></td>
													   </tr>
													   </table>
											   <table id="maincargodetail" class='tablesorter' width="100%">
												<tbody id="tblmaincargodetail">
													<tr id="maincargodetailrow1_1">
													   <td>#</td>
													   <td><strong>Shipper/Charterer</strong></td>
													   <td><strong>Cargo</strong></td>
													   <td><strong>Cargo(CBM)</strong></td>
													   <td><strong>Cargo (MT)</strong></td>
													   <td><strong>Rate USD/MT</strong></td>
													   <td><strong>Amount(USD)</strong></td>
													</tr>
													<?php 
														$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS=1";
														$i = 0;
														$res1 = mysql_query($sql1);
														$num1 = mysql_num_rows($res1);
														if($num1==0)
														{$i =1;
														?>	 
													 <tr id="maincargodetailrow2_1">
													   <td width="50px;"></td>
													   <td><select name="selCharterers_1" class="input-text" style="width:120px;" id="selCharterers_1" onChange="getFinalCalculation();"></select></td>
													   <td><select name="selCargo_1" class="input-text" style="width:120px;" id="selCargo_1"></select></td>
													   <td><input type="text" name="txtCargocbm_1" id="txtCargocbm_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt_1" id="txtCargomt_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt_1" id="txtRateUSDmt_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD_1" id="txtAmountUSD_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers_1").html($("#selCharterer").html());$("#selCargo_1").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());</script>
													</tr>
													<?php }else{
														while($rows1 = mysql_fetch_assoc($res1)){$i++;?>
													  <tr id="maincargodetailrow2_<?php echo $i;?>">
													   <td width="50px;"><?php if($i>1){?><a href="#tb1" onClick="deleteMainCargoDetails(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a><?php }?></td>
													   <td><select name="selCharterers_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCharterers_<?php echo $i;?>" onChange="getFinalCalculation();"></select><input type="hidden" name="txtMSlaveRandomID_<?php echo $i;?>" id="txtMSlaveRandomID_<?php echo $i;?>" value="<?php echo $rows1['RANDOMID'];?>"/></td>
													   <td><select name="selCargo_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCargo_<?php echo $i;?>"></select></td>
													   <td><input type="text" name="txtCargocbm_<?php echo $i;?>" id="txtCargocbm_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_CBM'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt_<?php echo $i;?>" id="txtCargomt_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt_<?php echo $i;?>" id="txtRateUSDmt_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['RATE_USD_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD_<?php echo $i;?>" id="txtAmountUSD_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['AMOUNT_USD'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers_<?php echo $i;?>").html($("#selCharterer").html());$("#selCharterers_<?php echo $i;?>").val('<?php echo $rows1['SHIPPER_CHARTER'];?>');$("#selCargo_<?php echo $i;?>").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());$("#selCargo_<?php echo $i;?>").val(<?php echo $rows1['CARGOID'];?>);</script>
													</tr>  
													<?php }}?>
												</tbody>
													 
												<tfoot style="background-color:#fff;">
												  <tr><td ><button type="button" onClick="addMainCargoDetails();" >Add</button>
												  <input type="hidden" name="txtMainCargoDetailID" id="txtMainCargoDetailID" value="<?php echo $i;?>" /></td>
													  <td><strong>Total</strong></td>
													   <td></td>
													   <td><span id="spancargoCBM"></span></td>
													   <td><span id="spancargoMT"></span></td>
													   <td></td>
													   <td><span id="spanAmountUSD"></span></td>
													  </tr>
													</tfoot>
												</table>
								<!------------------------- Start 1----OVERAGE DETAILS------------------------------>
											   <table class='tablesorter' width="100%">
												  <tr><td><strong style="font-size:12px;">Overage</strong></td></tr>    
											   </table>
											   <table id="overagedetail" class='tablesorter' width="100%">
												<tbody id="tbloveragedetail">
													<tr id="overagedetailrow1_1">
													   <td>#</td>
													   <td><strong>Shipper/Charterer</strong></td>
													   <td><strong>Cargo</strong></td>
													   <td><strong>Cargo(CBM)</strong></td>
													   <td><strong>Cargo (MT)</strong></td>
													   <td><strong>Rate USD/MT</strong></td>
													   <td><strong>Amount(USD)</strong></td>
													</tr>
													<?php 
														$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS=2";
														$i = 1;
														$res1 = mysql_query($sql1);
														$num1 = mysql_num_rows($res1);
														if($num1==0)
														{$i =1;
														?>	 
													 <tr id="overagedetailrow2_1">
													   <td width="50px;"><a href="#tb1" onClick="deleteoveragedetail(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td><select name="selCharterers2_1" class="input-text" style="width:120px;" id="selCharterers2_1" onChange="getFinalCalculation();"></select></td>
													   <td><select name="selCargo2_1" class="input-text" style="width:120px;" id="selCargo2_1"></select></td>
													   <td><input type="text" name="txtCargocbm2_1" id="txtCargocbm2_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt2_1" id="txtCargomt2_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt2_1" id="txtRateUSDmt2_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD2_1" id="txtAmountUSD2_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers2_1").html($("#selCharterer").html());$("#selCargo2_1").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());</script>
													</tr>
													<?php }else{
														while($rows1 = mysql_fetch_assoc($res1)){$i++;?>
													  <tr id="overagedetailrow2_<?php echo $i;?>">
													   <td width="50px;"><a href="#tb1" onClick="deleteoveragedetail(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td><select name="selCharterers2_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCharterers2_<?php echo $i;?>" onChange="getFinalCalculation();"></select><input type="hidden" name="txtMSlaveRandomID2_<?php echo $i;?>" id="txtMSlaveRandomID2_<?php echo $i;?>" value="<?php echo $rows1['RANDOMID'];?>"/></td>
													   <td><select name="selCargo2_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCargo2_<?php echo $i;?>"></select></td>
													   <td><input type="text" name="txtCargocbm2_<?php echo $i;?>" id="txtCargocbm2_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_CBM'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt2_<?php echo $i;?>" id="txtCargomt2_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt2_<?php echo $i;?>" id="txtRateUSDmt2_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['RATE_USD_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD2_<?php echo $i;?>" id="txtAmountUSD2_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['AMOUNT_USD'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers2_<?php echo $i;?>").html($("#selCharterer").html());$("#selCharterers2_<?php echo $i;?>").val('<?php echo $rows1['SHIPPER_CHARTER'];?>');$("#selCargo2_<?php echo $i;?>").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());$("#selCargo2_<?php echo $i;?>").val(<?php echo $rows1['CARGOID'];?>);</script>
													</tr>  
													<?php }}?>
												</tbody>
													 
												<tfoot style="background-color:#fff;">
												  <tr><td ><button type="button" onClick="addoveragedetail();" >Add</button>
												  <input type="hidden" name="txtoveragedetailID" id="txtoveragedetailID" value="<?php echo $i;?>" /></td>
													  <td><strong>Total</strong></td>
													  <td></td>
													   <td><span id="spancargoCBM2"></span></td>
													   <td><span id="spancargoMT2"></span></td>
													   <td></td>
													   <td><span id="spanAmountUSD2"></span></td>
													  </tr>
													</tfoot>
												</table>
									<!------------------------- Start 1----DEAD FREIGHT DETAILS------------------------------>			
											   <table class='tablesorter' width="100%">
												  <tr><td><strong style="font-size:12px;">Dead-freight</strong></td></tr>    
											   </table>
											   <table id="deadfreightdetail" class='tablesorter' width="100%">
												<tbody id="tbldeadfreight">
						
													<tr id="deadfreightdetailrow1_1">
													   <td>#</td>
													   <td><strong>Shipper/Charterer</strong></td>
													   <td><strong>Cargo</strong></td>
													   <td><strong>Cargo(CBM)</strong></td>
													   <td><strong>Cargo (MT)</strong></td>
													   <td><strong>Rate USD/MT</strong></td>
													   <td><strong>Amount(USD)</strong></td>
													</tr>	 
													<?php 
														$sql1 = "select * from freight_cost_estimete_slave10 where FCAID='".$obj->getFun1()."' and STATUS=3";
														$i = 0;
														$res1 = mysql_query($sql1);
														$num1 = mysql_num_rows($res1);
														if($num1==0)
														{$i =1;
														?>	 
													 <tr id="deadfreightdetailrow2_1">
													   <td width="50px;"><a href="#tb1" onClick="deletedeadfreightdetail(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td><select name="selCharterers3_1" class="input-text" style="width:120px;" id="selCharterers3_1" onChange="getFinalCalculation();"></select></td>
													   <td><select name="selCargo3_1" class="input-text" style="width:120px;" id="selCargo3_1"></select></td>
													   <td><input type="text" name="txtCargocbm3_1" id="txtCargocbm3_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt3_1" id="txtCargomt3_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt3_1" id="txtRateUSDmt3_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD3_1" id="txtAmountUSD3_1" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers3_1").html($("#selCharterer").html());$("#selCargo3_1").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());</script>
													</tr>
													<?php }else{
														while($rows1 = mysql_fetch_assoc($res1)){$i++;?>
													  <tr id="deadfreightdetailrow2_<?php echo $i;?>">
													   <td width="50px;"><a href="#tb1" onClick="deletedeadfreightdetail(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td><select name="selCharterers3_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCharterers3_<?php echo $i;?>" onChange="getFinalCalculation();"></select><input type="hidden" name="txtMSlaveRandomID3_<?php echo $i;?>" id="txtMSlaveRandomID3_<?php echo $i;?>" value="<?php echo $rows1['RANDOMID'];?>"/></td>
													   <td><select name="selCargo3_<?php echo $i;?>" class="input-text" style="width:120px;" id="selCargo3_<?php echo $i;?>"></select></td>
													   <td><input type="text" name="txtCargocbm3_<?php echo $i;?>" id="txtCargocbm3_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_CBM'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtCargomt3_<?php echo $i;?>" id="txtCargomt3_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['CARGO_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtRateUSDmt3_<?php echo $i;?>" id="txtRateUSDmt3_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['RATE_USD_MT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtAmountUSD3_<?php echo $i;?>" id="txtAmountUSD3_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows1['AMOUNT_USD'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly style="background-color:#E1E1E1;"/></td>
													   <script>$("#selCharterers3_<?php echo $i;?>").html($("#selCharterer").html());$("#selCharterers3_<?php echo $i;?>").val('<?php echo $rows1['SHIPPER_CHARTER'];?>');$("#selCargo3_<?php echo $i;?>").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());$("#selCargo3_<?php echo $i;?>").val('<?php echo $rows1['CARGOID'];?>');</script>
													</tr>  
													<?php }}?>
													 
												</tbody>
													 
												<tfoot style="background-color:#fff;">
											  <tr><td ><button type="button" onClick="adddeadfreightdetail();" >Add</button>
											  <input type="hidden" name="txtdeadfreightdetailID" id="txtdeadfreightdetailID" value="<?php echo $i;?>" /></td>
												  <td><strong>Total</strong></td>
												  <td></td>
												   <td><span id="spancargoCBM3"></span></td>
												   <td><span id="spancargoMT3"></span></td>
												   <td></td>
												   <td><span id="spanAmountUSD3"></span></td>
												  </tr>
												</tfoot>
											</table>
										   </div>  
										   <div id="divTankSingle">
											   <table class='tablesorter' width="100%" id="divTanker1">
												   <tbody>
													<tr>
													<?php if($obj->getFun171()==1){$displayws1 = '';$displayws2 = 'none';}else{$displayws1 = 'none';$displayws2 = '';} ?>
														<td width="140px;"><span id="spanwsports1" style="display:<?php echo $displayws2;?>;">WS Port(s) Combo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
														<td width="60px;"><span id="spanwsports2" style="display:<?php echo $displayws2;?>;">From :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
														<script>
												$(document).ready(function($)
												{
													$("#selWSFPort").select2({
														minimumInputLength: 1,
														placeholder: '---Select from list---',
														allowClear: true,
														ajax: {
															url: "options.php?id=84",
															dataType: 'json',
															quietMillis: 100,
															data: function(term, page) {
																return {
																	limit: -1,
																	q: term
																};
															},
															results: function(data, page ) {
																return { results: data }
															}
														},
														formatResult: function(doc) { 
															return "<div class='select2-user-result'>" + doc.name + "</div>"; 
														},
														formatSelection: function(doc) { 
															return  doc.name; 
														}
													});
													
													$("#selWSTPort").select2({
														minimumInputLength: 1,
														placeholder: '---Select from list---',
														allowClear: true,
														ajax: {
															url: "options.php?id=84",
															dataType: 'json',
															quietMillis: 100,
															data: function(term, page) {
																return {
																	limit: -1,
																	q: term
																};
															},
															results: function(data, page ) {
																return { results: data }
															}
														},
														formatResult: function(doc) { 
															return "<div class='select2-user-result'>" + doc.name + "</div>"; 
														},
														formatSelection: function(doc) { 
															return  doc.name; 
														}
													});
												 $("#selWSFPort").select2("data", {id: <?php echo $obj->getFun165();?>, name: "<?php echo $obj->getPortNameBasedOnID($obj->getFun165());?>"});
												 $("#selWSTPort").select2("data", {id: <?php echo $obj->getFun166();?>, name: "<?php echo $obj->getPortNameBasedOnID($obj->getFun166());?>"});
												 });
												 
											</script>
														<td width="142px;"><span id="spanwsports3" style="display:<?php echo $displayws2;?>;">
														<input type="text" name="selWSFPort" id="selWSFPort" class="input-text" style="width:200px;" value=""/></span>
														</td>
														<td width="40px;"><span id="spanwsports4" style="display:<?php echo $displayws2;?>;">To :</span></td>
														<td width="152px;"><span id="spanwsports5" style="display:<?php echo $displayws2;?>;">
															<input type="text" name="selWSTPort" id="selWSTPort" class="input-text" style="width:200px;" value=""/></span>
														</td>
														
														<td width="150px;" align="right"><input name="ChkLumpsum" class="checkbox" id="ChkLumpsum" type="checkbox" value="1" <?php if($obj->getFun171()==1){echo 'checked';}else{} ?>/>&nbsp;&nbsp;&nbsp;&nbsp;Lump-sum(USD)</td>
														<td width="110px;" align="right"><span id="lumpsumspan1" style="display:<?php echo $displayws1;?>;">Cargo Qty(MT)&nbsp;&nbsp;:&nbsp;&nbsp;</span></td>
														<td width="130px;"><span id="lumpsumspan2" style="display:<?php echo $displayws1;?>;"><input type="text" name="txtLumpsumQty" id="txtLumpsumQty" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun173();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></span></td>
														<td width="50px;"><span id="lumpsumspan3" style="display:<?php echo $displayws1;?>;">Amount(USD)&nbsp;&nbsp;:&nbsp;&nbsp;</span></td>
														<td width="130px;"><span id="lumpsumspan4" style="display:<?php echo $displayws1;?>;"><input type="text" name="txtLumpsum" id="txtLumpsum" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun172();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></span></td>
														<td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
													</tr>
													
												  </tbody>
											  </table>
											  <div style="clear:both;"></div>
											   
											  <table class='tablesorter'  id="divTanker2"  width="100%" style="display:<?php echo $displayws2;?>;">
												<tbody id="tblTankerBody">
													<tr><td colspan="9"><div><strong style="font-size:13px;">Freight Adjustment</strong></div></td></tr>
												   <?php 
													$sql12 = "select * from freight_cost_estimete_slave12 where FCAID='".$obj->getFun1()."'";
													$res12 = mysql_query($sql12);
													$rec12 = mysql_num_rows($res12);
													if($rec12==0)
													{$num=1;
													?> 
													<tr id="tankRow1_1">
													   <td><a href="#tb1" onClick="deleteTankerDetails(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td>Freight Specs</td>
													   <td><input type="text" name="txtFreightSpecs_1" id="txtFreightSpecs_1" class="input-text" autocomplete="off" size="30" value="" placeholder="Freight Specs" onKeyUp="getFinalCalculation();"/></td>
													   <td>Flat Rate</td>
													   <td>WS</td>
													   <td>Distance Leg</td>
													   <td>Total Distance</td>
													   <td>Amount</td>
													   <td>Customer</td>
													 </tr>
													 <tr id="tankRow2_1">
													   <td></td>
													   <td>Min Cargo Qty</td>
													   <td><input type="text" name="txtMinCargoQty_1" id="txtMinCargoQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinFlatRateQty_1" id="txtMinFlatRateQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinWSQty_1" id="txtMinWSQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinDisLeg_1" id="txtMinDisLeg_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinTotalDis_1" id="txtMinTotalDis_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinAmount_1" id="txtMinAmount_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td>
															<select  name="selTankVendor_1" class="input-text" style="width:120px;" id="selTankVendor_1">
															</select>
														</td>
													   <script>$("#selTankVendor_1").html($("#selVendor").html());</script>
													</tr>
													<tr id="tankRow3_1">
													   <td></td>
													   <td>Overage Qty</td>
													   <td><input type="text" name="txtOveCargoQty_1" id="txtOveCargoQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveFlatRateQty_1" id="txtOveFlatRateQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveWSQty_1" id="txtOveWSQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveDisLeg_1" id="txtOveDisLeg_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveTotalDis_1" id="txtOveTotalDis_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveAmount_1" id="txtOveAmount_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td></td>
													</tr>	
													<tr id="tankRow4_1">
													   <td></td>
													   <td>Total Cargo Qty</td>
													   <td><input type="text" name="txtTotalTankQty_1" id="txtTotalTankQty_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" readonly/></td>
													   <td></td>
													   <td></td>
													   <td></td>
													   <td></td>
													   <td><input type="text" name="txtTotalTankAmount_1" id="txtTotalTankAmount_1" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" readonly/></td>
													   <td></td>
													</tr>
													<tr id="tankRow5_1"><td colspan="9">&nbsp;</td></tr>	
												<?php }
												else{$i = 0;$num=$rec12;
												while($rows12 = mysql_fetch_assoc($res12))
												{ 	 $i++;?>
												<tr id="tankRow1_<?php echo $i;?>">
													   <td><a href="#tb1" onClick="deleteTankerDetails(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
													   <td>Freight Specs</td>
													   <td><input type="text" name="txtFreightSpecs_<?php echo $i;?>" id="txtFreightSpecs_<?php echo $i;?>" class="input-text" autocomplete="off" size="30" value="<?php echo $rows12['FREIGHT_SPECS'];?>" placeholder="Freight Specs" onKeyUp="getFinalCalculation();"/></td>
													   <td>Flat Rate</td>
													   <td>WS</td>
													   <td>Distance Leg</td>
													   <td>Total Distance</td>
													   <td>Amount</td>
													   <td>Customer</td>
													 </tr>
													 <tr id="tankRow2_<?php echo $i;?>">
													   <td></td>
													   <td>Min Cargo Qty</td>
													   <td><input type="text" name="txtMinCargoQty_<?php echo $i;?>" id="txtMinCargoQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_CARGO_QTY'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinFlatRateQty_<?php echo $i;?>" id="txtMinFlatRateQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_FLAT_RATE'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinWSQty_<?php echo $i;?>" id="txtMinWSQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_WS'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinDisLeg_<?php echo $i;?>" id="txtMinDisLeg_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_DIS_LEG'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinTotalDis_<?php echo $i;?>" id="txtMinTotalDis_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_DISTANCE'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtMinAmount_<?php echo $i;?>" id="txtMinAmount_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['MIN_AMOUNT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td>
															<select  name="selTankVendor_<?php echo $i;?>" class="input-text" style="width:120px;" id="selTankVendor_<?php echo $i;?>">
															</select>
														</td>
													   <script>$("#selTankVendor_<?php echo $i;?>").html($("#selVendor").html());$("#selTankVendor_<?php echo $i;?>").val('<?php echo $rows12['CUSTOMER'];?>');</script>
													</tr>
													<tr id="tankRow3_<?php echo $i;?>">
													   <td></td>
													   <td>Overage Qty</td>
													   <td><input type="text" name="txtOveCargoQty_<?php echo $i;?>" id="txtOveCargoQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_CARGO_QTY'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveFlatRateQty_<?php echo $i;?>" id="txtOveFlatRateQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_FLAT_RATE'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveWSQty_<?php echo $i;?>" id="txtOveWSQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_WS'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveDisLeg_<?php echo $i;?>" id="txtOveDisLeg_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_DIS_LEG'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveTotalDis_<?php echo $i;?>" id="txtOveTotalDis_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_DISTANCE'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td><input type="text" name="txtOveAmount_<?php echo $i;?>" id="txtOveAmount_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['OVE_AMOUNT'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													   <td></td>
													</tr>	
													<tr id="tankRow4_<?php echo $i;?>">
													   <td></td>
													   <td>Total Cargo Qty</td>
													   <td><input type="text" name="txtTotalTankQty_<?php echo $i;?>" id="txtTotalTankQty_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['TOTAL_QTY'];?>" placeholder="0.00" readonly/></td>
													   <td></td>
													   <td></td>
													   <td></td>
													   <td></td>
													   <td><input type="text" name="txtTotalTankAmount_<?php echo $i;?>" id="txtTotalTankAmount_<?php echo $i;?>" class="input-text" autocomplete="off" size="13" value="<?php echo $rows12['TOTAL_AMOUNT'];?>" placeholder="0.00" readonly/></td>
													   <td></td>
													</tr>
													<tr id="tankRow5_<?php echo $i;?>"><td colspan="9">&nbsp;</td></tr>	
												
										  <?php }}?>
												</tbody>
												<tfoot>
												  <tr><th colspan="9" style="background-color:#ffffff;"><button type="button" onClick="addTankDetails()" >Add</button><input type="hidden" name="txtTankID" id="txtTankID" value="<?php echo $num;?>" /><input type="hidden" name="txtTankQuantity" id="txtTankQuantity" value="" /></th>
												  </tr>
												</tfoot>
											</table>
                                          </div>
                                           
                                       </td>
                                   </tr>
								   
								   
								   
                                   
                                      <tr id="distypeDiv3">
                                           <td colspan="2">
                                               <table width="100%">
                                                   <tr>
                                                       <td width="20%"><input name="rdoQtyType" id="rdoQtyType1" type="radio" style="cursor:pointer;" value="1" class="input-text"  <?php if($rdoQtyType == 1) echo "checked"; ?> onClick="showHideQtyVendorDiv(1);"  /> <strong>Single</strong></td>
                                                       <td width="20%"><input name="rdoQtyType" id="rdoQtyType2" type="radio" style="cursor:pointer;" value="2"  <?php if($rdoQtyType == 2) echo "checked"; ?> onClick="showHideQtyVendorDiv(2);"  /> <strong>Distributed</strong></td>
                                                       <td><div id="divQty2" <?php echo $display1;?>><textarea class="input-text" name="txtDistributedRemarks" id="txtDistributedRemarks" cols="50" rows="2" placeholder="Distributed Remarks ..." ><?php echo $obj->getFun156();?></textarea></div></td>
                                                   </tr>
                                               </table>
                                               
                                               
                                               <table id="divQty1" class='tablesorter' width="100%" <?php echo $display1;?>>
                                                <thead>
                                                    <tr>
                                                        <th>#</th>
                                                        <th>&nbsp;&nbsp;&nbsp;Customer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
														<th>&nbsp;&nbsp;&nbsp;Cargo&nbsp;&nbsp;&nbsp;</th>
                                                        <th>Agreed&nbsp;Gross Freight <span style="font-size:10px; font-style:italic;">(Local Currency/MT)</span></th>
                                                        <th>Currency&nbsp;&nbsp;&nbsp;&nbsp;</th>
                                                        <th>Exchange&nbsp;Rate</th>
                                                        <th>Agreed&nbsp;Gross Freight <span style="font-size:10px; font-style:italic;">(USD/MT)</span></th>
                                                        <th>Quantity&nbsp;<span style="font-size:10px; font-style:italic;">(MT)</span>&nbsp;</th>
                                                        <?php 
                                                        $sql12 = "select * from freight_cost_estimete_slave7 where FCAID='".$obj->getFun1()."'";
                                                        $res12 = mysql_query($sql12);
                                                        $rec12 = mysql_num_rows($res12);
                                                        ?>
                                                        <th>Gross&nbsp;Freight <span style="font-size:10px; font-style:italic;">(USD)</span><input type="hidden" name="txtQTYID" id="txtQTYID" value="<?php echo $rec12;?>" /></th>
                                                        <th>Final Net Freight <span style="font-size:10px; font-style:italic;">(USD)</span></th>
                                                    </tr>
                                                </thead>
                                                <tbody id="tblQtyFreight">	 
                                                <?php if($rec12==0)
                                                {?>
                                                   
                                                    <?php }
                                                    else
                                                    {$i = 0;
                                                    while($rows2 = mysql_fetch_assoc($res12))
                                                    {$i = $i + 1;
                                                    ?>
                                                    
                                                     <tr id="tbrQtyVRow_<?php echo $i;?>">
                                                     <td><a href="#tb'+id+'" onClick="deleteQtyVendorDetails(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtQtySlaveRandomID_<?php echo $i;?>" id="txtQtySlaveRandomID_<?php echo $i;?>" value="<?php echo $rows2['RANDOMID'];?>"/></td>
                                                     <td><select  name="selQtyVendorList_<?php echo $i;?>" class="input-text" style="width:120px;" id="selQtyVendorList_<?php echo $i;?>"></select></td>
													 <td><select name="selQtyCargo_<?php echo $i;?>" class="input-text" style="width:120px;" id="selQtyCargo_<?php echo $i;?>"></select></td>
                                                     <td><input type="text" name="txtQtyLocalAggriedFreight_<?php echo $i;?>" id="txtQtyLocalAggriedFreight_<?php echo $i;?>" class="input-text" style="width:100px;"  autocomplete="off" value="<?php echo $rows2['AGREED_GROSS_FREIGHT_LOCAL'];?>" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td>
                                                     <td><select  name="selCurrencyDisList_<?php echo $i;?>" class="input-text" style="width:100px;" id="selCurrencyDisList_<?php echo $i;?>"><?php $obj->getCurrencyList(); ?></select></td>
													 <script>
													 $(document).ready(function(){
														 $("#selQtyVendorList_<?php echo $i;?>").html($("#selVendor").html());
														 $("#selQtyVendorList_<?php echo $i;?>").val('<?php echo $rows2['QTY_VENDORID'];?>');
														 $("#selCurrencyDisList_<?php echo $i;?>").val('<?php echo $rows2['CURRENCYID'];?>');
														 $("#selQtyCargo_<?php echo $i;?>").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());
														 $("#selQtyCargo_<?php echo $i;?>").val('<?php echo $rows2['CARGO'];?>');
													 });	 
													</script>
                                                     <td><input type="text" name="txtDisExchangeRate_<?php echo $i;?>" id="txtDisExchangeRate_<?php echo $i;?>" class="input-text" style="width:100px;" autocomplete="off" value="<?php echo $rows2['EXCHANGE_RATE'];?>" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td>
                                                     <td><input type="text" name="txtQtyAggriedFreight_<?php echo $i;?>" id="txtQtyAggriedFreight_<?php echo $i;?>" class="input-text" style="width:100px;" autocomplete="off" value="<?php echo $rows2['AGREED_GROSS_FREIGHT'];?>" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td>
                                                     <td><input type="text" name="txtFreightQty_<?php echo $i;?>" id="txtFreightQty_<?php echo $i;?>" class="input-text" style="width:100px;" value="<?php echo $rows2['QUANTITY'];?>" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td>
                                                     <td><input type="text" name="txtQtyFreight_<?php echo $i;?>" id="txtQtyFreight_<?php echo $i;?>" class="input-text" style="width:100px;" value="<?php echo $rows2['GROSS_FREIGHT'];?>" readonly/></td>
                                                     <td><input type="text" name="txtQtyNetFreight_<?php echo $i;?>" style="width:100px;" id="txtQtyNetFreight_<?php echo $i;?>" placeholder="0.00" class="input-text" readonly value="<?php echo $rows2['NET_FREIGHT'];?>" /></td>
                                                     </tr>
                                                    <?php }}?>
                                                </tbody>
                                                <tfoot>
                                                  <tr><th><button type="button" onClick="addQtyVendorDetails()" >Add</button></th><th></th><th></th><th></th><th></th><th></th><th></th><th><input type="text" name="txtTotalFreightQty" id="txtTotalFreightQty" style="width:100px;" class="input-text" readonly value=""/></th><th><input type="text" name="txtTotalQtyFreight" id="txtTotalQtyFreight" style="width:100px;" class="input-text" readonly value=""/></th>
                                              
												  <th><input type="text"  name="txtTotalNetFreight" id="txtTotalNetFreight" autocomplete="off" style="width:100px;" class="input-text" readonly value="0.00" /></th>
												  </tr>
                                                </tfoot>
                                            </table>
                                             
                                            <table class='tablesorter' width="100%" id="divMarket3" <?php echo $display2;?>>
                                              <tbody>
                                                <tr>
                                                    <td><strong>Market</strong>&nbsp;&nbsp;</td>
                                                    <td><input name="rdoMMarket" class="checkbox" id="rdoMMarket1" type="radio" value="1"  <?php if($rdoMMarket == 1) echo "checked"; ?>  onclick="showMMarketField(1);"  /></td>
                                                    <td>Agreed Gross Freight <span style="font-size:10px; font-style:italic;">(USD/MT)</span>&nbsp;&nbsp;</td>
                                                    <td><input type="text" name="txtMTCPDRate" id="txtMTCPDRate" class="input-text" autocomplete="off" size="13" placeholder="0.00" value="<?php echo $obj->getFun47();?>" onKeyUp="getFinalCalculation();" /></td>
                                                    <td><input name="rdoMMarket" class="checkbox" id="rdoMMarket2" type="radio" value="2"  <?php if($rdoMMarket == 2) echo "checked"; ?> onClick="showMMarketField(2);" />&nbsp;&nbsp;</td>
                                                    <td>Lumpsum&nbsp;<span style="font-size:10px; font-style:italic;">(USD)</span>&nbsp;&nbsp;</td>
                                                    <td><input type="text" name="txtMLumpsum" id="txtMLumpsum" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun48();?>" placeholder="0.00" disabled="disabled" onKeyUp="getFinalCalculation();"/></td>
                                                    <td colspan="2">Addnl&nbsp;Cargo&nbsp;Rate&nbsp;<span style="font-size:10px; font-style:italic;">(USD/MT)</span>&nbsp;</td>
                                                    <td><input type="text"  name="txtAddnlCRate" id="txtAddnlCRate" class="input-text" autocomplete="off" size="13" value="<?php echo $obj->getFun49();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
                                                    
                                                    <td>Quantity&nbsp;<span style="font-size:10px; font-style:italic;">(MT)</span>&nbsp;&nbsp;</td>
                                                    <td><input type="text" name="txtCQMT" id="txtCQMT" class="input-text" size="13" autocomplete="off" value="<?php echo $obj->getFun50();?>" placeholder="0.00"  onkeyup="getFinalCalculation();" /></td>
                                                    <td></td>
                                                </tr>
                                                <tr><td colspan="13"></td></tr>
                                                <tr>
                                                    <td><input type="hidden" name="txtAQMT" id="txtAQMT" class="input-text" autocomplete="off" onKeyUp="getFinalCalculation();"/><span style="font-size:10px; font-style:italic; color:#dc631e">( Please put dead freight quantity<br/> / addnl quantity separately )</span></td>
                                                    <td><input name="rdoQty" class="checkbox" id="rdoQty1" type="radio" value="1"  <?php if($rdoQty == 1) echo "checked"; ?>  onclick="showQtyField(1);"  /></td>
                                                    <td>DF Qty <span style="font-size:10px; font-style:italic;">(MT)</span></td>
                                                    <td><input type="text" name="txtDFQMT" id="txtDFQMT" class="input-text" autocomplete="off" value="<?php echo $obj->getFun53();?>" placeholder="0.00" size="13"  onkeyup="getFinalCalculation();" /></td>
                                                    <td><input name="rdoQty" class="checkbox" id="rdoQty2" type="radio" value="2" <?php if($rdoQty == 2) echo "checked"; ?> onClick="showQtyField(2);" /></td>
                                                    <td>Addnl&nbsp;Qty<span style="font-size:10px; font-style:italic;">(MT)</span></td>
                                                    <td><input type="text" name="txtAddnlQMT" id="txtAddnlQMT" class="input-text" autocomplete="off" placeholder="0.00" value="<?php echo $obj->getFun54();?>" size="13" onKeyUp="getFinalCalculation();" disabled /></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td colspan="3"></td>
                                                    
                                                </tr>
                                              
                                                <tr>   
                                                    
                                                    <td colspan="2">Gross&nbsp;Freight&nbsp;&nbsp;<input type="text"  name="txtFrAdjUsdGF" id="txtFrAdjUsdGF" size="13" class="input-text" readonly value="<?php echo $obj->getFun66();?>" /><input type="text" style="display:none;" name="txtFrAdjUsdGFMT" id="txtFrAdjUsdGFMT" size="13" class="input-text" readonly value="<?php echo $obj->getFun70();?>" /></td>
                                                    <td>Dead Freight</td>
                                                    <td><input type="text"  name="txtFrAdjUsdDF" id="txtFrAdjUsdDF" size="13" class="input-text" readonly value="<?php echo $obj->getFun67();?>" /><input type="text" style="display:none;" name="txtFrAdjUsdDFMT" id="txtFrAdjUsdDFMT" size="13" class="input-text" readonly value="<?php echo $obj->getFun71();?>"/></td>
                                                    <td></td>
                                                    <td>Addnl Freight</td>
                                                    <td><input type="text"  name="txtFrAdjUsdAF" id="txtFrAdjUsdAF" size="13" class="input-text" readonly value="<?php echo $obj->getFun68();?>" /><input type="text" style="display:none;" name="txtFrAdjUsdAFMT" id="txtFrAdjUsdAFMT" class="input-text" readonly value="<?php echo $obj->getFun72();?>" /></td>
                                                    <td>Total Freight</td>
                                                    <td><input type="text"  name="txtFrAdjUsdTF" id="txtFrAdjUsdTF" size="13" class="input-text" readonly value="<?php echo $obj->getFun69();?>" /><input type="text" style="display:none;" name="txtFrAdjUsdTFMT" id="txtFrAdjUsdTFMT" class="input-text" readonly value="<?php echo $obj->getFun73();?>" /></td>
                                                    <td></td>
													<td></td>
													<td></td>
													<td></td>
                                                    <td style="display:none;">Net Freight Payable</td>
                                                    <td style="display:none;"><input type="text" size="13" name="txtFrAdjUsdFP" id="txtFrAdjUsdFP" class="input-text" readonly value="<?php echo $obj->getFun80();?>"   /></td>
                                                </tr>
                                                
                                                </tbody>
                                            </table>
                                           </td>
                                       </tr>
                                   </tbody>
                                </table>
                           </td>
                          </tr>
                       <tr><td colspan="2"><div><strong style="font-size:13px;">Passage & Ports</strong></div></td></tr>
					   <tr><td colspan="2">
					       <table class='tablesorter'>
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>From Port</th>
                                        <th>To Port</th>
                                        <th>Navigation Method</th>
                                        <th>Passage Type</th>
									    <th>Speed Type</th>
                                        <th>Fetch</th>
										<th>Total Dist</th>
										<th>Total Days</th>
										<th>SECA Dist</th>
										<th>SECA Days</th>
										<th>Wx Margin <span style="font-size:10px; font-style:italic;">(%)</span></th>
                                        
                                    </tr>
                                </thead>
                                <tbody id="tblPortRotation">
                                <?php 
								$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
								
								$res1 = mysql_query($sql1);
								$num1 = mysql_num_rows($res1);
								if($num1==0)
								{$num1 =1;
								?>
                                    <tr id="pr_Row_1">
                                        <td align="center" class="input-text" >
                                          <a href="#pr1" id="spcancel_1" onClick="removePortRotation(1);" ><i class="fa fa-times" style="color:red;"></i></a>
                                        </td>
										<script type="text/javascript">
										$(document).ready(function($)
											{
												$("#selFPort_1").select2({
													minimumInputLength: 1,
													placeholder: '---Select from list---',
													allowClear: true,
													ajax: {
														url: "options.php?id=83",
														dataType: 'json',
														quietMillis: 100,
														data: function(term, page) {
															return {
																limit: -1,
																q: term
															};
														},
														results: function(data, page ) {
															return { results: data }
														}
													},
													formatResult: function(doc) { 
														return "<div class='select2-user-result'>" + doc.name + "</div>"; 
													},
													formatSelection: function(doc) { 
														return  doc.name; 
													}
												}).on("change", function (e) {
													getPortText();
												});
												
												$("#selTPort_1").select2({
													minimumInputLength: 3,
													placeholder: '---Select from list---',
													allowClear: true,
													ajax: {
														url: "options.php?id=83",
														dataType: 'json',
														quietMillis: 100,
														data: function(term, page) {
															return {
																limit: -1,
																q: term
															};
														},
														results: function(data, page ) {
															return { results: data }
														}
													},
													formatResult: function(doc) { 
														return "<div class='select2-user-result'>" + doc.name + "</div>"; 
													},
													formatSelection: function(doc) { 
														return  doc.name; 
													}
												}).on("change", function (e) {
													getPortText();  
												});
												
											});
										</script>
                                        <td align="left" class="input-text" >
										   <input type="text" class="input-text" name="selFPort_1" id="selFPort_1" autocomplete="off" value=""/>
										   <input type="hidden" name="txtCordinates_1" id="txtCordinates_1" value=""/>
										</td>
										<td align="left" class="input-text" >
										   <input type="text" class="input-text" name="selTPort_1" id="selTPort_1" autocomplete="off" value=""/>
										</td>
										<td align="left" class="input-text" >
											<select  name="selDType_1" class="input-text" style="width:90px;" id="selDType_1" >
												<?php $obj->getPortDistanceType_new_new(); ?>
											</select>
										</td>
										<td align="left" class="input-text" >
											<select  name="selPType_1" class="input-text" style="width:90px;" id="selPType_1" onChange="getVoyageTime()"; >
												<?php $obj->getPassageType(); ?>
											</select>
										</td>
										<td align="left" class="input-text" >
											<select  name="selSSpeed_1" class="input-text" style="width:90px;" id="selSSpeed_1" onChange="getVoyageTime()"; >
												<?php $obj->getSelectSpeedList(); ?>
											</select>
										</td>
										<td align="left" class="input-text" >
											<button type="button" data-toggle="modal" data-target="#compose_modal_distance" class="btn-danger btn-flat" onClick="getShowModel(1);"><b>Fetch</b></button>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtDistance_1" id="txtDistance_1" style="width:60px;" class="input-text"  value="" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime();"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtTtlDays_1" id="txtTtlDays_1" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtSecaDistance_1" id="txtSecaDistance_1" style="width:60px;" class="input-text numeric" value="" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime();"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtSecaDays_1" id="txtSecaDays_1" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtMargin_1" style="width:60px;" id="txtMargin_1" class="input-text" autocomplete="off" placeholder="0.00"  onKeyUp="getVoyageTime()"; />
											<input type="hidden" name="txtVoyageTime_1" id="txtVoyageTime_1" class="input-text" autocomplete="off" value="0.00" />
											<input type="hidden" name="txtTTLVoyageDays_1" id="txtTTLVoyageDays_1" class="input-text" autocomplete="off" value="0.00" />
											<input type="hidden" name="txtTTLFoConsp_1" id="txtTTLFoConsp_1" class="input-text" readonly value="0.00"  />
											<input type="hidden" name="txtTTLDoConsp_1" id="txtTTLDoConsp_1" class="input-text" readonly value="0.00"  />
										</td>
                                    </tr>	
                                 <?php }
								  else
								  {$i=0;$num1 = $num1;
									  while($rows1 = mysql_fetch_assoc($res1))
									  {$i = $i + 1;
									  ?>
                                     <tr id="pr_Row_<?php echo $i;?>">
                                        <td align="center" class="input-text" >
                                          <a href="#pr<?php echo $i;?>" id="spcancel_1" onClick="removePortRotation(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtFCASlaveID_<?php echo $i;?>" id="txtFCASlaveID_<?php echo $i;?>" value="<?php echo $rows1['FCA_SLAVEID'];?>"/><input type="hidden" name="txtFCASlaveRandomID_<?php echo $i;?>" id="txtFCASlaveRandomID_<?php echo $i;?>" value="<?php echo $rows1['RANDOMID'];?>"/>
                                        </td>
										<script type="text/javascript">
										$(document).ready(function($)
											{
												$("#selFPort_<?php echo $i;?>").select2({
													minimumInputLength: 1,
													placeholder: '---Select from list---',
													allowClear: true,
													ajax: {
														url: "options.php?id=83",
														dataType: 'json',
														quietMillis: 100,
														data: function(term, page) {
															return {
																limit: -1,
																q: term
															};
														},
														results: function(data, page ) {
															return { results: data }
														}
													},
													formatResult: function(doc) { 
														return "<div class='select2-user-result'>" + doc.name + "</div>"; 
													},
													formatSelection: function(doc) { 
														return  doc.name; 
													}
												}).on("change", function (e) {
													getPortText();
												});
												
												$("#selTPort_<?php echo $i;?>").select2({
													minimumInputLength: 3,
													placeholder: '---Select from list---',
													allowClear: true,
													ajax: {
														url: "options.php?id=83",
														dataType: 'json',
														quietMillis: 100,
														data: function(term, page) {
															return {
																limit: -1,
																q: term
															};
														},
														results: function(data, page ) {
															return { results: data }
														}
													},
													formatResult: function(doc) { 
														return "<div class='select2-user-result'>" + doc.name + "</div>"; 
													},
													formatSelection: function(doc) { 
														return  doc.name; 
													}
												}).on("change", function (e) {
													getPortText();  
												});
												
												$("#selFPort_<?php echo $i;?>").select2("data", {id: <?php echo $rows1['FROM_PORT'];?>, name: "<?php echo $obj->getPortNameBasedOnID($rows1['FROM_PORT']);?>"});
												$("#selTPort_<?php echo $i;?>").select2("data", {id: <?php echo $rows1['TO_PORT'];?>, name: "<?php echo $obj->getPortNameBasedOnID($rows1['TO_PORT']);?>"});
											});
										</script>
                                        <td align="left" class="input-text" >
										   <input type="text" class="input-text" name="selFPort_<?php echo $i;?>" id="selFPort_<?php echo $i;?>" autocomplete="off" value=""/>
                                        </td>
                                        <td align="left" class="input-text" >
										   <input type="text" class="input-text" name="selTPort_<?php echo $i;?>" id="selTPort_<?php echo $i;?>" autocomplete="off" value=""/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selDType_<?php echo $i;?>" class="input-text" style="width:90px;" id="selDType_<?php echo $i;?>" >
                                                <?php $obj->getPortDistanceType_new(); ?>
                                            </select>
                                            <script>$("#selDType_<?php echo $i;?>").val(<?php echo $rows1['DIS_TYPE'];?>);</script>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selPType_<?php echo $i;?>" class="input-text" style="width:90px;" id="selPType_<?php echo $i;?>" onChange="getVoyageTime()"; >
                                                <?php $obj->getPassageType(); ?>
                                            </select>
                                            <script>$("#selPType_<?php echo $i;?>").val(<?php echo $rows1['PASSAGE_TYPE'];?>);</script>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selSSpeed_<?php echo $i;?>" class="input-text" style="width:90px;" id="selSSpeed_<?php echo $i;?>" onChange="getVoyageTime()"; >
                                                <?php $obj->getSelectSpeedList(); ?>
                                            </select>
                                            <script>$("#selSSpeed_<?php echo $i;?>").val(<?php echo $rows1['SPEED_TYPE'];?>);</script>
                                        </td> 
										<td align="left" class="input-text" >
											<button type="button" data-toggle="modal" data-target="#compose_modal_distance" class="btn-danger btn-flat" onClick="getShowModel(<?php echo $i;?>);"><b>Fetch</b></button>
										</td>
										<td align="left" class="input-text" >
                                            <input type="text" name="txtDistance_<?php echo $i;?>" id="txtDistance_<?php echo $i;?>" style="width:70px;" class="input-text"  value="<?php echo $rows1['DISTANCE'];?>" placeholder="0.00" onKeyUp="getVoyageTime()"; />
                                        </td>
                                        <td align="left" class="input-text" >
											<input type="text" name="txtTtlDays_<?php echo $i;?>" id="txtTtlDays_<?php echo $i;?>" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00" value="<?php echo $rows1['TOTAL_VOYAGE_DAYS'];?>"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtSecaDistance_<?php echo $i;?>" id="txtSecaDistance_<?php echo $i;?>" style="width:60px;" class="input-text numeric" value="<?php echo $rows1['SECA_DISTANCE'];?>" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime();"/>
										</td>
										<td align="left" class="input-text" >
											<input type="text" name="txtSecaDays_<?php echo $i;?>" id="txtSecaDays_<?php echo $i;?>" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00" value="<?php echo $rows1['SECA_DAYS'];?>"/>
										</td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtMargin_<?php echo $i;?>" style="width:60px;" id="txtMargin_<?php echo $i;?>" class="input-text" autocomplete="off" placeholder="0.00" value="<?php echo $rows1['MARGIN_DISTANCE'];?>" onKeyUp="getVoyageTime()"; />
                                            <input type="hidden" name="txtVoyageTime_<?php echo $i;?>" id="txtVoyageTime_<?php echo $i;?>" class="input-text" autocomplete="off" value="0.00" />
                                            <input type="hidden" name="txtTTLVoyageDays_<?php echo $i;?>" id="txtTTLVoyageDays_<?php echo $i;?>" class="input-text" autocomplete="off" value="0.00" />
                                            <input type="hidden" name="txtTTLFoConsp_<?php echo $i;?>" id="txtTTLFoConsp_<?php echo $i;?>" class="input-text" readonly value="0.00"  />
                                            <input type="hidden" name="txtTTLDoConsp_<?php echo $i;?>" id="txtTTLDoConsp_<?php echo $i;?>" class="input-text" readonly value="0.00"  />
                                        </td>
                                    </tr>  
                                      
                                 <?php }}
								  ?>									
                                </tbody>
                                <tfoot>
                                <tr>
                                <th colspan="12" style="background-color:#ffffff;"><button type="button" onClick="addPortRotationDetails()" >Add</button><input type="hidden" name="p_rotationID" id="p_rotationID" class="input" value="<?php echo $num1;?>" /></th>
                                </tr>
                                </tfoot>
                            </table>
					   </td></tr>
                       <tr>
                           <td width="55%" style="vertical-align:top;">
                          
                              
                            <table class='tablesorter'>
                                <thead>
                                    <tr>
                                        <th>Load Port(s)</th>
                                        <th>Port&nbsp;Costs<span style="font-size:10px; font-style:italic;">(USD)</span>&nbsp;</th>
                                        <th>Qty&nbsp;<span id="loadqtylabel">(MT)</span>&nbsp;&nbsp;</th>
                                        <th>Rate&nbsp;<span style="font-size:10px; font-style:italic;" id="loadtablelebel">(MT/Day)</span></th>
                                        <th>LP/Terms&nbsp;&nbsp;</th>
                                        <th>Work&nbsp;Days&nbsp;&nbsp;</th>
                                        <th>Idle&nbsp;Days&nbsp;</th>
                                        <th>No Dem/Disp?</th>
										<th>SECA ?</th>
                                    </tr>
                                </thead>
                                <tbody id="tblLoadPort">
                                <?php 
								$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
								
								$res1 = mysql_query($sql1);
								$num1 = mysql_num_rows($res1);
								if($num1==0)
								{$num1 =1;
								?>
                                    <tr id="lp_Row_1">
                                        <td align="center" class="input-text" >
                                            <span id="spanLoadPort_1"></span>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtPCosts_1" id="txtPCosts_1" style="width:80px;" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtQMT_1" id="txtQMT_1" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtRate_1" id="txtRate_1" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selLPTerms_1" class="input-text" id="selLPTerms_1" style="width:80px;" onChange="getLPRemoveDaysAttr(1),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtWDays_1" id="txtWDays_1" class="input-text" style="width:80px;" autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtIDays_1" id="txtIDays_1" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/>
                                        </td>
                                        <td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkShowDDCLP_1" class="checkbox" id="ChkShowDDCLP_1" type="checkbox" value="1" />
                                        </td>
										<td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkLPSECA_1" class="checkbox" id="ChkLPSECA_1" type="checkbox" value="1" />
                                        </td>
                                    </tr>
                                 <?php }
								 else
								  {$i=0;$num1 = $num1;
								  while($rows1 = mysql_fetch_assoc($res1))
								  {$i = $i + 1;
								  ?>
                                  <tr id="lp_Row_<?php echo $i;?>">
                                    <td align="center" class="input-text" >
                                        <span id="spanLoadPort_<?php echo $i;?>"><?php echo $obj->getPortNameBasedOnID($rows1['FROM_PORT']);?></span>
                                    </td>
                                    <td align="left" class="input-text" >
                                        <input type="text" name="txtPCosts_<?php echo $i;?>" id="txtPCosts_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" value="<?php echo $rows1['LOAD_PORT_COST'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/>
                                    </td>
                                    <td align="left" class="input-text" >
                                        <input type="text" name="txtQMT_<?php echo $i;?>" id="txtQMT_<?php echo $i;?>" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="<?php echo $rows1['LOAD_PORT_QTY'];?>" placeholder="0.00" />
                                    </td>
                                    <td align="left" class="input-text" >
                                        <input type="text" name="txtRate_<?php echo $i;?>" id="txtRate_<?php echo $i;?>" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="<?php echo $rows1['LOAD_PORT_RATE'];?>" placeholder="0.00" />
                                    </td>
                                    <td align="left" class="input-text" >
                                        <select  name="selLPTerms_<?php echo $i;?>" class="input-text" id="selLPTerms_<?php echo $i;?>" style="width:80px;" onChange="getLPRemoveDaysAttr(<?php echo $i;?>),getPortCalculation();"><?php $obj->getLPTermsList($rows1['LOAD_PORT_TERMS']);?></select>
                                    </td>
                                    <?php if($rows1['LOAD_PORT_TERMS']==4){$readonly="";}else{$readonly="readonly";}?>
                                    <td align="left" class="input-text" >
                                        <input type="text" name="txtWDays_<?php echo $i;?>" id="txtWDays_<?php echo $i;?>" class="input-text" style="width:80px;" <?php echo $readonly;?> autocomplete="off" value="<?php echo $rows1['LOAD_PORT_WORK_DAYS'];?>" onKeyUp= "getVoyageTime();" />
                                    </td>
                                    <td align="left" class="input-text" >
                                        <input type="text" name="txtIDays_<?php echo $i;?>" id="txtIDays_<?php echo $i;?>" class="input-text" style="width:80px;" autocomplete="off" value="<?php echo $rows1['LOAD_PORT_IDEAL_DAYS'];?>" placeholder="0.00" onKeyUp="getVoyageTime();"/>
                                    </td>
                                    <td align="left" class="input-text" style="width:80px;">
                                        <input name="ChkShowDDCLP_<?php echo $i;?>" class="checkbox" id="ChkShowDDCLP_<?php echo $i;?>" type="checkbox" <?php if($rows1['IS_SHOW_DDCLP'] > 0) echo "checked"; ?> value="<?php echo $i;?>" />
                                    </td>
									<td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkLPSECA_<?php echo $i;?>" class="checkbox" id="ChkLPSECA_<?php echo $i;?>" type="checkbox" value="1" <?php if($rows1['CHK_LP_SECA'] > 0) echo "checked"; ?>/>
                                    </td>
                                </tr>
                                  
                              <?php }}?>										
                                </tbody>
                              </table>
                              <table class='tablesorter'>
                                <thead>
                                    <tr>
                                        <th>Discharge Port</th>
                                        <th>Port&nbsp;Costs<span style="font-size:10px; font-style:italic;">(USD)</span>&nbsp;</th>
                                        <th>Qty&nbsp;<span id="dischargeqtylabel">(MT)</span></th>
                                        <th>Rate&nbsp;<span style="font-size:10px; font-style:italic;" id="dischargetablelebel">(MT/Day)</span>&nbsp;&nbsp;&nbsp;</th>
                                        <th>&nbsp;DP/Terms</th>
                                        <th>Work&nbsp;Days&nbsp;&nbsp;</th>
                                        <th>Idle&nbsp;Days&nbsp;</th>
                                        <th>No Dem/Disp?</th>
										<th>SECA ?</th>
                                    </tr>
                                </thead>
                                <tbody id="tblDisPort">
									<?php 
                                    $sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
                                    
                                    $res1 = mysql_query($sql1);
                                    $num1 = mysql_num_rows($res1);
                                    if($num1==0)
                                    {$num1 =1;
                                    ?>
                                    <tr id="dp_Row_1">
                                        <td align="center" class="input-text" >
                                            <span id="spanDisPort_1"></span>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDCosts_1" id="txtDCosts_1" style="width:80px;" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDQMT_1" id="txtDQMT_1" style="width:80px;" class="input-text" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDRate_1" id="txtDRate_1" style="width:80px;" class="input-text" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selDPTerms_1" class="input-text" style="width:80px;" id="selDPTerms_1" onChange="getDPRemoveDaysAttr(1),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDWDays_1" id="txtDWDays_1" style="width:80px;" class="input-text" autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDIDays_1" id="txtDIDays_1" style="width:80px;" class="input-text" autocomplete="off" value="" placeholder="0.00"  onKeyUp="getVoyageTime();"/>
                                        </td>
                                        <td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkShowDDCDP_1" class="checkbox" id="ChkShowDDCDP_1" type="checkbox" value="1" />
                                        </td>
										<td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkDPSECA_1" class="checkbox" id="ChkDPSECA_1" type="checkbox" value="1" />
                                        </td>
                                    </tr>
                                    <?php }
									 else
									  {$i=0;$num1 = $num1;
									  while($rows1 = mysql_fetch_assoc($res1))
									  {$i = $i + 1;
									 ?>
                                    <tr id="dp_Row_1">
                                        <td align="center" class="input-text" >
                                            <span id="spanDisPort_<?php echo $i;?>"><?php echo $obj->getPortNameBasedOnID($rows1['TO_PORT']);?></span>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDCosts_<?php echo $i;?>" id="txtDCosts_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" value="<?php echo $rows1['DISC_PORT_COST'];?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDQMT_<?php echo $i;?>" id="txtDQMT_<?php echo $i;?>" style="width:80px;" class="input-text" onKeyUp="getPortCalculation();" autocomplete="off" value="<?php echo $rows1['DISC_PORT_QTY'];?>" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDRate_<?php echo $i;?>" id="txtDRate_<?php echo $i;?>" style="width:80px;" class="input-text" onKeyUp="getPortCalculation();" autocomplete="off" value="<?php echo $rows1['DISC_PORT_RATE'];?>" placeholder="0.00" />
                                        </td>
                                        <td align="left" class="input-text" >
                                            <select  name="selDPTerms_<?php echo $i;?>" class="input-text" style="width:80px;" id="selDPTerms_<?php echo $i;?>" onChange="getDPRemoveDaysAttr(<?php echo $i;?>),getPortCalculation();"><?php $obj->getLPTermsList($rows1['DISC_PORT_TERMS']);?></select>
                                        </td>
                                        <?php if($rows1['DISC_PORT_TERMS']==4){$readonly="";}else{$readonly="readonly";}?>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDWDays_<?php echo $i;?>" id="txtDWDays_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" readonly value="<?php echo $rows1['DISC_PORT_WORK_DAYS'];?>" onKeyUp= "getVoyageTime();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtDIDays_<?php echo $i;?>" id="txtDIDays_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" value="<?php echo $rows1['DISC_PORT_IDEAL_DATE'];?>" placeholder="0.00"  onKeyUp="getVoyageTime();"/>
                                        </td>
                                        <td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkShowDDCDP_<?php echo $i;?>" class="checkbox" id="ChkShowDDCDP_<?php echo $i;?>" <?php if($rows1['IS_SHOW_DDCDP'] > 0) echo "checked"; ?> type="checkbox" value="<?php echo $i;?>" />
                                        </td>
										<td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkDPSECA_<?php echo $i;?>" class="checkbox" id="ChkDPSECA_<?php echo $i;?>" type="checkbox" value="1" <?php if($rows1['CHK_DP_SECA'] > 0) echo "checked"; ?>/>
                                        </td>
                                    </tr>
                                  <?php }}?>												
                                </tbody>
                                
                              </table>
                                 <table class='tablesorter'>
                                    <thead>
                                        <tr>
                                            <th>Transit Port</th>
                                            <th>Port Costs<span style="font-size:10px; font-style:italic;">(USD)</span></th>
                                            <th>Idle Days</th>
											<th>SECA ?</th>
                                        </tr>
                                    </thead>
                                    <tbody id="tblTransitPort">
                                        <?php 
										$sql1 = "select * from freight_cost_estimete_slave1 where FCAID='".$obj->getFun1()."'";
										
										$res1 = mysql_query($sql1);
										$num1 = mysql_num_rows($res1);
										if($num1==0)
										{$num1 =1;
										?>
                                        <tr id="tp_Row_1">
                                            <td align="center" class="input-text" >
                                                <span id="TranDisPort_1"></span>
                                            </td>
                                            <td align="left" class="input-text" >
                                                <input type="text" name="txtTLPCosts_1" id="txtTLPCosts_1" style="width:80px;" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();"/>
                                            </td>
                                            <td align="left" class="input-text" >
                                                <input type="text" name="txtTLIDays_1" id="txtTLIDays_1" style="width:80px;" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();"/>
                                            </td>
											<td align="left" class="input-text" style="width:80px;">
												<input name="ChkTPSECA_1" class="checkbox" id="ChkTPSECA_1" type="checkbox" value="1" />
											</td>
                                        </tr>
									<?php }
                                     else
                                      {$i=0;$num1 = $num1;
                                      while($rows1 = mysql_fetch_assoc($res1))
                                      {$i = $i + 1;
                                      ?>
                                      <tr id="tp_Row_<?php echo $i;?>">
                                        <td align="center" class="input-text" >
                                            <span id="TranDisPort_<?php echo $i;?>"><?php echo $obj->getPortNameBasedOnID($rows1['FROM_PORT']);?></span>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtTLPCosts_<?php echo $i;?>" id="txtTLPCosts_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" value="<?php echo $rows1['TRANSIT_PORT_COST'];?>" placeholder="0.00" onKeyUp="getPortCalculation();"/>
                                        </td>
                                        <td align="left" class="input-text" >
                                            <input type="text" name="txtTLIDays_<?php echo $i;?>" id="txtTLIDays_<?php echo $i;?>" style="width:80px;" class="input-text" autocomplete="off" value="<?php echo $rows1['TRANSIT_PORT_IDLE_DAYS'];?>" placeholder="0.00" onKeyUp="getPortCalculation();"/>
                                        </td>
										<td align="left" class="input-text" style="width:80px;">
                                            <input name="ChkTPSECA_<?php echo $i;?>" class="checkbox" id="ChkTPSECA_<?php echo $i;?>" type="checkbox" value="1" <?php if($rows1['CHK_TP_SECA'] > 0) echo "checked"; ?>/>
                                        </td>
                                    </tr>	
                                      <?php }}?>															
                                    </tbody>
                                </table>
                                
                                <table>
                                  <tr class="input-text">
                                     <td>Laden Dist</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtLDist" id="txtLDist" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun55();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Ballast Dist</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtBDist" id="txtBDist" style="width:100px;" class="input-text" readonly value="<?php echo $obj->getFun56();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Total Dist</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTDist" id="txtTDist" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun63();?>" /></td>
                                  </tr>
                                  <tr class="input-text">
                                     <td>Laden Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtLDays" id="txtLDays" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun57();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Ballast Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtBDays" id="txtBDays" style="width:100px;" class="input-text" readonly value="<?php echo $obj->getFun58();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Total Sea Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTSDays" id="txtTSDays" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun59();?>" /></td>
                                  </tr>
                                  <tr class="input-text">
                                     <td>Ttl Port Idle Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTtPIDays" id="txtTtPIDays" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun60();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Ttl Port Work Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTtPWDays" id="txtTtPWDays" style="width:100px;" class="input-text" readonly value="<?php echo $obj->getFun61();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Total Days</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTDays" id="txtTDays" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun62();?>" /></td>
                                  </tr>
                                  <tr class="input-text">
                                     <td>Ttl FO Consp MT</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTFUMT" id="txtTFUMT" class="input-text" style="width:100px;" readonly value="<?php echo $obj->getFun64();?>" /></td><td>&nbsp;&nbsp;&nbsp;&nbsp;Ttl DO Consp MT</td><td>&nbsp;:&nbsp;</td><td><input type="text" name="txtTDUMT" id="txtTDUMT" style="width:100px;" class="input-text" readonly value="<?php echo $obj->getFun65();?>" /></td><td></td><td></td><td></td>
                                  </tr>
                                </table>
                                <div><strong style="font-size:13px;">Demurrage Dispatch</strong></div>
								    <table class='tablesorter'>
										<thead>
											<tr>
												<th width="20%"></th>
												<th width="15%">Estimated(USD)</th>
                                                <th width="15%">Actual(USD)</th>
                                                <th width="15%">Add Comm(%)</th>
												<th width="15%">Nett Value(USD)</th>
											</tr>
										</thead>
										<tbody id="tbDDCBody">
                                        
                                        <?php 
											$mysql2 = "select * from freight_cost_estimete_slave1 where FCAID='".$id."'";
											$myres2 = mysql_query($mysql2);
											$myrec2 = mysql_num_rows($myres2);
											if($myrec2 ==0)
											{?>
										      <tr id="DDCLProw_1"> 
												<td>Load Port <span id="spanDDCLPort_1"></span></td>
												<td><input type="text"  name="txtEstDDCLPCost_1" id="txtEstDDCLPCost_1" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /><input type="hidden" name="txtLPLayTimeIs_1" id="txtLPLayTimeIs_1" value="" /></td>
												<td><input type="text"  name="txtDDCLPCost_1" id="txtDDCLPCost_1" class="input-text" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtLPADDComm_1" id="txtLPADDComm_1" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td>
                                                <td><input type="text" name="txtDDCLPNetCostMT_1" id="txtDDCLPNetCostMT_1" class="input-text" readonly value="" /><input type="hidden" name="txtDDCLPCostMT_1" id="txtDDCLPCostMT_1" class="input-text" readonly value="0" /></td>
                                              </tr>	
                                              <tr id="DDCDProw_1"> 
												<td>Discharge Port <span id="spanDDCDPort_1"></span></td>
												<td><input type="text"  name="txtEstDDCDPCost_1" id="txtEstDDCDPCost_1" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /><input type="hidden" name="txtDPLayTimeIs_1" id="txtDPLayTimeIs_1" value="" /></td>
												<td><input type="text"  name="txtDDCDPCost_1" id="txtDDCDPCost_1" class="input-text" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtDPADDComm_1" id="txtDPADDComm_1" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td>
                                                <td><input type="text" name="txtDDCDPNetCostMT_1" id="txtDDCDPNetCostMT_1" class="input-text" readonly value="" /><input type="hidden" name="txtDDCDPCostMT_1" id="txtDDCDPCostMT_1" class="input-text" readonly value="0" /></td>
											 </tr>
									 <?php }
											else
											{$i=1;
											while($myrows2 = mysql_fetch_assoc($myres2))
											{
											$laytime_valLP = $obj->getLayTimeValuesBasedOnComID($mappingid,$myrows2['LOADPORTID'],"LP",$i);
											$laytime_valLP = explode('@#@',$laytime_valLP);
											if($laytime_valLP[1]== 0){$laytimeLP = $laytime_valLP[2];}else{$laytimeLP = $laytime_valLP[1];}
											if($laytime_valLP[0]== 0){$readonlyLP = "";}else{$readonlyLP = "readonly";}
											
											$laytime_valDP = $obj->getLayTimeValuesBasedOnComID($comid,$myrows2['LOADPORTID'],"DP",$i);
											$laytime_valDP = explode('@#@',$laytime_valDP);
											if($laytime_valDP[1]== 0){$laytimeDP = $laytime_valDP[2];}else{$laytimeDP = $laytime_valDP[1];}
											if($laytime_valDP[0]== 0){$readonlyDP = "";}else{$readonlyDP = "readonly";}
											if($myrows2['IS_SHOW_DDCDP'] > 0){$display1 = 'style="display:none;"';}else{$display1 = '';}
											if($myrows2['IS_SHOW_DDCLP'] > 0){$display2 = 'style="display:none;"';}else{$display2 = '';}
											?>
											<tr id="DDCLProw_<?php echo $i;?>" <?php echo $display2;?>> 
												<td>Load Port <span id="spanDDCLPort_<?php echo $i;?>"><?php echo $obj->getPortNameBasedOnID($myrows2['FROM_PORT']);?></span></td>
												<td><input type="text"  name="txtEstDDCLPCost_<?php echo $i;?>" id="txtEstDDCLPCost_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCLP_ESTCOST'];?>" autocomplete="off" onKeyUp="getFinalCalculation();" <?php echo $readonlyLP;?>/><input type="hidden" name="txtLPLayTimeIs_<?php echo $i;?>" id="txtLPLayTimeIs_<?php echo $i;?>" value="<?php echo $laytime_valLP[0];?>" /></td>
												
												<td><input type="text"  name="txtDDCLPCost_<?php echo $i;?>" id="txtDDCLPCost_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCLP_REALCOST'];?>" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtLPADDComm_<?php echo $i;?>" id="txtLPADDComm_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCLP_COMM'];?>" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td>
                                                <?php $omcvalueLP = $myrows2['DDCLP_ESTCOST'] - (($myrows2['DDCLP_ESTCOST'] * $myrows2['DDCLP_COMM'])/100);?>
												<td><input type="text" name="txtDDCLPNetCostMT_<?php echo $i;?>" id="txtDDCLPNetCostMT_<?php echo $i;?>" class="input-text" readonly value="<?php echo $omcvalueLP;?>" /><input type="hidden" name="txtDDCLPCostMT_<?php echo $i;?>" id="txtDDCLPCostMT_<?php echo $i;?>" class="input-text" readonly value="<?php echo $myrows2['DDCLP_NETCOST'];?>" /></td>
                                              </tr>	
                                              <tr id="DDCDProw_<?php echo $i;?>" <?php echo $display1;?>> 
												<td>Discharge Port <span id="spanDDCDPort_<?php echo $i;?>"><?php echo $obj->getPortNameBasedOnID($myrows2['TO_PORT']);?></span></td>
												<td><input type="text"  name="txtEstDDCDPCost_<?php echo $i;?>" id="txtEstDDCDPCost_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCDP_ESTCOST'];?>" autocomplete="off" onKeyUp="getFinalCalculation();" <?php echo $readonlyDP;?>/><input type="hidden" name="txtDPLayTimeIs_<?php echo $i;?>" id="txtDPLayTimeIs_<?php echo $i;?>" value="<?php echo $laytime_valDP[0];?>" /></td>
												
												<td><input type="text"  name="txtDDCDPCost_<?php echo $i;?>" id="txtDDCDPCost_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCDP_REALCOST'];?>" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtDPADDComm_<?php echo $i;?>" id="txtDPADDComm_<?php echo $i;?>" class="input-text" value="<?php echo $myrows2['DDCDP_COMM'];?>" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td>
                                                <?php $omcvalueDP = $myrows2['DDCDP_ESTCOST'] - (($myrows2['DDCDP_ESTCOST'] * $myrows2['DDCDP_COMM'])/100);?>
												<td><input type="text" name="txtDDCDPNetCostMT_<?php echo $i;?>" id="txtDDCDPNetCostMT_<?php echo $i;?>" class="input-text" readonly value="<?php echo $omcvalueDP;?>" /><input type="hidden" name="txtDDCDPCostMT_<?php echo $i;?>" id="txtDDCDPCostMT_<?php echo $i;?>" class="input-text" readonly value="<?php echo $myrows2['DDCDP_NETCOST'];?>" /></td>
                                              </tr>		
									<?php $i++;}} ?>
                                        
                                        
                                        
										    	
									 	</tbody>
									</table>
                                    
                                    <?php if($_SESSION['selBType']==1 || $_SESSION['selBType']==3){?>
                                    <div><strong style="font-size:13px;">Comparision</strong></div>
								    <table class='tablesorter'>
                                        <thead>
											<tr>
												<th width="40%" style="background-color:#8d8a8a;"></th>
												<th width="20%" style="background-color:#8d8a8a;">Floating</th>
                                                <th width="20%" style="background-color:#8d8a8a;">Fixed</th>
                                                <th width="20%" style="background-color:#8d8a8a;">Average</th>
											</tr>
										</thead>
										<tbody>
                                            <tr>
                                                <td>Base Rate</td>
                                                <td><input type="text"  name="txtBaseRateFloating" id="txtBaseRateFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun176();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtBaseRateFixed" id="txtBaseRateFixed" style="width:100px;" readonly class="input-text numeric" onKeyUp="getFinalCalculation();" value="<?php echo $obj->getFun177();?>" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtBaseRateAverage" id="txtBaseRateAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun178();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Gross Freight</td>
                                                <td><input type="text"  name="txtGFreightFloating" id="txtGFreightFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun179();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtGFreightFixed" id="txtGFreightFixed" style="width:100px;" readonly class="input-text numeric" value="<?php echo $obj->getFun180();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtGFreightAverage" id="txtGFreightAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun181();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Net Freight</td>
                                                <td><input type="text"  name="txtNFreightFloating" id="txtNFreightFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun182();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtNFreightFixed" id="txtNFreightFixed" style="width:100px;" readonly class="input-text numeric" value="<?php echo $obj->getFun183();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtNFreightAverage" id="txtNFreightAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun184();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Total Owner Expenses</td>
                                                <td><input type="text"  name="txtOExpensesFloating" id="txtOExpensesFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun185();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtOExpensesFixed" id="txtOExpensesFixed" style="width:100px;" readonly class="input-text numeric" value="<?php echo $obj->getFun186();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtOExpensesAverage" id="txtOExpensesAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun187();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Voyage Earnings <span style="font-size:10px; font-style:italic;">((Frt + Dem))</span></td>
                                                <td><input type="text"  name="txtVEarningFloating" id="txtVEarningFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun188();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtVEarningFixed" id="txtVEarningFixed" style="width:100px;" readonly class="input-text numeric" value="<?php echo $obj->getFun189();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtVEarningAverage" id="txtVEarningAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun190();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <?php if($_SESSION['selBType']==1){$readonlytr = 'readonly';$displaytr = '';$border_textbox='';}?>
                                            <?php if($_SESSION['selBType']==3){$readonlytr = '';$displaytr = 'style="display:none;"';$border_textbox='border:1px solid #F00;';}?>
                                            <tr>
                                                <td>Gross Daily TCE</td>
                                                <td><input type="text"  name="txtDailyEarningFloating" id="txtDailyEarningFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun191();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtDailyEarningFixed" id="txtDailyEarningFixed" style="width:100px;<?php echo $border_textbox;?>" <?php echo $readonlytr;?> class="input-text numeric" value="<?php echo $obj->getFun192();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtDailyEarningAverage" id="txtDailyEarningAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun193();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr <?php echo $displaytr;?>>
                                                <td>TCE Per Calender Month</td>
                                                <td><input type="text"  name="txtTCEMonthFloating" id="txtTCEMonthFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun194();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtTCEMonthFixed" id="txtTCEMonthFixed" class="input-text numeric" style="width:100px; border:1px solid #F00;" value="<?php echo $obj->getFun195();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtTCEMonthAverage" id="txtTCEMonthAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun196();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Daily Vessel Operation Expenses(Technical)</td>
                                                <td><input type="text"  name="txtOPExpensesFloating" id="txtOPExpensesFloating" class="input-text numeric" style="width:100px; border:1px solid #F00;" onKeyUp="getFinalCalculation();" value="<?php echo $obj->getFun197();?>" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtOPExpensesFixed" id="txtOPExpensesFixed" style="width:100px;" class="input-text numeric" readonly value="<?php echo $obj->getFun198();?>" onKeyUp="getFinalCalculation();" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtOPExpensesAverage" id="txtOPExpensesAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun199();?>" readonly autocomplete="off"/></td>
                                            </tr>
                                            <tr>
                                                <td>Nett Daily TCE</td>
                                                <td><input type="text"  name="txtNetDailyProfitFloating" id="txtNetDailyProfitFloating" style="width:100px;" class="input-text" value="<?php echo $obj->getFun203();?>" readonly autocomplete="off"/></td>
                                                <td><input type="text"  name="txtNetDailyProfitFixed" id="txtNetDailyProfitFixed" style="width:100px;" class="input-text" onKeyUp="getFinalCalculation();" value="<?php echo $obj->getFun204();?>" autocomplete="off"/></td>
                                                <td><input type="text"  name="txtNetDailyProfitAverage" id="txtNetDailyProfitAverage" style="width:100px;" class="input-text" value="<?php echo $obj->getFun205();?>" readonly autocomplete="off"/></td>
                                            </tr>
									 	</tbody>
									</table>
                                    <?php }?>
                                    
                           </td>
                           <td width="45%">
                               
                                <div><strong style="font-size:13px;">Bunkers Consumed (Estimated)</strong></div>
                                <table width="100%" class='tablesorter'>
								    <tbody>
                                        <tr>
										   <td>Bunker Grade</td>
										   <td>Consp(MT)</td>
										   <td>Used ?</td>
										   <td>Price (USD)</td>
										   <td>Amount(USD)</td>
										</tr>
										<tr>
										    <td colspan="5"><strong>SECA</strong></td>
										</tr>
										
									</tbody>
                                    <tbody id="ConbunkerEstimatedTBodySECA">
                                        <?php $sql_bunk = "select FCAID, BUNKERGRADEID, EST_MT, EST_PRICE, EST_COST, IDENTIFY, CHK_IF_CAL, BUNKER_TYPE from freight_cost_estimete_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='SECA'";
										$res_bunk = mysql_query($sql_bunk);
										$num_bunk = mysql_num_rows($res_bunk);
										if($num_bunk==0)
										{?>
										
									  <?php }else{ $bunk = 0;
										  while($rows_bunk = mysql_fetch_assoc($res_bunk))
										  {$bunk++;
										  ?>
									   <tr>
											<td><input type="hidden" name="txtSECABunkerid_<?=$bunk?>" id="txtSECABunkerid_<?=$bunk?>" value="<?=$rows_bunk['BUNKERGRADEID'];?>"/><?=$obj->getBunkerGradeBasedOnID($rows_bunk['BUNKERGRADEID']);?><input type="hidden" name="txtSECAIdentify_<?=$bunk?>" id="txtSECAIdentify_<?=$bunk?>" value="<?=$rows_bunk['BUNKER_TYPE'];?>"/></td>
											<td><input type="text" name="txtSECABunkerQty_<?=$bunk?>" id="txtSECABunkerQty_<?=$bunk?>" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value="<?=$rows_bunk['EST_MT'];?>"></td>
											<td align="left" class="input-text" ><input name="ChkSECACalBunker_<?=$bunk?>" class="checkbox" id="ChkSECACalBunker_<?=$bunk?>" type="checkbox" value="<?=$bunk?>" <?php if($rows_bunk['CHK_IF_CAL']>=1){?>checked<?php }?>/></td>
											<td><input type="text" name="txtSECABunkerPrice_<?=$bunk?>" id="txtSECABunkerPrice_<?=$bunk?>" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?=$rows_bunk['EST_PRICE'];?>"></td>
											<td><input type="text" name="txtSECABunkerAmt_<?=$bunk?>" id="txtSECABunkerAmt_<?=$bunk?>" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value="<?=$rows_bunk['EST_COST'];?>"></td>
										</tr>
									  <?php }$num_bunk =$bunk; }?>							
                                    </tbody>
									<tbody>
									    <tr>
										    <td colspan="4"><strong>Total Bunker Consumed - SECA <input type="hidden" name="txtSECAConBunkerCount" id="txtSECAConBunkerCount" value="<?=$num_bunk;?>"/></strong></td>
											<td><input type="text"  name="txtTotalSECAConsumption" id="txtTotalSECAConsumption" style="width:90px;" class="input-text" value="" readonly autocomplete="off"/></td>
										</tr>
									    <tr>
										    <td colspan="5"><strong>Non-SECA</strong></td>
										</tr>
								    </tbody>
									<tbody id="ConbunkerEstimatedTBodyNONSECA">
                                        <?php $sql_bunk = "select FCAID, BUNKERGRADEID, EST_MT, EST_PRICE, EST_COST, IDENTIFY, CHK_IF_CAL, BUNKER_TYPE from freight_cost_estimete_slave2 where FCAID='".$obj->getFun1()."' and IDENTIFY='NON_SECA'";
										$res_bunk = mysql_query($sql_bunk);
										$num_bunk = mysql_num_rows($res_bunk);
										if($num_bunk==0)
										{?>
										
									  <?php }else{ $bunk = 0;
										  while($rows_bunk = mysql_fetch_assoc($res_bunk))
										  {$bunk++;
										  ?>
									   <tr>
											<td><input type="hidden" name="txtNONSECABunkerid_<?=$bunk?>" id="txtNONSECABunkerid_<?=$bunk?>" value="<?=$rows_bunk['BUNKERGRADEID'];?>"/><?=$obj->getBunkerGradeBasedOnID($rows_bunk['BUNKERGRADEID']);?><input type="hidden" name="txtNONSECAIdentify_<?=$bunk?>" id="txtNONSECAIdentify_<?=$bunk?>" value="<?=$rows_bunk['BUNKER_TYPE'];?>"/></td>
											<td><input type="text" name="txtNONSECABunkerQty_<?=$bunk?>" id="txtNONSECABunkerQty_<?=$bunk?>" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value="<?=$rows_bunk['EST_MT'];?>"></td>
											<td align="left" class="input-text" ><input name="ChkNONSECACalBunker_<?=$bunk?>" class="checkbox" id="ChkNONSECACalBunker_<?=$bunk?>" type="checkbox" value="<?=$bunk?>" <?php if($rows_bunk['CHK_IF_CAL']>=1){?>checked<?php }?>/></td>
											<td><input type="text" name="txtNONSECABunkerPrice_<?=$bunk?>" id="txtNONSECABunkerPrice_<?=$bunk?>" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?=$rows_bunk['EST_PRICE'];?>"></td>
											<td><input type="text" name="txtNONSECABunkerAmt_<?=$bunk?>" id="txtNONSECABunkerAmt_<?=$bunk?>" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value="<?=$rows_bunk['EST_COST'];?>"></td>
										</tr>
									  <?php }$num_bunk =$bunk; }?>							
                                    </tbody>
									<tbody>
									    <tr>
										    <td colspan="4"><strong>Total Bunker Consumed - Non-SECA <input type="hidden" name="txtNONSECAConBunkerCount" id="txtNONSECAConBunkerCount" value="<?=$num_bunk;?>"/></strong></td>
											<td><input type="text"  name="txtTotalNONSECAConsumption" id="txtTotalNONSECAConsumption" style="width:90px;" class="input-text" value="" readonly autocomplete="off"/></td>
										</tr>
									</tbody>
                                </table>
                             
                                <div><strong style="font-size:13px;">Bunkers Consumed</strong></div>
                                <table width="100%" class='tablesorter'>
								  <tr>
								    <td></td>
									<td>Bunker Grade</td>
									<td>Qty(MT)</td>
									<td>Price(USD)</td>
									<td>Amount(USD)</td>
									</tr>
									<tbody id="ConbunkerTBody">
                                    <?php $sql_bunk = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."' and IDENTIFY='CONSUMPTION'";
									$res_bunk = mysql_query($sql_bunk);
									$num_bunk = mysql_num_rows($res_bunk);
									if($num_bunk==0)
									{$num_bunk =1;?>
							  		<tr id="DivConBunkeractual_1">
									<td><a href="#tb1'" onClick="removeConBunkerRows(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selConBunker_1" id="selConBunker_1" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtConBunkerQty_1" id="txtConBunkerQty_1" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtConBunkerPrice_1" id="txtConBunkerPrice_1" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtConBunkerAmt_1" id="txtConBunkerAmt_1" style="width:90px;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value=""/></td>
								  </tr>
                                  <?php }else{ $bunk = 0;
									  while($rows_bunk = mysql_fetch_assoc($res_bunk))
									  {$bunk++;
									  ?>
								   <tr id="DivConBunkeractual_<?php echo $bunk;?>">
									<td><a href="#tb<?php echo $bunk;?>'" onClick="removeConBunkerRows(<?php echo $bunk;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selConBunker_<?php echo $bunk;?>" id="selConBunker_<?php echo $bunk;?>" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtConBunkerQty_<?php echo $bunk;?>" id="txtConBunkerQty_<?php echo $bunk;?>" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['QTY'];?>"/></td>
									<td><input type="text" name="txtConBunkerPrice_<?php echo $bunk;?>" id="txtConBunkerPrice_<?php echo $bunk;?>" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['PRICE'];?>"/></td>
									<td><input type="text" name="txtConBunkerAmt_<?php echo $bunk;?>" id="txtConBunkerAmt_<?php echo $bunk;?>" style="width:90px;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value="<?php echo $rows_bunk['COST'];?>"/></td>
								  </tr>
                                  <script>$("#selConBunker_<?php echo $bunk;?>").val('<?php echo $rows_bunk['BUNKERGRADEID'];?>');</script>
                                  <?php }$num_bunk =$bunk; }?>
								</tbody>
								  <tr>
									<td colspan="5"><button type="button" onClick="addConBunkerRow()">Add</button><input type="hidden" name="txtConBunkerCount" id="txtConBunkerCount" value="<?php echo $num_bunk;?>"/></td>
								  </tr>
								</table>
                                <div><strong style="font-size:13px;">Bunkers Supplied</strong></div>
                                <table width="100%" class='tablesorter'>
								  <tr>
								    <td></td>
									<td>Bunker Grade</td>
									<td>Qty(MT)</td>
									<td>Price(USD)</td>
									<td>Amount(USD)</td>
                                    <td>Port</td>
									<td>Vendor</td>
									</tr>
									<tbody id="bunkerTBody">
                                    <?php $sql_bunk = "select * from freight_cost_estimete_slave8 where FCAID='".$obj->getFun1()."' and IDENTIFY='SUPPLY'";
									$res_bunk = mysql_query($sql_bunk);
									$num_bunk = mysql_num_rows($res_bunk);
									if($num_bunk==0)
									{$num_bunk =1;?>
							  		<tr id="DivBunkeractual_1">
									<td><a href="#tb1'" onClick="removeBunkerRows(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selBunker_1" id="selBunker_1" style="width:100px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtBunkerQty_1" id="txtBunkerQty_1" style="width:95px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtBunkerPrice_1" id="txtBunkerPrice_1" style="width:95px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
									<td><input type="text" name="txtBunkerAmt_1" id="txtBunkerAmt_1" style="width:95px;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value=""/></td>
									<script>
										$(document).ready(function($)
										{
											$("#selBunkerPort_1").select2({
												minimumInputLength: 1,
												placeholder: '---Select from list---',
												allowClear: true,
												ajax: {
													url: "options.php?id=84",
													dataType: 'json',
													quietMillis: 100,
													data: function(term, page) {
														return {
															limit: -1,
															q: term
														};
													},
													results: function(data, page ) {
														return { results: data }
													}
												},
												formatResult: function(doc) { 
													return "<div class='select2-user-result'>" + doc.name + "</div>"; 
												},
												formatSelection: function(doc) { 
													return  doc.name; 
												}
											});
										});
                                    </script>
                                    <td><input type="text" name="selBunkerPort_1" id="selBunkerPort_1" style="width:200px;" class="input-text" value=""/></td>
									<td><select name="selBunkerVendor_1" id="selBunkerVendor_1" style="width:120px;" class="input-text"></select></td>
								  </tr>
                                  <script>$("#selBunkerVendor_1").html($("#selVendor").html());</script>
                                  <?php }else{ $bunk = 0;
									  while($rows_bunk = mysql_fetch_assoc($res_bunk))
									  {$bunk++;
									  ?>
								   <tr id="DivBunkeractual_<?php echo $bunk;?>">
									<td><a href="#tb<?php echo $bunk;?>'" onClick="removeBunkerRows(<?php echo $bunk;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
									<td><select name="selBunker_<?php echo $bunk;?>" id="selBunker_<?php echo $bunk;?>" style="width:100px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
									<td><input type="text" name="txtBunkerQty_<?php echo $bunk;?>" id="txtBunkerQty_<?php echo $bunk;?>" style="width:95px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['QTY'];?>"/></td>
									<td><input type="text" name="txtBunkerPrice_<?php echo $bunk;?>" id="txtBunkerPrice_<?php echo $bunk;?>" style="width:95px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="<?php echo $rows_bunk['PRICE'];?>"/></td>
									<td><input type="text" name="txtBunkerAmt_<?php echo $bunk;?>" id="txtBunkerAmt_<?php echo $bunk;?>" style="width:95px;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value="<?php echo $rows_bunk['COST'];?>"/></td>
									<script>
										$(document).ready(function($)
										{
											$("#selBunkerPort_<?php echo $bunk;?>").select2({
												minimumInputLength: 1,
												placeholder: '---Select from list---',
												allowClear: true,
												ajax: {
													url: "options.php?id=84",
													dataType: 'json',
													quietMillis: 100,
													data: function(term, page) {
														return {
															limit: -1,
															q: term
														};
													},
													results: function(data, page ) {
														return { results: data }
													}
												},
												formatResult: function(doc) { 
													return "<div class='select2-user-result'>" + doc.name + "</div>"; 
												},
												formatSelection: function(doc) { 
													return  doc.name; 
												}
											});
											$("#selBunkerPort_<?php echo $bunk;?>").select2("data", {id: <?php echo $rows_bunk['PORT'];?>, name: "<?php echo $obj->getPortNameBasedOnID($rows_bunk['PORT']);?>"});
										});
                                    </script>
                                    <td><input type="text" name="selBunkerPort_<?php echo $bunk;?>" id="selBunkerPort_<?php echo $bunk;?>" style="width:200px;" class="input-text" value=""/></td>
									<td><select name="selBunkerVendor_<?php echo $bunk;?>" id="selBunkerVendor_<?php echo $bunk;?>" style="width:120px;" class="input-text"></select></td>
								  </tr>
                                  <script>$("#selBunkerVendor_<?php echo $bunk;?>").html($("#selVendor").html());$("#selBunkerVendor_<?php echo $bunk;?>").val('<?php echo $rows_bunk['VENDORID'];?>');$("#selBunker_<?php echo $bunk;?>").val('<?php echo $rows_bunk['BUNKERGRADEID'];?>');</script>
                                  <?php }$num_bunk =$bunk; }?>
								</tbody>
								  <tr>
									<td colspan="7"><button type="button" onClick="addBunkerRow()">Add</button><input type="hidden" name="txtBunkerCount" id="txtBunkerCount" value="<?php echo $num_bunk;?>"/></td>
								  </tr>
								</table>
                                
                                
                                <div><strong style="font-size:13px;">Operational Costs (Others)</strong></div>
								
                                <table class='tablesorter'>
                                    <tbody>
                                        <tr>
                                            <td colspan="2">Address Commission(Freight)</td>
                                            <td><input type="text"  name="txtFrAdjPerAC" id="txtFrAdjPerAC" class="input-text" autocomplete="off" size="12" value="<?php echo $obj->getFun74();?>" onKeyUp="getFinalCalculation();" placeholder="0.00"/></td>
                                            <td><input type="text"  name="txtFrAdjUsdAC" id="txtFrAdjUsdAC" class="input-text" readonly value="<?php echo $obj->getFun75();?>" size="12" /></td>
                                            <td></td>
                                        </tr>
                                    </tbody>
                                    <tbody id="tbodyBrokerage">
                                    <?php 
									$sql_brok = "select * from freight_cost_estimete_slave4 where FCAID='".$obj->getFun1()."'";
									
									$res_brok = mysql_query($sql_brok);
									$num_brok = mysql_num_rows($res_brok);
									if($num_brok==0)
									{$num_brok =1;
									?>
									 <tr id="tbrRow_1">
                                        <td><a href="#tb1'" onClick="removeBrokerage(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td>Brokerage Commission <span style="font-size:10px; font-style:italic;">(%)</span></td>
                                        
                                        <td><input type="text" name="txtBrCommPercent_1" id="txtBrCommPercent_1" class="input-text" autocomplete="off" size="12" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"  /></td>
                                        <td><input type="text" name="txtBrComm_1" id="txtBrComm_1" class="input-text" readonly value="0.00" size="12" /></td>
                                        <td></td>
                                    </tr>
									<?php }
									     else
									      {$i=0;$num_brok = $num_brok;
										  while($rows_brok = mysql_fetch_assoc($res_brok))
										  {$i = $i + 1;?>
										     <tr id="tbrRow_<?php echo $i;?>">
                                                <td><a href="#tb1'" onClick="removeBrokerage(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
												<td>Brokerage Commission <span style="font-size:10px; font-style:italic;">(%)</span></td>
												<td><input type="text" name="txtBrCommPercent_<?php echo $i;?>" id="txtBrCommPercent_<?php echo $i;?>" class="input-text" autocomplete="off" size="12" value="<?php echo $rows_brok['BROKAGE_PERCENT'];?>" onKeyUp="getFinalCalculation();" placeholder="0.00"/></td>
												<td><input type="text" name="txtBrComm_<?php echo $i;?>" id="txtBrComm_<?php echo $i;?>" class="input-text" readonly size="12" value="<?php echo $rows_brok['BROKAGE_AMT'];?>" /></td>
												<td></td>
											 </tr>
										  <?php }} ?>
                                     
                                    </tbody>
                                    
                                    <tbody>
                                    <tr>
                                        <td><button type="button" onClick="addBrokerageRow()">Add</button><input type="hidden" name="txtBRokageCount" id="txtBRokageCount" value="<?php echo $num_brok;?>"/></td>
                                        <td>Total&nbsp;Brokerage Commission <span style="font-size:10px; font-style:italic;">(%)</span></td>
                                        
                                        <td><input type="text" name="txtBrCommPercent" id="txtBrCommPercent" class="input-text" size="12" autocomplete="off" value="0.00" onKeyUp="getFinalCalculation();" readonly/></td>
                                        <td><input type="text" name="txtBrComm" id="txtBrComm" class="input-text" readonly size="12" value="0.00" /></td>
                                        <td>
                                        </td>
                                    </tr>
                                   </tbody>
                                 </table>
								
                                <table class='tablesorter'>
                                    <thead>
                                        <tr>
                                            <th width="20%"></th>
                                            <th width="20%"></th>
                                            <th width="20%">Cost</th>
                                        </tr>
                                   </thead>
                                   <tbody id="OWCBody">
                                   <?php $sql1 = "select * from freight_cost_estimete_slave3 where FCAID='".$id."' and IDENTIFY='ORC' and RAW_AMOUNT>0";
								   $res1 = mysql_query($sql1) or die($sql1);
								   $num1 = mysql_num_rows($res1);
								   if($num1==0)
								   {$num1 = 1;?>
									<tr id="OWCRow_1">
                                        <td><a href="#tb1'" onClick="removeCC(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td><select name="txtHidORCID_1" id="txtHidORCID_1" style="width:130px;" >
                                        <?php $obj->getOwnerRelatedCostList(0);?>
                                        </select></td>
                                        <td><input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"  /></td>
                                     </tr> 
								 <?php }else
								   {$i = 0;
								   while($rows1 = mysql_fetch_assoc($res1))
								   {
										$i = $i + 1;
										?>
									 <tr id="OWCRow_<?php echo $i;?>">
                                        <td><a href="#tb1'" onClick="removeCC(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td><select name="txtHidORCID_<?php echo $i;?>" id="txtHidORCID_<?php echo $i;?>" style="width:130px;" >
                                        <?php $obj->getOwnerRelatedCostList($rows1['IDENTY_ID']);?>
                                        </select></td>
                                        <td><input type="text" name="txtORCAmt_<?php echo $i;?>" id="txtORCAmt_<?php echo $i;?>" onKeyUp="getORCCalculate(<?php echo $i;?>);" class="input-text" autocomplete="off" value="<?php echo $rows1['RAW_AMOUNT'];?>" placeholder="0.00" size="12"  /></td>
                                    </tr>
									 <?php }}?>
									</tbody>
                                    <tfoot>
                                        <tr>
                                        <th colspan="3" align="left"><button type="button" onClick="addORCRow()">Add</button><input type="hidden" name="txtOWCCount" id="txtOWCCount" value="<?php echo $num1;?>"/></th>
                                        </tr>
                                    </tfoot>
                                 </table>
                                 <table width="100%" class='tablesorter'>
                                     <tbody>
                                         <tr>
                                            <td>CVE <span style="font-size:10px; font-style:italic;">(/Month)</span></td>
                                            <td><input type="text" name="txtCVE" style="width:90px;" id="txtCVE" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="<?php echo $obj->getFun142();?>" placeholder="0.00"></td>
                                            <td>CVE <span style="font-size:10px; font-style:italic;">(USD)</span></td>
                                            <td><input type="text" name="txtCVEAmt" style="width:90px;" id="txtCVEAmt" class="input-text" autocomplete="off" value="<?php echo $obj->getFun143();?>" placeholder="0.00" readonly><input type="hidden" name="txtHidCVEAmt" style="width:90px;" id="txtHidCVEAmt" autocomplete="off" value="<?php echo $obj->getFun143();?>"></td>
                                        </tr>
                                     </tbody>
                                 </table>
                                 <div><strong style="font-size:13px;">Other Income</strong></div>
                                <table class='tablesorter'>
                                    <thead>
                                        <tr>
                                            <th width="5%"></th>
                                            <th width="35%">Description</th>
                                            <th width="20%">Amount(USD)</th>
                                            <th width="20%">Add Comm(%)</th>
                                            <th width="20%">Net Amount(USD)</th>
                                        </tr>
                                   </thead>
                                   <tbody id="OthInBody">
                                   <?php $sql3 = "select * from freight_cost_estimete_slave3 where FCAID='".$id."' and IDENTIFY='OTHERINCOME' and RAW_AMOUNT>0";
								   $res3 = mysql_query($sql3) or die($sql3);
								   $num3 = mysql_num_rows($res3);
								   if($num3==0)
								   {$num3 = 1;?>
                                     <tr id="OthInRow_1">
                                        <td><a href="#tb1'" onClick="removeOtherIncome(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td><input type="text" name="txtDesc_1" id="txtDesc_1" class="input-text" autocomplete="off" value="" placeholder="Description" size="29"  /></td>
                                        <td><input type="text" name="txtOtherAmt_1" id="txtOtherAmt_1" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"  /></td>
                                        <td><input type="text" name="txtOtherAddComm_1" id="txtOtherAddComm_1" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"  /></td>
                                        <td><input type="text" name="txtOtherNetAmt_1" id="txtOtherNetAmt_1"  class="input-text" autocomplete="off" size="12" value="0.00"  readonly /></td>
                                    </tr>
                                 <?php }else
								   {$i = 0;
								   while($rows3 = mysql_fetch_assoc($res3))
								   {$i = $i + 1;?>
                                     <tr id="OthInRow_<?php echo $i;?>">
                                        <td><a href="#tb1'" onClick="removeOtherIncome(<?php echo $i;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td><input type="text" name="txtDesc_<?php echo $i;?>" id="txtDesc_<?php echo $i;?>" class="input-text" autocomplete="off" value="<?php echo $rows3['IDENTY_ID'];?>" placeholder="Description" size="29"  /></td>
                                        <td><input type="text" name="txtOtherAmt_<?php echo $i;?>" id="txtOtherAmt_<?php echo $i;?>" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="<?php echo $rows3['COST'];?>" placeholder="0.00" size="12"  /></td>
                                        <td><input type="text" name="txtOtherAddComm_<?php echo $i;?>" id="txtOtherAddComm_<?php echo $i;?>" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="<?php echo $rows3['ADDCOMM'];?>" placeholder="0.00" size="12"  /></td>
                                        <td><input type="text" name="txtOtherNetAmt_<?php echo $i;?>" id="txtOtherNetAmt_<?php echo $i;?>"  class="input-text" autocomplete="off" size="12" value="<?php echo $rows3['RAW_AMOUNT'];?>"  readonly /></td>
                                    </tr>
                                 <?php }}?>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                        <th colspan="5" align="left"><button type="button" onClick="addOtherInRow()">Add</button><input type="hidden" name="txtOthInCount" id="txtOthInCount" value="<?php echo $num3;?>"/></th>
                                        </tr>
                                    </tfoot>
                                </table>
                                    <div style="border-bottom:1px solid #ccc; height:30px;"><strong>Hire</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" data-toggle="modal" data-target="#compose-modal_TC" class="btn-danger btn-flat" style="font-size:12px;">TC Details</button></div>
                                    
									<div ><strong>Results</strong></div>
									<table class='tablesorter'>
										
										<tbody>
											<tr>
												<td>Revenue (Final Nett Freight)</td>
												<td><input type="text"  name="txtRevenue" style="width:90px;" id="txtRevenue" class="input-text" readonly placeholder="0.00" /></td>
												<td>Operational Expenses</td>
												<td><input type="text"  name="txtTotalOperationalCost" style="width:90px;" id="txtTotalOperationalCost" class="input-text" readonly value="<?php echo $obj->getFun84();?>" autocomplete="off"/></td>
											</tr>
                                            <tr>
                                                <td>Port Expenses</td>
                                                <td><input type="text"  name="txtTotalPortCost" style="width:90px;" id="txtTotalPortCost" class="input-text" readonly value=""/></td>
                                                <td>Bunker Expenses</td>
												<td><input type="text"  name="txtTotalBunkerCost" style="width:90px;" id="txtTotalBunkerCost" class="input-text" readonly value=""/></td>
                                                
                                            </tr>
                                            
											<tr>
												<td></td>
												<td></td>
												<td>Voyage Earnings</td>
												<td><input type="text"  name="txtVoyageEarnings" style="width:90px;" id="txtVoyageEarnings" class="input-text" readonly placeholder="0.00" /></td>
											</tr>
											
											<tr>
                                                <td>G Total Voyage Earnings&nbsp;&nbsp;&nbsp;<span style="font-size:10px; font-style:italic;">(Voyage Earnings + Demurrage)</span></td>
												<td><input type="text"  name="txtGTTLVoyageEarnings" style="width:90px;" id="txtGTTLVoyageEarnings" class="input-text" readonly  placeholder="0.00" /></td>
												<td style="color:#dc631e;" >Gross Daily TCE</td>
												<td><input type="text"  name="txtDailyEarnings" style="width:90px;" id="txtDailyEarnings" class="input-text" readonly placeholder="0.00" /></td>
												
											</tr>
											
											<tr>
												<td style="color:#dc631e;">Nett Daily TCE</td>
												<td><input type="text"  name="txtNettDailyProfit" style="width:90px;" id="txtNettDailyProfit" class="input-text" readonly placeholder="0.00" /></td>
												<td>P/L</td>
												<td><input type="text"  name="txtPL" id="txtPL" style="width:90px;" class="input-text" readonly placeholder="0.00" /></td>
											</tr>
											<tr>
												<td style="border-bottom:1px solid #ccc; height:5px;" colspan="4"></td>
											</tr>
											<tr>
												<td style="height:5px;" colspan="4"></td>
											</tr>
											<tr >
												<td>Gross Breakeven(USD)</td>
												<td><input type="text"  name="txtGrossBreakeven" style="width:90px;" id="txtGrossBreakeven" class="input-text" readonly placeholder="0.00" value="<?php echo $obj->getFun226();?>"/></td>
												<td>Breakeven (USD/MT)</td>
												<td><input type="text"  name="txtBreakevenMT" style="width:90px;" id="txtBreakevenMT" class="input-text" readonly value="<?php echo $obj->getFun227();?>" autocomplete="off"/></td>
											</tr>
										</tbody>
									</table>
                           </td>
                       </tr>
                       </table>
                    
                    
                    </div>
                    <!-- /.tab_1-pane -->
                    <div id="tabs_3" class="tab-pane">
                         <table width="100%" style="margin-top:2px;">
                           <tr>
                               <td class="input-text">&nbsp;DWT<span style="font-size:10px; font-style:italic;">(Summer)</span>&nbsp;:&nbsp;<input type="text" name="txtDWTS" id="txtDWTS" style="width:90px;" class="input-text" autocomplete="off" readonly value="<?php echo $obj->getFun10();?>" placeholder="0.00" />
                               </td>
                               <td class="input-text"></td>
                                <td class="input-text" id="tankgasnot1"><input name="rdoCap" id="rdoCap1" type="radio" style="cursor:pointer;" value="1"  <?php if($rdoCap == 1) echo "checked"; ?> onClick="showCapField(1);"  />&nbsp;Grain Cap.<span style="font-size:10px; font-style:italic;">(CBM)</span><input type="text" name="txtGCap" id="txtGCap" style="width:90px;" class="input-text" autocomplete="off" readonly value="<?php echo $obj->getFun13();?>" /></td>
                                <td class="input-text" id="tankgasnot2"><input name="rdoCap" id="rdoCap2" type="radio" style="cursor:pointer;" value="2"  <?php if($rdoCap == 2) echo "checked"; ?> onClick="showCapField(2);" />&nbsp;Bale&nbsp;Cap.<span style="font-size:10px; font-style:italic;">(CBM)</span><input type="text" name="txtBCap" id="txtBCap" style="width:90px;" class="input-text" autocomplete="off" readonly value="<?php echo $obj->getFun14();?>" disabled="disabled" /></td>
                                <td class="input-text" id="tankgasnot3">SF<span style="font-size:10px; font-style:italic;">(ft3/lt)</span><input type="text" name="txtSF" id="txtSF"  autocomplete="off" style="width:90px;" class="input-text" value="<?php echo $obj->getFun15();?>"  onkeyup="getTotalDWT(),getTotalDWT1()" /></td>
                                <td class="input-text" id="tankgasnot4">Loadable<span style="font-size:10px; font-style:italic;">(MT)</span><input type="text" name="txtLoadable" id="txtLoadable" autocomplete="off" style="width:90px;" class="input-text" readonly value="<?php echo $obj->getFun16();?>" /></td>
                           </tr>
                       </table>
                         <table cellpadding="1" cellspacing="1" border="0" width="100%"  class='tablesorter' >
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" ></td></tr>	
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" >
						<table width="100%" cellpadding="1" cellspacing="1" border="0">
						<thead>
                        <tr>
						<td width="25%" align="left" class="text">GRT<br/><input type="text" name="txtGNRT" id="txtGNRT" class="input-text" readonly value="<?php echo $obj->getFun17();?>" /></td>
						<td width="25%" align="left" valign="top" class="text">LOA<br/><input type="text" name="txtLOA" id="txtLOA" class="input-text" readonly value="<?php echo $obj->getFun18();?>" /></td>
						<td width="25%" align="left" valign="top" class="text">Built Year<br/><input type="text" name="txtBuiltYear" id="txtBuiltYear" class="input-text" readonly value="<?php echo $obj->getFun20();?>" /></td>
						<td width="25%" align="left" valign="top" class="text"></td>
						</tr>
                        <tr>
						<td width="25%" align="left" class="text">BEAM(m)<br/><input type="text" name="txtBeam" id="txtBeam" class="input-text" readonly value="<?php echo $obj->getFun21();?>" /></td>
						<td width="25%" align="left" valign="top" class="text">TPC<br/><input type="text" name="txtTPC" id="txtTPC" class="input-text" readonly value="<?php echo $obj->getFun22();?>" /></td>
						<td width="25%" align="left" valign="top" class="text"></td>
						<td width="25%" align="left" valign="top" class="text"></td>
						</tr>
						<tr>
						<td width="25%" align="left" class="text" style="color:#dc631e;">Speed Data</td>
						<td width="25%" align="right" valign="top" class="text" style="color:#1b77a6;">Full Speed</td>
						<td width="25%" align="right" valign="top" class="text" style="color:#1b77a6;">Service Speed</td>
						<td width="25%" align="right" valign="top" class="text" style="color:#1b77a6;">Most Eco Speed</td>
						</tr>
						</thead>
						<tbody>
						<tr>
						<td width="25%" align="left" class="input-text">Ballast Speed <span style="font-size:10px; font-style:italic;">(Knots)</span></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtBFullSpeed" id="txtBFullSpeed" class="input-text" value="<?php echo $obj->getFun23();?>" /></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtBEcoSpeed1" id="txtBEcoSpeed1" class="input-text" value="<?php echo $obj->getFun24();?>" /></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtBEcoSpeed2" id="txtBEcoSpeed2" class="input-text" value="<?php echo $obj->getFun25();?>" /></td>
						</tr>
						<tr>
						<td width="25%" align="left" class="input-text">Laden Speed <span style="font-size:10px; font-style:italic;">(Knots)</span></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtLFullSpeed" id="txtLFullSpeed" class="input-text" value="<?php echo $obj->getFun26();?>" /></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtLEcoSpeed1" id="txtLEcoSpeed1" class="input-text" value="<?php echo $obj->getFun27();?>" /></td>
						<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtLEcoSpeed2" id="txtLEcoSpeed2" class="input-text" value="<?php echo $obj->getFun28();?>" /></td>
						</tr>
						</tbody>
						</table>
						</td></tr>
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" ></td></tr>	
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" >
						<table width="100%">
						<tbody>
						   <tr>
							  <td colspan="13" style="color:#dc631e;"><strong>FO Consp/day(MT) - At Sea</strong></td>
						   </tr>
						</tbody>
						<thead>   
						   <tr>
							  <th></th>
							  <th colspan="4" style="text-align:center;">Full Speed</th>
							  <th colspan="4" style="text-align:center;">Service Speed</th>
							  <th colspan="4" style="text-align:center;">Most Eco Speed</th>
						   </tr>
						   <tr>
							  <th>Bunker&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
							  <th>SECA (Ballast)</th>
							  <th>SECA (Laden)</th>
							  <th>NON-SECA (Ballast)</th>
							  <th>NON-SECA (Laden)</th>
							  <th>SECA (Ballast)</th>
							  <th>SECA (Laden)</th>
							  <th>NON-SECA (Ballast)</th>
							  <th>NON-SECA (Laden)</th>
							  <th>SECA (Ballast)</th>
							  <th>SECA (Laden)</th>
							  <th>NON-SECA (Ballast)</th>
							  <th>NON-SECA (Laden)</th>
						   </tr>
						</thead>
						<tbody id="tbodyFOAtSea">
							<?php 
							  $sql = "select *, (select NAME from bunker_grade_master where bunker_grade_master.BUNKERGRADEID=freight_cost_estimete_slave16.BUNKERID) as BUNKER_NAME from freight_cost_estimete_slave16 where IDENTIFY='FO' and FCAID=".$obj->getFun1();
							  $result = mysql_query($sql) or die($sql);$i = 0;
							  $num = mysql_num_rows($result);
							  while($rows = mysql_fetch_assoc($result))
							  {$i++;?>
								<tr id="FOAtSeaRow_<?=$i?>">
									<td align="right"><input type="hidden" name="txtFOAtSeaBunker_<?=$i?>" id="txtFOAtSeaBunker_<?=$i?>" value="<?=$rows['BUNKERID'];?>"/><?=$rows['BUNKER_NAME'];?></td></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaSECAConspFS_<?=$i?>" style="width:80px;" id="txtFOBalAtSeaSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaSECAConspFS_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaNONSECAConspFS_<?=$i?>" style="width:80px;" id="txtFOBalAtSeaNONSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaNONSECAConspFS_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaNONSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaSECAConspSS_<?=$i?>" style="width:80px;" id="txtFOBalAtSeaSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaSECAConspSS_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaNONSECAConspSS_<?=$i?>" style="width:80px;" id="txtFOBalAtSeaNONSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaNONSECAConspSS_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaNONSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaSECAConspMES_<?=$i?>" style="width:80px;" id="txtFOBalAtSeaSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaSECAConspMES_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtFOBalAtSeaNONSECAConspMES_<?=$i?>" style="width:80px;" style="width:80px;" id="txtFOBalAtSeaNONSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtFOLadAtSeaNONSECAConspMES_<?=$i?>" style="width:80px;" id="txtFOLadAtSeaNONSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_MES'];?>"/></td>
								</tr>
						<?php }?>			
						</tbody>
						<tbody>
						   <tr>
							  <td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT) - At Sea</strong><input type="hidden" name="txtFOAtSeaID" id="txtFOAtSeaID" value="<?=$i?>"/></td>
						   </tr>
						</tbody>
						<tbody id="tbodyDOAtSea">
							<?php 
							  $sql = "select *, (select NAME from bunker_grade_master where bunker_grade_master.BUNKERGRADEID=freight_cost_estimete_slave16.BUNKERID) as BUNKER_NAME from freight_cost_estimete_slave16 where IDENTIFY='DO' and FCAID=".$obj->getFun1();
							  $result = mysql_query($sql) or die($sql);$i = 0;
							  $num = mysql_num_rows($result);
							  while($rows = mysql_fetch_assoc($result))
							  {$i++;?>
								<tr id="DOAtSeaRow_<?=$i?>">
									<td align="right"><input type="hidden" name="txtDOAtSeaBunker_<?=$i?>" id="txtDOAtSeaBunker_<?=$i?>" value="<?=$rows['BUNKERID'];?>"/><?=$rows['BUNKER_NAME'];?></td></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaSECAConspFS_<?=$i?>" style="width:80px;" id="txtDOBalAtSeaSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaSECAConspFS_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaNONSECAConspFS_<?=$i?>" style="width:80px;" id="txtDOBalAtSeaNONSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaNONSECAConspFS_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaNONSECAConspFS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_FS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaSECAConspSS_<?=$i?>" style="width:80px;" id="txtDOBalAtSeaSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaSECAConspSS_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaNONSECAConspSS_<?=$i?>" style="width:80px;" id="txtDOBalAtSeaNONSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaNONSECAConspSS_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaNONSECAConspSS_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_SS'];?>"/></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaSECAConspMES_<?=$i?>" style="width:80px;" id="txtDOBalAtSeaSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_SECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaSECAConspMES_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_SECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtDOBalAtSeaNONSECAConspMES_<?=$i?>" style="width:80px;" class="input-text" readonly="true"  id="txtDOBalAtSeaNONSECAConspMES_<?=$i?>" autocomplete="off" value="<?=$rows['FO_BALAST_ATSEA_NONSECA_CONSP_MES'];?>"/></td>
									<td align="right"><input type="text" name="txtDOLadAtSeaNONSECAConspMES_<?=$i?>" style="width:80px;" id="txtDOLadAtSeaNONSECAConspMES_<?=$i?>" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_LADEN_ATSEA_NONSECA_CONSP_MES'];?>"/></td>
								</tr>
						<?php }?>
						</tbody>
					</table>
						
						<table width="100%">
						    <tbody>
							   <tr>
								  <td colspan="13" style="color:#dc631e;"><strong>FO Consp/day(MT)- In Port</strong><input type="hidden" name="txtDOAtSeaID" id="txtDOAtSeaID" value="<?=$i?>"/></td>
							   </tr>
							</tbody>
							<thead>   
							   <tr>
								  <th></th>
								  <th colspan="2" style="text-align:center;">Working</th>
								  <th colspan="2" style="text-align:center;">Idle</th>
								  <th colspan="2" style="text-align:center;">Others</th>
							   </tr>
							   <tr>
								  <th>Bunker&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
								  <th>SECA</th>
								  <th>NON-SECA</th>
								  <th>SECA</th>
								  <th>NON-SECA</th>
								  <th>SECA</th>
								  <th>NON-SECA</th>
							   </tr>
							</thead>
							<tbody id="tbodyFOInPort">
							  <?php 
							  $sql = "select *, (select NAME from bunker_grade_master where bunker_grade_master.BUNKERGRADEID=freight_cost_estimete_slave16.BUNKERID) as BUNKER_NAME from freight_cost_estimete_slave16 where IDENTIFY='FO' and FCAID=".$obj->getFun1();
							  $result = mysql_query($sql) or die($sql);$i = 0;
							  $num = mysql_num_rows($result);
							  while($rows = mysql_fetch_assoc($result))
							  {$i++;?>
								<tr id="FOInPortRow_<?=$i?>">
									<td align="right"><input type="hidden" name="selFOInPortBunker_<?=$i?>" id="selFOInPortBunker_<?=$i?>" value="<?=$rows['BUNKERID'];?>"><span id="fo_bunkerLevel_<?=$i?>"><?=$rows['BUNKER_NAME'];?></span></td>
									<td align="right"><input type="text" name="txtFOInPortSECAConspWorking_<?=$i?>" id="txtFOInPortSECAConspWorking_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_WORKING'];?>"/></td>
									<td align="right"><input type="text" name="txtFOInPortNONSECAConspWorking_<?=$i?>" id="txtFOInPortNONSECAConspWorking_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_WORKING'];?>"/></td>
									<td align="right"><input type="text" name="txtFOInPortSECAConspIdle_<?=$i?>" id="txtFOInPortSECAConspIdle_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_IDLE'];?>"/></td>
									<td align="right"><input type="text" name="txtFOInPortNONSECAConspIdle_<?=$i?>" id="txtFOInPortNONSECAConspIdle_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_IDLE'];?>"/></td>
									<td align="right"><input type="text" name="txtFOInPortSECAConspOther_<?=$i?>" id="txtFOInPortSECAConspOther_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_OTHER'];?>"/></td>
									<td align="right"><input type="text" name="txtFOInPortNONSECAConspOther_<?=$i?>" id="txtFOInPortNONSECAConspOther_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_OTHER'];?>"/></td>
								</tr>
						<?php }?>
							</tbody>
							<tbody>
							   <tr>
								  <td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT)- In Port</strong><input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="<?=$i?>"/></td>
							   </tr>
							</tbody>
							<tbody id="tbodyDOInPort">
								<?php 
							  $sql = "select *, (select NAME from bunker_grade_master where bunker_grade_master.BUNKERGRADEID=freight_cost_estimete_slave16.BUNKERID) as BUNKER_NAME from freight_cost_estimete_slave16 where IDENTIFY='DO' and FCAID=".$obj->getFun1();
							  $result = mysql_query($sql) or die($sql);$i = 0;
							  $num = mysql_num_rows($result);
							  while($rows = mysql_fetch_assoc($result))
							  {$i++;?>
								<tr id="DOInPortRow_<?=$i?>">
									<td align="right"><input type="hidden" name="selDOInPortBunker_<?=$i?>" id="selDOInPortBunker_<?=$i?>" value="<?=$rows['BUNKERID'];?>"><span id="do_bunkerLevel_<?=$i?>"><?=$rows['BUNKER_NAME'];?></span></td>
									<td align="right"><input type="text" name="txtDOInPortSECAConspWorking_<?=$i?>" id="txtDOInPortSECAConspWorking_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_WORKING'];?>"/></td>
									<td align="right"><input type="text" name="txtDOInPortNONSECAConspWorking_<?=$i?>" id="txtDOInPortNONSECAConspWorking_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_WORKING'];?>"/></td>
									<td align="right"><input type="text" name="txtDOInPortSECAConspIdle_<?=$i?>" id="txtDOInPortSECAConspIdle_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_IDLE'];?>"/></td>
									<td align="right"><input type="text" name="txtDOInPortNONSECAConspIdle_<?=$i?>" id="txtDOInPortNONSECAConspIdle_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_IDLE'];?>"/></td>
									<td align="right"><input type="text" name="txtDOInPortSECAConspOther_<?=$i?>" id="txtDOInPortSECAConspOther_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_SECA_CONSP_OTHER'];?>"/></td>
									<td align="right"><input type="text" name="txtDOInPortNONSECAConspOther_<?=$i?>" id="txtDOInPortNONSECAConspOther_<?=$i?>" style="width:80px;" class="input-text" readonly="true" autocomplete="off" value="<?=$rows['FO_INPORT_NONSECA_CONSP_OTHER'];?>"/></td>
								</tr>
						<?php }?>
							</tbody>
						</table>
						</td></tr>	
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" ><input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="<?=$i?>"/></td></tr>	
						</table>
                    </div>
                    <!-- /.tab_2-pane -->
                    <div id="tabs_4" class="tab-pane" style="overflow:auto;">
                        <table width="100%">
                        <tr class="input-text">
                            <td>Port Open : </td>
							<script>
								$(document).ready(function($)
								{
									$("#selOpenPort").select2({
										minimumInputLength: 1,
										placeholder: '---Select from list---',
										allowClear: true,
										ajax: {
											url: "options.php?id=84",
											dataType: 'json',
											quietMillis: 100,
											data: function(term, page) {
												return {
													limit: -1,
													q: term
												};
											},
											results: function(data, page ) {
												return { results: data }
											}
										},
										formatResult: function(doc) { 
											return "<div class='select2-user-result'>" + doc.name + "</div>"; 
										},
										formatSelection: function(doc) { 
											return  doc.name; 
										}
									});
									<?php if($obj->getFun100()!=''){?>
									$("#selOpenPort").select2("data", {id: <?php echo $obj->getFun100();?>, name: "<?php echo $obj->getPortNameBasedOnID($obj->getFun100());?>"});
									<?php }?>
								});
							</script>
                            <td><input type="text" name="selOpenPort" class="input-text" id="selOpenPort" style="width:200px;" value=""></td>
                            <td>Zone Open : </td>
                            <td><select name="selZone" class="input-text" style="width:137px;" id="selZone"><?php $obj->getZoneList();?></select></td>
                            <td>Broker : </td>
                            <td><select  name="selBroker" class="input-text" style="width:150px;" id="selBroker"><?php $obj->getVendorListNewForCOA(12);?></select></td>
                            <td>COA / Spot : </td>
                            <td><select  name="selCOASpot" class="input-text" style="width:137px;" id="selCOASpot" onChange="getShow();"><?php $obj->getCOASpotList();?></select></td>
                        </tr>
                        <script>
						    $(document).ready(function(){
							    if($("#selCOASpot").val()==2){$("#tr_coa").val();}
							});
                        </script>
                        <tr class="input-text" id="tr_coa" style="display:none;">
                        	<td>COA Number : </td>
                            <td><select  name="selCOA" class="input-text" style="width:137px;" id="selCOA"><?php $obj->getCOAList();?></select></td>
                            <td>Number of Lift : </td>
                            <td><input type="text" name="txtNoLift" id="txtNoLift" class="input-text" size="21" placeholder=" Number of Lift" autocomplete="off" value="<?php echo $obj->getFun103();?>"/></td>
                            <td>Total No. of Shipments : </td>
                            <td><strong><span id="ttl_shipment" ></span></strong></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr class="input-text">
                        <?php if($obj->getFun112()=="" || $obj->getFun112()=="0000-00-00" || $obj->getFun112()=="1970-01-01"){$txtCPDate = "";}else{$txtCPDate = date('d-m-Y',strtotime($obj->getFun112()));}?>
                            <td>CP Date : </td>
                            <td><input type="text" name="txtCPDate" id="txtCPDate" class="input-text" size="21"  placeholder="dd-mm-yyyy" autocomplete="off" value="<?php echo $txtCPDate;?>"/></td>
                            <td>Remarks :</td>
                            <td><textarea class="input-text areasize" name="txtNotes" id="txtNotes" rows="3" cols="21" placeholder="Remarks ..." ><?php echo $obj->getFun113();?></textarea></td>
                            <td>Owner : </td>
                            <td><select  name="selOwner" class="input-text" style="width:150px;" id="selOwner"><?php $obj->getVendorListNewForCOA(11);?></select></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr class="input-text">
                        <?php if($obj->getFun109()=="" || $obj->getFun109()=="0000-00-00" || $obj->getFun109()=="1970-01-01"){$txtFDate = "";}else{$txtFDate = date('d-m-Y',strtotime($obj->getFun109()));}?>
                            <td>Laycan Start : </td>
                            <td><input type="text" name="txtFDate" id="txtFDate" class="input-text" size="21"  placeholder="dd-mm-yyyy" autocomplete="off" value="<?php echo $txtFDate;?>"/></td>
                            <?php if($obj->getFun110()=="" || $obj->getFun110()=="0000-00-00" || $obj->getFun110()=="1970-01-01"){$txtTDate = "";}else{$txtTDate = date('d-m-Y',strtotime($obj->getFun110()));}?>
                            <td>Laycan Finish : </td>
                            <td><input type="text" name="txtTDate" id="txtTDate" class="input-text" size="21"  placeholder="dd-mm-yyyy" autocomplete="off" value="<?php echo $txtTDate;?>"/></td>
                            <?php if($obj->getFun111()=="" || $obj->getFun111()=="0000-00-00" || $obj->getFun111()=="1970-01-01"){$txtETADate = "";}else{$txtETADate = date('d-m-Y',strtotime($obj->getFun111()));}?>
                            <td>ETA During Fixture : </td>
                            <td><input type="text" name="txtETADate" id="txtETADate" class="input-text" size="21" placeholder="dd-mm-yyyy" autocomplete="off" value="<?php echo $txtETADate;?>"/></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </table>
                        <table width="100%" class="tablesorter">
                        <tbody id="sort">
                        <tr>
                            <td width="11%">Disponent Owner 1 : </td>
                            <td width="89%"><select name="txtDisponentOwner" class="input-text" style="width:200px;" id="txtDisponentOwner"><?php $obj->getVendorListNewForCOA(11);?></select></td>
                        </tr>
                        <?php $sql5 = "select * from freight_cost_estimete_slave5 where FCAID='".$id."'";
					    $result5 = mysql_query($sql5);
					    $k =0;
					    while($rows5 = mysql_fetch_assoc($result5))
					    {$k = $k + 1;?>
                            <tr>
                            <td width="11%">Disponent Owner <?php echo $k+1;?> : </td>
                            <td width="89%"><select name="txtDisponentOwner_<?php echo $k;?>" class="input-text" style="width:200px;" id="txtDisponentOwner_<?php echo $k;?>"><?php $obj->getVendorListNewForCOA(11);?></select></td>
                            </tr>
					   <?php }?>
                        </tbody>
                        <tr>
                        <td colspan="2"><button type="button" onClick="addUI_Row();">Add</button><input type="hidden" class="input" name="txtTID" id="txtTID" value="<?php echo $k;?>" /></td>
                        </tr>
                        </table>
                        <table width="100%" class="tablesorter">
                            <tbody>
                            <tr>
                                <td colspan="2"><div class="btn btn-success btn-file btn-flat" data-toggle="tooltip">
                                                <i class="fa fa-paperclip"></i> Attachment
                                                <input type="file" class="form-control" multiple name="attach_file[]" id="attach_file" title="" data-widget="Attachment" data-toggle="tooltip" data-original-title="Attachment"/>
                                            </div></td>
                            </tr>
                            <?php if($obj->getFun115() != '')
                            { 
                                $file = explode(",",$obj->getFun115()); 
                                $name = explode(",",$obj->getFun116()); ?>										
                            <tr>
                                <td colspan="2">
                              Previous Attachments
                                </td>
                             </tr>
               
                                <?php
                                $j =1;
                                for($i=0;$i<sizeof($file);$i++)
                                {
                                ?>
                                <tr id="row_file_<?php echo $j;?>">
                                    <td width="40%" align="left" class="input-text"  valign="top"><a href="../../attachment/<?php echo $file[$i]; ?>" target="_blank" style="color:blue;" data-toggle="tooltip" data-original-title="<?php echo $name[$i];?>"><i class="fa fa-external-link"></i>&nbsp;&nbsp;Attachment<?php echo $j;?></a>
                                    <input type="hidden" name="file_<?php echo $j;?>" id="file_<?php echo $j;?>" value="<?php echo $file[$i]; ?>" />
                                    <input type="hidden" name="name_<?php echo $j;?>" id="name_<?php echo $j;?>" value="<?php echo $name[$i]; ?>" />
                                    </td>
                                    <td ><a href="#1" onClick="Del_Upload(<?php echo $j;?>);"><i class="fa fa-times " style="color:red;"></i></a></td>
                                </tr>
                                <?php $j++;}?>
                            <?php }?>
                            </tbody>
                        </table>
                    </div>
                    <div id="tabs_5" class="tab-pane">
                        <table width="100%">
                        <tr class="input-text">
                            <td>CP ID : </td>
                            <td><input type="text" name="txtCID" id="txtCID" class="input-text" size="21" placeholder="Cargo ID" readonly autocomplete="off" value=""/></td>
                            <td>Shipper : </td>
                            <td><select  name="selShipperCP" class="input-text" style="width:137px;" id="selShipperCP" ></select></td>
                            <td>Charterer : </td>
                            <td><select  name="selChartererCP" class="input-text" style="width:137px;" id="selChartererCP" ></select></td>
                            <td>Owner :</td>
                            <td><select  name="selOwnerCP" class="input-text" style="width:137px;" id="selOwnerCP" ></select></td>
                        </tr>
                        <tr class="input-text">
                        	<td>Receiver : </td>
                            <td><select  name="selReceiverCP" class="input-text" style="width:137px;" id="selReceiverCP" ></select></td>
                            <td>Cargo :</td>
                            <td><select  name="selCargoCP" class="input-text" style="width:137px;" id="selCargoCP"></select></td>
                            <script> $("#selCargoCP").html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());</script>
                            <td>Cargo Stem Size(MT) :</td>
                            <td><input type="text" name="txtQtyCP" id="txtQtyCP" class="input-text" readonly size="21"  placeholder="" autocomplete="off" value=""/></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr class="input-text">
                            <td>Tolerance (+/- %) : </td>
                            <td><input type="text" name="txtToleranceCP" id="txtToleranceCP" readonly class="input-text" size="21"  placeholder="" autocomplete="off" value=""/></td>
                            <?php if($_SESSION['selBType']==1){
								if($rdoQtyMar==1){$level = "Base Freight (USD/MT)"; $velues = $obj->getFun162(); }else{$level = "Lumpsum(USD)"; $velues = $obj->getFun164();}
							}?>
                            <?php if($_SESSION['selBType']==2){
								if($obj->getFun171()==1){$level = "Lumpsum(USD)"; $velues = $obj->getFun172(); }else{$level = "WS"; $velues = 0;}
							}?>
                            <?php if($_SESSION['selBType']==3){
								if($rdoQtyType==1){$level = "Freight (USD/MT)"; $velues = $obj->getFun47(); }else{$level = "Freight(USD/MT)"; $velues = 0;}
							}?>
                            <td><span id="spanGasLevel"><?php echo $level;?></span> : </td>
                            <td><input type="text" name="txtBaseFreightCP" id="txtBaseFreightCP" readonly class="input-text" size="21"  placeholder="" autocomplete="off" value="<?php echo $velues;?>"/></td>
                            <td>COA/Spot :</td>
                            <td> <select  name="selPlannintTypeCP" class="input-text" style="width:137px;" id="selPlannintTypeCP"><?php $obj->getCOASpotList();?></select></td>
                            <td>COA/CP date : </td>
                            <td><input type="text" name="txtCOADateCP" id="txtCOADateCP" class="input-text" readonly size="21" placeholder="dd-mm-yyyy" autocomplete="off" value=""/></td>
                        </tr>
                        <tr class="input-text">
                        	<td>Basin : </td>
                            <td><select  name="selBaseInCP" class="input-text" style="width:137px;" id="selBaseInCP" ><?php $obj->getBaseinList();?></select></td>
                            <td>Bunker Hedge :</td>
                            <td><select  name="selBunkerHedgeCP" class="input-text" style="width:137px;" id="selBunkerHedgeCP"><?php $obj->getLoader();?></select></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr class="input-text">
                            <td>Load Port : </td>
							<script>
								$(document).ready(function($)
								{
									$("#selLPortCP").select2({
										tags: true,
										maximumSelectionSize: 10,
										minimumResultsForSearch: 10,
										multiple: true,
										minimumInputLength: 1,
										placeholder: 'Search Port',
										allowClear: true,
										ajax: {
											url: "options.php?id=84",
											dataType: 'json',
											quietMillis: 100,
											data: function(term, page) {
												return {
													limit: -1,
													q: term
												};
											},
											results: function(data, page ) {
												return { results: data }
											}
										},
										formatResult: function(doc) { 
											return "<div class='select2-user-result'>" + doc.name + "</div>"; 
										},
										formatSelection: function(doc) { 
											return  doc.name; 
										}
									});
									
									$("#selDPortCP").select2({
										tags: true,
										maximumSelectionSize: 10,
										minimumResultsForSearch: 10,
										multiple: true,
										minimumInputLength: 1,
										placeholder: 'Search Port',
										allowClear: true,
										ajax: {
											url: "options.php?id=84",
											dataType: 'json',
											quietMillis: 100,
											data: function(term, page) {
												return {
													limit: -1,
													q: term
												};
											},
											results: function(data, page ) {
												return { results: data }
											}
										},
										formatResult: function(doc) { 
											return "<div class='select2-user-result'>" + doc.name + "</div>"; 
										},
										formatSelection: function(doc) { 
											return  doc.name; 
										}
									});
									
								});
							</script>
							
                            <td><input type="text"  name="selLPortCP" class="input-text" style="width:200px;" id="selLPortCP" value=""/></td>
                            <td>Discharge Port : </td>
                            <td><input type="text"  name="selDPortCP" class="input-text" style="width:200px;" id="selDPortCP" value=""/></td>
                            <td>LayCan Start Date :</td>
                            <td><input type="text" name="txtLCSDateCP" id="txtLCSDateCP" readonly class="input-text" size="21" autocomplete="off" value=""/></td>
                            <td>LayCan Finish Date : </td>
                            <td><input type="text" name="txtLCFDateCP" id="txtLCFDateCP" readonly class="input-text" size="21" autocomplete="off" value=""/></td>
                        </tr>
                        <tr class="input-text">
                            <td>Cargo Relet/Voyage : </td>
                            <td><select  name="selCargoReletCP" class="input-text" style="width:137px;" id="selCargoReletCP"><?php $obj->getBusinessTypeForCargoPlanning('');?></select></td>
                            <td>Nom Clause : </td>
                            <td><input type="text" name="txtNomClauseCP" id="txtNomClauseCP" readonly class="input-text" size="21" autocomplete="off" value=""/></td>
                            <td>Remarks :</td>
                            <td><textarea class="input-text" name="txtRemarksCP" id="txtRemarksCP" rows="2" cols="21" readonly placeholder="Remarks" ></textarea></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </table>
                        <table class='tablesorter' width="100%">
							<tr><td><strong style="font-size:12px;">Cargo Intake Calculations</strong></td></tr>    
					    </table>
                        <table width="100%">
                            <tr class="input-text">
                               <td>Summer DWT(MT):</td>
                               <td><input type="text" name="txtSDWTMT" id="txtSDWTMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun207();?>"/></td>
                               <td>Summer DWT(LT):</td>
                               <td><input type="text" name="txtSDWTLT" id="txtSDWTLT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun208();?>"/></td>
                               <td>Summer Draft(M):</td>
                               <td><input type="text" name="txtSDraftM" id="txtSDraftM" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun209();?>"/></td>
                               <td>Summer Draft(FT):</td>
                               <td><input type="text" name="txtSDraftFT" id="txtSDraftFT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun210();?>"/></td>
                            </tr>
                            <tr class="input-text">
                               <td>TPI(MT/Inch):</td>
                               <td><input type="text" name="txtTPIMT" id="txtTPIMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun211();?>"/></td>
                               <td>TPI(LT/Inch):</td>
                               <td><input type="text" name="txtTPILT" id="txtTPILT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun212();?>"/></td>
                               <td>TPC(MT):</td>
                               <td><input type="text" name="txtTPCMT" id="txtTPCMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun213();?>"/></td>
                               <td>TPC(LT):</td>
                               <td><input type="text" name="txtTPCLT" id="txtTPCLT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun214();?>"/></td>
                            </tr>
                            <tr class="input-text">
                               <td>Constants(MT):</td>
                               <td><input type="text" name="txtConstantsMT" id="txtConstantsMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun215();?>"/></td>
                               <td>Constants(LT):</td>
                               <td><input type="text" name="txtConstantsLT" id="txtConstantsLT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun216();?>"/></td>
                               <td>Grain Cap(CBM):</td>
                               <td><input type="text" name="txtGrainCapCBM" id="txtGrainCapCBM" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun217();?>"/></td>
                               <td>Grain Cap(CFT):</td>
                               <td><input type="text" name="txtGrainCapCFT" id="txtGrainCapCFT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun218();?>"/></td>
                            </tr>
                        
							<tr><td colspan="8"><strong style="font-size:12px;">Basis Max Draft in Port</strong></td></tr>    
					    
                            <tr class="input-text">
                               <td>Allowed Draft(M):</td>
                               <td><input type="text" name="txtAllawedDraftM" id="txtAllawedDraftM" class="input-text numeric" size="21" autocomplete="off" value="<?php echo $obj->getFun219();?>" placeholder="0.00" onKeyUp="getIntakeCalculation();"/></td>
                               <td>Bunker ROB(MT):</td>
                               <td><input type="text" name="txtBunkerRobMT" id="txtBunkerRobMT" class="input-text numeric" size="21" autocomplete="off" value="<?php echo $obj->getFun220();?>" placeholder="0.00" onKeyUp="getIntakeCalculation();"/></td>
                               <td>Cargo Intake(MT) :</td>
                               <td><input type="text" name="txtCargoIntakeMT" id="txtCargoIntakeMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun221();?>"/></td>
                               <td></td>
                               <td></td>
                            </tr>
                        
							<tr><td colspan="8"><strong style="font-size:12px;">Basis Stowage Factor</strong></td></tr>    
					    
                            <tr class="input-text">
                               <td>SF(CBM/MT):</td>
                               <td><input type="text" name="txtSFCBM_MT" id="txtSFCBM_MT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun222();?>"/></td>
                               <td>SF(CBFT/MT):</td>
                               <td><input type="text" name="txtSFCBFT_MT" id="txtSFCBFT_MT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun223();?>"/></td>
                               <td>Cargo Loadable (MT) :</td>
                               <td><input type="text" name="txtCargoLoadableMT" id="txtCargoLoadableMT" readonly class="input-text" size="21" autocomplete="off" value="<?php echo $obj->getFun224();?>"/></td>
                               <td></td>
                               <td></td>
                            </tr>
                        </table>
                        
                    </div>
                    </div><!-- /.tab-content -->
                </div>
                <div style="text-align:center;">
                            <input type="hidden" name="txtCRMFILE" id="txtCRMFILE" value="" />
							<input type="hidden" name="txtCRMNAME" id="txtCRMNAME" value="" />
                            <input type="hidden" name="txtCRMFILE1" id="txtCRMFILE1" value="" />
							<input type="hidden" name="txtCRMNAME1" id="txtCRMNAME1" value="" /><button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate();">Submit</button>
							<input type="hidden" name="action" id="action" value="submit" /><input type="hidden" name="vesselrec" id="vesselrec" class="input-text" value="" /></div>
                <!-- Main content -->
				<div class="modal fade" id="compose-modal_TC" tabindex="-1" role="dialog" aria-hidden="true">
					<div class="modal-dialog" style="width:90%;">
						 <div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;TC Hire Details</h4>
							</div>
							
							<div class="modal-body">
								<div class="row" style="margin-top:50px;margin-bottom:50px;">
									 <div class="col-md-4">
										 <table class='tablesorter'>
											<tbody>
												<tr>
													<td>Daily Hire(USD/Day)</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtDailyVesselOperatingExpenses" style="width:90px;" id="txtDailyVesselOperatingExpenses" class="input-text" autocomplete="off" value="<?php echo $obj->getFun91();?>" placeholder="0.00" onKeyUp="getFinalCalculation();" /></td>
													<td></td>
												</tr>
												<tr>
													<td>Total Voyage Days</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtTotalVoyageDays" style="width:90px;" id="txtTotalVoyageDays" class="input-text" autocomplete="off" readonly="true" value="<?php echo $obj->getFun62();?>" placeholder="0.00"/></td>
													<td></td>
												</tr>
												<tr>
													<td>Hireage (USD)</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtHireargeAmt" id="txtHireargeAmt" style="width:90px;" class="input-text" value="<?php echo $obj->getFun132();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Ballast Bonus (USD)</td>
													<td>:</td>
													<td></td>
													<td><input type="text" name="txtBallastBonus" id="txtBallastBonus" style="width:90px;" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="<?php echo $obj->getFun145();?>" placeholder="0.00"></td>
													<td></td>
												</tr>
												<tr>
													<td>Gross Hire-age (USD)</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtGrossHireargeAmt" id="txtGrossHireargeAmt" style="width:90px;" class="input-text" value="<?php echo $obj->getFun230();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Add Comm <span style="font-size:10px; font-style:italic;">(%)</span></td>
													<td>:</td>
													<td><input type="text"  name="txtHireargePercent" style="width:90px;" id="txtHireargePercent" class="input-text" value="<?php echo $obj->getFun129();?>" placeholder="%" onKeyUp="getFinalCalculation();"/></td>
													<td><input type="text"  name="txtHireargePercentAmt" style="width:90px;" id="txtHireargePercentAmt" class="input-text" value="<?php echo $obj->getFun130();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Brokerage <span style="font-size:10px; font-style:italic;">(%)</span></td>
													<td>:</td>
													<td><input type="text"  name="txtHireargeBroPercent" style="width:90px;" id="txtHireargeBroPercent" class="input-text" value="<?php echo $obj->getFun237();?>" placeholder="%" onKeyUp="getFinalCalculation();"/></td>
													<td><input type="text"  name="txtHireargeBroPercentAmt" style="width:90px;" id="txtHireargeBroPercentAmt" class="input-text" value="<?php echo $obj->getFun238();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Nett Hire-age (USD)</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtNettHireargeAmt" id="txtNettHireargeAmt" style="width:90px;" class="input-text" value="<?php echo $obj->getFun131();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>CVE <span style="font-size:10px; font-style:italic;">(Per Month)</span></td>
													<td>:</td>
													<td><input type="text"  name="txtHireargeCVE" style="width:90px;" id="txtHireargeCVE" class="input-text" value="<?php echo $obj->getFun231();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													<td><input type="text"  name="txtHireargeCVEAMT" style="width:90px;" id="txtHireargeCVEAMT" class="input-text" value="<?php echo $obj->getFun232();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													<td></td>
												</tr>
												<tr>
													<td>CVE Off Hire <span style="font-size:10px; font-style:italic;">(Per Month)</span></td>
													<td>:</td>
													<td><input type="text"  name="txtOffHireCVE" style="width:90px;" id="txtOffHireCVE" class="input-text" value="<?php echo $obj->getFun233();?>" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td>
													<td><input type="text"  name="txtOffHireCVEAMT" style="width:90px;" id="txtOffHireCVEAMT" class="input-text" value="<?php echo $obj->getFun234();?>" placeholder="0.00" readonly="true"/></td>
													<td></td>
												</tr>
												<tr>
													<td>Bunker on Owner's Account</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtTCBunkerOnOwnerAmt" style="width:90px;" id="txtTCBunkerOnOwnerAmt" class="input-text" value="" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Off Hire</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtLessOffHire" style="width:90px;" id="txtLessOffHire" class="input-text" value="<?php echo $obj->getFun235();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												<tr>
													<td>Final Hire-age</td>
													<td>:</td>
													<td></td>
													<td><input type="text"  name="txtFinalHireargeAmt" style="width:90px;" id="txtFinalHireargeAmt" class="input-text" value="<?php echo $obj->getFun236();?>" placeholder="0.00" readonly /></td>
													<td></td>
												</tr>
												
											</tbody>
										</table>
									 </div><!-- /.col -->
									 <div class="col-md-8">
										 <table class='tablesorter'>
											<tbody>
												<tr class="input-text">
												  <td>
													 <table width="100%">
														 <tr class="input-text">
															<td colspan="5"><strong>Delivery Bunkers</strong></td>
														 </tr>
														 <tr class="input-text">
														   <td>#</td>
														   <td>Bunker Grade</td>
														   <td>Qty(MT)</td>
														   <td>Bunker Date</td>
														   <td>Price USD/MT)</td>
														   <td>Amount(USD)</td>
														 </tr>
														 <tbody id="bunkerdelivery">
														<?php $sql3 = "select * from freight_cost_estimete_slave13 where FCAID='".$obj->getFun1()."' and IDENTITY='DEL'";
														 $result3 = mysql_query($sql3);
														 $num3 = mysql_num_rows($result3);$k = 0;
														 if($num3==0){$k++;?>
															<tr class="input-text" id="row_del_1">
															   <td><a href="#tbl1" onClick="removeDelBunker(1);" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td>
															   <td><select name="selDelBunker_1" class="input-text" style=" width:90px;" id="selDelBunker_1"><?php $obj->getBunkerList();?></select></td>
															   <td><input type="text" name="txtDelQty_1" id="txtDelQty_1" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelBunDate_1" id="txtDelBunDate_1" class="input-text" style="width:85px;" value="" placeholder="DD-MM-YYYY" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelPrice_1" id="txtDelPrice_1" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelAmount_1" id="txtDelAmount_1" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" autocomplete="off"/></td>
															</tr>
														<?php }else{
														   while($rows3 = mysql_fetch_assoc($result3))
														   {$k++;
														   if($rows3['BUNKER_DATE']=="" || $rows3['BUNKER_DATE']=="0000-00-00"  || $rows3['BUNKER_DATE']=="1970-01-01"){$txtDelBunDate = "";}else{$txtDelBunDate = date('d-m-Y',strtotime($rows3['BUNKER_DATE']));}
														   ?>
														     <tr class="input-text" id="row_del_<?php echo $k;?>">
															   <td><a href="#tbl1" onClick="removeDelBunker(<?php echo $k;?>);" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td>
															   <td><select name="selDelBunker_<?php echo $k;?>" class="input-text" style=" width:90px;" id="selDelBunker_<?php echo $k;?>"><?php $obj->getBunkerList();?></select></td>
															   <td><input type="text" name="txtDelQty_<?php echo $k;?>" id="txtDelQty_<?php echo $k;?>" class="input-text numeric" style="width:85px;" value="<?php echo $rows3['QTY'];?>" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelBunDate_<?php echo $k;?>" id="txtDelBunDate_<?php echo $k;?>" class="input-text" style="width:85px;" value="<?php echo $txtDelBunDate;?>" placeholder="DD-MM-YYYY" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelPrice_<?php echo $k;?>" id="txtDelPrice_<?php echo $k;?>" class="input-text numeric" style="width:85px;" value="<?php echo $rows3['PRICE'];?>" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtDelAmount_<?php echo $k;?>" id="txtDelAmount_<?php echo $k;?>" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="<?php echo $rows3['AMOUNT'];?>" placeholder="0.00" autocomplete="off"/></td>
															</tr>
														   <script>$("#selDelBunker_<?php echo $k;?>").val(<?php echo $rows3['BUNKERID'];?>)</script>
													   <?php }}?>
														</tbody>
														<tbody>		
														<tr class="input-text">
															<td colspan="2"><button type="button" onClick="AddNewDel();">Add Bunkers</button><input type="hidden" name="txtDELID" id="txtDELID" value="<?=$k;?>"/></td>
															<td ></td>
															<td ></td>
															<td ></td>
															<td ><input type="text" name="txtTotalDelAmount" id="txtTotalDelAmount" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" autocomplete="off"/></td>
															
														</tr>
													 </table>
												  </td>
												</tr>
												<tr class="input-text">
												  <td>
													 <table width="100%">
														<tr class="input-text">
															<td colspan="5"><strong>Re-Delivery Bunkers</strong></td>
														</tr>
														<tr class="input-text">
														   <td>#</td>
														   <td>Bunker Grade</td>
														   <td>Qty(MT)</td>
														   <td>Bunker Date</td>
														   <td>Price USD/MT)</td>
														   <td>Amount(USD)</td>
														</tr>
														<tbody id="bunkerRedelivery">
														<?php $sql3 = "select * from freight_cost_estimete_slave13 where FCAID='".$obj->getFun1()."' and IDENTITY='REDEL'";
														 $result3 = mysql_query($sql3);
														 $num3 = mysql_num_rows($result3);$k = 0;
														 if($num3==0){$k++;?>
															<tr class="input-text" id="row_Redel_1">
															   <td><a href="#tbl1" onClick="removeReDelBunker(1);" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td>
															   <td><select name="selReDelBunker_1" class="input-text" style=" width:90px;" id="selReDelBunker_1"><?php $obj->getBunkerList();?></select></td>
															   <td><input type="text" name="txtReDelQty_1" id="txtReDelQty_1" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelBunDate_1" id="txtReDelBunDate_1" class="input-text" style="width:85px;" value="" placeholder="DD-MM-YYYY" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelPrice_1" id="txtReDelPrice_1" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelAmount_1" id="txtReDelAmount_1" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" autocomplete="off"/></td>
															</tr>
														  <?php }else{
														   while($rows3 = mysql_fetch_assoc($result3))
														   {$k++;
														   if($rows3['BUNKER_DATE']=="" || $rows3['BUNKER_DATE']=="0000-00-00"  || $rows3['BUNKER_DATE']=="1970-01-01"){$txtReDelBunDate = "";}else{$txtReDelBunDate = date('d-m-Y',strtotime($rows3['BUNKER_DATE']));}
														   ?>
															 <tr class="input-text" id="row_Redel_<?php echo $k;?>">
															   <td><a href="#tbl<?php echo $k;?>" onClick="removeReDelBunker(<?php echo $k;?>);" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td>
															   <td><select name="selReDelBunker_<?php echo $k;?>" class="input-text" style=" width:90px;" id="selReDelBunker_<?php echo $k;?>"><?php $obj->getBunkerList();?></select></td>
															   <td><input type="text" name="txtReDelQty_<?php echo $k;?>" id="txtReDelQty_<?php echo $k;?>" class="input-text numeric" style="width:85px;" value="<?php echo $rows3['QTY'];?>" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelBunDate_<?php echo $k;?>" id="txtReDelBunDate_<?php echo $k;?>" class="input-text" style="width:85px;" value="<?php echo $txtReDelBunDate;?>" placeholder="DD-MM-YYYY" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelPrice_<?php echo $k;?>" id="txtReDelPrice_<?php echo $k;?>" class="input-text numeric" style="width:85px;" value="<?php echo $rows3['PRICE'];?>" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td>
															   <td><input type="text" name="txtReDelAmount_<?php echo $k;?>" id="txtReDelAmount_<?php echo $k;?>" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="<?php echo $rows3['AMOUNT'];?>" placeholder="0.00" autocomplete="off"/></td>
															</tr>
														   <script>$("#selReDelBunker_<?php echo $k;?>").val(<?php echo $rows3['BUNKERID'];?>)</script>
													   <?php }}?>
														</tbody>
														<tbody>		
														<tr class="input-text">
															<td colspan="2"><button type="button" onClick="AddNewReDel();">Add Bunkers</button><input type="hidden" name="txtREDELID" id="txtREDELID" value="<?=$k;?>"/></td>
															<td ></td>
															<td ></td>
															<td ></td>
															<td ><input type="text" name="txtTotalReDelAmount" id="txtTotalReDelAmount" readonly class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" autocomplete="off"/></td>
														</tr>
														</tbody>
													 </table>
												  
												  </td>
												</tr>
											</tbody>
										</table>    
										<table width="100%">
										<tr class="input-text">
											<td colspan="5"><strong>Off Hire</strong></td>
										 </tr>
										<tr class="input-text">
										   <td></th>
										   <td>Off Hire Reason</td>
										   <td>Off Hire From</td>
										   <td>Off Hire To</td>
										   <td>Off Hire Days</td>
										   <td>Off Hire Rate/Day(USD)</td>
										   <td>Off Hire(USD)</td>
										   
										</tr>
										<tbody id="offhirebody">
	                             <?php $sql3 = "select * from freight_cost_estimete_slave14 where FCAID='".$obj->getFun1()."'";
                                 $result3 = mysql_query($sql3);
                                 $num3 = mysql_num_rows($result3);$k = 0;
                                 if($num3==0){$k++;?>
                                    <tr class="input-text" id="row_offhire_<?php echo $k;?>">
                                        <td><a href="#tb1" onClick="removeOffHire(<?php echo $k;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
                                        <td valign="top"><textarea class="input-text areasize" name="txtOffHireReason_<?php echo $k;?>" style="width:120px;" id="txtOffHireReason_<?php echo $k;?>" rows="3" placeholder="Off Hire Reason..."></textarea></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireFrom_<?php echo $k;?>" id="txtOffHireFrom_<?php echo $k;?>" class="input-text" value="" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireTo_<?php echo $k;?>" id="txtOffHireTo_<?php echo $k;?>" class="input-text" value="" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireDays_<?php echo $k;?>" id="txtOffHireDays_<?php echo $k;?>" class="input-text" placeholder="Off Hire Days" style="width:90px;background-color:#EAEAEA;" readonly value="" ></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireRate_<?php echo $k;?>" id="txtOffHireRate_<?php echo $k;?>" class="input-text" placeholder="Rate/Day(USD)" style="width:100px;" onKeyUp="getFinalCalculation();" value="" ></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireAmt_<?php echo $k;?>" id="txtOffHireAmt_<?php echo $k;?>" class="input-text" placeholder="Off Hire(USD)" style="width:90px;background-color:#EAEAEA;" readonly value="" ></td>
                                       
                                    </tr>
									<tr id="row_offhireBunker_<?php echo $k;?>">
										<td></td>
										<td colspan="6">
											<table width="100%" class='tablesorter'>
											  <tr>
												<td></td>
												<td>Bunker Grade</td>
												<td>Qty(MT)</td>
												<td>Price(USD)</td>
												<td>Amount(USD)</td>
												<td>On Owner's Account</td>
											  </tr>
											  <tbody id="TCConbunkerTBody_<?php echo $k;?>">
											  <tr id="DivTCConBunkeractual_<?php echo $k;?>_1">
												<td><a href="#tb1'" onClick="removeTCConBunkerRows(<?php echo $k;?>,1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
												<td><select name="selTCConBunker_<?php echo $k;?>_1" id="selTCConBunker_<?php echo $k;?>_1" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
												<td><input type="text" name="txtTCConBunkerQty_<?php echo $k;?>_1" id="txtTCConBunkerQty_<?php echo $k;?>_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
												<td><input type="text" name="txtTCConBunkerPrice_<?php echo $k;?>_1" id="txtTCConBunkerPrice_<?php echo $k;?>_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
												<td><input type="text" name="txtTCConBunkerAmt_<?php echo $k;?>_1" id="txtTCConBunkerAmt_<?php echo $k;?>_1" style="width:90px;background-color:#EAEAEA;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value=""/></td>
												<td><input name="ChkOFFHireCal_<?php echo $k;?>_1" class="checkbox" id="ChkOFFHireCal_<?php echo $k;?>_1" type="checkbox" value="1"/></td>
											  </tr>
											</tbody>
											  <tr>
												<td colspan="6"><button type="button" onClick="addTCConBunkerRow(<?php echo $k;?>)">Add Bunkers</button><input type="hidden" name="txtTCConBunkerCount_<?php echo $k;?>" id="txtTCConBunkerCount_<?php echo $k;?>" value="<?php echo $k;?>"/></td>
											  </tr>
											</table>
										</td>
									</tr>
                                <?php }else{
                                   while($rows3 = mysql_fetch_assoc($result3))
                                   {$k++;?>
                                     <tr class="input-text" id="row_offhire_<?php echo $k;?>">
                                        <td><a href="#tb1" onClick="removeOffHire(<?php echo $k;?>);" ><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtTCOFFhireRandom_<?php echo $k;?>" id="txtTCOFFhireRandom_<?php echo $k;?>" value="<?php echo $rows3['RANDOMID'];?>"/></td>
                                        <td valign="top"><textarea class="input-text areasize" name="txtOffHireReason_<?php echo $k;?>" style="width:120px;" id="txtOffHireReason_<?php echo $k;?>" rows="2" placeholder="Off Hire Reason..."><?php echo $rows3['OFF_REASON'];?></textarea></td>
                                        <?php if($rows3['OFF_FROM']=='0000-00-00 00:00:00' || $rows3['OFF_FROM']=='1970-01-01 08:00:00'){$offfrom = '';}else{$offfrom = date('d-m-Y H:i',strtotime($rows3['OFF_FROM']));}?>
                                        <?php if($rows3['OFF_TO']=='0000-00-00 00:00:00' || $rows3['OFF_TO']=='1970-01-01 08:00:00'){$offto = '';}else{$offto = date('d-m-Y H:i',strtotime($rows3['OFF_TO']));}?>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireFrom_<?php echo $k;?>" id="txtOffHireFrom_<?php echo $k;?>" class="input-text" value="<?php echo $offfrom;?>" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireTo_<?php echo $k;?>" id="txtOffHireTo_<?php echo $k;?>" class="input-text" value="<?php echo $offto;?>" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireDays_<?php echo $k;?>" id="txtOffHireDays_<?php echo $k;?>" class="input-text" placeholder="Off Hire Days" style="width:90px;background-color:#EAEAEA;" readonly value="<?php echo $rows3['OFF_DAYS'];?>" ></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireRate_<?php echo $k;?>" id="txtOffHireRate_<?php echo $k;?>" class="input-text" placeholder="Rate/Day(USD)" style="width:100px;" onKeyUp="getFinalCalculation();" value="<?php echo $rows3['HIRE_RATE'];?>" ></td>
                                        <td valign="top"><input autocomplete="off" type="text" name="txtOffHireAmt_<?php echo $k;?>" id="txtOffHireAmt_<?php echo $k;?>" class="input-text" placeholder="Off Hire(USD)" style="width:90px;background-color:#EAEAEA;" readonly value="<?php echo $rows3['OFF_HIRE'];?>" ></td>
                                       
                                    </tr>
									<tr id="row_offhireBunker_<?php echo $k;?>">
										<td></td>
										<td colspan="6">
											<table width="100%" class='tablesorter'>
											  <tr>
												<td></td>
												<td>Bunker Grade</td>
												<td>Qty(MT)</td>
												<td>Price(USD)</td>
												<td>Amount(USD)</td>
												<td>On Owner's Account</td>
											  </tr>
											  <tbody id="TCConbunkerTBody_<?php echo $k;?>">
											 <?php $sql4 = "select * from freight_cost_estimete_slave15 where FCAID='".$obj->getFun1()."' and FCA_SLAVE14ID='".$rows3['FCA_SLAVE14ID']."'";
											 $result4 = mysql_query($sql4);
											 $num4 = mysql_num_rows($result4);$m = 0;
											 if($num4==0){$m++;?>
											  <tr id="DivTCConBunkeractual_<?php echo $k;?>_1">
												<td><a href="#tb1'" onClick="removeTCConBunkerRows(<?php echo $k;?>,1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
												<td><select name="selTCConBunker_<?php echo $k;?>_1" id="selTCConBunker_<?php echo $k;?>_1" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
												<td><input type="text" name="txtTCConBunkerQty_<?php echo $k;?>_1" id="txtTCConBunkerQty_<?php echo $k;?>_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
												<td><input type="text" name="txtTCConBunkerPrice_<?php echo $k;?>_1" id="txtTCConBunkerPrice_<?php echo $k;?>_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td>
												<td><input type="text" name="txtTCConBunkerAmt_<?php echo $k;?>_1" id="txtTCConBunkerAmt_<?php echo $k;?>_1" style="width:90px;background-color:#EAEAEA;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value=""/></td>
												<td><input name="ChkOFFHireCal_<?php echo $k;?>_1" class="checkbox" id="ChkOFFHireCal_<?php echo $k;?>_1" type="checkbox" value="1"/></td>
											  </tr>
											 <?php }else{
											   while($rows4 = mysql_fetch_assoc($result4))
											   {$m++;?>
											   <tr id="DivTCConBunkeractual_<?php echo $k;?>_<?=$m;?>">
												<td><a href="#tb1'" onClick="removeTCConBunkerRows(<?php echo $k;?>,<?=$m;?>);" ><i class="fa fa-times" style="color:red;"></i></a></td>
												<td><select name="selTCConBunker_<?php echo $k;?>_<?=$m;?>" id="selTCConBunker_<?php echo $k;?>_<?=$m;?>" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td>
												<td><input type="text" name="txtTCConBunkerQty_<?php echo $k;?>_<?=$m;?>" id="txtTCConBunkerQty_<?php echo $k;?>_<?=$m;?>" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value="<?=$rows4['BUNKERQTY'];?>"/></td>
												<td><input type="text" name="txtTCConBunkerPrice_<?php echo $k;?>_<?=$m;?>" id="txtTCConBunkerPrice_<?php echo $k;?>_<?=$m;?>" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value="<?=$rows4['BUNKERPRICE'];?>"/></td>
												<td><input type="text" name="txtTCConBunkerAmt_<?php echo $k;?>_<?=$m;?>" id="txtTCConBunkerAmt_<?php echo $k;?>_<?=$m;?>" style="width:90px;background-color:#EAEAEA;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value="<?=$rows4['BUNKERAMT'];?>"/></td>
												<td><input name="ChkOFFHireCal_<?php echo $k;?>_<?=$m;?>" class="checkbox" id="ChkOFFHireCal_<?php echo $k;?>_<?=$m;?>" type="checkbox" value="1" <?php if($rows4['CHECK_BUNKER_CAL']==1){echo "checked";}?>/></td>
											  </tr>
											  <script>$("#selTCConBunker_<?php echo $k;?>_<?=$m;?>").val(<?=$rows4['BUNKERID'];?>);</script>
											  <?php }}?>
											</tbody>
											  <tr>
												<td colspan="6"><button type="button" onClick="addTCConBunkerRow(<?php echo $k;?>)">Add Bunkers</button><input type="hidden" name="txtTCConBunkerCount_<?php echo $k;?>" id="txtTCConBunkerCount_<?php echo $k;?>" value="<?=$m;?>"/></td>
											  </tr>
											</table>
										</td>
									</tr>
                                <?php }}?>
										</tbody>
										<tbody>		
											<tr class="input-text">
												<td ><button type="button" onClick="AddNewOffHire();">Add Off-Hire</button><input type="hidden" name="txtOFFID" id="txtOFFID" value="<?php echo $k;?>"/></td>
												<td colspan="7"></td>
												
											</tr>
										</tbody>
										</table>
									 </div><!-- /.col -->
								</div>
								
								
								<div class="row">
									 <div class="col-xs-12" style="text-align:right;">
										 <button type="button" class="btn btn-primary btn-flat" data-dismiss="modal">Close</button>       
									 </div><!-- /.col -->
								</div>
							</div>
							
						 </div>
					</div>
				</div>
                </form>
            </aside><!-- /.right-side -->
			<div class="modal fade" id="compose-modal" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog" style="width:95%;">
					 <div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;Cargo Planning</h4>
						</div>
						
						<div class="modal-body">
                            <div class="row">
                                 <div class="col-xs-2">
                                     <strong>Laycan Start From</strong>
									 <address>
                                     <input type="text" name="txtLaycanSDate" id="txtLaycanSDate" class="form-control" value="" placeholder"dd-mm-yy"/>
                                     </address>
                                 </div><!-- /.col -->
                                 <div class="col-xs-2">
                                     <strong>Laycan Start To</strong>
									 <address>
                                     <input type="text" name="txtLaycanEDate" id="txtLaycanEDate" class="form-control" value="" placeholder"dd-mm-yy"/> 
                                     </address>              
                                 </div><!-- /.col -->
                                 <div class="col-xs-2">
                                     <strong>Cargo</strong>
									 <address>
                                     <select type="text" name="selCargoPlan" id="selCargoPlan" class="form-control"><option value="">---Select From List---</option></select>   
									 </address>            
                                 </div><!-- /.col -->
                                 <div class="col-xs-2">
                                     <strong>From Cargo Size(MT)</strong>
									 <address>
                                     <input type="text" name="txtFromCargoSize" id="txtFromCargoSize" class="form-control" value="" placeholder""/>
                                     </address>
                                 </div><!-- /.col -->
                                 <div class="col-xs-2">
                                     <strong>To Cargo Size(MT)</strong>
									 <address>
                                     <input type="text" name="txtToCargoSize" id="txtToCargoSize" class="form-control" value="" placeholder""/> 
                                     </address>              
                                 </div><!-- /.col -->
                                 <div class="col-xs-2">
                                     <strong>&nbsp;</strong>
									 <address>
                                     <button type="button" class="btn btn-success btn-flat" onClick="getCargoPlanningDataList();">Load</button>
                                     </address>              
                                 </div><!-- /.col -->
                                 <script>$("#selCargoPlan").html($("#selCargoPlan").html()+''+$("#selMaterial<?php echo $_SESSION['selBType'];?>").html());</script>
                            </div>
                            <h3 style="text-align:center;">LIST OF CARGOES TO CHOOSE FROM</h3>
                            <div class="box-body table-responsive" style="overflow:auto;">
                                <table id="cargoplan_list" class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th align="left" valign="top" width="8%">CP ID</th>
                                            <th align="left" valign="top" width="7%">COA Date</th>
                                            <th align="left" valign="top" width="8%">Charterer</th>
                                            <th align="left" valign="top" width="8%">Owner </th>
                                            <th align="left" valign="top" width="8%">Cargo</th>
                                            <th align="left" valign="top" width="8%">Cargo Stem Size(MT)</th>
                                       <?php if($_SESSION['selBType']==1){?>
                                            <th align="left" valign="top" width="8%">Base Freight(USD/MT)/<br/>Lumpsum(USD)</th>
                                       <?php }if($_SESSION['selBType']==2){?>
                                       		<th align="left" valign="top" width="8%">WS(USD/MT)/<br/>Lumpsum(USD)</th>
                                       <?php }if($_SESSION['selBType']==3){?>
                                       		<th align="left" valign="top" width="8%">Frt<br/>(USD/MT)</th>
                                       <?php }?>
                                            <th align="left" valign="top" width="7%">Basin</th>
                                            <th align="left" valign="top" width="8%">LP</th>
                                            <th align="left" valign="top" width="7%">DP</th>
                                            <th align="left" valign="top" width="7%">Laycan Start</th>
                                            <th align="left" valign="top" width="7%">Laycan Finish</th>
                                            <th align="left" valign="top" width="8%">Vsl Type </th>
                                            <th align="center" valign="top" width="5%">Select</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                            <div class="row">
                                 <div class="col-xs-12" style="text-align:right;">
                                     <button type="button" class="btn btn-primary btn-flat" data-dismiss="modal">Close</button>       
                                 </div><!-- /.col -->
                            </div>
						</div>
                        
					 </div>
				</div>
			</div>
			
			<div class="modal fade" id="compose_modal_distance" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog" style="width:80%;">
					 <div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;Port to Port Distance</h4>
							<input type="hidden" id="portDistanceRowid" name="portDistanceRowid" value=""/>
						</div>
						
						<div class="modal-body">
                            <table class='tablesorter' width="100%">
								    <tr>
										<td width="20%"><b>From Port</b></td>
										<td width="20%"><b>To Port</b></td>
										<td width="15%"><b>Navigation Method</b></td>
										<td width="15%"><span id="spanGreatCircle1"><b>Great Circle Interval (n.m.)</b><br/>(Between 1 to 500)n.m.</span></td>
										<td width="15%"><b>SECA Area Avoidance  </b>(%)<br/>(Between 0 to 100)%</td>
										<td width="15%"><b>ASL Compliance </b>(%)<br/>(Between 0 to 100)%</td>
										<td width="20%"><b>Piracy Avoidance Settings</b></td>
										
									</tr>
									
									<tr>
										<td><span id="spanFromPort"></span></td>
										<td><span id="spanToPort"></span></td>
										
										<td><select name="selGreatCicle" id="selGreatCicle" class="input-text" style="width:100px;" onChange="getShowGreatCircleBox();"><option value="">---Select From List---</option><option value="1">Great-Circle</option><option value="2">Rhumb-Line</option></select></td>
										<td><span id="spanGreatCircle2"><select name="txtGreatCircleInterval" style="width:100px;" id="txtGreatCircleInterval" class="input-text">
										<?php
										for($i=0;$i<=500;$i++)
										{
										    echo '<option value="'.$i.'">'.$i.' n.m.</option>';
										}
										?>
										</select></span></td>
										<td>
										<select name="txtSecaAvoidance" style="width:100px;" id="txtSecaAvoidance" class="input-text">
										<?php
										for($i=0;$i<=100;$i++)
										{
										    echo '<option value="'.$i.'">'.$i.' %</option>';
										}
										?>
										</select>
										</td>
										<td>
										<select name="txtASLCompliance" style="width:100px;" id="txtASLCompliance" class="input-text">
										<?php
										for($i=0;$i<=100;$i++)
										{
										    echo '<option value="'.$i.'">'.$i.' %</option>';
										}
										?>
										</select>
										</td>
										<td><select name="selPiracyZone" id="selPiracyZone" class="input-text" style="width:200px;">
											<option value="">Somalia Zone 1 (farthest from Somalian coast, following the 65th meridian)</option>
											<option value="10001">Somalia Zone 2 (Closer to Somalian coast. It automatically enables 10001, following the 60th meridian)</option>
											<option value="10002">Somalia Zone 3 (Even closer to Somalian coast. It automatically enables 10002 and 10001, keeping 400-500n.m off Somalian coast)</option>
											<option value="10003">Somalia Zone 4 (Very Close to the coast. It automatically enables 10003, 10002 and 10001, keeping 250-300n.m off Somalian coast)</option>
											<option value="10004">NO Somalia Avoidance (De-activates Somalia avoidance completely and routes closest to the Somalian coast)</option>
											</select>
										</td>
										
									</tr>
									<tr>
										<td colspan="2"><b>Distance</b></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>
									<tr>
										<td colspan="6"><div id="distancemap1" style="width:100%; height:500px; vertical-align:middle; text-align:center; border:1px solid #D6D6D6; margin-bottom:10px;"><div id="distancemap" style="width:100%; height:500px; vertical-align:middle; text-align:center; border:1px solid #D6D6D6; margin-bottom:10px;">Show Map Here</div></td>
										<td style="padding:2px;"><b>Passage Names</b><br/>
										    <table width="100%">
											   <tr>
											        <td>Bahamas Canal</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_1" class="onoffswitch-checkbox" id="myonoffswitch_1" checked value="1">
														<label class="onoffswitch-label" for="myonoffswitch_1">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Magellan Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_2" class="onoffswitch-checkbox" id="myonoffswitch_2" checked value="2">
														<label class="onoffswitch-label" for="myonoffswitch_2">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Kiel Canal</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_3" class="onoffswitch-checkbox" id="myonoffswitch_3" checked value="3">
														<label class="onoffswitch-label" for="myonoffswitch_3">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Oresund strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_4" class="onoffswitch-checkbox" id="myonoffswitch_4" checked value="4">
														<label class="onoffswitch-label" for="myonoffswitch_4">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Panama Canal</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_5" class="onoffswitch-checkbox" id="myonoffswitch_5" checked value="5">
														<label class="onoffswitch-label" for="myonoffswitch_5">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Corinth Canal</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_6" class="onoffswitch-checkbox" id="myonoffswitch_6" checked value="6">
														<label class="onoffswitch-label" for="myonoffswitch_6">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Suez Canal</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_7" class="onoffswitch-checkbox" id="myonoffswitch_7" checked value="7">
														<label class="onoffswitch-label" for="myonoffswitch_7">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Bonifacio Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_8" class="onoffswitch-checkbox" id="myonoffswitch_8" checked value="8">
														<label class="onoffswitch-label" for="myonoffswitch_8">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Providence Channel</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_9" class="onoffswitch-checkbox" id="myonoffswitch_9" checked value="9">
														<label class="onoffswitch-label" for="myonoffswitch_9">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Messina Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_10" class="onoffswitch-checkbox" id="myonoffswitch_10" checked value="10">
														<label class="onoffswitch-label" for="myonoffswitch_10">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Spratly Passage</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_11" class="onoffswitch-checkbox" id="myonoffswitch_11" checked value="11">
														<label class="onoffswitch-label" for="myonoffswitch_11">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Kanmon Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_12" class="onoffswitch-checkbox" id="myonoffswitch_12" checked value="12">
														<label class="onoffswitch-label" for="myonoffswitch_12">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>La Perouse Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_13" class="onoffswitch-checkbox" id="myonoffswitch_13" checked  value="13">
														<label class="onoffswitch-label" for="myonoffswitch_13">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Unimak Pass</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_14" class="onoffswitch-checkbox" id="myonoffswitch_14" checked value="14">
														<label class="onoffswitch-label" for="myonoffswitch_14">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
											   <tr>
											        <td>Hainan Strait</td>
													<td>
													<div class="onoffswitch">
														<input type="text" name="onoffswitch_15" class="onoffswitch-checkbox" id="myonoffswitch_15" checked value="15">
														<label class="onoffswitch-label" for="myonoffswitch_15">
															<div class="onoffswitch-inner"></div>
															<div class="onoffswitch-switch"></div>
														</label>
													</div>
													</td>
											   </tr>
										    </table>
										</td>
									</tr>
								</tbody>
							</table>
							
                            <div class="row">
							     <div class="col-xs-4" style="text-align:left;">
								 <textarea style="display:none;" id="pointsTextArea1" name="pointsTextArea1" rows="4" class="form-control"></textarea>
								 <!--<textarea id="pointsTextArea" name="pointsTextArea" rows="5" class="form-control"></textarea>-->
								 </div>
								 <div class="col-xs-2" style="text-align:left;">
								    Total Distance
									<address>
										<span id="totalDistance">0.00</span>
									</address>
								 </div>
								 <div class="col-xs-2" style="text-align:left;">
								    (S)ECA Distance
									<address>
										<span id="totalSECADistance">0.00</span>
									</address>
								 </div>
                                 <div class="col-xs-4" style="text-align:right;">
									 <button type="button" class="btn btn-primary btn-flat" id="bttngetDistance" onClick="getdistancemap();">Get Distance</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-danger btn-flat" data-dismiss="modal" onClick="useDistance();" id="bttnuseDistance">Confirm Route</button>       
                                 </div><!-- /.col -->
                            </div>
						</div>
                        
					 </div>
				</div>
			    </div>
			</div>
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<link href="../../css/sort.css" rel="stylesheet" type="text/css" />
<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script src='../../js/jquery.autosize.js'></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.numeric.js"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.calculation-min.js"></script>
<link type='text/css' href='../../css/basic.css' rel='stylesheet' media='screen' />
<script src="../../js/chosen.jquery.js" type="text/javascript"></script>
<link href="../../css/datetimepicker/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/plugins/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link type="text/css" href="../../css/chosen.css" rel="stylesheet" />

<link rel="stylesheet" href="../../js/leaflet.css" />
<script src="../../js/leaflet.js"></script>
<script type='text/javascript' src="../../js/leaflet-editable-polyline.js"></script>
<script language="JavaScript" type="text/javascript" src="../../js/leaflet.edgebuffer.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
$("#selShipperCP,#selChartererCP,#selOwnerCP,#selReceiverCP").html($("#selVendor").html());
$('#txtDistributedRemarks').autosize({append: "\n"});
$("#selMType").chosen();
$(".numeric").numeric();
$("#selCName").chosen();
$("#frm1").validate({
	rules: {
		txtENo:"required",
		selVName:"required"
		},
	messages: {
		selVName:"*",
		
		},
submitHandler: function(form)  {
		jConfirm('Are you sure you have checked each entry ?', 'Confirmation', function(r) {
			if(r){
				var var3 = $("[id^=file_]").map(function () {return this.value;}).get().join(",");
				$('#txtCRMFILE').val(var3);
				var var2 = $("[id^=name_]").map(function () {return this.value;}).get().join(",");
				$('#txtCRMNAME').val(var2);
				var var3 = $("[id^=file1_]").map(function () {return this.value;}).get().join(",");
				$('#txtCRMFILE1').val(var3);
				var var2 = $("[id^=name1_]").map(function () {return this.value;}).get().join(",");
				$('#txtCRMNAME1').val(var2);
				jAlert('<b style="font-size:25px;">Please wait . . .</b><br><br><img src="../../img/loading.gif"  />', 'Alert');
				$("#popup_container").css({"background": "rgba(255,255,255,0.1)","border": "10px solid rgba(255,255,255,0.1)","width": "100%"});
				$("#popup_content").css({"background":"none","text-align":"center"});
				$("#popup_ok,#popup_title").hide();  
				frm1.submit();
			    }
				else{return false;}
			});
	}
});

$("#selVName").val(<?php echo $obj->getFun5();?>);
$("#selCType").val(<?php echo $obj->getFun51();?>);
$("#selFType").val(<?php echo $obj->getFun2();?>);
$("[id^=txtQtyAggriedFreight_],[id^=txtFreightQty_],#txtMTCPDRate,#txtAddnlCRate,#txtCQMT,#txtDFQMT,[id^=txtMCWS_],[id^=txtMCDistanceLeg_], [id^=txtMCTotalDistance_],[id^=txtOvrWS_],[id^=txtOvrDistanceLeg_],[id^=txtddswDPCost_],[id^=txtddswLPCost_],[id^=txtOvrTotalDistance_], [id^=txtAdditionAmt_],[id^=txtDeductionAmt_],#txtFrAdjUsdGF,#txtFrAdjPerACTF,#txtFrAdjPerACGF,[id^=txtOMCAbs_],#txtDWTS,#txtSF,#txtTFUMTManual, #txtTDUMTManual,#txtQtyAggriedFreight, #txtFreightQty,#txtQtyLocalAggriedFreight,#txtDisExchangeRate,#txtMarLocalAggriedFreight, #txtMarExchangeRate,[id^=txtORCAmt_],[id^=txtDistance_],[id^=txtWeather_],[id^=txtMargin_],[id^=txtPCosts_],[id^=txtQMT_],[id^=txtRate_],[id^=txtIDays_], [id^=txtDWDays_],[id^=txtWDays_],[id^=txtTLPCosts_],[id^=txtTLIDays_],#txtFrAdjPerAC,#txtFrAdjPerAgC,[id^=txtBrCommPercent_],[id^=txtORCAmt_],[id^=txtCCAbs_],#txtDailyVesselOperatingExpenses,[id^=txtEstDDCLPCost_],[id^=txtEstDDCDPCost_], #txtHireargePercent,#txtBallastBonus,#txtCVE,#txtQtyAggriedFreight, #txtFreightQty,#txtQtyLocalAggriedFreight,#txtDisExchangeRate,#txtMarLocalAggriedFreight, #txtMarExchangeRate,[id^=txtQtyLocalAggriedFreight_],[id^=txtDisExchangeRate_],[id^=txtMarLocalAggriedFreight_],[id^=txtMarExchangeRate_],#txtBFullSpeed,#txtBEcoSpeed1,#txtBEcoSpeed2,#txtBFOFullSpeed,#txtBFOEcoSpeed1,#txtBFOEcoSpeed2,#txtBDOFullSpeed,#txtBDOEcoSpeed1,#txtBDOEcoSpeed2,#txtLFullSpeed,#txtLEcoSpeed1,#txtLEcoSpeed2,#txtLFOFullSpeed,#txtLFOEcoSpeed1,#txtLFOEcoSpeed2,#txtLDOFullSpeed,#txtLDOEcoSpeed1,#txtLDOEcoSpeed2,#txtPIFOFullSpeed,#txtPWFOFullSpeed,#txtPIDOFullSpeed,#txtPWDOFullSpeed,#txtAddnlCRatePer,#txtBalticRate,#txtAdnlPrenium,#txtGasCQMT,#txtGASLumpsum,#txtFixedDiff,[id^=txtLPADDComm_],[id^=txtDPADDComm_],[id^=txtOtherAmt_],[id^=txtOtherAddComm_], #txtHireargeBroPercent").numeric();
$("[id^=txtMinCargoQty_],[id^=txtMinFlatRateQty_],[id^=txtMinWSQty_],[id^=txtMinDisLeg_],[id^=txtMinTotalDis_],[id^=txtMinAmount_],[id^=txtMinCargoQty_],[id^=txtOveFlatRateQty_],[id^=txtOveWSQty_],[id^=txtOveTotalDis_],[id^=txtOveAmount_],[id^=txtTotalTankQty_],[id^=txtOveDisLeg_],#txtLumpsumQty,#txtLumpsum,[id^=txtOffHireRate_],#txtHireargeCVE,#txtOffHireCVE").numeric();

$('[id^=txtOffHireFrom_],[id^=txtOffHireTo_]').datetimepicker({
		format: 'dd-mm-yyyy hh:ii',
		autoclose: true,
		todayBtn: true,
		minuteStep: 1
		}).on('changeDate', function(){
		getFinalCalculation();
		});
 
$("#txtDate,#txtCPDate,#txtETADate,#txtLaycanSDate,#txtLaycanEDate,[id^=txtDelBunDate_],[id^=txtReDelBunDate_]").datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true
});

$('[id^=ChkShowDDCDP_]').on('ifChecked', function () { 
   $("#DDCDProw_"+$(this).val()).hide();
});
 
$('[id^=ChkShowDDCDP_]').on('ifUnchecked', function () { 
   $("#DDCDProw_"+$(this).val()).show();
});
 
$('[id^=ChkShowDDCLP_]').on('ifChecked', function () { 
    $("#DDCLProw_"+$(this).val()).hide();
});
 
$('[id^=ChkShowDDCLP_]').on('ifUnchecked', function () { 
    $("#DDCLProw_"+$(this).val()).show();
});

$('[id^=ChkLPSECA_]').on('ifChecked', function () { 
   $(this).attr('checked', true);getVoyageTime();
});
 
$('[id^=ChkLPSECA_]').on('ifUnchecked', function () { 
   $(this).attr('checked', false);getVoyageTime();
});
 
$('[id^=ChkDPSECA_]').on('ifChecked', function () { 
    $(this).attr('checked', true);getVoyageTime();
});
 
$('[id^=ChkDPSECA_]').on('ifUnchecked', function () { 
    $(this).attr('checked', false);getVoyageTime();
});

$('[id^=ChkTPSECA_]').on('ifChecked', function () { 
    $(this).attr('checked', true);getVoyageTime();
});
 
$('[id^=ChkTPSECA_]').on('ifUnchecked', function () { 
    $(this).attr('checked', false);getVoyageTime();
});

$('[id^=ChkOFFHireCal_]').on('ifChecked', function () { 
   $(this).attr('checked', true);
   getFinalCalculation();
});
 
$('[id^=ChkOFFHireCal_]').on('ifUnchecked', function () { 
   $(this).attr('checked', false);
   getFinalCalculation();
});

$('#ChkLumpsum').on('ifChecked', function () { 
    $("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").show();
	$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").hide();
	getFinalCalculation();
});

$('#ChkLumpsum').on('ifUnchecked', function () { 
    $("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").hide();
	$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").show();
	getFinalCalculation();
});


$('#rdoTankType1').on('ifChecked', function () { 
    $("#divTankDistributed").hide();
	$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").show();
	getFinalCalculation();
});

$('#rdoTankType1').on('ifUnchecked', function () { 
    $("#divTankDistributed").show();
	$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").hide();
	getFinalCalculation();
});

$('#rdoTankType2').on('ifChecked', function () { 
    $("#divTankDistributed").show();
	$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").hide();
	getFinalCalculation();
});

$('#rdoTankType2').on('ifUnchecked', function () { 
    $("#divTankDistributed").hide();
	$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").show();
	getFinalCalculation();
});

$('[id^=ChkSECACalBunker_]').on('ifChecked', function () { 
	$("#txtSECABunkerPrice_"+$(this).val()).attr('readonly',false);
	$(this).attr('checked', true);
	getBunkerCalculation();
});
 
$('[id^=ChkSECACalBunker_]').on('ifUnchecked', function () { 
    $("#txtSECABunkerPrice_"+$(this).val()).val(0);
	$("#txtSECABunkerPrice_"+$(this).val()).attr('readonly',true);
	$(this).attr('checked', false);
	getBunkerCalculation();
});

$('[id^=ChkNONSECACalBunker_]').on('ifChecked', function () { 
    $("#txtNONSECABunkerPrice_"+$(this).val()).attr('readonly',false);
	$(this).attr('checked', true);
	getBunkerCalculation();
});
 
$('[id^=ChkNONSECACalBunker_]').on('ifUnchecked', function () { 
    $("#txtNONSECABunkerPrice_"+$(this).val()).val(0);
	$("#txtNONSECABunkerPrice_"+$(this).val()).attr('readonly',true);
	$(this).attr('checked', false);
	getBunkerCalculation();
});


$('#ChkOFFHireBunker').on('ifChecked', function () { 
    $('#ChkOFFHireBunker').prop('checked',true);
	
	getFinalCalculation();
});

$('#ChkOFFHireBunker').on('ifUnchecked', function () {
    $('#ChkOFFHireBunker').prop('checked',false);
	getFinalCalculation();
});


$('#txtLCSDate').datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true,
	todayBtn: true,
	minuteStep: 1
 }).on('changeDate', function(){
	$('#txtLCFDate').datepicker('setStartDate', new Date(getString($(this).val())));
 });
 
$('#txtLCFDate').datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true,
	todayBtn: true,
	minuteStep: 1
 }).on('changeDate', function(){   });
 
$('#txtFDate').datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true,
	todayBtn: true,
	minuteStep: 1
 }).on('changeDate', function(){
	$('#txtTDate').datepicker('setStartDate', new Date(getString($(this).val())));
 });
 
$('#txtTDate').datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true,
	todayBtn: true,
	minuteStep: 1
 }).on('changeDate', function(){   });


function getString(var1)
{
  var var2 = var1.split('-');  
  return var2[2]+'/'+var2[1]+'/'+var2[0];
}

$("#selZone").val(<?php echo $obj->getFun101();?>);
$("#selCOASpot").val(<?php echo $obj->getFun126();?>);

if($("#selCOASpot").val()==2)
{
	$("#tr_coa,#tr_coa1").show();
}
$("#selShipper").val('<?php echo $obj->getFun117();?>');
$("#selBroker").val('<?php echo $obj->getFun127();?>');
$("#selOwner").val('<?php echo $obj->getFun107();?>');
$("#selLPort").val(<?php echo $obj->getFun122();?>);
$("#selDPort").val(<?php echo $obj->getFun123();?>);
$("#selCOA").val(<?php echo $obj->getFun102();?>);
$("#selVCType").val(<?php echo $obj->getFun105();?>);
$("#txtDisponentOwner").val('<?php echo $obj->getFun108();?>');
<?php $sql5 = "select * from freight_cost_estimete_slave5 where FCAID='".$id."'";
$result5 = mysql_query($sql5);
$k =0;
while($rows5 = mysql_fetch_assoc($result5))
{$k = $k + 1;?>
$("#txtDisponentOwner_<?php echo $k;?>").val('<?php echo $rows5['DISPONENT_OWNER'];?>');
<?php }?>

<?php
$sql = "SELECT * FROM bunker_grade_master where STATUS=1";
$res = mysql_query($sql);
$rec = mysql_num_rows($res);
$m=0; 
while($rows = mysql_fetch_assoc($res)){
?>
$("#txt<?php echo $rows['NAME'];?>_1_2").numeric();
<?php } ?>

$("#txtNoLift").val(<?php echo $obj->getFun103();?>);
showQtyField(<?php echo $rdoQty;?>);
showCapField(<?php echo $rdoCap;?>);
getQtyLocalFreightCal();
getBunkerCalculation();
showHideEstimateTypeDiv(1);
showGasMarket(<?=$rdoQtyMar;?>);
getCargoPlanningdata(2);
showHideTankQtyVendorDiv(<?=$rdoTankQtyType;?>);
getReDelBunkerCalculation();
getDelBunkerCalculation();
var i=1;
$("[id^=myonoffswitch_]").each(function () {
	document.getElementById("myonoffswitch_"+i).setAttribute("type", "checkbox");
	i++;
});
$(".sidebar-toggle").click();
});

function getValue()
{
	
}

function showHideEstimateTypeDiv(val)
{
	if($("#rdoEstimateType").val()==1)
	{
		$("#distypeDiv3,#distypeDiv2,#tankgasnot1,#tankgasnot2,#tankgasnot3,#tankgasnot4").hide();
		$("#distypeDiv1").show();
		$("#loadtablelebel").html('(CBM/Hr)');
	    $("#dischargetablelebel").html('(CBM/Hr)');
		$("#loadqtylabel,#dischargeqtylabel").html('(MT)');
		if(val==2)
		{
			$('#selCName option:selected').removeAttr("selected");
			$('#selMType option:selected').removeAttr("selected");
			$('#selCName,#selMType').html($('#selMaterial1').html());
			$('#selCName,#selMType').trigger("liszt:updated");
			$("#selCName,#selMType").chosen();
		}
	}
	if($("#rdoEstimateType").val()==2)
	{
		$("#distypeDiv3,#distypeDiv1,#tankgasnot1,#tankgasnot2,#tankgasnot3,#tankgasnot4").hide();
		$("#distypeDiv2").show();
		$("#loadtablelebel").html('(MT/Hr)');
	    $("#dischargetablelebel").html('(MT/Hr)');
		$("#loadqtylabel,#dischargeqtylabel").html('(MT)');
		if(val==2)
		{
			$('#selCName option:selected').removeAttr("selected");
			$('#selMType option:selected').removeAttr("selected");
			$('#selCName,#selMType').html($('#selMaterial2').html());
			$('#selCName,#selMType').trigger("liszt:updated");
			$("#selCName,#selMType").chosen();
		}
	}
	
	if($("#rdoEstimateType").val()==3)
	{
		$("#distypeDiv2,#distypeDiv1").hide();
		$("#distypeDiv3,#tankgasnot1,#tankgasnot2,#tankgasnot3,#tankgasnot4").show();
		$("#loadtablelebel").html('(MT/Day)');
	    $("#dischargetablelebel").html('(MT/Day)');
		$("#loadqtylabel,#dischargeqtylabel").html('(MT)');
		if(val==2)
		{
			$('#selCName option:selected').removeAttr("selected");
			$('#selMType option:selected').removeAttr("selected");
			$('#selCName,#selMType').html($('#selMaterial3').html());
			$('#selCName,#selMType').trigger("liszt:updated");
			$("#selCName,#selMType").chosen();
		}
	}
}



function getMaterialCode()
{
	var mcode = "";
	$("#selMType option:selected").each(function () {
		var $this1 = $(this).text();
		if(mcode!=""){mcode = mcode+", ";}
		mcode = mcode+""+$this1.split("(")[1].replace(')','');
	});
    $("#txtMCode").val(mcode);
}

function getShow()
{
	if($("#selCOASpot").val() == 1 || $("#selCOASpot").val() == 3 || $("#selCOASpot").val() == 4)
	{
		$("#tr_coa,#tr_coa1").hide();
		$("#ttl_shipment").html("");
	}
	else if($("#selCOASpot").val() == 2)
	{
		$("#ttl_shipment").html("");
		$("#tr_coa,#tr_coa1").show();
	}
}


function addUI_Row()
{
	var id = $("#txtTID").val();
	
	if(id == 0)
	{
		if($("#txtDisponentOwner").val() != "")
		{
			id  = (id - 1 )+ 2;
			num = parseFloat(id +1);
			$('<tr><td width="11%">Disponent Owner '+num+' : </td><td width="89%"><select name="txtDisponentOwner_'+id+'" class="input-text" style="width:200px;" id="txtDisponentOwner_'+id+'"><?php $obj->getVendorListNewForCOA(11);?></select></td></tr>').appendTo("#sort");
			$("#txtTID").val(id);
		}
		else
		{
			jAlert('Please fill the above entries.', 'Alert');
		}
	}
	else
	{
		if($("#txtDisponentOwner_"+id).val() != "")
		{
			id  = (id - 1 )+ 2;
			num = parseFloat(id +1);
			$('<tr><td width="11%">Disponent Owner '+num+' : </td><td width="89%"><select name="txtDisponentOwner_'+id+'" class="input-text" style="width:200px;" id="txtDisponentOwner_'+num+'"><?php $obj->getVendorListNewForCOA(11);?></select></td></tr>').appendTo("#sort");
			$("#txtTID").val(id);
		}
		else
		{
			jAlert('Please fill the above entries.', 'Alert');
		}
	}	
}

function getData()
{
	  if($("#selVName").val()!="")
	  {
		  $.post("options.php?id=42",{vessel1d:""+$("#selVName").val()+""}, function(data) 
			{
				var vsldata = JSON.parse(data);
				$.each(vsldata[$("#selVName").val()], function(index, array) {
					if(array['num'] == "" || array['num']==0)
					{
						jAlert('Please ensure commercial parameters are completed before proceeding', 'Alert', function(r) {
						if(r){ 
							window.location="commercial_parameter.php?id="+$("#selVName").val();
							}
							else{return false;}
							});	
					}
					else
					{
						$('#txtVType').val(array['type']);
						$('#txtDWTS').val(array['dwtsum']);
						$('#txtGCap').val(array['grain']);
						$('#txtBCap').val(array['bale']);
						
						$('#txtBFullSpeed').val(array['bfs']);
						$('#txtBEcoSpeed1').val(array['bes1']);
						$('#txtBEcoSpeed2').val(array['bes2']);
						
						
						$('#txtLFullSpeed').val(array['lfs']);
						$('#txtLEcoSpeed1').val(array['les1']);
						$('#txtLEcoSpeed2').val(array['les2']);
						
						$('#vesselrec').val(array['num']);
						$('#txtFlag').val(array['flag']);
						$('#txtBuiltYear').val(array['year']);
						$('#txtGNRT').val(array['gnrt']);
						$('#txtLOA').val(array['loa']);
						$('#txtGear').val(array['gear']);
						$('#txtBeam').val(array['beam']);
						$('#txtTPC').val(array['tpc']);
						
						$('#txtSDWTMT').val(array['SDWTMT']);
						$('#txtSDWTLT').val(array['SDWTLT']);
						$('#txtSDraftM').val(array['SDraftM']);
						$('#txtSDraftFT').val(array['SDraftFT']);
						$('#txtTPIMT').val(array['TPIMT']);
						$('#txtTPILT').val(array['TPILT']);
						$('#txtTPCMT').val(array['TPCMT']);
						$('#txtTPCLT').val(array['TPCLT']);
						$('#txtConstantsMT').val(array['ConstantsMT']);
						$('#txtConstantsLT').val(array['ConstantsLT']);
						$('#txtGrainCapCBM').val(array['GrainCapCBM']);
						$('#txtGrainCapCFT').val(array['GrainCapCFT']);
						
						
					}
					
					var conspdata = array['laden_balast_consp'];
					$.each(conspdata, function(index1, array1) {
						var id = $("#txtFOAtSeaID").val();
						if(array1['IDENTIFY'] == "FO")
						{
							id = (id - 1) + 2;
							$('<tr id="FOAtSeaRow_'+id+'"><td align="right"><input type="hidden" name="txtFOAtSeaBunker_'+id+'" id="txtFOAtSeaBunker_'+id+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'</td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaSECAConspFS_'+id+'" id="txtFOBalAtSeaSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaSECAConspFS_'+id+'" id="txtFOLadAtSeaSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaNONSECAConspFS_'+id+'" id="txtFOBalAtSeaNONSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaNONSECAConspFS_'+id+'" id="txtFOLadAtSeaNONSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaSECAConspSS_'+id+'" id="txtFOBalAtSeaSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaSECAConspSS_'+id+'" id="txtFOLadAtSeaSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaNONSECAConspSS_'+id+'" id="txtFOBalAtSeaNONSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaNONSECAConspSS_'+id+'" id="txtFOLadAtSeaNONSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaSECAConspMES_'+id+'" id="txtFOBalAtSeaSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaSECAConspMES_'+id+'" id="txtFOLadAtSeaSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOBalAtSeaNONSECAConspMES_'+id+'" id="txtFOBalAtSeaNONSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOLadAtSeaNONSECAConspMES_'+id+'" id="txtFOLadAtSeaNONSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_MES']+'" readonly/></td></tr>').appendTo("#tbodyFOAtSea");
							$("#txtFOAtSeaID").val(id);
							
							var idd = $("#txtSECAConBunkerCount").val();
							idd = (idd - 1) + 2;
							$('<tr><td><input type="hidden" name="txtSECABunkerid_'+idd+'" id="txtSECABunkerid_'+idd+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'<input type="hidden" name="txtSECAIdentify_'+idd+'" id="txtSECAIdentify_'+idd+'" value="FO"/></td><td><input type="text" name="txtSECABunkerQty_'+idd+'" id="txtSECABunkerQty_'+idd+'" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value=""></td><td align="left" class="input-text" ><input name="ChkSECACalBunker_'+idd+'" class="checkbox" id="ChkSECACalBunker_'+idd+'" type="checkbox" value="'+idd+'" checked/></td><td><input type="text" name="txtSECABunkerPrice_'+idd+'" id="txtSECABunkerPrice_'+idd+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtSECABunkerAmt_'+idd+'" id="txtSECABunkerAmt_'+idd+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerEstimatedTBodySECA");
							$("#txtSECAConBunkerCount").val(idd);
							$(".numeric").numeric();
							
							var idd = $("#txtNONSECAConBunkerCount").val();
							idd = (idd - 1) + 2;
							$('<tr><td><input type="hidden" name="txtNONSECABunkerid_'+idd+'" id="txtNONSECABunkerid_'+idd+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'<input type="hidden" name="txtNONSECAIdentify_'+idd+'" id="txtNONSECAIdentify_'+idd+'" value="FO"/></td><td><input type="text" name="txtNONSECABunkerQty_'+idd+'" id="txtNONSECABunkerQty_'+idd+'" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value=""></td><td align="left" class="input-text" ><input name="ChkNONSECACalBunker_'+idd+'" class="checkbox" id="ChkNONSECACalBunker_'+idd+'" type="checkbox" value="'+idd+'" checked/></td><td><input type="text" name="txtNONSECABunkerPrice_'+idd+'" id="txtNONSECABunkerPrice_'+idd+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtNONSECABunkerAmt_'+idd+'" id="txtNONSECABunkerAmt_'+idd+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerEstimatedTBodyNONSECA");
							$("#txtNONSECAConBunkerCount").val(idd);
							$(".numeric").numeric();	
						}
						
						var id = $("#txtDOAtSeaID").val();
						if(array1['IDENTIFY'] == "DO")
						{
							id = (id - 1) + 2;
							$('<tr id="DOAtSeaRow_'+id+'"><td align="right"><input type="hidden" name="txtDOAtSeaBunker_'+id+'" id="txtDOAtSeaBunker_'+id+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'</td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaSECAConspFS_'+id+'" id="txtDOBalAtSeaSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaSECAConspFS_'+id+'" id="txtDOLadAtSeaSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaNONSECAConspFS_'+id+'" id="txtDOBalAtSeaNONSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaNONSECAConspFS_'+id+'" id="txtDOLadAtSeaNONSECAConspFS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_FS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaSECAConspSS_'+id+'" id="txtDOBalAtSeaSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaSECAConspSS_'+id+'" id="txtDOLadAtSeaSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaNONSECAConspSS_'+id+'" id="txtDOBalAtSeaNONSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaNONSECAConspSS_'+id+'" id="txtDOLadAtSeaNONSECAConspSS_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_SS']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaSECAConspMES_'+id+'" id="txtDOBalAtSeaSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_SECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaSECAConspMES_'+id+'" id="txtDOLadAtSeaSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_SECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOBalAtSeaNONSECAConspMES_'+id+'" id="txtDOBalAtSeaNONSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_BALAST_ATSEA_NONSECA_CONSP_MES']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOLadAtSeaNONSECAConspMES_'+id+'" id="txtDOLadAtSeaNONSECAConspMES_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_LADEN_ATSEA_NONSECA_CONSP_MES']+'" readonly/></td></tr>').appendTo("#tbodyDOAtSea");
							$("#txtDOAtSeaID").val(id);
							
							var idd = $("#txtSECAConBunkerCount").val();
							idd = (idd - 1) + 2;
							$('<tr><td><input type="hidden" name="txtSECABunkerid_'+idd+'" id="txtSECABunkerid_'+idd+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'<input type="hidden" name="txtSECAIdentify_'+idd+'" id="txtSECAIdentify_'+idd+'" value="DO"/></td><td><input type="text" name="txtSECABunkerQty_'+idd+'" id="txtSECABunkerQty_'+idd+'" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value=""></td><td align="left" class="input-text" ><input name="ChkSECACalBunker_'+idd+'" class="checkbox" id="ChkSECACalBunker_'+idd+'" type="checkbox" value="'+idd+'" checked/></td><td><input type="text" name="txtSECABunkerPrice_'+idd+'" id="txtSECABunkerPrice_'+idd+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtSECABunkerAmt_'+idd+'" id="txtSECABunkerAmt_'+idd+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerEstimatedTBodySECA");
							$("#txtSECAConBunkerCount").val(idd);
							$(".numeric").numeric();
							
							var idd = $("#txtNONSECAConBunkerCount").val();
							idd = (idd - 1) + 2;
							$('<tr><td><input type="hidden" name="txtNONSECABunkerid_'+idd+'" id="txtNONSECABunkerid_'+idd+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'<input type="hidden" name="txtNONSECAIdentify_'+idd+'" id="txtNONSECAIdentify_'+idd+'" value="DO"/></td><td><input type="text" name="txtNONSECABunkerQty_'+idd+'" id="txtNONSECABunkerQty_'+idd+'" style="width:90px;" class="input-text numeric" readonly placeholder="0.00" autocomplete="off" value=""></td><td align="left" class="input-text" ><input name="ChkNONSECACalBunker_'+idd+'" class="checkbox" id="ChkNONSECACalBunker_'+idd+'" type="checkbox" value="'+idd+'" checked/></td><td><input type="text" name="txtNONSECABunkerPrice_'+idd+'" id="txtNONSECABunkerPrice_'+idd+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtNONSECABunkerAmt_'+idd+'" id="txtNONSECABunkerAmt_'+idd+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="true" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerEstimatedTBodyNONSECA");
							$("#txtNONSECAConBunkerCount").val(idd);
							$(".numeric").numeric();
						}
						
						$("[id^=ChkNONSECACalBunker_],[id^=ChkSECACalBunker_]").iCheck({
							checkboxClass: 'icheckbox_minimal',
							radioClass: 'iradio_minimal'
						});
						
						$('[id^=ChkSECACalBunker_]').on('ifChecked', function () { 
							$("#txtSECABunkerPrice_"+$(this).val()).attr('readonly',false);
							$(this).attr('checked', true);
							getBunkerCalculation();
						});
						 
						$('[id^=ChkSECACalBunker_]').on('ifUnchecked', function () { 
							$("#txtSECABunkerPrice_"+$(this).val()).val(0);
							$("#txtSECABunkerPrice_"+$(this).val()).attr('readonly',true);
							$(this).attr('checked', false);
							getBunkerCalculation();
						});
						
						$('[id^=ChkNONSECACalBunker_]').on('ifChecked', function () { 
							$("#txtNONSECABunkerPrice_"+$(this).val()).attr('readonly',false);
							$(this).attr('checked', true);
							getBunkerCalculation();
						});
						 
						$('[id^=ChkNONSECACalBunker_]').on('ifUnchecked', function () { 
							$("#txtNONSECABunkerPrice_"+$(this).val()).val(0);
							$("#txtNONSECABunkerPrice_"+$(this).val()).attr('readonly',true);
							$(this).attr('checked', false);
							getBunkerCalculation();
						});
						
					});
					
					
					var conspdata1 = array['working_idle_consp'];
					$.each(conspdata1, function(index1, array1) {
						var id = $("#txtFOInPortID").val();
						if(array1['IDENTIFY'] == "FO")
						{
							id = (id - 1) + 2;
							$('<tr id="FOInPortRow_'+id+'"><td align="right"><input type="hidden" name="selFOInPortBunker_'+id+'" id="selFOInPortBunker_'+id+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'</td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortSECAConspWorking_'+id+'" id="txtFOInPortSECAConspWorking_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_WORKING']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortNONSECAConspWorking_'+id+'" id="txtFOInPortNONSECAConspWorking_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_WORKING']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortSECAConspIdle_'+id+'" id="txtFOInPortSECAConspIdle_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_IDLE']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortNONSECAConspIdle_'+id+'" id="txtFOInPortNONSECAConspIdle_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_IDLE']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortSECAConspOther_'+id+'" id="txtFOInPortSECAConspOther_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_OTHER']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortNONSECAConspOther_'+id+'" id="txtFOInPortNONSECAConspOther_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_OTHER']+'" readonly/></td></tr>').appendTo("#tbodyFOInPort");
							$("#txtFOInPortID").val(id);
						}
						
						var id = $("#txtDOInPortID").val();
						if(array1['IDENTIFY'] == "DO")
						{
							id = (id - 1) + 2;
							$('<tr id="DOInPortRow_'+id+'"><td align="right"><input type="hidden" name="selDOInPortBunker_'+id+'" id="selDOInPortBunker_'+id+'" value="'+array1['BUNKERID']+'"/>'+array1['BUNKER_NAME']+'</td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortSECAConspWorking_'+id+'" id="txtDOInPortSECAConspWorking_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_WORKING']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortNONSECAConspWorking_'+id+'" id="txtDOInPortNONSECAConspWorking_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_WORKING']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortSECAConspIdle_'+id+'" id="txtDOInPortSECAConspIdle_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_IDLE']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortNONSECAConspIdle_'+id+'" id="txtDOInPortNONSECAConspIdle_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_IDLE']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortSECAConspOther_'+id+'" id="txtDOInPortSECAConspOther_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_SECA_CONSP_OTHER']+'" readonly/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortNONSECAConspOther_'+id+'" id="txtDOInPortNONSECAConspOther_'+id+'" class="input-text autocomplete="off" value="'+array1['FO_INPORT_NONSECA_CONSP_OTHER']+'" readonly/></td></tr>').appendTo("#tbodyDOInPort");
							$("#txtDOInPortID").val(id);
						}
					});
					getVoyageTime();
				});
				
			});  
	  }
	  else
	  {
		  $('#txtVType,#txtDWTS,#txtGCap,#txtBCap,#txtBFullSpeed,#txtBEcoSpeed1,#txtBEcoSpeed2,#txtBFOFullSpeed,#txtBFOEcoSpeed1,#txtBFOEcoSpeed2,#txtBDOFullSpeed,#txtBDOEcoSpeed1,#txtBDOEcoSpeed2,#txtLFullSpeed,#txtLEcoSpeed1,#txtLEcoSpeed2,#txtLFOFullSpeed,#txtLFOEcoSpeed1,#txtLFOEcoSpeed2,#txtLDOFullSpeed,#txtLDOEcoSpeed1,#txtLDOEcoSpeed2,#txtPIFOFullSpeed,#txtPWFOFullSpeed,#txtPIDOFullSpeed,#txtPWDOFullSpeed,#vesselrec,#txtFlag,#txtGear,#txtBuiltYear,#txtGNRT,#txtLOA,#rdoEstimateType, #txtSDWTMT, #txtSDWTLT, #txtSDraftM, #txtSDraftFT, #txtTPIMT, #txtTPILT, #txtTPCMT, #txtTPCLT, #txtConstantsMT, #txtConstantsLT, #txtGrainCapCBM, #txtGrainCapCFT').val("");
		  $("#tbodyDOAtSea,#tbodyFOAtSea,#tbodyFOInPort,#tbodyDOInPort").empty();
		  getVoyageTime();
	  }
	  
}


function showMMarketField(value)
{
	
	if(value == 1)
	{
		$("#txtMTCPDRate").removeAttr('disabled');
		$("#txtMLumpsum").attr('disabled',true);
		$("#txtMTCPDRate,#txtMLumpsum").val("");
		$("#txtMTCPDRate").focus();
		getFinalCalculation();
	}
	if(value == 2)
	{			
		$("#txtMTCPDRate").attr('disabled',true);
		$("#txtMLumpsum").removeAttr('disabled');
		$("#txtMTCPDRate,#txtMLumpsum").val("");
		$("#txtMLumpsum").focus();
		getFinalCalculation();
	}
}

function showQtyField(val)
{
	if(val == 1)
	{
		$("#txtDFQMT").removeAttr('disabled');
		$("#txtAddnlQMT").attr('disabled',true);
		$("#txtAddnlQMT").val("");
		$("#txtDFQMT").focus();
	}
	if(val == 2)
	{
		$("#txtDFQMT").attr('disabled',true);
		$("#txtAddnlQMT").removeAttr('disabled');
		$("#txtDFQMT").val("");
		$("#txtAddnlQMT").focus();
	}
	getFinalCalculation();
}


function getBunkerCalculation()
{
        var totalfoConsumption = totaldoConsumption = 0;
	    var txtSECAConBunkerCount = $("#txtSECAConBunkerCount").val();
		for(var i=1;i<=txtSECAConBunkerCount;i++)
		{
		    var txtSECABunkerQty = $("#txtSECABunkerQty_"+i).val();
			var txtSECABunkerPrice = $("#txtSECABunkerPrice_"+i).val();
		    if($("#ChkSECACalBunker_"+i).is(":checked"))
			{
			    if($("#txtSECAIdentify_"+i).val()=='FO')
			    {
				    totalfoConsumption = parseFloat(totalfoConsumption) + parseFloat(txtSECABunkerQty);
				}
				if($("#txtSECAIdentify_"+i).val()=='DO')
			    {
				    totaldoConsumption = parseFloat(totaldoConsumption) + parseFloat(txtSECABunkerQty);
				}
			}
			var calc = parseFloat(txtSECABunkerQty) * parseFloat(txtSECABunkerPrice);if(isNaN(calc)){calc =0; }
			$("#txtSECABunkerAmt_"+i).val(calc.toFixed(2));
		}
		$("#txtTotalSECAConsumption").val($("[id^=txtSECABunkerAmt_]").sum().toFixed(2));
		
		var txtNONSECAConBunkerCount = $("#txtNONSECAConBunkerCount").val();
		for(var i=1;i<=txtNONSECAConBunkerCount;i++)
		{
		    var txtNONSECABunkerQty = $("#txtNONSECABunkerQty_"+i).val();
			var txtNONSECABunkerPrice = $("#txtNONSECABunkerPrice_"+i).val();
			
		    if($("#ChkNONSECACalBunker_"+i).is(":checked"))
			{
			    if($("#txtNONSECAIdentify_"+i).val()=='FO')
			    {
				    totalfoConsumption = parseFloat(totalfoConsumption) + parseFloat(txtNONSECABunkerQty);
				}
				if($("#txtNONSECAIdentify_"+i).val()=='DO')
			    {
				    totaldoConsumption = parseFloat(totaldoConsumption) + parseFloat(txtNONSECABunkerQty);
				}
			}
			var calc = parseFloat(txtNONSECABunkerQty) * parseFloat(txtNONSECABunkerPrice);if(isNaN(calc)){calc =0; }
			$("#txtNONSECABunkerAmt_"+i).val(calc.toFixed(2));
		}
		$("#txtTotalNONSECAConsumption").val($("[id^=txtNONSECABunkerAmt_]").sum().toFixed(2));
		
		$("#txtTFUMT").val(totalfoConsumption.toFixed(2));$("#txtTDUMT").val(totaldoConsumption.toFixed(2));
		
		$("#txtTotalBunkerCost").val($("#txtTotalNONSECAConsumption,#txtTotalSECAConsumption").sum().toFixed(2));
		
		var txtBunkerCount = $("#txtBunkerCount").val();
		for(var i=1;i<=txtBunkerCount;i++)
		{
			var txtBunkerQty = $("#txtBunkerQty_"+i).val();if(isNaN(txtBunkerQty)){txtBunkerQty =0; }
			var txtBunkerPrice = $("#txtBunkerPrice_"+i).val();if(isNaN(txtBunkerPrice)){txtBunkerPrice =0; }
			var calc = parseFloat(txtBunkerQty) * parseFloat(txtBunkerPrice);
			if(isNaN(calc)){calc =0; }
			$("#txtBunkerAmt_"+i).val(calc.toFixed(2));
		}
		
		var txtConBunkerCount = $("#txtConBunkerCount").val();
		for(var i=1;i<=txtConBunkerCount;i++)
		{
			var txtConBunkerQty = $("#txtConBunkerQty_"+i).val();if(isNaN(txtConBunkerQty)){txtConBunkerQty =0; }
			var txtConBunkerPrice = $("#txtConBunkerPrice_"+i).val();if(isNaN(txtConBunkerPrice)){txtConBunkerPrice =0; }
			var calc = parseFloat(txtConBunkerQty) * parseFloat(txtConBunkerPrice);
			if(isNaN(calc)){calc =0; }
			$("#txtConBunkerAmt_"+i).val(calc.toFixed(2));
		}
		
		if($("[id^=txtConBunkerAmt_]").sum() > 0){$("#txtTotalBunkerCost").val($("[id^=txtConBunkerAmt_]").sum().toFixed(2));}
	getFinalCalculation();
}




function getVoyageTime()
{
	
	$("#txtBDays,#txtLDays").val(0);
	$("#txtLDist,#txtBDist,#txtTDUMT,#txtTFUMT").val(0);
	var ladendays = ballastdays = idealdays = workingdays = consumptiondo = consumptionfo =  0;
	var id = $("#p_rotationID").val();
	for(var i=1;i<=id;i++)
	{
	    if($("#txtMargin_"+i).val() == ""){var margin = 0;}else{var margin = $("#txtMargin_"+i).val();}
		if($("#txtDistance_"+i).val() == ""){var distance = 0;}else{var distance = $("#txtDistance_"+i).val();}
		if($("#txtSecaDistance_"+i).val() == ""){var secaDistance = 0;}else{var secaDistance = $("#txtSecaDistance_"+i).val();}if(isNaN(secaDistance)){secaDistance = 0;}
		var nonSECADistance = parseFloat(distance) - parseFloat(secaDistance);
		if($("#selPType_"+i).val() == 1)
		{
			if($("#selSSpeed_"+i).val() == 1)
			{
				var ballast = $("#txtBFullSpeed").val();
			}
			if($("#selSSpeed_"+i).val() == 2)
			{
				var ballast = $("#txtBEcoSpeed1").val();
			}
			if($("#selSSpeed_"+i).val() == 3)
			{
				var ballast = $("#txtBEcoSpeed2").val();
			}
			//---------------non seca--------------
			var spd = (parseFloat(nonSECADistance) / parseFloat(ballast));
			var calc = spd/24;
			var ttl_days = parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100);
			
			//------------seca---------
			var secaspd = (parseFloat(secaDistance) / parseFloat(ballast));
			var secacalc = secaspd/24;
			var ttl_secadays = parseFloat(secacalc) + parseFloat(parseFloat(parseFloat(secacalc)*parseFloat(margin))/100);
		
			var totalpassagedays = parseFloat(ttl_days.toFixed(3)) + parseFloat(ttl_secadays.toFixed(3));
			ballastdays = ballastdays + parseFloat(totalpassagedays.toFixed(3));
			var ttl_dis = parseFloat(distance);
			$("#txtBDist").val(ttl_dis.toFixed(2));
			$("#txtTDist").val($("#txtBDist,#txtLDist").sum().toFixed(2));
			$("#txtTtlDays_"+i).val(totalpassagedays.toFixed(3));
			$("#txtSecaDays_"+i).val(ttl_secadays.toFixed(3));
		}
		if($("#selPType_"+i).val() == 2)
		{
			if($("#selSSpeed_"+i).val() == 1)
			{
				var ladan = $("#txtLFullSpeed").val();
			}
			if($("#selSSpeed_"+i).val() == 2)
			{
				var ladan = $("#txtLEcoSpeed1").val();
			}
			if($("#selSSpeed_"+i).val() == 3)
			{
				var ladan = $("#txtLEcoSpeed2").val();
			}
			
			//-------------------non seca---------------------
			var spd = (parseFloat(nonSECADistance) / parseFloat(ladan));
			var calc = spd/24;
			var ttl_days = parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100);
			
			//------------------------------------seca------------------------------------
			var secaspd = (parseFloat(secaDistance) / parseFloat(ladan));
			var secacalc = secaspd/24;
			var ttl_secadays = parseFloat(secacalc) + parseFloat(parseFloat(parseFloat(secacalc)*parseFloat(margin))/100);
			
			var totalpassagedays = parseFloat(ttl_days.toFixed(3)) + parseFloat(ttl_secadays.toFixed(3));
			ladendays = parseFloat(ladendays) + parseFloat(totalpassagedays.toFixed(3));
			var ttl_dis = parseFloat(distance);
			$("#txtLDist").val(ttl_dis.toFixed(2));
			$("#txtTDist").val($("#txtBDist,#txtLDist").sum().toFixed(2));
			$("#txtTtlDays_"+i).val(totalpassagedays.toFixed(3));
			$("#txtSecaDays_"+i).val(ttl_secadays.toFixed(3));
		}
		
		
		if($("#txtIDays_"+i).val() == ""){var idle_days = 0;}else{var idle_days = $("#txtIDays_"+i).val();}
		if($("#txtWDays_"+i).val() == ""){var w_days = 0;}else{var w_days = $("#txtWDays_"+i).val();}	
		idealdays = parseFloat(idealdays) + parseFloat(idle_days);
		var ttl_days1 = parseFloat(w_days);
		var ttl_days = parseFloat(ttl_days1);
		workingdays = parseFloat(workingdays) + parseFloat(ttl_days);
		
		//Dis Port
		if($("#txtDIDays_"+i).val() == ""){var idle_days = 0;}else{var idle_days = $("#txtDIDays_"+i).val();}
		if($("#txtDWDays_"+i).val() == ""){var w_days = 0;}else{var w_days = $("#txtDWDays_"+i).val();}
		idealdays = parseFloat(idealdays) + parseFloat(idle_days);
		var ttl_days1 = parseFloat(w_days);
		var ttl_days = parseFloat(ttl_days1);
		workingdays = parseFloat(workingdays) + parseFloat(ttl_days);
		
		//transit 
		if($("#txtTLIDays_"+i).val() == ""){var idle_days = 0;}else{var idle_days = $("#txtTLIDays_"+i).val();}
		idealdays = parseFloat(idealdays) + parseFloat(idle_days);
	}
	
	if(isNaN(ladendays) || ladendays=="")
	{ladendays = 0;	}
	$("#txtLDays").val(ladendays.toFixed(3));
	if(isNaN(ballastdays) || ballastdays=="")
	{ballastdays = 0;	}
	$("#txtBDays").val(ballastdays.toFixed(3));
	if(isNaN(idealdays) || idealdays=="")
	{idealdays = 0;	}
	if(isNaN(workingdays) || workingdays=="")
	{workingdays = 0;	}
	$("#txtTtPIDays").val(parseFloat(idealdays.toFixed(3)));$("#txtTtPWDays").val(parseFloat(workingdays.toFixed(3)));
	$("#txtTSDays").val($("#txtBDays,#txtLDays").sum().toFixed(3));
	$("#txtTDays").val($("#txtTSDays,#txtTtPIDays,#txtTtPWDays").sum().toFixed(2));
	$("#txtTotalVoyageDays").val($("#txtTDays").val());
	
	
	
	var txtSECAConBunkerCount = $("#txtSECAConBunkerCount").val();
	for(var i = 1;i <= parseInt(txtSECAConBunkerCount);i++)
	{
	    var totalconspfo = totalconspdo = 0;
	    if($("#txtSECAIdentify_"+i).val() == 'FO')
		{
		    var txtFOAtSeaID = $("#txtFOAtSeaID").val();
			for(var j=1;j<=parseInt(txtFOAtSeaID);j++)
			{
			    if($("#txtFOAtSeaBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
					    var foconspparameter = 0;
						if($("#selPType_"+k).val() == '1')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var foconspparameter = $("#txtFOBalAtSeaSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var foconspparameter = $("#txtFOBalAtSeaSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var foconspparameter = $("#txtFOBalAtSeaSECAConspMES_"+j).val();
							} 
						}
						
						if($("#selPType_"+k).val() == '2')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var foconspparameter = $("#txtFOLadAtSeaSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var foconspparameter = $("#txtFOLadAtSeaSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var foconspparameter = $("#txtFOLadAtSeaSECAConspMES_"+j).val();
							} 
						}
						if(isNaN(foconspparameter)){foconspparameter = 0;}
						var txtSecaDays = parseFloat($("#txtSecaDays_"+k).val());
						var foconsp = parseFloat(txtSecaDays)*parseFloat(foconspparameter); 
						if(isNaN(foconsp)){foconsp = 0;}if(isNaN(foconspparameter)){foconspparameter = 0;}
						totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp);
					}
				}
			}
			
			var txtFOInPortID = $("#txtFOInPortID").val();
			for(var j=1;j<=parseInt(txtFOAtSeaID);j++)
			{
			    if($("#selFOInPortBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
						if($("#ChkLPSECA_"+k).is(":checked"))
						{
						    var txtWDays = $("#txtWDays_"+k).val();if(isNaN(txtWDays)){txtWDays = 0;}
							var txtIDays = $("#txtIDays_"+k).val();if(isNaN(txtIDays)){txtIDays = 0;}
							
							var foconspworking = $("#txtFOInPortSECAConspWorking_"+j).val();if(isNaN(foconspworking)){foconspworking = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							
							var foconsp1 = parseFloat(txtWDays)*parseFloat(foconspworking);if(isNaN(foconsp1)){foconsp1 = 0;}
							var foconsp2 = parseFloat(txtIDays)*parseFloat(foconspidle);if(isNaN(foconsp2)){foconsp2 = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2);
						}
						
						if($("#ChkDPSECA_"+k).is(":checked"))
						{
						    var txtDWDays = $("#txtDWDays_"+k).val();if(isNaN(txtDWDays)){txtDWDays = 0;}
							var txtDIDays = $("#txtDIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							
							var foconspworking = $("#txtFOInPortSECAConspWorking_"+j).val();if(isNaN(foconspworking)){foconspworking = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							
							var foconsp1 = parseFloat(txtDWDays)*parseFloat(foconspworking);if(isNaN(foconsp1)){foconsp1 = 0;}
							var foconsp2 = parseFloat(txtDIDays)*parseFloat(foconspidle);if(isNaN(foconsp2)){foconsp2 = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2);
						}
						
						if($("#ChkTPSECA_"+k).is(":checked"))
						{
							var txtDIDays = $("#txtTLIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							var foconsp = parseFloat(txtDIDays)*parseFloat(foconspidle);if(isNaN(foconsp)){foconsp = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp);
						}
					}
				}     
			}
			
			$("#txtSECABunkerQty_"+i).val(totalconspfo.toFixed(2));
		}
		
		if($("#txtSECAIdentify_"+i).val() == 'DO')
		{
		    var txtDOAtSeaID = $("#txtDOAtSeaID").val();
			for(var j=1;j<=parseInt(txtDOAtSeaID);j++)
			{
			    if($("#txtDOAtSeaBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k=1;k<=parseInt(id);k++)
					{   
					    var doconspparameter = 0;
						if($("#selPType_"+k).val() == '1')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var doconspparameter = $("#txtDOBalAtSeaSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var doconspparameter = $("#txtDOBalAtSeaSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var doconspparameter = $("#txtDOBalAtSeaSECAConspMES_"+j).val();
							} 
						}
						
						if($("#selPType_"+k).val() == '2')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var doconspparameter = $("#txtDOLadAtSeaSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var doconspparameter = $("#txtDOLadAtSeaSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var doconspparameter = $("#txtDOLadAtSeaSECAConspMES_"+j).val();
							} 
						}
						
						if(isNaN(doconspparameter)){doconspparameter = 0;}
						var txtSecaDays = parseFloat($("#txtSecaDays_"+k).val());
						var doconsp = parseFloat(txtSecaDays)*parseFloat(doconspparameter);
						if(isNaN(doconsp)){doconsp = 0;}
						totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp);
					}
				}
			}
			
			var txtDOInPortID = $("#txtDOInPortID").val();
			for(var j=1;j<=parseInt(txtDOInPortID);j++)
			{
			    if($("#selDOInPortBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
						if($("#ChkLPSECA_"+k).is(":checked"))
						{
						    var txtWDays = $("#txtWDays_"+k).val();if(isNaN(txtWDays)){txtWDays = 0;}
							var txtIDays = $("#txtIDays_"+k).val();if(isNaN(txtIDays)){txtIDays = 0;}
							
							var doconspworking = $("#txtDOInPortSECAConspWorking_"+j).val();if(isNaN(doconspworking)){doconspworking = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							
							var doconsp1 = parseFloat(txtWDays)*parseFloat(doconspworking);if(isNaN(doconsp1)){doconsp1 = 0;}
							var doconsp2 = parseFloat(txtIDays)*parseFloat(doconspidle);if(isNaN(doconsp2)){doconsp2 = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2);
						}
						
						if($("#ChkDPSECA_"+k).is(":checked"))
						{
						    var txtDWDays = $("#txtDWDays_"+k).val();if(isNaN(txtDWDays)){txtDWDays = 0;}
							var txtDIDays = $("#txtDIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							
							var doconspworking = $("#txtDOInPortSECAConspWorking_"+j).val();if(isNaN(doconspworking)){doconspworking = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							
							var doconsp1 = parseFloat(txtDWDays)*parseFloat(doconspworking);if(isNaN(doconsp1)){doconsp1 = 0;}
							var doconsp2 = parseFloat(txtDIDays)*parseFloat(doconspidle);if(isNaN(doconsp2)){doconsp2 = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2);
						}
						
						if($("#ChkTPSECA_"+k).is(":checked"))
						{
							var txtDIDays = $("#txtTLIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							var doconsp = parseFloat(txtDIDays)*parseFloat(doconspidle);if(isNaN(doconsp)){doconsp = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp);
						}
					}
				}     
			}
			$("#txtSECABunkerQty_"+i).val(totalconspdo.toFixed(2));
		}
	}
	
	
	var txtNONSECAConBunkerCount = $("#txtNONSECAConBunkerCount").val();
	for(var i = 1;i <= parseInt(txtNONSECAConBunkerCount);i++)
	{
	    var totalconspfo = totalconspdo = 0;
	    if($("#txtNONSECAIdentify_"+i).val() == 'FO')
		{
		    var txtFOAtSeaID = $("#txtFOAtSeaID").val();
			for(var j=1;j<=parseInt(txtFOAtSeaID);j++)
			{
			    if($("#txtFOAtSeaBunker_"+j).val() == $("#txtNONSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
					    var foconspparameter = 0;
						if($("#selPType_"+k).val() == '1')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var foconspparameter = $("#txtFOBalAtSeaNONSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var foconspparameter = $("#txtFOBalAtSeaNONSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var foconspparameter = $("#txtFOBalAtSeaNONSECAConspMES_"+j).val();
							} 
						}
						
						if($("#selPType_"+k).val() == '2')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var foconspparameter = $("#txtFOLadAtSeaNONSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var foconspparameter = $("#txtFOLadAtSeaNONSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var foconspparameter = $("#txtFOLadAtSeaNONSECAConspMES_"+j).val();
							} 
						}
						if(isNaN(foconspparameter)){foconspparameter = 0;}
						if($("#txtTtlDays_"+k).val() == ""){var txtTtlDays = 0;}else{var txtTtlDays = $("#txtTtlDays_"+k).val();}if(isNaN(txtTtlDays)){txtTtlDays = 0;}
						if($("#txtSecaDays_"+k).val() == ""){var txtSecaDays = 0;}else{var txtSecaDays = $("#txtSecaDays_"+k).val();}if(isNaN(txtSecaDays)){txtSecaDays = 0;}
						var nonSECAdays = parseFloat(txtTtlDays) - parseFloat(txtSecaDays);
						//alert(nonSECAdays);
						var foconsp = parseFloat(nonSECAdays)*parseFloat(foconspparameter); 
						if(isNaN(foconsp)){foconsp = 0;}if(isNaN(foconspparameter)){foconspparameter = 0;}
						totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp);
					}
				}
			}
			
			var txtFOInPortID = $("#txtFOInPortID").val();
			for(var j=1;j<=parseInt(txtFOAtSeaID);j++)
			{
			    if($("#selFOInPortBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
						if(!$("#ChkLPSECA_"+k).is(":checked"))
						{
						    var txtWDays = $("#txtWDays_"+k).val();if(isNaN(txtWDays)){txtWDays = 0;}
							var txtIDays = $("#txtIDays_"+k).val();if(isNaN(txtIDays)){txtIDays = 0;}
							
							var foconspworking = $("#txtFOInPortSECAConspWorking_"+j).val();if(isNaN(foconspworking)){foconspworking = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							
							var foconsp1 = parseFloat(txtWDays)*parseFloat(foconspworking);if(isNaN(foconsp1)){foconsp1 = 0;}
							var foconsp2 = parseFloat(txtIDays)*parseFloat(foconspidle);if(isNaN(foconsp2)){foconsp2 = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2);
						}
						
						if(!$("#ChkDPSECA_"+k).is(":checked"))
						{
						    var txtDWDays = $("#txtDWDays_"+k).val();if(isNaN(txtDWDays)){txtDWDays = 0;}
							var txtDIDays = $("#txtDIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							
							var foconspworking = $("#txtFOInPortSECAConspWorking_"+j).val();if(isNaN(foconspworking)){foconspworking = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							
							var foconsp1 = parseFloat(txtDWDays)*parseFloat(foconspworking);if(isNaN(foconsp1)){foconsp1 = 0;}
							var foconsp2 = parseFloat(txtDIDays)*parseFloat(foconspidle);if(isNaN(foconsp2)){foconsp2 = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2);
						}
						
						if(!$("#ChkTPSECA_"+k).is(":checked"))
						{
							var txtDIDays = $("#txtTLIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							var foconspidle = $("#txtFOInPortSECAConspIdle_"+j).val();if(isNaN(foconspidle)){foconspidle = 0;}
							var foconsp = parseFloat(txtDIDays)*parseFloat(foconspidle);if(isNaN(foconsp)){foconsp = 0;}
							totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp);
						}
					}
				}     
			}
			
			$("#txtNONSECABunkerQty_"+i).val(totalconspfo.toFixed(2));
		}
		
		if($("#txtNONSECAIdentify_"+i).val() == 'DO')
		{
		    var txtDOAtSeaID = $("#txtDOAtSeaID").val();
			for(var j=1;j<=parseInt(txtDOAtSeaID);j++)
			{
			    if($("#txtDOAtSeaBunker_"+j).val() == $("#txtNONSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k=1;k<=parseInt(id);k++)
					{   
					    var doconspparameter = 0;
						if($("#selPType_"+k).val() == '1')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var doconspparameter = $("#txtDOBalAtSeaNONSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var doconspparameter = $("#txtDOBalAtSeaNONSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var doconspparameter = $("#txtDOBalAtSeaNONSECAConspMES_"+j).val();
							} 
						}
						
						if($("#selPType_"+k).val() == '2')
						{
							if($("#selSSpeed_"+k).val() == '1')
							{
								var doconspparameter = $("#txtDOLadAtSeaNONSECAConspFS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '2')
							{
								var doconspparameter = $("#txtDOLadAtSeaNONSECAConspSS_"+j).val();
							}
							if($("#selSSpeed_"+k).val() == '3')
							{
								var doconspparameter = $("#txtDOLadAtSeaNONSECAConspMES_"+j).val();
							} 
						}
						
						if($("#txtTtlDays_"+k).val() == ""){var txtTtlDays = 0;}else{var txtTtlDays = $("#txtTtlDays_"+k).val();}if(isNaN(txtTtlDays)){txtTtlDays = 0;}
						if($("#txtSecaDays_"+k).val() == ""){var txtSecaDays = 0;}else{var txtSecaDays = $("#txtSecaDays_"+k).val();}if(isNaN(txtSecaDays)){txtSecaDays = 0;}
						var nonSECAdays = parseFloat(txtTtlDays) - parseFloat(txtSecaDays);
						
						if(isNaN(doconspparameter)){doconspparameter = 0;}
						var doconsp = parseFloat(nonSECAdays)*parseFloat(doconspparameter);
						if(isNaN(doconsp)){doconsp = 0;}
						totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp);
					}
				}
			}
			
			var txtDOInPortID = $("#txtDOInPortID").val();
			for(var j=1;j<=parseInt(txtDOInPortID);j++)
			{
			    if($("#selDOInPortBunker_"+j).val() == $("#txtSECABunkerid_"+i).val())
				{
					var id = $("#p_rotationID").val();
					for(var k = 1;k <= parseInt(id); k++)
					{
						if(!$("#ChkLPSECA_"+k).is(":checked"))
						{
						    var txtWDays = $("#txtWDays_"+k).val();if(isNaN(txtWDays)){txtWDays = 0;}
							var txtIDays = $("#txtIDays_"+k).val();if(isNaN(txtIDays)){txtIDays = 0;}
							
							var doconspworking = $("#txtDOInPortSECAConspWorking_"+j).val();if(isNaN(doconspworking)){doconspworking = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							
							var doconsp1 = parseFloat(txtWDays)*parseFloat(doconspworking);if(isNaN(doconsp1)){doconsp1 = 0;}
							var doconsp2 = parseFloat(txtIDays)*parseFloat(doconspidle);if(isNaN(doconsp2)){doconsp2 = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2);
						}
						if(!$("#ChkDPSECA_"+k).is(":checked"))
						{
						    var txtDWDays = $("#txtDWDays_"+k).val();if(isNaN(txtDWDays)){txtDWDays = 0;}
							var txtDIDays = $("#txtDIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							
							var doconspworking = $("#txtDOInPortSECAConspWorking_"+j).val();if(isNaN(doconspworking)){doconspworking = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							
							var doconsp1 = parseFloat(txtDWDays)*parseFloat(doconspworking);if(isNaN(doconsp1)){doconsp1 = 0;}
							var doconsp2 = parseFloat(txtDIDays)*parseFloat(doconspidle);if(isNaN(doconsp2)){doconsp2 = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2);
						}
						
						if(!$("#ChkTPSECA_"+k).is(":checked"))
						{
							var txtDIDays = $("#txtTLIDays_"+k).val();if(isNaN(txtDIDays)){txtDIDays = 0;}
							var doconspidle = $("#txtDOInPortSECAConspIdle_"+j).val();if(isNaN(doconspidle)){doconspidle = 0;}
							var doconsp = parseFloat(txtDIDays)*parseFloat(doconspidle);if(isNaN(doconsp)){doconsp = 0;}
							totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp);
						}
					}
				}     
			}
			$("#txtNONSECABunkerQty_"+i).val(totalconspdo.toFixed(2));
		}
	}
	getBunkerCalculation();
}



function addPortRotationDetails()
{
	var id = idd = $("#p_rotationID").val();
	if($("#selFPort_"+id).val() != "" && $("#selTPort_"+id).val() != "" && $("#selPType_"+id).val() != "" && $("#txtDistance_"+id).val() != "" && $("#selSSpeed_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="pr_Row_'+id+'"><td align="center" class="input-text" ><a href="#pr'+id+'" id="spcancel_'+id+'" onclick="removePortRotation('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td align="left" class="input-text" ><input type="text" class="input-text" name="selFPort_'+id+'" id="selFPort_'+id+'" autocomplete="off" value=""/><input type="hidden" name="txtCordinates_'+id+'" id="txtCordinates_'+id+'" value=""/></td><td align="left" class="input-text" ><input type="text" class="input-text" name="selTPort_'+id+'" id="selTPort_'+id+'" autocomplete="off" value=""/></td><td align="left" class="input-text" ><select  name="selDType_'+id+'" class="input-text" style="width:90px;" id="selDType_'+id+'"><?php $obj->getPortDistanceType_new(); ?></select></td><td align="left" class="input-text" ><select name="selPType_'+id+'" class="input-text" style="width:90px;" id="selPType_'+id+'" onChange="getVoyageTime();" ><?php $obj->getPassageType(); ?></select></td><td align="left" class="input-text" ><select  name="selSSpeed_'+id+'" class="input-text" id="selSSpeed_'+id+'" style="width:90px;" onChange="getVoyageTime();" ><?php $obj->getSelectSpeedList(); ?></select></td><td align="left" class="input-text" ><button type="button" data-toggle="modal" data-target="#compose_modal_distance" class="btn-danger btn-flat" onClick="getShowModel('+id+');"><b>Fetch</b></button></td><td align="left" class="input-text" ><input type="text" name="txtDistance_'+id+'" style="width:70px;" id="txtDistance_'+id+'" class="input-text"  value="" placeholder="0.00" autocomplete="off" onKeyUp="getVoyageTime();" /></td><td align="left" class="input-text" ><input type="text" name="txtTtlDays_'+id+'" id="txtTtlDays_'+id+'" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00"/></td><td align="left" class="input-text" ><input type="text" name="txtSecaDistance_'+id+'" id="txtSecaDistance_'+id+'" style="width:60px;" class="input-text numeric" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input type="text" name="txtSecaDays_'+id+'" id="txtSecaDays_'+id+'" style="width:60px;" class="input-text" readonly="true" autocomplete="off" placeholder="0.00"/></td><td align="left" class="input-text" ><input type="text" name="txtMargin_'+id+'" style="width:60px;" id="txtMargin_'+id+'" class="input-text" autocomplete="off" placeholder="0.00"  onKeyUp="getVoyageTime();" /><input type="hidden" name="txtVoyageTime_'+id+'" id="txtVoyageTime_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" /><input type="hidden" name="txtTTLVoyageDays_'+id+'" id="txtTTLVoyageDays_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" /><input type="hidden" name="txtTTLFoConsp_'+id+'" id="txtTTLFoConsp_'+id+'" class="input-text" readonly value="0.00"  /><input type="hidden" name="txtTTLDoConsp_'+id+'" id="txtTTLDoConsp_'+id+'" class="input-text" readonly value="0.00"  /></td></tr>').appendTo("#tblPortRotation");
		
		$('<tr id="lp_Row_'+id+'"><td align="center" class="input-text" ><span id="spanLoadPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtPCosts_'+id+'" id="txtPCosts_'+id+'" class="input-text" autocomplete="off" value="" style="width:80px;" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtQMT_'+id+'" id="txtQMT_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><input type="text" name="txtRate_'+id+'" id="txtRate_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><select  name="selLPTerms_'+id+'" class="input-text" style="width:80px;" id="selLPTerms_'+id+'" onChange="getLPRemoveDaysAttr('+id+'),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select></td><td align="left" class="input-text"><input type="text" name="txtWDays_'+id+'" id="txtWDays_'+id+'" class="input-text"  style="width:80px;"  autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();"/></td><td align="left" class="input-text"><input type="text" name="txtIDays_'+id+'" id="txtIDays_'+id+'" class="input-text"  style="width:80px;"  autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input name="ChkShowDDCLP_'+id+'" class="checkbox" id="ChkShowDDCLP_'+id+'" type="checkbox" value="'+id+'"/></td><td align="left" class="input-text" ><input name="ChkLPSECA_'+id+'" class="checkbox" id="ChkLPSECA_'+id+'" type="checkbox" value="'+id+'"/></td></tr>').appendTo("#tblLoadPort");
		
		
		$('<tr id="dp_Row_'+id+'"><td align="center" class="input-text" ><span id="spanDisPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtDCosts_'+id+'" id="txtDCosts_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtDQMT_'+id+'" id="txtDQMT_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><input type="text" name="txtDRate_'+id+'" id="txtDRate_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><select  name="selDPTerms_'+id+'" class="input-text" style="width:80px;" id="selDPTerms_'+id+'" onChange="getDPRemoveDaysAttr('+id+'),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select></td><td align="left" class="input-text" ><input type="text" name="txtDWDays_'+id+'" id="txtDWDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();"/></td><td align="left" class="input-text" ><input type="text" name="txtDIDays_'+id+'" id="txtDIDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input name="ChkShowDDCDP_'+id+'" class="checkbox" id="ChkShowDDCDP_'+id+'" type="checkbox" value="'+id+'"/></td><td align="left" class="input-text" ><input name="ChkDPSECA_'+id+'" class="checkbox" id="ChkDPSECA_'+id+'" type="checkbox" value="'+id+'"/></td></tr>').appendTo("#tblDisPort");
		
		
		$('<tr id="tp_Row_'+id+'"><td align="center" class="input-text" ><span id="TranDisPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtTLPCosts_'+id+'" id="txtTLPCosts_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp= "getPortCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtTLIDays_'+id+'" id="txtTLIDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input name="ChkTPSECA_'+id+'" class="checkbox" id="ChkTPSECA_'+id+'" type="checkbox" value="'+id+'"/></td></tr>').appendTo("#tblTransitPort");
		
		
		$('<tr id="DDCLProw_'+id+'"><td>Load Port <span id="spanDDCLPort_'+id+'"></span></td><td><input type="text"  name="txtEstDDCLPCost_'+id+'" id="txtEstDDCLPCost_'+id+'" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /><input type="hidden" name="txtLPLayTimeIs_'+id+'" id="txtLPLayTimeIs_'+id+'" value="" /></td><td><input type="text"  name="txtDDCLPCost_'+id+'" id="txtDDCLPCost_'+id+'" class="input-text" value="0" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td><td><input type="text"  name="txtLPADDComm_'+id+'" id="txtLPADDComm_'+id+'" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td><td><input type="text" name="txtDDCLPNetCostMT_'+id+'" id="txtDDCLPNetCostMT_'+id+'" class="input-text" readonly value="" /><input type="hidden" name="txtDDCLPCostMT_'+id+'" id="txtDDCLPCostMT_'+id+'" class="input-text" readonly value="0" /></td></tr><tr id="DDCDProw_'+id+'"><td>Discharge Port <span id="spanDDCDPort_'+id+'"></span></td><td><input type="text"  name="txtEstDDCDPCost_'+id+'" id="txtEstDDCDPCost_'+id+'" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /><input type="hidden" name="txtDPLayTimeIs_'+id+'" id="txtDPLayTimeIs_'+id+'" value="" /></td><td><input type="text"  name="txtDDCDPCost_'+id+'" id="txtDDCDPCost_'+id+'" class="input-text" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly autocomplete="off"/></td><td><input type="text"  name="txtDPADDComm_'+id+'" id="txtDPADDComm_'+id+'" class="input-text" value="" placeholder="0.00" autocomplete="off" onKeyUp="getFinalCalculation();" /></td><td><input type="text" name="txtDDCDPNetCostMT_'+id+'" id="txtDDCDPNetCostMT_'+id+'" class="input-text" readonly value="" /><input type="hidden" name="txtDDCDPCostMT_'+id+'" id="txtDDCDPCostMT_'+id+'" class="input-text" readonly value="0" /></td></tr>').appendTo("#tbDDCBody");
		$("[id^=txtDistance_],[id^=txtWeather_],[id^=txtMargin_],[id^=txtPCosts_],[id^=txtQMT_],[id^=txtRate_],[id^=txtIDays_],[id^=txtDWDays_],[id^=txtWDays_],[id^=txtTLPCosts_],[id^=txtTLIDays_],[id^=txtEstDDCLPCost_],[id^=txtEstDDCDPCost_],[id^=txtLPADDComm_],[id^=txtDPADDComm_]").numeric();
		
		$("#selFPort_"+id).select2({
			minimumInputLength: 3,
			placeholder: '---Select from list---',
			allowClear: true,
			ajax: {
				url: "options.php?id=83",
				dataType: 'json',
				quietMillis: 100,
				data: function(term, page) {
					return {
						limit: -1,
						q: term
					};
				},
				results: function(data, page ) {
					return { results: data }
				}
			},
			formatResult: function(doc) { 
				return "<div class='select2-user-result'>" + doc.name + "</div>"; 
			},
			formatSelection: function(doc) { 
				return  doc.name; 
			}
		}).on("change", function (e) {
			getPortText();
		});
		
		$("#selTPort_"+id).select2({
			minimumInputLength: 3,
			placeholder: '---Select from list---',
			allowClear: true,
			ajax: {
				url: "options.php?id=83",
				dataType: 'json',
				quietMillis: 100,
				data: function(term, page) {
					return {
						limit: -1,
						q: term
					};
				},
				results: function(data, page ) {
					return { results: data }
				}
			},
			formatResult: function(doc) { 
				return "<div class='select2-user-result'>" + doc.name + "</div>"; 
			},
			formatSelection: function(doc) { 
				return  doc.name; 
			}
		}).on("change", function (e) {
			getPortText();
		});
		
		$("[id^=ChkShowDDCLP_],[id^=ChkShowDDCDP_],[id^=ChkLPSECA_],[id^=ChkDPSECA_],[id^=ChkTPSECA_]").iCheck({
			checkboxClass: 'icheckbox_minimal',
			radioClass: 'iradio_minimal'
		});
		
		if($("#selTPort_"+idd).val()!='')
		{
			$("#selFPort_"+id).select2("data", {id: $("#selTPort_"+idd).val(), name: $("#selTPort_"+idd).select2('data').name});
		}
		
		//.........ends...................
		$("#p_rotationID").val(id);
		
		$('[id^=ChkShowDDCDP_]').on('ifChecked', function () { 
		   $("#DDCDProw_"+$(this).val()).hide();
		});
		 
		$('[id^=ChkShowDDCDP_]').on('ifUnchecked', function () { 
		   $("#DDCDProw_"+$(this).val()).show();
		});
		 
		$('[id^=ChkShowDDCLP_]').on('ifChecked', function () { 
			$("#DDCLProw_"+$(this).val()).hide();
		});
		 
		$('[id^=ChkShowDDCLP_]').on('ifUnchecked', function () { 
			$("#DDCLProw_"+$(this).val()).show();
		});
		
		$('[id^=ChkLPSECA_]').on('ifChecked', function () { 
		   $(this).attr('checked', true);getVoyageTime();
		});
		 
		$('[id^=ChkLPSECA_]').on('ifUnchecked', function () { 
		   $(this).attr('checked', false);getVoyageTime();
		});
		 
		$('[id^=ChkDPSECA_]').on('ifChecked', function () { 
			$(this).attr('checked', true);getVoyageTime();
		});
		 
		$('[id^=ChkDPSECA_]').on('ifUnchecked', function () { 
			$(this).attr('checked', false);getVoyageTime();
		});
		
		$('[id^=ChkTPSECA_]').on('ifChecked', function () { 
			$(this).attr('checked', true);getVoyageTime();
		});
		 
		$('[id^=ChkTPSECA_]').on('ifUnchecked', function () { 
			$(this).attr('checked', false);getVoyageTime();
		});
	}
	else
	{
		jAlert('Please fill all the records for Sea Passage', 'Alert');
	}
}

function removePortRotation(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#pr_Row_"+var1).remove();
					$("#lp_Row_"+var1).remove();
					$("#dp_Row_"+var1).remove();
					$("#tp_Row_"+var1).remove();
					$("#DDCDProw_"+var1).remove();
					$("#DDCLProw_"+var1).remove();
					getPortCalculation();		
				 }
			else{return false;}
			});
}


function getPortCalculation()
{
	var id = $("#p_rotationID").val();
	if($("#rdoEstimateType").val()==1)
	{
		var divideby = 24;
	}
	if($("#rdoEstimateType").val()==2)
	{
		var divideby = 24;
	}
	if($("#rdoEstimateType").val()==3)
	{
		var divideby = 1;
	}
	for(var i=1;i<=id;i++)
	{
		if($("#txtQMT_"+i).val() != "" && $("#txtRate_"+i).val() != "") 
		{
			var value = 0;
			if($("#selLPTerms_"+i).val() == 1)
			{
				value = parseFloat(parseFloat($("#txtQMT_"+i).val() / $("#txtRate_"+i).val())/parseInt(divideby));
			}
			else if($("#selLPTerms_"+i).val() == 2)
			{
				value = parseFloat(parseFloat($("#txtQMT_"+i).val() / $("#txtRate_"+i).val())/parseInt(divideby)) * 1.262 ;
			}
			else if($("#selLPTerms_"+i).val() == 3)
			{
				value = parseFloat(parseFloat($("#txtQMT_"+i).val() / $("#txtRate_"+i).val())/parseInt(divideby)) * 1.405 ;
			}
			else
			{
				value = parseFloat(parseFloat($("#txtQMT_"+i).val() / $("#txtRate_"+i).val())/parseInt(divideby));
			}
			
			if($("#selLPTerms_"+i).val() != 4)
			{
				if(isNaN(value) || value=="" || value=="Infinity")
				{
					value =0;
				}
				$("#txtWDays_"+i).val(value.toFixed(3));
			}
		}
		else
		{
			$("#txtWDays_"+i).val('0.00');
		}
		
		if($("#txtDQMT_"+i).val() != "" && $("#txtDRate_"+i).val() != "") 
		{
			var value = 0;
			if($("#selDPTerms_"+i).val() == 1)
			{
				value = parseFloat(parseFloat($("#txtDQMT_"+i).val() / $("#txtDRate_"+i).val())/parseInt(divideby));
			}
			else if($("#selDPTerms_"+i).val() == 2)
			{
				value = parseFloat(parseFloat($("#txtDQMT_"+i).val() / $("#txtDRate_"+i).val())/parseInt(divideby)) * 1.262 ;
			}
			else if($("#selDPTerms_"+i).val() == 3)
			{
				value = parseFloat(parseFloat($("#txtDQMT_"+i).val() / $("#txtDRate_"+i).val())/parseInt(divideby)) * 1.405 ;
			}
			else
			{
				value = parseFloat(parseFloat($("#txtDQMT_"+i).val() / $("#txtDRate_"+i).val())/parseInt(divideby));
			}
			
			if($("#selDPTerms_"+i).val() != 4)
			{
				if(isNaN(value) || value=="" || value=="Infinity")
				{
					value =0;
				}
				$("#txtDWDays_"+i).val(value.toFixed(3));
			}
		}
		else
		{
			$("#txtDWDays"+i+",#txtDWDays1_"+i).val('0.00');
		}
	}
	getVoyageTime();
}


function getLPRemoveDaysAttr(i)
{
	if($("#selLPTerms_"+i).val() == 4)
	{
		$("#txtWDays_"+i).removeAttr('readonly');
		$("#txtWDays_"+i).val(0);
	}
	else
	{
		$("#txtWDays_"+i).attr('readonly',true);
	}
}

function getDPRemoveDaysAttr(i)
{
	if($("#selDPTerms_"+i).val() == 4)
	{
		$("#txtDWDays_"+i).removeAttr('readonly');
		$("#txtDWDays_"+i).val(0);
	}
	else
	{
		$("#txtDWDays_"+i).attr('readonly',true);
	}	
}


function getFinalCalculation()
{
	var rev = 0;var freightcostforcom = 0;
	if($("#rdoEstimateType").val()==1)
	{
		if($("#rdoQtyMar1").is(":checked"))
		{
			var txtBaseRate = $("#txtBaseRate").val();
			if(isNaN(txtBaseRate) || txtBaseRate=='')
			{txtBaseRate = 0;}
			
			var qty = $("#txtGasCQMT").val();
			if(isNaN(qty) || qty=='')
			{qty = 0;}
			
			rev = parseFloat(qty) * parseFloat(txtBaseRate);
			$("#txtBaseRateFloating").val($("#txtBaseRate").val());
		}
		else
		{
			var txtGASLumpsum = parseFloat($("#txtGASLumpsum").val());
			if(isNaN(txtGASLumpsum) || txtGASLumpsum=='')
			{txtGASLumpsum = 0;}
			rev = parseFloat(txtGASLumpsum);
		}
		freightcostforcom = rev;
		$("#txtBaseRateFloating").val($("#txtBaseRate").val());
	}

	
	if($("#rdoEstimateType").val()==2)
	{
		var sum = 0;
		var quantity = 0;
		
		if($("#rdoTankType1").is(":checked"))
		{
			if($("#ChkLumpsum").is(":checked"))
			{
				sum = parseFloat($("#txtLumpsum").val());
				if(isNaN(sum) || sum==''){sum = 0;}
				var qty = parseFloat($("#txtLumpsumQty").val());
				if(isNaN(qty)){qty = 0.00;}
				quantity = qty;
			}
			else
			{
				var txtTankID = $("#txtTankID").val();
				for(var i =1;i<=txtTankID;i++)
				{
					var txtMinCargoQty = parseFloat($("#txtMinCargoQty_"+i).val());
					if(isNaN(txtMinCargoQty) || txtMinCargoQty==''){txtMinCargoQty = 0;}
					var txtMinFlatRateQty = parseFloat($("#txtMinFlatRateQty_"+i).val());
					if(isNaN(txtMinFlatRateQty) || txtMinFlatRateQty==''){txtMinFlatRateQty = 0;}
					var txtMinWSQty = parseFloat($("#txtMinWSQty_"+i).val());
					if(isNaN(txtMinWSQty) || txtMinWSQty==''){txtMinWSQty = 0;}
					var txtMinDisLeg = parseFloat($("#txtMinDisLeg_"+i).val());
					if(isNaN(txtMinDisLeg) || txtMinDisLeg==''){txtMinDisLeg = 0;}
					var txtMinTotalDis = parseFloat($("#txtMinTotalDis_"+i).val());
					if(isNaN(txtMinTotalDis) || txtMinTotalDis==''){txtMinTotalDis = 0;}
					var cladata = parseFloat(parseFloat(parseFloat(parseFloat(parseFloat(txtMinCargoQty)*parseFloat(txtMinFlatRateQty)*parseFloat(txtMinWSQty))/100)*parseFloat(txtMinDisLeg))/parseFloat(txtMinTotalDis));
					if(isNaN(cladata) || cladata=='Infinity'){cladata = 0;}
					$("#txtMinAmount_"+i).val(cladata.toFixed(2));
					
					var txtOveCargoQty = parseFloat($("#txtOveCargoQty_"+i).val());
					if(isNaN(txtOveCargoQty) || txtOveCargoQty==''){txtOveCargoQty = 0;}
					var txtOveFlatRateQty = parseFloat($("#txtOveFlatRateQty_"+i).val());
					if(isNaN(txtOveFlatRateQty) || txtOveFlatRateQty==''){txtOveFlatRateQty = 0;}
					var txtOveWSQty = parseFloat($("#txtOveWSQty_"+i).val());
					if(isNaN(txtOveWSQty) || txtOveWSQty==''){txtOveWSQty = 0;}
					var txtOveDisLeg = parseFloat($("#txtOveDisLeg_"+i).val());
					if(isNaN(txtOveDisLeg) || txtOveDisLeg==''){txtOveDisLeg = 0;}
					var txtOveTotalDis = parseFloat($("#txtOveTotalDis_"+i).val());
					if(isNaN(txtOveTotalDis) || txtOveTotalDis==''){txtOveTotalDis = 0;}
					var cladata = parseFloat(parseFloat(parseFloat(parseFloat(parseFloat(txtOveCargoQty)*parseFloat(txtOveFlatRateQty)*parseFloat(txtOveWSQty))/100)*parseFloat(txtOveDisLeg))/parseFloat(txtOveTotalDis));
					if(isNaN(cladata) || cladata=='Infinity')
					{cladata = 0;}
					$("#txtOveAmount_"+i).val(cladata.toFixed(2))
					
					$("#txtTotalTankQty_"+i).val(parseFloat(parseFloat(txtOveCargoQty) + parseFloat(txtMinCargoQty)));
					$("#txtTotalTankAmount_"+i).val(parseFloat(parseFloat($("#txtMinAmount_"+i).val()) + parseFloat($("#txtOveAmount_"+i).val())).toFixed(2));
					sum = parseFloat(sum) + parseFloat($("#txtTotalTankAmount_"+i).val());
					quantity = parseFloat(quantity) + parseFloat(txtMinCargoQty) + parseFloat(txtOveCargoQty);
				}
			}
		}
		else
		{
			var txtMainCargoDetailID = $("#txtMainCargoDetailID").val();
			var txtCargocbmsum  = txtCargomtsum = txtAmountUSDsum = 0;
			for(var i =1;i<=txtMainCargoDetailID;i++)
			{
				var txtCargocbm = parseFloat($("#txtCargocbm_"+i).val());if(isNaN(txtCargocbm) || txtCargocbm==''){txtCargocbm = 0;}
				var txtCargomt  = parseFloat($("#txtCargomt_"+i).val());if(isNaN(txtCargomt) || txtCargomt==''){txtCargomt = 0;}
				var txtRateUSDmt = parseFloat($("#txtRateUSDmt_"+i).val());if(isNaN(txtRateUSDmt) || txtRateUSDmt==''){txtRateUSDmt = 0;}
				
				txtCargocbmsum 		= parseFloat(txtCargocbmsum) + parseFloat(txtCargocbm);
				txtCargomtsum    	= parseFloat(txtCargomtsum) + parseFloat(txtCargomt);
				var amount 			= parseFloat(txtCargomt)*parseFloat(txtRateUSDmt);
				
				if(isNaN(amount) || amount==''){amount = 0;}
				$("#txtAmountUSD_"+i).val(parseFloat(amount).toFixed(2));
				txtAmountUSDsum 		= parseFloat(txtAmountUSDsum) + parseFloat(amount);
				
				$("#spancargoCBM").text(txtCargocbmsum.toFixed(2));
				$("#spancargoMT").text(txtCargomtsum.toFixed(2));
				$("#spanAmountUSD").text(txtAmountUSDsum.toFixed(2));
			}
			
			var txtoveragedetailID = $("#txtoveragedetailID").val();
			var txtCargocbmsum2  = txtCargomtsum2 = txtAmountUSDsum2 = 0;
			for(var i =1;i<=txtoveragedetailID;i++)
			{
				var txtCargocbm = parseFloat($("#txtCargocbm2_"+i).val());if(isNaN(txtCargocbm) || txtCargocbm==''){txtCargocbm = 0;}
				var txtCargomt  = parseFloat($("#txtCargomt2_"+i).val());if(isNaN(txtCargomt) || txtCargomt==''){txtCargomt = 0;}
				var txtRateUSDmt = parseFloat($("#txtRateUSDmt2_"+i).val());if(isNaN(txtRateUSDmt) || txtRateUSDmt==''){txtRateUSDmt = 0;}
				
				txtCargocbmsum2 		= parseFloat(txtCargocbmsum2) + parseFloat(txtCargocbm);
				txtCargomtsum2    	= parseFloat(txtCargomtsum2) + parseFloat(txtCargomt);
				var amount 			= parseFloat(txtCargomt)*parseFloat(txtRateUSDmt);
				
				if(isNaN(amount) || amount==''){amount = 0;}
				$("#txtAmountUSD2_"+i).val(parseFloat(amount).toFixed(2));
				txtAmountUSDsum2 		= parseFloat(txtAmountUSDsum2) + parseFloat(amount);
				
				$("#spancargoCBM2").text(txtCargocbmsum2.toFixed(2));
				$("#spancargoMT2").text(txtCargomtsum2.toFixed(2));
				$("#spanAmountUSD2").text(txtAmountUSDsum2.toFixed(2));
			}
			
			var txtdeadfreightdetailID = $("#txtdeadfreightdetailID").val();
			var txtCargocbmsum3  = txtCargomtsum3 = txtAmountUSDsum3 = 0;
			for(var i =1;i<=txtdeadfreightdetailID;i++)
			{
				var txtCargocbm = parseFloat($("#txtCargocbm3_"+i).val());if(isNaN(txtCargocbm) || txtCargocbm==''){txtCargocbm = 0;}
				var txtCargomt  = parseFloat($("#txtCargomt3_"+i).val());if(isNaN(txtCargomt) || txtCargomt==''){txtCargomt = 0;}
				var txtRateUSDmt = parseFloat($("#txtRateUSDmt3_"+i).val());if(isNaN(txtRateUSDmt) || txtRateUSDmt==''){txtRateUSDmt = 0;}
				
				txtCargocbmsum3 		= parseFloat(txtCargocbmsum3) + parseFloat(txtCargocbm);
				txtCargomtsum3    	= parseFloat(txtCargomtsum3) + parseFloat(txtCargomt);
				var amount 			= parseFloat(txtCargomt)*parseFloat(txtRateUSDmt);
				
				if(isNaN(amount) || amount==''){amount = 0;}
				$("#txtAmountUSD3_"+i).val(parseFloat(amount).toFixed(2));
				txtAmountUSDsum3 		= parseFloat(txtAmountUSDsum3) + parseFloat(amount);
				
				$("#spancargoCBM3").text(txtCargocbmsum3.toFixed(2));
				$("#spancargoMT3").text(txtCargomtsum3.toFixed(2));
				$("#spanAmountUSD3").text(txtAmountUSDsum3.toFixed(2));
			}
			sum = parseFloat(txtAmountUSDsum) + parseFloat(txtAmountUSDsum2) + parseFloat(txtAmountUSDsum3);
			quantity = parseFloat(txtCargomtsum) + parseFloat(txtCargomtsum2) + parseFloat(txtCargomtsum3);
		}
		rev = parseFloat(sum);
		$("#txtTankQuantity").val(parseFloat(quantity));
	}
	
	if($("#rdoEstimateType").val()==3)
	{
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
		if(parseFloat(cargo_qty)){var per_mt = parseFloat(cargo_qty);}
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
		if(parseFloat(cargo_qty)){var per_mt = parseFloat(cargo_qty);}
				
		if($("#txtddswCost").val() == ""){var ddsw_cost = 0;}else{var ddsw_cost = $("#txtddswCost").val();}
		if($("#txtddswAddComm").val() == ""){var ddsw_addcomm = 0;}else{var ddsw_addcomm = $("#txtddswAddComm").val();}
		var ddsw_value = parseFloat(ddsw_cost) - parseFloat((parseFloat(ddsw_cost) * parseFloat(ddsw_addcomm))/100);
		$("#txtddswValue").val(ddsw_value.toFixed(2));
		
		if($("#txtMinQMT").val() == ""){var min_qty = 0;}else{var min_qty = $("#txtMinQMT").val();}
		if($("#txtWSFR").val() == ""){var ws_flat_rate = 0;}else{var ws_flat_rate = $("#txtWSFR").val();}
		if($("#txtWSFD").val() == ""){var fixed_diff = 0;}else{var fixed_diff = $("#txtWSFD").val();}
		if($("#txtMTCPDRate").val() == ""){var ws_rate = 0;}else{var ws_rate = $("#txtMTCPDRate").val();}
		if($("#txtAddnlQMT").val() == ""){var addnl_qty = 0;}else{var addnl_qty = $("#txtAddnlQMT").val();}
		
		$("[id^=txtMinCargo_]").val(min_qty);$("[id^=txtOverage_]").val(addnl_qty);
		$("[id^=txtMCWSFlatRate_],[id^=txtOvrWSFlatRate_]").val(ws_flat_rate);
		
		$("[id^=txtTotalCargoQty_]").val(cargo_qty);
		
		<!----------------- Quantity  ------------------->
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var per_QTY = 0;}else{var per_QTY = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var per_QTY = 0;}else{var per_QTY = $("#txtTotalFreightQty").val();}}
		
		if($("#rdoMMarket1").is(":checked"))
		{
			if($("#txtMTCPDRate").val() == ""){var agr_gross_fr = 0;}else{var agr_gross_fr = $("#txtMTCPDRate").val();}
			var gross_fr = parseFloat(agr_gross_fr) * parseFloat(per_QTY);
			$("#txtFrAdjUsdGF").val(gross_fr.toFixed(2));
			
			var gross_fr_mt = parseFloat(gross_fr) / parseFloat(per_QTY);
			if(isNaN(gross_fr_mt) || gross_fr_mt=='Infinity'){gross_fr_mt = 0;}
			$("#txtFrAdjUsdGFMT").val(gross_fr_mt.toFixed(2));
			
			if($("#txtDFQMT").val() == "" || $("#txtDFQMT").val() == 0)
			{
				var df_qty = 0;
				$("#txtFrAdjUsdDF,#txtFrAdjUsdDFMT").val("0.00");
			}
			else
			{
				var df_qty = $("#txtDFQMT").val();
				var dead_fr = parseFloat(agr_gross_fr) * parseFloat(df_qty);
				$("#txtFrAdjUsdDF").val(dead_fr.toFixed(2));
				
				var dead_fr_mt = parseFloat(dead_fr) / parseFloat(df_qty);
				$("#txtFrAdjUsdDFMT").val(dead_fr_mt.toFixed(2));
			}
			
			if($("#txtAddnlCRate").val() == ""){var addnl_rate = 0;}else{var addnl_rate = $("#txtAddnlCRate").val();}
			if($("#txtAddnlQMT").val() == "" || $("#txtAddnlQMT").val() == 0 )
			{
				var addnl_qty = 0;
				$("#txtFrAdjUsdAF,#txtFrAdjUsdAFMT").val("0.00");
			}
			else
			{
				var addnl_qty = $("#txtAddnlQMT").val();
				var addnl_fr = parseFloat(addnl_rate) * parseFloat(addnl_qty);
				$("#txtFrAdjUsdAF").val(addnl_fr.toFixed(2));
				var addnl_fr_mt = parseFloat(addnl_fr) / parseFloat(addnl_qty);
				$("#txtFrAdjUsdAFMT").val(addnl_fr_mt.toFixed(2));
			}
			$("#txtFrAdjUsdTF").val($("#txtFrAdjUsdGF,#txtFrAdjUsdDF,#txtFrAdjUsdAF").sum().toFixed(2));
			var ttl_fr_mt = parseFloat($("#txtFrAdjUsdTF").val()) / (parseFloat(per_QTY) + parseFloat(df_qty) + parseFloat(addnl_qty));
			if(isNaN(ttl_fr_mt) || ttl_fr_mt=='Infinity'){ttl_fr_mt = 0;}
			$("#txtFrAdjUsdTFMT").val(ttl_fr_mt.toFixed(2));
			$("#txtBaseRateFloating").val($("#txtMTCPDRate").val());
		}
		
		if($("#rdoMMarket2").is(":checked"))
		{
		    var txtMLumpsum = $("#txtMLumpsum").val();if(isNaN(txtMLumpsum)){txtMLumpsum = 0;}
			var txtCQMT = $("#txtCQMT").val();if(isNaN(txtCQMT)){txtCQMT = 0;}
			$("#txtFrAdjUsdGF").val($("#txtMLumpsum").val());
			var gross_fr_mt = parseFloat($("#txtFrAdjUsdGF").val()) / parseFloat(per_QTY);
			if(isNaN(gross_fr_mt) || gross_fr_mt=='Infinity'){gross_fr_mt = 0;}
			$("#txtFrAdjUsdGFMT").val(gross_fr_mt.toFixed(2));
			$("#txtFrAdjUsdDF,#txtFrAdjUsdDFMT").val("0.00");
			$("#txtFrAdjUsdAF,#txtFrAdjUsdAFMT").val("0.00");
			$("#txtFrAdjUsdTF").val($("#txtFrAdjUsdGF,#txtFrAdjUsdDF,#txtFrAdjUsdAF").sum());
			var ttl_fr_mt = parseFloat($("#txtFrAdjUsdTF").val()) / parseFloat(per_QTY);
			if(isNaN(ttl_fr_mt) || ttl_fr_mt=='Infinity'){ttl_fr_mt = 0;}
			$("#txtFrAdjUsdTFMT").val(ttl_fr_mt.toFixed(2));
			
			var freightforcom = parseFloat(txtMLumpsum)/parseFloat(txtCQMT);if(isNaN(freightforcom)){freightforcom = 0;}
			$("#txtBaseRateFloating").val(freightforcom.toFixed(2));
			
		}
		
		if($("#rdoQtyType1").is(":checked"))
		{
			var ttl_fr = parseFloat($("#txtFrAdjUsdTF").val());if(isNaN(ttl_fr) || ttl_fr=='Infinity'){ttl_fr = 0;}
			$("#txtFrAdjUsdFP").val(ttl_fr.toFixed(2));
			var net_fr_mt = parseFloat(ttl_fr) / parseFloat(per_QTY);
			if(isNaN(net_fr_mt) || net_fr_mt=='Infinity'){net_fr_mt = 0;}
			if($("#txtFrAdjUsdFP").val() == ""){var final_nett_frt = 0;}else{var final_nett_frt = $("#txtFrAdjUsdFP").val();}
			var rev = parseFloat(final_nett_frt);
		}
		if($("#rdoQtyType2").is(":checked"))
		{var rev = parseFloat($("[id^=txtQtyNetFreight_]").sum()); if(ttl_fr == ""){var ttl_fr = 0;}}
		freightcostforcom = $("#txtFrAdjUsdTF").val();
	}
	
	for(var l = 1;l<=$("#txtBRokageCount").val();l++)
	{
		if($("#txtBrCommPercent_"+l).val() == ""){var brokerage_comm = 0;}else{var brokerage_comm = $("#txtBrCommPercent_"+l).val();}
		var brokerage_comm_usd = (parseFloat(rev) * parseFloat(brokerage_comm))/100;
		$("#txtBrComm_"+l).val(brokerage_comm_usd.toFixed(2));
	}
	$("#txtBrCommPercent").val($("[id^=txtBrCommPercent_]").sum().toFixed(2));
	$("#txtBrComm").val($("[id^=txtBrComm_]").sum().toFixed(2));
	
	
	if($("#txtFrAdjPerAC").val() == ""){var ac_per = 0;}else{var ac_per = $("#txtFrAdjPerAC").val();}
	var address_commission = (parseFloat(rev) * parseFloat(ac_per)) / 100;
	$("#txtFrAdjUsdAC").val(address_commission.toFixed(2));
	rev = parseFloat(rev) - parseFloat(address_commission);
	
	var otherincomeAmt = 0;
	for(var l = 1;l<=$("#txtOthInCount").val();l++)
	{
		if($("#txtOtherAmt_"+l).val() == ""){var otheramt = 0;}else{var otheramt = $("#txtOtherAmt_"+l).val();}
		if($("#txtOtherAddComm_"+l).val() == "" && isNaN($("#txtOtherAddComm_"+l).val())){var otherpercent = 100;}else{var otherpercent = $("#txtOtherAddComm_"+l).val();}
		var other_usd = parseFloat(otheramt) - parseFloat(parseFloat(parseFloat(otheramt) * parseFloat(otherpercent))/100);
		if(isNaN(other_usd)){other_usd = 0;}
		$("#txtOtherNetAmt_"+l).val(other_usd.toFixed(2));
		otherincomeAmt = parseFloat(otherincomeAmt) + parseFloat(other_usd);
	}
	rev = parseFloat(rev) + parseFloat(otherincomeAmt);
	
	$("#txtRevenue").val(rev.toFixed(2));
	
	if($("#txtCVE").val() == ""){var txtCVE = 0;}else{var txtCVE = $("#txtCVE").val();}
	if($("#txtTDays").val() == ""){var txtTDays = 0;}else{var txtTDays = $("#txtTDays").val();}
	var calmul = parseFloat(parseFloat(parseFloat(parseFloat(txtCVE)*12)/365)*parseFloat(txtTDays));
	if(isNaN(calmul) || calmul=="" || calmul=="Infinity"){calmul = 0;}
	$("#txtCVEAmt").val(calmul.toFixed(2));
	$("#txtHidCVEAmt").val(calmul.toFixed(2));
	
	
	if($("#txtDailyVesselOperatingExpenses").val() == ""){var daily_vessel_exp = 0;}else{var daily_vessel_exp = $("#txtDailyVesselOperatingExpenses").val();}
	var hireage_amt = parseFloat(parseFloat(daily_vessel_exp)*parseFloat($("#txtTDays").val())).toFixed(2);
	if(hireage_amt=="" || isNaN(hireage_amt)){hireage_amt =0;}
	$("#txtHireargeAmt").val(parseFloat(hireage_amt).toFixed(2));
	
	if($("#txtBallastBonus").val() == ""){var txtBallastBonus = 0;}else{var txtBallastBonus = $("#txtBallastBonus").val();}
	var txtGrossHireargeAmt = parseFloat(parseFloat(txtBallastBonus) + parseFloat($("#txtHireargeAmt").val())).toFixed(2);
	if(txtGrossHireargeAmt=="" || isNaN(txtGrossHireargeAmt)){txtGrossHireargeAmt =0;}
	$("#txtGrossHireargeAmt").val(parseFloat(txtGrossHireargeAmt).toFixed(2));
	
	if($("#txtHireargePercent").val() == ""){var txtHireargePercent = 0;}else{var txtHireargePercent = $("#txtHireargePercent").val();}
	if($("#txtHireargeBroPercent").val() == ""){var txtHireargeBroPercent = 0;}else{var txtHireargeBroPercent = $("#txtHireargeBroPercent").val();}
	
	var txtHireargePercentAmt = parseFloat(parseFloat(parseFloat(txtGrossHireargeAmt)*parseFloat(txtHireargePercent))/100);
	var txtHireargeBroPercentAmt = parseFloat(parseFloat(parseFloat(hireage_amt)*parseFloat(txtHireargeBroPercent))/100);
	if(txtHireargePercentAmt=="" || isNaN(txtHireargePercentAmt)){txtHireargePercentAmt =0;}
	if(txtHireargeBroPercentAmt=="" || isNaN(txtHireargeBroPercentAmt)){txtHireargeBroPercentAmt =0;}
	$("#txtHireargePercentAmt").val(parseFloat(txtHireargePercentAmt).toFixed(2));
	$("#txtHireargeBroPercentAmt").val(parseFloat(txtHireargeBroPercentAmt).toFixed(2));
	
	var txtNettHireargeAmt = parseFloat(parseFloat(txtGrossHireargeAmt) -  parseFloat(txtHireargePercentAmt) -  parseFloat(txtHireargeBroPercentAmt));
	$("#txtNettHireargeAmt").val(parseFloat(txtNettHireargeAmt).toFixed(2));
		
	var txtHireargeCVE = $("#txtHireargeCVE").val();
	if(txtHireargeCVE=="" || isNaN(txtHireargeCVE)){txtHireargeCVE =0;}
	var txtHireargeCVEAMT = parseFloat(parseFloat(parseFloat(parseFloat(txtHireargeCVE)*12)/365)*parseFloat($("#txtTDays").val()));
	if(txtHireargeCVEAMT=="" || isNaN(txtHireargeCVEAMT)){txtHireargeCVEAMT =0;}
	$("#txtHireargeCVEAMT").val(parseFloat(txtHireargeCVEAMT).toFixed(2));
	
	
	var numoff = $("#txtOFFID").val();
	var offhiredays = 0;var offhirebunker = 0;
	var ownersbunkercal = 0;
	for(var i =1;i <=numoff;i++)
	{
		if(typeof($("#txtOffHireFrom_"+i).val())!='undefined')
		{
			var timediff = parseFloat(getTimeDiff($("#txtOffHireTo_"+i).val(),$("#txtOffHireFrom_"+i).val()));
			if(isNaN(timediff)){timediff = 0.00;}
			$("#txtOffHireDays_"+i).val(parseFloat(timediff).toFixed(4))
			var offrate  = parseFloat($("#txtOffHireRate_"+i).val());
			if(isNaN(offrate)){offrate = 0.00;}
			offhiredays =   parseFloat(parseFloat(offhiredays) + parseFloat(timediff));
			$("#txtOffHireAmt_"+i).val(parseFloat(parseFloat(timediff)*parseFloat(offrate)).toFixed(2));
			
			var numoffbunker = $("#txtTCConBunkerCount_"+i).val();
			for(var j =1;j <=numoffbunker;j++)
			{
				if(typeof($("#selTCConBunker_"+i+"_"+j).val())!='undefined')
				{
					var txtTCConBunkerQty = parseFloat($("#txtTCConBunkerQty_"+i+"_"+j).val());
					if(isNaN(txtTCConBunkerQty)){txtTCConBunkerQty = 0.00;}
					var txtTCConBunkerPrice = parseFloat($("#txtTCConBunkerPrice_"+i+"_"+j).val());
					if(isNaN(txtTCConBunkerPrice)){txtTCConBunkerPrice = 0.00;}
					var txtTCConBunkerAmt = parseFloat(parseFloat(txtTCConBunkerQty)*parseFloat(txtTCConBunkerPrice));
					var offhirebunker =   parseFloat(parseFloat(offhirebunker) + parseFloat(txtTCConBunkerAmt));
					$("#txtTCConBunkerAmt_"+i+"_"+j).val(parseFloat(txtTCConBunkerAmt).toFixed(2));
					if($("#ChkOFFHireCal_"+i+"_"+j).is(":checked"))
					{
					   ownersbunkercal = parseFloat(ownersbunkercal) + parseFloat(txtTCConBunkerAmt);
					}
				}
			}
		}
	}	
	$("#txtOffHireBunkerPrices").val($("[id^=txtTCConBunkerAmt_]").sum().toFixed(2));
	var OffhireDays = $("[id^=txtOffHireDays_]").sum().toFixed(2);
	var txtOffHireCVE = $("#txtOffHireCVE").val();
	if(txtOffHireCVE=="" || isNaN(txtOffHireCVE)){txtOffHireCVE =0;}
	var txtOffHireCVEAMT = parseFloat(parseFloat(parseFloat(parseFloat(txtOffHireCVE)*12)/365)*parseFloat(OffhireDays));
	if(txtOffHireCVEAMT=="" || isNaN(txtOffHireCVEAMT)){txtOffHireCVEAMT =0;}
	$("#txtOffHireCVEAMT").val(parseFloat(txtOffHireCVEAMT).toFixed(2));
	
	var txtOffHireAmt = $('[id^=txtOffHireAmt_]').sum();
	var OffhireDaysAMT = parseFloat(txtOffHireAmt) + parseFloat(txtOffHireCVEAMT) + parseFloat(ownersbunkercal);
	$("#txtTCBunkerOnOwnerAmt").val(parseFloat(ownersbunkercal).toFixed(2));
	if(isNaN(OffhireDaysAMT)){OffhireDaysAMT = 0.00;}
	$("#txtLessOffHire").val(parseFloat(OffhireDaysAMT).toFixed(2));
	
	if($("#ChkOFFHireBunker").is(":checked"))
	{
		var txtFinalHireargeAmt = parseFloat(parseFloat(txtNettHireargeAmt) + $("[id^=txtDelAmount_]").sum() +  parseFloat(txtHireargeCVEAMT)) - $("[id^=txtReDelAmount_]").sum() - parseFloat(OffhireDaysAMT) - $("[id^=txtTCConBunkerAmt_]").sum(); 
	}else{
		var txtFinalHireargeAmt = parseFloat(parseFloat(txtNettHireargeAmt) + $("[id^=txtDelAmount_]").sum() +  parseFloat(txtHireargeCVEAMT)) - $("[id^=txtReDelAmount_]").sum() - parseFloat(OffhireDaysAMT);
	}  
	if(isNaN(txtFinalHireargeAmt)){txtFinalHireargeAmt = 0.00;}
	$("#txtFinalHireargeAmt").val(parseFloat(txtFinalHireargeAmt).toFixed(2));
	
		
	$("#txtTotalOperationalCost").val($("[id^=txtORCAmt_],#txtBrComm,#txtHidCVEAmt").sum());
	
	$("#txtTotalPortCost").val($("[id^=txtPCosts_],[id^=txtDCosts_],[id^=txtTLPCosts_]").sum().toFixed(2));
	
	var totalexpenses = $("#txtTotalOperationalCost,#txtTotalPortCost,#txtTotalBunkerCost").sum().toFixed(2);
	if($("#txtRevenue").val() == ""){var revenue = 0;}else{var revenue = $("#txtRevenue").val();}
	var costbeforebamarage = parseFloat(revenue) - parseFloat(totalexpenses);// - parseFloat(txtFinalHireargeAmt)
	var voyage_earning = parseFloat(revenue) - parseFloat(totalexpenses) + parseFloat(getDDCOwnerCalculation()) - parseFloat(txtFinalHireargeAmt);
	
	$("#txtVoyageEarnings").val(costbeforebamarage.toFixed(2));
	$("#txtGTTLVoyageEarnings").val(voyage_earning.toFixed(2));
	if($("#txtTDays").val() == 0){var ttl_days = 1;}else{var ttl_days = $("#txtTDays").val();}
	var daily_earnings = parseFloat(voyage_earning) / parseFloat(ttl_days);
	var costbeforebamarage_erning = parseFloat(voyage_earning) / parseFloat(ttl_days);
	$("#txtDailyEarnings").val(costbeforebamarage_erning.toFixed(2));
		
	
	var netprofilt = parseFloat(voyage_earning);
	var nett_daily_profit = parseFloat(parseFloat(voyage_earning)/parseFloat(ttl_days));
	if(nett_daily_profit=="" || isNaN(nett_daily_profit) || nett_daily_profit=="Infinity"){nett_daily_profit =0;}
	$("#txtNettDailyProfit").val(parseFloat(nett_daily_profit).toFixed(2));
	$("#txtPL").val(parseFloat(netprofilt).toFixed(2));
	
	var breakeven_qty = 0;
	if($("#rdoEstimateType").val()==1)
	{
		breakeven_qty = $("#txtGasCQMT").val();
	}
	if($("#rdoEstimateType").val()==2)
	{
		breakeven_qty = $("#txtTankQuantity").val();
	}
	
	if($("#rdoEstimateType").val()==3)
	{
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){breakeven_qty = 0;}else{breakeven_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){breakeven_qty = 0;}else{breakeven_qty = $("#txtTotalFreightQty").val();}}
	}
	if(breakeven_qty=="" || isNaN(breakeven_qty)){breakeven_qty =0;}
	
	var expense = parseFloat($("#txtTotalOperationalCost, #txtTotalPortCost, #txtTotalBunkerCost, #txtFrAdjUsdAC, #txtFinalHireargeAmt").sum());
	if(expense=="" || isNaN(expense)){expense =0;}
	$("#txtGrossBreakeven").val(expense.toFixed(2));
	var txtBreakevenMT = parseFloat(parseFloat(expense)/parseFloat(breakeven_qty));
	if(txtBreakevenMT=="" || isNaN(txtBreakevenMT)){txtBreakevenMT =0;}
	$("#txtBreakevenMT").val(txtBreakevenMT.toFixed(2));
	
	$('[id^=txtLPOSCCost_]').each(function(index) {
				var rowid = this.id;
				var lasrvar1 = rowid.split('_').slice(1).join('_');
				var costMT = this.value / parseFloat(per_mt);
				$("#txtLPOSCCostMT_"+lasrvar1).val(costMT.toFixed(2));
			});
	$('[id^=txtDPOSCCost_]').each(function(index) {
				var rowid = this.id;
				var lasrvar1 = rowid.split('_').slice(1).join('_');
				var costMT = this.value / parseFloat(per_mt);
				$("#txtDPOSCCostMT_"+lasrvar1).val(costMT.toFixed(2));
			});
	$('[id^=txtTPOSCCost_]').each(function(index) {
				var rowid = this.id;
				var lasrvar1 = rowid.split('_').slice(1).join('_');
				var costMT = this.value / parseFloat(per_mt);
				$("#txtTPOSCCostMT_"+lasrvar1).val(costMT.toFixed(2));
			});
	var txtDailyEarningFixed = 0;
	<?php if($_SESSION['selBType']==1 || $_SESSION['selBType']==3){?>		
	var txtGFreightFloating = parseFloat(freightcostforcom);if(isNaN(txtGFreightFloating)){txtGFreightFloating = 0;}
	$("#txtGFreightFloating").val(txtGFreightFloating.toFixed(4));
	var txtNFreightFloating = parseFloat(freightcostforcom);if(isNaN(txtNFreightFloating)){txtNFreightFloating = 0;}
	$("#txtNFreightFloating").val(txtNFreightFloating.toFixed(4));
	
	var demurrage = parseFloat(getDDCOwnerCalculation());
	var txtOExpensesFloating = parseFloat($("#txtTotalOperationalCost").val()) + parseFloat($("#txtTotalPortCost").val()) + parseFloat($("#txtTotalBunkerCost").val()) + parseFloat($("#txtFinalHireargeAmt").val());if(isNaN(txtOExpensesFloating)){txtOExpensesFloating = 0;}
	$("#txtOExpensesFloating,#txtOExpensesFixed,#txtOExpensesAverage").val(txtOExpensesFloating.toFixed(4));
	var txtVEarningFloating = parseFloat($("#txtNFreightFloating").val()) - parseFloat($("#txtOExpensesFloating").val()) + parseFloat(demurrage);if(isNaN(txtVEarningFloating)){txtVEarningFloating = 0;}
	<?php if($_SESSION['selBType']==1){?>
	var quantitydrygas = $("#txtGasCQMT").val();if(isNaN(quantitydrygas)){quantitydrygas = 0;}
	var txtTCEMonthFixed    = parseFloat($("#txtTCEMonthFixed").val());if(isNaN(txtTCEMonthFixed)){txtTCEMonthFixed = 0;}
	var txtDailyEarningFixed = parseFloat(parseFloat($("#txtTCEMonthFixed").val())*12)/365;if(isNaN(txtDailyEarningFixed)){txtDailyEarningFixed = 0;}
	$("#txtDailyEarningFixed").val(txtDailyEarningFixed.toFixed(4));
	<?php }?>
	<?php if($_SESSION['selBType']==3){?>
	if($("#rdoQtyType1").is(":checked"))
	{if($("#txtCQMT").val() == ""){var quantitydrygas = 0;}else{var quantitydrygas = $("#txtCQMT").val();}}
	if($("#rdoQtyType2").is(":checked"))
	{if($("#txtTotalFreightQty").val() == ""){var quantitydrygas = 0;}else{var quantitydrygas = $("#txtTotalFreightQty").val();}}
	var txtDailyEarningFixed    = parseFloat($("#txtDailyEarningFixed").val());if(isNaN(txtDailyEarningFixed)){txtDailyEarningFixed = 0;}
	<?php }?>
	var txtVEarningFixed = parseFloat(txtDailyEarningFixed)*parseFloat($("#txtTDays").val());if(isNaN(txtVEarningFixed)){txtVEarningFixed = 0;}
	
	$("#txtVEarningFixed").val(txtVEarningFixed.toFixed(4));
	var txtNFreightFixed = parseFloat($("#txtVEarningFixed").val()) + parseFloat($("#txtOExpensesFixed").val()) - parseFloat(demurrage.toFixed(2));if(isNaN(txtNFreightFixed)){txtNFreightFixed = 0;}
	
	$("#txtNFreightFixed").val(txtNFreightFixed.toFixed(4));
	
	var betfreightfixed = parseFloat($("#txtNFreightFixed").val());
	var txtGFreightFixed = parseFloat(betfreightfixed);
	if(isNaN(txtGFreightFixed)){txtGFreightFixed = 0.00;}
	$("#txtGFreightFixed").val(txtGFreightFixed.toFixed(4));
	var txtFrAdjUsdAF = parseFloat($("#txtFrAdjUsdAF").val());if(isNaN(txtFrAdjUsdAF)){txtFrAdjUsdAF = 0;}
	var txtFrAdjUsdDF = parseFloat($("#txtFrAdjUsdDF").val());if(isNaN(txtFrAdjUsdDF)){txtFrAdjUsdDF = 0;}
	txtGFreightFixed = parseFloat(txtGFreightFixed) - parseFloat(txtFrAdjUsdAF) - parseFloat(txtFrAdjUsdDF);
	var txtBaseRateFixed = parseFloat(txtGFreightFixed)/parseFloat(quantitydrygas);if(isNaN(txtBaseRateFixed)){txtBaseRateFixed = 0;}
	$("#txtBaseRateFixed").val(txtBaseRateFixed.toFixed(4));
	
	var txtBaseRateFloating = $("#txtBaseRateFloating").val();if(isNaN(txtBaseRateFloating)){txtBaseRateFloating = 0;}
	var txtBaseRateFixed    = $("#txtBaseRateFixed").val();if(isNaN(txtBaseRateFixed)){txtBaseRateFixed = 0;}
	var averageRate = (parseFloat(txtBaseRateFloating) + parseFloat(txtBaseRateFixed))/2;if(isNaN(averageRate)){averageRate = 0;}
	$("#txtBaseRateAverage").val(averageRate.toFixed(2));
	
	var txtGFreightFloating = $("#txtGFreightFloating").val();if(isNaN(txtGFreightFloating)){txtGFreightFloating = 0;}
	var txtGFreightFixed    = $("#txtGFreightFixed").val();if(isNaN(txtGFreightFixed)){txtGFreightFixed = 0;}
	var averagefreight = (parseFloat(txtGFreightFloating) + parseFloat(txtGFreightFixed))/2;if(isNaN(averagefreight)){averagefreight = 0;}
	$("#txtGFreightAverage").val(averagefreight.toFixed(2));
	
	var txtNFreightFloating = $("#txtNFreightFloating").val();if(isNaN(txtNFreightFloating)){txtNFreightFloating = 0;}
	var txtNFreightFixed    = $("#txtNFreightFixed").val();if(isNaN(txtNFreightFixed)){txtNFreightFixed = 0;}
	var averagefreight = (parseFloat(txtNFreightFloating) + parseFloat(txtNFreightFixed))/2;if(isNaN(averagefreight)){averagefreight = 0;}
	$("#txtNFreightAverage").val(averagefreight.toFixed(2));
	
	$("#txtVEarningFloating").val(txtVEarningFloating.toFixed(4));
	var txtVEarningFloating = $("#txtVEarningFloating").val();if(isNaN(txtVEarningFloating)){txtVEarningFloating = 0;}
	var averageexpense = (parseFloat(txtVEarningFloating) + parseFloat(txtVEarningFixed))/2;if(isNaN(averageexpense)){averageexpense = 0;}
	$("#txtVEarningAverage").val(averageexpense.toFixed(2));
	
	var txtDailyEarningFloating = parseFloat($("#txtVEarningFloating").val())/parseFloat($("#txtTDays").val());if(isNaN(txtDailyEarningFloating)){txtDailyEarningFloating = 0;}
	$("#txtDailyEarningFloating").val(txtDailyEarningFloating.toFixed(4));
	
	var txtDailyEarningAverage = (parseFloat(txtDailyEarningFloating) + parseFloat(txtDailyEarningFixed))/2;if(isNaN(txtDailyEarningAverage)){txtDailyEarningAverage = 0;}
	$("#txtDailyEarningAverage").val(txtDailyEarningAverage.toFixed(2));
	
	var txtTCEMonthFloating = parseFloat(parseFloat(parseFloat($("#txtDailyEarningFloating").val())*365)/12);if(isNaN(txtTCEMonthFloating)){txtTCEMonthFloating = 0;}
	var txtTCEMonthAverage = (parseFloat(txtTCEMonthFloating) + parseFloat(txtTCEMonthFixed))/2;if(isNaN(txtTCEMonthAverage)){txtTCEMonthAverage = 0;}
	$("#txtTCEMonthFloating").val(txtTCEMonthFloating.toFixed(4));$("#txtTCEMonthAverage").val(txtTCEMonthAverage.toFixed(2));
	
	var txtOPExpensesFloating = $("#txtOPExpensesFloating").val();if(isNaN(txtOPExpensesFloating) || txtOPExpensesFloating ==''){txtOPExpensesFloating = 0;}
	$("#txtOPExpensesFixed").val(txtOPExpensesFloating);
	var txtOPExpensesFixed    = $("#txtOPExpensesFixed").val();if(isNaN(txtOPExpensesFixed) || txtOPExpensesFixed ==''){txtOPExpensesFixed = 0;}
	var txtOPExpensesAverage = (parseFloat(txtOPExpensesFloating) + parseFloat(txtOPExpensesFixed))/2;if(isNaN(txtOPExpensesAverage)){txtOPExpensesAverage = 0;}
	$("#txtOPExpensesAverage").val(txtOPExpensesAverage.toFixed(2));
	
	var txtNetDailyProfitFloating = parseFloat($("#txtDailyEarningFloating").val()) - parseFloat(txtOPExpensesFloating);if(isNaN(txtNetDailyProfitFloating)){txtNetDailyProfitFloating = 0;}
	var txtNetDailyProfitFixed = parseFloat(txtDailyEarningFixed) - parseFloat(txtOPExpensesFloating);if(isNaN(txtNetDailyProfitFixed)){txtNetDailyProfitFixed = 0;}
	var txtNetDailyProfitAverage = parseFloat(parseFloat(txtNetDailyProfitFloating) + parseFloat(txtNetDailyProfitFixed))/2;if(isNaN(txtNetDailyProfitAverage)){txtNetDailyProfitAverage = 0;}
	$("#txtNetDailyProfitFloating").val(txtNetDailyProfitFloating.toFixed(2));
	$("#txtNetDailyProfitFixed").val(txtNetDailyProfitFixed.toFixed(2));
	$("#txtNetDailyProfitAverage").val(txtNetDailyProfitAverage.toFixed(2));
	<?php }?>
}



function addBrokerageRow()
{
	var id = $("#txtBRokageCount").val();
	if($("#txtBrCommPercent_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="tbrRow_'+id+'"><td><a href="#tb1" onclick="removeBrokerage('+id+');" ><i class="fa fa-times" style="color:red;"></a></td><td>Brokerage Commission <span style="font-size:10px; font-style:italic;">(%)</span></td><td><input type="text" name="txtBrCommPercent_'+id+'" id="txtBrCommPercent_'+id+'" size="12" class="input-text" autocomplete="off" value="" onKeyUp="getFinalCalculation();" placeholder="0.00" /></td><td><input type="text" name="txtBrComm_'+id+'" size="12" id="txtBrComm_'+id+'" class="input-text" readonly value="0.00" /></td><td></td></tr>').appendTo("#tbodyBrokerage");
	    $("#selBroVList_"+id).html($("#selVendor").html());$("#selBroVList_"+id).val('');
		$("[id^=txtBrCommPercent_]").numeric();	
		$("#txtBRokageCount").val(id);
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeBrokerage(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#tbrRow_"+var1).remove();
					getFinalCalculation();			
				 }
			else{return false;}
			});
}

function getTotalDWT()
{
var dwt = $("#txtDWTS").val();	
	if($("#rdoCap1").is(":checked"))
	{
		if($("#txtGCap").val() == ""){var gcap = 0;}else{var gcap = $("#txtGCap").val();}
		if($("#txtSF").val() != "" || $("#txtSF").val() != 0)
		{
			var ttl = parseFloat(parseFloat(gcap)*35.3146) / parseFloat($("#txtSF").val());
			if(parseFloat($("#txtSF").val())>0)
			{
				$("#txtLoadable").val(ttl.toFixed(2));
			}
			else
			{
				$("#txtLoadable").val(0);
			}
		}
	}
	
}

function showCapField(val)
{
	if(val == 1)
	{
		$("#txtGCap").removeAttr('disabled');
		$("#txtBCap").attr('disabled','disabled');
		getTotalDWT();
		getTotalDWT1();
	}
	if(val == 2)
	{
		$("#txtGCap").attr('disabled','disabled');
		$("#txtBCap").removeAttr('disabled');		
		getTotalDWT();
		getTotalDWT1();
	}
}

function getTotalDWT1()
{
	var dwt = $("#txtDWTS").val();
	
	if($("#rdoCap2").is(":checked"))
	{
		if($("#txtBCap").val() == ""){var bcap = 0;}else{var bcap = $("#txtBCap").val();}
		
		if($("#txtSF").val() != "" || $("#txtSF").val() != 0)
		{			
			var ttl = parseFloat(parseFloat(bcap)*35.3146) / parseFloat($("#txtSF").val());
			if(parseFloat($("#txtSF").val())>0)
			{
				$("#txtLoadable").val(ttl.toFixed(2));
			}
			else
			{
				$("#txtLoadable").val(0);
			}
		}
	}
	getFinalCalculation();
}

function getORCCalculate(var1)
{
	if($("#rdoEstimateType").val()==1)
	{
		var cargo_qty = $("#txtGasCQMT").val();
	}
	if($("#rdoEstimateType").val()==2)
	{
		var cargo_qty = $("#txtTankQuantity").val();
	}
	
	if($("#rdoEstimateType").val()==3)
	{
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
	}
	
	if($("#txtORCAmt_"+var1).val() == ""){var cc_abs = 0;}else{var cc_abs = $("#txtORCAmt_"+var1).val();}
	var calc = parseFloat(cc_abs) / parseFloat(cargo_qty);
	$("#txtORCAmtMT_"+var1).val(calc.toFixed(2));
	getFinalCalculation();	
}

function getValidate()
{
	
	getFinalCalculation();
	
}


function addORCRow()
{
	var id = $("#txtOWCCount").val();
	if($("#txtHidORCID_"+id).val() != "" && $("#txtORCAmt_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="OWCRow_'+id+'"><td><a href="#tb1" onClick="removeCC('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="txtHidORCID_'+id+'" id="txtHidORCID_'+id+'" style="width:130px;" ></select></td><td><input type="text" name="txtORCAmt_'+id+'" id="txtORCAmt_'+id+'" onKeyUp="getORCCalculate('+id+');" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"  /></td></tr>').appendTo("#OWCBody");
		$("[id^=txtORCAmt_]").numeric();	
		$("#txtHidORCID_"+id).html($("#selOwnerCost").html());	
		$("#txtOWCCount").val(id);
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeCC(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#OWCRow_"+var1).remove();
					getFinalCalculation();			
				 }
			else{return false;}
			});
}



function getDDCOwnerCalculation(){
	
	if($("#rdoQtyType1").is(":checked"))
	{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
	if($("#rdoQtyType2").is(":checked"))
	{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
	
	$('[id^=txtDDCLPCost_]').each(function(index) {
		var rowid       = this.id;
		var ddswLP1     = rowid.split('_')[1];
		if($("#txtLPLayTimeIs_"+ddswLP1).val()==0)
		{
			$("#txtDDCLPCost_"+ddswLP1).val($("#txtEstDDCLPCost_"+ddswLP1).val());
		}
		if($("#txtDDCLPCost_"+ddswLP1).val() == ""){var addLPcost = 0;}else{var addLPcost = $("#txtDDCLPCost_"+ddswLP1).val();}
		var addcomm = $("#txtLPADDComm_"+ddswLP1).val();
		if(isNaN(addcomm) || addcomm==''){addcomm =0;}
		var addcommamt = parseFloat(parseFloat(parseFloat(addLPcost)*parseFloat(addcomm))/100);
		var remLpAmt  = parseFloat(addLPcost) - parseFloat(addcommamt);
		$('#txtDDCLPNetCostMT_'+ddswLP1).val(remLpAmt.toFixed(2));
		var ddswLPCCost = parseFloat(remLpAmt)/parseFloat(cargo_qty);
		$('#txtDDCLPCostMT_'+ddswLP1).val(ddswLPCCost.toFixed(2));
	});
	
	$('[id^=txtDDCDPCost_]').each(function(index) {
		var rowid       = this.id;
		var ddswDP1     = rowid.split('_')[1];
		if($("#txtDPLayTimeIs_"+ddswDP1).val()==0)
		{
			$("#txtDDCDPCost_"+ddswDP1).val($("#txtEstDDCDPCost_"+ddswDP1).val());
		}
		if($("#txtDDCDPCost_"+ddswDP1).val() == ""){var addDPcost = 0;}else{var addDPcost = $("#txtDDCDPCost_"+ddswDP1).val();}
		var addcomm = $("#txtDPADDComm_"+ddswDP1).val();
		if(isNaN(addcomm) || addcomm==''){addcomm =0;}
		var addcommamt = parseFloat(parseFloat(parseFloat(addDPcost)*parseFloat(addcomm))/100);
		var remLpAmt  = parseFloat(addDPcost) - parseFloat(addcommamt);
		$('#txtDDCDPNetCostMT_'+ddswDP1).val(remLpAmt.toFixed(2));
		var ddswDPCCost = parseFloat(remLpAmt)/parseFloat(cargo_qty);
		$('#txtDDCDPCostMT_'+ddswDP1).val(ddswDPCCost.toFixed(2));
	});
	var LPDPttl = parseFloat($('[id^=txtDDCLPNetCostMT_]').sum().toFixed(2)) + parseFloat($('[id^=txtDDCDPNetCostMT_]').sum().toFixed(2));
	return LPDPttl;
}



function showHideQtyVendorDiv(value)
{
	if(value ==1)
	{
		$("#divMarket3").show();
		$("#divQty1,#divQty2,#tblQtyFreight").hide();
		$("#tblQtyFreight").empty();
		$("#txtQTYID").val(0);
		getQtyLocalFreightCal();
	}
	if(value ==2)
	{
		$("#divMarket3").hide();
		$("#divQty1,#divQty2,#tblQtyFreight").show();
		if(value==2)
		{
		  getQtyLocalFreightCal();
		}
	}
	getPortCalculation();
}

function addQtyVendorDetails()
{
	var id = $("#txtQTYID").val();
	if($("#selQtyVendorList").val() != "" && $("#txtQtyAggriedFreight").val() != "" && $("#txtFreightQty").val() != "" )
	{
		$("#tbrQtyVRow_empty,#tbrQtyVRow_empty1,#tbrQtyVRow_empty2").remove();
		id = (id - 1) + 2;
		$('<tr id="tbrQtyVRow_'+id+'"><td><a href="#tb'+id+'" onclick="deleteQtyVendorDetails('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select  name="selQtyVendorList_'+id+'" class="input-text" style="width:120px;" id="selQtyVendorList_'+id+'"></select></td><td><select name="selQtyCargo_'+id+'" class="input-text" style="width:120px;" id="selQtyCargo_'+id+'"></select></td><td><input type="text" name="txtQtyLocalAggriedFreight_'+id+'" id="txtQtyLocalAggriedFreight_'+id+'" class="input-text" style="width:100px;"  autocomplete="off" value="" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td><td><select  name="selCurrencyDisList_'+id+'" class="input-text" style="width:100px;" id="selCurrencyDisList_'+id+'"><?php $obj->getCurrencyList(); ?></select></td><td><input type="text" name="txtDisExchangeRate_'+id+'" id="txtDisExchangeRate_'+id+'" class="input-text" style="width:100px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td><td><input type="text" name="txtQtyAggriedFreight_'+id+'" id="txtQtyAggriedFreight_'+id+'" class="input-text" style="width:100px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td><td><input type="text" name="txtFreightQty_'+id+'" id="txtFreightQty_'+id+'" class="input-text" style="width:100px;" value="" placeholder="0.00" onKeyUp="getQtyLocalFreightCal();"/></td><td><input type="text" name="txtQtyFreight_'+id+'" id="txtQtyFreight_'+id+'" class="input-text" style="width:100px;" value="0" readonly/></td><td><input type="text" name="txtQtyNetFreight_'+id+'" style="width:100px;" id="txtQtyNetFreight_'+id+'" placeholder="0.00" class="input-text" readonly value="" /></td></tr>').appendTo("#tblQtyFreight");
		$("#selQtyVendorList_"+id).html($("#selVendor").html());
		$("#txtQTYID").val(id);
		$("#selQtyCargo_"+id).html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());
		$("[id^=txtQtyAggriedFreight_], [id^=txtFreightQty_], [id^=txtQtyLocalAggriedFreight_], [id^=txtDisExchangeRate_], [id^=txtMarLocalAggriedFreight_], [id^=txtMarExchangeRate_]").numeric();
	}
	else
	{
		jAlert('Please fill All details', 'Alert');
		return false;
	}
	getFinalCalculation();
}


function deleteQtyVendorDetails(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#tbrQtyVRow_"+var1).remove();
					$("#tbrQtyVRow1_"+var1).remove();
					$("#tbrQtyVRow2_"+var1).remove();
					getQtyLocalFreightCal();	
				 }
			else{return false;}
			});
}


function getQtyLocalFreightCal()
{
	var id = $("#txtQTYID").val();
	for(var i=1;i<=id;i++)
	{
		if($("#txtQtyLocalAggriedFreight_"+i).val() == ""){var localfreightcost = 0;}else{var localfreightcost = $("#txtQtyLocalAggriedFreight_"+i).val();}
		if($("#txtDisExchangeRate_"+i).val() == ""){var txtDisExchangeRate = 0;}else{var txtDisExchangeRate = $("#txtDisExchangeRate_"+i).val();}
		var calmul = parseFloat(localfreightcost)/parseFloat(txtDisExchangeRate);
		if(isNaN(calmul) || calmul=="" || calmul=="Infinity"){calmul = 0;}
		$("#txtQtyAggriedFreight_"+i).val(calmul.toFixed(2));
		if($("#txtFreightQty_"+i).val() == ""){var txtFreightQty = 0;}else{var txtFreightQty = $("#txtFreightQty_"+i).val();}
		var calmul2 = parseFloat(calmul)*parseFloat(txtFreightQty);
		if(isNaN(calmul2) || calmul2=="" || calmul=="Infinity"){calmul2 =0;}
		$("#txtQtyFreight_"+i).val(calmul2.toFixed(2));
				
		$("#txtQtyNetFreight_"+i).val(calmul2.toFixed(2));
	}
	$("#txtTotalFreightQty").val($("[id^=txtFreightQty_]").sum().toFixed(2));
	$("#txtTotalQtyFreight").val($("[id^=txtQtyFreight_]").sum().toFixed(2));
	$("#txtTotalNetFreight").val($("[id^=txtQtyNetFreight_]").sum().toFixed(2));
	getFinalCalculation();
}

function getMarLocalFreightCal()
{
	if($("#txtMarLocalAggriedFreight").val() == ""){var localfreightcost = 0;}else{var localfreightcost = $("#txtMarLocalAggriedFreight").val();}
	if($("#txtMarExchangeRate").val() == ""){var txtMarExchangeRate = 0;}else{var txtMarExchangeRate = $("#txtMarExchangeRate").val();}
	var calmul = parseFloat(localfreightcost)/parseFloat(txtMarExchangeRate);
	if(isNaN(calmul) || calmul=="" || calmul=="Infinity"){calmul = 0;}
	$("#txtMTCPDRate").val(calmul.toFixed(2));
	getFinalCalculation();
}

function getSubmitForm()
{
	$("#action").val("");
	document.frm1.submit();
}

function showGasMarket(value)
{
	
	if(value == 2)
	{
		$("#txtGASLumpsum").removeAttr('disabled');
		$("#txtAdnlPrenium,#txtBalticRate,#txtBaseRate").attr('disabled',true);
		$("#txtBalticRate,#txtBaseRate,#txtAdnlPrenium").val("");
		$("#txtBalticRate").focus();
		getFinalCalculation();
	}
	else
	{
		$("#txtGASLumpsum").val("");
	}
	if(value == 1)
	{			
		$("#txtGASLumpsum").attr('disabled',true);
		$("#txtAdnlPrenium,#txtBalticRate,#txtBaseRate").removeAttr('disabled');
		$("#txtGASLumpsum").val("");
		$("#txtGASLumpsum").focus();
		getFinalCalculation();
	}
	else
	{
	    $("#txtBalticRate,#txtBaseRate,#txtAdnlPrenium").val("");	
	}
}


function addTankDetails()
{
	var id = $("#txtTankID").val();
	if($("#txtFreightSpecs_"+id).val() != "" )
	{
		$("#tbrQtyVRow_empty,#tbrQtyVRow_empty1,#tbrQtyVRow_empty2").remove();
		id = (id - 1) + 2;
		$('<tr id="tankRow1_'+id+'"><td><a href="#tb'+id+'" onclick="deleteTankerDetails('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td>Freight Specs</td><td><input type="text" name="txtFreightSpecs_'+id+'" id="txtFreightSpecs_'+id+'" class="input-text" autocomplete="off" size="30" value="" placeholder="Freight Specs" onKeyUp="getFinalCalculation();"/></td><td>Flat Rate</td><td>WS</td><td>Distance Leg</td><td>Total Distance</td><td>Amount</td><td>Customer</td></tr><tr id="tankRow2_'+id+'"><td></td><td>Min Cargo Qty</td><td><input type="text" name="txtMinCargoQty_'+id+'" id="txtMinCargoQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtMinFlatRateQty_'+id+'" id="txtMinFlatRateQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtMinWSQty_'+id+'" id="txtMinWSQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtMinDisLeg_'+id+'" id="txtMinDisLeg_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtMinTotalDis_'+id+'" id="txtMinTotalDis_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtMinAmount_'+id+'" id="txtMinAmount_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><select  name="selTankVendor_'+id+'" class="input-text" style="width:120px;" id="selTankVendor_'+id+'"></select></td></tr><tr id="tankRow3_'+id+'"><td></td><td>Overage Qty</td><td><input type="text" name="txtOveCargoQty_'+id+'" id="txtOveCargoQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtOveFlatRateQty_'+id+'" id="txtOveFlatRateQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtOveWSQty_'+id+'" id="txtOveWSQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtOveDisLeg_'+id+'" id="txtOveDisLeg_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtOveTotalDis_'+id+'" id="txtOveTotalDis_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtOveAmount_'+id+'" id="txtOveAmount_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td></td></tr><tr id="tankRow4_'+id+'"><td></td><td>Total Cargo Qty</td><td><input type="text" name="txtTotalTankQty_'+id+'" id="txtTotalTankQty_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" readonly/></td><td></td><td></td><td></td><td></td><td><input type="text" name="txtTotalTankAmount_'+id+'" id="txtTotalTankAmount_'+id+'" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" readonly/></td><td></td></tr><tr id="tankRow5_'+id+'"><td colspan="9">&nbsp;</td></tr>').appendTo("#tblTankerBody");
		$("#txtMinTotalDis_"+id+",#txtOveTotalDis_"+id).val($("#txtTDist").val());
		$("#txtTankID").val(id);
		$("[id^=txtMinCargoQty_],[id^=txtMinFlatRateQty_],[id^=txtMinWSQty_],[id^=txtMinDisLeg_],[id^=txtMinTotalDis_],[id^=txtMinAmount_],[id^=txtMinCargoQty_],[id^=txtOveFlatRateQty_],[id^=txtOveWSQty_],[id^=txtOveTotalDis_],[id^=txtOveAmount_],[id^=txtTotalTankQty_],[id^=txtOveDisLeg_]").numeric();
		$("#selTankVendor_"+id).html($("#selVendor").html());
	}
	else
	{
		jAlert('Please fill All details', 'Alert');
		return false;
	}
	getFinalCalculation();
}


function deleteTankerDetails(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#tankRow1_"+var1).remove();
					$("#tankRow2_"+var1).remove();
					$("#tankRow3_"+var1).remove();
					$("#tankRow4_"+var1).remove();
					$("#tankRow5_"+var1).remove();
					getQtyLocalFreightCal();	
				 }
			else{return false;}
			});
}

function addOtherInRow()
{
	var id = $("#txtOthInCount").val();
	if($("#txtDesc_"+id).val() != "" && $("#txtOtherAmt_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="OthInRow_'+id+'"><td><a href="#tb1" onClick="removeOtherIncome('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><input type="text" name="txtDesc_'+id+'" id="txtDesc_'+id+'" class="input-text" autocomplete="off" value="" placeholder="Description" size="29"/></td><td><input type="text" name="txtOtherAmt_'+id+'" id="txtOtherAmt_'+id+'" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"/></td><td><input type="text" name="txtOtherAddComm_'+id+'" id="txtOtherAddComm_'+id+'" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"/></td><td><input type="text" name="txtOtherNetAmt_'+id+'" id="txtOtherNetAmt_'+id+'"  class="input-text" autocomplete="off" size="12" value="0.00"  readonly /></td></tr>').appendTo("#OthInBody");
		$("[id^=txtOtherAmt_],[id^=txtOtherAddComm_]").numeric();		
		$("#txtOthInCount").val(id);
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeOtherIncome(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#OthInRow_"+var1).remove();
					getFinalCalculation();			
				 }
			else{return false;}
			});
}


function Del_Upload1(var1)
{
	jConfirm('Are you sure you want to remove this attachment permanently ?', 'Confirmation', function(r) {
	if(r){
			$("#row_file1_"+var1).remove();	
		 }
	else{return false;}
	});
}

function Del_Upload(var1)
{
	jConfirm('Are you sure you want to remove this attachment permanently ?', 'Confirmation', function(r) {
	if(r){
			$("#row_file_"+var1).remove();	
		 }
	else{return false;}
	});
}



function addBunkerRow()
{
	var id = $("#txtBunkerCount").val();
	if($("#txtBunkerQty_"+id).val() != "" && $("#selBunker_"+id).val() != "" && $("#txtBunkerPrice_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="DivBunkeractual_'+id+'"><td><a href="#tbb'+id+'" onclick="removeBunkerRows('+id+');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selBunker_'+id+'" id="selBunker_'+id+'" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtBunkerQty_'+id+'" id="txtBunkerQty_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtBunkerPrice_'+id+'" id="txtBunkerPrice_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtBunkerAmt_'+id+'" id="txtBunkerAmt_'+id+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="" autocomplete="off" value=""></td><td><input type="text" name="selBunkerPort_'+id+'" id="selBunkerPort_'+id+'" style="width:200px;" class="input-text" value=""/></td><td><select name="selBunkerVendor_'+id+'" id="selBunkerVendor_'+id+'" style="width:120px;" class="input-text"></select></td></tr>').appendTo("#bunkerTBody");
		$("#txtBunkerCount").val(id);
		$("#selBunkerVendor_"+id).html($("#selVendor").html());
		$("#selBunkerPort_"+id).select2({
			minimumInputLength: 1,
			placeholder: '---Select from list---',
			allowClear: true,
			ajax: {
				url: "options.php?id=84",
				dataType: 'json',
				quietMillis: 100,
				data: function(term, page) {
					return {
						limit: -1,
						q: term
					};
				},
				results: function(data, page ) {
					return { results: data }
				}
			},
			formatResult: function(doc) { 
				return "<div class='select2-user-result'>" + doc.name + "</div>"; 
			},
			formatSelection: function(doc) { 
				return  doc.name; 
			}
		});
		$(".numeric").numeric();	
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeBunkerRows(var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
		if(r){
				$("#DivBunkeractual_"+var1).remove();
				getBunkerCalculation();			
			 }
		else{return false;}
		});
}

function getCargoPlanningdata(val)
{
	if($("#selCargoPlanning").val()!="")
	  {
		  $.post("options.php?id=72",{selCargoPlanning:""+$("#selCargoPlanning").val()+""}, function(data)
			{
				var vsldata = JSON.parse(data);
				$('#txtCID').val(vsldata['CPID']);
				$('#selShipperCP').val(vsldata['SHIPPER']);
				$('#selChartererCP').val(vsldata['CHARTERER']);
				$('#selOwnerCP').val(vsldata['OWNER']);
				$('#selReceiverCP').val(vsldata['RECEAVER']);
				$('#selCargoCP').val(vsldata['CARGO']);
				$('#txtQtyCP').val(vsldata['CARGOSTEAMSIZE']);
				$('#txtToleranceCP').val(vsldata['TOLERANCE']);
				$('#selPlannintTypeCP').val(vsldata['COA_SPOT']);
				$('#txtCOADateCP').val(vsldata['COA_DATE']);
				$('#selBaseInCP').val(vsldata['BASINID']);
				$('#selBunkerHedgeCP').val(vsldata['BUNKER_HEDGE']);
				
				$("#selLPortCP").select2("data", vsldata['LOAD_PORT_TEXT']);
				$("#selDPortCP").select2("data", vsldata['DISCHARGE_PORT_TEXT']);
				
				$('#txtLCSDateCP').val(vsldata['LAYCAN_SDATE']);
				$('#txtLCFDateCP').val(vsldata['LAYCAN_EDATE']);
				$('#selCargoReletCP').val(vsldata['CARGO_RELET']);
				$('#txtNomClauseCP').val(vsldata['NOMCLAUSE']);
				$('#txtRemarksCP').val(vsldata['REMARKS']);
		        if(val==1)
				{
					<?php 
					if($_SESSION['selBType']==1)
					{?>
						if(vsldata['RDO_WS_TYPE'] == '1')
						{
							$('#rdoQtyMar1').attr('checked', true);
							$('#rdoQtyMar2').attr('checked', false);
							showGasMarket(1);
							$("#spanGasLevel").text("Base Freight (USD/MT)");
							$('#txtBaseRate,#txtBaseFreightCP').val(vsldata['WS_LUMPSUM_AMOUNT']);
							$("#txtGasCQMT").val(vsldata['CARGOSTEAMSIZE']);
						}
						else if(vsldata['RDO_WS_TYPE'] == '2')
						{
							$('#rdoQtyMar2').attr('checked', true);
							$('#rdoQtyMar1').attr('checked', false);
							showGasMarket(2);
							$("#spanGasLevel").text("Lumpsum (USD)");
							$('#txtGASLumpsum,#txtBaseFreightCP').val(vsldata['WS_LUMPSUM_AMOUNT']);
							$("#txtGasCQMT").val(vsldata['CARGOSTEAMSIZE']);
						}
						$('#rdoQtyMar2,#rdoQtyMar1').iCheck({
							checkboxClass: 'icheckbox_minimal',
							radioClass: 'iradio_minimal'
						});
					<?php 
					}?>
					<?php 
					if($_SESSION['selBType']==2)
					{?>
						if(vsldata['RDO_WS_TYPE'] == '1')
						{
							$("#spanGasLevel").text("WS");
							$('#ChkLumpsum').attr('checked', false);
							$("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").hide();
							$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").show();
							$('#txtMinWSQty_1,#txtBaseFreightCP').val(vsldata['WS_LUMPSUM_AMOUNT']);
							$("#txtMinCargoQty_1").val(vsldata['CARGOSTEAMSIZE']);
							$('#txtLumpsum').val("");
						
						}
						else if(vsldata['RDO_WS_TYPE'] == '2')
						{
							$("#spanGasLevel").text("Lumpsum (USD)");
							$('#ChkLumpsum').attr('checked', true);
							$("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").show();
							$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").hide();
							$('#txtLumpsum,#txtBaseFreightCP').val(vsldata['WS_LUMPSUM_AMOUNT']);
							$("#txtLumpsumQty").val(vsldata['CARGOSTEAMSIZE']);
							$('#txtMinWSQty_1').val("");
						}
						$('#ChkLumpsum').iCheck({
						checkboxClass: 'icheckbox_minimal',
						radioClass: 'iradio_minimal'
						});
						$('#ChkLumpsum').on('ifChecked', function () { 
							$("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").show();
							$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").hide();
							getFinalCalculation();
						});
						
						$('#ChkLumpsum').on('ifUnchecked', function () { 
							$("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").hide();
							$("#divTanker2,#spanwsports1,#spanwsports2,#spanwsports3,#spanwsports4,#spanwsports5").show();
							getFinalCalculation();
						});
					<?php 
					}?>
					
					<?php 
					if($_SESSION['selBType']==3)
					{?>
						$("#spanGasLevel").text("Freight (USD)");
						$('#txtMTCPDRate,#txtBaseFreightCP').val(vsldata['BASE_FREIGHT']);
						$('#rdoQtyType1').attr('checked', true);
						$('#rdoQtyType2').attr('checked', false);
						$("#txtCQMT").val(vsldata['CARGOSTEAMSIZE']);
						showHideQtyVendorDiv(1);
						$('#rdoQtyType1,#rdoQtyType2').iCheck({
						checkboxClass: 'icheckbox_minimal',
						radioClass: 'iradio_minimal'
						});
					<?php 
					}?>
					$("#selCName").val(vsldata['CARGO']).trigger('change');
					$('#selCName').trigger('liszt:updated');
				}
					getFinalCalculation();
			
			});  
	  }
	  else
	  {
		  $('#txtCID, #selShipperCP, #selChartererCP, #selOwnerCP, #selReceiverCP, #selCargoCP, #txtQtyCP, #txtToleranceCP, #selPlannintTypeCP, #txtCOADateCP, #selBaseInCP, #selBunkerHedgeCP, #selLPortCP, #selDPortCP, #txtLCSDateCP, #txtLCFDateCP, #selCargoReletCP, #txtNomClauseCP, #txtRemarksCP,#txtMinWSQty_1,#txtLumpsum').val("");
	  }
}


function getIntakeCalculation()
{
	var txtAllawedDraftM  = parseFloat($("#txtAllawedDraftM").val());if(isNaN(txtAllawedDraftM)){txtAllawedDraftM = 0;}
	var txtSDraftM        = parseFloat($("#txtSDraftM").val());if(isNaN(txtSDraftM)){txtSDraftM = 0;}
	var txtSDWTMT         = parseFloat($("#txtSDWTMT").val());if(isNaN(txtSDWTMT)){txtSDWTMT = 0;}
	var txtTPCMT          = parseFloat($("#txtTPCMT").val());if(isNaN(txtTPCMT)){txtTPCMT = 0;}
	var txtConstantsMT    = parseFloat($("#txtConstantsMT").val());if(isNaN(txtConstantsMT)){txtConstantsMT = 0;}
	var txtBunkerRobMT    = parseFloat($("#txtBunkerRobMT").val());if(isNaN(txtBunkerRobMT)){txtBunkerRobMT = 0;}
	
	var diffdrafts = parseFloat(txtSDraftM) - parseFloat(txtAllawedDraftM);if(isNaN(diffdrafts)){diffdrafts = 0;}
	var diffdraftsmt = parseFloat(diffdrafts)*100;if(isNaN(diffdraftsmt)){diffdraftsmt = 0;}
	
	var DWTdiffmt = parseFloat(diffdraftsmt)*parseFloat(txtTPCMT);if(isNaN(DWTdiffmt)){DWTdiffmt = 0;}
	
	var cargointakemt = parseFloat(txtSDWTMT) - parseFloat(DWTdiffmt) - parseFloat(txtBunkerRobMT) - parseFloat(txtConstantsMT);if(isNaN(cargointakemt)){cargointakemt = 0;}
	if(txtAllawedDraftM == 0 || txtAllawedDraftM=='')
	{
		$("#txtCargoIntakeMT").val(0);
		$("#txtCQMT").val($('#txtQtyCP').val());
		
	}
	else
	{
		$("#txtCargoIntakeMT,#txtCQMT").val(cargointakemt.toFixed(2));
	}
}

function addConBunkerRow()
{
	var id = $("#txtConBunkerCount").val();
	if($("#txtConBunkerQty_"+id).val() != "" && $("#selConBunker_"+id).val() != "" && $("#txtConBunkerPrice_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="DivConBunkeractual_'+id+'"><td><a href="#tbb'+id+'" onclick="removeConBunkerRows('+id+');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selConBunker_'+id+'" id="selConBunker_'+id+'" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtConBunkerQty_'+id+'" id="txtConBunkerQty_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtConBunkerPrice_'+id+'" id="txtConBunkerPrice_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtConBunkerAmt_'+id+'" id="txtConBunkerAmt_'+id+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="" autocomplete="off" value=""></td></tr>').appendTo("#ConbunkerTBody");
		$("#txtConBunkerCount").val(id);
		$("#selConBunkerVendor_"+id).html($("#selVendor").html());
		$(".numeric").numeric();	
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeConBunkerRows(var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
		if(r){
				$("#DivConBunkeractual_"+var1).remove();
				getBunkerCalculation();			
			 }
		else{return false;}
		});
}

function getCargoPlanningDataList()
{
	$("#cargoplan_list tbody").empty();
	$("#cargoplan_list tbody").html('<tr><td height="200" colspan="17" align="center" ><img src="../../img/loading.gif" /></td></tr>');
	$.post("options.php?id=77",{txtLaycanSDate:""+$("#txtLaycanSDate").val()+"",txtLaycanEDate:""+$("#txtLaycanEDate").val()+"",selCargoPlan:""+$("#selCargoPlan").val()+"",txtFromCargoSize:""+$("#txtFromCargoSize").val()+"",txtToCargoSize:""+$("#txtToCargoSize").val()+"",coaspot:1,relet:2}, function(data)
	{
		$("#cargoplan_list tbody").empty();
		var cpdata = JSON.parse(data);
		var i = 0;
		$.each(cpdata, function(index, array) {
			i = parseInt(i) + 1;
			$('<tr><td>'+array['CPID']+'</td><td>'+array['COA_DATE']+'</td><td>'+array['CHARTERER']+'</td><td>'+array['OWNER']+'</td><td>'+array['CARGO']+'</td><td>'+array['CARGOSTEAMSIZE']+'</td><td>'+array['BASE_FREIGHT']+'</td><td>'+array['BASINID']+'</td><td>'+array['LOAD_PORT']+'</td><td>'+array['DISCHARGE_PORT']+'</td><td>'+array['LAYCAN_SDATE']+'</td><td>'+array['LAYCAN_EDATE']+'</td><td>'+array['VESSELTYPE']+'</td><td><input name="rdoCargoPlanning" class="checkbox" id="rdoCargoPlanning_'+i+'" type="radio" value="'+array['OPEN_CARGOID']+'"/><input name="txtCargoPlanning_'+array['OPEN_CARGOID']+'" id="txtCargoPlanning_'+array['OPEN_CARGOID']+'" type="hidden" value="'+array['TEXTTOSHOW']+'"/></td></tr>').appendTo("#cargoplan_list tbody");
		});	
		$("input[name='rdoCargoPlanning']").iCheck({
			checkboxClass: 'icheckbox_minimal',
			radioClass: 'iradio_minimal'
		});
		$('[id^=rdoCargoPlanning_]').on('ifChecked', function () { 
		   $("#selCargoPlanning").val($(this).val());
		   $("#txtCargoPlanDetails").val($("#txtCargoPlanning_"+$(this).val()).val());
		   getCargoPlanningdata(1);
		});
	});  
}

function addMainCargoDetails()
{
	var id = $("#txtMainCargoDetailID").val();
	if($("#selCharterers_"+id).val() != "" && $("#txtAmountUSD_"+id).val() != "" )
	{
		id = (id - 1) + 2;
		$('<tr id="maincargodetailrow2_'+id+'"><td width="50px;"><a href="#tb1" onClick="deleteMainCargoDetails('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selCharterers_'+id+'" class="input-text" style="width:120px;" id="selCharterers_'+id+'" onChange="getFinalCalculation();"></select></td><td><select name="selCargo_'+id+'" class="input-text" style="width:120px;" id="selCargo_'+id+'"></select></td><td><input type="text" name="txtCargocbm_'+id+'" id="txtCargocbm_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtCargomt_'+id+'" id="txtCargomt_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtRateUSDmt_'+id+'" id="txtRateUSDmt_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtAmountUSD_'+id+'" id="txtAmountUSD_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly="true" style="background-color:#E1E1E1;"/></td></tr>').appendTo("#tblmaincargodetail");
		$("#txtMainCargoDetailID").val(id);
		$("[id^=txtCargocbm_],[id^=txtCargomt_],[id^=txtRateUSDmt_],[id^=txtAmountUSD_]").numeric();
		$("#selCharterers_"+id).html($("#selCharterer").html());
		$("#selCargo_"+id).html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());
	}
	else
	{
		jAlert('Please fill All details', 'Alert');
		return false;
	}
}


function deleteMainCargoDetails(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#maincargodetailrow1_"+var1).remove();
					$("#maincargodetailrow2_"+var1).remove();
					getFinalCalculation();	
				 }
			else{return false;}
			});
}

function addoveragedetail()
{
	var id = $("#txtoveragedetailID").val();
	if($("#selCharterers2_"+id).val() != "" && $("#txtAmountUSD2_"+id).val() != "" )
	{
		id = (id - 1) + 2;
		$('<tr id="overagedetailrow2_'+id+'"><td width="50px;"><a href="#tb1" onClick="deleteoveragedetail('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selCharterers2_'+id+'" class="input-text" style="width:120px;" id="selCharterers2_'+id+'" onChange="getFinalCalculation();"></select></td><td><select name="selCargo2_'+id+'" class="input-text" style="width:120px;" id="selCargo2_'+id+'"></select></td><td><input type="text" name="txtCargocbm2_'+id+'" id="txtCargocbm2_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtCargomt2_'+id+'" id="txtCargomt2_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtRateUSDmt2_'+id+'" id="txtRateUSDmt2_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtAmountUSD2_'+id+'" id="txtAmountUSD2_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly="true" style="background-color:#E1E1E1;"/></td></tr>').appendTo("#tbloveragedetail");
		$("#txtoveragedetailID").val(id);
		$("[id^=txtCargocbm2_],[id^=txtCargomt2_],[id^=txtRateUSDmt2_],[id^=txtAmountUSD2_]").numeric();
		$("#selCharterers2_"+id).html($("#selCharterer").html());
		$("#selCargo2_"+id).html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());
	}
	else
	{
		jAlert('Please fill All details', 'Alert');
		return false;
	}
}

function deleteoveragedetail(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#overagedetailrow1_"+var1).remove();
					$("#overagedetailrow2_"+var1).remove();
					getFinalCalculation();	
				 }
			else{return false;}
			});
}

function adddeadfreightdetail()
{
	var id = $("#txtdeadfreightdetailID").val();
	if($("#selCharterers3_"+id).val() != "" && $("#txtAmountUSD3_"+id).val() != "" )
	{
		id = (id - 1) + 2;
		$('<tr id="deadfreightdetailrow2_'+id+'"><td width="50px;"><a href="#tb1" onClick="deletedeadfreightdetail('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selCharterers3_'+id+'" class="input-text" style="width:120px;" id="selCharterers3_'+id+'" onChange="getFinalCalculation();"></select></td><td><select name="selCargo3_'+id+'" class="input-text" style="width:120px;" id="selCargo3_'+id+'"></select></td><td><input type="text" name="txtCargocbm3_'+id+'" id="txtCargocbm3_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtCargomt3_'+id+'" id="txtCargomt3_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtRateUSDmt3_'+id+'" id="txtRateUSDmt3_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td><input type="text" name="txtAmountUSD3_'+id+'" id="txtAmountUSD3_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly="true" style="background-color:#E1E1E1;"/></td></tr>').appendTo("#tbldeadfreight");
		$("#txtdeadfreightdetailID").val(id);
		$("[id^=txtCargocbm3_],[id^=txtCargomt3_],[id^=txtRateUSDmt3_],[id^=txtAmountUSD3_]").numeric();
		$("#selCharterers3_"+id).html($("#selCharterer").html());
		$("#selCargo3_"+id).html($("#selMaterial<?php echo $_SESSION['selBType'];?>").html());
	}
	else
	{
		jAlert('Please fill All details', 'Alert');
		return false;
	}
}

function deletedeadfreightdetail(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
			if(r){
					$("#deadfreightdetailrow1_"+var1).remove();
					$("#deadfreightdetailrow2_"+var1).remove();
					getFinalCalculation();	
				 }
			else{return false;}
			});
}

function showHideTankQtyVendorDiv(value)
{
	if(value ==1)
	{
		$("#divTankDistributed").hide();
		$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").show();
	}
	if(value ==2)
	{
		$("#divTankDistributed").show();
		$("#divTankSingle,#cargoplan_1,#cargoplan_2,#cargoplan_3").hide();
	}
}


function removeDelBunker(var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
	if(r){
			$("#row_del_"+var1).remove();			
		 }
	else{return false;}
	});
}


function AddNewDel()
{
	var id = $("#txtDELID").val();
	if($("#selDelBunker_"+id).val() != "" && $("#txtDelQty_"+id).val() != "" && $("#txtDelBunDate_"+id).val() != "" && $("#txtDelPrice_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr class="input-text" id="row_del_'+id+'"><td><a href="#tbl'+id+'" onClick="removeDelBunker('+id+');" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td><td><select name="selDelBunker_'+id+'" class="input-text" style=" width:90px;" id="selDelBunker_'+id+'"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtDelQty_'+id+'" id="txtDelQty_'+id+'" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td><td><input type="text" name="txtDelBunDate_'+id+'" id="txtDelBunDate_'+id+'" class="input-text" style="width:85px;" value="" placeholder="DD-MM-YYYY" autocomplete="off" /></td><td><input type="text" name="txtDelPrice_'+id+'" id="txtDelPrice_'+id+'" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getDelBunkerCalculation();" autocomplete="off" /></td><td><input type="text" name="txtDelAmount_'+id+'" id="txtDelAmount_'+id+'" class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" readonly="true" autocomplete="off"/></td></tr>').appendTo("#bunkerdelivery");
		$("#txtDELID").val(id);
		$(".numeric").numeric();	
		$("[id^=txtDelBunDate_]").datepicker({
			format: 'dd-mm-yyyy',
			autoclose: true
		});
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function getDelBunkerCalculation()
{
	var txtDELID = $("#txtDELID").val();
	for(var i =1;i <=txtDELID;i++)
	{
		var txtDelQty      = parseFloat($("#txtDelQty_"+i).val());if(isNaN(txtDelQty)){txtDelQty = 0.00;}
		var txtDelPrice    = parseFloat($("#txtDelPrice_"+i).val());if(isNaN(txtDelPrice)){txtDelPrice = 0.00;}
		var amount          =   parseFloat(parseFloat(txtDelQty)*parseFloat(txtDelPrice));if(isNaN(amount)){amount = 0.00;}
		$('#txtDelAmount_'+i).val(parseFloat(amount).toFixed(2));
	}
	$("#txtTotalDelAmount").val($('[id^=txtDelAmount_]').sum());
	getFinalCalculation();
}

function getReDelBunkerCalculation()
{
	var txtREDELID = $("#txtREDELID").val();
	for(var i =1;i <=txtREDELID;i++)
	{
		var txtReDelQty      = parseFloat($("#txtReDelQty_"+i).val());if(isNaN(txtReDelQty)){txtReDelQty = 0.00;}
		var txtReDelPrice    = parseFloat($("#txtReDelPrice_"+i).val());if(isNaN(txtReDelPrice)){txtReDelPrice = 0.00;}
		var amount          =   parseFloat(parseFloat(txtReDelPrice)*parseFloat(txtReDelQty));if(isNaN(amount)){amount = 0.00;}
		$('#txtReDelAmount_'+i).val(parseFloat(amount).toFixed(2));
	}
	$("#txtTotalReDelAmount").val($('[id^=txtReDelAmount_]').sum());
	getFinalCalculation();
}


function removeReDelBunker(var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
	if(r){
			$("#row_Redel_"+var1).remove();		
		 }
	else{return false;}
	});
}


function AddNewReDel()
{
	var id = $("#txtREDELID").val();
	if($("#selReDelBunker_"+id).val() != "" && $("#txtReDelQty_"+id).val() != "" && $("#txtReDelBunDate_"+id).val() != "" && $("#txtReDelPrice_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr class="input-text" id="row_Redel_'+id+'"><td><a href="#tbl'+id+'" onClick="removeReDelBunker('+id+');" ><i class="fa fa-times" style="color:red;"></i></a>&nbsp;&nbsp;</td><td><select name="selReDelBunker_'+id+'" class="input-text" style=" width:90px;" id="selReDelBunker_'+id+'"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtReDelQty_'+id+'" id="txtReDelQty_'+id+'" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td><td><input type="text" name="txtReDelBunDate_'+id+'" id="txtReDelBunDate_'+id+'" class="input-text" style="width:85px;" value="" placeholder="DD-MM-YYYY" autocomplete="off" /></td><td><input type="text" name="txtReDelPrice_'+id+'" id="txtReDelPrice_'+id+'" class="input-text numeric" style="width:85px;" value="" placeholder="0.00" onKeyUp="getReDelBunkerCalculation();" autocomplete="off" /></td><td><input type="text" name="txtReDelAmount_'+id+'" id="txtReDelAmount_'+id+'" class="input-text numeric" style="width:85px;background-color:#E1E1E1;" value="" placeholder="0.00" readonly="true" autocomplete="off"/></td></tr>').appendTo("#bunkerRedelivery");
		$("#txtREDELID").val(id);
		$(".numeric").numeric();	
		$("[id^=txtReDelBunDate_]").datepicker({
			format: 'dd-mm-yyyy',
			autoclose: true
		});
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}


function AddNewOffHire()
{
	var id = $("#txtOFFID").val();
	if($("#txtOffHireReason_"+id).val() != "" && $("#txtOffHireFrom_"+id).val() != "" && $("#txtOffHireTo_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="row_offhire_'+id+'" class="input-text"><td><a href="#pr'+id+'" onclick="removeOffHire('+id+');"><i class="fa fa-times" style="color:red;"></i></a></td><td valign="top"><textarea class="input-text areasize" name="txtOffHireReason_'+id+'" style="width:120px;" id="txtOffHireReason_'+id+'" rows="3" placeholder="Off Hire Reason..."></textarea></td><td valign="top"><input type="text" name="txtOffHireFrom_'+id+'" id="txtOffHireFrom_'+id+'" class="input-text" placeholder="dd-mm-yyyy HH:MM" style="width:100px;" autocomplete="off" value=""></td><td valign="top"><input type="text" name="txtOffHireTo_'+id+'" id="txtOffHireTo_'+id+'" class="input-text" placeholder="dd-mm-yyyy HH:MM" autocomplete="off" value="" style="width:100px;"></td><td valign="top"><input type="text" name="txtOffHireDays_'+id+'" id="txtOffHireDays_'+id+'" class="input-text"  placeholder="Off Hire Days" style="width:90px;background-color:#EAEAEA;" autocomplete="off" value=""/></td><td valign="top"><input type="text" name="txtOffHireRate_'+id+'" id="txtOffHireRate_'+id+'" class="input-text" style="width:100px;"  placeholder="Rate/Day" autocomplete="off" value="" onKeyUp="getFinalCalculation();"/></td><td valign="top"><input type="text" name="txtOffHireAmt_'+id+'" id="txtOffHireAmt_'+id+'" class="input-text"  placeholder="Off Hire(USD)" style="width:90px;background-color:#EAEAEA;" autocomplete="off" value=""/></td></tr><tr id="row_offhireBunker_'+id+'"><td></td><td colspan="6"><table width="100%" class="tablesorter"><tr><td></td><td>Bunker Grade</td><td>Qty(MT)</td><td>Price(USD)</td><td>Amount(USD)</td><td>On Owner\'s Account</td></tr><tbody id="TCConbunkerTBody_'+id+'"><tr id="DivTCConBunkeractual_'+id+'_1"><td><a href="#tb1" onClick="removeTCConBunkerRows('+id+',1);" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selTCConBunker_'+id+'_1" id="selTCConBunker_'+id+'_1" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtTCConBunkerQty_'+id+'_1" id="txtTCConBunkerQty_'+id+'_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td><td><input type="text" name="txtTCConBunkerPrice_'+id+'_1" id="txtTCConBunkerPrice_'+id+'_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""/></td><td><input type="text" name="txtTCConBunkerAmt_'+id+'_1" id="txtTCConBunkerAmt_'+id+'_1" style="width:90px;" class="input-text"  placeholder="0.00" readonly autocomplete="off" value=""/></td><td><input name="ChkOFFHireCal_'+id+'_1" class="checkbox" id="ChkOFFHireCal_'+id+'_1" type="checkbox" value="1"/></td></tr></tbody><tr><td colspan="6"><button type="button" onClick="addTCConBunkerRow('+id+',1)">Add Bunkers</button><input type="hidden" name="txtTCConBunkerCount_'+id+'" id="txtTCConBunkerCount_'+id+'" value="1"/></td></tr></table></td></tr>').appendTo("#offhirebody");
		$("#txtOFFID").val(id);
		$("[id^=txtOffHireRate_]").numeric();	
		$(".numeric").numeric();
		$(".areasize").autosize({append: "\n"});
		$('#txtOffHireFrom_'+id+',#txtOffHireTo_'+id).datetimepicker({
		format: 'dd-mm-yyyy hh:ii',
	    autoclose: true,
        todayBtn: true,
        minuteStep: 1
		}).on('changeDate', function(){  getFinalCalculation(); });
		
		$('#ChkOFFHireCal_'+id+'_1').iCheck({
		checkboxClass: 'icheckbox_minimal',
		radioClass: 'iradio_minimal'
		});
		
		$('[id^=ChkOFFHireCal_]').on('ifChecked', function () { 
		   $(this).attr('checked', true);
		   getFinalCalculation();
		});
		 
		$('[id^=ChkOFFHireCal_]').on('ifUnchecked', function () { 
		   $(this).attr('checked', false);
		   getFinalCalculation();
		});
	}
}


function removeOffHire(var1)
{
		jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
		if(r){
				$("#row_offhire_"+var1).remove();
				$("#row_offhireBunker_"+var1).remove()
				getFinalCalculation();
			 }
		else{return false;}
		});
}


function getTimeDiff(date2,date1)
{	
	if(date1 != '' &&  date2 != '')
	{
		end_actual_time  	 =  getDateWithSpecificFormat(date2);
		start_actual_time    =  getDateWithSpecificFormat(date1);
		
		start_actual_time 	= new Date(start_actual_time);
		end_actual_time 	= new Date(end_actual_time);
	
		var diff 			= end_actual_time - start_actual_time;
		var days			= (diff) / 86400000;
		return days.toFixed(5);	
	}
}

function getDateWithSpecificFormat(sep)
{
	var dateSplit1  = sep.split(' ');
	var dateSplit   = dateSplit1[0].split('-');
	var currentDate = dateSplit[2] + '-' + dateSplit[1] + '-' + dateSplit[0]+' '+dateSplit1[1];
	return currentDate;
}

function addTCConBunkerRow(val)
{
	var id = $("#txtTCConBunkerCount_"+val).val();
	if($("#txtTCConBunkerQty_"+val+"_"+id).val() != "" && $("#selTCConBunker_"+val+"_"+id).val() != "" && $("#txtTCConBunkerPrice_"+val+"_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="DivTCConBunkeractual_'+val+'_'+id+'"><td><a href="#tbb'+id+'" onclick="removeTCConBunkerRows('+val+','+id+');"><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="selTCConBunker_'+val+'_'+id+'" id="selTCConBunker_'+val+'_'+id+'" style="width:90px;" class="input-text"><?php $obj->getBunkerList();?></select></td><td><input type="text" name="txtTCConBunkerQty_'+val+'_'+id+'" id="txtTCConBunkerQty_'+val+'_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtTCConBunkerPrice_'+val+'_'+id+'" id="txtTCConBunkerPrice_'+val+'_'+id+'" style="width:90px;" class="input-text numeric" onkeyup="getFinalCalculation();" placeholder="0.00" autocomplete="off" value=""></td><td><input type="text" name="txtTCConBunkerAmt_'+val+'_'+id+'" id="txtTCConBunkerAmt_'+val+'_'+id+'" style="width:90px;" class="input-text" placeholder="0.00" readonly="" autocomplete="off" value=""></td><td><input name="ChkOFFHireCal_'+val+'_'+id+'" class="checkbox" id="ChkOFFHireCal_'+val+'_'+id+'" type="checkbox" value="1"/></td></tr>').appendTo("#TCConbunkerTBody_"+val);
		$("#txtTCConBunkerCount_"+val).val(id);
		$(".numeric").numeric();	
		$('#ChkOFFHireCal_'+val+'_'+id).iCheck({
		checkboxClass: 'icheckbox_minimal',
		radioClass: 'iradio_minimal'
		});
		
		$('[id^=ChkOFFHireCal_]').on('ifChecked', function () { 
		   $(this).attr('checked', true);
		   getFinalCalculation();
		});
		 
		$('[id^=ChkOFFHireCal_]').on('ifUnchecked', function () { 
		   $(this).attr('checked', false);
		   getFinalCalculation();
		});
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

function removeTCConBunkerRows(val,var1)
{
	jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
		if(r){
				$("#DivTCConBunkeractual_"+val+"_"+var1).remove();
				getBunkerCalculation();			
			 }
		else{return false;}
		});
}


function getPortText()
{
    var p_rotationID = $("#p_rotationID").val();
	for(var i =1;i <=p_rotationID;i++)
	{
		if($("#selFPort_"+i).val()!='')
		{
		    $("#spanLoadPort_"+i).text($("#selFPort_"+i).select2('data').name);
			$("#TranDisPort_"+i).text($("#selFPort_"+i).select2('data').name);
			$("#spanDDCLPort_"+i).text($("#selFPort_"+i).select2('data').name);
		}else
		{
		    $("#spanLoadPort_"+i).text('');
			$("#TranDisPort_"+i).text('');
			$("#spanDDCLPort_"+i).text('');
		}
		
		if($("#selTPort_"+i).val()!='')
		{
		    $("#spanDisPort_"+i).text($("#selTPort_"+i).select2('data').name);
			$("#spanDDCDPort_"+i).text($("#selTPort_"+i).select2('data').name);
		}else
		{
		    $("#spanDisPort_"+i).text('');
			$("#spanDDCDPort_"+i).text('');
		}
	}
	getVoyageTime();

}


function getShowModel(val)
{
    if($("#selFPort_"+val).val()=='' || $("#selTPort_"+val).val()=='')
	{
	    $("#bttngetDistance").hide();
		
		jAlert('Please select From Port and To Port', 'Alert');
	}
	else
	{
		$("#portDistanceRowid").val(val);
		$("#spanFromPort").text($("#selFPort_"+val).select2('data').name);
		$("#spanToPort").text($("#selTPort_"+val).select2('data').name);
		$("#selGreatCicle").val($("#selDType_"+val).val());
		$("#distancebutton").click();
		var i=1;
		$("[id^=myonoffswitch_]").each(function () {
			document.getElementById("myonoffswitch_"+i).setAttribute("type", "checkbox");
			i++;
		});
		getShowGreatCircleBox();
		$("#bttngetDistance").show();
	    getdistancemap(); 
	}
}


function getShowGreatCircleBox()
{
    if($("#selGreatCicle").val()==1)
	{
	     $("#spanGreatCircle1,#spanGreatCircle2").show();
	}else{
	     $("#spanGreatCircle1,#spanGreatCircle2").hide();
		 $("#txtGreatCircleInterval").val(0);
	}
}


function useDistance()
{
    var rowid = $("#portDistanceRowid").val();
	$("#txtDistance_"+rowid).val($("#totalDistance").text());
    $("#txtSecaDistance_"+rowid).val($("#totalSECADistance").text());
	$("#selDType_"+rowid).val($("#selGreatCicle").val());
	getVoyageTime();
}

function getdistancemap() 
{
	$("#distancemap1").html('<div style="margin-top:200px;"><img src="../../img/loading.gif" /></div>');
	$("#bttnuseDistance").hide();
    var rowid = $("#portDistanceRowid").val();
	var StartPortID = $("#selFPort_"+rowid).select2('data').id;
	var EndPortID = $("#selTPort_"+rowid).select2('data').id;
	var StartLon = 0;
	var StartLat = 0;
	var EndLon = 0;
	var EndLat = 0;
	var GreatCircleInterval = $("#txtGreatCircleInterval").val();
	var SecaAvoidance = $("#txtSecaAvoidance").val();
	var AslCompliance = $("#txtASLCompliance").val();
	var i =1;var k =0;
	var AllowedAreas = Array();
	$("[id^=myonoffswitch_]").each(function () {
	    if($("#myonoffswitch_"+i).is(":checked"))
		{
		   AllowedAreas[k] = $("#myonoffswitch_"+i).val();
		   k++;
		}
		i++;
    });
	
	AllowedAreas[k] = $("#selPiracyZone").val();
    $("#totalDistance").text(0.00);
    $("#totalSECADistance").text(0.00);
	$.post("options.php?id=82",{StartPortID:""+StartPortID+"",EndPortID:""+EndPortID+"",StartLon:StartLon,StartLat:StartLat,EndLon:EndLon,EndLat:EndLat,GreatCircleInterval:GreatCircleInterval,SecaAvoidance:SecaAvoidance,AslCompliance:AslCompliance,AllowedAreas:""+AllowedAreas+""}, function(data) 
	{
	     $("#distancemap1").empty();
		 $("#distancemap1").html('<div id="distancemap" style="width:100%; height:500px; vertical-align:middle; text-align:center; border:1px solid #D6D6D6; margin-bottom:10px;">Show Map Here</div>');
		 var successtext = '';
		 var lat_long_string = [];
		 var i = 1;
		 var sartlong = '';
		 var endlong = '';
		 var editionval = 0;
	     var distancedata = JSON.parse(data);
		 $.each(distancedata, function(index, array) {
			  $("#totalDistance").text(array['totalDistance']);
			  $("#totalSECADistance").text(array['secaDistance']);
			  $("#bttnuseDistance").show();
		      if(array['resultCode']==1)
			  {
			      if(array['waypoints']!=null)
				  {   
					  $.each(array['waypoints'], function(index1, distancearray) {
					      endlong = distancearray['lon'];
						  if(sartlong!='')
						  {
						      var longdiff = parseFloat(sartlong) - parseFloat(endlong);
						      if(longdiff > 180){editionval = 360;}
							  if(longdiff < -180){editionval = -360;}
						  }
					      distancearray['lon'] = parseFloat(distancearray['lon']) + parseFloat(editionval);
						  lat_long_string.push(new L.LatLng(distancearray['lat'], distancearray['lon']));
						  sartlong = endlong;
						  i++;
					  });
				  }else{jAlert(array['resultText'], 'Alert');successtext = 'error';}
			  }else{successtext = 'error';}
			
		 });
		 $("#txtCordinates_"+rowid).val(lat_long_string);
		 $("#pointsTextArea1").val(lat_long_string);
		 if(successtext != 'error')
		 {
		    
		 	 var map = L.map('distancemap', {
			 zoomSnap: 0.25
			 }).setView([52, 22], 6);
			 L.tileLayer('https://mapsapi.seametrix.net/api/colorful/{z}/{x}/{y}.png', {
			 maxZoom: 10,
			 center: [0, 180],
			 edgeBufferTiles: 1
			 }).addTo(map);
			 
			var coordinates = lat_long_string;
			//alert(coordinates);
			 var polyline = L.Polyline.PolylineEditor(coordinates, {maxMarkers: 200}).addTo(map);
			 map.fitBounds(polyline.getBounds());
			 
			 /*var coordinates = lat_long_string;
			var polyline = L.polyline(lat_long_string, {color: 'red'}).addTo(map);
			// zoom the map to the polyline
			map.fitBounds(polyline.getBounds());
			
			 var corner1 = L.latLng(startlat, startlong),
			 corner2 = L.latLng(endlat, endlong),
			 bounds = L.latLngBounds(corner1, corner2);
			 new L.LatLng(endlat, endlong, true);*/
			 //var polyline = L.Polyline(coordinates, {maxMarkers: 200}).addTo(map);
			 //map.fitBounds(polyline.getBounds());
		     
			 /*var dumpPoints = function() {
				 var pointsTextArea = document.getElementById('pointsTextArea');
				 pointsTextArea.innerHTML = '';
				 map.getEditablePolylines().forEach(function(polyline) {
					 var points = polyline.getPoints();
					 points.forEach(function(point) {
						 var latLng = point.getLatLng();
						 console.log(point.context);
						 pointsTextArea.innerHTML += 'originalPointNo=' + (point.context ? point.context.originalPointNo : null)
									+ ' originalPolylineNo=' + (point.context ? point.context.originalPolylineNo : null)
									+ ' (' + latLng.lat + ',' + latLng.lng + ')\n';
									+ '\n';
					 });
					 pointsTextArea.innerHTML += '----------------------------------------------------------------------------------------------------\n';
				 });
			 };*/
		 }
		 else
		 {
		     jAlert('Error!, Something went wrong, Please try again', 'Alert');
		     return false;
		 }
	});
}
</script>
    </body>
</html>