<?php 
session_start();
require_once 'includes/database.php';
include 'includes/funcs.php';
if (!isset($_SESSION['reusername'])) { echo 'Sorry You Dont Have permissions to View this Page!'; exit();}
else {$user = $_SESSION['reusername'];}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <script type="text/javascript" src="js/jquery-1.10.2.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.10.4.custom.js"></script>
        <link rel="stylesheet" href="css/allcss.css" type="text/css" />
        <link rel="stylesheet" href="css/jquery-ui-1.10.4.custom.css" type="text/css" />
<style>
html, body {margin:0; padding:0; height:100%; width:100%; min-width:100%; min-height:100%; overflow:scroll;z-index: 100;}  
#insform {
text-align: left;
width:90%;
margin: 5px; padding-left:5px; padding-right:5px;
border: 1px solid #666; 
background: #D2FC52;
box-shadow: 0px 0px 5px rgba(0,0,0,0.5); 
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:14px;
color:#2C2C57; 
z-index: 100;
text-wrap: none;
}
.no-js #loader { display: none;  }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 9999;
	background: url(images/spinner.gif) center no-repeat #fff;
}
</style>

<script type="text/javascript">       
$(document).ready(function() {  
$('#spinns').hide();

$("#btnaddins").click(function(e) {
e.preventDefault();
//$('#spinns').show();
//If($('#testd:checked'){document.getElementById('testd').value=1; }
if( $('#cname').val() === ''  ){ document.getElementById('valerr').value="Customer Name Cannot be Blank!";	} 
else if( $('#insurer').val() === ''  ){ document.getElementById('valerr').value="Insurer Name Cannot be Blank!";	}
else if( $('#idate').val() === ''  ){ document.getElementById('valerr').value="Date Cannot be Blank!";	}
else if( $('#icat').val() === ''  ){ document.getElementById('valerr').value="Category Cannot be Blank!";	}
else if( $('#isco').val() === ''  ){ document.getElementById('valerr').value="Scope Cannot be Blank!";	}
else if( $('#insprem').val() === ''  ){ document.getElementById('valerr').value="Premium Value Cannot be Blank!";	}
else if( $('#chasis').val() === ''  ){ document.getElementById('valerr').value="Chasis Cannot be Blank!";	}
else if( $('#inam').val() === ''  ){ document.getElementById('valerr').value="Insured Value Cannot be Blank!";	}
else if( $('#cname').val() !== '' && $('#idate').val() !== '' && $('#chasis').val() !== '' && $('#insurer').val() !== '') {
		var savjcdet = $.post("savinsinv.php?e=0&cname="+$('#cname').val()+"&idate="+$('#idate').val()+"&vehmod="+$('#vehmod').val()+"&chasis="+$('#chasis').val()+"&pno="+$('#pno').val()+"&agpno="+$('#agpno').val()+"&agpno1="+$('#agpno1').val()+"&agpno2="+$('#agpno2').val()+"&agpno3="+$('#agpno3').val()+"&vbody="+$('#vbody').val()+"&yom="+$('#yom').val()+"&rating="+$('#rating').val()+
		"&regno="+$('#regno').val()+"&vcolor="+$('#vcolor').val()+"&insurer="+$('#insurer').val()+"&instel="+$('#instel').val()+"&inam="+$('#inam').val()+"&insprem="+$('#insprem').val()+"&rmks="+$('#rmks').val()+"&expdate="+$('#expdate').val()+"&insaddr="+$('#insaddr').val()+"&inst1="+$('#inst1').val()+"&inst2="+$('#inst2').val()+"&inst3="+$('#inst3').val()+"&engno="+$('#engno').val()+
		"&proval="+$('#proval').val()+"&prorate="+$('#prorate').val()+"&proprem="+$('#proprem').val()+"&insrate="+$('#insrate').val()+"&icat="+$('#icat').val()+"&supp="+$('#supp').val()+"&isco="+$('#isco').val()+"&idno="+$('#idno').val()+"&pinno="+$('#pinno').val()+"&plllab="+$('#plllab').val()+"&pllam="+$('#pllam').val()+"&cpvt="+$('#cpvt').val()+"&cpvtr="+$('#cpvtr').val()+
		"&ppvtr="+$('#ppvtr').val()+"&ppvt="+$('#ppvt').val()+"&ctotprem="+$('#ctotprem').val()+"&cexpr="+$('#cexpr').val()+"&cexp="+$('#cexp').val()+"&pexpr="+$('#pexpr').val()+"&pexp="+$('#pexp').val()+"&ptotprem="+$('#ptotprem').val(), function(data){
                                alert(data);
								window.close();  });
	 	}						
});

$("#btnmodins").click(function(e) {
e.preventDefault();
$('#spinns').show();
if( $('#cname').val() === ''  ){ document.getElementById('valerr').value="Customer Name Cannot be Blank!";	} 
else if( $('#insurer').val() === ''  ){ document.getElementById('valerr').value="Insurer Name Cannot be Blank!";	}
else if( $('#idate').val() === ''  ){ document.getElementById('valerr').value="Date Cannot be Blank!";	}
else if( $('#icat').val() === ''  ){ document.getElementById('valerr').value="Category Cannot be Blank!";	}
else if( $('#insprem').val() === ''  ){ document.getElementById('valerr').value="Premium Value Cannot be Blank!";	}
else if( $('#chasis').val() === ''  ){ document.getElementById('valerr').value="Chasis Cannot be Blank!";	}
else if( $('#inam').val() === ''  ){ document.getElementById('valerr').value="Insured Value Cannot be Blank!";	}
else if( $('#cname').val() !== '' && $('#idate').val() !== '' && $('#chasis').val() !== '' && $('#insurer').val() !== '' && $('#insno').val() !== '') {
		var savjcdet = $.post("savinsinv.php?e=1&cname="+$('#cname').val()+"&insno="+$('#insno').val()+"&idate="+$('#idate').val()+"&vehmod="+$('#vehmod').val()+"&chasis="+$('#chasis').val()+"&pno="+$('#pno').val()+"&agpno="+$('#agpno').val()+"&agpno1="+$('#agpno1').val()+"&agpno2="+$('#agpno2').val()+"&agpno3="+$('#agpno3').val()+"&vbody="+$('#vbody').val()+"&yom="+$('#yom').val()+"&rating="+$('#rating').val()+
		"&regno="+$('#regno').val()+"&vcolor="+$('#vcolor').val()+"&insurer="+$('#insurer').val()+"&instel="+$('#instel').val()+"&inam="+$('#inam').val()+"&expdate="+$('#expdate').val()+"&insprem="+$('#insprem').val()+"&insaddr="+$('#insaddr').val()+"&inst1="+$('#inst1').val()+"&inst2="+$('#inst2').val()+"&inst3="+$('#inst3').val()+"&engno="+$('#engno').val()+
		"&proval="+$('#proval').val()+"&prorate="+$('#prorate').val()+"&proprem="+$('#proprem').val()+"&rmks="+$('#rmks').val()+"&insrate="+$('#insrate').val()+"&icat="+$('#icat').val()+"&supp="+$('#supp').val()+"&isco="+$('#isco').val()+"&idno="+$('#idno').val()+"&pinno="+$('#pinno').val()+"&plllab="+$('#plllab').val()+"&pllam="+$('#pllam').val()+
		"&cpvt="+$('#cpvt').val()+"&cpvtr="+$('#cpvtr').val()+"&ppvtr="+$('#ppvtr').val()+"&ppvt="+$('#ppvt').val()+"&ctotprem="+$('#ctotprem').val()+"&cexpr="+$('#cexpr').val()+"&cexp="+$('#cexp').val()+"&pexpr="+$('#pexpr').val()+"&pexp="+$('#pexp').val()+"&ptotprem="+$('#ptotprem').val(), function(data){
                                if(data.trim()==="OK") { window.close(); } 
								});
	 	}						
});

 
});
</script>
<?php 
if($_REQUEST['e'] === "0"){
	$cname = '';
	$idate = '';
	$vehmod = '';
	$regno = '';
	$chasis = '';
	$vcolor = '';	$vbody = '';	$yom = '';	$rating = '';	$engno='';
	$insurer = '';
	$inam = '';		$inst1 = '';	$inst2 = '';	$inst3 = '';
	$instel = '';
	$insaddr = '';
	$icat = '';
	$insprem = '';
	$insrate = '';
	$rmks = '';
	$insno = '';
	$supp = '0';
	$isco = '';
	$pno = '';
	$agpno = '';	$agpno1 = '';	$agpno2 = '';	$agpno3 = '';
	$proval = 0;
	$prorate =0;
	$proprem = 0;
	$expdate='';
	$idno = '';	$pinno = '';	$plllab = '';	$pllam= '';	
	$cpvtr = '';	$cexpr= '';    $cpvt = '';	$cexp= '';   $ctotprem= '';
	$ppvtr = '';	$pexpr= '';    $ppvt = '';	$pexp= '';   $ptotprem= '';
}
else {
	$insno = $_REQUEST['insno'];
	require_once 'includes/database.php';
	$db=new MySQLDatabase();
	$db->open_connection();
	$query = "SELECT * FROM insrecs WHERE insno = '$insno';";
	$result = mysqli_query($db->connection, $query) or die(mysqli_error($db->connection) );
	if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
		$cname = $row['cname'];
		$idate = substr($row['idate'],8,2)."-".substr($row['idate'],5,2)."-".substr($row['idate'] ,0,4);
		$vehmod = $row['vehmod'];
		$regno = $row['regno'];
		$chasis = $row['chasis'];
		$vcolor =$row['vcolor'];    $vbody = $row['vbody'];	   $yom = $row['yom'];	$rating = $row['rating'];	$engno = $row['engno'];
		$insurer = $row['insurer'];
		$insrate = $row['insrate'];
		$instel = $row['instel'];
		$inam = $row['inam'];	$inst1 = $row['inst1'];		$inst2 = $row['inst2'];		$inst3 = $row['inst3'];
		$icat = $row['icat'];	$plllab= $row['plllab'];	$pllam= $row['pllam'];
		$isco = $row['isco'];
		$insaddr = $row['insaddr'];
		$insprem = $row['insprem'];
		$proval = $row['proval'];
		$prorate = $row['prorate'];
		$proprem = $row['proprem'];
		$rmks = $row['rmks'];
		$supp = $row['supp'];	
		$cpvt= $row['cpvt'];	$cpvtr= $row['cpvtr'];	$cexp= $row['cexp'];  	$cexpr= $row['cexpr'];	$ctotprem= $row['ctotprem'];
		$ppvt= $row['ppvt'];	$ppvtr= $row['ppvtr'];	$pexp= $row['pexp'];  	$pexpr= $row['pexpr'];	$ptotprem= $row['ptotprem'];
		$pno = $row['pno'];	$pinno = $row['pinno'];	 	$idno = $row['idno'];	
		$expdate = substr($row['expdate'],8,2)."-".substr($row['expdate'],5,2)."-".substr($row['expdate'] ,0,4);
		$agpno = $row['agpno'];		$agpno1 = $row['agpno1'];		$agpno2 = $row['agpno2'];		$agpno3 = $row['agpno3'];
	}
	else { echo '<script type="text/javascript"> window.close();</script>';}
}
?>   
</head><body>
<div id="spinns" class="se-pre-con"></div>
<p class="titletr"> <?php echo ($_REQUEST['e'] === "0") ? 'Book Customer Insurance' : 'Edit Booking No.'.$insno ; echo str_repeat('&nbsp;', 8); ?> <input type="text" id="valerr" name="valerr" value="" size="30"> <?php echo str_repeat('&nbsp;', 10); ?> <a href="#"><img src="images/close.png" onclick="window.close();"> </a>  </p>       
<form id="insform" method="post" onkeypress="return event.keyCode!=13" enctype="multipart/form-data" action="#" >
                    <center>
                    <table cellspacing="5px" id="regaddbox">
					<tr><td align="left"><label for="idate"> Date &nbsp;</label></td>
                    <td><input type="text" id="idate" name="idate" value="<?php echo $idate; ?>" size="20"/> <input type="hidden" id="ctotprem" name="ctotprem" value="0"/> <input type="hidden" id="ptotprem" name="ptotprem" value="0"/></td>
                    </tr>
                    <tr><td align="left"><label for="cname">Dealer Name &nbsp; </label></td>
                    <td><select id="cname" name="cname" selected><?php echo '<option value="'.$cname.'">'.$cname.'</option>'; echo selcus();?> </select> <input type="hidden" id="insno" name="insno" value= "<?php echo $insno; ?>"> </td>
                    </tr>
					<tr><td align="left"><label for="insurer"> Insured &nbsp;</label></td>
                    <td><input type="text" id="insurer" name="insurer" value="<?php echo $insurer; ?>" size="40"/> </td>
                    </tr>
					<tr><td align="left"><label for="instel"> Insured Phone No. &nbsp;</label></td>
                    <td><input type="text" id="instel" name="instel" value="<?php echo $instel; ?>" size="20"/> </td>
                    </tr>
                    <tr><td align="left"><label for="idno"> Insured ID No. &nbsp;</label> <input type="text" id="idno" name="idno" value="<?php echo $idno; ?>" size="8"/></td>
                    <td><label for="pinno"> Insured PIN No. &nbsp;</label> <input type="text" id="pinno" name="pinno" value="<?php echo $pinno; ?>" size="10"/> </td>
                    </tr>
					<tr><td align="left"><label for="insaddr"> Insured Address &nbsp;</label></td>
                    <td><input type="text" id="insaddr" name="insaddr" value="<?php echo $insaddr; ?>" size="30"/> </td>
                    </tr>
					<tr><td align="left"><label for="icat"> Category &nbsp;</label></td>
                    <td><select id="icat" name="icat" style="width:200px;" selected> <?php echo '<option value="'.$icat.'">'.$icat.'</option>';?> <option value="COMMERCIAL GENERAL CARTAGE">COMMERCIAL GENERAL CARTAGE</option> <option value="COMMERCIAL OWN GOODS">COMMERCIAL OWN GOODS</option> <option value="PRIVATE">PRIVATE</option> <option value="PSV">PSV</option></select> </td>
                    </tr>
					<tr><td align="left"><label for="isco"> Insurance Scope &nbsp;</label></td>
                    <td><select id="isco" name="isco" style="width:220px;" selected> <?php echo '<option value="'.$isco.'">'.$isco.'</option>';?> <option value="COMPREHENSIVE">COMPREHENSIVE</option> <option value="THIRD PARTY">THIRD PARTY</option> <option value="THIRD PARTY FIRE AND THEFT">THIRD PARTY FIRE AND THEFT</option> </select> </td>
                    </tr>
                    <tr><td align="left"><label for="vehmod"> Vehicle Model &nbsp;</label></td>
                    <td><input type="text" id="vehmod" name="vehmod" value="<?php echo $vehmod; ?>" size="30"/> </td>
                    </tr>
					<tr><td align="left"><label for="vbody"> Vehicle Body Type &nbsp;</label></td>
                    <td><input type="text" id="vbody" name="vbody" value="<?php echo $vbody; ?>" size="10"/> </td>
                    </tr>
					<tr><td align="left"><label for="yom"> Year of Manufacture &nbsp;</label></td>
                    <td><input type="text" id="yom" name="yom" value="<?php echo $yom; ?>" size="10"/> </td>
                    </tr>
					<tr> <td align="left"><label for="rating"> Rating &nbsp;</label></td>
                    <td><input type="text" id="rating" name="rating" value="<?php echo $rating; ?>" size="10"/> </td>
                    </tr>
					<tr> <td align="left"><label for="engno"> Engine No. &nbsp;</label></td>
                    <td><input type="text" id="engno" name="engno" value="<?php echo $engno; ?>" size="30"/> </td>
                    </tr>
                    <tr><td align="left"><label for="chasis"> Chassis No. &nbsp;</label></td>
                    <td><input type="text" id="chasis" name="chasis" value="<?php echo $chasis; ?>" size="20"/> </td>
                    </tr>
                    <tr><td align="left"><label for="regno"> Reg. No. &nbsp;</label></td>
                    <td><input type="text" id="regno" name="regno" value="<?php echo $regno; ?>" size="10"/> </td>
                    </tr>
					<tr><td align="left"><label for="vcolor"> Vehicle Colour &nbsp;</label></td>
                    <td><input type="text" id="vcolor" name="vcolor" value="<?php echo $vcolor; ?>" size="20"/> </td>
                    </tr>
					<tr><td align="left"><label for="supp"> Provider &nbsp;</label></td>
                    <td><select id="supp" name="supp" style="width:180px;"> <?php echo '<option value="'.$supp.'">'.getsupplier($supp).'</option>'; echo selsupplier(); ?> </select> </td>
                    </tr>
					<tr><td align="left"><label for="inam"> Cust. Insured Value &nbsp;</label>  <input type="text" id="inam" name="inam" onchange="showprem();" value="<?php echo $inam; ?>" size="10" /> </td>
						<td align="left"><label for="proval"> Prov. Insured Value &nbsp;</label>  <input type="text" id="proval" name="proval" onchange="showpprem();" value="<?php echo $proval; ?>" size="10" /> </td>
					</tr>
					<tr><td align="left"><label for="insrate"> Cust. Insurance Rate (%)&nbsp;</label> <input type="text" id="insrate" name="insrate" onchange="showprem();" value="<?php echo $insrate; ?>" size="5"> </td>
						<td align="left"><label for="insrate"> Prov. Insurance Rate (%)&nbsp;</label> <input type="text" id="prorate" name="prorate" onchange="showpprem();" value="<?php echo $prorate; ?>" size="5"> </td>
                    </tr>
					<tr><td align="left"><label for="insprem"> Cust. Premium  &nbsp;</label> <input type="text" id="insprem" name="insprem" required="requirred" value="<?php echo $insprem; ?>" size="10"/> </td>
					<td align="left"><label for="insprem"> Prov. Premium &nbsp;</label> <input type="text" id="proprem" name="proprem" required="requirred" value="<?php echo $proprem; ?>" size="10"/> </td>
                    </tr>
                    <tr><td colspan="2" align="left"><label for="pllval"> PLL  &nbsp;</label> &nbsp;&nbsp;<input type="text" id="plllab" name="plllab" value="<?php echo $plllab; ?>" size="10"> &nbsp;&nbsp;<input type="text" id="pllam" name="pllam" value="<?php echo $pllam; ?>" size="10">
                        </td> </tr>
                     <tr><td align="left"><label for="cvtr"> Cus. PVT Rate (%)&nbsp;</label> &nbsp;&nbsp;<input type="text" id="cpvtr" name="cpvtr" value="<?php echo $cpvtr; ?>" onchange="docpvtval();" size="5"/> &nbsp;&nbsp;<input type="text" id="cpvt" name="cpvt" value="<?php echo $cpvt; ?>" size="5"/> </td>   	
                     	<td align="left"><label for="ppvtr"> Prov. PVT Rate (%)&nbsp;</label> &nbsp;&nbsp;<input type="text" id="ppvtr" name="ppvtr" value="<?php echo $ppvtr; ?>" onchange="doppvtval();" size="5"/> &nbsp;&nbsp;<input type="text" id="ppvt" name="ppvt" value="<?php echo $ppvt; ?>" size="5"/> </td> </tr>			
		    <tr> <td align="left"><label for="cexpr"> Cus. Excess Prot. (%)&nbsp;</label> &nbsp;&nbsp;<input type="text" id="cexpr" name="cexpr" value="<?php echo $cexpr; ?>" onchange="docepval();" size="5"/>&nbsp;&nbsp;<input type="text" id="cexp" name="cexp" value="<?php echo $cexp; ?>" size="5"/> </td>   
		     	 <td align="left"><label for="excproc"> Prov. Excess Prot. (%)&nbsp;</label> &nbsp;&nbsp;<input type="text" id="pexpr" name="pexpr" value="<?php echo $pexpr; ?>" onchange="dopepval();" size="5"/>&nbsp;&nbsp;<input type="text" id="pexp" name="pexp" value="<?php echo $pexp; ?>" size="5"/> </td> </tr> 
		    <tr><td align="left"><label for="rmks"> Remarks &nbsp;</label></td>
                    <td><input type="text" id="rmks" name="rmks" value="<?php echo $rmks; ?>" size="40"> </td>
                    </tr>
					<tr><td align="left"><label for="pno"> Provider Policy No. &nbsp;</label></td>
                    <td><input type="text" id="pno" name="pno" value="<?php echo $pno; ?>" size="20"> </td>
                    </tr>
					<tr><td align="left"><label for="idate"> Expiry Date &nbsp;</label></td>
                    <td><input type="text" id="expdate" name="expdate" value="<?php echo $expdate; ?>" size="12"/> </td>
                    </tr>
					<tr><td align="left"><label for="agpno1"> Inst. 1 : QIA Policy No. &nbsp;</label>&nbsp;&nbsp;<input type="text" id="agpno1" name="agpno1" value="<?php echo $agpno1; ?>" size="20"></td> 
						<td><label for="inst1"> Installment 1 : &nbsp;</label>&nbsp;&nbsp;<input type="text" id="inst1" name="inst1" value="<?php echo $inst1; ?>" size="10"> </td></tr>
                    <tr><td><label for="agpno2"> Inst. 2 : QIA Policy No. &nbsp;</label>&nbsp;&nbsp;<input type="text" id="agpno2" name="agpno2" value="<?php echo $agpno2; ?>" size="20"> </td> 
						<td><label for="inst1"> Installment 2 : &nbsp;</label>&nbsp;&nbsp;<input type="text" id="inst2" name="inst2" value="<?php echo $inst2; ?>" size="10"> </td></tr>
					<tr><td align="left"><label for="agpno3"> Inst 3 : QIA Policy No. &nbsp;</label>&nbsp;&nbsp;<input type="text" id="agpno3" name="agpno3" value="<?php echo $agpno3; ?>" size="20"></td> 
						<td><label for="inst3"> Installment 3 : &nbsp;</label>&nbsp;&nbsp;<input type="text" id="inst3" name="inst3" value="<?php echo $inst3; ?>" size="10"> </td></tr>
                    <td><label for="agpno"> Full Premium : Policy No. &nbsp;</label> </td> <td><input type="text" id="agpno" name="agpno" value="<?php echo $agpno; ?>" size="20"> </td> </tr>
                    <tr><td colspan=2> </td></tr><br />
                    <tr><td colspan=2 align="center">
					 <?php echo '<input type="button" class="text ui-widget-content ui-corner-all" style="width:160px;font-weight:bold;"'; echo ($_REQUEST['e'] === "0") ? ' id="btnaddins" name="btnaddins" value=" Book Insurance "' : ' id="btnmodins" name="btnmodins" value=" Save Details "'; echo '/>'; ?>
                    </td></tr>
                    </table></center>
        </form>
</body>
</html>

<script type="text/javascript">   
$('#cname').autocomplete({ source: <?php echo allcustomers(); ?>, minLength: 2  });                                                             
$('#idate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
$('#expdate').datepicker({ changeMonth: true, changeYear: true, dateFormat: "dd-mm-yy"}); 
																			// computation of premium
function showprem(){  
 if($('#inam').val() !== '' && $('#insrate').val() !== ''){
	var imm = parseFloat(document.getElementById('inam').value);
	var imn = parseFloat(document.getElementById('insrate').value);
	var tt = (imm * imn)/100.0;
	document.getElementById('insprem').value = tt.toFixed(2);                    
	}
else { document.getElementById('insprem').value = 0;}	
};

function showpprem(){  
 if($('#proval').val() !== '' && $('#prorate').val() !== ''){
	var imm = parseFloat(document.getElementById('proval').value);
	var imn = parseFloat(document.getElementById('prorate').value);
	var tt = (imm * imn)/100.0;
	document.getElementById('proprem').value = tt.toFixed(2);                    
	}
else { document.getElementById('proprem').value = 0;}	
};

function docpvtval(){  
 if($('#cpvtr').val() !== '' && $('#inam').val() !== ''){
	var inam = parseFloat(document.getElementById('inam').value);
	var pvtr = parseFloat(document.getElementById('cpvtr').value);
	var tt = (inam * pvtr)/100.0;
	document.getElementById('cpvt').value = tt.toFixed(2);  
	document.getElementById('ctotprem').value = parseFloat(document.getElementById('insprem').value) + parseFloat(document.getElementById('cexp').value)+parseFloat(document.getElementById('cpvt').value);                                    
	}
else { document.getElementById('cpvt').value = 0;}	
}

function doppvtval(){  
 if($('#ppvtr').val() !== '' && $('#proval').val() !== ''){
	var inam = parseFloat(document.getElementById('proval').value);
	var pvtr = parseFloat(document.getElementById('ppvtr').value);
	var tt = (inam * pvtr)/100.0;
	document.getElementById('ppvt').value = tt.toFixed(2);    
	document.getElementById('ptotprem').value = parseFloat(document.getElementById('proprem').value) + parseFloat(document.getElementById('pexp').value)+parseFloat(document.getElementById('ppvt').value);                
	}
else { document.getElementById('ppvt').value = 0;}	
}

function docepval(){  
 if($('#cexpr').val() !== '' && $('#inam').val() !== ''){
	var inam = parseFloat(document.getElementById('inam').value);
	var epr = parseFloat(document.getElementById('cexpr').value);
	var tt = (inam * epr)/100.0;
	document.getElementById('cexp').value = tt.toFixed(2);  
	document.getElementById('ctotprem').value = parseFloat(document.getElementById('insprem').value) + parseFloat(document.getElementById('cexp').value)+parseFloat(document.getElementById('cpvt').value);                  
	}
else { document.getElementById('cexp').value = 0;}	
}

function dopepval(){  
 if($('#pexpr').val() !== '' && $('#proval').val() !== ''){
	var inam = parseFloat(document.getElementById('proval').value);
	var epr = parseFloat(document.getElementById('pexpr').value);
	var tt = (inam * epr)/100.0;
	document.getElementById('pexp').value = tt.toFixed(2); 
	document.getElementById('ptotprem').value = parseFloat(document.getElementById('proprem').value) + parseFloat(document.getElementById('pexp').value)+parseFloat(document.getElementById('ppvt').value);
	}
else { document.getElementById('pexp').value = 0;}	
}
</script>



