<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
$page 	= $_REQUEST['page'];
$coaid 	= $_REQUEST['coaid'];

if(@$_REQUEST['action'] == 'submit')
{
	$msg = $obj->insertCOAestimatesDetails();
	header('Location:./coa_list.php?msg='.$msg);
}

if(isset($_REQUEST['estimatetype']) && $_REQUEST['estimatetype']!="")
{
	$estimatetype = $_REQUEST['estimatetype'];
	$_SESSION['selBType'] = $_REQUEST['estimatetype'];
}
else
{
    $estimatetype = $_SESSION['selBType'];
}

$result = mysql_query("select * from coa_master where COAID='".$coaid."'") or die;
$rows   = mysql_fetch_assoc($result);

$rdoQtyType = 1;
$rdoQtyMar = 1;

$pagename = basename($_SERVER['PHP_SELF'])."?coaid=".$coaid."&page=".$page;
$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(); ?>
<?php $display->js(); ?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
<style>
.animated {
	vertical-align: top; 
	transition: height 0.2s;
	-webkit-transition: height 0.2s; 
	-moz-transition: height 0.2s; 
}

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

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

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


.input 
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: normal;
color: #333333;
text-decoration: none;
}
</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(20); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                 <section class="content-header">
                    <h1>
                        <i class="fa fa-leaf"></i>&nbsp;COA 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">COA Estimates</li>
                    </ol>
                </section>
                <div align="right" style="margin-top:5px;margin-bottom:5px;margin-right:5px;">
				<a href="coa_list.php"><button class="btn btn-info btn-flat">Back</button></a>
				</div>
      <form role="form" name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">
                <table width="100%" style="margin-bottom:5px; padding:0px 5px 0px 5px;">
                   <tr>
                       <td width="12%" class="input-text" style="color:#175c84;"><strong >Fixture&nbsp;Type&nbsp;:</strong>&nbsp;COA&nbsp;<input type="hidden" name="selFType" id="selFType" value="2"></td>&nbsp;&nbsp;
                       <td class="input-text" style="color:#175c84;"><strong>COA&nbsp;No.:</strong><input type="text" name="txtCOAno" id="txtCOAno" style="width:100px;color:#175c84;background-color:#E1E1E1;" class="input-text" readonly value="<?php echo $rows['COA_NO']; ?>" /></td>
                       <td class="input-text" style="color:#175c84;">
                       <strong>Vessel&nbsp;:</strong><select name="selVName" class="input-text" id="selVName" style="width:120px;color:#175c84;" onChange="getData();">
                            <?php 
                            $obj->getVesselTypeListMemberWise($estimatetype);
                            ?>
                            </select>
                       </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;background-color:#E1E1E1;" class="input-text" readonly value="" />
                        <select  name="selCharterer" style="display:none;"  id="selCharterer">
                        <?php $obj->getVendorListNewForCOA('7,11,10');?>
                        </select> 
                        <select  name="selVendor" style="display:none;"  id="selVendor">
                        <?php $obj->getVendorListNewUpdate();	?>
                        </select> 
                        <select  name="selPort" style="display:none;" id="selPort">
                            <?php $obj->getPortList(); ?>
                        </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>
                       </td>
                       <td class="input-text" style="color:#175c84;"><strong>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="" autocomplete="off" placeholder"" /></td>
                   </tr>
               </table>
                <div id="tabs" class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tabs_1" data-toggle="tab">Voyage Financials : Estimate</a></li>
                        <li><a href="#tabs_3" data-toggle="tab">Commercial Parameters</a></li>
                    </ul>
                    
                    <div class="tab-content">
   <!------------------------- Start 1----MAIN CARGO DETAILS------------------------------>
                    <div id="tabs_1" class="tab-pane active" style="overflow:auto;">
                       <table class='tablesorter' width="100%">
						  <tr><td><strong style="font-size:12px;">Main Cargo Details</strong></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(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;"><a href="#tb1" onClick="deleteMainCargoDetails(1);" ><i class="fa fa-times" style="color:red;"></i></a></td>
							   <td><select name="selCharterers_1" class="input-text" style="width:120px;" id="selCharterers_1" onChange="getFinalCalculation();"></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());</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><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(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><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());</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><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(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><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());</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><span id="spancargoCBM3"></span></td>
					   <td><span id="spancargoMT3"></span></td>
					   <td></td>
					   <td><span id="spanAmountUSD3"></span></td>
					  </tr>
					</tfoot>
				</table>
             </div>
					
					
					
					
					
					
                    <div id="tabs_3" class="tab-pane">
                         <table width="100%" style="margin-top:2px;">
                           <tr>
                               <td class="input-text">&nbsp;DWT<span style="font-size:10px; font-style:italic;">(Summer)</span>&nbsp;:&nbsp;<input type="text" name="txtDWTS" id="txtDWTS" style="width:90px;" class="input-text" autocomplete="off" readonly value="" 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 cellpadding="1" cellspacing="1" border="0" width="100%"  class='tablesorter' >
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" ></td></tr>	
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" >
						<table width="100%" cellpadding="1" cellspacing="1" border="0">
						<thead>
                        <tr>
						<td width="25%" align="left" class="text">GRT&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>
						<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%" cellpadding="1" cellspacing="1" border="0">
						<thead>
						<tr>
						<td width="45%" align="left" class="text" style="color:#dc631e;">FO Consumption MT/Day</td>
						<td width="20%" align="right" valign="top" class="text" style="color:#1b77a6;">Full Speed</td>
						<td width="17%" align="right" valign="top" class="text" style="color:#1b77a6;">Service Speed</td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text" style="color:#1b77a6;">Most Eco Speed</td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</thead>
						<tbody>
						<tr>
						<td width="45%" align="left" class="input-text">Ballast Passage</td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtBFOFullSpeed" id="txtBFOFullSpeed" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtBFOEcoSpeed1" id="txtBFOEcoSpeed1" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"><input type="text" name="txtBFOEcoSpeed2" id="txtBFOEcoSpeed2" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						<tr>
						<td width="45%" align="left" class="input-text">Laden Passage</td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtLFOFullSpeed" id="txtLFOFullSpeed" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtLFOEcoSpeed1" id="txtLFOEcoSpeed1" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"><input type="text" name="txtLFOEcoSpeed2" id="txtLFOEcoSpeed2" style="width:190px;" class="input-text"  value=""  onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						<tr>
						<td colspan="7" align="left" class="text">
						<table width="100%" cellpadding="1" cellspacing="1" border="0">
						<thead>
						<tr>
						<td width="45%" align="left" class="text"></td>
						<td width="20%" align="right" valign="top" class="text">In Port - Idle</td>
						<td width="17%" align="right" valign="top" class="text">In Port - Working</td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</thead>
						<tbody>
						<tr>
						<td width="45%" align="left" class="text"></td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtPIFOFullSpeed" id="txtPIFOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtPWFOFullSpeed" id="txtPWFOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</tbody>
						</table>
						</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%" cellpadding="1" cellspacing="1" border="0">
						<thead>
						<tr>
						<td width="45%" align="left" class="text" style="color:#dc631e;">DO Consumption per MT/Day</td>
						<td width="20%" align="right" valign="top" class="text" style="color:#1b77a6;">Full Speed</td>
						<td width="17%" align="right" valign="top" class="text" style="color:#1b77a6;">Service Speed</td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text" style="color:#1b77a6;">Most Eco Speed</td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</thead>
						<tbody>
						<tr>
						<td width="45%" align="left" class="input-text">Ballast Passage</td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtBDOFullSpeed" id="txtBDOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtBDOEcoSpeed1" id="txtBDOEcoSpeed1" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"><input type="text" name="txtBDOEcoSpeed2" id="txtBDOEcoSpeed2" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						<tr>
						<td width="45%" align="left" class="input-text">Laden Passage</td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtLDOFullSpeed" id="txtLDOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtLDOEcoSpeed1" id="txtLDOEcoSpeed1" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"><input type="text" name="txtLDOEcoSpeed2" id="txtLDOEcoSpeed2" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						
						<tr>
						<td colspan="7" align="left" class="text">
						<table width="100%" cellpadding="1" cellspacing="1" border="0">
						<thead>
						<tr>
						<td width="45%" align="left" class="text"></td>
						<td width="20%" align="right" valign="top" class="text">In Port - Idle</td>
						<td width="17%" align="right" valign="top" class="text">In Port - Working</td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</thead>
						<tbody>
						<tr>
						<td width="45%" align="left" class="text"></td>
						<td width="20%" align="right" valign="top" class="text"><input type="text" name="txtPIDOFullSpeed" id="txtPIDOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="17%" align="right" valign="top" class="text"><input type="text" name="txtPWDOFullSpeed" id="txtPWDOFullSpeed" style="width:190px;" class="input-text"  value="" onKeyUp="getVoyageTime();" placeholder="0.00"/></td>
						<td width="1%" align="left" class="text"></td>
						<td width="16%" align="right" valign="top" class="text"></td>
						<td width="1%" align="left" class="text"></td>
						</tr>
						</tbody>
						</table>
						</td>
						</tr>
						</tbody>
						</table>
						
						</td></tr>	
						
						<tr height="10"><td colspan="10" align="left" class="text" valign="top" ></td></tr>	
						</table>
                    </div>
                   </div><!-- /.tab-content -->
                </div>
                <div style="text-align:center;">
                <input type="hidden" name="txtCRMFILE" id="txtCRMFILE" value="" />
							<input type="hidden" name="txtCRMNAME" id="txtCRMNAME" value="" />
                            <input type="hidden" name="txtCRMFILE1" id="txtCRMFILE1" value="" />
					        <input type="hidden" name="txtCRMNAME1" id="txtCRMNAME1" value="" />
                            <button type="submit" class="btn btn-primary btn-flat" onClick="return getValidate();">Submit</button>
							<input type="hidden" name="action" id="action" value="submit" /><input type="hidden" name="vesselrec" id="vesselrec" class="input-text" value="" /></div>
                <!-- Main content -->
                
                </form>
            </aside><!-- /.right-side -->
			
        </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 language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script src="../../js/timer.js" type="text/javascript"></script>
<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/bootstrap-datepicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.numeric.js"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.calculation-min.js"></script>
<script type='text/javascript' src='../../js/jquery.simplemodal.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" />
<script type="text/javascript">
$(document).ready(function(){ 
$('#txtDistributedRemarks').autosize({append: "\n"});
$("#selCName,#selMType").chosen();
$("#frm1").validate({
	rules: {
		txtENo:"required",
		selVName:"required"
		},
	messages: {
		selVName:"*",
		},
submitHandler: function(form)  {
	jConfirm('Are you sure you have checked each entry ?', 'Confirmation', function(r) {
			if(r){
				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^=txtCargocbm_],[id^=txtCargomt_],[id^=txtRateUSDmt_],[id^=txtAmountUSD_],[id^=txtCargocbm2_],[id^=txtCargomt2_],[id^=txtRateUSDmt2_],[id^=txtAmountUSD2_],[id^=txtCargocbm3_],[id^=txtCargomt3_],[id^=txtRateUSDmt3_],[id^=txtAmountUSD3_],[id^=txtMinTotalDis_],[id^=txtMinAmount_],[id^=txtCargocbm_],[id^=txtOveFlatRateQty_],[id^=txtOveWSQty_],[id^=txtOveTotalDis_],[id^=txtOveAmount_],[id^=txtTotalTankQty_],[id^=txtOveDisLeg_],#txtLumpsumQty,#txtLumpsum").numeric();
$("#txtDate,#txtCPDate,#txtETADate").datepicker({
	format: 'dd-mm-yyyy',
	autoclose: true
});




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

$('#ChkLumpsum').on('ifChecked', function () { 
    $("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").show();
	$("#maincargodetail").hide();
	getFinalCalculation();
});

$('#ChkLumpsum').on('ifUnchecked', function () { 
    $("#lumpsumspan1,#lumpsumspan2,#lumpsumspan3,#lumpsumspan4").hide();
	$("#maincargodetail").show();
	getFinalCalculation();
});

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

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

<?php
$sql = "SELECT * FROM bunker_grade_master where MODULEID='".$_SESSION['moduleid']."' AND MCOMPANYID='".$_SESSION['company']."' and 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;?>);
$(".navbar-btn").on('click',function(){getDivwidthAsParent(2)});
getDivwidthAsParent(1);

});

function getValue()
{
	
}


function showHideEstimateTypeDiv(val)
{
	if($("#rdoEstimateType").val()==1)
	{
		$("#distypeDiv3,#distypeDiv,#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();
		$("#distypeDiv").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)
	{
		$("#distypeDiv,#distypeDiv1").hide();
		$("#distypeDiv3,#tankgasnot1,#tankgasnot2,#tankgasnot3,#tankgasnot4").show();
		$("#loadtablelebel").html('(MT/Day)');
	    $("#dischargetablelebel").html('(MT/Day)');
		$("#loadqtylabel,#dischargeqtylabel").html('(MT)');
		if(val==2)
		{
			$('#selCName option:selected').removeAttr("selected");
			$('#selMType option:selected').removeAttr("selected");
			$('#selCName,#selMType').html($('#selMaterial3').html());
			$('#selCName,#selMType').trigger("liszt:updated");
			$("#selCName,#selMType").chosen();
		}
	}
}

function getDivwidthAsParent(val)
{
	if(val==1)
	{
	    var widths = parseInt($('#parenttdID').width());
	    $("#bunkercontainer").css( "maxWidth", widths+"px" );
		$("#txtBunkerWidth").val(widths);
	}
	else
	{
		var widthidentity = $("#txtBunkerWidth1").val();
		if(widthidentity == 1)
		{
			var widths = $('#parenttdID').width();
			$("#bunkercontainer").css( "maxWidth", widths+"px" );
			$("#txtBunkerWidth1").val(2);
		}
		else
		{
			var widths = $('#txtBunkerWidth').val();
			$("#bunkercontainer").css( "maxWidth", widths+"px" );
			$("#txtBunkerWidth1").val(1);
		}
	}
}

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

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


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

function getData()
{
	  if($("#selVName").val()!="")
	  {
		  $.post("options.php?id=42",{vessel1d:""+$("#selVName").val()+""}, function(data) 
			{
				    var vsldata = JSON.parse(data);
					$.each(vsldata[$("#selVName").val()], function(index, array) {
					if(array['num'] == "" || array['num']==0)
					{
						jAlert('Please ensure commercial parameters are completed before proceeding', 'Alert', function(r) {
						if(r){ 
							window.location="commercial_parameter.php?id="+$("#selVName").val();
							}
							else{return false;}
							});	
					}
					else
					{
						$('#txtVType').val(array['type']);
						$('#txtDWTS').val(array['dwtsum']);
						$('#txtGCap').val(array['grain']);
						$('#txtBCap').val(array['bale']);
						
						$('#txtBFullSpeed').val(array['bfs']);
						$('#txtBEcoSpeed1').val(array['bes1']);
						$('#txtBEcoSpeed2').val(array['bes2']);
						$('#txtBFOFullSpeed').val(array['fobfs']);
						$('#txtBFOEcoSpeed1').val(array['fobes1']);
						$('#txtBFOEcoSpeed2').val(array['fobes2']);
						$('#txtBDOFullSpeed').val(array['dobfs']);
						$('#txtBDOEcoSpeed1').val(array['dobes1']);
						$('#txtBDOEcoSpeed2').val(array['dobes2']);
						
						$('#txtLFullSpeed').val(array['lfs']);
						$('#txtLEcoSpeed1').val(array['les1']);
						$('#txtLEcoSpeed2').val(array['les2']);
						$('#txtLFOFullSpeed').val(array['folfs']);
						$('#txtLFOEcoSpeed1').val(array['foles1']);
						$('#txtLFOEcoSpeed2').val(array['foles2']);
						$('#txtLDOFullSpeed').val(array['dolfs']);
						$('#txtLDOEcoSpeed1').val(array['doles1']);
						$('#txtLDOEcoSpeed2').val(array['doles2']);
						
						$('#txtPIFOFullSpeed').val(array['foidle']);
						$('#txtPWFOFullSpeed').val(array['fwking']);
						$('#txtPIDOFullSpeed').val(array['ddle']);
						$('#txtPWDOFullSpeed').val(array['dwking']);
						$('#vesselrec').val(array['num']);
						$('#txtFlag').val(array['flag']);
						$('#txtBuiltYear').val(array['year']);
						$('#txtGNRT').val(array['gnrt']);
						$('#txtLOA').val(array['loa']);
						$('#txtGear').val(array['gear']);
						$('#txtBeam').val(array['beam']);
						$('#txtTPC').val(array['tpc']);
						//$("#rdoEstimateType").val(array['btype']);
						$("#cargotypespan").html(array['btypename']);
						showHideEstimateTypeDiv(2);
						getVoyageTime();
					}
				});
			});  
	  }
	  else
	  {
		  $('#txtVType,#txtDWTS,#txtGCap,#txtBCap,#txtBFullSpeed,#txtBEcoSpeed1,#txtBEcoSpeed2,#txtBFOFullSpeed,#txtBFOEcoSpeed1,#txtBFOEcoSpeed2,#txtBDOFullSpeed,#txtBDOEcoSpeed1,#txtBDOEcoSpeed2,#txtLFullSpeed,#txtLEcoSpeed1,#txtLEcoSpeed2,#txtLFOFullSpeed,#txtLFOEcoSpeed1,#txtLFOEcoSpeed2,#txtLDOFullSpeed,#txtLDOEcoSpeed1,#txtLDOEcoSpeed2,#txtPIFOFullSpeed,#txtPWFOFullSpeed,#txtPIDOFullSpeed,#txtPWDOFullSpeed,#vesselrec,#txtFlag,#txtGear,#txtBuiltYear,#txtGNRT,#txtLOA,#rdoEstimateType').val("");
	  }
}



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);
		$("#txtDFQMT,#txtAddnlQMT").val("");
		$("#txtDFQMT").focus();
	}
	if(val == 2)
	{
		$("#txtDFQMT").attr('disabled',true);
		$("#txtAddnlQMT").removeAttr('disabled');
		$("#txtDFQMT,#txtAddnlQMT").val("");
		$("#txtAddnlQMT").focus();
	}
	getFinalCalculation();
}


function getBunkerCalculation()
{
	    var noOfBunker = $("#txtBunkerRec").val();
		var sum = "";
		for(var i=1;i<=noOfBunker;i++)
		{
		   var bunkergrade = $("#txtBunkerGradeName_"+i).val();
		   var bunkergradetype = $("#txtBunkerGradeType_"+i).val();
		   var str = bunkergradetype.substr(0,3);
		   if(str == 'IFO')
			{
					$("#txt"+bunkergrade+"_1_1").val($("#txtTFUMT").val());
			}
			else if(str == 'MDO')
			{
					$("#txt"+bunkergrade+"_1_1").val($("#txtTDUMT").val());
			}
			else if(str == 'MGO')
			{
					$("#txt"+bunkergrade+"_1_1").val($("#txtTDUMT").val());
			}
			else
			{
				$("#txt"+bunkergrade+"_1_1").val('0.00');
			}
			
			var var3 = $("#txt"+bunkergrade+"_1_1").val();
			if(var3 == ""){var first = 0;}else{var first = var3;}
			if($("#txt"+bunkergrade+"_1_2").val() == ""){var second = 0;}else{var second = $("#txt"+bunkergrade+"_1_2").val();}
			var calc = parseFloat(first) * parseFloat(second);
			$("#txt"+bunkergrade+"_1_3").val(calc.toFixed(2));
			$("#txtBunkerCost_"+bunkergrade).val($("#txt"+bunkergrade+"_1_3").val());
		}
		$("#txtTotalBunkerCost").val($("[id^=txtBunkerCost_]").sum().toFixed(2));
	getFinalCalculation();
}


function getDistance(i)
{
	
		$("#txtDistance_"+i).val("");
		$("#ploader_"+i).show();
		var loadporttext = disporttext = "";
		if($("#selFPort_"+i).val()!=""){loadporttext = $("#selFPort_"+i+" option:selected").text();}else{loadporttext = "";}
		if($("#selTPort_"+i).val()!=""){disporttext = $("#selTPort_"+i+" option:selected").text();}else{disporttext = "";}
		$("#spanLoadPort_"+i).html(loadporttext);
		$("#spanDisPort_"+i).html(disporttext);
		$("#TranDisPort_"+i).html(loadporttext);
		$("#spanDDCLPort_"+i).html(loadporttext);
		$("#spanDDCDPort_"+i).html(disporttext);
		if($('#selFPort_'+i).val() != "" && $('#selTPort_'+i).val() != "" && $('#selDType_'+i).val() != "")
		{
			$("#txtDistance_"+i).val(0);
			$.post("options.php?id=10",{selFPort:""+$("#selFPort_"+i).val()+"",selTPort:""+$("#selTPort_"+i).val()+"",selDType:""+$("#selDType_"+i).val()+""}, function(data) 
			{
					$('#txtDistance_'+i).val(data);
					$("#ploader_"+i).hide();
					getVoyageTime();
			});
		}
		else
		{
			$('#txtDistance_'+i).val(0);
			$("#ploader_"+i).hide();
			getVoyageTime();
		}
}

function getVoyageTime()
{
	var id = $("#p_rotationID").val();
	$("#txtBDays,#txtLDays").val(0);
	$("#txtLDist,#txtBDist,#txtTDUMT,#txtTFUMT").val(0);
	var ladendays = ballastdays = idealdays = workingdays = consumptiondo = consumptionfo =  0;
	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($("#txtWeather_"+i).val() == ""){var speed_adj = 0;}else{var speed_adj = $("#txtWeather_"+i).val();}
		if($("#selPType_"+i).val() == 1)
		{
			if($("#selSSpeed_"+i).val() == 1)
			{
				var ballast = $("#txtBFullSpeed").val();
				var fo_ballast = $("#txtBFOFullSpeed").val();
				var do_ballast = $("#txtBDOFullSpeed").val();
			}
			if($("#selSSpeed_"+i).val() == 2)
			{
				var ballast = $("#txtBEcoSpeed1").val();
				var fo_ballast = $("#txtBFOEcoSpeed1").val();
				var do_ballast = $("#txtBDOEcoSpeed1").val();
			}
			if($("#selSSpeed_"+i).val() == 3)
			{
				var ballast = $("#txtBEcoSpeed2").val();
				var fo_ballast = $("#txtBFOEcoSpeed2").val();
				var do_ballast = $("#txtBDOEcoSpeed2").val();
			}
			var spd = ($("#txtDistance_"+i).val() /  (parseFloat(ballast) + parseFloat(speed_adj)));
			var calc = spd/24;
			var ttl_days = parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100);
			ballastdays = ballastdays + parseFloat(ttl_days.toFixed(3));
		
			var consp_fo = parseFloat((parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100)) *  parseFloat(fo_ballast));
			var consp_do = parseFloat((parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100)) *  parseFloat(do_ballast));	
			if(isNaN(consp_do) || consp_do=="")
	        {consp_do = 0;	}
			if(isNaN(consp_fo) || consp_fo=="")
	        {consp_fo = 0;	}
			consumptiondo = parseFloat(consumptiondo) + parseFloat(consp_do.toFixed(2));
			consumptionfo = parseFloat(consumptionfo) + parseFloat(consp_fo.toFixed(2));
			
			var ttl_dis = parseFloat(distance) + parseFloat($("#txtBDist").val());
			$("#txtBDist").val(ttl_dis.toFixed(2));
			$("#txtTDist").val($("#txtBDist,#txtLDist").sum().toFixed(2));
		}
		if($("#selPType_"+i).val() == 2)
		{
			if($("#selSSpeed_"+i).val() == 1)
			{
				var ladan = $("#txtLFullSpeed").val();
				var fo_ladan = $("#txtLFOFullSpeed").val();
				var do_ladan = $("#txtLDOFullSpeed").val();
			}
			if($("#selSSpeed_"+i).val() == 2)
			{
				var ladan = $("#txtLEcoSpeed1").val();
				var fo_ladan = $("#txtLFOEcoSpeed1").val();
				var do_ladan = $("#txtLDOEcoSpeed1").val();
			}
			if($("#selSSpeed_"+i).val() == 3)
			{
				var ladan = $("#txtLEcoSpeed2").val();
				var fo_ladan = $("#txtLFOEcoSpeed2").val();
				var do_ladan = $("#txtLDOEcoSpeed2").val();
			}
			
			var spd = ($("#txtDistance_"+i).val() /  (parseFloat(ladan) + parseFloat(speed_adj)));
			var calc = spd/24;
			var ttl_days = parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100);
			ladendays = parseFloat(ladendays) + parseFloat(ttl_days.toFixed(3));
			
			var consp_fo = parseFloat((parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100)) *  parseFloat(fo_ladan));
			var consp_do = parseFloat((parseFloat(calc) + parseFloat(parseFloat(parseFloat(calc)*parseFloat(margin))/100)) *  parseFloat(do_ladan));
			if(isNaN(consp_do) || consp_do=="")
	        {consp_do = 0;	}
			if(isNaN(consp_fo) || consp_fo=="")
	        {consp_fo = 0;	}	
			consumptiondo = parseFloat(consumptiondo) + parseFloat(consp_do.toFixed(2));
			consumptionfo = parseFloat(consumptionfo) + parseFloat(consp_fo.toFixed(2));
			
			var ttl_dis = parseFloat(distance) + parseFloat($("#txtLDist").val());
			$("#txtLDist").val(ttl_dis.toFixed(2));
			$("#txtTDist").val($("#txtBDist,#txtLDist").sum().toFixed(2));
		}
		
		
		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);

		var margin_fo = parseFloat(idle_days) * parseFloat($("#txtPIFOFullSpeed").val());
		var wrkingdays_fo = parseFloat(w_days) * parseFloat($("#txtPWFOFullSpeed").val());
		var consp_fo =  parseFloat(margin_fo.toFixed(2)) + parseFloat(wrkingdays_fo.toFixed(2));
		
		var margin_do = parseFloat(idle_days) * parseFloat($("#txtPIDOFullSpeed").val());
		var wrkingdays_do = parseFloat(w_days) * parseFloat($("#txtPWDOFullSpeed").val());			
		var consp_do = parseFloat(margin_do.toFixed(2)) + parseFloat(wrkingdays_do.toFixed(2));	
		if(isNaN(consp_do) || consp_do=="")
		{consp_do = 0;	}
		if(isNaN(consp_fo) || consp_fo=="")
		{consp_fo = 0;	}
		consumptiondo = parseFloat(consumptiondo) + parseFloat(consp_do.toFixed(2));
		consumptionfo = parseFloat(consumptionfo) + parseFloat(consp_fo.toFixed(2));
		
		//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);
		
		var margin_fo = parseFloat(idle_days) * parseFloat($("#txtPIFOFullSpeed").val());
		var wrkingdays_fo = parseFloat(w_days) * parseFloat($("#txtPWFOFullSpeed").val());
		var consp_fo =  parseFloat(margin_fo.toFixed(2)) + parseFloat(wrkingdays_fo.toFixed(2));
		
		var margin_do = parseFloat(idle_days) * parseFloat($("#txtPIDOFullSpeed").val());
		var wrkingdays_do = parseFloat(w_days) * parseFloat($("#txtPWDOFullSpeed").val());	
		var consp_do =  parseFloat(margin_do.toFixed(2)) + parseFloat(wrkingdays_do.toFixed(2));
		if(isNaN(consp_do) || consp_do=="")
		{consp_do = 0;	}
		if(isNaN(consp_fo) || consp_fo=="")
		{consp_fo = 0;	}
		consumptiondo = parseFloat(consumptiondo) + parseFloat(consp_do.toFixed(2));
		consumptionfo = parseFloat(consumptionfo) + parseFloat(consp_fo.toFixed(2));
		
		//transit 
		if($("#txtTLIDays_"+i).val() == ""){var idle_days = 0;}else{var idle_days = $("#txtTLIDays_"+i).val();}
		idealdays = parseFloat(idealdays) + parseFloat(idle_days);
		
		var margin_fo = parseFloat(idle_days) * parseFloat($("#txtPIFOFullSpeed").val());
		var margin_do = parseFloat(idle_days) * parseFloat($("#txtPIDOFullSpeed").val());
		if(isNaN(margin_do) || margin_do=="")
		{margin_do = 0;	}
		if(isNaN(margin_fo) || margin_fo=="")
		{margin_fo = 0;	}
		consumptiondo = parseFloat(consumptiondo) + parseFloat(margin_do.toFixed(2));
		consumptionfo = parseFloat(consumptionfo) + parseFloat(margin_fo.toFixed(2));
	}
	if(isNaN(consumptionfo) || consumptionfo=="")
	{consumptionfo = 0;	}
	$("#txtTFUMT").val(consumptionfo.toFixed(2));
	if(isNaN(consumptiondo) || consumptiondo=="")
	{consumptiondo = 0;	}
	$("#txtTDUMT").val(consumptiondo.toFixed(2));
	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));
	getBunkerCalculation();
}



function addPortRotationDetails()
{
	var id = idd = $("#p_rotationID").val();
	if($("#selFPort_"+id).val() != "" && $("#selTPort_"+id).val() != "" && $("#selPType_"+id).val() != "" && $("#txtDistance_"+id).val() != "" && $("#selSSpeed_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="pr_Row_'+id+'"><td align="center" class="input-text" ><a href="#pr'+id+'" id="spcancel_'+id+'" onclick="removePortRotation('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td align="left" class="input-text" ><select name="selFPort_'+id+'" style="width:100px;" class="input-text" id="selFPort_'+id+'" onChange="getDistance('+id+');"></select></td><td align="left" class="input-text" ><select  name="selTPort_'+id+'" class="input-text" style="width:100px;" id="selTPort_'+id+'" onChange="getDistance('+id+');"></select></td><td align="left" class="input-text" ><select  name="selDType_'+id+'" class="input-text" style="width:90px;" id="selDType_'+id+'" onChange="getDistance('+id+');"><?php $obj->getPortDistanceType(); ?></select></td><td align="left" class="input-text" ><select name="selPType_'+id+'" class="input-text" style="width:90px;" id="selPType_'+id+'" onChange="getVoyageTime()"; ><?php $obj->getPassageType(); ?></select></td><td align="left" class="input-text" ><input type="text" name="txtDistance_'+id+'" style="width:70px;" id="txtDistance_'+id+'" class="input-text"  value="" placeholder="0.00" onKeyUp="getVoyageTime()"; /><span id="ploader_'+id+'" style="display:none;"><img src="../../img/ajax-loader2.gif" /></span></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" ><input type="text" name="txtWeather_'+id+'" id="txtWeather_'+id+'" style="width:70px;" class="input-text" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime()"; /></td><td align="left" class="input-text" ><input type="text" name="txtMargin_'+id+'" id="txtMargin_'+id+'" style="width:70px;" class="input-text" autocomplete="off" placeholder="0.00" onKeyUp="getVoyageTime()"; /><input type="hidden" name="txtVoyageTime_'+id+'" id="txtVoyageTime_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" /><input type="hidden" name="txtTTLVoyageDays_'+id+'" id="txtTTLVoyageDays_'+id+'" class="input-text" autocomplete="off" value="" placeholder="0.00" /><input type="hidden" name="txtTTLFoConsp_'+id+'" id="txtTTLFoConsp_'+id+'" class="input-text" readonly value="0.00"  /><input type="hidden" name="txtTTLDoConsp_'+id+'" id="txtTTLDoConsp_'+id+'" class="input-text" readonly value="0.00"  /></td></tr>').appendTo("#tblPortRotation");
		
		$('<tr id="lp_Row_'+id+'"><td align="center" class="input-text" ><span id="spanLoadPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtPCosts_'+id+'" id="txtPCosts_'+id+'" class="input-text" autocomplete="off" value="" style="width:80px;" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtQMT_'+id+'" id="txtQMT_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><input type="text" name="txtRate_'+id+'" id="txtRate_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><select  name="selLPTerms_'+id+'" class="input-text" style="width:80px;" id="selLPTerms_'+id+'" onChange="getLPRemoveDaysAttr('+id+'),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select></td><td align="left" class="input-text"><input type="text" name="txtWDays_'+id+'" id="txtWDays_'+id+'" class="input-text"  style="width:80px;"  autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();"/></td><td align="left" class="input-text"><input type="text" name="txtIDays_'+id+'" id="txtIDays_'+id+'" class="input-text"  style="width:80px;"  autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input name="ChkShowDDCLP_'+id+'" class="checkbox" id="ChkShowDDCLP_'+id+'" type="checkbox" value="'+id+'"/></td></tr>').appendTo("#tblLoadPort");
		
		
		$('<tr id="dp_Row_'+id+'"><td align="center" class="input-text" ><span id="spanDisPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtDCosts_'+id+'" id="txtDCosts_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getFinalCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtDQMT_'+id+'" id="txtDQMT_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><input type="text" name="txtDRate_'+id+'" id="txtDRate_'+id+'" class="input-text" style="width:80px;" onKeyUp="getPortCalculation();" autocomplete="off" value="" placeholder="0.00" /></td><td align="left" class="input-text" ><select  name="selDPTerms_'+id+'" class="input-text" style="width:80px;" id="selDPTerms_'+id+'" onChange="getDPRemoveDaysAttr('+id+'),getPortCalculation();"><?php $obj->getLPTermsList(0);?></select></td><td align="left" class="input-text" ><input type="text" name="txtDWDays_'+id+'" id="txtDWDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" readonly value="" onKeyUp= "getVoyageTime();"/></td><td align="left" class="input-text" ><input type="text" name="txtDIDays_'+id+'" id="txtDIDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td><td align="left" class="input-text" ><input name="ChkShowDDCDP_'+id+'" class="checkbox" id="ChkShowDDCDP_'+id+'" type="checkbox" value="'+id+'"/></td></tr>').appendTo("#tblDisPort");
		
		
		$('<tr id="tp_Row_'+id+'"><td align="center" class="input-text" ><span id="TranDisPort_'+id+'"></span></td><td align="left" class="input-text" ><input type="text" name="txtTLPCosts_'+id+'" id="txtTLPCosts_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp= "getPortCalculation();"/></td><td align="left" class="input-text" ><input type="text" name="txtTLIDays_'+id+'" id="txtTLIDays_'+id+'" class="input-text" style="width:80px;" autocomplete="off" value="" placeholder="0.00" onKeyUp="getVoyageTime();"/></td></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();
		$("input[type='checkbox']").iCheck({
			checkboxClass: 'icheckbox_minimal',
			radioClass: 'iradio_minimal'
		});
		$("#selFPort_"+id+",#selTPort_"+id).html($("#selPort").html());
		$("#selFPort_"+id).val($("#selTPort_"+idd).val());
		$("#TranDisPort_"+id).html($("#selFPort_"+id+" option:selected").text());
		//.........ends...................
		$("#p_rotationID").val(id);
		if($("#selFPort_"+id).val()!=''){$("#spanLoadPort_"+id).html($("#selFPort_"+id+" option:selected").text());}
		if($("#selTPort_"+id).val()!=''){$("#spanDisPort_"+id).html($("#selTPort_"+id+" option:selected").text());}
		
		$('[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();
		});
	}
	else
	{
		jAlert('Please fill all the records for Sea Passage', 'Alert');
	}
}

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


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


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

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


function getFinalCalculation()
{
	var rev = 0;
	if($("#rdoEstimateType").val()==1)
	{
		if($("#rdoQtyMar1").is(":checked"))
		{
			var balticrate = $("#txtBalticRate").val();
			if(isNaN(balticrate) || balticrate=='')
			{balticrate = 0;}
			
			var txtAdnlPrenium = $("#txtAdnlPrenium").val();
			if(isNaN(txtAdnlPrenium) || txtAdnlPrenium=='')
			{txtAdnlPrenium = 0;}
			var summ = parseFloat(balticrate) + parseFloat(txtAdnlPrenium);
			if(isNaN(summ) || summ=='')
			{summ = 0;}
			$("#txtBaseRate").val(summ);
			
			var qty = $("#txtGasCQMT").val();
			if(isNaN(qty) || qty=='')
			{qty = 0;}
			
			rev = parseFloat(qty) * parseFloat(summ);
		}
		else
		{
			var txtGASLumpsum = parseFloat($("#txtGASLumpsum").val());
			if(isNaN(txtGASLumpsum) || txtGASLumpsum=='')
			{txtGASLumpsum = 0;}
			rev = parseFloat(txtGASLumpsum);
		}
	}
	
	
	var txtMainCargoDetailID = $("#txtMainCargoDetailID").val();
	var txtCargocbm = txtAmountUSD = txtRateUSDmt = txtCargomt = 0;
	for(var i =1;i<=txtMainCargoDetailID;i++)
	{
		if($("#selCharterers_"+i).val() != "" && $("#txtCargocbm_"+i).val() != "" && $("#txtCargocbm_"+i).val() != null )
		{
			txtCargocbm 		= parseFloat(txtCargocbm) + parseFloat($("#txtCargocbm_"+i).val());
			var txtCargomt1 	= parseFloat($("#txtCargomt_"+i).val());
			txtCargomt 			= parseFloat(txtCargomt) + parseFloat(txtCargomt1);
			var txtRateUSDmt 	= parseFloat($("#txtRateUSDmt_"+i).val());
			var amount 			= parseFloat(txtCargomt1)*parseFloat(txtRateUSDmt);
			
			if(isNaN(amount) || amount==''){amount = 0;}
			$("#txtAmountUSD_"+i).val(parseFloat(amount).toFixed(2));
			
			txtAmountUSD 		= parseFloat(txtAmountUSD) + parseFloat($("#txtAmountUSD_"+i).val());
		}
		
		if(isNaN(txtCargocbm) || txtCargocbm=='Infinity'){txtCargocbm = 0;}
		if(isNaN(txtCargomt) || txtCargomt=='Infinity'){txtCargomt = 0;}
		if(isNaN(txtAmountUSD) || txtAmountUSD=='Infinity'){txtAmountUSD = 0;}
		$("#spancargoCBM").text(txtCargocbm.toFixed(2));
		$("#spancargoMT").text(txtCargomt.toFixed(2));
		$("#spanAmountUSD").text(txtAmountUSD.toFixed(2));
	}
	
	var txtoveragedetailID = $("#txtoveragedetailID").val();
	var txtCargocbm2 = txtAmountUSD2 = txtRateUSDmt2 = txtCargomt2 = 0;
	for(var i =1;i<=txtoveragedetailID;i++)
	{
		if($("#selCharterers2_"+i).val() != "" && $("#txtCargocbm2_"+i).val() != "" && $("#txtCargocbm2_"+i).val() != null )
		{
			txtCargocbm2 		= parseFloat(txtCargocbm2) + parseFloat($("#txtCargocbm2_"+i).val());
			var txtCargomt12 	= parseFloat($("#txtCargomt2_"+i).val());
			txtCargomt2			= parseFloat(txtCargomt2) + parseFloat(txtCargomt12);
			var txtRateUSDmt2 	= parseFloat($("#txtRateUSDmt2_"+i).val());
			var amount2			= parseFloat(txtCargomt12)*parseFloat(txtRateUSDmt2);
			
			if(isNaN(amount2) || amount2==''){amount2 = 0;}
			$("#txtAmountUSD2_"+i).val(parseFloat(amount2).toFixed(2));
			
			txtAmountUSD2 		= parseFloat(txtAmountUSD2) + parseFloat($("#txtAmountUSD2_"+i).val());
		}
		
		if(isNaN(txtCargocbm2) || txtCargocbm2=='Infinity'){txtCargocbm2 = 0;}
		if(isNaN(txtCargomt2) || txtCargomt2=='Infinity'){txtCargomt2 = 0;}
		if(isNaN(txtAmountUSD2) || txtAmountUSD2=='Infinity'){txtAmountUSD2 = 0;}
		$("#spancargoCBM2").text(txtCargocbm2.toFixed(2));
		$("#spancargoMT2").text(txtCargomt2.toFixed(2));
		$("#spanAmountUSD2").text(txtAmountUSD2.toFixed(2));
	}
	
	
	var txtdeadfreightdetailID = $("#txtdeadfreightdetailID").val();
	var txtCargocbm3 = txtAmountUSD3 = txtRateUSDmt3 = txtCargomt3 = 0;
	for(var i =1;i<=txtdeadfreightdetailID;i++)
	{
		if($("#selCharterers3_"+i).val() != "" && $("#txtCargocbm3_"+i).val() != "" && $("#txtCargocbm3_"+i).val() != null )
		{
			txtCargocbm3 		= parseFloat(txtCargocbm3) + parseFloat($("#txtCargocbm3_"+i).val());
			var txtCargomt13 	= parseFloat($("#txtCargomt3_"+i).val());
			txtCargomt3			= parseFloat(txtCargomt3) + parseFloat(txtCargomt13);
			var txtRateUSDmt3 	= parseFloat($("#txtRateUSDmt3_"+i).val());
			var amount3			= parseFloat(txtCargomt13)*parseFloat(txtRateUSDmt3);
			
			if(isNaN(amount3) || amount3==''){amount3 = 0;}
			$("#txtAmountUSD3_"+i).val(parseFloat(amount3).toFixed(2));
			
			txtAmountUSD3 		= parseFloat(txtAmountUSD3) + parseFloat($("#txtAmountUSD3_"+i).val());
		}
		
		if(isNaN(txtCargocbm3) || txtCargocbm3=='Infinity'){txtCargocbm3 = 0;}
		if(isNaN(txtCargomt3) || txtCargomt3=='Infinity'){txtCargomt3 = 0;}
		if(isNaN(txtAmountUSD3) || txtAmountUSD3=='Infinity'){txtAmountUSD3 = 0;}
		$("#spancargoCBM3").text(txtCargocbm3.toFixed(2));
		$("#spancargoMT3").text(txtCargomt3.toFixed(2));
		$("#spanAmountUSD3").text(txtAmountUSD3.toFixed(2));
	}
	
	
	if($("#rdoEstimateType").val()==3)
	{
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
		if(parseFloat(cargo_qty)){var per_mt = parseFloat(cargo_qty);}
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var cargo_qty = 0;}else{var cargo_qty = $("#txtTotalFreightQty").val();}}
		if(parseFloat(cargo_qty)){var per_mt = parseFloat(cargo_qty);}
				
		if($("#txtddswCost").val() == ""){var ddsw_cost = 0;}else{var ddsw_cost = $("#txtddswCost").val();}
		if($("#txtddswAddComm").val() == ""){var ddsw_addcomm = 0;}else{var ddsw_addcomm = $("#txtddswAddComm").val();}
		var ddsw_value = parseFloat(ddsw_cost) - parseFloat((parseFloat(ddsw_cost) * parseFloat(ddsw_addcomm))/100);
		$("#txtddswValue").val(ddsw_value.toFixed(2));
		
		if($("#txtMinQMT").val() == ""){var min_qty = 0;}else{var min_qty = $("#txtMinQMT").val();}
		if($("#txtWSFR").val() == ""){var ws_flat_rate = 0;}else{var ws_flat_rate = $("#txtWSFR").val();}
		if($("#txtWSFD").val() == ""){var fixed_diff = 0;}else{var fixed_diff = $("#txtWSFD").val();}
		if($("#txtMTCPDRate").val() == ""){var ws_rate = 0;}else{var ws_rate = $("#txtMTCPDRate").val();}
		if($("#txtAddnlQMT").val() == ""){var addnl_qty = 0;}else{var addnl_qty = $("#txtAddnlQMT").val();}
		
		$("[id^=txtMinCargo_]").val(min_qty);$("[id^=txtOverage_]").val(addnl_qty);
		$("[id^=txtMCWSFlatRate_],[id^=txtOvrWSFlatRate_]").val(ws_flat_rate);
		
		$("[id^=txtTotalCargoQty_]").val(cargo_qty);
		
		<!----------------- Quantity  ------------------->
		if($("#rdoQtyType1").is(":checked"))
		{if($("#txtCQMT").val() == ""){var per_amt = 0;}else{var per_amt = $("#txtCQMT").val();}}
		if($("#rdoQtyType2").is(":checked"))
		{if($("#txtTotalFreightQty").val() == ""){var per_amt = 0;}else{var per_amt = $("#txtTotalFreightQty").val();}}
		
		if($("#rdoMMarket1").is(":checked"))
		{
			if($("#txtMTCPDRate").val() == ""){var agr_gross_fr = 0;}else{var agr_gross_fr = $("#txtMTCPDRate").val();}
			var addnlrateper = $("#txtAddnlCRatePer").val(); 
			if(isNaN(addnlrateper) || addnlrateper==''){addnlrateper = 0;}
			var addnlrate = parseFloat(parseFloat(agr_gross_fr)*parseFloat(addnlrateper))/100;
			$("#txtAddnlCRate").val(parseFloat(addnlrate).toFixed(2));
			
			var gross_fr = parseFloat(agr_gross_fr) * parseFloat(per_amt);
			$("#txtFrAdjUsdGF").val(gross_fr.toFixed(2));
			
			var gross_fr_mt = parseFloat(gross_fr) / parseFloat(per_amt);
			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_amt) + 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));
		}
		
		if($("#rdoMMarket2").is(":checked"))
		{
			$("#txtFrAdjUsdGF").val($("#txtMLumpsum").val());
			var gross_fr_mt = parseFloat($("#txtFrAdjUsdGF").val()) / parseFloat(per_amt);
			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_amt);
			if(isNaN(ttl_fr_mt) || ttl_fr_mt=='Infinity'){ttl_fr_mt = 0;}
			$("#txtFrAdjUsdTFMT").val(ttl_fr_mt.toFixed(2));
		}
		
		if($("#rdoQtyType1").is(":checked"))
		{
			if($("#txtFrAdjUsdTF").val() == ""){var ttl_fr = 0;}else{var ttl_fr = $("#txtFrAdjUsdTF").val();}
			if($("#txtFrAdjPerAgC").val() == ""){var ag_per = 0;}else{var ag_per = $("#txtFrAdjPerAgC").val();}
			var agent_commission = (parseFloat(ttl_fr) * parseFloat(ag_per)) / 100;
			$("#txtFrAdjUsdAgC").val(agent_commission.toFixed(2));
			var net_fr = parseFloat(ttl_fr) - parseFloat($("#txtFrAdjUsdAgC").sum());
			$("#txtFrAdjUsdFP").val(net_fr.toFixed(2));
			var net_fr_mt = parseFloat(net_fr) / parseFloat(per_amt);
			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;}}
	}
	
	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(txtCVE)/30)*parseFloat(txtTDays));
	if(isNaN(calmul) || calmul=="" || calmul=="Infinity"){calmul = 0;}
	$("#txtCVEAmt").val(calmul.toFixed(2));
	$("#txtHidCVEAmt").val(calmul.toFixed(2));
	
	
	if($("#txtDailyVesselOperatingExpenses").val() == ""){var daily_vessel_exp = 0;}else{var daily_vessel_exp = $("#txtDailyVesselOperatingExpenses").val();}
	var hireage_amt = parseFloat(parseFloat(daily_vessel_exp)*parseFloat($("#txtTDays").val())).toFixed(2);
	if(hireage_amt=="" || isNaN(hireage_amt)){hireage_amt =0;}
	$("#txtHireargeAmt").val(parseFloat(hireage_amt).toFixed(2));
	if($("#txtBallastBonus").val() == ""){var txtBallastBonus = 0;}else{var txtBallastBonus = $("#txtBallastBonus").val();}
	if($("#txtHireargePercent").val() == ""){var txtHireargePercent = 0;}else{var txtHireargePercent = $("#txtHireargePercent").val();}
	var ballast_hireage = parseFloat(hireage_amt) + parseFloat(txtBallastBonus);
	var txtHireargePercentAmt = parseFloat(parseFloat(parseFloat(ballast_hireage)*parseFloat(txtHireargePercent))/100);
	if(txtHireargePercentAmt=="" || isNaN(txtHireargePercentAmt)){txtHireargePercentAmt =0;}
	$("#txtHireargePercentAmt").val(parseFloat(txtHireargePercentAmt).toFixed(2));
	var txtNettHireargeAmt = parseFloat(parseFloat(ballast_hireage) -  parseFloat(txtHireargePercentAmt));
	$("#txtNettHireargeAmt").val(parseFloat(txtNettHireargeAmt).toFixed(2));	
	$("#txtTotalOperationalCost").val($("[id^=txtORCAmt_],#txtBrComm,#txtHidCVEAmt").sum());
	
	$("#txtTotalPortCost").val($("[id^=txtPCosts_],[id^=txtDCosts_],[id^=txtTLPCosts_]").sum().toFixed(2));
	
	var totalexpenses = $("#txtTotalOperationalCost,#txtTotalPortCost,#txtTotalBunkerCost").sum().toFixed(2);
	if($("#txtRevenue").val() == ""){var revenue = 0;}else{var revenue = $("#txtRevenue").val();}
	var costbeforebamarage = parseFloat(revenue) - parseFloat(totalexpenses);
	var voyage_earning = parseFloat(revenue) - parseFloat(totalexpenses) + parseFloat(getDDCOwnerCalculation());
	
	$("#txtVoyageEarnings").val(costbeforebamarage.toFixed(2));
	$("#txtGTTLVoyageEarnings").val(voyage_earning.toFixed(2));
	voyage_earning = parseFloat(voyage_earning) - parseFloat(txtNettHireargeAmt);
	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(costbeforebamarage) / parseFloat(ttl_days);
	$("#txtDailyEarnings").val(daily_earnings.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));
	
	$('[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));
			});
}



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

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

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

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

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

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

function getValidate()
{
	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 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><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="txtQtyBrokeragePer_'+id+'" id="txtQtyBrokeragePer_'+id+'" style="width:100px;" value="" onKeyUp="getQtyLocalFreightCal();" class="input-text" placeholder="0.00" /></td><td><input type="text" name="txtQtyBrokerageAmt_'+id+'" id="txtQtyBrokerageAmt_'+id+'" class="input-text" style="width:100px;" readonly value="" placeholder="0.00" /></td><td><input type="text" name="txtQtyNetFreight_'+id+'" style="width:100px;" id="txtQtyNetFreight_'+id+'" placeholder="0.00" class="input-text" readonly value="" /></td><td><input type="text"  name="txtQtyNetFreightMT_'+id+'" id="txtQtyNetFreightMT_'+id+'" class="input-text" style="width:100px;" readonly value="0.00" /></td></tr>').appendTo("#tblQtyFreight");
		$("#selQtyVendorList_"+id).html($("#selCharterer").html());
		$("#txtQTYID").val(id);
		$("[id^=txtQtyAggriedFreight_], [id^=txtFreightQty_], [id^=txtQtyBrokeragePer_], [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();	
				 }
			else{return false;}
			});
}


function getQtyLocalFreightCal()
{
	var id = $("#txtQTYID").val();
	for(var i=1;i<=id;i++)
	{
		if($("#txtQtyLocalAggriedFreight_"+i).val() == ""){var localfreightcost = 0;}else{var localfreightcost = $("#txtQtyLocalAggriedFreight_"+i).val();}
		if($("#txtDisExchangeRate_"+i).val() == ""){var txtDisExchangeRate = 0;}else{var txtDisExchangeRate = $("#txtDisExchangeRate_"+i).val();}
		var calmul = parseFloat(localfreightcost)/parseFloat(txtDisExchangeRate);
		if(isNaN(calmul) || calmul=="" || calmul=="Infinity"){calmul = 0;}
		$("#txtQtyAggriedFreight_"+i).val(calmul.toFixed(2));
		if($("#txtFreightQty_"+i).val() == ""){var txtFreightQty = 0;}else{var txtFreightQty = $("#txtFreightQty_"+i).val();}
		var calmul2 = parseFloat(calmul)*parseFloat(txtFreightQty);
		if(isNaN(calmul2) || calmul2=="" || calmul=="Infinity"){calmul2 =0;}
		$("#txtQtyFreight_"+i).val(calmul2.toFixed(2));
				
		if($("#txtQtyBrokeragePer_"+i).val() == ""){var brokrage = 0;}else{var brokrage = $("#txtQtyBrokeragePer_"+i).val();}
		var brokerage_usd = (parseFloat(calmul2) * parseFloat(brokrage))/100;
		$("#txtQtyBrokerageAmt_"+i).val(brokerage_usd.toFixed(2));
		var diff = $("#txtQtyFreight_"+i).val() - $("#txtQtyBrokerageAmt_"+i).val();
		if(diff == "" || isNaN(diff) || diff=="Infinity"){var diff = 0;}
		$("#txtQtyNetFreight_"+i).val(diff.toFixed(2));
		var qtyMT = parseFloat(diff) / parseFloat(calmul2);
		if(qtyMT == "" || isNaN(qtyMT) || qtyMT=="Infinity"){var qtyMT = 0;}
		$("#txtQtyNetFreightMT_"+i).val(qtyMT.toFixed(2));
	}
	$("#txtTotalFreightQty").val($("[id^=txtFreightQty_]").sum().toFixed(2));
	$("#txtTotalQtyFreight").val($("[id^=txtQtyFreight_]").sum().toFixed(2));
	$("#txtTotalNetBrokerage").val($("[id^=txtQtyBrokerageAmt_]").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 addMainCargoDetails()
{
	var id = $("#txtMainCargoDetailID").val();
	if($("#selCharterers_"+id).val() != "" && $("#txtCargocbm_"+id).val() != "" && $("#txtCargomt_"+id).val() != "" && $("#txtRateUSDmt_"+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><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());
	}
	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() != "" && $("#txtCargocbm2_"+id).val() != "" && $("#txtCargomt2_"+id).val() != "" && $("#txtRateUSDmt2_"+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><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());
	}
	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() != "" && $("#txtCargocbm3_"+id).val() != "" && $("#txtCargomt3_"+id).val() != "" && $("#txtRateUSDmt3_"+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><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());
	}
	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 addORCRow()
{
	var id = $("#txtOWCCount").val();
	if($("#txtHidORCID_"+id).val() != "" && $("#txtORCAmt_"+id).val() != "")
	{
		id = (id - 1) + 2;
		$('<tr id="OWCRow_'+id+'"><td><a href="#tb1" onClick="removeCC('+id+');" ><i class="fa fa-times" style="color:red;"></i></a></td><td><select name="txtHidORCID_'+id+'" id="txtHidORCID_'+id+'" style="width:130px;" ></select></td><td><input type="text" name="txtORCAmt_'+id+'" id="txtORCAmt_'+id+'" onKeyUp="getORCCalculate('+id+');" class="input-text" autocomplete="off" value="" placeholder="0.00" size="12"  /></td></tr>').appendTo("#OWCBody");
		$("[id^=txtORCAmt_]").numeric();	
		$("#txtHidORCID_"+id).html($("#selOwnerCost").html());	
		$("#txtOWCCount").val(id);
	}
	else
	{
		jAlert('Please fill previous data', 'Alert');
		return false;
	}
}

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



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

</script>
    </body>
</html>