
<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='index.php' </script>";
  return;
}
include("includes/top.php");

include("test.php");
include("opendb.php");
$taxtype=$_REQUEST[taxtype];
$intr=$taxtype;

?>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>zf</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />	
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script>
  $(function() {
    $( "#leddt" ).datepicker({ dateFormat: 'yy-mm-dd' });

  });
  
  $(function() {
    $( "#supdt" ).datepicker({ dateFormat: 'yy-mm-dd' });

  });
</script>


<script type="text/javascript">

$(function(){
  $(".supnm").live("keydown.autocomplete",function(){
  $supnm = $(this);
  $row = $supnm.parent().parent();
  $(this).autocomplete({
    source: function( request, response ) {
    $.ajax({
      url: "search1_ven.php",
      dataType: "json",
      data: "key="+$supnm.val(),
      success: function( data ) {
        response( $.map( data, function( item ) {
          return {
            label: '<span class="la-code">'+item.supnm+' </span><span class="la-name">'+  item.partname + '</span>'    ,
            value: item.supnm,
            name:item.partname,
            tax:item.tax,
            stock:item.stock,
            rate:item.rate,
            reduct:item.reduct,
            }
        }));
      }
    });
  }
  ,
  minLength: 2,
  select: function( event, ui ) {
  $row.find('.partname').val(ui.item.name);
  $row.find('.stok').val(ui.item.stock);
  $row.find('.unitprice').val(ui.item.rate);

  $row.find('.tax').val(ui.item.tax);
  $row.find('.itmvl').val(ui.item.reduct);
  $row.find('.qty').focus();
  /*log( ui.item ?
  "Selected: " + ui.item.label :
  "Nothing selected, input was " + this.value);
  */
   }

  }).data("ui-autocomplete")._renderItem = function (ul, item) {
         return $("<li></li>")
             .data("item.autocomplete", item)
             .append( item.label )
             .appendTo(ul);
     };
  });
});
</script>
<script type="text/javascript">
$(function(){
  $(".exphd").live("keydown.autocomplete",function(){
  $led = $(this);
  $row = $led.parent().parent();
  $(this).autocomplete({
    source: function( request, response ) {
    $.ajax({
      url: "searchledgst.php",
      dataType: "json",
      data: "key="+$led.val(),
      success: function( data ) {
        response( $.map( data, function( item ) {
          return {
            label: '<span class="la-code">'+item.led+' </span><span class="la-name">'+  item.partname + '</span>',
            value: item.led,
            name:item.partname,
            tax:item.tax,
            stock:item.stock,
            rate:item.rate,
            reduct:item.reduct,
            }
        }));
      }
    });
  }
  ,
  minLength: 2,
  select: function( event, ui ) {
  $row.find('.led').val(ui.item.value);
  $row.find('.stok').val(ui.item.stock);
  $row.find('.unitprice').val(ui.item.rate);

  $row.find('.tax').val(ui.item.tax);
  $row.find('.itmvl').val(ui.item.reduct);
  $row.find('.qty').focus();
  /*log( ui.item ?
  "Selected: " + ui.item.label :
  "Nothing selected, input was " + this.value);
  */
   }

  }).data("ui-autocomplete")._renderItem = function (ul, item) {
         return $("<li></li>")
             .data("item.autocomplete", item)
             .append( item.label )
             .appendTo(ul);
     };
  });
});





</script>
<script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        }); 
        
        

 var count1=0;
 var empname=[];

 var cur=1;
 //var partcode=[];
 var partname=[];
 var unitprice=[];
 var qty=[];
 var tot=[];
 var typ=[];
 var cnt=1;

function insRow(event,i1,id2)
{
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

var cur_val=i1.value;


switch(keyCode)
{
case 38:
   var row=i1.parentNode.parentNode.rowIndex;
   var col  =i1.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
  break;
case 40:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
  break;
case 37:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
  document.getElementById('myTable').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();
	
}



if(id2!="insrowbttn")
  {
   var i2=i1.parentNode.parentNode.rowIndex;
   var i3=parseFloat(i2)+parseFloat(1);
   var rowCounts = document.getElementById('myTable').rows.length;
   var rowCounts1= rowCounts-1;
  
  }
else
  {
   var i2=0;
   var rowCounts1=0;
  }
//alert(cur);


if(((keyCode == 13) && (i2==rowCounts1))||(cnt==1))
 {
var rowCount = document.getElementById('myTable').rows.length;

var rowcount1=parseFloat(rowCount)+parseFloat(1);

var x=document.getElementById('myTable').insertRow(rowCount);


if(rowCount>=1)
 {
    document.getElementById('insrowbttn').type='hidden';
 }


var a=x.insertCell(0);
var i1=x.insertCell(1);
var j1=x.insertCell(2);
var k1=x.insertCell(3);
<?
if($intr=='INTRASTATE')
{
?>
var l1=x.insertCell(4);
var m1=x.insertCell(5);
var n1=x.insertCell(6);
var o1=x.insertCell(7);
var p1=x.insertCell(8);
var q1=x.insertCell(9);
<?
}
?>
<?
if($intr=='INTERSTATE')
{
?>
var l1=x.insertCell(4);
var m1=x.insertCell(5);
var n1=x.insertCell(6);
var o1=x.insertCell(7);
<?
}
?>


var k;//=this.rowIndex;
var k1;
a.innerHTML=cur;

i1.innerHTML="<input type=text id='befrtx"+cur+"' name=befrtx[] size=8 value='0' onKeyup='calamt(this.value,this,this.id)' class='befrtx' onKeydown='return handleEnter(this, event)' >";
var xv="";
xv="<select name='taxprc[]' id=taxprc"+cur+" onchange='showregister(this.value,this,this.id)'  onKeydown='return handleEnter(this, event)'><option>-select-</option>";
<?
 $empre=mysqli_query($db,"select distinct tax_igst from taxmaster");
 while($emprow=mysqli_fetch_row($empre))
 {
     ?>
  xv=xv+'<option><? echo $emprow[0] ?></option>';
  <?
 }
?>

j1.innerHTML=xv+"</select> ";

var xv1="";
xv1="<select name='led[]' id=led"+cur+" onKeydown='return handleEnter(this, event)'><option>-select-</option>";

  xv1=xv1+'<option>Labour</option>';
  xv1=xv1+'<option>Material</option>';

k1.innerHTML=xv1+"</select> ";
//k1.innerHTML="<input type=text id='led"+cur+"' name=led[]  size=8 class='led' onKeydown='return handleEnter(this, event)' >";
<?
if($intr=='INTRASTATE')
{?>
l1.innerHTML="<input type=text id='cgstp"+cur+"' name=cgstp[] readonly value='0' size=3 class='cgstp' onKeydown='return handleEnter(this, event)'  >";
m1.innerHTML="<input type=text id='cgstamt"+cur+"' name=cgstamt[] readonly value='0' size=3 class='cgstamt' onKeydown='return handleEnter(this, event)'  >";
n1.innerHTML="<input type=text id='sgstp"+cur+"' name=sgstp[] readonly value='0' size=3 class='sgstp' onKeydown='return handleEnter(this, event)'  >";
o1.innerHTML="<input type=text id='sgstamt"+cur+"' name=sgstamt[] readonly value='0' size=3 class='sgstamt' onKeydown='return handleEnter(this, event)'  >";
p1.innerHTML="<input type=text id='ntamt"+cur+"' name=ntamt[] readonly value='0' size=8 class='ntamt' onKeydown='insRow(event,this,this.id)' onKeyup='return handleEnter(this, event)' >";
q1.innerHTML="<input type='button' onClick='delrow(this)' class='del' value='Delete' id=del"+cur+">";

<?
}
?>
<?
if($intr=='INTERSTATE')
{?>
l1.innerHTML="<input type=text id='igstp"+cur+"' name=igstp[] readonly value='0' size=3 class='igstp' onKeydown='return handleEnter(this, event)' >";
m1.innerHTML="<input type=text id='igstamt"+cur+"' name=igstamt[] readonly value='0' size=3 class='igstamt' onKeydown='return handleEnter(this, event)' >";
n1.innerHTML="<input type=text id='ntamt"+cur+"' name=ntamt[] readonly value='0' size=8 class='ntamt' onKeydown='insRow(event,this,this.id)' onKeyup='return handleEnter(this, event)' >";
o1.innerHTML="<input type='button' onClick='delrow(this)' class='del' value='Delete' id=del"+cur+">";
<?
}
?>

cur++;
cnt++;
var table = document.getElementById("myTable");
var row = table.rows[index];
console.log(secondRow.id);
}
if(keyCode == 40)
{
return handleEnter(this, event);
}
if(keyCode == 13)
	{
		var tbl = document.getElementById('myTable');
   		var id3=tbl.rows[i3].cells[0].innerHTML;	
		document.getElementById("led"+id3).focus();
	} 

}
        
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;

}
.la-code {
    display: inline-block;
    width: 300px;
}
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
} 
</style>
<STYLE>
#popup 
{
position: fixed; top: 60%; left: 60%; width: 200px; height: 100px; margin-left: -300px; margin-top: -200px;
  display:none;
}
</STYLE>
<style>


body {
    

  }


#mask {
	display: none;
	background:url(images/bgimg1.gif) repeat;
	//background: #000; 
	position: fixed; left: 0; top: 0; 
	z-index: 10;
	width: 100%; height: 100%;
	opacity: 0.8;
	z-index: 999;
}

.login-popup{
		display:none;
	background:white;
	padding: 10px; 	
	border: 2px solid #ddd;
	float: left;

	position: fixed;
	top: 4%; left: 45%;
	z-index: 99999;
	box-shadow: 0px 0px 20px #999;
	-moz-box-shadow: 0px 0px 20px #999; /* Firefox */
    -webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
	border-radius:3px 3px 3px 3px;
    -moz-border-radius: 3px; /* Firefox */
    -webkit-border-radius: 3px; /* Safari, Chrome */
}
}

img.btn_close {
	float: right; 
	margin: -28px -28px 0 0;
}

fieldset { 
	border:none; 
}

form.signin .textbox label { 
	display:block; 
	padding-bottom:7px; 
}

form.signin .textbox span { 
	display:block;
}

form.signin p, form.signin span { 
	color:white; 

	line-height:18px;
} 

form.signin .textbox input { 
	background:#666666; 
	border-bottom:1px solid #333;
	border-left:1px solid #000;
	border-right:1px solid #333;
	border-top:1px solid #000;
	color:white; 
	border-radius: 3px 3px 3px 3px;
	-moz-border-radius: 3px;
    -webkit-border-radius: 3px;
	font:13px Arial, Helvetica, sans-serif;
	padding:6px 6px 4px;
	width:200px;
}

form.signin input:-moz-placeholder { color:white; text-shadow:0 0 2px #000; }
form.signin input::-webkit-input-placeholder { color:hwite; text-shadow:0 0 2px #000;  }

.submit button { 
	background: -moz-linear-gradient(center top, #f3f3f3, #dddddd);
	background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(#dddddd));
	background:  -o-linear-gradient(top, #f3f3f3, #dddddd);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f3f3f3', EndColorStr='#dddddd');
	border-color:#000; 
	border-width:1px;
	border-radius:4px 4px 4px 4px;
	-moz-border-radius: 4px;
    -webkit-border-radius: 4px;
	color:#333;
	cursor:pointer;
	display:inline-block;
	padding:6px 6px 4px;
	margin-top:10px;
 
	width:100px;
}

.button:hover { background:#ddd; }


#outPopUp{
     //position:absolute;
     width:800px;
     text-align:center;
    // height:300px;
    // z-index:15;
     //top:50%;
     //left:50%;
    // margin:-150px 0 0 -150px;
     //background:red;
}

</style>

   

<script>
$(document).ready(function() {
	$('a.login-window').click(function() {
		
		// Getting the variable's value from a link 
		var loginBox = $(this).attr('href');

		//Fade in the Popup and add close button
		$(loginBox).fadeIn(300);
		
		//Set the center alignment padding + border
		var popMargTop = ($(loginBox).height() + 24) / 2; 
		var popMargLeft = ($(loginBox).width() + 24) / 2; 
		
		$(loginBox).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		// Add the mask to body
		$('body').append('<div id="mask"></div>');
		$('#mask').fadeIn(300);
		
		return false;
	});
	
	// When clicking on the button close or the mask layer the popup closed
	$('a.close, #mask').live('click', function() { 
	  $('#mask , .login-popup').fadeOut(300 , function() {
		$('#mask').remove();  
	}); 
	return false;
	});
});

$(document).ready(function(){
  $("#svbttn").click(function(){

$("#msgbox").html('<small>Loading...</small>');
  	 var values1 = $("#jforms").serialize();
    

  	  $.ajax({
   	   url: "svgstmulti2.php",
    	  type: "POST",
   	  data:   values1,
     	  success: function(msg){


           	 if(parseInt(msg)!=0)    

          	  {

                $('#msgbox').html(msg);
               
		}
           

      	},
      error:function(){
          alert("failure");
          $("#msgbox").html('there is error while submit');
      }   
   	 }); 

	 }); 
	 }); 




  var rawTags;
   var inputField;
   var  initInputFieldValue;
   var dataList;
    var initNbVirgules ;


 /* ********* below function is to get other values from vehmast as per regno or chasisno ********* */
</script>
<style>
.cont
	{
      

	
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
}
#pg{
       text-decoration:none;
       text-align: center;
       vertical-align: top;
}
.pgbtn{
      float:left;
margin-left: 10px;
height: 20px;
line-height: 22px;
text-align:center;
background-color:#fbfbfb;
border:1px solid #b7b7b7;
color:#606060;
cursor:pointer;
display:inline-block;
font:bold 100% Arial,sans-serif;
       
}
#msg {
    height:80px auto;
    background-color:grey;
    padding:2px;
    margin-top:0px;
    border-bottom:5px solid white;
    border:5px solid #F8F8FF;
    width:150px auto;
    text_align:center;
    display: none;
    position: fixed; left: 600px; top: 0; 
    z-index: 10;
    opacity: 0.8;
    z-index: 999;
    color:white;
     }
 
  .show_hide {
    display:none;
    }


/*  code below for search button* /


/* reset webkit search input browser style */
input[type=search] {
	outline: none;
}
input[type=search] {
	-webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;
}
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button {
	display: none; /* remove the search and cancel icon */
}

/* search input field */
input[type=search] {
	background: #ededed url(images/search-icon.png) no-repeat 9px center;
	border: solid 1px #ccc;
	padding: 9px 10px 9px 32px;
	width: 35px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
}
input[type=search]:focus {
	width: 130px;
	background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
}

/* placeholder */
input[type=search]:-moz-placeholder {
	color: #999;
}
input[type=search]::-webkit-input-placeholder {
	color: #999;
}

#reg_sea_bttn{

       background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
      border: solid 1px #ccc;
	padding: 9px 10px 9px 2px;
	width: 30px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
       outline: none;
        -webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;

 }
.tble1 input {
background-color:transparent;
border: 0px solid;


color:black;
font-size: 12px;
}
.tble1
{

border:1px solid silver;
margin-top:20px;
font-family: Tahoma,Verdana,Geneva,sans-serif !important;
    font-size: 12px;
}
.trcls
{

background-color:#BDBDBD;
border:1px solid silver;

}	
.tble1 td, th
{
border-collapse:collapse;
border:1px solid silver;
}
.tble1 tr
{
height:30px;
}	
</style>
<body background="back_ground.jpg" onload=shortkey_tblopen()><center>
<div class='cont'>
<table class="container"><tr><td>


<script type="text/javascript">

function pgnfn(str){
            document.getElementById('pgbtn'+str).style.background = "#ccc";
            document.f1.entrydate.focus();
}
</script>



<form name='f1' id='jforms' action='<?print $PHP_SELF?>'  method='post'> 
<br>
<table class="container" ><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;"> </font>
<br>
<center>


<? 
$query=mysqli_query($db,"select trnstyp from transactmast where trnsid='$jtype'");
$sql="select trnstyp from transactmast where trnsid='$jtype'";
$rw=mysqli_fetch_array($query);

$query11=mysqli_query($db,"select max(refno) from gst_expense where brcode='$brcode'");
$rw11=mysqli_fetch_array($query11);
if($rw11[0]<1)
{
    $refno='000001';
}
else
{
	$refno=substr($rw11[0],-6)+1;
	$refno=substr('000000'.$refno,-6);
}
 ?>

<center>
<form action="" method="POST" name='f2' >
    
   
        <table border=1 class='tble1' width=100%>
          <tr><td>Expense head</td><td>Date</td><td width="85px">Vendor Inv No.</td><td>Ref No</td><td>Vendor</td><td>Vendor Inv Date</td><td colspan=4>Narration</td></tr>
        <tr><td><input type=text size=30 name='exphd' id=exphd class=exphd>   
        </td>
        
        <td><input type=text id='leddt' name='leddt'  class='leddt' readonly value='<? echo date("Y-m-d") ?>'  size=10  onkeypress='handleEnter(this, event)' ></td>
        <td width="85px"><input type=text name='vndinvno' id=vndinvno size=10 onkeypress='handleEnter(this, event)'></td>
        <td><input type=text name=refno id=refno size=10 class='refno'  value='<?echo $refno?>'  readonly onKeydown='return handleEnter(this, event)' ></td>
        <td><input type=text id='supnm' name=supnm size=30 class='supnm' onKeydown='return handleEnter(this, event)'></td>
        <td><input type=text id='supdt' name=supdt class='vnddt' readonly value='<? echo date("Y-m-d") ?>' size=10 onkeypress='handleEnter(this, event)'></td>
        <td colspan=4><input type=text id='narrat' name=narrat size=25  class='narrat' onKeydown='return handleEnter(this, event)' autocomplete="on"></td></tr>
            </table>
    <input type="button" id='insrowbttn' onclick="insRow(event,this,this.id)"  value="+">
    <table border=1 id="myTable" class='tble1' width=100%>
 
        <?
        if($taxtype=='INTRASTATE')
        {
        ?>
        <tr class='trcls'><td>No.</td><td>Before Tax</td><td>Select Tax %</td><td>Item</td><td>CGST %</td><td>CGST Amt</td><td>SGST %</td><td>SGST Amt</td><td>Expense Amt</td><td>Delete</td></td></tr>
  
        <?  
        }
        ?>
         <?
        if($taxtype=='INTERSTATE')
        {
        ?>
        <tr class='trcls'><td>No.</td><td>Before Tax</td><td>Select Tax %</td><td>Ledger</td><td>IGST %</td><td>IGST Amt</td><td>Expense Amt</td><td>Delete</td></td></tr>
  
        <?  
        }
        ?>

</table>
<br>  
<tr><td align=right>Total<input type=text style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="tot" id="tot" value="0.00"></td> </tr>
<tr><td align=right>Round Off<input type=text style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;"  name="rndoff" id="rndoff" value="0.00"></td> </tr>
<tr><td colspan='4' style="text-align:right;">
Net Total
<input  style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="spare_total" id="spare_total" value="0.00" type="text">
</td></tr>
<tr><td colspan=2 align='center'><a href="#login-box" class="login-window" style="text-decoration:none;"> <input  style="height:32px;width:110px;" value="Save" type="button" id='svbttn'></a></td></tr>
<input type=hidden name='taxtype' id='taxtype' value='<? echo $taxtype ?>'>
<input type='hidden' name='savecount' id='savecount' value='0'>
</form>
</center>
<br><br>
<div id="login-box" class="login-popup">
        <a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
          <div id='msgbox'></div>
		</div>

<datalist id="htmlListTags"></datalist>
<div id='txtHint'></div>
</body>
</html>
</td></tr></table>

<script>

  



function delrow(r)
  {

    var i=r.parentNode.parentNode.rowIndex;
     document.getElementById('myTable').deleteRow(i);
    var rowCount = document.getElementById('myTable').rows.length;
     if(rowCount<=1)
       {
          document.getElementById('insrowbttn').type='button';
       }
   
        cnt--;
         cur--;
   }
 
function calcval()
{

	var bframt=document.getElementById("bfrtx").value;
	var cgsamt;
	var sumnw;
	if(document.getElementById("taxtype").value=='INTRASTATE')
    {
        document.getElementById('cgstamt').value=(bframt*document.getElementById('cgstp').value/100).toFixed(2);
        document.getElementById('sgstamt').value=(bframt*document.getElementById('sgstp').value/100).toFixed(2);
	    sumnw=parseFloat(bframt)+parseFloat(document.getElementById('cgstamt').value)+parseFloat(document.getElementById('sgstamt').value);
    }
    if(document.getElementById("taxtype").value=='INTERSTATE')
    {
        document.getElementById("igstamt").value=(bframt*document.getElementById('igstp').value/100).toFixed(2);
        sumnw=parseFloat(bframt)+parseFloat(document.getElementById('igstamt').value);        
    }
	
		document.getElementById('ntamt[]').value=sumnw.toFixed(2); 

}


 
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}  
   
   
    
function showregister(str,r,str2)
{
    var i=r.parentNode.parentNode.rowIndex;
    var tbl = document.getElementById('myTable');
    var id1=i;
    if (str=="")
    {
        document.getElementById("to_new_registerTD").innerHTML="";
        return;
    }
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            if(document.getElementById("taxtype").value=='INTRASTATE')
            {
                document.getElementById("cgstp"+id1).value=document.getElementById("mblamt").value;
                document.getElementById("sgstp"+id1).value=document.getElementById("mcrlmt").value;
                if(document.getElementById("befrtx"+id1).value>0)
                {
                var cgstamount=parseFloat(document.getElementById("cgstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
                document.getElementById("cgstamt"+id1).value=cgstamount.toFixed(2);
                var sgstamount=parseFloat(document.getElementById("sgstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
                document.getElementById("sgstamt"+id1).value=sgstamount.toFixed(2);
                }
                document.getElementById("ntamt"+id1).value=(parseFloat(document.getElementById("befrtx"+id1).value)+parseFloat(document.getElementById("cgstamt"+id1).value)+parseFloat(document.getElementById("sgstamt"+id1).value)).toFixed(2);
                              var p=0;
                 var ups1 = document.getElementsByName('ntamt[]'), sum1 = 0, p;

                  for(p = ups1.length; p--;)

                              sum1 += parseFloat(ups1[p].value, 10);
                                              var sum1_rnd=Math.round(sum1);
                              var dif=sum1-sum1_rnd;
                              
                 document.getElementById('rndoff').value=dif.toFixed(2);             
                document.getElementById('spare_total').value=sum1_rnd.toFixed(2);
                document.getElementById('tot').value=sum1.toFixed(2);
            }
            
            if(document.getElementById("taxtype").value=='INTERSTATE')
            {
                document.getElementById("igstp"+id1).value=document.getElementById("mdsbl").value;
                if(document.getElementById("befrtx"+id1).value>0)
                {
                var igstamount=parseFloat(document.getElementById("igstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
                document.getElementById("igstamt"+id1).value=igstamount.toFixed(2);
                }
                document.getElementById("ntamt"+id1).value=(parseFloat(document.getElementById("befrtx"+id1).value)+parseFloat(document.getElementById("igstamt"+id1).value)).toFixed(2);
            
                                              var p=0;
                 var ups1 = document.getElementsByName('ntamt[]'), sum1 = 0, p;

                  for(p = ups1.length; p--;)

                              sum1 += parseFloat(ups1[p].value, 10);
                            var sum1_rnd=Math.round(sum1);
                              var dif=sum1-sum1_rnd;
                              
                 document.getElementById('rndoff').value=dif.toFixed(2);             
                document.getElementById('spare_total').value=sum1_rnd.toFixed(2);
                document.getElementById('tot').value=sum1.toFixed(2);
            }
        }
      
    }
    xmlhttp.open("GET","showtax.php?cname="+str,true);
    xmlhttp.send();

}

function calamt(str,r,qid)
{
    var i=r.parentNode.parentNode.rowIndex;
    var tbl = document.getElementById('myTable');
    var id1=i;
   
    if(document.getElementById("taxtype").value=='INTRASTATE')
    {  
        if(document.getElementById("cgstp"+id1).value>0)
        {
            var cgstamount=parseFloat(document.getElementById("cgstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
            document.getElementById("cgstamt"+id1).value=cgstamount.toFixed(2);
            var cgstamount=document.getElementById("cgstamt"+id1).value;
        }
        else
        {
            var cgstamount=0;
        }
        
        if(document.getElementById("sgstp"+id1).value>0)
        {
            var sgstamount=parseFloat(document.getElementById("sgstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
            document.getElementById("sgstamt"+id1).value=sgstamount.toFixed(2);
            var sgstamount=document.getElementById("sgstamt"+id1).value;
        }
        else
        {
            var sgstamount=0;
        }
        document.getElementById("ntamt"+id1).value=(parseFloat(document.getElementById("befrtx"+id1).value)+parseFloat(cgstamount)+parseFloat(sgstamount)).toFixed(2);
        
                      var p=0;
                 var ups1 = document.getElementsByName('ntamt[]'), sum1 = 0, p;
                
                  for(p = ups1.length; p--;)

                              sum1 += parseFloat(ups1[p].value, 10);
                              var sum1_rnd=Math.round(sum1);
                              var dif=sum1-sum1_rnd;
                              
                 document.getElementById('rndoff').value=dif.toFixed(2);             
                document.getElementById('spare_total').value=sum1_rnd.toFixed(2);
                document.getElementById('tot').value=sum1.toFixed(2);
                
            
    }
    if(document.getElementById("taxtype").value=='INTERSTATE')
    {  
        if(document.getElementById("igstp"+id1).value>0)
        {
            var igstamount=parseFloat(document.getElementById("igstp"+id1).value/100)*document.getElementById("befrtx"+id1).value;
            document.getElementById("igstamt"+id1).value=igstamount.toFixed(2);
            var igstamount=document.getElementById("igstamt"+id1).value;
        }
        else
        {
            var igstamount=0;
        }
        document.getElementById("ntamt"+id1).value=(parseFloat(document.getElementById("befrtx"+id1).value)+parseFloat(igstamount)).toFixed(2);
    
                      var p=0;
                 var ups1 = document.getElementsByName('ntamt[]'), sum1 = 0, p;

                  for(p = ups1.length; p--;)

                              sum1 += parseFloat(ups1[p].value, 10);
                            var sum1_rnd=Math.round(sum1);
                              var dif=sum1-sum1_rnd;
                              
                 document.getElementById('rndoff').value=dif.toFixed(2);             
                document.getElementById('spare_total').value=sum1_rnd.toFixed(2);
                document.getElementById('tot').value=sum1.toFixed(2);
            
    }
    
    
    //var netamt=parseFloat(document.getElementById("fivetax"+id1).value)+parseFloat(document.getElementById("fivepnttax"+id1).value)+parseFloat(document.getElementById("fourteentax"+id1).value)+parseFloat(document.getElementById("lubtx"+id1).value)+parseFloat(document.getElementById("servtx"+id1).value)+parseFloat(document.getElementById("kkcs"+id1).value)+parseFloat(document.getElementById("sbc"+id1).value)+parseFloat(document.getElementById("others"+id1).value)+parseFloat(document.getElementById("roundof"+id1).value);


//document.getElementById("ntamt"+id1).value=netamt.toFixed(2);
//var netamt=Math.round(document.getElementById("ntamt"+id1).value);
//var rondofvl= netamt-document.getElementById("ntamt"+id1).value;

 //document.getElementById("roundof"+id1).value=Math.abs(rondofvl).toFixed(2);     
}

</script>
<script type="text/javascript">
function shortkey_tblopen()
	{
       	var rowCounts = document.getElementById('myTable').rows.length;
		if(rowCounts<=1)
			{
		          
				document.getElementById('insrowbttn').click(); 
             }		   					
 		 
 	}

</script>
<style>
.comp{
  width:250px;
  }
</style>