<?php

// DIE('CHECK');


session_start();
require_once("../../includes/display_internal_user_sopf.inc.php");
require_once("../../includes/functions_internal_user_sopf.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
if (@$_REQUEST['action'] == 'submit') {
	$msg = $obj->insertTCITemplateDetailsNew();
	header('Location:./estimate_list.php?msg=' . $msg);
}
if (isset($_REQUEST['estimatetype']) && $_REQUEST['estimatetype'] != "") {
	$estimatetype = $_REQUEST['estimatetype'];
	$_SESSION['selBType'] = $_REQUEST['estimatetype'];
} else {
	$estimatetype = $_SESSION['selBType'];
}
if (isset($_REQUEST['periodid'])) {
	$periodid = $_REQUEST['periodid'];
} else {
	$periodid = '';
}
$rdoQtyType = 1;
$rdoQtyMar = 1;
$rdoTankQtyType = 1;
$pagename = basename($_SERVER['PHP_SELF']);
$rdoMarket = $rdoMMarket = $rdoCap = $rdoDWT = $rdoQty = 1;
// echo $_SESSION['selBType'];
// die();

$bunkerGradeData	=	$obj->getBunkerGradeData();
?>

<!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" />
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" type="text/css" />
	<?php $display->js(); ?>
	<script src="../../js/select2.min.js" type="text/javascript"></script>
	<link rel="stylesheet" href="css/estimate-fix.css" type="text/css" />
	<style>



	</style>

	<style>
		.speed-col {
			display: none;
			background: transparent !important;
		}

		.speed-col.full-speed {
			display: table-cell;
			background: transparent !important;
		}

		.owcDesign {

			border-collapse: collapse;
			margin: auto;
		}

		.owcDesign trs {

			border: 1px solid #000;
			padding: 10px 20px;
			text-align: center;
		}

		/* .speed-col {
    display: none;
    background: transparent !important;
}
.speed-col.full-speed {
    display: table-cell;
} */

		/* Consumption data column visibility */
		.consumption-full-speed,
		.consumption-service-speed,
		.consumption-eco-speed {
			display: none;
		}

		.show-full-speed .consumption-full-speed,
		.show-service-speed .consumption-service-speed,
		.show-eco-speed .consumption-eco-speed {
			display: table-cell;
		}





		/* Remove any background colors */
		/* td, th {
    background: transparent !important;
} */
		<?php

		// DIE('CHECK');


		session_start();
		require_once("../../includes/display_internal_user_sopf.inc.php");
		require_once("../../includes/functions_internal_user_sopf.inc.php");
		$obj = new data();
		$connect = $obj->funConnect();
		$display = new display();
		$display->logout_iu();
		if (@$_REQUEST['action'] == 'submit') {
			$msg = $obj->insertTCITemplateDetailsNew();
			header('Location:./estimate_list.php?msg=' . $msg);
		}
		if (isset($_REQUEST['estimatetype']) && $_REQUEST['estimatetype'] != "") {
			$estimatetype = $_REQUEST['estimatetype'];
			$_SESSION['selBType'] = $_REQUEST['estimatetype'];
		} else {
			$estimatetype = $_SESSION['selBType'];
		}
		if (isset($_REQUEST['periodid'])) {
			$periodid = $_REQUEST['periodid'];
		} else {
			$periodid = '';
		}
		$rdoQtyType = 1;
		$rdoQtyMar = 1;
		$rdoTankQtyType = 1;
		$pagename = basename($_SERVER['PHP_SELF']);
		$rdoMarket = $rdoMMarket = $rdoCap = $rdoDWT = $rdoQty = 1;
		?>< !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" /><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" type="text/css" /><?php $display->js(); ?><script src="../../js/select2.min.js" type="text/javascript"></script><link rel="stylesheet" href="css/speed-fix.css" type="text/css" /><style>
	</style>

	<style>
		.speed-col {
			display: none;
			background: transparent !important;
		}

		.speed-col.full-speed {
			display: table-cell;
			background: transparent !important;
		}

		td.text,
		td.input-text {
			background: transparent !important;
		}

		table,
		tr,
		td {
			background: transparent !important;
		}

		/* Override any other background colors */



		/* Speed column visibility */
		/* .speed-col {
    display: none;
    background: transparent !important;
}
.speed-col.full-speed {
    display: table-cell;
} */

		/* Consumption data column visibility */
		.consumption-full-speed,
		.consumption-service-speed,
		.consumption-eco-speed {
			display: none;
		}

		.show-full-speed .consumption-full-speed,
		.show-service-speed .consumption-service-speed,
		.show-eco-speed .consumption-eco-speed {
			display: table-cell;
		}



		<?php

		// DIE('CHECK');


		session_start();
		require_once("../../includes/display_internal_user_sopf.inc.php");
		require_once("../../includes/functions_internal_user_sopf.inc.php");
		$obj = new data();
		$connect = $obj->funConnect();
		$display = new display();
		$display->logout_iu();
		if (@$_REQUEST['action'] == 'submit') {
			$msg = $obj->insertTCITemplateDetailsNew();
			header('Location:./estimate_list.php?msg=' . $msg);
		}
		if (isset($_REQUEST['estimatetype']) && $_REQUEST['estimatetype'] != "") {
			$estimatetype = $_REQUEST['estimatetype'];
			$_SESSION['selBType'] = $_REQUEST['estimatetype'];
		} else {
			$estimatetype = $_SESSION['selBType'];
		}
		if (isset($_REQUEST['periodid'])) {
			$periodid = $_REQUEST['periodid'];
		} else {
			$periodid = '';
		}
		$rdoQtyType = 1;
		$rdoQtyMar = 1;
		$rdoTankQtyType = 1;
		$pagename = basename($_SERVER['PHP_SELF']);
		$rdoMarket = $rdoMMarket = $rdoCap = $rdoDWT = $rdoQty = 1;
		?>< !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" /><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" type="text/css" /><?php $display->js(); ?><script src="../../js/select2.min.js" type="text/javascript"></script><link rel="stylesheet" href="css/speed-fix.css" type="text/css" /><style>
	</style>

	<style>
		.speed-col {
			display: none;
			background: transparent !important;
		}

		.speed-col.full-speed {
			display: table-cell;
			background: transparent !important;
		}

		td.text,
		td.input-text {
			background: transparent !important;
		}

		table,
		tr,
		td {
			background: transparent !important;
		}




		/* Speed column visibility */
		/* .speed-col {
    display: none;
    background: transparent !important;
}
.speed-col.full-speed {
    display: table-cell;
} */

		/* Consumption data column visibility */
		.consumption-full-speed,
		.consumption-service-speed,
		.consumption-eco-speed {
			display: none;
		}

		.show-full-speed .consumption-full-speed,
		.show-service-speed .consumption-service-speed,
		.show-eco-speed .consumption-eco-speed {
			display: table-cell;
		}







		td[width="25%"] {
			width: 25% !important;
		}

		*/
		/* Remove any global table styles that might affect other sections */




		/* Remove any background colors */
		/* td, th {
    background: transparent !important;
} */
		<?php

		// DIE('CHECK');


		session_start();
		require_once("../../includes/display_internal_user_sopf.inc.php");
		require_once("../../includes/functions_internal_user_sopf.inc.php");
		$obj = new data();
		$connect = $obj->funConnect();
		$display = new display();
		$display->logout_iu();
		if (@$_REQUEST['action'] == 'submit') {
			$msg = $obj->insertTCITemplateDetailsNew();
			header('Location:./estimate_list.php?msg=' . $msg);
		}
		if (isset($_REQUEST['estimatetype']) && $_REQUEST['estimatetype'] != "") {
			$estimatetype = $_REQUEST['estimatetype'];
			$_SESSION['selBType'] = $_REQUEST['estimatetype'];
		} else {
			$estimatetype = $_SESSION['selBType'];
		}
		if (isset($_REQUEST['periodid'])) {
			$periodid = $_REQUEST['periodid'];
		} else {
			$periodid = '';
		}
		$rdoQtyType = 1;
		$rdoQtyMar = 1;
		$rdoTankQtyType = 1;
		$pagename = basename($_SERVER['PHP_SELF']);
		$rdoMarket = $rdoMMarket = $rdoCap = $rdoDWT = $rdoQty = 1;
		?>< !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" /><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" type="text/css" /><?php $display->js(); ?><script src="../../js/select2.min.js" type="text/javascript"></script><link rel="stylesheet" href="css/speed-fix.css" type="text/css" /><style>
	</style>

	<style>
		.speed-col {
			display: none;
			background: transparent !important;
		}

		.speed-col.full-speed {
			display: table-cell;
			background: transparent !important;
		}

		td.text,
		td.input-text {
			background: transparent !important;
		}

		table,
		tr,
		td {
			background: transparent !important;
		}



		/* Speed column visibility */
		/* .speed-col {
    display: none;
    background: transparent !important;
}
.speed-col.full-speed {
    display: table-cell;
} */

		/* Consumption data column visibility */
		.consumption-full-speed,
		.consumption-service-speed,
		.consumption-eco-speed {
			display: none;
		}

		.show-full-speed .consumption-full-speed,
		.show-service-speed .consumption-service-speed,
		.show-eco-speed .consumption-eco-speed {
			display: table-cell;
		}





		td[width="25%"] {
			width: 25% !important;
		}

		*/
		/* Remove any background colors */
		/* td, th {
    background: transparent !important;
} */

		/* tr:nth-child(even) {
	background-color: rgba(150, 212, 212, 0.4);
	}

	th:nth-child(even),td:nth-child(even) {
	background-color: rgba(150, 212, 212, 0.4);
	} */

		.content-header {
			margin-top: 0 !important;
			padding: 0px 15px !important;
		}

		.content-header h1 {
			margin: -11px !important;
		}

		.content-header .breadcrumb {
			margin: -12px !important;
			padding: 0px 15px !important;
		}



		.modal-foot {
			padding: 7px 20px 5px;
			margin-top: 1px;
			text-align: right;
			border-top: 1px solid #e5e5e5;
		}

		select[readonly] {
			pointer-events: none;
		}


		/* irrelevent styling */

		* {
			box-sizing: border-box;
		}

		*[readonly] {
			background: #DFDFDF;
			border: 1px solid #ccc;
			color: #555;
		}

		.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;
		}
	</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 Out 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 Out 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:3px; padding:15px 5px 0px 5px;">
					<tr>


						<td class="input-text" style="color:#175c84;">
							<strong>Business&nbsp;Type:</strong><select name="selBusinessType" class="input-text" id="selBusinessType" style="width:120px;color:#175c84;" onChange="makeFieldManD(this);">
								<option value="">---Select from list---</option>
								<option value="1">TCIN-VCOUT</option>
								<option value="2">VCIN-VCOUT</option>
								<option value="3">VCOUT</option>
							</select>
						</td>

						<!-- <select id="targetSelect" style="display:none">
						<option value="">Select from chosen items</option>
						</select> -->


						<!-- <td class="input-text" style="color:#175c84;"><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:#175c84;">

							<script type="text/javascript">
								$(document).ready(function($) {
									$("#selVName").select2({
										minimumInputLength: 1,
										placeholder: '---Select from list---',
										allowClear: true,
										ajax: {
											url: "getVesselByImo.php",
											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) {

										$('#shipTypeFromApi').val($(e)[0]['added']['shipType'])
										$('#dwtFromApi').val($(e)[0]['added']['dwt'])
										getData();

									});



								});
							</script>



							<strong>Vessel&nbsp;:</strong><input name="selVName" class="input-text" id="selVName" style="width:170px;color:#175c84;">
							<input type="hidden" name="shipTypeFromApi" class="input-text" id="shipTypeFromApi" value="">
							<input type="hidden" name="dwtFromApi" class="input-text" id="dwtFromApi" value="">
							</input>
						</td>

						<td class="input-text" style="color:#175c84;"><strong>Vessel&nbsp;Type&nbsp;:</strong><input type="text" name="txtVType" id="txtVType" style="width:95px;color:#175c84;" class="input-text" readonly value="" />
							<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:#175c84;"><strong>Flag&nbsp;:</strong><input type="text" name="txtFlag" id="txtFlag" style="width:100px;color:#175c84;" class="input-text" readonly value="" /></td>
						<td class="input-text" style="color:#175c84;"><strong>CP Date&nbsp;:</strong><input type="text" name="txtDate" id="txtDate" style="width:90px;color:#175c84;" class="input-text" value="<?php echo date("d-m-Y", time()); ?>" placeholder"dd-mm-yy" /></td>
						<td class="input-text" style="color:#367fa9;"><strong>Voyage&nbsp;No.&nbsp;:</strong><input type="text" name="txtVNo" id="txtVNo" style="width:90px;color:#175c84;" class="input-text" value="" placeholder"" /></td>

						<td style="width:60px;color:#175c84;text-align:center;"><a href="estimate_list.php">
								<div class="btn-info btn-flat">Back</div>
							</a></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> -->
					</ul>

					<div class="tab-content">

						<!----------------------------------------------- Start 1------------------------------------------------->
						<div id="tabs_2" class="tab-pane active" style="overflow:auto;">




							<table width="100%" style="margin-top:2px;">
								<tr style="display: none;">
									<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="" 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="" /></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="" 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="" 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="" /></td>
								</tr>
							</table>


							<table width="100%" style="margin-top:2px;">
								<tr style="">
									<td class="input-text">&nbsp;DWT<span style="font-size:10px; font-style:italic;">(Summer)</span>&nbsp;:&nbsp;<input type="text" name="txtSummer_DWT1" id="txtSummer_DWT1" style="width:90px;" class="input-text" value="" placeholder="0.00" readonly />
									</td>




									<td width="25%" align="left" class="text">GRT&nbsp;:&nbsp;<input type="text" name="txtGNRT" id="txtGNRT" style="width:100px;" class="input-text" readonly value="" /></td>


									<td width="25%" align="left" valign="top" class="text">LOA&nbsp;:&nbsp;<input type="text" name="txtLOA" id="txtLOA" style="width:100px;" class="input-text" readonly value="" /></td>



									<td width="25%" align="left" valign="top" class="text">TPC&nbsp;:&nbsp;<input type="text" name="txtTPC" id="txtTPC" style="width:100px;" class="input-text" readonly value="" /></td>




								</tr>
							</table>



							<!-- <div class="container">
  							  <div id="commercialSection">
       					
   

	

							</div>
							<div id="resultSection">
											

							


							</div>
						</div> -->






							<table width="100%">
								<tr>
									<td colspan="2">



									</td>
								</tr>
								<tr>
									<td colspan="2">
										<div class="custom-heading">
											<i class="fas fa-route"></i>
											Passage & Ports
										</div>
									</td>
								</tr>
								<tr>
									<td colspan="2">
										<table class='tablesorter'>
											<thead>
												<tr>
													<th>#</th>
													<th>From Port</th>
													<th>To Port</th>
													<th>Wx<span style="font-size:10px; font-style:italic;">(%)</span></th>

													<th>L/B</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>Navigation</th>
												</tr>
											</thead>
											<tbody id="tblPortRotation">
												<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: "getportapi.php",
																	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: "getportapi.php",
																	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">
														<input type="text" name="txtMargin_1" style="width:60px;" id="txtMargin_1" class="input-text" autocomplete="off" placeholder="0.00" value="5" 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>


													<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" onClick="getShowModel(1);"><b>Fetch</b></button>
														</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">
														<select name="selDType_1" class="input-text" style="width:90px;" id="selDType_1">
															<?php $obj->getPortDistanceType_new(); ?>
														</select>
													</td>




												</tr>
											</tbody>
											<tfoot>
												<tr>
													<th colspan="12" style="background-color:#ffffff;"><button class="btn-flat" type="button" onClick="addPortRotationDetails()">Add</button><input type="hidden" name="p_rotationID" id="p_rotationID" class="input" value="1" /></th>
												</tr>
											</tfoot>
										</table>
									</td>
								<tr>
									<td width="60%" style="vertical-align:top;">

										<table cellpadding="1" cellspacing="1" border="0" width="100%" class='tablesorter' id="commercialParameter" style="">
											<!-- <tr height="10">
									<td colspan="10" align="left" class="text" valign="top"></td>
								</tr> -->

											<tr>
												<!-- <td width="25%" align="left" class="text" style="color:#dc631e;">Speed Data</td> -->
											<tr>
												<td width="25%" align="left" class="text" style="color:#dc631e;">Speed Data</td>
												<td colspan="2" width="25%" align="right" valign="top" class="text" style="color:#1b77a6;">
													<select name="speedType" id="speedType" class="input-text" style="width:104px;color:#175c84;" onchange="toggleSpeedFields()">
														<option value="full" selected>Full Speed</option>
														<option value="service">Service Speed</option>
														<option value="eco">Most Eco Speed</option>
													</select>
												</td>
												<!-- <td width="25%" align="right" valign="top" class="text"></td>

	

	
    <td width="25%" align="right" valign="top" class="text"></td> -->
												<!-- <td width="25%" align="left" class="text">GRT&nbsp;:&nbsp;<input type="text" name="txtGNRT" id="txtGNRT" style="width:190px;" class="input-text" readonly value="" /></td> -->

												<td colspan="2" width="25%" align="left" class="input-text" style="color:#dc631e;">Ballast Speed <span style="font-size:10px; font-style:italic;">(Knots)</span></td>
												<td width="25%" align="right" valign="top" class="text speed-col full-speed"><input type="text" name="txtBFullSpeed" id="txtBFullSpeed" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
												<td width="25%" align="right" valign="top" class="text speed-col service-speed"><input type="text" name="txtBEcoSpeed1" id="txtBEcoSpeed1" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
												<td width="25%" align="right" valign="top" class="text speed-col eco-speed"><input type="text" name="txtBEcoSpeed2" id="txtBEcoSpeed2" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>


												<td width="25%" colspan="2" align="left" class="input-text" style="color:#dc631e;">Laden Speed <span style="font-size:10px; font-style:italic;">(Knots)</span></td>
												<td width="25%" align="right" valign="top" class="text speed-col full-speed"><input type="text" name="txtLFullSpeed" id="txtLFullSpeed" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
												<td width="25%" align="right" valign="top" class="text speed-col service-speed"><input type="text" name="txtLEcoSpeed1" id="txtLEcoSpeed1" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
												<td width="25%" align="right" valign="top" class="text speed-col eco-speed"><input type="text" name="txtLEcoSpeed2" id="txtLEcoSpeed2" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>





											</tr>
											<tbody>
												<tr>

												</tr>
												<tr>

												</tr>
											</tbody>


											<tr style="display: none;" height="10">
												<td colspan="10" align="left" class="text" valign="top">
													<table width="100%" cellpadding="1" cellspacing="1" border="0">
														<thead>
															<tr style="display: none;">
																<td width="25%" align="left" class="text">GRT&nbsp;:&nbsp;<input type="text" name="txtGNRT" id="txtGNRT" style="width:190px;" class="input-text" readonly value="" /></td>
																<td width="25%" align="left" valign="top" class="text">LOA&nbsp;:&nbsp;<input type="text" name="txtLOA" id="txtLOA" style="width:190px;" class="input-text" readonly value="" /></td>
																<td width="25%" align="left" valign="top" class="text">Built Year&nbsp;:&nbsp;<input type="text" name="txtBuiltYear" id="txtBuiltYear" class="input-text" readonly value="" /></td>
																<td width="25%" align="left" valign="top" class="text"></td>
															</tr>
															<tr style="display: none;">
																<td width="25%" align="left" class="text">BEAM(m)<br /><input type="text" name="txtBeam" id="txtBeam" class="input-text" readonly value="" /></td>
																<td width="25%" align="left" valign="top" class="text">TPC&nbsp;:&nbsp;<input type="text" name="txtTPC" id="txtTPC" style="width:190px;" class="input-text" readonly value="" /></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" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
													<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtBEcoSpeed1" id="txtBEcoSpeed1" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
													<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtBEcoSpeed2" id="txtBEcoSpeed2" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></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" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
													<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtLEcoSpeed1" id="txtLEcoSpeed1" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></td>
													<td width="25%" align="right" valign="top" class="text"><input type="text" name="txtLEcoSpeed2" id="txtLEcoSpeed2" style="width:190px;" class="input-text" value="" onKeyUp="getVoyageTime();" placeholder="0.00" /></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><input type="hidden" name="txtFOAtSeaID" id="txtFOAtSeaID" value="0" /></td>
															</tr>
														</tbody>
														<thead>
															<tr>
																<th></th>
																<th colspan="4" class="consumption-full-speed" style="text-align:center;">Full Speed</th>
																<th colspan="4" class="consumption-service-speed" style="text-align:center;">Service Speed</th>
																<th colspan="4" class="consumption-eco-speed" style="text-align:center;">Most Eco Speed</th>
																<th colspan="2" style="text-align:center;">Working</th>
																<th colspan="2" style="text-align:center;">Idle</th>

															</tr>
															<tr>
																<th>Bunker</th>
																<th class="consumption-full-speed">SECA (B)</th>
																<th class="consumption-full-speed">SECA (L)</th>
																<th class="consumption-full-speed">NON-SECA (B)</th>
																<th class="consumption-full-speed">NON-SECA (L)</th>
																<th class="consumption-service-speed">SECA (B)</th>
																<th class="consumption-service-speed">SECA (L)</th>
																<th class="consumption-service-speed">NON-SECA (B)</th>
																<th class="consumption-service-speed">NON-SECA (L)</th>
																<th class="consumption-eco-speed">SECA (B)</th>
																<th class="consumption-eco-speed">SECA (L)</th>
																<th class="consumption-eco-speed">NON-SECA (B)</th>
																<th class="consumption-eco-speed">NON-SECA (L)</th>
																<th class="consumption-full-speed">SECA</th>
																<th class="consumption-full-speed">NON-SECA</th>
																<th class="consumption-full-speed">SECA</th>
																<th class="consumption-full-speed">NON-SECA</th>


																<th class="consumption-service-speed">SECA</th>
																<th class="consumption-service-speed">NON-SECA</th>
																<th class="consumption-service-speed">SECA</th>
																<th class="consumption-service-speed">NON-SECA</th>


																<th class="consumption-eco-speed">SECA</th>
																<th class="consumption-eco-speed">NON-SECA</th>
																<th class="consumption-eco-speed">SECA</th>
																<th class="consumption-eco-speed">NON-SECA</th>





															</tr>
														</thead>
														<tbody id="tbodyFOAtSea">

														</tbody>
														<tbody>
															<tr>
																<td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT) - At Sea</strong><input type="hidden" name="txtDOAtSeaID" id="txtDOAtSeaID" value="0" /></td>
															</tr>
														</tbody>
														<tbody id="tbodyDOAtSea">

														</tbody>







													</table>
													<?php if ($_SESSION['selBType'] == 1 || $_SESSION['selBType'] == 3) { ?>
														<table width="100%">
															<tbody>
																<!-- <tr>
														<td colspan="13" style="color:#dc631e;"><strong>FO Consp/day(MT)- In Port</strong><input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="0" /></td>
													</tr> -->
																<input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="0" />
																<input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="0" />
															</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">

																<!-- </tbody> -->
															<tbody>
																<!-- <tr>
														<td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT)- In Port</strong><input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="0" /></td>
													</tr> -->
															</tbody>
															<tbody id="tbodyDOInPort">

																<!-- </tbody> -->
														</table>
													<?php } else { ?>
														<input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="0" />
														<input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="0" />
														<!-- <table width="100%">
												<tbody>
													<tr>
														<td colspan="13" style="color:#dc631e;"><strong>FO Consp/day(MT)- In Port</strong><input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="0" /></td>
													</tr>
												</tbody>
												<thead>
													<tr>
														<th></th>
														<th colspan="4" style="text-align:center;">Idle</th>
														<th colspan="2" style="text-align:center;">Working - LP(incl. Deball)</th>
														<th colspan="2" style="text-align:center;">Working - DP(Incl. COW, Inert, Ball)</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>NON-SECA (Ballast)</th>
														<th>SECA (Laden)</th>
														<th>NON-SECA (Laden)</th>
														<th>SECA</th>
														<th>NON-SECA</th>
														<th>SECA</th>
														<th>NON-SECA</th>
													</tr>
												</thead>
												<tbody id="tbodyFOInPort">

												</tbody>
												<tbody>
													<tr>
														<td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT)- In Port</strong><input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="0" /></td>
													</tr>
												</tbody>
												<tbody id="tbodyDOInPort">

												</tbody>
											</table>

											<table width="100%">
												<tbody>
													<tr>
														<td colspan="13" style="color:#dc631e;"><strong>FO Consp/day(MT) - Others</strong><input type="hidden" name="txtFOInPortID" id="txtFOInPortID" value="0" /></td>
													</tr>
												</tbody>
												<thead>
													<tr>
														<th></th>
														<th colspan="2" style="text-align:center;">Tank Cleaning(Incl. Inert)</th>
														<th colspan="2" style="text-align:center;">Inerting</th>
														<th colspan="2" style="text-align:center;">Gas Freeing</th>
														<th colspan="2" style="text-align:center;">Heating(Maintain 45 dec C)</th>
														<th colspan="2" style="text-align:center;">Heating(Raise 1 Deg C)</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>
														<th>SECA</th>
														<th>NON-SECA</th>
														<th>SECA</th>
														<th>NON-SECA</th>
													</tr>
												</thead>
												<tbody id="tbodyFOOthers">

												</tbody>
												<tbody>
													<tr>
														<td colspan="13" style="color:#dc631e;"><strong>DO Consp/day(MT) - Others</strong><input type="hidden" name="txtDOInPortID" id="txtDOInPortID" value="0" /></td>
													</tr>
												</tbody>
												<tbody id="tbodyDOOthers">

												</tbody>
											</table> -->
													<?php } ?>
												</td>
											</tr>



											<!-- 
								<tr height="10">
									<td colspan="10" align="left" class="text" valign="top"></td>
								</tr> -->
										</table>



										<div class="custom-heading">
											<i class="fas fa-boxes"></i>
											Cargo
										</div>
										<table class='tablesorter'>
											<tbody>
												<tr>
													<td colspan="2">
														<table width="">
															<tr>


																<td style="width:10%;"><strong>Cargo Name&nbsp;:</strong><input type="hidden" name="rdoEstimateType" id="rdoEstimateType" value="<?php echo $_SESSION['selBType']; ?>" /></td>
																<td style="width:25%;">
																	<select data-placeholder="Choose Cargo Name..." class="input-text chzn-select" style="width:300px;" multiple name="selCName[]" onChange="getMaterialCode();" id="selCName"><?php $obj->getCargoNameListForMultiple($_SESSION['selBType']); ?></select>
																</td>

																<td style="width:8%;"><strong>Chartering Team&nbsp;1:</strong></td>
																<td style="width:8%;">
																	<select name="chartering_pic" class="input-text" id="chartering_pic" style="width:200px;color:#175c84;" onChange="">
																		<?php
																		echo $obj->getCountyListForChartering();
																		?>
																	</select>
																</td>
																<td style="width:10%;"><strong>Chartering PIC 1&nbsp;:</strong></td>
																<td style="width:10%;">
																	<select name="chartering_pic_1" class="input-text" id="chartering_pic_1" style="width:200px;color:#175c84;" onChange="">
																		<?php
																		echo $obj->getUserListForChartering();
																		?>
																	</select>
																</td>

																<td style="width:10%;">Total Freight</td>
																<td><input type="text" name="txtFrAdjUsdTF" id="txtFrAdjUsdTF" size="13" class="input-text" readonly value="" /><input type="text" style="display:none;" name="txtFrAdjUsdTFMT" id="txtFrAdjUsdTFMT" class="input-text" readonly value="" /></td>



																<!-- <td style="width:10%;"><strong>Period&nbsp;Contract&nbsp;:</strong></td> -->
																<!-- <td style="width:27%;" colspan="2"><select name="selPeriodContract" class="input-text" id="selPeriodContract" style="width:200px;color:#175c84;" onChange="loadPeriodDetails();">
																		<?php
																		$obj->getPeriodContractList($periodid);
																		?>
																	</select>
																	<script>
																		$("#selPeriodContract").val(<?= $periodid; ?>);
																	</script>
																</td> -->


															</tr>


															<tr>


																<!-- <td style="width:10%;"><strong>Chartering&nbsp; PIC 2&nbsp;:</strong></td>
																<td style="width:27%;" colspan="2">
																	<select name="chartering_pic_2" class="input-text" id="chartering_pic_2" style="width:200px;color:#175c84;" onChange="">
																		<?php
																		echo $obj->getUserListForChartering();
																		?>
																	</select>

																</td> -->
															</tr>
															<tr>

																<!-- <td style="width:8%;"><strong>Chartering Team&nbsp;2:</strong></td>
																<td style="width:8%;">
																	<select name="chartering_pic_team_1" class="input-text" id="chartering_pic_team_1" style="width:200px;color:#175c84;">
																		<?php
																		// $obj->getFun261()

																		echo $obj->getCountyListForChartering();
																		?>
																	</select>
																</td> -->
																<!-- <td style="width:10%;"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Chartering PIC 3&nbsp;:</strong></td>
																<td style="width:25%;">
																	<select name="chartering_pic_3" class="input-text" id="chartering_pic_3" style="width:200px;color:#175c84;" onChange="">
																		<?php

																		echo $obj->getUserListForChartering();
																		?>
																		<input type="hidden" name="chTeam_3" id="chTeam_3" value="">
																	</select>
																</td> -->
																<!-- <td style="width:10%;"><strong>Chartering&nbsp; PIC 4&nbsp;:</strong></td>
																<td style="width:27%;" colspan="2">
																	<select name="chartering_pic_4" class="input-text" id="chartering_pic_4" style="width:200px;color:#175c84;" onChange="">
																		<?php

																		echo $obj->getUserListForChartering();
																		?>
																		<input type="hidden" name="chTeam_4" id="chTeam_4" value="">
																	</select>

																</td> -->


															</tr>

														</table>
													</td>
												</tr>
												<tr id="distypeDiv1" style="display:none;">
													<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="" 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="" 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="" 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 style="display:none;">
																<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="10%;"><span id="lumpsumspan5">Freight&nbsp;Rate(USD/MT)</span></td>
																<td width="100px;"><span id="lumpsumspan6"><input type="text" name="txtTankerFreightRate" id="txtTankerFreightRate" class="input-text numeric" autocomplete="off" size="12" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" /></span></td>
															</tr>
														</table>
														<div id="divTankDistributed">
															<table class='tablesorter' width="100%">
																<tr>
																	<td><strong style="font-size:12px;">Main Cargo Details</strong></td>
																	<td class="input-text"></td>
																	<td></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>
																	<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>
																</tbody>

																<tfoot style="background-color:#fff;">
																	<tr>
																		<td><button type="button" onClick="addMainCargoDetails();">Add</button>
																			<input type="hidden" name="txtMainCargoDetailID" id="txtMainCargoDetailID" value="1" />
																		</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>
																	<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>
																</tbody>

																<tfoot style="background-color:#fff;">
																	<tr>
																		<td><button type="button" onClick="addoveragedetail();">Add</button>
																			<input type="hidden" name="txtoveragedetailID" id="txtoveragedetailID" value="1" />
																		</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>
																	<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>
																</tbody>

																<tfoot style="background-color:#fff;">
																	<tr>
																		<td><button type="button" onClick="adddeadfreightdetail();">Add</button>
																			<input type="hidden" name="txtdeadfreightdetailID" id="txtdeadfreightdetailID" value="1" />
																		</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>
														<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;
																	}
																});
															});
														</script>
														<div id="divTankSingle">
															<table class='tablesorter' width="100%" id="divTanker1">
																<tbody>
																	<tr>
																		<td width="140px;"><span id="spanwsports1">WS Port(s) Combo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
																		<td width="60px;"><span id="spanwsports2">From :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>
																		<td width="142px;"><span id="spanwsports3">
																				<input type="text" name="selWSFPort" id="selWSFPort" class="input-text" style="width:200px;" value="" />
																			</span>
																		</td>
																		<td width="40px;"><span id="spanwsports4">To :</span></td>
																		<td width="152px;">
																			<span id="spanwsports5"><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" />&nbsp;&nbsp;Lump-sum(USD)</td>
																		<td width="110px;" align="right"><span id="lumpsumspan1" style="display:none;">Cargo&nbsp;Qty(MT)&nbsp;&nbsp;:&nbsp;&nbsp;</span></td>
																		<td width="130px;"><span id="lumpsumspan2" style="display:none;"><input type="text" name="txtLumpsumQty" id="txtLumpsumQty" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" /></span></td>
																		<td width="50px;"><span id="lumpsumspan3" style="display:none;">Amount(USD)&nbsp;&nbsp;:&nbsp;&nbsp;</span></td>
																		<td width="130px;"><span id="lumpsumspan4" style="display:none;"><input type="text" name="txtLumpsum" id="txtLumpsum" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" /></span></td>
																		<td width="110px;"></td>


																	</tr>

																</tbody>
															</table>
															<div style="clear:both;"></div>

															<table class='tablesorter' id="divTanker2" width="100%">
																<tbody id="tblTankerBody">
																	<tr>
																		<td colspan="9">
																			<div><strong style="font-size:13px;">Freight Adjustment</strong></div>
																		</td>
																	</tr>
																	<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>
																</tbody>
																<tfoot style="background-color:#fff;">
																	<tr>
																		<td colspan="9"><button type="button" onClick="addTankDetails();">Add</button><input type="hidden" name="txtTankID" id="txtTankID" value="1" /><input type="hidden" name="txtTankQuantity" id="txtTankQuantity" value="" /></td>
																	</tr>
																</tfoot>
															</table>
														</div>

													</td>
												</tr>

												<tr id="distypeDiv3" style="display:none;">
													<td colspan="2">
														<table width="100%">
															<tr style="display:none">
																<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"><textarea class="input-text" name="txtDistributedRemarks" id="txtDistributedRemarks" cols="50" rows="2" placeholder="Distributed Remarks ..."></textarea></div>
													</td>
												</tr>
										</table>

										<table id="divQty1" class='tablesorter' width="100%">
											<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>
													<th>Gross&nbsp;Freight <span style="font-size:10px; font-style:italic;">(USD)</span><input type="hidden" name="txtQTYID" id="txtQTYID" value="0" /></th>
													<th>Final Net Freight <span style="font-size:10px; font-style:italic;">(USD)</span></th>

												</tr>
											</thead>
											<tbody id="tblQtyFreight">
											</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="0.00" /></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">
											<tbody>
												<tr>
													<td style="display:none;"><strong>Market</strong>&nbsp;&nbsp;</td>
													<td style="display:none;"><input name="rdoMMarket" class="checkbox" id="rdoMMarket1" type="radio" value="1" <?php if ($rdoMMarket == 1) echo "checked"; ?> onclick="showMMarketField(1);" /></td>
													<td>Freight <span style="font-size:10px; font-style:italic;">($/MT)</span>&nbsp;&nbsp;</td>
													<td><input type="text" name="txtMTCPDRate" id="txtMTCPDRate" class="input-text" autocomplete="off" size="13" placeholder="0.00" value="" 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>LS&nbsp;<span style="font-size:10px; font-style:italic;">($)</span>&nbsp;&nbsp;</td>
													<td><input type="text" name="txtMLumpsum" id="txtMLumpsum" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" disabled="disabled" onKeyUp="getFinalCalculation();" /></td>
													<!-- <td>Addnl&nbsp;Cargo&nbsp;Rate&nbsp;<span style="font-size:10px;font-style:italic;">($/MT)</span>&nbsp;</td>
																	<td><input type="text" name="txtAddnlCRate" id="txtAddnlCRate" class="input-text" autocomplete="off" size="13" value="" placeholder="0.00" onKeyUp="getFinalCalculation();" /></td> -->
													<td>QTY&nbsp;<span style="font-size:10px; font-style:italic;">(MT)</span>&nbsp;&nbsp;</td>
													<td><input type="text" name="txtBLCQMT" id="txtBLCQMT" class="input-text numeric" size="13" autocomplete="off" value="0.00" placeholder="0.00" onkeyup="getFinalCalculation();" /></td>

												</tr>
												<tr>
													<td colspan="13"></td>
												</tr>
												<tr>
													<td style="display:none;"><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 style="display:none;"><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="" 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="" size="13" onKeyUp="getFinalCalculation();" disabled /></td>
																	<td>Less (%) In BL Qty.</td>
																	<td><input type="text" name="txtLessPerQty" id="txtLessPerQty" class="input-text numeric" size="13" autocomplete="off" value="" placeholder="0.00" onkeyup="getFinalCalculation();" /></td>
																	<td>Quantity For Freight&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" readonly="true" autocomplete="off" value="" placeholder="0.00" onkeyup="getFinalCalculation();" /></td> -->


													<td colspan="2">Gross&nbsp;Freight&nbsp;&nbsp;<input type="text" name="txtFrAdjUsdGF" id="txtFrAdjUsdGF" size="13" class="input-text" readonly value="" /><input type="text" style="display:none;" name="txtFrAdjUsdGFMT" id="txtFrAdjUsdGFMT" size="13" class="input-text" readonly value="" /></td>
													<td>Dead Freight</td>
													<td><input type="text" name="txtFrAdjUsdDF" id="txtFrAdjUsdDF" size="13" class="input-text" readonly value="" /><input type="text" style="display:none;" name="txtFrAdjUsdDFMT" id="txtFrAdjUsdDFMT" size="13" class="input-text" readonly value="" /></td>

													<!-- <td>Addnl Freight</td>
																	<td><input type="text" name="txtTotalFreightQty" id="txtTotalFreightQty" style="width:100px;" class="input-text" readonly value="0.00" /><input type="text" style="display:none;" name="txtFrAdjUsdAFMT" id="txtFrAdjUsdAFMT" class="input-text" readonly value="" /></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="" /></td>

												</tr>

												<tr>


												</tr>

											</tbody>
										</table>
									</td>
								</tr>
								</tbody>
							</table>




							<!-- <div><strong style=io"font-size:13px;">Operatnal 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" onKeyUp="getFinalCalculation();" value="" placeholder="0.00" /></td>
										<td><input type="text" name="txtFrAdjUsdAC" id="txtFrAdjUsdAC" class="input-text" readonly value="0.00" size="12" /></td>

									</tr>
								</tbody>
								<tbody id="tbodyBrokerage">
									<tr id="tbrRow_1">
										<td><a href="#tb1'" onClick="removeBrokerage(1);"><i class="fa fa-times" style="color:red;"></i></a></td>
										<td>Charterers side 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>

									</tr>
								</tbody>

								<tbody>
									<tr>
										<td><button type="button" class="btn-flat" onClick="addBrokerageRow()">Add</button><input type="hidden" name="txtBRokageCount" id="txtBRokageCount" value="1" /></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>

									</tr>
								</tbody>
							</table>





							<table class='tablesorter'>
								<thead>
									<tr>
										<th>No Dem/Disp/Port?</th>

										<th>LP</th>
										<th>Cargos'</th>
										<th>Cost($)</th>
										<th>Qty&nbsp;<span id="loadqtylabel">(MT)</span>&nbsp;&nbsp;</th>
										<th></th>
										<th><span style="font-size:10px; font-style:italic;" id="loadtablelebel">(MT/Day)</span></th>
										<th>Terms&nbsp;&nbsp;</th>
										<th>Work&nbsp;Days&nbsp;&nbsp;</th>
										<th>Idle&nbsp;Days&nbsp;</th>

										<th>SECA ?</th>
									</tr>
								</thead>
								<tbody id="tblLoadPort">
									<tr id="lp_Row_1">

										<td align="left" class="form-control"

											title="" data-widget="Please check the box, for which demurrage/despatch is not required." data-toggle="tooltip" data-original-title="Please check the box, for which demurrage/despatch is not required.">
											<input name="ChkShowDDCLP_1" class="checkbox" id="ChkShowDDCLP_1" type="checkbox" value="1" />
										</td>

										<td align="center" class="input-text">
											<span id="spanLoadPort_1"></span>
										</td>


										<td align="left" class="input-text">
											<select id="targetSelectLp_1" name="targetSelectLp_1" class="targetSelect" style="width:80px;">
												<option value="">---Select from chosen items---</option>
											</select>
										</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">
											<i class="fa fa-calculator" style="font-size:17px" data-widget="Calculate loadable" data-toggle="tooltip" data-original-title="Calculate loadable" data-rotationId="1" data-porttype="lp" onclick="setCalloadable(this)"></i>


										</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="ChkLPSECA_1" class="checkbox" id="ChkLPSECA_1" type="checkbox" value="1" />
										</td>
									</tr>
								</tbody>
							</table>
							<table class='tablesorter'>
								<thead>
									<tr>
										<th>No Dem/Disp/Port?</th>

										<th>DP</th>
										<th>Cargos'</th>
										<th>Cost($)</th>
										<th>Qty&nbsp;<span id="dischargeqtylabel">(MT)</span></th>
										<th></th>
										<th><span style="font-size:10px; font-style:italic;" id="dischargetablelebel">(MT/Day)</span></th>
										<th>Terms</th>
										<th>Work&nbsp;Days&nbsp;&nbsp;</th>
										<th>Idle&nbsp;Days&nbsp;</th>

										<th>SECA ?</th>
									</tr>
								</thead>
								<tbody id="tblDisPort">
									<tr id="dp_Row_1">
										<td align="left" class="form-control"

											title="" data-widget="Please check the box, for which demurrage/despatch is not required." data-toggle="tooltip" data-original-title="Please check the box, for which demurrage/despatch is not required.">
											<input name="ChkShowDDCDP_1" class="checkbox" id="ChkShowDDCDP_1" type="checkbox" value="1" />
										</td>

										<td align="center" class="input-text">
											<span id="spanDisPort_1"></span>
										</td>
										<td align="left" class="input-text">
											<select id="targetSelectDp_1" name="targetSelectDp_1" class="targetSelect" style="width:80px;">
												<option value="">---Select from chosen items---</option>
											</select>
										</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">
											<i class="fa fa-calculator" style="font-size:17px" data-widget="Calculate loadable" data-toggle="tooltip" data-rotationId="1" data-original-title="Calculate loadable" data-porttype="dp" onclick="setCalloadable(this)"></i>

										</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="ChkDPSECA_1" class="checkbox" id="ChkDPSECA_1" type="checkbox" value="1" />
										</td>
									</tr>
								</tbody>

							</table>
							<table class='tablesorter'>
								<thead>
									<tr>

										<!-- <th></th> -->
										<th>TP/ BP</th>

										<th>Cost($)</th>
										<th>Idle Days</th>
										<th>SECA ?</th>
										<th>Port Function</th>

									</tr>
								</thead>
								<tbody id="tblTransitPort">
									<tr id="tp_Row_1">


										<!-- <td align="left"class="form-control" >
															
														
													</td> -->



										<td></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();setRequired(this);" />
										</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>




										<td align="left" class="input-text">
											<select name="selPortFun_1" class="input-text" style="width:120px;" id="selPortFun_1">
												<option value="">--Please Select---</option>
												<option value="TP">Transit Port</option>
												<option value="BP">Bunkering Port</option>
											</select>
										</td>




									</tr>
								</tbody>
							</table>
							<?php if ($_SESSION['selBType'] == 2) { ?>
								<table class='tablesorter'>
									<thead>
										<tr>
											<th>Activity</th>
											<th>SECA (Hrs)</th>
											<th>Non-SECA (Hrs)</th>
										</tr>
									</thead>
									<tbody>
										<tr class="input-text">
											<td>Tank Cleaning(Incl. Inert) <span style="font-size:10px; font-style:italic;">(Hrs)</span></td>
											<td><input type="text" name="txtTKSECAHrs" id="txtTKSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
											<td><input type="text" name="txtTKNONSECAHrs" id="txtTKNONSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
										</tr>
										<tr class="input-text">
											<td>Inerting <span style="font-size:10px; font-style:italic;">(Hrs)</span></td>
											<td><input type="text" name="txtInertSECAHrs" id="txtInertSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
											<td><input type="text" name="txtInertNONSECAHrs" id="txtInertNONSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
										</tr>
										<tr class="input-text">
											<td>Gas Freeing <span style="font-size:10px; font-style:italic;">(Hrs)</span></td>
											<td><input type="text" name="txtGFSECAHrs" id="txtGFSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
											<td><input type="text" name="txtGFNONSECAHrs" id="txtGFNONSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
										</tr>
										<tr class="input-text">
											<td>Heating(Maintain 45 dec C) <span style="font-size:10px; font-style:italic;">(Hrs)</span></td>
											<td><input type="text" name="txtHeatSECAHrs" id="txtHeatSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
											<td><input type="text" name="txtHeatNONSECAHrs" id="txtHeatNONSECAHrs" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
										</tr>

										<tr class="input-text">
											<td>Heating(Raise 1 Deg C) <span style="font-size:10px; font-style:italic;">(Hrs)</span></td>
											<td><input type="text" name="txtHeatSECAHrs1" id="txtHeatSECAHrs1" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
											<td><input type="text" name="txtHeatNONSECAHrs1" id="txtHeatNONSECAHrs1" style="width:80px;" class="input-text numeric" autocomplete="off" value="" placeholder="0.00" onKeyUp="getPortCalculation();" /></td>
										</tr>
									</tbody>
								</table>
							<?php } ?>


							<!-- <table class='tablesorter' class='owcDesign'>
											<thead>
												<tr>
													<th width="20%"></th>
													<th width="20%"></th>
													<th width="20%">Cost</th>
												</tr>
											</thead>
											<tbody id="OWCBody">
												

												<tr id="OWCRow_1">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" /></td>
													<td><select name="txtHidORCID_1" id="txtHidORCID_1" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(3); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="2000" placeholder="0.00" size="12" required /></td>

												</tr>

												<tr id="OWCRow_2">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_3" id="txtORCSlaveRandomID_3" value="" /></td>
													<td><select name="txtHidORCID_2" id="txtHidORCID_2" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(6); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_2" id="txtORCAmt_2" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required /></td>

												</tr>

												<tr id="OWCRow_3">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_4" id="txtORCSlaveRandomID_4" value="" /></td>
													<td><select name="txtHidORCID_3" id="txtHidORCID_3" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(32); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_3" id="txtORCAmt_3" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required /></td>

												</tr>

												<tr id="OWCRow_4">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_5" id="txtORCSlaveRandomID_5" value="" /></td>
													<td><select name="txtHidORCID_4" id="txtHidORCID_4" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(30); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_4" id="txtORCAmt_4" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required /></td>

												</tr>

												<tr id="OWCRow_5">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_6" id="txtORCSlaveRandomID_6" value="" /></td>
													<td><select name="txtHidORCID_5" id="txtHidORCID_5" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(31); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_5" id="txtORCAmt_5" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required /></td>

												</tr>

												<tr id="OWCRow_6">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_7" id="txtORCSlaveRandomID_7" value="" /></td>
													<td><select name="txtHidORCID_6" id="txtHidORCID_6" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(12); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_6" id="txtORCAmt_6" onKeyUp="getORCCalculate(1);setIlhocForTcDet();" class="input-text" autocomplete="off" value="5000" placeholder="0.00" size="12" required /></td>

												</tr>


												<tr id="OWCRow_7">
													<td><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_8" id="txtORCSlaveRandomID_8" value="" /></td>
													<td><select name="txtHidORCID_7" id="txtHidORCID_7" style="width:130px;">
															<?php $obj->getOwnerRelatedCostList(5); ?>
														</select></td>
													<td><input type="text" name="txtORCAmt_7" id="txtORCAmt_7" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="0" placeholder="0.00" size="12" required /></td>

												</tr>


												


											</tbody>
											<tfoot>
											<tr>
												<td></td>
													<td><strong>TOTAL</strong></td>
													<td><input type="text" name="ttlorcamt" id="ttlorcamt"  class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"/></td>
											</tr>
										
											


												<tr>
													<th colspan="3" align="left"><button type="button" onClick="addORCRow()">Add</button><input type="hidden" name="txtOWCCount" id="txtOWCCount" value="7" /></th>
												</tr>
											</tfoot>
										</table> -->

							<div id="OWCBody" style="display: flex; flex-wrap: wrap; gap: 10px;">
								<div class="owc-item"> <a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(3); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="2000" placeholder="0.00" size="12" required />
								</div>
								<div class="owc-item">
									<a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(6); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required />
								</div>
								<div class="owc-item"><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(32); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required />
								</div>

								<div class="owc-item"><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(30); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required />
								</div>

								<div class="owc-item"><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(31); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="1000" placeholder="0.00" size="12" required />
								</div>

								<div class="owc-item"><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(12); ?>
									</select>
									<input type="text" name="txtORCAmt_1" id="txtORCAmt_1" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="5000" placeholder="0.00" size="12" required />
								</div>

								<div class="owc-item"><a href="#tb1'" onClick="removeCCForLock(1);"><i class="fa fa-times" style="color:red;"></i></a><input type="hidden" name="txtORCSlaveRandomID_2" id="txtORCSlaveRandomID_2" value="" />
									<select name="txtHidORCID_1" id="txtHidORCID_1" style="width:90px;">
										<?php $obj->getOwnerRelatedCostList(5); ?>
									</select>

									<input type="text" name="txtORCAmt_7" id="txtORCAmt_7" onKeyUp="getORCCalculate(1);" class="input-text" autocomplete="off" value="0" placeholder="0.00" size="12" required />
								</div>



								<div class="owc-item">
									<button type="button" class="btn-flat" onClick="addORCRow()">Add</button><input type="hidden" name="txtOWCCount" id="txtOWCCount" value="7" />

									<input type="text" name="ttlorcamt" id="ttlorcamt" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12" />

								</div>








								<!-- etc. -->
							</div>

							<div class="custom-heading">
								<i class="fa fa-coins"></i>
								Other Income
							</div>
							<table class='tablesorter'>
								<thead>
									<tr>
										<th width="5%"></th>
										<th width="35%">Description</th>
										<th width="20%">Amount($)</th>
										<th width="20%">Add Comm(%)</th>
										<th width="20%">Net Amount($)</th>
									</tr>
								</thead>
								<tbody id="OthInBody">
									<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>
								</tbody>
								<tfoot>
									<tr>
										<th colspan="5" align="left"><button type="button" class="btn-flat" onClick="addOtherInRow()">Add</button><input type="hidden" name="txtOthInCount" id="txtOthInCount" value="1" /></th>
									</tr>
								</tfoot>
							</table>

							<div class="custom-heading">
								<i class="fas fa-gas-pump"></i>
								Bunkers
							</div>
							<table width="100%" class='tablesorter'>
								<tbody>
									<tr>
										<td>Bunker Grade</td>
										<td>SECA(MT)</td>
										<td>NON SECA(MT)</td>


										<td>Price (SECA)</td>
										<td>Price (NON SECA)</td>
										<td>Amount($)<input type="hidden" name="txtSECAConBunkerCount" id="txtSECAConBunkerCount" value="0" /><input type="hidden" name="txtNONSECAConBunkerCount" id="txtNONSECAConBunkerCount" value="0" /></td>
									</tr>
									<!-- <tr>
													<td colspan="5"><strong>SECA</strong></td>
												</tr> -->

								</tbody>
								<tbody id="ConbunkerEstimatedTBodySECA">

								</tbody>
								<tbody>
									<tr>
										<td colspan="5"><strong>Total Bunker Consumed - SECA/NON SECA</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">

								</tbody>
								<!-- <tbody>
												<tr>
													<td colspan="4"><strong>Total Bunker Consumed - Non-SECA</strong></td>
													<td><input type="text" name="txtTotalNONSECAConsumption" id="txtTotalNONSECAConsumption" style="width:90px;" class="input-text" value="" readonly autocomplete="off" /></td>
												</tr>
											</tbody> -->
							</table>
							<table width="100%" class='tablesorter'>
								<tbody>
									<tr>
										<td> CO2 Price($/MT)</td>
										<td><input type="text" name="txtPriceCO2" style="width:90px;" id="txtCVE" class="input-text" autocomplete="off" placeholder="0.00"></td>
										<td>EUA Price($/MT)</span></td>
										<td><input type="text" name="txtEuaPrice" style="width:90px;" id="txtEuaPrice" class="input-text" autocomplete="off" value="" placeholder="0.00"></td>

									</tr>
								</tbody>
							</table>




							<div class="custom-heading">
								<i class="fa fa-handshake"></i>
								Hire
							</div>
							<table class='tablesorter'>
								<thead>
									<tr>
										<th width="35%">Hire/Day<span style="font-size:10px; font-style:italic;">($)</th>
										<th width="35%">Add Comm <span style="font-size:10px; font-style:italic;">(%)</span></th>
										<th width="20%">Brokerage<span style="font-size:10px; font-style:italic;">(%)</th>
										<th width="20%">BB($)</th>

									</tr>
								</thead>
								<tbody>
									<tr>
										<td><input type="text" name="dummyHireRate" style="width:90px;" id="dummyHireRate" onKeyUp="setCveAmtInTcDet();" class="input-text" autocomplete="off" value="" placeholder="0.00"></td>
										<td><input type="text" name="dummyAdcom" style="width:90px;" id="dummyAdcom" onKeyUp="setCveAmtInTcDet();" class="input-text" autocomplete="off" value="" placeholder="0.00"></td>
										<td><input type="text" name="dummyBrokerage" style="width:90px;" id="dummyBrokerage" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="setCveAmtInTcDet();"></td>
										<td><input type="text" name="dummyBB" style="width:90px;" id="dummyBB" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="setCveAmtInTcDet();"></td>
									</tr>
								</tbody>

							</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="setCveAmtInTcDet();" class="input-text" autocomplete="off" value="1500" placeholder="0.00"></td>
										<td>CVE <span style="font-size:10px; font-style:italic;">($)</span></td>
										<td><input type="text" name="txtCVEAmt" style="width:90px;" id="txtCVEAmt" class="input-text" autocomplete="off" value="" placeholder="0.00" readonly><input type="hidden" name="txtHidCVEAmt" style="width:90px;" id="txtHidCVEAmt" autocomplete="off" value=""></td>

									</tr>
								</tbody>
							</table>



							<!-- <div><strong style="font-size:13px;">Bunkers Consumed</strong></div> -->
							<table style="display: none;" width="100%" class='tablesorter'>
								<tr>
									<td></td>
									<td>Bunker Grade</td>
									<td>Qty(MT)</td>
									<td>Price($)</td>
									<td>Amount($)</td>
								</tr>
								<tbody id="ConbunkerTBody">
									<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>
									<script>
										$("#selConBunkerVendor_1").html($("#selVendor").html());
										$("#selConBunker_1").val(29);
									</script>
									<tr id="DivConBunkeractual_2">
										<td><a href="#tb2'" onClick="removeConBunkerRows(2);"><i class="fa fa-times" style="color:red;"></i></a></td>
										<td><select name="selConBunker_2" id="selConBunker_2" style="width:90px;" class="input-text"><?php $obj->getBunkerList(); ?></select></td>
										<td><input type="text" name="txtConBunkerQty_2" id="txtConBunkerQty_2" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="" /></td>
										<td><input type="text" name="txtConBunkerPrice_2" id="txtConBunkerPrice_2" style="width:90px;" class="input-text numeric" onKeyUp="getBunkerCalculation();" placeholder="0.00" autocomplete="off" value="" /></td>
										<td><input type="text" name="txtConBunkerAmt_2" id="txtConBunkerAmt_2" style="width:90px;" class="input-text" placeholder="0.00" readonly autocomplete="off" value="" /></td>
									</tr>
									<script>
										$("#selConBunkerVendor_2").html($("#selVendor").html());
										$("#selConBunker_2").val(23);
									</script>
								</tbody>
								<tr>
									<td colspan="5"><button type="button" onClick="addConBunkerRow()">Add</button><input type="hidden" name="txtConBunkerCount" id="txtConBunkerCount" value="2" /></td>
								</tr>
							</table>
							<div style="display:none;"><strong style="font-size:13px;">Demurrage Dispatch</strong></div>
							<table class='tablesorter' style="border-bottom:2px solid #ccc; height:40px;display:none;">
								<thead>
									<tr>
										<th width="20%"></th>
										<th width="15%">Estimated($)</th>
										<th width="15%">Actual($)</th>
										<th width="15%">Add Comm(%)</th>
										<th width="15%">Nett Value($)</th>
									</tr>
								</thead>
								<tbody id="tbDDCBody">
									<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>
								</tbody>
							</table>


							<!-- <div><strong style="font-size:13px;">Results</strong></div> -->


							<?php if ($_SESSION['selBType'] == 1 || $_SESSION['selBType'] == 3) { ?>
								<!-- <div><strong style="font-size:13px;">Comparision</strong></div> -->
								<table class='tablesorter' style="display: none;">
									<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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtBaseRateFixed" id="txtBaseRateFixed" style="width:100px;" class="input-text numeric" readonly onKeyUp="getFinalCalculation();" value="" autocomplete="off" /></td>
											<td><input type="text" name="txtBaseRateAverage" id="txtBaseRateAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtGFreightFixed" id="txtGFreightFixed" style="width:100px;" class="input-text numeric" readonly value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtGFreightAverage" id="txtGFreightAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtNFreightFixed" id="txtNFreightFixed" style="width:100px;" class="input-text numeric" readonly value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtNFreightAverage" id="txtNFreightAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtOExpensesFixed" id="txtOExpensesFixed" style="width:100px;" readonly class="input-text numeric" value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtOExpensesAverage" id="txtOExpensesAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtVEarningFixed" id="txtVEarningFixed" style="width:100px;" readonly class="input-text numeric" value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtVEarningAverage" id="txtVEarningAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtDailyEarningFixed" id="txtDailyEarningFixed" style="width:100px;<?php echo $border_textbox; ?>" class="input-text numeric" value="" <?php echo $readonlytr; ?> onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtDailyEarningAverage" id="txtDailyEarningAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtTCEMonthFixed" id="txtTCEMonthFixed" class="input-text numeric" style="width:100px; border:1px solid #F00;" value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtTCEMonthAverage" id="txtTCEMonthAverage" style="width:100px;" class="input-text" value="" 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="" autocomplete="off" /></td>
											<td><input type="text" name="txtOPExpensesFixed" id="txtOPExpensesFixed" style="width:100px;" class="input-text numeric" readonly value="" onKeyUp="getFinalCalculation();" autocomplete="off" /></td>
											<td><input type="text" name="txtOPExpensesAverage" id="txtOPExpensesAverage" style="width:100px;" class="input-text" value="" 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="" readonly autocomplete="off" /></td>
											<td><input type="text" name="txtNetDailyProfitFixed" id="txtNetDailyProfitFixed" style="width:100px;" class="input-text" onKeyUp="getFinalCalculation();" value="" autocomplete="off" /></td>
											<td><input type="text" name="txtNetDailyProfitAverage" id="txtNetDailyProfitAverage" style="width:100px;" class="input-text" value="" readonly autocomplete="off" /></td>
										</tr>
									</tbody>
								</table>
							<?php } ?>
							</td>
							<td width="40%" style="vertical-align:top;">



								<div class="custom-heading">
									<i class="fa fa-chart-line"></i>
									Results
								</div>
								<table class='tablesorter' id="" style="border-bottom:1px solid #ccc; height:30px;">
									<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 style="color:#007bff;">Nett Daily TCE</td>
											<td><input type="text" name="txtNettDailyProfit" style="width:90px;" id="txtNettDailyProfit" class="input-text" readonly placeholder="0.00" /></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> -->

											<!-- <td></td>
													<td></td> -->
										</tr>

										<tr>

											<td><span>Net Hireage</span></td>
											<td><span><input type="text" name="netHireage" id="netHireage" style="width:90px;" class="input-text" readonly placeholder="0.00" /></span></td>



											<?php if (in_array($_SESSION['uid'], $obj->getUserRightsForPl($_SESSION['uid'], 5, 18))) { ?>
												<td><span>P/L</span></td>
												<td><span><input type="text" name="txtPL" id="txtPL" style="width:90px;" class="input-text" readonly placeholder="0.00" /></span></td>
											<?php } else { ?>
												<td></td>

												<td></td>
											<?php } ?>

										</tr>
										<tr>
											<td style="color:#dc631e;"></td>
											<td></td>
											<td></td>
											<td></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($)</td>
												<td><input type="text"  name="txtGrossBreakeven" style="width:90px;" id="txtGrossBreakeven" class="input-text" readonly placeholder="0.00" /></td>
												<td>Breakeven ($/MT)</td>
												<td><input type="text"  name="txtBreakevenMT" style="width:90px;" id="txtBreakevenMT" class="input-text" readonly value="" autocomplete="off"/></td>
												</tr> -->
									</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="0" /></td>
										<td>Ballast Dist</td>
										<td>&nbsp;:&nbsp;</td>
										<td><input type="text" name="txtBDist" id="txtBDist" style="width:100px;" class="input-text" readonly value="0" /></td>
										<td>Total Dist</td>
										<td>&nbsp;:&nbsp;</td>
										<td><input type="text" name="txtTDist" id="txtTDist" class="input-text" style="width:100px;" readonly value="0" /></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="0" /></td>
										<td>Ballast Days</td>
										<td>&nbsp;:&nbsp;</td>
										<td><input type="text" name="txtBDays" id="txtBDays" style="width:100px;" class="input-text" readonly value="0" /></td>
										<td>Total Sea Days</td>
										<td>&nbsp;:&nbsp;</td>
										<td><input type="text" name="txtTSDays" id="txtTSDays" class="input-text" style="width:100px;" readonly value="0" /></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="0" /></td>
										<td>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="0" /></td>
										<td>Total Days</td>
										<td>&nbsp;:&nbsp;</td>
										<td><input type="text" name="txtTDays" id="txtTDays" class="input-text" style="width:100px;" readonly value="0" /></td>
									</tr>
									<tr class="input-text" style="display: none;">
										<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="0" /></td>
										<td>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="0" /></td>

									</tr>
								</table>


								<div class="custom-heading">
									<i class="fa fa-tint"></i>
									Bunker Results
								</div>

								<table class='tablesorter' id="" style="border-bottom:1px solid #ccc; height:30px;">
									<tbody>
										<tr>
											<td>Total HSFO (MT)</td>
											<td><input type="text" name="txtHsfo" style="width:90px;" id="txtHsfo" class="input-text" readonly value="0.00" /></td>
											<td>EU ETS/Fuel EU HSFO (MT)</td>
											<td><input type="text" name="txtEtsFuelHsfo" style="width:90px;" id="txtEtsFuelHsfo" class="input-text" readonly value="0.00" autocomplete="off" /></td>
										</tr>
										<tr>
											<td>Total VLSFO (MT)</td>
											<td><input type="text" name="txtVlfoMT" style="width:90px;" id="txtVlfoMT" class="input-text" readonly value="69.23" /></td>
											<td>EU ETS/Fuel EU VLSFO (MT)</td>
											<td><input type="text" name="txtFuelVlsfo" style="width:90px;" id="txtFuelVlsfo" class="input-text" readonly value="69.95" /></td>

										</tr>

										<tr>
											<td>Total LSMGO (MT)</td>
											<td><input type="text" name="txtLsmgo" style="width:90px;" id="txtLsmgo" class="input-text" readonly value="77.93" /></td>
											<td>EU ETS/Fuel EU LSMGO (MT)</td>
											<td><input type="text" name="txtEuEtslsmgo" style="width:90px;" id="txtEuEtslsmgo" class="input-text" readonly value="77.93" /></td>
										</tr>

										<tr>

											<td style="color:#007bff;"><span>Total Cost (USD)</span></td>
											<td><span><input type="text" name="txtCostUsd" id="txtCostUsd" style="width:90px;" class="input-text" readonly value="119,104.96" /></span></td>


										</tr>


									</tbody>
								</table>


								<div class="custom-heading">
									<i class="fa fa-balance-scale"></i>
									Compliance Results
								</div>
								<div class="ets-header">
									<i class="fa fa-leaf"></i>
									<span>EU ETS</span>
								</div>
								<table class='tablesorter' id="" style="border-bottom:1px solid #ccc; height:30px;">
									<tbody>
										<tr>
											<td>EEOI (gCO2 / tnm)</td>
											<td><input type="text" name="txtEeoi" style="width:90px;" id="txtEeoi" class="input-text" readonly value="0" /></td>
											<td>CII (gCO2 / dwtnm)</td>
											<td><input type="text" name="txtCiiGCo" style="width:90px;" id="txtCiiGCo" class="input-text" readonly value="7.41" autocomplete="off" /></td>
										</tr>
										<tr>
											<td>EEOI CO2(MT)</td>
											<td><input type="text" name="txtEeoiCo" style="width:90px;" id="txtEeoiCo" class="input-text" readonly value="470.26" /></td>


										</tr>

										<tr>
											<td> Total CO2(MT)</td>
											<td><input type="text" name="txtCo2mt" style="width:90px;" id="txtCo2mt" class="input-text" readonly value="" /></td>
											<td>Total CO2 Cost(USD)</td>
											<td><input type="text" name="txtCo2Cost" style="width:90px;" id="txtCo2Cost" class="input-text" readonly value="" /></td>
										</tr>


										<tr>
											<td>EUA CO2 2025(MT)</td>
											<td><input type="text" name="txtEuaCo2mt" style="width:90px;" id="txtEuaCo2mt" class="input-text" readonly value="" /></td>
											<td>EUA CO2 2025Cost(USD)</td>
											<td><input type="text" name="txteuaCo2Usd" style="width:90px;" id="txteuaCo2Usd" class="input-text" readonly value="" /></td>
										</tr>



										<tr>

											<td style="color: #ff4d4f ; font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="euETsAddToF" class="checkbox" id="euETsAddToF" type="checkbox" value="1" />&nbsp;&nbsp;&nbsp;&nbsp;<span>Add to freight cost</span></td>
											<td><span><input type="text" name="txtCostUsd" id="txtCostUsd" style="width:90px;" class="input-text" readonly value="0.66" /></span></td>


										</tr>


									</tbody>
								</table>


								<div class="ets-header">
									<i class="fa fa-bolt"></i>
									<span>Fuel EU</span>
								</div>
								<table class='tablesorter' id="" style="border-bottom:1px solid #ccc; height:30px;">
									<tbody>
										<tr>
											<td>HSFO GHG Intensity 2025(gCO2eq/MJ)</td>
											<td><input type="text" name="txtHsfoGhgIn" style="width:90px;" id="txtHsfoGhgIn" class="input-text" readonly value="<?php echo $bunkerGradeData['HSFO']['INTENSITY'] ?>" /></td>
											<td>Target 2025</td>
											<td><input type="text" name="txttarget2025" style="width:90px;" id="txttarget2025" class="input-text" readonly value="<?php echo $bunkerGradeData['HSFO']['GHGRATE'] ?>" autocomplete="off" /></td>
										</tr>
										<tr>
											<td>VLSFO GHG Intensity 2025(gCO2eq/MJ)</td>
											<td><input type="text" name="txtvlsoGhgIn" style="width:90px;" id="txtvlsoGhgIn" class="input-text" readonly value="<?php echo $bunkerGradeData['VLSFO']['INTENSITY'] ?>" /></td>
											<td>Target 2025</td>
											<td><input type="text" name="txttarget2025vlfo" style="width:90px;" id="txttarget2025vlfo" class="input-text" readonly value="<?php echo $bunkerGradeData['VLSFO']['GHGRATE'] ?>" autocomplete="off" /></td>

										</tr>

										<tr>
											<td>LSMGO GHG Intensity 2025(gCO2eq/MJ)</td>
											<td><input type="text" name="txtlsmgoGhgIn" style="width:90px;" id="txtlsmgoGhgIn" class="input-text" readonly value="<?php echo $bunkerGradeData['LSMGO']['INTENSITY'] ?>" /></td>
											<td>Target 2025</td>
											<td><input type="text" name="txtTarget2025lsmgo" style="width:90px;" id="txtTarget2025lsmgo" class="input-text" readonly value="<?php echo $bunkerGradeData['LSMGO']['GHGRATE'] ?>" /></td>
										</tr>


										<tr>
											<td>HSFO Penalty ($)</td>
											<td><input type="text" name="txtHsfoPenal" style="width:90px;" id="txtHsfoPenal" class="input-text" readonly value="" /></td>
											<td>$/MT</td>
											<td><input type="text" name="txtdollarPerMt" style="width:90px;" id="txtdollarPerMt" class="input-text" readonly value="<?php echo $bunkerGradeData['HSFO']['PENALITY'] ?>" /></td>
										</tr>


										<tr>
											<td> VLSFO Penalty ($)</td>
											<td><input type="text" name="txtVlsoPenal" style="width:90px;" id="txtVlsoPenal" class="input-text" readonly value="" /></td>
											<td>$/MT</td>
											<td><input type="text" name="txtdollarPerMtVlso" style="width:90px;" id="txtdollarPerMtVlso" class="input-text" readonly value="<?php echo $bunkerGradeData['VLSFO']['PENALITY'] ?>" /></td>
										</tr>


										<tr>
											<td>LSMGO Penalty ($)</td>
											<td><input type="text" name="txtLsmgoPenal" style="width:90px;" id="txtLsmgoPenal" class="input-text" readonly value="" /></td>
											<td>$/MT</td>
											<td><input type="text" name="txtdollarPerMtLsmgo" style="width:90px;" id="txtdollarPerMtLsmgo" class="input-text" readonly value="<?php echo $bunkerGradeData['LSMGO']['PENALITY'] ?>" /></td>
										</tr>



										<tr>

											<td style="color: #ff4d4f ; font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="euETsAddToF" class="checkbox" id="euETsAddToF" type="checkbox" value="1" />&nbsp;&nbsp;&nbsp;&nbsp;<span>Add to freight cost</span></td>
											<td><span><input type="text" name="txtCostUsd" id="txtCostUsd" style="width:90px;" class="input-text" readonly value="0.66" /></span></td>


										</tr>


									</tbody>
								</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($)</td>
									<td>Amount($)</td>
                                    <td>Port</td>
									<td>Vendor</td>
									</tr>
									<tbody id="bunkerTBody">
							  		<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:90px;" class="input-text"><?php $obj->getBunkerList(); ?></select></td>
									<td><input type="text" name="txtBunkerQty_1" id="txtBunkerQty_1" style="width:90px;" 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:90px;" 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:90px;" 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>
								</tbody>
								  <tr>
									<td colspan="7"><button type="button" onClick="addBunkerRow()">Add</button><input type="hidden" name="txtBunkerCount" id="txtBunkerCount" value="1"/></td>
								  </tr>
								</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 tcin" style="font-size:12px;">TC In Details</button> -->

						</div>

						<!-- <div><strong style="font-size:13px;">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> 

													<td></td>
													<td></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>

													<?php if (in_array($_SESSION['uid'], $obj->getUserRightsForPl($_SESSION['uid'], 5, 18))) { ?>
														<td><span>P/L</span></td>
														<td><span><input type="text" name="txtPL" id="txtPL" style="width:90px;" class="input-text" readonly placeholder="0.00" /></span></td>
													<?php } else { ?>
														<td></td>

														<td></td>
													<?php } ?>
												</tr>
												<tr>
													<td style="color:#dc631e;"></td>
													<td></td>
													<td></td>
													<td></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>
												
											</tbody>
										</table>  -->
						</td>
						</tr>
						</table>


					</div>
					<!-- /.tab_1-pane -->

					<!-- /.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;
											}
										});
									});
								</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>
							<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="" /></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">
								<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 date('d-m-Y', time()); ?>" /></td>
								<td>Remarks : </td>
								<td><textarea class="input-text areasize" name="txtNotes" id="txtNotes" rows="3" cols="21" placeholder="Remarks ..."></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">
								<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 date('d-m-Y', time()); ?>" /></td>
								<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 date('d-m-Y', time()); ?>" /></td>
								<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 date('d-m-Y', time()); ?>" /></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>
							</tbody>
							<tr>
								<td colspan="2"><button type="button" onClick="addUI_Row();">Add</button><input type="hidden" class="input" name="txtTID" id="txtTID" value="0" /></td>
							</tr>
						</table>
						<table width="100%" class="tablesorter">
							<tbody id="sort">
								<tr>
									<td>
										<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>
							</tbody>

						</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="button-modern" onClick="return getValidate(0);">Submit</button>
		<input type="hidden" name="action" id="action" value="submit" /><input type="hidden" name="vesselrec" id="vesselrec" class="input-text" value="" /><input type="hidden" name="txtBStatus" id="txtBStatus" 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:10px;">
						<div class="col-md-12">
							<table width="100%">
								<tr class="input-text">
									<td colspan="5"><strong>Hire Details</strong></td>
								</tr>
								<tr class="input-text">
									<!-- <td></th> -->
									<!-- <td>Hire From</td>
										 		  <td>Hire To</td> -->
									<td>Hire Days</td>
									<td>Hire/Day ($)</td>
									<td>Hire Amt ($)</td>
								</tr>
								<tbody id="hirebody">
									<tr class="input-text" id="row_hire_1">
										<!-- <td><a href="#tb1" onClick="removeHireRow(1);" ><i class="fa fa-times" style="color:red;"></i></a></td> -->
										<!-- <td valign="top"><input autocomplete="off" type="text" name="txtHireFrom_1" id="txtHireFrom_1" class="input-text" value="" style="width:120px;" placeholder="dd-mm-yyyy HH:MM" /></td> -->
										<!-- <td valign="top"><input autocomplete="off" type="text" name="txtHireTo_1" id="txtHireTo_1" class="input-text" value="" style="width:120px;" placeholder="dd-mm-yyyy HH:MM" /></td> -->
										<td valign="top"><input autocomplete="off" type="text" name="txtHireDays_1" id="txtHireDays_1" class="input-text" placeholder="Hire Days" style="width:100px;background-color:#EAEAEA;" readonly value=""></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtHireRate_1" id="txtHireRate_1" class="input-text" placeholder="Rate/Day ($)" style="width:100px;" onKeyUp="getFinalCalculation();" value=""></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtHireAmt_1" id="txtHireAmt_1" class="input-text" placeholder="Hire Amt ($)" style="width:100px;" readonly value="0.00"></td>
									</tr>

								</tbody>
								<tbody>
									<tr class="input-text">
										<!-- <td ><button type="button" onClick="AddNewHireRow();">Add Hire</button>
												<td colspan="5"></td> -->

										<input type="hidden" name="txtHIREID" id="txtHIREID" value="1" /></td>

									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="row" style="margin-top:10px;">
						<div class="col-md-2 input-text">
							<strong>Delivery</strong>
						</div>
						<div class="col-md-2">
							<textarea class="input-text areasize" name="txtTCDelivery" id="txtTCDelivery" rows="2" cols="25" placeholder="Delivery ..."></textarea>
						</div>
						<div class="col-md-2">
							<input autocomplete="off" type="text" name="txtTCDeliveryDate" id="txtTCDeliveryDate" class="input-text" value="" style="width:120px;" placeholder="dd-mm-yyyy HH:MM" />
						</div>

						<div class="col-md-2 input-text">
							<strong>Re-Delivery</strong>
						</div>
						<div class="col-md-2">
							<textarea class="input-text areasize" name="txtTCReDelivery" id="txtTCReDelivery" rows="2" cols="25" placeholder="Re-Delivery ..."></textarea>
						</div>
						<div class="col-md-2">
							<input autocomplete="off" type="text" name="txtTCReDeliveryDate" id="txtTCReDeliveryDate" class="input-text" value="" style="width:120px;" placeholder="dd-mm-yyyy HH:MM" />
						</div>
					</div>
					<div class="row" style="margin-bottom:50px;margin-top:10px;">
						<div class="col-md-4">
							<table class='tablesorter'>
								<tbody>
									<tr>
										<td>CP Date</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtTC_CPDate" style="width:90px;" id="txtTC_CPDate" class="input-text " autocomplete="off" value="" placeholder="dd-mm-yyyy" /></td>
										<td></td>
									</tr>
									<tr style="display:none;">
										<td>Daily Hire($/Day)</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtDailyVesselOperatingExpenses" style="width:90px;" id="txtDailyVesselOperatingExpenses" class="input-text" autocomplete="off" value="" 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" readonly="true" autocomplete="off" value="" placeholder="0.00" /></td>
										<td></td>
									</tr>
									<tr>
										<td>Hireage ($)</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtHireargeAmt" id="txtHireargeAmt" style="width:90px;" class="input-text" value="0.00" placeholder="0.00" readonly /></td>
										<td></td>
									</tr>
									<tr>
										<td>Ballast Bonus ($)</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtBallastBonus" id="txtBallastBonus" style="width:90px;" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="0.00" placeholder="0.00"></td>
										<td></td>
									</tr>
									<tr>
										<td>Gross Hire-age ($)</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtGrossHireargeAmt" id="txtGrossHireargeAmt" style="width:90px;" class="input-text" value="" 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="" placeholder="%" onKeyUp="getFinalCalculation();" /></td>
										<td><input type="text" name="txtHireargePercentAmt" style="width:90px;" id="txtHireargePercentAmt" class="input-text" value="" 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="" placeholder="%" onKeyUp="getFinalCalculation();" /></td>
										<td><input type="text" name="txtHireargeBroPercentAmt" style="width:90px;" id="txtHireargeBroPercentAmt" class="input-text" value="" placeholder="0.00" readonly /></td>
										<td></td>
									</tr>
									<tr>
										<td>Nett Hire-age ($)</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtNettHireargeAmt" id="txtNettHireargeAmt" style="width:90px;" class="input-text" value="" 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="" placeholder="0.00" onKeyUp="getFinalCalculation();" readonly /></td>
										<td><input type="text" name="txtHireargeCVEAMT" style="width:90px;" id="txtHireargeCVEAMT" class="input-text" value="" 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="" placeholder="0.00" onKeyUp="getFinalCalculation();" /></td>
										<td><input type="text" name="txtOffHireCVEAMT" style="width:90px;" id="txtOffHireCVEAMT" class="input-text" value="" 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="" placeholder="0.00" readonly /></td>
										<td></td>
									</tr>

									<tr>
										<td>ILOHC</td>
										<td>:</td>
										<td></td>
										<td><input type="text" name="txtIlohcForTcDet" style="width:90px;" id="txtIlohcForTcDet" class="input-text" value="0.00" 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="" 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($)</td>
													<td>Amount($)</td>
												</tr>
												<tbody id="bunkerdelivery">

													<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>
												</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="1" /></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 $/MT)</td>
													<td>Amount($)</td>
												</tr>
												<tbody id="bunkerRedelivery">
													<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>
												</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="1" /></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($)</td>
									<td>Off Hire($)</td>

								</tr>
								<tbody id="offhirebody">

									<tr class="input-text" id="row_offhire_1">
										<td><a href="#tb1" onClick="removeOffHire(1);"><i class="fa fa-times" style="color:red;"></i></a></td>
										<td valign="top"><textarea class="input-text areasize" name="txtOffHireReason_1" style="width:120px;" id="txtOffHireReason_1" rows="3" placeholder="Off Hire Reason..."></textarea></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtOffHireFrom_1" id="txtOffHireFrom_1" class="input-text" value="" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtOffHireTo_1" id="txtOffHireTo_1" class="input-text" value="" style="width:100px;" placeholder="dd-mm-yyyy HH:MM" /></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtOffHireDays_1" id="txtOffHireDays_1" class="input-text numeric" placeholder="Off Hire Days" style="width:90px;" value=""></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtOffHireRate_1" id="txtOffHireRate_1" class="input-text" placeholder="Rate/Day($)" style="width:100px;" onKeyUp="getFinalCalculation();" value=""></td>
										<td valign="top"><input autocomplete="off" type="text" name="txtOffHireAmt_1" id="txtOffHireAmt_1" class="input-text" placeholder="Off Hire($)" style="width:90px;background-color:#EAEAEA;" readonly value=""></td>
									</tr>
									<tr id="row_offhireBunker_1">
										<td></td>
										<td colspan="6">
											<table width="100%" class='tablesorter'>
												<tr>
													<td></td>
													<td>Bunker Grade</td>
													<td>Qty(MT)</td>
													<td>Price($)</td>
													<td>Amount($)</td>
													<td>On Owner's Account</td>
												</tr>
												<tbody id="TCConbunkerTBody_1">
													<tr id="DivTCConBunkeractual_1_1">
														<td><a href="#tb1'" onClick="removeTCConBunkerRows(1,1);"><i class="fa fa-times" style="color:red;"></i></a></td>
														<td><select name="selTCConBunker_1_1" id="selTCConBunker_1_1" style="width:90px;" class="input-text"><?php $obj->getBunkerList(); ?></select></td>
														<td><input type="text" name="txtTCConBunkerQty_1_1" id="txtTCConBunkerQty_1_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value="" /></td>
														<td><input type="text" name="txtTCConBunkerPrice_1_1" id="txtTCConBunkerPrice_1_1" style="width:90px;" class="input-text numeric" onKeyUp="getFinalCalculation();" placeholder="0.00" autocomplete="off" value="" /></td>
														<td><input type="text" name="txtTCConBunkerAmt_1_1" id="txtTCConBunkerAmt_1_1" style="width:90px;" class="input-text" placeholder="0.00" readonly autocomplete="off" value="" /></td>
														<td><input name="ChkOFFHireCal_1_1" class="checkbox" id="ChkOFFHireCal_1_1" type="checkbox" value="1" /></td>
													</tr>
												</tbody>
												<tr>
													<td colspan="6"><button type="button" onClick="addTCConBunkerRow(1)">Add Bunkers</button><input type="hidden" name="txtTCConBunkerCount_1" id="txtTCConBunkerCount_1" value="1" /></td>
												</tr>
											</table>
										</td>
									</tr>
								</tbody>
								<tbody>
									<tr class="input-text">
										<td><button type="button" onClick="AddNewOffHire();">Add Off-Hire</button><input type="hidden" name="txtOFFID" id="txtOFFID" value="1" /></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>





	<div class="modal fade" id="compose-modal_CalLoadable" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width:55%;">
			<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" align='center'><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;<strong>Cargo - Loadable
							Calculation</strong></h4>
				</div>

				<div class="modal-body">


					<div class="row" style="">
						<div class="col-md-6">
							<table class='' border="1px solid">
								<tbody>

									<tr align='center'>
										<td colspan="3" style="font-size: 13px;"><strong>PORT</strong></td>

									</tr>


									<tr style="font-size: 11px;">
										<td>Port</td>
										<td>:</td>

										<td><input type="text" name="txt_port_load" style="width:90px;" id="txt_port_load" class="input-text " autocomplete="off" value="" placeholder="" readonly /></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>Port Max Draft(M)</td>
										<td>:</td>

										<td><input type="text" name="txt_Port_Max_Daft" style="width:90px;" id="txt_Port_Max_Daft" class="input-text" autocomplete="off" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>Water Density(kg/Cu.M) selection</td>
										<td>:</td>
										<td> <select name="displayWaterDens" id="displayWaterDens" class="input-text" style="" onchange="setCalForCargoCalLoad()">

												<?php $obj->getWaterDensity(); ?>


											</select></td>

									</tr>
									<tr>
									<tr align='center'>
										<td colspan="3" style="font-size: 13px;"><strong>VESSEL</strong></td>
									</tr>



									<tr style="font-size: 11px;">
										<td>Vessel</td>
										<td>:</td>

										<td><input type="text" name="txt_Vessel_Loadable" id="txt_Vessel_Loadable" style="width:90px;" onKeyUp="getFinalCalculation();" class="input-text" autocomplete="off" value="" placeholder="0.00" readonly></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>Summer DWT(MT)</td>
										<td>:</td>

										<td><input type="text" name="txtSummer_DWT" id="txtSummer_DWT" style="width:90px;" class="input-text" value="" placeholder="0.00" readonly /></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>Summer Draft<span style="font-size:11px; font-style:italic;">(M)</span></td>
										<td>:</td>

										<td><input type="text" name="txtSummerDraft" style="width:90px;" id="txtSummerDraft" class="input-text" value="" placeholder="0.00" readonly /></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>TPC<span style="font-size:11px; font-style:italic;">(Ts/CM)</span></td>
										<td>:</td>

										<td><input type="text" name="txtTcP_TSCM" style="width:90px;" id="txtTcP_TSCM" class="input-text" value="" placeholder="0.00" readonly /></td>

									</tr>
									<tr style="font-size: 11px;">
										<td>Cubic Cap(Cu.M)</td>
										<td>:</td>

										<td><input type="text" name="txtCubicCap" id="txtCubicCap" style="width:90px;" class="input-text" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>
									<tr>



									<tr align='center'>
										<td colspan="3" style="font-size: 13px;"><strong>CARGO</strong></td>
									</tr>




									<tr style="font-size: 11px;">
										<td>Cargo Name</td>
										<td>:</td>

										<td><input type="text" name="txtCargoName" style="width:90px;" id="txtCargoName" class="input-text" value="" placeholder="0.00" readonly="true" /></td>

									</tr>





								</tbody>
							</table>
						</div><!-- /.col -->
						<div class="col-md-6">
							<table class='' border='1px'>

								<tbody>

									<tr align='center'>
										<td colspan="3" style="font-size: 13px;"><strong>CALCULATION SELECTION</strong></td>
									</tr>






									<tr align="center" style="font-size: 11px;">
										<td colspan='3' align="center">Via Draft&nbsp;&nbsp;<input name="checkViaDrat" class="example" id="checkViaDrat" type="radio" value="1" checked /></td>


									</tr>

									<tr style="font-size: 11px;">
										<td>Draft(M)</td>
										<td>:</td>

										<td><input type="text" name="txtDraft_m" style="width:90px;" id="txtDraft_m" class="input-text" value="" placeholder="0.00" /></td>

									</tr>



									<tr style="font-size: 11px;">
										<td>Constant(MT)</td>
										<td>:</td>

										<td><input type="text" name="txtConstant_mt" style="width:90px;" id="txtConstant_mt" class="input-text" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>


									<tr style="font-size: 11px;">
										<td>Bunkers on board(MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_bunkers_on_b_mt" style="width:90px;" id="txt_bunkers_on_b_mt" class="input-text" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>



									<tr style="font-size: 11px;">
										<td>FW(MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_FW_MT" style="width:90px;" id="txt_FW_MT" class="input-text" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>



									<tr align="center" style="font-size: 11px;">
										<td colspan='3' align="center">Via Stowage Factor&nbsp;&nbsp;<input name="checkViaDrat" class="example" id="checkViaStowage" type="radio" value="1" /></td>


									</tr>

									<tr style="font-size: 11px;">
										<td>Stowage Factor(Cu.M/MT)</td>
										<td>:</td>

										<td><input type="text" name="txtstowageDacCum" style="width:90px;" id="txtstowageDacCum" class="input-text" value="" placeholder="0.00" onKeyUp="setCalForCargoCalLoad()" /></td>

									</tr>



									<tr style="font-size: 11px;">
										<td>Stowage Factor(Cu.Ft/MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_stowage_fac_cu_ft" style="width:90px;" id="txt_stowage_fac_cu_ft" class="input-text" value="" placeholder="0.00" /></td>

									</tr>





									<tr align='center'>
										<td colspan="3" style="font-size: 13px;"><strong>CARGO-RESULTS</strong></td>
									</tr>





									<tr style="font-size: 11px;">
										<td>Observed DWT(MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_obser_DWT" style="width:90px;" id="txt_obser_DWT" class="input-text" value="" placeholder="0.00" /></td>

									</tr>

									<tr style="font-size: 11px;">
										<td>Cargo Loadable(MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_cargo_load" style="width:90px;" id="txt_cargo_load" class="input-text" value="" placeholder="0.00" /></td>

									</tr>


									<tr style="font-size: 11px;">
										<td>Observed Draft(MT)</td>
										<td>:</td>

										<td><input type="text" name="txt_oberseved_draft" style="width:90px;" id="txt_oberseved_draft" class="input-text" value="" placeholder="0.00" /></td>

									</tr>





								</tbody>



							</table>






						</div><!-- /.col -->
					</div>





				</div>

				<div class="modal-foot">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					<button type="button" class="btn btn-primary" id="savePackageChangesBtn" data-dismiss="modal" onclick="setBlQuant()">Save changes</button>
				</div>


			</div>
		</div>
	</div>





	<div class="modal fade" id="compose-modalPreviewRes" tabindex="-1" role="dialog" aria-hidden="true">
		<div class="modal-dialog" style="width:50%;">
			<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" align='center'><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;<strong>RESPONSE</strong></h4>
				</div>

				<div class="modal-body previewResponse">
				</div>

				<div class="modal-foot">
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					<!-- <button type="button" class="btn btn-primary" id="savePackageChangesBtn"  data-dismiss="modal" onclick="setBlQuant()">Save changes</button> -->
				</div>


			</div>
		</div>
	</div>



	</form>
	</aside><!-- /.right-side -->

	<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><!-- ./wrapper -->
	<?php $display->footer(); ?>
	<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
	<link href="../../css/sort.css" rel="stylesheet" type="text/css" />
	<script src='../../js/jquery.autosize.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 type="text/css" href="../../css/chosen.css" rel="stylesheet" />
	<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>
	<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>

	<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
	<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></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() {


			// $('#checkViaDrat').prop('checked', true);
			// $('#checkViaDrat').iCheck('check'); 

			$("#selCName").click(function() {
				const selectedData = $("#selCName option:selected").map(function() {
					return {
						value: $(this).val(), // Get the value
						text: $(this).text() // Get the text
					};
				}).get(); // Convert to an array of objects

				// Format the selected data for display
				const displayData = selectedData.map(item => `Value: ${item.value}, Text: ${item.text}`).join("\n");
				alert("Selected Data:\n" + displayData);
			});


			$('#txtCVE').keyup(function(e) {
				complianceCalculation(); // legacy
			});

			$('#txtEuaPrice').keyup(function(e) {
				complianceCalculation(); // legacy
			});


			getORCCalculate();
			setIlhocForTcDet();
			setCveAmtInTcDet();
			$("#selShipperCP,#selChartererCP,#selOwnerCP,#selReceiverCP").html($("#selVendor").html());
			$('#txtDistributedRemarks').autosize({
				append: "\n"
			});
			$('.numeric').numeric();
			$("#selCName,#selMType").chosen();
			if (<?= $_REQUEST['estimatetype']; ?> != 2) {
				$("#frm1").validate({
					onclick: false,
					rules: {

						selBusinessType: "required",
						txtENo: "required",
						selVName: "required",
						chartering_pic: "required",
						chartering_pic_1: "required",
						txtVNo: "required",




						txtBLCQMT: {
							required: function(element) {
								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : $('#selBusinessType').val() == '2';
							}
						},


						txtMTCPDRate: {
							required: function(element) {
								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : $('#selBusinessType').val() == '2';
							}
						},

						txtMLumpsum: {
							required: function(element) {
								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : $('#selBusinessType').val() == '2';
							}
						},

						selFPort_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},



						selPType_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},


						selSSpeed_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;
							}
						},


						txtDistance_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},






						selDelBunker_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						selReDelBunker_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},


						txtDelQty_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtDelBunDate_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtDelPrice_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelQty_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelBunDate_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelPrice_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},


					},

					messages: {
						selVName: "*",

					},

					submitHandler: function(form) {

						$.post("options.php?id=149", {
							Vno: "" + $('#txtVNo').val() + ""
						}, function(data) {

							if (data == 1) {

								jAlert('Voyage number already exists', 'Alert');

								return false;


							} else {



								jConfirm('Are you sure you have checked each entry ?', 'Confirmation', function(r) {
									if (r) {
										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;
									}
								});




							}


						});



					}
				});
			} else {
				$("#frm1").validate({
					onclick: false,
					rules: {

						selBusinessType: "required",
						txtENo: "required",
						selVName: "required",
						chartering_pic: "required",
						chartering_pic_1: "required",
						txtVNo: "required",


						selFPort_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},



						selPType_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},


						selSSpeed_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;
							}
						},


						txtDistance_1: {
							required: function(element) {

								return $('#selBusinessType').val() == '1' ? true : $('#selBusinessType').val() == '3' ? true : false;

							}
						},






						selDelBunker_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						selReDelBunker_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},


						txtDelQty_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtDelBunDate_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtDelPrice_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelQty_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelBunDate_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtReDelPrice_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},

						txtHireRate_1: {
							required: function(element) {
								return $('#selBusinessType').val() == '1';
							}
						},
					},

					messages: {
						selVName: "*",

					},

					submitHandler: function(form) {

						$.post("options.php?id=149", {
							Vno: "" + $('#txtVNo').val() + ""
						}, function(data) {

							if (data == 1) {

								jAlert('Voyage number already exists', 'Alert');

								return false;


							} else {



								jConfirm('Are you sure you have checked each entry ?', 'Confirmation', function(r) {
									if (r) {
										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;
									}
								});




							}


						});



					}
				});




			}

			$("[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,#txtDWTT,#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,#txtBalticRate,#txtAdnlPrenium,#txtGasCQMT,#txtGASLumpsum,#txtFixedDiff,[id^=txtLPADDComm_],[id^=txtDPADDComm_],[id^=txtOtherAmt_],[id^=txtOtherAddComm_]").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,#txtHireargeBroPercent, #txtBLCQMT, #txtLessPerQty").numeric();
			$("#txtDate,#txtCPDate,#txtETADate,#txtLaycanSDate,#txtLaycanEDate,[id^=txtDelBunDate_],[id^=txtReDelBunDate_],#txtTC_CPDate").datepicker({
				format: 'dd-mm-yyyy',
				autoclose: true
			});

			$('[id^=txtOffHireFrom_],[id^=txtOffHireTo_],#txtTCDeliveryDate,#txtTCReDeliveryDate,[id^=txtHireFrom_],[id^=txtHireTo_]').datetimepicker({
				format: 'dd-mm-yyyy hh:ii',
				autoclose: true,
				todayBtn: true,
				minuteStep: 1
			}).on('changeDate', function() {
				getFinalCalculation();
			});


			$('[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();
			});


			$('#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];
			}

			<?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 } ?>
			showCapField(1);
			showHideEstimateTypeDiv(1);
			showHideQtyVendorDiv(<?= $rdoQtyType; ?>);
			showHideTankQtyVendorDiv(<?= $rdoTankQtyType; ?>);
			var i = 1;
			$("[id^=myonoffswitch_]").each(function() {
				document.getElementById("myonoffswitch_" + i).setAttribute("type", "checkbox");
				i++;
			});
			$(".sidebar-toggle").click();
			loadPeriodDetails();
		});

		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();
				}
			}
		}


		// $('#selCName').on('change', function(evt, params) {
		// 	var selectedValue = params.params;
		// 	console.log(selectedValue);
		// });

		$("#get-selected-texts").change(function() {
			const selectedTexts = $("#selCName option:selected").map(function() {
				return $(this).text(); // Get the text of each selected option
			}).get(); // Convert to a plain array
			alert("Selected texts: " + selectedTexts.join(", "));
		});



		$("#selCName").click(function() {
			const selectedData = $("#selCName option:selected").map(function() {
				return {
					value: $(this).val(), // Get the value
					text: $(this).text() // Get the text
				};
			}).get(); // Convert to an array of objects

			// Format the selected data for display
			const displayData = selectedData.map(item => `Value: ${item.value}, Text: ${item.text}`).join("\n");
			alert("Selected Data:\n" + displayData);
		});




		function getMaterialCode() {

			const $targetSelect = $('.targetSelect');
			$targetSelect.empty();
			const selectedData = $("#selCName option:selected").map(function() {
				return {
					value: $(this).val(),
					text: $(this).text()
				};
			}).get();

			$targetSelect.append(`<option value="">---Select from chosen cargos'---</option>`);

			$targetSelect.append(selectedData.map(item => `<option value="${item.value}">${item.text}</option>`));

		}

		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() + "",
					shipType: $('#shipTypeFromApi').val(),
					dwtFromApi: $('#dwtFromApi').val(),
				}, function(data) {

					var vsldata = JSON.parse(data);

					// $('.previewResponse').html(JSON.stringify(vsldata['com_data'][0]['data_array'],null,'\t'));

					// $('#compose-modalPreviewRes').modal('show'); 

					$.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['cubicCap']);
							$('#txtBCap').val(array['bale']);
							$('#txt_Vessel_Loadable').val(array['Vesselname']);
							$('#txtSummer_DWT1').val(array['dwtsum']);
							$('#txtSummer_DWT').val(array['dwtsum']);
							$('#txtSummerDraft').val(array['SDraftM']);
							$('#txt_Port_Max_Daft').val(array['SDraftM']);
							$('#txtTcP_TSCM').val(array['TPCMT']);
							$('#txtCubicCap').val(array['cubicCap']);
							$('#txt_obser_DWT').val(array['dwtsum']);

							$('#txtBFullSpeed').val(array['bfs']);
							$('#txtBEcoSpeed1').val(array['bes1']);
							$('#txtBEcoSpeed2').val(array['bes2']);

							// txtTcP_TSCM
							$('#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['TPCMT']);

							$('#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']);



							setCalForCargoCalLoad();
						}
						$("#tbodyDOAtSea,#tbodyFOAtSea,#tbodyFOInPort,#tbodyDOInPort,#ConbunkerEstimatedTBodySECA,#ConbunkerEstimatedTBodyNONSECA,#tbodyFOInPort,#tbodyDOInPort").empty();
						$("#txtFOAtSeaID,#txtSECAConBunkerCount,#txtNONSECAConBunkerCount,#txtDOAtSeaID,#txtFOInPortID,#txtDOInPortID").val(0);


						const obj1 = array['laden_balast_consp'];
						const obj2 = array['working_idle_consp'];

						const conspdata = obj1.map(item1 => {
							const match = obj2.find(item2 => item2.BUNKERID === item1.BUNKERID);
							return {
								...item1,
								...(match || {})
							};
						});

						$.each(conspdata, function(index1, array1) {
							var id = $("#txtFOAtSeaID").val();
							if (array1['IDENTIFY'] == "FO") {
								id = (id - 1) + 2;
								$('<tr id="FOAtSeaRow_' + id + '"><td align="right" class=""><input type="hidden" name="txtFOAtSeaBunker_' + id + '" id="txtFOAtSeaBunker_' + id + '" value="' + array1['BUNKERID'] + '"/>' + array1['BUNKER_NAME'] + '</td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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"  placeholder="0.00" autocomplete="off" value="" readonly></td><td><input type="hidden" name="txtNONSECABunkerid_' + idd + '" id="txtNONSECABunkerid_' + idd + '" value="' + array1['BUNKERID'] + '"/><input type="hidden" name="txtNONSECAIdentify_' + idd + '" id="txtNONSECAIdentify_' + idd + '" value="FO"/><input type="text" name="txtNONSECABunkerQty_' + idd + '" id="txtNONSECABunkerQty_' + idd + '" style="width:90px;" class="input-text numeric"  placeholder="0.00" autocomplete="off" value="" readonly></td><td><input type="text" name="txtSECABunkerPrice_' + idd + '" id="txtSECABunkerPrice_' + idd + '" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation(); getVoyageTime();" placeholder="0.00" autocomplete="off" value="0.00"></td><td><input type="text" name="txtSECABunkerPriceNonSeca_' + idd + '" id="txtSECABunkerPriceNonSeca_' + idd + '" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation(); getVoyageTime();" 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" ="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"  placeholder="0.00" autocomplete="off" value="" readonly></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(); getVoyageTime();" 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" ="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" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-full-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-service-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></td><td align="right" class="consumption-eco-speed"><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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></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"  placeholder="0.00" autocomplete="off" value="" readonly></td><td><input type="hidden" name="txtNONSECABunkerid_' + idd + '" id="txtNONSECABunkerid_' + idd + '" value="' + array1['BUNKERID'] + '"/><input type="hidden" name="txtNONSECAIdentify_' + idd + '" id="txtNONSECAIdentify_' + idd + '" value="DO"/><input type="text" name="txtNONSECABunkerQty_' + idd + '" id="txtNONSECABunkerQty_' + idd + '" style="width:90px;" class="input-text numeric"  placeholder="0.00" autocomplete="off" value="" readonly></td><td><input type="text" name="txtSECABunkerPrice_' + idd + '" id="txtSECABunkerPrice_' + idd + '" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation(); getVoyageTime();" placeholder="0.00" autocomplete="off" value="0.00"></td><td><input type="text" name="txtSECABunkerPriceNonSeca_' + idd + '" id="txtSECABunkerPriceNonSeca_' + idd + '" style="width:90px;" class="input-text numeric" onkeyup="getBunkerCalculation(); getVoyageTime();" 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"  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"  placeholder="0.00" autocomplete="off" value="" readonly></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(); getVoyageTime();" 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"  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();
							});

						});

						<?php if ($_SESSION['selBType'] == 1 || $_SESSION['selBType'] == 3) { ?>
							var conspdata1 = array['working_idle_consp'];
							$.each(conspdata1, function(index1, array1) {
								var id = $("#txtFOInPortID").val();
								if (array1['IDENTIFY'] == "FO") {
									id = (id - 1) + 2;

									$('<input type="hidden" name="selFOInPortBunker_' + id + '" id="selFOInPortBunker_' + id + '" value="' + array1['BUNKERID'] + '"/>').appendTo("#tbodyFOInPort");


									// <input type="hidden" name="selFOInPortBunker_' + id + '" id="selFOInPortBunker_' + id + '" value="' + array1['BUNKERID'] + '"/>
									// $('<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="txtFOInPortSECAConspOther_' + id + '" id="txtFOInPortSECAConspOther_' + id + '" class="input-text autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_OTHER'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();" /></td></tr>').appendTo("#tbodyFOInPort");
									$("#txtFOInPortID").val(id);
								}

								var id = $("#txtDOInPortID").val();
								if (array1['IDENTIFY'] == "DO") {
									id = (id - 1) + 2;
									// <input type="hidden" name="selDOInPortBunker_' + id + '" id="selDOInPortBunker_' + id + '" value="' + array1['BUNKERID'] + '"/>

									$('<input type="hidden" name="selDOInPortBunker_' + id + '" id="selDOInPortBunker_' + id + '" value="' + array1['BUNKERID'] + '"/>').appendTo("#tbodyDOInPort");


									// $('<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="txtDOInPortSECAConspOther_' + id + '" id="txtDOInPortSECAConspOther_' + id + '" class="input-text autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_OTHER'] + '" onKeyUp="getVoyageTime();"/></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'] + '" onKeyUp="getVoyageTime();"/></td></tr>').appendTo("#tbodyDOInPort");
									$("#txtDOInPortID").val(id);
								}
							});
						<?php } else { ?>
							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'] + '"><span id="fo_bunkerLevel_' + id + '">' + array1['BUNKER_NAME'] + '</span></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortSECAConspIdleBallast_' + id + '" id="txtFOInPortSECAConspIdleBallast_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_IDLE_BALLAST'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortNONSECAConspIdleBallast_' + id + '" id="txtFOInPortNONSECAConspIdleBallast_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_IDLE_BALLAST'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortSECAConspIdleLaden_' + id + '" id="txtFOInPortSECAConspIdleLaden_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_IDLE_LADEN'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortNONSECAConspIdleLaden_' + id + '" id="txtFOInPortNONSECAConspIdleLaden_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_IDLE_LADEN'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortSECAConspWorkingLP_' + id + '" id="txtFOInPortSECAConspWorkingLP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_WORKING_LP'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortNONSECAConspWorkingLP_' + id + '" id="txtFOInPortNONSECAConspWorkingLP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_WORKING_LP'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOInPortSECAConspWorkingDP_' + id + '" id="txtFOInPortSECAConspWorkingDP_' + id + '" class="input-text"  autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_WORKING_DP'] + '"/></td><td align="right"><input type="text" style="width:80px;" name="txtFOInPortNONSECAConspWorkingDP_' + id + '"  id="txtFOInPortNONSECAConspWorkingDP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_WORKING_DP'] + '"/></td></tr>').appendTo("#tbodyFOInPort");

									$('<tr id="FOOthersRow_' + id + '"><td align="right"><input type="hidden" name="selFOOtherBunker_' + id + '" id="selFOOtherBunker_' + id + '" value="' + array1['BUNKERID'] + '"><span id="fo_otherbunkerLevel_' + id + '">' + array1['BUNKER_NAME'] + '</span></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherSECAConspTK_' + id + '" id="txtFOOtherSECAConspTK_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_TK'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherNONSECAConspTK_' + id + '" id="txtFOOtherNONSECAConspTK_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_TK'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherSECAConspInert_' + id + '" id="txtFOOtherSECAConspInert_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_INERT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherNONSECAConspInert_' + id + '" id="txtFOOtherNONSECAConspInert_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_INERT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherSECAConspGF_' + id + '" id="txtFOOtherSECAConspGF_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_GF'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherNONSECAConspGF_' + id + '" id="txtFOOtherNONSECAConspGF_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_GF'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherSECAConspHeat_' + id + '" id="txtFOOtherSECAConspHeat_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_HEAT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherNONSECAConspHeat_' + id + '" id="txtFOOtherNONSECAConspHeat_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_HEAT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherSECAConspHeat1_' + id + '" id="txtFOOtherSECAConspHeat1_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_HEAT_1'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtFOOtherNONSECAConspHeat1_' + id + '" id="txtFOOtherNONSECAConspHeat1_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_HEAT_1'] + '"/></td></tr>').appendTo("#tbodyFOOthers");

									$("#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'] + '"><span id="do_bunkerLevel_' + id + '">' + array1['BUNKER_NAME'] + '</span></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortSECAConspIdleBallast_' + id + '" id="txtDOInPortSECAConspIdleBallast_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_IDLE_BALLAST'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortNONSECAConspIdleBallast_' + id + '" id="txtDOInPortNONSECAConspIdleBallast_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_IDLE_BALLAST'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortSECAConspIdleLaden_' + id + '" id="txtDOInPortSECAConspIdleLaden_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_IDLE_LADEN'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortNONSECAConspIdleLaden_' + id + '" id="txtDOInPortNONSECAConspIdleLaden_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_IDLE_LADEN'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortSECAConspWorkingLP_' + id + '" id="txtDOInPortSECAConspWorkingLP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_WORKING_LP'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortNONSECAConspWorkingLP_' + id + '" id="txtDOInPortNONSECAConspWorkingLP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_WORKING_LP'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOInPortSECAConspWorkingDP_' + id + '" id="txtDOInPortSECAConspWorkingDP_' + id + '" class="input-text"  autocomplete="off" value="' + array1['FO_INPORT_SECA_CONSP_WORKING_DP'] + '"/></td><td align="right"><input type="text" style="width:80px;" name="txtDOInPortNONSECAConspWorkingDP_' + id + '"  id="txtDOInPortNONSECAConspWorkingDP_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_INPORT_NONSECA_CONSP_WORKING_DP'] + '"/></td></tr>').appendTo("#tbodyDOInPort");

									$('<tr id="DOOthersRow_' + id + '"><td align="right"><input type="hidden" name="selDOOtherBunker_' + id + '" id="selDOOtherBunker_' + id + '" value="' + array1['BUNKERID'] + '"><span id="do_otherbunkerLevel_' + id + '">' + array1['BUNKER_NAME'] + '</span></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherSECAConspTK_' + id + '" id="txtDOOtherSECAConspTK_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_TK'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherNONSECAConspTK_' + id + '" id="txtDOOtherNONSECAConspTK_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_TK'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherSECAConspInert_' + id + '" id="txtDOOtherSECAConspInert_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_INERT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherNONSECAConspInert_' + id + '" id="txtDOOtherNONSECAConspInert_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_INERT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherSECAConspGF_' + id + '" id="txtDOOtherSECAConspGF_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_GF'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherNONSECAConspGF_' + id + '" id="txtDOOtherNONSECAConspGF_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_GF'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherSECAConspHeat_' + id + '" id="txtDOOtherSECAConspHeat_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_HEAT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherNONSECAConspHeat_' + id + '" id="txtDOOtherNONSECAConspHeat_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_HEAT'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherSECAConspHeat1_' + id + '" id="txtDOOtherSECAConspHeat1_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_SECA_CONSP_HEAT_1'] + '"/></td><td align="right"><input type="text"  style="width:80px;" name="txtDOOtherNONSECAConspHeat1_' + id + '" id="txtDOOtherNONSECAConspHeat1_' + id + '" class="input-text" autocomplete="off" value="' + array1['FO_OTHER_NONSECA_CONSP_HEAT_1'] + '"/></td></tr>').appendTo("#tbodyDOOthers");

									$("#txtDOInPortID").val(id);
								}
							});
						<?php } ?>
						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, #txtSDWTMT, #txtSDWTLT, #txtSDraftM, #txtSDraftFT, #txtTPIMT, #txtTPILT, #txtTPCMT, #txtTPCLT, #txtConstantsMT, #txtConstantsLT, #txtGrainCapCBM, #txtGrainCapCFT').val("");
				$("#tbodyDOAtSea,#tbodyFOAtSea,#tbodyFOInPort,#tbodyDOInPort,#ConbunkerEstimatedTBodySECA,#ConbunkerEstimatedTBodyNONSECA,#tbodyFOInPort,#tbodyDOInPort").empty();
				$("#txtFOAtSeaID,#txtSECAConBunkerCount,#txtNONSECAConBunkerCount,#txtDOAtSeaID,#txtFOInPortID,#txtDOInPortID").val(0);
				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();
				var txtNONSECABunkerQty = $("#txtNONSECABunkerQty_" + i).val();
				var txtSECABunkerPriceNonSeca = $("#txtSECABunkerPriceNonSeca_" + i).val();
				if (txtNONSECABunkerQty == '') {
					txtNONSECABunkerQty = 0;
				}
				if (txtSECABunkerPriceNonSeca == '') {
					txtSECABunkerPriceNonSeca = 0;
				}


				// console.log('txtSECABunkerQty', txtSECABunkerQty)
				// console.log('txtSECABunkerPrice', txtSECABunkerPrice)
				// console.log('txtNONSECABunkerQty', txtNONSECABunkerQty)
				// console.log('txtSECABunkerPriceNonSeca', txtSECABunkerPriceNonSeca)

				var calc = parseFloat(txtSECABunkerQty * txtSECABunkerPrice) + parseFloat(txtNONSECABunkerQty * txtSECABunkerPriceNonSeca);
				// console.log('chev',calc)
				if (isNaN(calc)) {
					calc = 0;
				}
				$("#txtSECABunkerAmt_" + i).val(calc.toFixed(2));
			}
			$("#txtTotalSECAConsumption").val($("[id^=txtSECABunkerAmt_]").sum().toFixed(2));

			$("#txtCostUsd").val($("#txtTotalSECAConsumption").val());

			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 ballastTotal = 0;

			// console.log('check',id)
			var LadenTotal = 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 ($("#selPType_" + i).val() == 1) {


					ballastTotal = parseFloat($("#txtDistance_" + i).val()) + parseFloat(ballastTotal);

				}


				if ($("#selPType_" + i).val() == 2) {




					LadenTotal = parseFloat($("#txtDistance_" + i).val()) + parseFloat(LadenTotal);

				}




				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(parseFloat(ballastTotal).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(parseFloat(LadenTotal).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));

			$("#txtHireDays_1").val($("#txtTSDays,#txtTtPIDays,#txtTtPWDays").sum().toFixed(2));


			var txtSECAConBunkerCount = $("#txtSECAConBunkerCount").val();
			for (var i = 1; i <= parseInt(txtSECAConBunkerCount); i++) {
				var totalconspfo = 0;
				var 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);
							}
						}
					}

					console.log('chewck1', totalconspfo);

					var txtFOInPortID = $("#txtFOInPortID").val();
					for (var j = 1; j <= parseInt(txtFOInPortID); 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 foconspworkingtanker = $("#txtFOInPortSECAConspWorkingLP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var foconsp1 = parseFloat(txtWDays) * parseFloat(foconspworking);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									var foconsp2 = parseFloat(txtIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp2)) {
										foconsp2 = 0;
									}
									var foconsp3 = parseFloat(txtWDays) * parseFloat(foconspworkingtanker);
									if (isNaN(foconsp3)) {
										foconsp3 = 0;
									}
									var foconsp4 = parseFloat(txtIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp4)) {
										foconsp4 = 0;
									}

									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2) + parseFloat(foconsp3) + parseFloat(foconsp4);
								}
								console.log('chewck2', totalconspfo);

								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 foconspworkingtanker = $("#txtFOInPortSECAConspWorkingDP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var foconsp1 = parseFloat(txtDWDays) * parseFloat(foconspworking);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									var foconsp2 = parseFloat(txtDIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp2)) {
										foconsp2 = 0;
									}
									var foconsp3 = parseFloat(txtDWDays) * parseFloat(foconspworkingtanker);
									if (isNaN(foconsp3)) {
										foconsp3 = 0;
									}
									var foconsp4 = parseFloat(txtDIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp4)) {
										foconsp4 = 0;
									}

									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2) + parseFloat(foconsp3) + parseFloat(foconsp4);
								}
								console.log('chewck3', totalconspfo);
								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;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									var foconsp = parseFloat(txtDIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp)) {
										foconsp = 0;
									}
									var foconsp1 = parseFloat(txtDIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp) + parseFloat(foconsp1);
								}
							}
							console.log('chewck4', totalconspfo);
							var txtTKSECAHrs = parseFloat($("#txtTKSECAHrs").val());
							if (isNaN(txtTKSECAHrs)) {
								txtTKSECAHrs = 0;
							}
							var txtTKSECAHrs_1 = parseFloat(txtTKSECAHrs) / 24;
							var txtFOOtherSECAConspTK = parseFloat($("#txtFOOtherSECAConspTK_" + j).val());
							if (isNaN(txtFOOtherSECAConspTK)) {
								txtFOOtherSECAConspTK = 0;
							}
							var tkconsp = parseFloat(txtTKSECAHrs_1) * parseFloat(txtFOOtherSECAConspTK);
							if (isNaN(tkconsp)) {
								tkconsp = 0;
							}

							var txtInertSECAHrs = parseFloat($("#txtInertSECAHrs").val());
							if (isNaN(txtInertSECAHrs)) {
								txtInertSECAHrs = 0;
							}
							var txtInertSECAHrs_1 = parseFloat(txtInertSECAHrs) / 24;
							var txtFOOtherSECAConspInert = parseFloat($("#txtFOOtherSECAConspInert_" + j).val());
							if (isNaN(txtFOOtherSECAConspInert)) {
								txtFOOtherSECAConspInert = 0;
							}
							var inertconsp = parseFloat(txtInertSECAHrs_1) * parseFloat(txtFOOtherSECAConspInert);
							if (isNaN(inertconsp)) {
								inertconsp = 0;
							}

							var txtGFSECAHrs = parseFloat($("#txtGFSECAHrs").val());
							if (isNaN(txtGFSECAHrs)) {
								txtGFSECAHrs = 0;
							}
							var txtGFSECAHrs_1 = parseFloat(txtGFSECAHrs) / 24;
							var txtFOOtherSECAConspGF = parseFloat($("#txtFOOtherSECAConspGF_" + j).val());
							if (isNaN(txtFOOtherSECAConspGF)) {
								txtFOOtherSECAConspGF = 0;
							}
							var GFconsp = parseFloat(txtGFSECAHrs_1) * parseFloat(txtFOOtherSECAConspGF);
							if (isNaN(GFconsp)) {
								GFconsp = 0;
							}

							var txtHeatSECAHrs = parseFloat($("#txtHeatSECAHrs").val());
							if (isNaN(txtHeatSECAHrs)) {
								txtHeatSECAHrs = 0;
							}
							var txtHeatSECAHrs_1 = parseFloat(txtHeatSECAHrs) / 24;
							var txtFOOtherSECAConspHeat = parseFloat($("#txtFOOtherSECAConspHeat_" + j).val());
							if (isNaN(txtFOOtherSECAConspHeat)) {
								txtFOOtherSECAConspHeat = 0;
							}
							var heatconsp = parseFloat(txtHeatSECAHrs_1) * parseFloat(txtFOOtherSECAConspHeat);
							if (isNaN(heatconsp)) {
								heatconsp = 0;
							}

							var txtHeatSECAHrs1 = parseFloat($("#txtHeatSECAHrs1").val());
							if (isNaN(txtHeatSECAHrs1)) {
								txtHeatSECAHrs1 = 0;
							}
							var txtHeatSECAHrs1_1 = parseFloat(txtHeatSECAHrs1) / 24;
							var txtFOOtherSECAConspHeat1 = parseFloat($("#txtFOOtherSECAConspHeat1_" + j).val());
							if (isNaN(txtFOOtherSECAConspHeat1)) {
								txtFOOtherSECAConspHeat1 = 0;
							}
							var heatconsp1 = parseFloat(txtHeatSECAHrs1_1) * parseFloat(txtFOOtherSECAConspHeat1);
							if (isNaN(heatconsp1)) {
								heatconsp1 = 0;
							}

							totalconspfo = parseFloat(totalconspfo) + parseFloat(tkconsp) + parseFloat(inertconsp) + parseFloat(GFconsp) + parseFloat(heatconsp) + parseFloat(heatconsp1);
						}
					}
					$("#txtSECABunkerQty_" + i).val(totalconspfo.toFixed(2));

					if ($('#txtSECABunkerid_' + i).val() == 29) {
						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtVlfoMT').val(parseFloat(totalconspfo).toFixed(2));
						} else {
							$('#txtVlfoMT').val('0.00');
						}

					} else if ($('#txtSECABunkerid_' + i).val() == 11) {
						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtHsfo').val(parseFloat(totalconspfo).toFixed(2));
						} else {
							$('#txtHsfo').val('0.00');
						}
					}




				}

				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 doconspworkingtanker = $("#txtDOInPortSECAConspWorkingLP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var doconsp1 = parseFloat(txtWDays) * parseFloat(doconspworking);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									var doconsp2 = parseFloat(txtIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp2)) {
										doconsp2 = 0;
									}
									var doconsp3 = parseFloat(txtWDays) * parseFloat(doconspworkingtanker);
									if (isNaN(doconsp3)) {
										doconsp3 = 0;
									}
									var doconsp4 = parseFloat(txtIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp4)) {
										doconsp4 = 0;
									}
									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2) + parseFloat(doconsp3) + parseFloat(doconsp4);
								}

								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 doconspworkingtanker = $("#txtDOInPortSECAConspWorkingDP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var doconsp1 = parseFloat(txtDWDays) * parseFloat(doconspworking);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									var doconsp2 = parseFloat(txtDIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp2)) {
										doconsp2 = 0;
									}
									var doconsp3 = parseFloat(txtDWDays) * parseFloat(doconspworkingtanker);
									if (isNaN(doconsp3)) {
										doconsp3 = 0;
									}
									var doconsp4 = parseFloat(txtDIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp4)) {
										doconsp4 = 0;
									}
									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2) + parseFloat(doconsp3) + parseFloat(doconsp4);
								}

								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;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									var doconsp = parseFloat(txtDIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp)) {
										doconsp = 0;
									}
									var doconsp1 = parseFloat(txtDIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp) + parseFloat(doconsp1);
								}
							}

							var txtTKSECAHrs = parseFloat($("#txtTKSECAHrs").val());
							if (isNaN(txtTKSECAHrs)) {
								txtTKSECAHrs = 0;
							}
							var txtTKSECAHrs_1 = parseFloat(txtTKSECAHrs) / 24;
							var txtDOOtherSECAConspTK = parseFloat($("#txtDOOtherSECAConspTK_" + j).val());
							if (isNaN(txtDOOtherSECAConspTK)) {
								txtDOOtherSECAConspTK = 0;
							}
							var tkconsp = parseFloat(txtTKSECAHrs_1) * parseFloat(txtDOOtherSECAConspTK);
							if (isNaN(tkconsp)) {
								tkconsp = 0;
							}

							var txtInertSECAHrs = parseFloat($("#txtInertSECAHrs").val());
							if (isNaN(txtInertSECAHrs)) {
								txtInertSECAHrs = 0;
							}
							var txtInertSECAHrs_1 = parseFloat(txtInertSECAHrs) / 24;
							var txtDOOtherSECAConspInert = parseFloat($("#txtDOOtherSECAConspInert_" + j).val());
							if (isNaN(txtDOOtherSECAConspInert)) {
								txtDOOtherSECAConspInert = 0;
							}
							var inertconsp = parseFloat(txtInertSECAHrs_1) * parseFloat(txtDOOtherSECAConspInert);
							if (isNaN(inertconsp)) {
								inertconsp = 0;
							}

							var txtGFSECAHrs = parseFloat($("#txtGFSECAHrs").val());
							if (isNaN(txtGFSECAHrs)) {
								txtGFSECAHrs = 0;
							}
							var txtGFSECAHrs_1 = parseFloat(txtGFSECAHrs) / 24;
							var txtDOOtherSECAConspGF = parseFloat($("#txtDOOtherSECAConspGF_" + j).val());
							if (isNaN(txtDOOtherSECAConspGF)) {
								txtDOOtherSECAConspGF = 0;
							}
							var GFconsp = parseFloat(txtGFSECAHrs_1) * parseFloat(txtDOOtherSECAConspGF);
							if (isNaN(GFconsp)) {
								GFconsp = 0;
							}

							var txtHeatSECAHrs = parseFloat($("#txtHeatSECAHrs").val());
							if (isNaN(txtHeatSECAHrs)) {
								txtHeatSECAHrs = 0;
							}
							var txtHeatSECAHrs_1 = parseFloat(txtHeatSECAHrs) / 24;
							var txtDOOtherSECAConspHeat = parseFloat($("#txtDOOtherSECAConspHeat_" + j).val());
							if (isNaN(txtDOOtherSECAConspHeat)) {
								txtDOOtherSECAConspHeat = 0;
							}
							var heatconsp = parseFloat(txtHeatSECAHrs_1) * parseFloat(txtDOOtherSECAConspHeat);
							if (isNaN(heatconsp)) {
								heatconsp = 0;
							}

							var txtHeatSECAHrs1 = parseFloat($("#txtHeatSECAHrs1").val());
							if (isNaN(txtHeatSECAHrs1)) {
								txtHeatSECAHrs1 = 0;
							}
							var txtHeatSECAHrs1_1 = parseFloat(txtHeatSECAHrs1) / 24;
							var txtDOOtherSECAConspHeat1 = parseFloat($("#txtDOOtherSECAConspHeat1_" + j).val());
							if (isNaN(txtDOOtherSECAConspHeat1)) {
								txtDOOtherSECAConspHeat1 = 0;
							}
							var heatconsp1 = parseFloat(txtHeatSECAHrs1_1) * parseFloat(txtDOOtherSECAConspHeat1);
							if (isNaN(heatconsp1)) {
								heatconsp1 = 0;
							}

							totalconspdo = parseFloat(totalconspdo) + parseFloat(tkconsp) + parseFloat(inertconsp) + parseFloat(GFconsp) + parseFloat(heatconsp) + parseFloat(heatconsp1);
						}
					}


					$("#txtSECABunkerQty_" + i).val(totalconspdo.toFixed(2));

					if ($('#txtSECABunkerid_' + i).val() == 23) {
						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtLsmgo').val(parseFloat(totalconspdo).toFixed(2));
						} else {
							$('#txtLsmgo').val('0.00');
						}
					}







				}
			}


			var txtNONSECAConBunkerCount = $("#txtNONSECAConBunkerCount").val();
			for (var i = 1; i <= parseInt(txtNONSECAConBunkerCount); i++) {
				var totalconspfo = 0;
				var 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);
								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(txtFOInPortID); j++) {
						if ($("#selFOInPortBunker_" + j).val() == $("#txtNONSECABunkerid_" + 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 = $("#txtFOInPortNONSECAConspWorking_" + j).val();
									if (isNaN(foconspworking)) {
										foconspworking = 0;
									}
									var foconspidle = $("#txtFOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(foconspidle)) {
										foconspidle = 0;
									}
									var foconspworkingtanker = $("#txtFOInPortNONSECAConspWorkingLP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var foconsp1 = parseFloat(txtWDays) * parseFloat(foconspworking);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									var foconsp2 = parseFloat(txtIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp2)) {
										foconsp2 = 0;
									}
									var foconsp3 = parseFloat(txtWDays) * parseFloat(foconspworkingtanker);
									if (isNaN(foconsp3)) {
										foconsp3 = 0;
									}
									var foconsp4 = parseFloat(txtIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp4)) {
										foconsp4 = 0;
									}

									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2) + parseFloat(foconsp3) + parseFloat(foconsp4);
								}

								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 = $("#txtFOInPortNONSECAConspWorking_" + j).val();
									if (isNaN(foconspworking)) {
										foconspworking = 0;
									}
									var foconspidle = $("#txtFOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(foconspidle)) {
										foconspidle = 0;
									}
									var foconspworkingtanker = $("#txtFOInPortNONSECAConspWorkingDP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var foconsp1 = parseFloat(txtDWDays) * parseFloat(foconspworking);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									var foconsp2 = parseFloat(txtDIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp2)) {
										foconsp2 = 0;
									}
									var foconsp3 = parseFloat(txtDWDays) * parseFloat(foconspworkingtanker);
									if (isNaN(foconsp3)) {
										foconsp3 = 0;
									}
									var foconsp4 = parseFloat(txtDIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp4)) {
										foconsp4 = 0;
									}

									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp1) + parseFloat(foconsp2) + parseFloat(foconsp3) + parseFloat(foconsp4);
								}

								if (!$("#ChkTPSECA_" + k).is(":checked")) {
									var txtDIDays = $("#txtTLIDays_" + k).val();
									if (isNaN(txtDIDays)) {
										txtDIDays = 0;
									}
									var foconspidle = $("#txtFOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(foconspidle)) {
										foconspidle = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var foconspidletanker = $("#txtFOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									var foconsp = parseFloat(txtDIDays) * parseFloat(foconspidle);
									if (isNaN(foconsp)) {
										foconsp = 0;
									}
									var foconsp1 = parseFloat(txtDIDays) * parseFloat(foconspidletanker);
									if (isNaN(foconsp1)) {
										foconsp1 = 0;
									}
									totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp) + parseFloat(foconsp1);
								}
							}
							var txtTKNONSECAHrs = parseFloat($("#txtTKNONSECAHrs").val());
							if (isNaN(txtTKNONSECAHrs)) {
								txtTKNONSECAHrs = 0;
							}
							var txtTKNONSECAHrs_1 = parseFloat(txtTKNONSECAHrs) / 24;
							var txtFOOtherNONSECAConspTK = parseFloat($("#txtFOOtherNONSECAConspTK_" + j).val());
							if (isNaN(txtFOOtherNONSECAConspTK)) {
								txtFOOtherNONSECAConspTK = 0;
							}
							var tkconsp = parseFloat(txtTKNONSECAHrs_1) * parseFloat(txtFOOtherNONSECAConspTK);
							if (isNaN(tkconsp)) {
								tkconsp = 0;
							}

							var txtInertNONSECAHrs = parseFloat($("#txtInertNONSECAHrs").val());
							if (isNaN(txtInertNONSECAHrs)) {
								txtInertNONSECAHrs = 0;
							}
							var txtInertNONSECAHrs_1 = parseFloat(txtInertNONSECAHrs) / 24;
							var txtFOOtherNONSECAConspInert = parseFloat($("#txtFOOtherNONSECAConspInert_" + j).val());
							if (isNaN(txtFOOtherNONSECAConspInert)) {
								txtFOOtherNONSECAConspInert = 0;
							}
							var inertconsp = parseFloat(txtInertNONSECAHrs_1) * parseFloat(txtFOOtherNONSECAConspInert);
							if (isNaN(inertconsp)) {
								inertconsp = 0;
							}

							var txtGFNONSECAHrs = parseFloat($("#txtGFNONSECAHrs").val());
							if (isNaN(txtGFNONSECAHrs)) {
								txtGFNONSECAHrs = 0;
							}
							var txtGFNONSECAHrs_1 = parseFloat(txtGFNONSECAHrs) / 24;
							var txtFOOtherNONSECAConspGF = parseFloat($("#txtFOOtherNONSECAConspGF_" + j).val());
							if (isNaN(txtFOOtherNONSECAConspGF)) {
								txtFOOtherNONSECAConspGF = 0;
							}
							var GFconsp = parseFloat(txtGFNONSECAHrs_1) * parseFloat(txtFOOtherNONSECAConspGF);
							if (isNaN(GFconsp)) {
								GFconsp = 0;
							}

							var txtHeatNONSECAHrs = parseFloat($("#txtHeatNONSECAHrs").val());
							if (isNaN(txtHeatNONSECAHrs)) {
								txtHeatNONSECAHrs = 0;
							}
							var txtHeatNONSECAHrs_1 = parseFloat(txtHeatNONSECAHrs) / 24;
							var txtFOOtherNONSECAConspHeat = parseFloat($("#txtFOOtherNONSECAConspHeat_" + j).val());
							if (isNaN(txtFOOtherNONSECAConspHeat)) {
								txtFOOtherNONSECAConspHeat = 0;
							}
							var heatconsp = parseFloat(txtHeatNONSECAHrs_1) * parseFloat(txtFOOtherNONSECAConspHeat);
							if (isNaN(heatconsp)) {
								heatconsp = 0;
							}

							var txtHeatNONSECAHrs1 = parseFloat($("#txtHeatNONSECAHrs1").val());
							if (isNaN(txtHeatNONSECAHrs1)) {
								txtHeatNONSECAHrs1 = 0;
							}
							var txtHeatNONSECAHrs1_1 = parseFloat(txtHeatNONSECAHrs1) / 24;
							var txtFOOtherNONSECAConspHeat1 = parseFloat($("#txtFOOtherNONSECAConspHeat1_" + j).val());
							if (isNaN(txtFOOtherNONSECAConspHeat1)) {
								txtFOOtherNONSECAConspHeat1 = 0;
							}
							var heatconsp1 = parseFloat(txtHeatNONSECAHrs1_1) * parseFloat(txtFOOtherNONSECAConspHeat1);
							if (isNaN(heatconsp1)) {
								heatconsp1 = 0;
							}

							totalconspfo = parseFloat(totalconspfo) + parseFloat(tkconsp) + parseFloat(inertconsp) + parseFloat(GFconsp) + parseFloat(heatconsp) + parseFloat(heatconsp1);
						}
					}
					$("#txtNONSECABunkerQty_" + i).val(totalconspfo.toFixed(2));

					if ($('#txtNONSECABunkerid_' + i).val() == 29) {


						let currentVal = parseFloat($('#txtVlfoMT').val()) || 0;
						let additionalVal = parseFloat(totalconspfo) || 0;
						let result = (currentVal + additionalVal).toFixed(2);
						//$('#txtVlfoMT').val(result);

						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtVlfoMT').val(result);
						} else {
							$('#txtVlfoMT').val('0.00');
						}

					} else if ($('#txtNONSECABunkerid_' + i).val() == 11) {

						let currentVal = parseFloat($('#txtHsfo').val()) || 0;
						let additionalVal = parseFloat(totalconspfo) || 0;
						let result = (currentVal + additionalVal).toFixed(2);

						//$('#txtHsfo').val(result);

						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtHsfo').val(result);
						} else {
							$('#txtHsfo').val('0.00');
						}

					}




				}

				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() == $("#txtNONSECABunkerid_" + 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 = $("#txtDOInPortNONSECAConspWorking_" + j).val();
									if (isNaN(doconspworking)) {
										doconspworking = 0;
									}
									var doconspidle = $("#txtDOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(doconspidle)) {
										doconspidle = 0;
									}
									var doconspworkingtanker = $("#txtDOInPortNONSECAConspWorkingLP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var doconsp1 = parseFloat(txtWDays) * parseFloat(doconspworking);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									var doconsp2 = parseFloat(txtIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp2)) {
										doconsp2 = 0;
									}
									var doconsp3 = parseFloat(txtWDays) * parseFloat(doconspworkingtanker);
									if (isNaN(doconsp3)) {
										doconsp3 = 0;
									}
									var doconsp4 = parseFloat(txtIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp4)) {
										doconsp4 = 0;
									}

									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2) + parseFloat(doconsp3) + parseFloat(doconsp4);
								}
								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 = $("#txtDOInPortNONSECAConspWorking_" + j).val();
									if (isNaN(doconspworking)) {
										doconspworking = 0;
									}
									var doconspidle = $("#txtDOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(doconspidle)) {
										doconspidle = 0;
									}
									var doconspworkingtanker = $("#txtDOInPortNONSECAConspWorkingDP_" + j).val();
									if (isNaN(foconspworkingtanker)) {
										foconspworkingtanker = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}

									var doconsp1 = parseFloat(txtDWDays) * parseFloat(doconspworking);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									var doconsp2 = parseFloat(txtDIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp2)) {
										doconsp2 = 0;
									}
									var doconsp3 = parseFloat(txtDWDays) * parseFloat(doconspworkingtanker);
									if (isNaN(doconsp3)) {
										doconsp3 = 0;
									}
									var doconsp4 = parseFloat(txtDIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp4)) {
										doconsp4 = 0;
									}

									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp1) + parseFloat(doconsp2) + parseFloat(doconsp3) + parseFloat(doconsp4);
								}

								if (!$("#ChkTPSECA_" + k).is(":checked")) {
									var txtDIDays = $("#txtTLIDays_" + k).val();
									if (isNaN(txtDIDays)) {
										txtDIDays = 0;
									}
									var doconspidle = $("#txtDOInPortNONSECAConspIdle_" + j).val();
									if (isNaN(doconspidle)) {
										doconspidle = 0;
									}
									if ($("#selPType_" + k).val() == 1) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleBallast_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									if ($("#selPType_" + k).val() == 2) {
										var doconspidletanker = $("#txtDOInPortNONSECAConspIdleLaden_" + j).val();
										if (isNaN(foconspidletanker)) {
											foconspidletanker = 0;
										}
									}
									var doconsp = parseFloat(txtDIDays) * parseFloat(doconspidle);
									if (isNaN(doconsp)) {
										doconsp = 0;
									}
									var doconsp1 = parseFloat(txtDIDays) * parseFloat(doconspidletanker);
									if (isNaN(doconsp1)) {
										doconsp1 = 0;
									}
									totalconspdo = parseFloat(totalconspdo) + parseFloat(doconsp) + parseFloat(doconsp1);
								}
							}
							var txtTKNONSECAHrs = parseFloat($("#txtTKNONSECAHrs").val());
							if (isNaN(txtTKNONSECAHrs)) {
								txtTKNONSECAHrs = 0;
							}
							var txtTKNONSECAHrs_1 = parseFloat(txtTKNONSECAHrs) / 24;
							var txtDOOtherNONSECAConspTK = parseFloat($("#txtDOOtherNONSECAConspTK_" + j).val());
							if (isNaN(txtDOOtherNONSECAConspTK)) {
								txtDOOtherNONSECAConspTK = 0;
							}
							var tkconsp = parseFloat(txtTKNONSECAHrs_1) * parseFloat(txtDOOtherNONSECAConspTK);
							if (isNaN(tkconsp)) {
								tkconsp = 0;
							}

							var txtInertNONSECAHrs = parseFloat($("#txtInertNONSECAHrs").val());
							if (isNaN(txtInertNONSECAHrs)) {
								txtInertNONSECAHrs = 0;
							}
							var txtInertNONSECAHrs_1 = parseFloat(txtInertNONSECAHrs) / 24;
							var txtDOOtherNONSECAConspInert = parseFloat($("#txtDOOtherNONSECAConspInert_" + j).val());
							if (isNaN(txtDOOtherNONSECAConspInert)) {
								txtDOOtherNONSECAConspInert = 0;
							}
							var inertconsp = parseFloat(txtInertNONSECAHrs_1) * parseFloat(txtDOOtherNONSECAConspInert);
							if (isNaN(inertconsp)) {
								inertconsp = 0;
							}

							var txtGFNONSECAHrs = parseFloat($("#txtGFNONSECAHrs").val());
							if (isNaN(txtGFNONSECAHrs)) {
								txtGFNONSECAHrs = 0;
							}
							var txtGFNONSECAHrs_1 = parseFloat(txtGFNONSECAHrs) / 24;
							var txtDOOtherNONSECAConspGF = parseFloat($("#txtDOOtherNONSECAConspGF_" + j).val());
							if (isNaN(txtDOOtherNONSECAConspGF)) {
								txtDOOtherNONSECAConspGF = 0;
							}
							var GFconsp = parseFloat(txtGFNONSECAHrs_1) * parseFloat(txtDOOtherNONSECAConspGF);
							if (isNaN(GFconsp)) {
								GFconsp = 0;
							}

							var txtHeatNONSECAHrs = parseFloat($("#txtHeatNONSECAHrs").val());
							if (isNaN(txtHeatNONSECAHrs)) {
								txtHeatNONSECAHrs = 0;
							}
							var txtHeatNONSECAHrs_1 = parseFloat(txtHeatNONSECAHrs) / 24;
							var txtDOOtherNONSECAConspHeat = parseFloat($("#txtDOOtherNONSECAConspHeat_" + j).val());
							if (isNaN(txtDOOtherNONSECAConspHeat)) {
								txtDOOtherNONSECAConspHeat = 0;
							}
							var heatconsp = parseFloat(txtHeatNONSECAHrs_1) * parseFloat(txtDOOtherNONSECAConspHeat);
							if (isNaN(heatconsp)) {
								heatconsp = 0;
							}

							var txtHeatNONSECAHrs1 = parseFloat($("#txtHeatNONSECAHrs1").val());
							if (isNaN(txtHeatNONSECAHrs1)) {
								txtHeatNONSECAHrs1 = 0;
							}
							var txtHeatNONSECAHrs1_1 = parseFloat(txtHeatNONSECAHrs1) / 24;
							var txtDOOtherNONSECAConspHeat1 = parseFloat($("#txtDOOtherNONSECAConspHeat1_" + j).val());
							if (isNaN(txtDOOtherNONSECAConspHeat1)) {
								txtDOOtherNONSECAConspHeat1 = 0;
							}
							var heatconsp1 = parseFloat(txtHeatNONSECAHrs1_1) * parseFloat(txtDOOtherNONSECAConspHeat1);
							if (isNaN(heatconsp1)) {
								heatconsp1 = 0;
							}

							totalconspdo = parseFloat(totalconspdo) + parseFloat(tkconsp) + parseFloat(inertconsp) + parseFloat(GFconsp) + parseFloat(heatconsp) + parseFloat(heatconsp1);
						}
					}
					$("#txtNONSECABunkerQty_" + i).val(totalconspdo.toFixed(2));


					if ($('#txtNONSECABunkerid_' + i).val() == 23) {


						let currentVal = parseFloat($('#txtLsmgo').val()) || 0;
						let additionalVal = parseFloat(totalconspdo) || 0;
						let result = (currentVal + additionalVal).toFixed(2);
						//$('#txtLsmgo').val(result);

						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtLsmgo').val(result);
						} else {
							$('#txtLsmgo').val('0.00');
						}
					}




				}
			}
			getBunkerCalculation();
			getEuConsp();
		}




		function getEuConsp() {

			$('#txtEtsFuelHsfo').val(0.00);
			$('#txtFuelVlsfo').val(0.00);
			$('#txtEuEtslsmgo').val(0.00);

			var txtSECAConBunkerCount = $("#txtSECAConBunkerCount").val();
			for (var i = 1; i <= parseInt(txtSECAConBunkerCount); i++) {
				var totalconspfo = 0;
				var totalconspfo2 = 0;
				var totalconspdo = 0;
				var totalconspdo2 = 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;

								var euConsp = calculateSeaLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));
								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 * euConsp);
							}
						}
					}

					// console.log('ticks0',totalconspfo);



					// console.log('ticksCheckFoseca',totalconspfo2);
					if ($('#txtSECABunkerid_' + i).val() == 29) {

						let res = (totalconspfo).toFixed(2);

						//$('#txtEtsFuelHsfo').val(res);

						$('#txtFuelVlsfo').val(res);

					} else if ($('#txtSECABunkerid_' + i).val() == 11) {

						let res = (totalconspfo).toFixed(2);
						//$('#txtFuelVlsfo').val(res);

						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtEtsFuelHsfo').val(res);
						}
					}






				}

				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;

								var euConsp = calculateSeaLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));
								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 * euConsp);
							}
						}
					}







					if ($('#txtSECABunkerid_' + i).val() == 23) {

						let res = (totalconspdo).toFixed(2);
						$('#txtEuEtslsmgo').val(res);

					}







				}
			}


			var txtNONSECAConBunkerCount = $("#txtNONSECAConBunkerCount").val();
			for (var i = 1; i <= parseInt(txtNONSECAConBunkerCount); i++) {
				var totalconspfo = 0;
				var totalconspfo2 = 0;
				var totalconspdo = 0;
				var totalconspdo2 = 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;

								var euConsp = calculateSeaLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));
								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);
								var foconsp = parseFloat(nonSECAdays) * parseFloat(foconspparameter);
								if (isNaN(foconsp)) {
									foconsp = 0;
								}
								if (isNaN(foconspparameter)) {
									foconspparameter = 0;
								}
								totalconspfo = parseFloat(totalconspfo) + parseFloat(foconsp * euConsp);
							}
						}
					}

					var txtFOInPortID = $("#txtFOInPortID").val();
					for (var j = 1; j <= parseInt(txtFOInPortID); j++) {
						if ($("#selFOInPortBunker_" + j).val() == $("#txtNONSECABunkerid_" + i).val()) {
							var id = $("#p_rotationID").val();
							for (var k = 1; k <= parseInt(id); k++) {
								if ($("#txtQMT_" + k).val() > 0) {
									if ($("#selPType_" + k).val() == '2') {
										var euConsp = calculatePortLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));
										var txtWDays = $("#txtWDays_" + k).val();
										if (isNaN(txtWDays)) {
											txtWDays = 0;
										}
										var txtIDays = $("#txtIDays_" + k).val();
										if (isNaN(txtIDays)) {
											txtIDays = 0;
										}

										var foconspworking = $("#txtFOInPortNONSECAConspWorking_" + j).val();
										if (isNaN(foconspworking)) {
											foconspworking = 0;
										}
										var foconspidle = $("#txtFOInPortNONSECAConspIdle_" + j).val();
										if (isNaN(foconspidle)) {
											foconspidle = 0;
										}
										var foconspworkingtanker = $("#txtFOInPortNONSECAConspWorkingLP_" + j).val();
										if (isNaN(foconspworkingtanker)) {
											foconspworkingtanker = 0;
										}
										if ($("#selPType_" + k).val() == 1) {
											var foconspidletanker = $("#txtFOInPortNONSECAConspIdleBallast_" + j).val();
											if (isNaN(foconspidletanker)) {
												foconspidletanker = 0;
											}
										}
										if ($("#selPType_" + k).val() == 2) {
											var foconspidletanker = $("#txtFOInPortNONSECAConspIdleLaden_" + j).val();
											if (isNaN(foconspidletanker)) {
												foconspidletanker = 0;
											}
										}

										var foconsp1 = parseFloat(txtWDays) * parseFloat(foconspworking);
										if (isNaN(foconsp1)) {
											foconsp1 = 0;
										}
										var foconsp2 = parseFloat(txtIDays) * parseFloat(foconspidle);
										if (isNaN(foconsp2)) {
											foconsp2 = 0;
										}
										var foconsp3 = parseFloat(txtWDays) * parseFloat(foconspworkingtanker);
										if (isNaN(foconsp3)) {
											foconsp3 = 0;
										}
										var foconsp4 = parseFloat(txtIDays) * parseFloat(foconspidletanker);
										if (isNaN(foconsp4)) {
											foconsp4 = 0;
										}

										totalconspfo2 = parseFloat(totalconspfo2) + parseFloat(foconsp1 * euConsp) + parseFloat(foconsp2 * euConsp) + parseFloat(foconsp3 * euConsp) + parseFloat(foconsp4 * euConsp);
									}
								}




							}

						}
					}
					console.log('ticksCheckFononseca', totalconspfo2);



					if ($('#txtNONSECABunkerid_' + i).val() == 29) {

						// let res = (euConsp * totalconspfo).toFixed(2);

						let currentVal = parseFloat($('#txtEtsFuelHsfo').val()) || 0;
						console.log('currentValnonfo', currentVal)
						let additionalVal = parseFloat((totalconspfo + totalconspfo2).toFixed(2)) || 0;
						let result = (currentVal + additionalVal).toFixed(2);


						//$('#txtEtsFuelHsfo').val(result);

						$('#txtFuelVlsfo').val(result);

					} else if ($('#txtNONSECABunkerid_' + i).val() == 11) {


						let currentVal = parseFloat($('#txtFuelVlsfo').val()) || 0;

						console.log('currentValfononseca2', currentVal)
						let additionalVal = parseFloat((totalconspfo + totalconspfo2).toFixed(2)) || 0;
						let result = (currentVal + additionalVal).toFixed(2);


						//$('#txtFuelVlsfo').val(result);

						if (parseFloat($('#txtSECABunkerPrice_' + i).val()) > 0 || parseFloat($('#txtSECABunkerPriceNonSeca_' + i).val()) > 0) {
							$('#txtEtsFuelHsfo').val(result);
						}
					}
				}

				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;

								var euConsp = calculateSeaLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));
								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 * euConsp);
							}
						}
					}

					var txtDOInPortID = $("#txtDOInPortID").val();
					for (var j = 1; j <= parseInt(txtDOInPortID); j++) {
						if ($("#selDOInPortBunker_" + j).val() == $("#txtNONSECABunkerid_" + i).val()) {
							var id = $("#p_rotationID").val();
							for (var k = 1; k <= parseInt(id); k++) {

								var euConsp = calculatePortLegPercentage(extractCountryCodeFromSelect2("s2id_selFPort_" + k), extractCountryCodeFromSelect2("s2id_selTPort_" + k));

								if ($("#txtQMT_" + k).val() > 0) {
									if ($("#selPType_" + k).val() == '2') {
										var txtWDays = $("#txtWDays_" + k).val();
										if (isNaN(txtWDays)) {
											txtWDays = 0;
										}
										var txtIDays = $("#txtIDays_" + k).val();
										if (isNaN(txtIDays)) {
											txtIDays = 0;
										}

										var doconspworking = $("#txtDOInPortNONSECAConspWorking_" + j).val();
										if (isNaN(doconspworking)) {
											doconspworking = 0;
										}
										var doconspidle = $("#txtDOInPortNONSECAConspIdle_" + j).val();
										if (isNaN(doconspidle)) {
											doconspidle = 0;
										}
										var doconspworkingtanker = $("#txtDOInPortNONSECAConspWorkingLP_" + j).val();
										if (isNaN(foconspworkingtanker)) {
											foconspworkingtanker = 0;
										}
										if ($("#selPType_" + k).val() == 1) {
											var doconspidletanker = $("#txtDOInPortNONSECAConspIdleBallast_" + j).val();
											if (isNaN(foconspidletanker)) {
												foconspidletanker = 0;
											}
										}
										if ($("#selPType_" + k).val() == 2) {
											var doconspidletanker = $("#txtDOInPortNONSECAConspIdleLaden_" + j).val();
											if (isNaN(foconspidletanker)) {
												foconspidletanker = 0;
											}
										}

										var doconsp1 = parseFloat(txtWDays) * parseFloat(doconspworking);
										if (isNaN(doconsp1)) {
											doconsp1 = 0;
										}
										var doconsp2 = parseFloat(txtIDays) * parseFloat(doconspidle);
										if (isNaN(doconsp2)) {
											doconsp2 = 0;
										}
										var doconsp3 = parseFloat(txtWDays) * parseFloat(doconspworkingtanker);
										if (isNaN(doconsp3)) {
											doconsp3 = 0;
										}
										var doconsp4 = parseFloat(txtIDays) * parseFloat(doconspidletanker);
										if (isNaN(doconsp4)) {
											doconsp4 = 0;
										}

										totalconspdo2 = parseFloat(totalconspdo2) + parseFloat(doconsp1 * euConsp) + parseFloat(doconsp2 * euConsp) + parseFloat(doconsp3 * euConsp) + parseFloat(doconsp4 * euConsp);
									}
								}



							}



						}
					}

					console.log('ticksCheckdononseca', totalconspdo2);
					if ($('#txtNONSECABunkerid_' + i).val() == 23) {


						let currentVal = parseFloat($('#txtEuEtslsmgo').val()) || 0;
						console.log('currentVal3donon', currentVal);
						let additionalVal = parseFloat((totalconspdo + totalconspdo2).toFixed(2)) || 0;
						let result = (currentVal + additionalVal).toFixed(2);
						$('#txtEuEtslsmgo').val(result);

					}






				}
			}


			complianceCalculation();
		}


		function complianceCalculation() {
			var fuelHSFO = parseFloat($('#txtEtsFuelHsfo').val());
			var fuelVLSFO = parseFloat($('#txtFuelVlsfo').val());
			var euetsLSMGO = parseFloat($('#txtEuEtslsmgo').val());
			var cargoQty = parseFloat($('#txtBLCQMT').val());
			var ladenDist = parseFloat($('#txtLDist').val());
			var dwtQty = parseFloat($('#txtSummer_DWT1').val());
			var sailedDist = parseFloat($('#txtTDist').val());

			var bunkerGradeData = JSON.parse('<?php echo json_encode($bunkerGradeData) ?>');

			if (fuelHSFO > 0) {
				var penaltyHSFO = parseFloat(fuelHSFO * bunkerGradeData.HSFO.PENALITY);

				$("#txtHsfoPenal").val((penaltyHSFO).toFixed(2));
			} else {
				$("#txtHsfoPenal").val('0.00');
			}

			if (fuelVLSFO > 0) {
				var penaltyVLSFO = parseFloat(fuelVLSFO * bunkerGradeData.VLSFO.PENALITY);

				$("#txtVlsoPenal").val((penaltyVLSFO).toFixed(2));
			} else {
				$("#txtVlsoPenal").val('0.00');
			}

			if (euetsLSMGO > 0) {
				var penaltyLSMGO = parseFloat(euetsLSMGO * bunkerGradeData.LSMGO.PENALITY);

				$("#txtLsmgoPenal").val((penaltyLSMGO).toFixed(2));
			} else {
				$("#txtLsmgoPenal").val('0.00');
			}

			if ((fuelHSFO > 0 || fuelVLSFO > 0 || euetsLSMGO > 0) && cargoQty > 0 && ladenDist > 0) {
				var eeoi = ((parseFloat(fuelHSFO * bunkerGradeData.HSFO.CO2_FAC) + parseFloat(fuelVLSFO * bunkerGradeData.VLSFO.CO2_FAC) + parseFloat(euetsLSMGO * bunkerGradeData.LSMGO.CO2_FAC)) * (10 ** 6)) / (cargoQty * ladenDist);

				$("#txtEeoi").val((eeoi).toFixed(2));
			} else {
				$("#txtEeoi").val('0.00');
			}

			if ((fuelVLSFO > 0 || euetsLSMGO > 0) && dwtQty > 0 && sailedDist > 0) {
				var cii = ((parseFloat(fuelHSFO * bunkerGradeData.HSFO.CO2_FAC) + parseFloat(fuelVLSFO * bunkerGradeData.VLSFO.CO2_FAC) + parseFloat(euetsLSMGO * bunkerGradeData.LSMGO.CO2_FAC)) * (10 ** 6)) / (dwtQty * sailedDist);

				$("#txtCiiGCo").val((cii).toFixed(2));
			} else {
				$("#txtCiiGCo").val('0.00');
			}

			if (fuelVLSFO > 0 || euetsLSMGO > 0) {
				var eeoi_co2 = parseFloat(fuelHSFO * bunkerGradeData.HSFO.CO2_FAC) + parseFloat(fuelVLSFO * bunkerGradeData.VLSFO.CO2_FAC) + parseFloat(euetsLSMGO * bunkerGradeData.LSMGO.CO2_FAC);

				$("#txtEeoiCo").val((eeoi_co2).toFixed(2));
			} else {
				$("#txtEeoiCo").val('0.00');

				var eeoi_co2 = 0;
			}

			var ttlHSFO = parseFloat($('#txtHsfo').val());
			var ttlVLSFO = parseFloat($('#txtVlfoMT').val());
			var ttlLSMGO = parseFloat($('#txtLsmgo').val());

			if (ttlHSFO > 0 || ttlVLSFO > 0 || ttlLSMGO > 0) {
				var co2mt = parseFloat(ttlHSFO * bunkerGradeData.HSFO.CO2_FAC) + parseFloat(ttlVLSFO * bunkerGradeData.VLSFO.CO2_FAC) + parseFloat(ttlLSMGO * bunkerGradeData.LSMGO.CO2_FAC);

				$("#txtCo2mt").val((co2mt).toFixed(2));
			} else {
				$("#txtCo2mt").val('0.00');
			}

			var co2mt = parseFloat($("#txtCo2mt").val());
			var co2price = parseFloat($("#txtCVE").val());

			if (co2mt > 0 && co2price > 0) {
				var ttlCostUSD = co2mt * co2price;

				$("#txtCo2Cost").val((ttlCostUSD).toFixed(2));
			} else {
				$("#txtCo2Cost").val('0.00');
			}

			if (fuelHSFO > 0 || fuelVLSFO > 0 || euetsLSMGO > 0) {
				var euaco2 = parseFloat(fuelHSFO * bunkerGradeData.HSFO.CO2_FAC * (bunkerGradeData.HSFO.EUACO2RATE / 100)) + parseFloat(fuelVLSFO * bunkerGradeData.VLSFO.CO2_FAC * (bunkerGradeData.VLSFO.EUACO2RATE / 100)) + parseFloat(euetsLSMGO * bunkerGradeData.LSMGO.CO2_FAC * (bunkerGradeData.LSMGO.EUACO2RATE / 100));

				$("#txtEuaCo2mt").val((euaco2).toFixed(2));
			} else {
				$("#txtEuaCo2mt").val('0.00');

				var euaco2 = 0;
			}

			var euaprice = parseFloat($("#txtEuaPrice").val());

			if (euaco2 > 0 && euaprice > 0) {
				var euaco2usd = parseFloat(euaco2 * euaprice);

				$("#txteuaCo2Usd").val(Math.ceil(euaco2usd));
			} else {
				$("#txteuaCo2Usd").val('0.00');
			}
		}




		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" ><input type="text" name="txtMargin_' + id + '" style="width:60px;" id="txtMargin_' + id + '" class="input-text" autocomplete="off" placeholder="0.00" value="5"  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><td align="left" class="input-text" ><select name="selPType_' + id + '" class="input-text" style="width:90px;" id="selPType_' + id + '" onChange="getVoyageTime(this);" ><?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" ><select  name="selDType_' + id + '" class="input-text" style="width:90px;" id="selDType_' + id + '"><?php $obj->getPortDistanceType_new(); ?></select></td></tr>').appendTo("#tblPortRotation");

				$('<tr id="lp_Row_' + id + '"><td align="left" class="form-control" title="" data-widget="Please check the box, for which demurrage/despatch is not required." data-toggle="tooltip" data-original-title="Please check the box, for which demurrage/despatch is not required." ><input name="ChkShowDDCLP_' + id + '" class="checkbox" id="ChkShowDDCLP_' + id + '" type="checkbox" value="' + id + '"/></td><td align="center" class="input-text" ><span id="spanLoadPort_' + id + '"></span></td><td align="left" class="input-text"><select id="targetSelectLp_' + id + '" name="targetSelectLp_' + id + '" class="targetSelect" style="width:80px;"><option value="">---Select from chosen items---</option></select></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"><i class="fa fa-calculator" style="font-size:17px" data-widget="Calculate loadable" data-toggle="tooltip" data-original-title="Calculate loadable" data-rotationId="' + id + '" data-porttype="lp" onclick="setCalloadable(this)"></i></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="ChkLPSECA_' + id + '" class="checkbox" id="ChkLPSECA_' + id + '" type="checkbox" value="' + id + '"/></td></tr>').appendTo("#tblLoadPort");

				$('<tr id="dp_Row_' + id + '"><td align="left" class="form-control" title="" data-widget="Please check the box, for which demurrage/despatch is not required." data-toggle="tooltip" data-original-title="Please check the box, for which demurrage/despatch is not required." ><input name="ChkShowDDCDP_' + id + '" class="checkbox" id="ChkShowDDCDP_' + id + '" type="checkbox" value="' + id + '"/></td><td align="center" class="input-text" ><span id="spanDisPort_' + id + '"></span></td><td align="left" class="input-text"><select id="targetSelectDp_' + id + '" name="targetSelectDp_' + id + '" class="targetSelect" style="width:80px;"><option value="">---Select from chosen items---</option></select></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"><i class="fa fa-calculator" style="font-size:17px" data-widget="Calculate loadable" data-toggle="tooltip" data-rotationId="' + id + '" data-original-title="Calculate loadable" data-porttype="dp" onclick="setCalloadable(this)"></i></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="ChkDPSECA_' + id + '" class="checkbox" id="ChkDPSECA_' + id + '" type="checkbox" value="' + id + '"/></td></tr>').appendTo("#tblDisPort");

				getMaterialCode();
				$('<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();setRequired(this);"/></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><td align="left" class="input-text"><select name="selPortFun_' + id + '" class="input-text" style="width:120px;" id="selPortFun_' + id + '"><option value="">--Please Select---</option><option value="TP">Transit Port</option><option value="BP">Bunkering Port</option></select></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();



				previd = id - 1;
				$('#selFPort_O_' + id).val($('#selTPort_O_' + previd).val());
				$("#selFPort_" + id).select2({
					minimumInputLength: 3,
					placeholder: '---Select from list---',
					allowClear: true,
					ajax: {
						url: "getportapi.php",
						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: "getportapi.php",
						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_],[id^=ChkShowDDCTPBP_]").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();
			var divideby = 0;
			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.555555;
					} else if ($("#selLPTerms_" + i).val() == 3) {
						value = parseFloat(parseFloat($("#txtQMT_" + i).val() / $("#txtRate_" + i).val()) / parseInt(divideby)) * 1.405;
					} else if ($("#selLPTerms_" + i).val() == 5) {
						value = parseFloat(parseFloat($("#txtQMT_" + i).val() / $("#txtRate_" + i).val()) / parseInt(divideby)) * 1;
					} else if ($("#selLPTerms_" + i).val() == 6) {
						value = parseFloat(parseFloat($("#txtQMT_" + i).val() / $("#txtRate_" + i).val()) / parseInt(divideby)) * 1.272727;
					} else if ($("#selLPTerms_" + i).val() == 7) {
						value = parseFloat(parseFloat($("#txtQMT_" + i).val() / $("#txtRate_" + i).val()) / parseInt(divideby)) * 1.333333;
					} 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(2));
					}
				} 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.555555;
					} else if ($("#selDPTerms_" + i).val() == 3) {
						value = parseFloat(parseFloat($("#txtDQMT_" + i).val() / $("#txtDRate_" + i).val()) / parseInt(divideby)) * 1.405;
					} else if ($("#selDPTerms_" + i).val() == 5) {
						value = parseFloat(parseFloat($("#txtDQMT_" + i).val() / $("#txtDRate_" + i).val()) / parseInt(divideby)) * 1;
					} else if ($("#selDPTerms_" + i).val() == 6) {
						value = parseFloat(parseFloat($("#txtDQMT_" + i).val() / $("#txtDRate_" + i).val()) / parseInt(divideby)) * 1.272727;
					} else if ($("#selDPTerms_" + i).val() == 7) {
						value = parseFloat(parseFloat($("#txtDQMT_" + i).val() / $("#txtDRate_" + i).val()) / parseInt(divideby)) * 1.333333;
					} 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(2));
					}
				} 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(3));
						$("#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(3));
						$("#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(3));
						$("#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) {
				var txtBLCQMT = parseFloat($("#txtBLCQMT").val());
				if (isNaN(txtBLCQMT) || txtBLCQMT == '') {
					txtBLCQMT = 0
				}
				var txtLessPerQty = parseFloat($("#txtLessPerQty").val());
				if (isNaN(txtLessPerQty) || txtLessPerQty == '') {
					txtLessPerQty = 0
				}
				if (txtLessPerQty > 0) {
					var txtCQMT = parseFloat(txtBLCQMT) - parseFloat((parseFloat(txtBLCQMT) * parseFloat(txtLessPerQty)) / 100);
					if (isNaN(txtCQMT) || txtCQMT == '') {
						txtCQMT = 0
					}
				} else {
					var txtCQMT = txtBLCQMT;

					var checkForCheck = '<pro>'
				}
				$("#txtCQMT").val(txtCQMT.toFixed(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 ($("#txtBLCQMT").val() == " " || isNaN($("#txtBLCQMT").val())) {
					var per_QTY = 0.00;
				} else {
					var per_QTY = $("#txtBLCQMT").val();
				}


				if ($("#rdoMMarket1").is(":checked")) {
					if ($("#txtMTCPDRate").val() == "" || isNaN($("#txtMTCPDRate").val())) {
						var agr_gross_fr = 0;
					} else {
						var agr_gross_fr = $("#txtMTCPDRate").val();
					}
					// console.log('test123');
					console.log('agr_gross_fr', agr_gross_fr);
					console.log('per_QTY', per_QTY);
					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));


			var txtHIREID = $("#txtHIREID").val();
			var hiredays = 0;
			for (var i = 1; i <= txtHIREID; i++) {
				// if(typeof($("#txtHireFrom_"+i).val())!='undefined')
				// {
				// var timediff = parseFloat(getTimeDiff($("#txtHireTo_"+i).val(),$("#txtHireFrom_"+i).val()));
				if (isNaN(timediff)) {
					timediff = 0.00;
				}
				// $("#txtHireDays_"+i).val(parseFloat(timediff).toFixed(4))
				var offrate = parseFloat($("#txtHireRate_" + i).val());
				if (isNaN(offrate)) {
					offrate = 0.00;
				}

				var hdays = parseFloat($("#txtHireDays_" + i).val());
				if (isNaN(hdays)) {
					hdays = 0.00;
				}


				hiredays = parseFloat(parseFloat(hiredays) + parseFloat(timediff));
				$("#txtHireAmt_" + i).val((parseFloat(hdays) * parseFloat(offrate)).toFixed(2));
				// }

				console.log('hdays', hdays)
				console.log('offrate', offrate)
				console.log('txtHireDays_', $("#txtHireDays_" + i).val())
				console.log('txtHireRate_', $("#txtHireRate_" + i).val())
				console.log('count', i)
			}
			var txtTotalVoyageDays = $("[id^=txtHireDays_]").sum();
			var hireage_amt = $("[id^=txtHireAmt_]").sum();
			$("#txtTotalVoyageDays").val(parseFloat(txtTotalVoyageDays).toFixed(5));

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


			console.log('txtBallastBonus', txtBallastBonus);
			console.log('txtHireargeAmt', parseFloat($("#txtHireargeAmt").val()));


			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;
				$("#txtHireargeCVE").val($("#txtCVE").val());




			}


			// if(txtHireargeCVE == "" || isNaN(txtHireargeCVE) || txtHireargeCVE==0){

			$("#txtHireargeCVE").val($("#txtCVE").val());

			// 
			// }
			var txtHireargeCVEAMT = parseFloat(parseFloat(parseFloat(parseFloat(txtHireargeCVE) * 12) / 365) * parseFloat(txtTotalVoyageDays));
			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') {
					if ($("#txtOffHireTo_" + i).val() != '' && $("#txtOffHireFrom_" + i).val()) {
						var timediff = parseFloat(getTimeDiff($("#txtOffHireTo_" + i).val(), $("#txtOffHireFrom_" + i).val()));
						if (isNaN(timediff)) {
							timediff = 0.00;
						}
						$("#txtOffHireDays_" + i).val(parseFloat(timediff).toFixed(5));
					} else {
						var timediff = $("#txtOffHireDays_" + i).val();
						if (timediff == "" || isNaN(timediff)) {
							timediff = 0;
						}
					}
					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);
							}
						}
					}
				}
			}
			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));


			var txtIlohcForTcDet = parseFloat($('#txtIlohcForTcDet').val());
			if (txtIlohcForTcDet == "" || isNaN(txtIlohcForTcDet)) {
				txtIlohcForTcDet = 0;
			}



			var txtFinalHireargeAmt = parseFloat(parseFloat(txtNettHireargeAmt) + $("[id^=txtDelAmount_]").sum() + parseFloat(txtHireargeCVEAMT)) - $("[id^=txtReDelAmount_]").sum() - parseFloat(OffhireDaysAMT);

			// console.log('txtNettHireargeAmt',parseFloat(parseFloat(txtNettHireargeAmt)))
			// console.log('txtDelAmount_',$("[id^=txtDelAmount_]").sum());
			// console.log('txtIlohcForTcDet',$('#txtIlohcForTcDet').val());
			// console.log('txtReDelAmount_',$("[id^=txtReDelAmount_]").sum());
			// console.log('txtHireargeCVEAMT',txtHireargeCVEAMT);
			// console.log('OffhireDaysAMT',OffhireDaysAMT);
			// console.log('txtFinalHireargeAmt',txtFinalHireargeAmt);

			if (isNaN(txtFinalHireargeAmt)) {
				txtFinalHireargeAmt = 0.00;
			}
			$("#txtFinalHireargeAmt").val(parseFloat(txtFinalHireargeAmt).toFixed(2));



			$("#txtTotalOperationalCost").val($("[id^=txtORCAmt_],#txtBrComm").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 txtIlohcForTcDet = parseFloat($('#txtIlohcForTcDet').val());
			if (txtIlohcForTcDet == "" || isNaN(txtIlohcForTcDet)) {
				txtIlohcForTcDet = 0;
			}


			var costbeforebamarage = parseFloat(revenue) - parseFloat(totalexpenses) - parseFloat(txtHireargeCVEAMT);
			var voyage_earning = parseFloat(revenue) - parseFloat(totalexpenses) - parseFloat(txtFinalHireargeAmt) + txtIlohcForTcDet;







			// if(voyage_earning<0){

			// 	voyage_earning = voyage_earning + parseFloat($('#txtFrAdjUsdAC').val()) + parseFloat($('#txtBrComm').val())

			// 	costbeforebamarage = costbeforebamarage + parseFloat($('#txtFrAdjUsdAC').val()) + parseFloat($('#txtBrComm').val());

			// }

			$("#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));
			$("#netHireage").val(parseFloat(txtFinalHireargeAmt).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));
			});

			<?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 } ?>

			if (parseFloat($("#txtBLCQMT").val()) > 0) {
				complianceCalculation();
			}
		}



		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>Charterers side 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 setIlhocForTcDet() {

			$('#txtIlohcForTcDet').val($('#txtORCAmt_6').val())

			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) {
				var txtBLCQMT = parseFloat($("#txtBLCQMT").val());
				if (isNaN(txtBLCQMT) || txtBLCQMT == '') {
					txtBLCQMT = 0
				}
				var txtLessPerQty = parseFloat($("#txtLessPerQty").val());
				if (isNaN(txtLessPerQty) || txtLessPerQty == '') {
					txtLessPerQty = 0
				}
				if (txtLessPerQty > 0) {
					var txtCQMT = parseFloat(txtBLCQMT) - parseFloat((parseFloat(txtBLCQMT) * parseFloat(txtLessPerQty)) / 100);
					if (isNaN(txtCQMT) || txtCQMT == '') {
						txtCQMT = 0
					}
				} else {
					var txtCQMT = txtBLCQMT;
				}
				$("#txtCQMT").val(txtCQMT.toFixed(2));

				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();
					}
				}
			}


			$("#ttlorcamt").val(parseFloat($("[id^=txtORCAmt_]").sum()).toFixed(2));


			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(val) {


			if ($('#selCName').val() == null) {
				jAlert('Please fill Cargo Name', 'Alert');

				return false;
			}


			$("#txtBStatus").val(val);
			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);
			getFinalCalculation();

		}





		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 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 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(4));
				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 addORCRow() {
			var id = $("#txtOWCCount").val();

			// var id 
			if ($("#txtHidORCID_" + id).val() != "" && $("#txtORCAmt_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="OWCRow_' + id + '"><td><a href="#tb1" onClick="removeCC(' + id + ',' + 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"  required/></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, var2) {
			jConfirm('Are you sure you want to remove this entry permanently ?', 'Confirmation', function(r) {
				if (r) {
					$("#OWCRow_" + var1).remove();

					$("#txtOWCCount").val(var2 - 1);


					getFinalCalculation();
					getORCCalculate();


				} else {
					return false;
				}
			});
		}

		function removeCCForLock(var1) {

			jAlert('Sorry You Cannot Delete it', 'Alert');
			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 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());
				$(".numeric").numeric();
				$("#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;
					}
				});
			} 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 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 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 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() != "") || $("#txtOffHireDays_" + 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 numeric"  placeholder="Off Hire Days" style="width:90px;" 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 + '"></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="0"/></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() {
					getCalculateoffhireBunker(id)
				});


				$('#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() != "") {
				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("getdistanceapi.php", {
				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://tile3-service.seametrix.net/mapsapi/basemap15/5hn3v1h7ra/{z}/{x}/{y}.png', {
						maxZoom: 10,
						center: [0, 180],
						edgeBufferTiles: 1
					}).addTo(map);

					var coordinates = lat_long_string;

					var polyline = L.Polyline.PolylineEditor(coordinates, {
						maxMarkers: 200
					}).addTo(map);
					map.fitBounds(polyline.getBounds());
				} else {
					jAlert('Error!, Something went wrong, Please try again', 'Alert');
					return false;
				}
			});
		}


		function AddNewHireRow() {
			var id = $("#txtHIREID").val();
			if ($("#txtHireFrom_" + id).val() != "" && $("#txtHireTo_" + id).val() != "") {
				id = (id - 1) + 2;
				$('<tr id="row_hire_' + id + '" class="input-text"><td><a href="#pr' + id + '" onclick="removeHireRow(' + id + ');"><i class="fa fa-times" style="color:red;"></i></a></td><td valign="top"><input type="text" name="txtHireFrom_' + id + '" id="txtHireFrom_' + id + '" class="input-text" placeholder="dd-mm-yyyy HH:MM" style="width:120px;" autocomplete="off" value=""></td><td valign="top"><input type="text" name="txtHireTo_' + id + '" id="txtHireTo_' + id + '" class="input-text" placeholder="dd-mm-yyyy HH:MM" autocomplete="off" value="" style="width:120px;"></td><td valign="top"><input type="text" name="txtHireDays_' + id + '" id="txtHireDays_' + id + '" class="input-text"  placeholder="Off Hire Days" style="width:100px;background-color:#EAEAEA;" autocomplete="off" value=""/></td><td valign="top"><input type="text" name="txtHireRate_' + id + '" id="txtHireRate_' + id + '" class="input-text" style="width:100px;"  placeholder="Rate/Day" autocomplete="off" value="" onKeyUp="getFinalCalculation();"/></td><td valign="top"><input type="text" name="txtHireAmt_' + id + '" id="txtHireAmt_' + id + '" class="input-text" readonly="true" placeholder="Off Hire(USD)" style="width:100px;" autocomplete="off" value=""/></td></tr>').appendTo("#hirebody");
				$("#txtHIREID").val(id);
				$("[id^=txtHireRate_]").numeric();
				$(".numeric").numeric();
				$('#txtHireFrom_' + id + ',#txtHireTo_' + id).datetimepicker({
					format: 'dd-mm-yyyy hh:ii',
					autoclose: true,
					todayBtn: true,
					minuteStep: 1
				}).on('changeDate', function() {
					getFinalCalculation();
				});

			}
		}


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


		function getCalculateoffhireBunker(val) {
			if ($("#txtOffHireTo_" + val).val() != '' && $("#txtOffHireFrom_" + val).val()) {
				var timediff = parseFloat(getTimeDiff($("#txtOffHireTo_" + val).val(), $("#txtOffHireFrom_" + val).val()));
				if (isNaN(timediff)) {
					timediff = 0.00;
				}
				var offdays = parseFloat(timediff).toFixed(5);

				$("#TCConbunkerTBody_" + val).empty();
				$("#txtTCConBunkerCount_" + val).val(0);

				var txtFOInPortID = $("#txtFOInPortID").val();
				for (var j = 1; j <= parseInt(txtFOInPortID); j++) {
					addTCConBunkerRow(val);
					var txtTCConBunkerCount = $("#txtTCConBunkerCount_" + val).val();
					$("#selTCConBunker_" + val + "_" + txtTCConBunkerCount).val($("#selFOInPortBunker_" + j).val());

					var foconspidle = $("#txtFOInPortNONSECAConspIdle_" + j).val();
					if (isNaN(foconspidle)) {
						foconspidle = 0;
					}
					var consp = parseFloat(offdays) * parseFloat(foconspidle);
					if (isNaN(consp)) {
						consp = 0;
					}

					$("#txtTCConBunkerQty_" + val + "_" + txtTCConBunkerCount).val(parseFloat(consp).toFixed(4));
					$("#txtTCConBunkerPrice_" + val + "_" + txtTCConBunkerCount).val('0.00');
					$("#txtTCConBunkerAmt_" + val + "_" + txtTCConBunkerCount).val('0.00');
				}

				var txtDOInPortID = $("#txtDOInPortID").val();
				for (var k = 1; k <= parseInt(txtDOInPortID); k++) {
					addTCConBunkerRow(val);
					var txtTCConBunkerCount = $("#txtTCConBunkerCount_" + val).val();
					$("#selTCConBunker_" + val + "_" + txtTCConBunkerCount).val($("#selDOInPortBunker_" + k).val());

					var foconspidle = $("#txtDOInPortNONSECAConspIdle_" + k).val();
					if (isNaN(foconspidle)) {
						foconspidle = 0;
					}
					var consp = parseFloat(offdays) * parseFloat(foconspidle);
					if (isNaN(consp)) {
						consp = 0;
					}

					$("#txtTCConBunkerQty_" + val + "_" + txtTCConBunkerCount).val(parseFloat(consp).toFixed(4));
					$("#txtTCConBunkerPrice_" + val + "_" + txtTCConBunkerCount).val('0.00');
					$("#txtTCConBunkerAmt_" + val + "_" + txtTCConBunkerCount).val('0.00');
				}
			}

			getFinalCalculation();
		}


		function loadPeriodDetails() {
			if ($("#selPeriodContract").val() != "") {
				$.post("options.php?id=103", {
					periodid: "" + $("#selPeriodContract").val() + ""
				}, function(data) {
					var jsondata = JSON.parse(data);
					var vesselimoid = jsondata['vesselimoid'];
					$("#selVName").val(vesselimoid);
					getData();
					var period_hire_details = jsondata['period_hire_details'];
					var period_bunker_details = jsondata['period_bunker_details'];
					var period_offhire_details = jsondata['period_offhire_details'];
					var hirenum = jsondata['hirenum'];
					var bunkernum = jsondata['bunkernum'];
					var offhirenum = jsondata['offhirenum'];

					$("#offhirebody").empty();
					$("#txtOFFID").val(0);
					$("#bunkerRedelivery,#bunkerdelivery").empty();
					$("#txtDELID,#txtREDELID").val(0);
					//	$("#hirebody").empty();
					// $("#txtHIREID").val(0);

					if (offhirenum > 0) {
						$("#offhirebody").empty();
						$("#txtOFFID").val(0);
						$.each(period_offhire_details, function(index, array) {
							AddNewOffHire();
							var txtOFFID = $("#txtOFFID").val();
							$("#txtOffHireReason_" + txtOFFID).val(array['OFF_HIRE_REASON']);
							$("#txtOffHireFrom_" + txtOFFID).val(array['OFF_HIRE_FROM']);
							$("#txtOffHireTo_" + txtOFFID).val(array['OFF_HIRE_TO']);
							$("#txtOffHireDays_" + txtOFFID).val(array['OFF_HIRE_DAYS']);
							$("#txtOffHireRate_" + txtOFFID).val(array['OFF_HIRE_RATE']);
							$("#txtOffHireAmt_" + txtOFFID).val(array['OFF_HIRE_AMT']);

							$.each(array['OFF_HIRE_BUNKER'], function(index1, array1) {
								addTCConBunkerRow(txtOFFID);
								var txtTCConBunkerCount = $("#txtTCConBunkerCount_" + txtOFFID).val();
								$("#selTCConBunker_" + txtOFFID + "_" + txtTCConBunkerCount).val(array1['BUNKERGRADEID']);
								$("#txtTCConBunkerQty_" + txtOFFID + "_" + txtTCConBunkerCount).val(array1['BUNKER_QTY']);
								$("#txtTCConBunkerPrice_" + txtOFFID + "_" + txtTCConBunkerCount).val(array1['BUNKER_PRICE']);
								$("#txtTCConBunkerAmt_" + txtOFFID + "_" + txtTCConBunkerCount).val(array1['BUNKER_AMT']);
								if (array1['CHK_OWNER_ACCOUNT'] == "1") {
									$("#ChkOFFHireCal_" + txtOFFID + "_" + txtTCConBunkerCount).attr('checked', true);
									$("#ChkOFFHireCal_" + txtOFFID + "_" + txtTCConBunkerCount).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();
									});

								}

							});
							getFinalCalculation();
						});
					}

					if (hirenum > 0) {
						$("#hirebody").empty();
						$("#txtHIREID").val(0);
						$.each(period_hire_details, function(index, array) {
							AddNewHireRow();
							var txtHIREID = $("#txtHIREID").val();
							$("#txtHireFrom_" + txtHIREID).val(array['HIRE_FROM']);
							$("#txtHireTo_" + txtHIREID).val(array['HIRE_TO']);
							// $("#txtHireDays_" + txtHIREID).val(array['HIRE_DAYS']);
							// $("#txtHireRate_" + txtHIREID).val(array['HIRE_RATE']);
							getFinalCalculation();
						});
					}

					if (bunkernum > 0) {
						$("#bunkerRedelivery,#bunkerdelivery").empty();
						$("#txtDELID,#txtREDELID").val(0);
						$.each(period_bunker_details, function(index, array) {
							if (array['IDENTITY'] == 'DEL') {
								AddNewDel();
								var txtDELID = $("#txtDELID").val();
								$("#selDelBunker_" + txtDELID).val(array['BUNKERGRADEID']);
								$("#txtDelQty_" + txtDELID).val(array['BUNKER_QTY']);
								$("#txtDelBunDate_" + txtDELID).val(array['BUNKER_DATE']);
								$("#txtDelPrice_" + txtDELID).val(array['BUNKER_RATE']);
								$("#txtDelAmount_" + txtDELID).val(array['BUNKER_AMT']);
								getDelBunkerCalculation();
							}
							if (array['IDENTITY'] == 'REDEL') {
								AddNewReDel();
								var txtREDELID = $("#txtREDELID").val();
								$("#selReDelBunker_" + txtREDELID).val(array['BUNKERGRADEID']);
								$("#txtReDelQty_" + txtREDELID).val(array['BUNKER_QTY']);
								$("#txtReDelBunDate_" + txtREDELID).val(array['BUNKER_DATE']);
								$("#txtReDelPrice_" + txtREDELID).val(array['BUNKER_RATE']);
								$("#txtReDelAmount_" + txtREDELID).val(array['BUNKER_AMT']);
								getReDelBunkerCalculation();
							}
						});
					}

				});
			} else {

			}
		}




		$('#txtVNo,#txtTCNo,#txtENo').on('input', function() {
			var c = this.selectionStart,
				r = /[^a-z0-9]/gi,
				v = $(this).val();
			if (r.test(v)) {
				$(this).val(v.replace(r, ''));
				c--;
			}
			this.setSelectionRange(c, c);
			console.log($(this).val())

			$('#txtTCNo').val($(this).val());
			$('#txtENo').val($(this).val());





		});










		function makeFieldManD(elx) {

			// console.log($(elx).val())

			if ($(elx).val() == 1) {

				$('.tcin').show();
			} else {

				$('.tcin').hide();
			}




			if ($(elx).val() == 2) {

				$("[id^=txtORCAmt_]").val(0);

				$("#txtCVE").val(0);
				$("#ttlorcamt").val(parseFloat($("[id^=txtORCAmt_]").sum()).toFixed(2));
				getFinalCalculation();

			} else {



				$('#txtORCAmt_1').val(2000)
				$('#txtORCAmt_2').val(1000)
				$('#txtORCAmt_3').val(1000)
				$('#txtORCAmt_4').val(1000)
				$('#txtORCAmt_5').val(1000)
				$('#txtORCAmt_6').val(5000)
				$("#txtCVE").val(1500);
				$("#ttlorcamt").val(parseFloat($("[id^=txtORCAmt_]").sum()).toFixed(2));

				getFinalCalculation();


			}








		}

		function pasteCharteing(elx) {


			$.post("options.php?id=116", {
				ID: "" + $(elx).val() + ""
			}, function(data) {

				$('#chartering_pic_1').html(data)

				$('#chartering_pic_2').html(data)

			});
		}


		function setCveAmtInTcDet() {

			console.log('check', $('#txtHireRate_1').val())
			console.log('check123', $('#dummyHireRate').val())


			$('#txtHireargeCVE').val($('#txtCVE').val());

			$('#txtHireargePercent').val($('#dummyAdcom').val());

			$('#txtHireRate_1').val($('#dummyHireRate').val());
			$('#txtBallastBonus').val($('#dummyBB').val());

			$('#txtHireargeBroPercent').val($('#dummyBrokerage').val());


			getFinalCalculation();
		}



		function setRequired(elx) {


			if ($(elx).val() != '') {

				$($(elx).parent().next().next().next().find('select')).attr("required", "true");

			} else {

				$($(elx).parent().next().next().next().find('select')).prop('required', false);

			}

		}


		function setCalloadable(elx) {


			var checkCargo = $(elx).parent().prev().prev().prev().find('select').val();
			var Cargoname = $(elx).parent().prev().prev().prev().find('select option:selected').text();

			var id = $(elx).data('rotationid');

			// // console.log(id);

			if ($("#selFPort_" + id).val() == '' || $("#selTPort_" + id).val() == '' || checkCargo.length == 0) {
				jAlert('Please select From Port/To Port/Cargo', 'Alert');

			} else {


				$('#compose-modal_CalLoadable').modal('show');

				if ($(elx).data('porttype') == 'lp') {

					var port = $("#selFPort_" + id).select2('data').name;
					$('#txt_port_load').val(port);
					$('#txtCargoName').val(Cargoname);


				}
				if ($(elx).data('porttype') == 'dp') {

					var port = $("#selTPort_" + id).select2('data').name;
					$('#txt_port_load').val(port);
					$('#txtCargoName').val(Cargoname);

				}


			}

		}

		const debounce = (func, wait) => {
			let timeout;

			return function executedFunction(...args) {
				const later = () => {
					clearTimeout(timeout);
					func(...args);
				};

				clearTimeout(timeout);
				timeout = setTimeout(later, wait);
			};
		};


		$('#checkViaDrat').on('ifChecked', function() {

			setCalForCargoCalLoad();

		});


		$('#checkViaStowage').on("ifChecked", function() {

			setCalForCargoCalLoad();
		});


		function setCalForCargoCalLoad() {

			debounce(function() {
				if ($('#checkViaDrat').is(':checked')) {

					var sinkage = 0.00;
					var sinkageBi = 0.00;
					if ($('#txt_Port_Max_Daft').val() < $('#txtSummerDraft').val()) {

						$('#txtDraft_m').val($('#txt_Port_Max_Daft').val())
						$('#txt_oberseved_draft').val($('#txt_Port_Max_Daft').val())

						sinkage = $('#txt_Port_Max_Daft').val();
						sinkageBi = $('#txtSummerDraft').val();
					} else {
						$('#txtDraft_m').val($('#txtSummerDraft').val())
						$('#txt_oberseved_draft').val($('#txtSummerDraft').val())
						sinkage = $('#txtSummerDraft').val();
						sinkageBi = $('#txt_Port_Max_Daft').val();
					}

					// console.log(parseFloat($('#txt_Port_Max_Daft').val())<parseFloat($('#txtSummerDraft').val()));

					// console.log('check',$('#txt_Port_Max_Daft').val())
					// console.log('check2',$('#txtSummerDraft').val())

					var sinkageThus = (parseFloat(sinkageBi) - parseFloat(sinkage)) * 100;

					var txtTcP_TSCM = parseFloat($('#txtTcP_TSCM').val());
					if (isNaN(txtTcP_TSCM)) {
						txtTcP_TSCM = 0;
					}

					var ttlLessCargo = parseFloat(txtTcP_TSCM) * sinkageThus;


					if ($('#displayWaterDens').val() == '1.025') {

						$('#txt_cargo_load').val($('#txtSummer_DWT').val() - $('#txtConstant_mt').val() - $('#txt_bunkers_on_b_mt').val() - $('#txt_FW_MT').val() - parseFloat(ttlLessCargo));

						$('#txt_obser_DWT').val((parseFloat($('#txtSummer_DWT').val()) - parseFloat(ttlLessCargo)).toFixed(2));

					} else {

						var waterDensity = parseFloat($('#displayWaterDens').val());
						var mulWaterDen = waterDensity / 1.025;

						$('#txt_cargo_load').val((($('#txtSummer_DWT').val() - $('#txtConstant_mt').val() - $('#txt_bunkers_on_b_mt').val() - $('#txt_FW_MT').val() - parseFloat(ttlLessCargo)) * parseFloat(mulWaterDen)).toFixed(2));

						$('#txt_obser_DWT').val(parseFloat((($('#txtSummer_DWT').val()) - parseFloat(ttlLessCargo)) * parseFloat(mulWaterDen)).toFixed(2));

					}


				}

				if ($('#checkViaStowage').is(':checked')) {

					if ($('#txt_Port_Max_Daft').val() < $('#txtSummerDraft').val()) {

						$('#txtDraft_m').val($('#txt_Port_Max_Daft').val())
						$('#txt_oberseved_draft').val($('#txt_Port_Max_Daft').val())
					} else {
						$('#txtDraft_m').val($('#txtSummerDraft').val())
						$('#txt_oberseved_draft').val($('#txtSummerDraft').val())
					}

					// console.log(parseFloat($('#txt_Port_Max_Daft').val())<parseFloat($('#txtSummerDraft').val()));

					// console.log('check',$('#txt_Port_Max_Daft').val())
					// console.log('check2',$('#txtSummerDraft').val())

					var txtCubicCap = parseFloat($('#txtCubicCap').val());
					if (isNaN(txtCubicCap)) {
						txtCubicCap = 0;
					}
					var txtstowageDacCum = parseFloat($('#txtstowageDacCum').val());
					if (isNaN(txtstowageDacCum)) {
						txtstowageDacCum = 0;
					}

					$('#txt_cargo_load').val((parseFloat(txtCubicCap) / parseFloat(txtstowageDacCum)).toFixed(2));

					var txt_cargo_load = parseFloat($('#txt_cargo_load').val());
					if (isNaN(txt_cargo_load)) {
						txt_cargo_load = 0;
					}

					$('#txt_obser_DWT').val((parseFloat(txt_cargo_load) + parseFloat($('#txtConstant_mt').val()) + parseFloat($('#txt_bunkers_on_b_mt').val()) + parseFloat($('#txt_FW_MT').val())).toFixed(2));

				}
			}, 500).call();



			// getFinalCalculation();
		}


		function setBlQuant() {

			$("[id^=txtQMT_]").val($('#txt_cargo_load').val());
			$("[id^=txtDQMT_]").val($('#txt_cargo_load').val());
			$("#txtBLCQMT").val($('#txt_cargo_load').val());
			getFinalCalculation();
		}

		function setCalForCargoCalLoadViaStowage() {

			// $('#checkViaDrat').prop('checked', true);

			debounce(function() {

				if ($('#txt_Port_Max_Daft').val() < $('#txtSummerDraft').val()) {

					$('#txtDraft_m').val($('#txt_Port_Max_Daft').val())
					$('#txt_oberseved_draft').val($('#txt_Port_Max_Daft').val())
				} else {
					$('#txtDraft_m').val($('#txtSummerDraft').val())
					$('#txt_oberseved_draft').val($('#txtSummerDraft').val())
				}

				// console.log(parseFloat($('#txt_Port_Max_Daft').val())<parseFloat($('#txtSummerDraft').val()));

				// console.log('check',$('#txt_Port_Max_Daft').val())
				// console.log('check2',$('#txtSummerDraft').val())

				var txtCubicCap = parseFloat($('#txtCubicCap').val());
				if (isNaN(txtCubicCap)) {
					txtCubicCap = 0;
				}
				var txtstowageDacCum = parseFloat($('#txtstowageDacCum').val());
				if (isNaN(txtstowageDacCum)) {
					txtstowageDacCum = 0;
				}

				$('#txt_cargo_load').val(parseFloat(txtCubicCap) / parseFloat(txtstowageDacCum));

				var txt_cargo_load = parseFloat($('#txt_cargo_load').val());
				if (isNaN(txt_cargo_load)) {
					txt_cargo_load = 0;
				}

				$('#txt_obser_DWT').val(parseFloat(txt_cargo_load) + parseFloat($('#txtConstant_mt').val()) + parseFloat($('#txt_bunkers_on_b_mt').val()) + parseFloat($('#txt_FW_MT').val()));


			}, 500).call();

		}
	</script>
	<!-------------------------------------------------- DPK ------------------------------------------------------------->

	<script>
		function toggleSpeedFields() {
			var speedType = document.getElementById('speedType').value;


			document.querySelectorAll('.speed-col').forEach(function(col) {
				col.style.display = 'none';
			});


			document.querySelectorAll('.' + speedType + '-speed').forEach(function(col) {
				col.style.display = 'table-cell';
			});


			var tables = document.querySelectorAll('table');

			tables.forEach(function(table) {
				table.classList.remove('show-full-speed', 'show-service-speed', 'show-eco-speed');
				table.classList.add('show-' + speedType + '-speed');
			});


		}

		const euCountries = new Set([
			'AUT', 'BEL', 'BGR', 'HRV', 'CYP', 'CZE',
			'DNK', 'EST', 'FIN', 'FRA', 'DEU', 'GRC',
			'HUN', 'IRL', 'ITA', 'LVA', 'LTU', 'LUX',
			'MLT', 'NLD', 'POL', 'PRT', 'ROU', 'SVK',
			'SVN', 'ESP', 'SWE', 'ISL', 'LIE', 'NOR'
		]);



		function calculateSeaLegPercentage(fromCountry, toCountry) {

			console.log('fromCountry', fromCountry);
			console.log('toCountry', toCountry);
			const fromEU = euCountries.has(fromCountry);
			const toEU = euCountries.has(toCountry);

			if (fromEU && toEU) {
				return 1;
			} else if (!fromEU && toEU) {
				return 0.5;
			} else if (fromEU && !toEU) {
				return 0.5;
			} else {
				return 0;
			}
		}



		function calculatePortLegPercentage(fromCountry, toCountry) {

			console.log('fromCountry', fromCountry);
			console.log('toCountry', toCountry);
			const fromEU = euCountries.has(fromCountry);
			const toEU = euCountries.has(toCountry);

			if (fromEU && toEU) {
				return 1;
			} else if (!fromEU && toEU) {
				return 1;
			} else if (fromEU && !toEU) {
				return 1;
			} else {
				return 0;
			}
		}





		function extractCountryCodeFromSelect2(id) {
			const element = document.querySelector(`#${id} .select2-chosen`);
			if (!element) return null;

			const text = element.textContent.trim();
			const match = text.match(/\(([^)]+)\)$/);

			return match ? match[1] : null;
		}



		function isEU(countryCode) {
			return euCountries.has(countryCode);
		}



		document.addEventListener('DOMContentLoaded', function() {
			toggleSpeedFields();
		});
	</script>

</body>

</html>