function changeUpQuantity(e,tItem,tField,tNoQuantity,tNumber)
{
	 
	 var lstUpQuantity = getEventTarget(e); 
	 var chkExl = document.getElementById("exlchk"+tNumber);
	 var txtUpQuantityPrice = document.getElementById("txtUpQuantityPrice"+tNumber);
	 var txtUpQuantityPrev = document.getElementById("txtUpQuantityPrev"+tNumber);
	 var txtCurrencyUpPrice = document.getElementById("txtCurrencyUpPrice"+tNumber);
     var txtPrice = document.getElementById("txtPrice");
	 var txtSumPrice = document.getElementById("txtSumPrice");
     var txtDevPrice = document.getElementById("txtDevPrice");
	 var txtQuantity = document.getElementById("txtQuantity");
	 var txtUpSumQuantity = document.getElementById("txtUpSumQuantity");
	 var txtUpSumPrice = document.getElementById("txtUpSumPrice");
	 var txtUpDevPrice = document.getElementById("txtUpDevPrice");

	
	 var lUpPrice =  parseInt(chkExl.value);
	 var lUpDevPrice =  parseInt(txtUpDevPrice.value);
	 var lUpCurrencyPrice =  parseInt(txtCurrencyUpPrice.value);
	 var lUpQuantity =  parseInt(lstUpQuantity.value);
	 var lUpQuantityPrice =  parseInt(txtUpQuantityPrice.value);
	 var lUpQuantityPrev =  parseInt(txtUpQuantityPrev.value);
	 var lUpSumQuantity = parseInt(txtUpSumQuantity.value);
	 var lUpSumPrice = parseInt(txtUpSumPrice.value);

     
     if (txtSumPrice)
     	var lPrice =  parseInt(txtSumPrice.value);     
     else
     	var lPrice =  parseInt(txtPrice.value);
	 
	 var lDevPrice =  parseInt(txtDevPrice.value);
     var lQuantity = parseInt(txtQuantity.value);

     
     if (chkExl.checked)
     {
     	if (txtSumPrice)
     		txtSumPrice.value = lPrice - lUpQuantityPrice;
 		else
     		txtPrice.value = lPrice - lUpQuantityPrice;
     	
     	txtUpSumPrice.value =  lUpSumPrice - lUpQuantityPrice;
        txtQuantity.value = lQuantity - lUpQuantityPrev;  
        txtUpSumQuantity.value = lUpSumQuantity - lUpQuantityPrev;
        txtUpDevPrice.value = lUpDevPrice - lUpCurrencyPrice;
        txtDevPrice.value = lDevPrice - lUpCurrencyPrice;

     }
     
     
     lQuantity = parseInt(txtQuantity.value);
     
     txtUpQuantityPrice.value = lUpPrice*lUpQuantity;
     txtUpQuantityPrev.value = lUpQuantity;
     txtCurrencyUpPrice.value =  lUpCurrencyPrice*lUpQuantity;
     
     
     if (chkExl.checked)
     	changeUpPrice(e,tItem,tField,tNoQuantity,tNumber,false);  
}


function changeUpPrice(e,tItem,tField,tNoQuantity,tNumber,tSetFields)
{
		
	var chkExl = document.getElementById("exlchk"+tNumber);
    var txtUpQuantityPrice = document.getElementById("txtUpQuantityPrice"+tNumber);
    var txtUpQuantityPrev = document.getElementById("txtUpQuantityPrev"+tNumber);
	var txtPrice = document.getElementById("txtPrice");
    var txtSumPrice = document.getElementById("txtSumPrice");
    var txtQuantity = document.getElementById("txtQuantity");
	var txtUpItems = document.getElementById("txtUpItems");
	var txtUpFields = document.getElementById("txtUpFields");
	var chkInstallment = document.getElementById("chkInstallment");
	
	var txtCurrencyUpPrice = document.getElementById("txtCurrencyUpPrice"+tNumber);
	var txtDevPrice = document.getElementById("txtDevPrice");
	var txtUpDevPrice = document.getElementById("txtUpDevPrice");
	var txtUpSumPrice = document.getElementById("txtUpSumPrice");
	var txtUpSumQuantity = document.getElementById("txtUpSumQuantity");

	var lPrice = parseInt(txtPrice.value);
	var lCurrencyUpPrice = parseInt(txtCurrencyUpPrice.value);
	
	if (txtDevPrice)
		var lDevPrice = parseInt(txtDevPrice.value);
	
	if (txtUpDevPrice)
		var lUpDevPrice = parseInt(txtUpDevPrice.value);
	
	var lUpSumPrice = parseInt(txtUpSumPrice.value);
	var lUpSumQuantity = parseInt(txtUpSumQuantity.value);
    var lUpPrice =  parseInt(txtUpQuantityPrice.value);
	var lUpQuantity = parseInt(txtUpQuantityPrev.value);
	var lQuantity = parseInt(txtQuantity.value);
	var lUpItems = txtUpItems.value;
	var lUpFields = txtUpFields.value;
		
	tItem = tItem+",";
	tField = tField+",";
	
    
	if (chkExl.checked)
	{
		if (txtSumPrice)
		{
			var lPrice = parseInt(txtSumPrice.value);
			txtSumPrice.value = lPrice + lUpPrice;
		}
		
		if (txtUpSumPrice)
		{
			txtUpSumPrice.value = lUpSumPrice + lUpPrice;
		}
		
		if (txtUpSumQuantity)
		{
			txtUpSumQuantity.value = lUpSumQuantity + lUpQuantity;
		}
		
		if (txtUpDevPrice)
		{
			txtUpDevPrice.value = lUpDevPrice + lCurrencyUpPrice;
		}
		
		if (txtDevPrice)
		{
			txtDevPrice.value = lDevPrice + lCurrencyUpPrice;
		}
		
		txtPrice.value = lPrice + lUpPrice;
		
		if (tNoQuantity!='T')
			txtQuantity.value = lQuantity + lUpQuantity;

		if (tSetFields)
		{
			txtUpItems.value = lUpItems + tItem;
			txtUpFields.value =  lUpFields + tField;
		}			
	}
	else
	{
		if (txtSumPrice)
		{
			var lPrice = parseInt(txtSumPrice.value);
			txtSumPrice.value = lPrice - lUpPrice;
		}
		
		if (txtUpSumPrice)
		{
			txtUpSumPrice.value = lUpSumPrice - lUpPrice;
		}
		
		if (txtUpSumQuantity)
		{
			txtUpSumQuantity.value = lUpSumQuantity - lUpQuantity;
		}
		
		if (txtUpDevPrice)
		{
			txtUpDevPrice.value = lUpDevPrice - lCurrencyUpPrice;
		}
		
		if (txtDevPrice)
		{
			txtDevPrice.value = lDevPrice - lCurrencyUpPrice;
		}
		
		txtPrice.value = lPrice - lUpPrice;
		
		if (tNoQuantity!='T')
			txtQuantity.value = lQuantity - lUpQuantity;

		
		if (tSetFields)
		{
			txtUpItems.value =  lUpItems.replace(tItem,"");
			txtUpFields.value = lUpFields.replace(tField,"");
		}
	
	}
	
	
	if (chkInstallment.checked)
		changeInstallment(e);
	
}


