/*
 * ITR5_Calculations.js
 *
 * Created on 11/10/2013
 *
 * Copyright(c) 2014  TCS Company, Inc.  All Rights Reserved.
 * This software is the proprietary information of TCS Company.
 *
 */


var globTempStcg1 = 0;
var globTempStcg2 = 0;
var globTempltcg1 = 0;
var globTempltcg2 = 0;
var dpmCeasesMesg ='';
var doaCeasesMesg ='';


var FY_start_date = '01/04/2019';
var FY_end_date = '31/03/2020';
var AY_start_date = '01/04/2020';
var Filing_dueDate = '10/01/2021';
//var Int_start_date_234A = '01/01/2021'; //modified due date

var slab0_end_date = '15/06/2019';
var slab1_start_date = '16/06/2019';
var slab1_end_date = '16/09/2019';
var slab2_start_date = '17/09/2019';
var slab2_end_date = '16/12/2019';
var slab3_start_date = '17/12/2019';
var slab3_end_date = '16/03/2020';
var slab4_start_date = '17/03/2020';

var Cg_ded_start_date = '31/03/2015';
var Cg_ded_end_date = '16/02/2021';


var Int_234A_Due_date_234A = '11/01/2021';
//var Int_234A_IF_NO_dt = '31/12/2020';
var sectionClaimed = {};

function calcITR5(){
	//setTimeout(calcITR5Impl, 100);
	calcITR5Impl();
}

function calcITR5Impl(){
	try{
		if (document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '04'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '03'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '21'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '22'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '20'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '23'||
				document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value == '30') {
			slab2_end_date = '31/12/2019';
			slab3_start_date = '01/01/2020';
		} else {
			slab2_end_date = '16/12/2019';
			slab3_start_date = '17/12/2019';

		}
		var cgosIncome = {};
		calcOthAssetLTCG();
		initCgOsInc(cgosIncome);
		enable115AdP();
		enableTable('scheduleCGPost45.shortTermCapGainPost45.unutilizedCapgainFlag','Y','scheduleStcgunUtilizedCapGain54');
		enableTable('scheduleCGPost45.LongTermCapGainPost45.unutilizedCapgainFlag','Y','scheduleLtcgunUtilizedCapGain54');
		scheduleHPCalcFor5();
		calculateTotalDeductions();
		otherProperty();
		//calcSch112A();
		othergener();
		enableGrossAmtTDS1();
		validateTDS2();
		validateTDS3();
		validatepoint1513();
		validatePLafter61();
		enableSch80p();
		//enable80P1();
		//disable80P();
		calculate80P();
		setSecRespOnSave();
		calculatedon80GGA();
		calcTotFullConA('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdRecvUnqshr','scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fairMrktValueUnqshr','scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdSec50CA');
		scheduleCGA('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdSec50CA','scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdOthUnqshr','scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration');
		calcTotFullConA('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullValueConsdRecvUnqshr','scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fairMrktValueUnqshr', 'scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullValueConsdSec50CA');
		scheduleCGA('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullValueConsdSec50CA','scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullValueConsdOthUnqshr','scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsideration');
		scheduleCGA('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullValueConsdRecvUnqshr','scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullValueConsdOthUnqshr','scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration');
		calcTotFullConTable();
		scheduleCGB6a();
		scheduleCGB8a();
		enableAuditDetailsLiable();
		enableAuditReportDetails();
		if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value=='NRI'){
			scheduleCGGrtr();
		}


	/*	var effectOnProfit = document.getElementsByName('partaoi.profDeviatDueAcctMeth')[0];
		effectOnProfit.value =  coalesceSetRet('itrScheduleICDS.totNetEffect') ;
		if(coalesceSetRet('itrScheduleICDS.totNetEffect')<0){
			effectOnProfit.value =  coalesceSetRet('itrScheduleICDS.totNetEffectN') ;
		}

*/
		calcBalSheet();
		calcClosingStockTotal();
		calculateRemurationPaid();
		calculatePL();
		calcTotSchPL47i();
		calcSchTPSA();
		calcSchBP();
		income115BBF_BP();
		calcPartAOI();
		calculateSchDPM();
		calculateSchDOA();
		calcSchDEPFor6();
		calcSchDCGFor6();
		calcSchESRFor5();
		validateSchOSDTAA();
		
		calcUD();
		//calc10A();
		//populateDI();
		calc10AA();
		calcSchBP();
		validateSchBPA5();
		calCGPointB8Total();
		calcSchCG(cgosIncome);
		
		var simap = calculateOS(cgosIncome);
		scheduleCGA5a();
		OSSubCal();
		OSSubCalInc();
		calculateCYLA(cgosIncome);
		var amt5BBC = simap['5BBC'];
		var amt5Ea = simap['5Ea'];
		/*  calculateScheduleOStaxBenifit();*/
		populateSI(cgosIncome,simap);
		calcTotal80IA();
		calcTotal80IB();
		calcTotal80IC();
		calculatePartBTI_first();
		//enable80GGAtables();
		enablepl();
		enablePLtables();
		enablePL63tables();
		caclDedSchVIA();
		calcTotal80GDeductions('ded100PerWithoutQual',3,2,amt5BBC,amt5Ea);
		calcTotal80GDeductions('ded50WithoutQual',3,2,amt5BBC,amt5Ea);
		calcTotal80GDeductions('ded100Qual',3,2,amt5BBC,amt5Ea);
		calcTotal80GDeductions('ded50WithQual',3,2,amt5BBC,amt5Ea);
		panValidation80GGA('schedule80GGA');
		caclDedSchVIA();
		calcTotalAmt('schEIMinorChild');
		calculateNetAgricultureIncomeforEI();
		calcScheduleSI();
		calTotalEI();
		calcTotSchEIDTAA();
		calcTotSchEIOthers();
		calcTotSchIF();
		calculatePartBTI_second();
		calcScheduleFSI();
		populateAMT();
		calculateTCS();
		calculateTiTti(cgosIncome);
		calCGA7TotalSum();
		calCGPointB8Total();
		calculatePartBTTI_second(cgosIncome);
		populateAMTC();
		calScheduleAmtc();
		cflFieldxiii();
		calculateTotalTaxIT('scheduleIt');
		makeSurchargeCessEditable();
		validatePartAGen2();
		calcTotalICDS();
		surchargeEditable();
		checkSchEIxmlblock();
		//enable44AD();
		enableFieldsPDTAOT();
		pdtItr5NotReqd();
		validateSchCGSTCGAmt();
		validateSchCGLTCGAmt();
		validateTDS29Grtthen67();
		validateTDS39Grtthen67();
		checkFor16thFiledValue();
		disableTDS2Fields();
		disableTDS3Fields();
		calcAnyOtherIncome();
		enableTPSA();
		enableDirecComp();
		/*calculateScheduleOStaxBenifit();
		calculateScheduleOSicnomeBenifit();*/
		calculateSchRA();
		calcTotSchTradingRev();
		calcTotSchTradingExp();
		calcTotSchPL47i();
		calcTotSchPL47ii();
		calculatePartBTI23FBC();
		disablepartbTI23FB();
		disablepartbTI23FC();
		scheduleCFLfieldReadonly();
		
		
		adjustForm();
		calculateScheduleDI();
		auditEnableDia();
		schAmtcgreyOff();
		schVIApartCgreyOff();
		schCgA3greyOff();
		disableSch80();
		schPL48();
		checkFor80PFiledValue();
		siDisable11();
		disableScheduleFor115AD('Sch115Ad1');
		
	}catch(e){
		alert('error in calcITR5 ='+ e.stack);
	}
}

function validateSec50C_CG(capGainType) {
	var fullConsideration = document.getElementsByName('scheduleCGPost45.'+capGainType+'.saleofLandBuild.fullConsideration')[0];
	var propertyValuation = document.getElementsByName('scheduleCGPost45.'+capGainType+'.saleofLandBuild.propertyValuation')[0];
	var fullConsideration50C = document.getElementsByName('scheduleCGPost45.'+capGainType+'.saleofLandBuild.fullConsideration50C')[0];

	if(fullConsideration50C.value!=fullConsideration.value && fullConsideration50C.value!=propertyValuation.value){
		j.setFieldError('scheduleCGPost45.'+capGainType+'.saleofLandBuild.fullConsideration50C','Please enter value from ai or aii only');
		addErrorXHTML(fullConsideration50C ,'Please enter value from ai or aii only',true);
	}
}

function scheduleCFL1fieldReadonlyonLoad(){
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var subStatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;


	if(status=='14'&& subStatus=='21')
	{

		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.hpLossCFTotal')[0].readOnly=false;
		/*document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmInsuCF')[0].readOnly=false;*/
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=false;
		
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.hpLossCFTotal')[0].readOnly=false;
		/*document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.busLossOthThanSpecLossCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmSpecBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmSpecifiedBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmInsuCF')[0].readOnly=false;
	*/	document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.stcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.ltcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.othSrcLossRaceHorseCF')[0].readOnly=false;

	}
	else{
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.hpLossCFTotal')[0].readOnly=true;
		/*document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.lossFrmInsuCF')[0].readOnly=true;
		*/
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.totalLossCFCurrent.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.hpLossCFTotal')[0].readOnly=true;
/*		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.busLossOthThanSpecLossCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmSpecBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmSpecifiedBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.lossFrmInsuCF')[0].readOnly=true;*/
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.stcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.ltcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.othSrcLossRaceHorseCF')[0].readOnly=true;

	}

}

function scheduleCFLfieldReadonlyonLoad(){
	var returnFiled = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var returnFiledsec = document.getElementsByName('partAGEN1.filingStatus.returnFileInResp')[0].value;
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var subStatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;


	if((status=='14'&& subStatus=='21') || returnFiled=='12'||returnFiledsec=='13'||returnFiled=='20'){
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=false;

	}
	else{
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=true;

	}

}
function scheduleCFLfieldReadonly(){
	var returnFiled = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var returnFiledsec = document.getElementsByName('partAGEN1.filingStatus.returnFileInResp')[0].value;

	if(returnFiled=='12'||returnFiledsec=='13'||returnFiled=='20'){
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=false;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=false;

	}
	else{
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly=true;
		document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly=true;

	}

}

function validateNatureOfBussiness(){
	var table = document.getElementById('natOfBustTradeTableId');
	var rowCount = table.rows.length;

	for(var i=0;i<rowCount-2;i++){
		if(document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value=="00002"&&(document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value!="7"&&document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value!="12"&&document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value!="11"&&document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value!="13"&&document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value!="18")){
			j.setFieldError('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code','Please select applicable nature of business code for the selected sub status');
			addErrorXHTML( document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0],
					'Please select applicable nature of business code for the selected sub status',
					true);
		}
		if((document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value!='') && (document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].tradeName1')[0].value==''))
		{
			j.setFieldError('partAGEN2.natOfBus.natureOfBusiness[' + i + '].tradeName1','Please enter TradeName in Nature of Business');
			addErrorXHTML( document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].tradeName1')[0],
					'Please enter TradeName in Nature of Business',
					true);
		}
	}
}


function checkFor16thFiledValue(){
	if( getAmt('scheduleDPM.plantMachinery.rate15.depreciationDetail.proportionateAggDepreciation') >
	getAmt('scheduleDPM.plantMachinery.rate15.depreciationDetail.netAggregateDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate15.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}

	if( getAmt('scheduleDPM.plantMachinery.rate30.depreciationDetail.proportionateAggDepreciation') >
	getAmt('scheduleDPM.plantMachinery.rate30.depreciationDetail.netAggregateDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate30.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}

	if( getAmt('scheduleDPM.plantMachinery.rate40.depreciationDetail.proportionateAggDepreciation') >
	getAmt('scheduleDPM.plantMachinery.rate40.depreciationDetail.netAggregateDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate40.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}

	if( getAmt('scheduleDPM.plantMachinery.rate15.depreciationDetail.depDisAllowUs38_2') >
	getAmt('scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate15.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}

	if( getAmt('scheduleDPM.plantMachinery.rate30.depreciationDetail.depDisAllowUs38_2') >
	getAmt('scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate30.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}

	if( getAmt('scheduleDPM.plantMachinery.rate40.depreciationDetail.depDisAllowUs38_2') >
	getAmt('scheduleDPM.plantMachinery.rate40.depreciationDetail.totalDepreciation')  ){
		j.setFieldError('scheduleDPM.plantMachinery.rate40.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
}
function scheduleCGGrtr(){
	var table = document.getElementById('stcg10pctTab');
	var rowCount = table.rows.length/16;
	for(var i=0;i<rowCount;i++){
		calcTotFullConA('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fullValueConsdRecvUnqshr','scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fairMrktValueUnqshr', 'scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fullValueConsdSec50CA');
		scheduleCGA('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fullValueConsdSec50CA','scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fullValueConsdOthUnqshr','scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i + '].fullConsideration');
	
	}


}
function scheduleCGA(Grtr,Total,grndTotal){
	var afield = document
	.getElementsByName(Grtr)[0];afield.value=coalesce(afield.value);
	var bfield = document
	.getElementsByName(Total)[0];bfield.value=coalesce(bfield.value);
	var cfield = document
	.getElementsByName(grndTotal)[0];cfield.value=coalesce(cfield.value);

	cfield.value=parseInt(coalesce(afield.value),10)+parseInt(coalesce(bfield.value),10);
}

function initCgOsInc(cgosIncome){
	cgosIncome.cgInc = {};
	cgosIncome.osInc = {};
	cgosIncome.cgInc.stcg={};
	cgosIncome.cgInc.ltcg={};
	cgosIncome.cgInc.ltcg.prctg10={};
	cgosIncome.cgInc.ltcg.prctg20 = {};
	cgosIncome.cgInc.stcg.prctg30 = {};
	cgosIncome.cgInc.stcg.prctgAr = {};
	cgosIncome.cgInc.stcg.prctg15 = {};
	cgosIncome.cgInc.stcg.prctg30.sec115AD = 0;
	cgosIncome.cgInc.stcg.prctg30.secPti = 0;
	cgosIncome.cgInc.stcg.prctgAr.stcgApp = 0;
	cgosIncome.cgInc.stcg.prctgAr.secPti = 0;
	cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii = 0;
	cgosIncome.cgInc.stcg.prctg15.secPti = 0;
	cgosIncome.cgInc.stcg.prctg15.sec111a = 0;
	cgosIncome.cgInc.ltcg.prctg20.sec112 = 0;
	cgosIncome.cgInc.ltcg.prctg20.sec11EA = 0; // Not active
	cgosIncome.cgInc.ltcg.prctg20.secPti = 0;
	cgosIncome.cgInc.ltcg.prctg10.secPti = 0;
	cgosIncome.cgInc.ltcg.prctg10.sec112A = 0;
	cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP = 0;
	cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2 = 0; // B6 of CG
	cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B = 0; // B6 of CG new
	cgosIncome.cgInc.ltcg.prctg10.sec115AC_1 = 0; //B6 of CG
	cgosIncome.cgInc.ltcg.prctg10.sec115AD_3 = 0; //B6 of CG
	cgosIncome.cgInc.ltcg.prctg10.secProviso = 0; // B4e + B5d CG
	cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1 = 0; // Not active
	cgosIncome.cgInc.ltcg.prctg10.sec115E_b = 0; // Not active
	//2019 changes
	cgosIncome.cgInc.ltcg.prctg10.sec112A = 0;
	cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP = 0;

	cgosIncome.osInc.sec115A_1_a_i = 0;
	cgosIncome.osInc.sec115A_1_a_ii = 0;
	cgosIncome.osInc.sec115A_1_a_iia = 0;
	cgosIncome.osInc.sec115A_1_a_iiaa = 0;
	cgosIncome.osInc.sec115A_1_a_iiab = 0;
	cgosIncome.osInc.sec115A_1_a_iii = 0;
	cgosIncome.osInc.sec115A_1_b_A = 0;
	cgosIncome.osInc.sec115A_1_b_B = 0;
	cgosIncome.osInc.sec115AC_1_a_b = 0;
	cgosIncome.osInc.sec115ACA_1_a = 0;
	cgosIncome.osInc.sec115AD_1_i = 0;
	cgosIncome.osInc.sec115BBA = 0;
	cgosIncome.osInc.sec115BBDA = 0;
	cgosIncome.osInc.sec115BBC = 0;
	cgosIncome.osInc.sec115BBE = 0;
	cgosIncome.osInc.sec115BBF = 0;
	cgosIncome.osInc.sec115BBG = 0;
	cgosIncome.osInc.sec115BB = 0;
	cgosIncome.osInc.sec115E_a = 0;
	cgosIncome.osInc.sec111 = 0;
	cgosIncome.bpNetInc = 0;
}

function initMapForSI(cgosIncome){
	var simap = {
			//"5Eacg":cgosIncome.cgInc.ltcg.prctg20.sec11EA,
			"PTI_LTCG20P" : cgosIncome.cgInc.ltcg.prctg20.secPti,
			"5AC1c":cgosIncome.cgInc.ltcg.prctg10.sec115AC_1,
			"5ACA1b":cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1,
			"5ADiii":cgosIncome.cgInc.ltcg.prctg10.sec115AD_3,
			"5ADiiiP" : cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP,
			"5Eb":cgosIncome.cgInc.ltcg.prctg10.sec115E_b,
			"PTI_LTCG10P" : cgosIncome.cgInc.ltcg.prctg10.secPti,
			"PTI_LTCG10P112A" : cgosIncome.cgInc.ltcg.prctg10.secPti112A,
			"5AD1biip":cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii,
			"1A":cgosIncome.cgInc.stcg.prctg15.sec111a,
			"5AB1b":cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B,
			"PTI_STCG15P" : cgosIncome.cgInc.stcg.prctg15.secPti,
			"PTI_STCG30P" : cgosIncome.cgInc.stcg.prctg30.secPti,
			"2A" : cgosIncome.cgInc.ltcg.prctg10.sec112A

	};
	return simap;
}

function updateMapForSI(cgosIncome, simap){
	//simap["5Eacg"]=cgosIncome.cgInc.ltcg.prctg20.sec11EA;
	simap["PTI_LTCG20P"] = cgosIncome.cgInc.ltcg.prctg20.secPti;
	simap["5AC1c"]=cgosIncome.cgInc.ltcg.prctg10.sec115AC_1;
	simap["5ACA1b"]=cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1;
	simap["5AB1b"]=cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B;
	simap["5ADiii"]=cgosIncome.cgInc.ltcg.prctg10.sec115AD_3;
	simap["5ADiiiP"] = cgosIncome.cgInc.stcg.prctg15.sec115ADiiiP;
	simap["5Eb"]=cgosIncome.cgInc.ltcg.prctg10.sec115E_b;
	simap["PTI_LTCG10P"] = cgosIncome.cgInc.ltcg.prctg10.secPti;
	simap["PTI_LTCG10P112A"] = cgosIncome.cgInc.ltcg.prctg10.secPti112A;
	simap["5AD1biip"]=cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii;
	simap["1A"]=cgosIncome.cgInc.stcg.prctg15.sec111a;
	simap["PTI_STCG15P"] = cgosIncome.cgInc.stcg.prctg15.secPti;
	simap["PTI_STCG30P"] = cgosIncome.cgInc.stcg.prctg30.secPti;
	simap["2A"] = cgosIncome.cgInc.stcg.prctg15.sec112A;

}

function calcTotal80IA(){

	var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);

	if(parseInt(grossTotalIncome ,10)< 0){

		grossTotalIncome='';

	}

	var table = document.getElementById('taxDed80IA4iID');
	var rowCount = table.rows.length;
	var sumTotal80IAaa=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IAaa = eval(parseInt(sumTotal80IAaa,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IAaa['+i+']'),10));
	}

	var table = document.getElementById('taxDed80IA4iiID');
	var rowCount = table.rows.length;
	var sumTotal80IAa=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IAa = eval(parseInt(sumTotal80IAa,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IAa['+i+']'),10));
	}

	var table = document.getElementById('taxDed80IA4iiiID');
	var rowCount = table.rows.length;
	var sumTotal80IAb=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IAb = eval(parseInt(sumTotal80IAb,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IAb['+i+']'),10));
	}

	var table = document.getElementById('taxDed80IA4ivID');
	var rowCount = table.rows.length;
	var sumTotal80IAc=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IAc = eval(parseInt(sumTotal80IAc,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IAc['+i+']'),10));
	}

	var table = document.getElementById('taxDed80IA4vID');
	var rowCount = table.rows.length;
	var sumTotal80IAd=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IAd = eval(parseInt(sumTotal80IAd,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IAd['+i+']'),10));
	}

	document.getElementsByName('schedule80IA.totSchedule80IA')[0].value=sumTotal80IAaa+sumTotal80IAa+sumTotal80IAb+sumTotal80IAc+sumTotal80IAd;


}

function calcTotal80IB(){

	var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);

	if(parseInt(grossTotalIncome ,10)< 0){

		grossTotalIncome='';

	}


	var table = document.getElementById('deductJKLocUs80IB4');
	var rowCount = table.rows.length;
	var sumTotal80IBa=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBa = eval(parseInt(sumTotal80IBa,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBa['+i+']'),10));
	}

	var table = document.getElementById('deductBackStatesUs80IB4');
	var rowCount = table.rows.length;
	var sumTotal80IBb=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBb = eval(parseInt(sumTotal80IBb,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBb['+i+']'),10));
	}

	var table = document.getElementById('deductBackDisttUs80IB5');
	var rowCount = table.rows.length;
	var sumTotal80IBc=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBc = eval(parseInt(sumTotal80IBc,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBc['+i+']'),10));
	}

	var table = document.getElementById('deductMultiplexUs80IB7A');
	var rowCount = table.rows.length;
	var sumTotal80IBd=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBd = eval(parseInt(sumTotal80IBd,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBd['+i+']'),10));
	}

	var table = document.getElementById('deductConvCentUs80IB7B');
	var rowCount = table.rows.length;
	var sumTotal80IBe=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBe = eval(parseInt(sumTotal80IBe,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBe['+i+']'),10));
	}

	var table = document.getElementById('deductMinOilUs80IB9');
	var rowCount = table.rows.length;
	var sumTotal80IBf=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBf = eval(parseInt(sumTotal80IBf,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBf['+i+']'),10));
	}

	var table = document.getElementById('deductHousUs80IB10');
	var rowCount = table.rows.length;
	var sumTotal80IBg=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBg = eval(parseInt(sumTotal80IBg,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBg['+i+']'),10));
	}

	var table = document.getElementById('deductColdChainUs80IB11');
	var rowCount = table.rows.length;
	var sumTotal80IBh=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBh = eval(parseInt(sumTotal80IBh,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBh['+i+']'),10));
	}

	var table = document.getElementById('deductFruitVegUs80IB11A');
	var rowCount = table.rows.length;
	var sumTotal80IBi=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBi = eval(parseInt(sumTotal80IBi,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBi['+i+']'),10));
	}

	var table = document.getElementById('deductFoodGrainUs80IB11A');
	var rowCount = table.rows.length;
	var sumTotal80IBj=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBj = eval(parseInt(sumTotal80IBj,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBj['+i+']'),10));
	}

	var table = document.getElementById('deductRurHospUs80IB11B');
	var rowCount = table.rows.length;
	var sumTotal80IBk=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBk = eval(parseInt(sumTotal80IBk,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBk['+i+']'),10));
	}

	var table = document.getElementById('deductHospAnyAreaUs80IB11C');
	var rowCount = table.rows.length;
	var sumTotal80IBl=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80IBl = eval(parseInt(sumTotal80IBl,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80IBl['+i+']'),10));
	}

	document.getElementsByName('schedule80IB.totSchedule80IB')[0].value=
		sumTotal80IBa+
		sumTotal80IBb+
		sumTotal80IBc+
		sumTotal80IBd+
		sumTotal80IBe+
		sumTotal80IBf+
		sumTotal80IBg+
		sumTotal80IBh+
		sumTotal80IBi+
		sumTotal80IBj+
		sumTotal80IBk+
		sumTotal80IBl;


}

function calcTotal80IC(){
	var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);

	if(parseInt(grossTotalIncome ,10)< 0){

		grossTotalIncome='';

	}

	var table = document.getElementById('deductInSikkim');
	var rowCount = table.rows.length;
	var sumTotal80ICa=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICa = eval(parseInt(sumTotal80ICa,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICa['+i+']'),10));
	}
	var table = document.getElementById('deductInHimachalP');
	var rowCount = table.rows.length;
	var sumTotal80ICb=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICb = eval(parseInt(sumTotal80ICb,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICb['+i+']'),10));
	}
	var table = document.getElementById('deductInUttaranchal');
	var rowCount = table.rows.length;
	var sumTotal80ICc=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICc = eval(parseInt(sumTotal80ICc,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICc['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastAassam');
	var rowCount = table.rows.length;
	var sumTotal80ICda=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICda = eval(parseInt(sumTotal80ICda,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICda['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastArunachalPradesh');
	var rowCount = table.rows.length;
	var sumTotal80ICdb=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICdb = eval(parseInt(sumTotal80ICdb,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICdb['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastManipur');
	var rowCount = table.rows.length;
	var sumTotal80ICdc=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICdc = eval(parseInt(sumTotal80ICdc,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICdc['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastMizoram');
	var rowCount = table.rows.length;
	var sumTotal80ICdd=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICdd = eval(parseInt(sumTotal80ICdd,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICdd['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastMeghalaya');
	var rowCount = table.rows.length;
	var sumTotal80ICde=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICde = eval(parseInt(sumTotal80ICde,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICde['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastNagaland');
	var rowCount = table.rows.length;
	var sumTotal80ICdf=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICdf = eval(parseInt(sumTotal80ICdf,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICdf['+i+']'),10));
	}
	var table = document.getElementById('deductInNorthEastTripura');
	var rowCount = table.rows.length;
	var sumTotal80ICdg=0;
	for(var i=0;i<rowCount-2;i++){
		sumTotal80ICdg = eval(parseInt(sumTotal80ICdg,10) + parseInt(coalesceSetRet('schedule80.dedUs80Detail.dedFromUndertaking.80ICdg['+i+']'),10));
	}

	var totDeductInNorthEast=$('[name="schedule80IC.deductInNorthEast.totDeductInNorthEast"]')[0];

	totDeductInNorthEast.value=
		sumTotal80ICda+
		sumTotal80ICdb+
		sumTotal80ICdc+
		sumTotal80ICdd+
		sumTotal80ICde+
		sumTotal80ICdf+
		sumTotal80ICdg;


	document.getElementsByName('schedule80IC.totSchedule80IC')[0].value=
		sumTotal80ICa+
		sumTotal80ICb+
		sumTotal80ICc+
		sumTotal80ICda+
		sumTotal80ICdb+
		sumTotal80ICdc+
		sumTotal80ICdd+
		sumTotal80ICde+
		sumTotal80ICdf+
		sumTotal80ICdg;
}


function calcTotal80GDeductions (tableId,noOfRow,last,amt5BBC,amt5Ea)  {
	try {

		var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);
		var incChrgable= coalesce(document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0].value);
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
		var ded10A=coalesce(document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0].value);

		if(parseInt(grossTotalIncome ,10)< 0){

			grossTotalIncome='0';

		}

		var residue50Perc;
		var qualifyingLimit;
		var scheduleVIA =  document.getElementsByName('scheduleVIA.deductUndChapVIA.totalChapVIADeductions')[0]; scheduleVIA.value = coalesce(scheduleVIA.value);
		var schedule80G=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80G')[0]; schedule80G.value = coalesce(schedule80G.value);
		var schedule80GGC=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGC')[0]; schedule80GGC.value = coalesce(schedule80GGC.value);
		var schedule80JJAA=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJAA')[0]; schedule80JJAA.value = coalesce(schedule80JJAA.value);
		var usr80GGC=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGC')[0];
		usr80GGC.value = coalesce(usr80GGC.value);
		var deductionsSysTotal=0;

		deductionsSysTotal=zeroOrMore(eval(parseInt(scheduleVIA.value,10)-parseInt(schedule80G.value,10)));

		if(parseInt(deductionsSysTotal ,10)> parseInt(grossTotalIncome ,10)){

			deductionsSysTotal=grossTotalIncome;
		}

		var gtiLimit=eval(parseInt(coalesce(grossTotalIncome),10)-parseInt(coalesce(incChrgable),10)-parseInt(coalesce(ded10A),10)) ;

		if(gtiLimit<0){
			gtiLimit=0;
		}
		var tab = document.getElementById(tableId);
		var allInputTags = tab.getElementsByTagName('input');

		if ( tableId == 'ded100PerWithoutQual' ) {
			for(var i = 0; i < allInputTags.length; i++) {
				if (allInputTags[i].name.match("eligibleDonationAmt$")) {

					if( parseInt(allInputTags[i-3].value,10) > parseInt(2000 ,10)) {
						allInputTags[i].value = coalesce(allInputTags[i - 2].value);
					}
					else
					{
						allInputTags[i].value = eval(parseInt(coalesce(allInputTags[i - 2].value)) + parseInt(coalesce(allInputTags[i - 3].value)));
					}

					if( parseInt(allInputTags[i].value,10) > parseInt(gtiLimit ,10)) {
						allInputTags[i].value = gtiLimit;
					}
				}
			}
			calcTableTotEligAmt('ded100PerWithoutQual',qualifyingLimit,residue50Perc);
		}

		if ( tableId == 'ded50WithoutQual' ) {
			for(var i = 0; i < allInputTags.length; i++) {
				if (allInputTags[i].name.match("eligibleDonationAmt$")) {


					if( parseInt(allInputTags[i-3].value,10) > parseInt(2000 ,10)) {
						allInputTags[i].value = parseInt(Math.round(coalesce(allInputTags[i - 2].value)/2) , 10);
					}
					else
					{
						allInputTags[i].value = eval(parseInt(Math.round(coalesce(allInputTags[i - 2].value)/2) , 10) + parseInt(Math.round(coalesce(allInputTags[i - 3].value)/2) , 10));
					}

					if( parseInt(allInputTags[i].value ,10) > parseInt(gtiLimit ,10) ) {
						allInputTags[i].value = gtiLimit;
					}

				}
			}
			calcTableTotEligAmt('ded50WithoutQual',qualifyingLimit,residue50Perc);
		}


		//Net Qualifyin Limit calculation


		var adjstGTI;
		if(grossTotalIncome==scheduleVIA.value){
			adjstGTI=0;
		}else{

			adjstGTI = eval(parseInt(grossTotalIncome,10))-eval(parseInt(deductionsSysTotal,10))
			-eval(incChrgable)
			//+ parseInt(document.getElementsByName('scheduleSI.splCodeRateTax[].splRateInc')[0].value)
			//+ parseInt(document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0].value)
			+ parseInt(coalesce(amt5BBC))
			+ parseInt(coalesce(amt5Ea));
			//+ parseInt(coalesce(amt5BBC));
		}

		qualifyingLimit = eval(parseInt(adjstGTI ,10) * parseFloat('0.10'));

		if(parseInt(qualifyingLimit,10) <0){
			qualifyingLimit='0';
		}
		var totEligAmtTableC = document.getElementsByName('schedule80G.don100PercentApprReqd.totEligibleDon100PercentApprReqd')[0];

		if ( tableId == 'ded100Qual' ) {
			for(var i = 0; i < allInputTags.length; i++) {
				if (allInputTags[i].name.match("eligibleDonationAmt$")) {
					if( parseInt(allInputTags[i-3].value,10) > parseInt(2000 ,10)) {
						allInputTags[i].value = parseInt(Math.round(coalesce(allInputTags[i - 2].value)) , 10);
					}
					else
					{
						allInputTags[i].value = eval(parseInt(Math.round(coalesce(allInputTags[i - 2].value)) , 10) + parseInt(Math.round(coalesce(allInputTags[i - 3].value)) , 10));
					}
					if( parseInt(allInputTags[i].value ,10) > parseInt(qualifyingLimit , 10)) {
						allInputTags[i].value = parseInt(qualifyingLimit , 10);
					}



				}
			}
			calcTableTotEligAmt('ded100Qual',qualifyingLimit,residue50Perc);
		}


		var residue;
		if(parseInt(qualifyingLimit , 10) > parseInt(coalesce(totEligAmtTableC.value) , 10)) {

			residue = eval(parseInt(qualifyingLimit , 10)) -eval( parseInt(totEligAmtTableC.value , 10) );
		} else {
			residue = parseInt('0' ,10) ;
		}


		residue50Perc = eval( parseInt(residue , 10) * parseFloat( '0.50' ));


		if ( tableId == 'ded50WithQual' ) {
			for(var i = 0; i < allInputTags.length; i++) {
				if (allInputTags[i].name.match("eligibleDonationAmt$")) {
					if( parseInt(allInputTags[i-3].value,10) > parseInt(2000 ,10)) {
						allInputTags[i].value =  parseInt(Math.round(coalesce(allInputTags[i - 2].value)/2) , 10);
					}
					else
					{
						allInputTags[i].value = eval( parseInt(Math.round(coalesce(allInputTags[i - 2].value)/2) , 10) +  parseInt(Math.round(coalesce(allInputTags[i - 3].value)/2) , 10));
					}
					if( parseInt(allInputTags[i].value ,10) > parseInt(residue50Perc , 10)) {
						allInputTags[i].value = parseInt(residue50Perc , 10);



					}
				}
			}
			calcTableTotEligAmt('ded50WithQual',qualifyingLimit,residue50Perc);
		}


	}
	catch (e) {
		alert ('ss :- ' + e);
		alert ('Uma :- ' + e.stack);
	}

}



function calcTableTotEligAmt(tableId,qualifyingLimit,residue50Perc){
	try{

		var tab = document.getElementById(tableId);
		var allInputTags = tab.getElementsByTagName('input');
		var sumOfAll = parseInt('0' ,10);
		var sumOfAlluserEntredValue = parseInt('0' ,10);
		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("eligibleDonationAmt$")) {
				sumOfAll = eval ( parseInt(sumOfAll ,10) + parseInt( allInputTags[i].value ,10) );
				sumOfAlluserEntredValue = eval ( parseInt(sumOfAlluserEntredValue ,10) + parseInt( coalesce(allInputTags[i-1].value) ,10) );
			}
		}


		var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);

		if(parseInt(grossTotalIncome ,10)< 0){

			grossTotalIncome='0';

		}

		if( parseInt(sumOfAll ,10) > parseInt(grossTotalIncome ,10)) {
			sumOfAll = grossTotalIncome;
		}



		if(tableId == 'ded100PerWithoutQual'){
			var temp1 = document.getElementsByName('schedule80G.don100Percent.totEligibleDon100Percent')[0] ;
			var temp2 = document.getElementsByName('schedule80G.don100Percent.totDon100Percent')[0] ;

			temp1.value = parseInt(sumOfAll ,10);

			temp2.value = parseInt(sumOfAlluserEntredValue ,10);


		}
		else if(tableId == 'ded50WithoutQual'){
			var temp1 = document.getElementsByName('schedule80G.don50PercentNoApprReqd.totEligibleDon50Percent')[0] ;
			var temp2 = document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentNoApprReqd')[0] ;
			temp1.value = parseInt(sumOfAll ,10);
			temp2.value = parseInt(sumOfAlluserEntredValue ,10);
		}
		else if(tableId == 'ded100Qual'){
			var temp1 = document.getElementsByName('schedule80G.don100PercentApprReqd.totEligibleDon100PercentApprReqd')[0] ;
			var temp2 = document.getElementsByName('schedule80G.don100PercentApprReqd.totDon100PercentApprReqd')[0] ;
			temp1.value = parseInt(sumOfAll ,10);
			temp2.value = parseInt(sumOfAlluserEntredValue ,10);

			if(parseInt(temp1.value ,10) > parseInt(qualifyingLimit ,10)){

				temp1.value=parseInt(qualifyingLimit ,10);;
			}

		}
		else if(tableId == 'ded50WithQual'){

			var temp1 = document.getElementsByName('schedule80G.don50PercentApprReqd.totEligibleDon50PercentApprReqd')[0] ;
			var temp2 = document.getElementsByName('schedule80G.don50PercentApprReqd.totDon50PercentApprReqd')[0] ;

			temp1.value = parseInt(sumOfAll ,10);
			temp2.value = parseInt(sumOfAlluserEntredValue ,10);

			if(parseInt(temp1.value ,10) > parseInt(residue50Perc ,10)){

				temp1.value=parseInt(residue50Perc ,10);;
			}

		}

		calcTotalDonations80G();
		calcEligbDonations80G();
	}catch(e){
		alert(e.stack);
	}
}




function calcTotalDonations80G(){

	var tot80GAuserEntrd =  document.getElementsByName('schedule80G.don100Percent.totDon100Percent')[0]; tot80GAuserEntrd.value = coalesce(tot80GAuserEntrd.value);
	var tot80GBuserEntrd =  document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentNoApprReqd')[0]; tot80GBuserEntrd.value = coalesce(tot80GBuserEntrd.value);
	var tot80GCuserEntrd =  document.getElementsByName('schedule80G.don100PercentApprReqd.totDon100PercentApprReqd')[0]; tot80GCuserEntrd.value = coalesce(tot80GCuserEntrd.value);
	var tot80GDuserEntrd =  document.getElementsByName('schedule80G.don50PercentApprReqd.totDon50PercentApprReqd')[0]; tot80GDuserEntrd.value = coalesce(tot80GDuserEntrd.value);
	var tot80GDonuserEntrd =  document.getElementsByName('schedule80G.totalDonationsUs80G')[0]; tot80GDonuserEntrd.value = coalesce(tot80GDonuserEntrd.value);

	tot80GDonuserEntrd.value = eval(tot80GAuserEntrd.value)+ eval(tot80GBuserEntrd.value)+ eval(tot80GCuserEntrd.value)+ eval(tot80GDuserEntrd.value) ;

}




function calcEligbDonations80G(){
	var grossTotalIncome = coalesce(document.getElementsByName('partBTI.grossTotalIncome')[0].value);
	var incChrgable= coalesce(document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0].value);
	var ded10A=coalesce(document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0].value);
	var gtiLimit=eval(parseInt(coalesce(grossTotalIncome),10)-parseInt(coalesce(incChrgable),10)-parseInt(coalesce(ded10A),10)) ;
	var tot80GAelig =  document.getElementsByName('schedule80G.don100Percent.totEligibleDon100Percent')[0]; tot80GAelig.value = coalesce(tot80GAelig.value);
	var tot80GBelig =  document.getElementsByName('schedule80G.don50PercentNoApprReqd.totEligibleDon50Percent')[0]; tot80GBelig.value = coalesce(tot80GBelig.value);
	var tot80GCelig =  document.getElementsByName('schedule80G.don100PercentApprReqd.totEligibleDon100PercentApprReqd')[0]; tot80GCelig.value = coalesce(tot80GCelig.value);
	var tot80GDelig =  document.getElementsByName('schedule80G.don50PercentApprReqd.totEligibleDon50PercentApprReqd')[0]; tot80GDelig.value = coalesce(tot80GDelig.value);
	var tot80GDonelig =  document.getElementsByName('schedule80G.totalEligibleDonationsUs80G')[0]; tot80GDonelig.value = coalesce(tot80GDonelig.value);

	tot80GDonelig.value = eval(tot80GAelig.value)+ eval(tot80GBelig.value)+ eval(tot80GCelig.value)+ eval(tot80GDelig.value) ;

	if(gtiLimit<0){
		gtiLimit=parseInt('0',10);
	}

	if(tot80GDonelig.value> gtiLimit){
		tot80GDonelig.value=gtiLimit;
	}
}



function caclDedSchVIA(){

	try{
		disableSch80();
		//schVIApartCgreyOff();
		var isifsc = document.getElementsByName('partAGEN1.filingStatus.intFinancialServices')[0];
		if (isifsc.value == "N"){
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].disabled = false;
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].value = '';
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].disabled = true;
		}
		else{
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].value = '';
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].disabled = true;
			document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].disabled = false;
		}


		var grossTotInc = document.getElementsByName('partBTI.grossTotalIncome')[0];
		var incChrgable=document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0];
		var statusOrCompanyType=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusOrCompanyType=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
		//	var deductionsUnder10Aor10AA=document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0];

		if(parseInt(grossTotInc.value ,10) <0){

			grossTotInc.value='0';
		}

		if(parseInt(incChrgable.value ,10) <0){

			incChrgable.value='0';
		}


		var gtiLimit=eval(parseInt(coalesce(grossTotInc.value),10)-parseInt(coalesce(incChrgable.value),10)
		/*-parseInt(coalesce(deductionsUnder10Aor10AA.value),10)*/);

		if(gtiLimit<0){
			gtiLimit=0;
		}


		var profGainSpecifiedBus = document.getElementsByName('partBTI.profBusGain.profGainSpecifiedBus')[0];
		var gtiLimitC = zeroOrMore(parseInt(coalesce(gtiLimit),10) - parseInt(coalesce(profGainSpecifiedBus.value),10));




		var sec80G=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80G')[0];
		sec80G.value = coalesce(sec80G.value);

		var sec80GSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80G')[0];
		sec80GSysCal.value = coalesce(sec80GSysCal.value);

		var totalElgblAmt80G=document.getElementsByName('schedule80G.totalEligibleDonationsUs80G')[0];
		totalElgblAmt80G.value = coalesce(totalElgblAmt80G.value);

		var sec80GGA = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGA')[0];
		sec80GGA.value = coalesceSetRet('schedule80GGA.totalDonationsUs80GGA');

		var sec80GGASysCal = document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGA')[0];
		sec80GGASysCal.value = coalesceSetRet('schedule80GGA.totalEligibleDonationsUs80GGA');

		var sec80GGATotalEligbleAmt = document.getElementsByName('schedule80GGA.totalEligibleDonationsUs80GGA')[0];

		sec80GGATotalEligbleAmt.value = coalesceSetRet('schedule80GGA.totalEligibleDonationsUs80GGA');

		var sec80GGC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGC')[0];
		sec80GGC.value = coalesce(sec80GGC.value);

		var sec80GGCSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGC')[0];
		sec80GGCSysCal.value = coalesce(sec80GGCSysCal.value);

		var sch80IA=document.getElementsByName('schedule80IA.totSchedule80IA')[0];
		sch80IA.value = coalesce(sch80IA.value);

		var sec80IA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IA')[0];
		sec80IA.value = coalesce(sec80IA.value);

		var sec80IASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IA')[0];
		sec80IASysCal.value = coalesce(sec80IASysCal.value);


		var sec80IAB=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAB')[0];
		sec80IAB.value = coalesce(sec80IAB.value);

		var sec80IABSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IAB')[0];
		sec80IABSysCal.value = coalesce(sec80IABSysCal.value);

		var sec80IAC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAC')[0];
		sec80IAC.value = coalesce(sec80IAC.value);

		var sec80IACSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IAC')[0];
		sec80IACSysCal.value = coalesce(sec80IACSysCal.value);

		var sch80IB=document.getElementsByName('schedule80IB.totSchedule80IB')[0];
		sch80IB.value = coalesce(sch80IB.value);

		var sec80IB=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IB')[0];
		sch80IB.value = coalesce(sch80IB.value);

		var sec80IBSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IB')[0];
		sec80IBSysCal.value = coalesce(sec80IBSysCal.value);

		var sec80IBA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IBA')[0];
		sec80IBA.value = coalesce(sec80IBA.value);

		var sec80IBASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IBA')[0];
		sec80IBASysCal.value = coalesce(sec80IBASysCal.value);

		var sch80IC=document.getElementsByName('schedule80IC.totSchedule80IC')[0];
		sch80IC.value = coalesce(sch80IC.value);

		var sec80IC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IC')[0];

		sec80IC.value = coalesce(sec80IC.value);

		var sec80ICSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IC')[0];
		sec80ICSysCal.value = coalesce(sec80ICSysCal.value);

		/*var sec80ID=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80ID')[0];
	var sec80IDSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80ID')[0];*/

		var sec80JJA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJA')[0];
		sec80JJA.value = coalesce(sec80JJA.value);

		var sec80JJASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJA')[0];
		sec80JJASysCal.value = coalesce(sec80JJASysCal.value);


		var section80JJAA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJAA')[0];
		section80JJAA.value = coalesce(section80JJAA.value);

		var sec80JJAASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJAA')[0];
		sec80JJAASysCal.value = coalesce(sec80JJAASysCal.value);

		var sec80LA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0];
		sec80LA.value = coalesce(sec80LA.value);

		var sec80LASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80LA')[0];
		sec80LASysCal.value = coalesce(sec80LASysCal.value);

		var sec80LA1A=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0];
		sec80LA1A.value = coalesce(sec80LA1A.value);

		var sec80LA1ASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80LA1A')[0];
		sec80LA1ASysCal.value = coalesce(sec80LA1ASysCal.value);


		var sec80P=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80P')[0];
		var sec80PSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80P')[0];

		var totalDedVIA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.totalChapVIADeductions')[0]; totalDedVIA.value=coalesce(totalDedVIA.value);
		var totalDedVIASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.totalChapVIADeductions')[0]; totalDedVIASysCal.value=coalesce(totalDedVIASysCal.value);

		var total80P = document.getElementsByName('schedule80P.deductUndChap80P.total')[0];
		var totGrossOS = document.getElementsByName('scheduleOS.totalOSGross')[0].value;
		var pgbp=document.getElementsByName('partBTI.profBusGain.totProfBusGain')[0].value;


		//Autopopulate 80G

		sec80G.value=totalElgblAmt80G.value;

		if(eval(parseInt(sec80G.value,10)>parseInt(gtiLimit,10))){

			sec80GSysCal.value=parseInt(gtiLimit,10);
		}else{
			sec80GSysCal.value = parseInt(sec80G.value,10);
		}
//		80GGA
		if(parseInt(pgbp)>0){

			sec80GGASysCal.value=0;
		}
		else if(eval(parseInt(sec80GGATotalEligbleAmt.value,10)>parseInt(gtiLimit,10))){

			sec80GGASysCal.value=parseInt(gtiLimit,10);
		}else{
			sec80GGASysCal.value = parseInt(sec80GGATotalEligbleAmt.value,10);
		}



		//80GGC
		if(!(substatusOrCompanyType == '9') && statusOrCompanyType != '2') {
			if(eval(parseInt(sec80GGC.value,10)>parseInt(gtiLimit,10))){

				sec80GGCSysCal.value=parseInt(gtiLimit,10);
			}else{
				sec80GGCSysCal.value = parseInt(sec80GGC.value,10);
			}
		} else {
			sec80GGCSysCal.value = parseInt(0,10);
		}

//		Part C limited to gtiLimitC
		//80IAB

		sec80IABSysCal.value = parseInt(sec80IAB.value, 10);


		//80IAC


		sec80IACSysCal.value = parseInt(sec80IAC.value, 10);

		//80JJAA

		sec80JJAASysCal.value = parseInt(section80JJAA.value, 10);


		//Autopoulate 80IA

		sec80IA.value = parseInt(sch80IA.value, 10);
		sec80IASysCal.value = parseInt(sch80IA.value, 10);

		//Autopoulate 80IB
		sec80IB.value = parseInt(sch80IB.value, 10);
		sec80IBSysCal.value = parseInt(sch80IB.value, 10);		

		//80IBA

		sec80IBASysCal.value = parseInt(sec80IBA.value, 10);

		//Autopoulate 80IC

		sec80IC.value = parseInt(sch80IC.value, 10);
		sec80ICSysCal.value = parseInt(sch80IC.value, 10);

		//80ID


		/*	if(eval(parseInt(sec80ID.value,10)>parseInt(gtiLimitC,10))){

		sec80IDSysCal.value=parseInt(gtiLimitC,10);
	}else{
		sec80IDSysCal.value = parseInt(coalesce(sec80ID.value,10));
	}*/


		//80JJA

		sec80JJASysCal.value = parseInt(sec80JJA.value, 10);

		//80LA

		sec80LASysCal.value = parseInt(sec80LA.value, 10);

		//80LA1A	


		sec80LA1ASysCal.value = parseInt(sec80LA1A.value, 10);


		sec80P.value=parseInt(coalesce(total80P.value,10));

		sec80PSysCal.value = parseInt(sec80P.value, 10);

		sumUserEntrdDed();

		// Do the sum of deductions again after adding 80GG and 80G
		sumDeductions(sec80GSysCal, sec80GGASysCal,sec80GGCSysCal,
				sec80IASysCal,sec80IABSysCal,sec80IACSysCal,sec80IBSysCal,sec80IBASysCal,sec80ICSysCal,sec80JJASysCal,
				sec80JJAASysCal,sec80LASysCal,sec80LA1ASysCal,sec80PSysCal);


	}catch(e){
		alert(e.stack);
	}

}
function getAmt(name){
	var val = $('[name="'+name+'"]')[0].value;
	return parseInt(coalesce(val));
}

function zeroOrMore(val){
	val = coalesce(val);
	if(val < 0){
		return 0;
	}
	return val;
}

function sumUserEntrdDed() {


	var sec80G=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80G')[0];

	var sec80GGC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGC')[0];

	var sec80IA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IA')[0];
	var sec80IAB=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAB')[0];
	var sec80IAC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAC')[0];
	var sec80IB=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IB')[0];
	var sec80IBA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IBA')[0];
	var sec80IC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IC')[0];
	/*var sec80ID=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80ID')[0];*/
	var sec80JJA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJA')[0];
	var sec80JJAA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJAA')[0];
	var sec80LA=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0];
	var sec80LA1A=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0];

	var sec80P=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80P')[0];
	var sec80GGA = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGA')[0];

	var userEntrdDedPartB=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.totalDeductionPartb')[0];


	var userEntrdDedPartC=document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.totalDeductionPartC')[0];


	userEntrdDedPartB.value= eval(parseInt(coalesce(sec80G.value) ,10))+
	eval(parseInt(coalesce(sec80GGC.value) ,10))+
	eval(parseInt(coalesce(sec80GGA.value), 10));

	var BFLAi5 = document
	.getElementsByName('scheduleBFLA.hp.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAii5 = document
	.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAiv5 = document
	.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAv5 = document
	.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAviii5 = document
	.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAxiii5 = document
	.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAxiv5 = document
	.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];

	var BFLATotalFields = eval(parseInt(BFLAi5.value, 10))
	+ eval(parseInt(BFLAii5.value, 10))
	+ eval(parseInt(BFLAiv5.value, 10))
	+ eval(parseInt(BFLAv5.value, 10))
	+ eval(parseInt(BFLAviii5.value, 10))
	+ eval(parseInt(BFLAxiii5.value, 10))
	+ eval(parseInt(BFLAxiv5.value, 10));



	userEntrdDedPartC.value= eval(parseInt(coalesce(sec80IA.value) ,10))+
	eval(parseInt(coalesce(sec80IAB.value) ,10))+
	eval(parseInt(coalesce(sec80IAC.value) ,10))+
	eval(parseInt(coalesce(sec80IB.value) ,10))+
	eval(parseInt(coalesce(sec80IBA.value) ,10))+
	eval(parseInt(coalesce(sec80IC.value) ,10))+
	eval(parseInt(coalesce(sec80JJA.value) ,10))+
	eval(parseInt(coalesce(sec80JJAA.value) ,10))+
	eval(parseInt(coalesce(sec80LA.value) ,10))+
	eval(parseInt(coalesce(sec80LA1A.value) ,10))+
	eval(parseInt(coalesce(sec80P.value) ,10));


	var userEntrdDed = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.totalChapVIADeductions')[0];
	userEntrdDed.value =eval(parseInt(coalesce(userEntrdDedPartB.value) ,10))+eval(parseInt(coalesce(userEntrdDedPartC.value) ,10));

}

function sumDeductions(sec80GSysCalc,sec80GGASysCal,sec80GGCSysCalc,
		sec80IASysCal,sec80IABSysCal,sec80IACSysCal,sec80IBSysCal,sec80IBASysCal,sec80ICSysCal,sec80JJASysCal,
		sec80JJAASysCal,sec80LASysCalc,sec80LA1ASysCal,sec80PSysCalc,BFLATotalFields){

	sec80GSysCalc.value = coalesce(sec80GSysCalc.value); sec80GGCSysCalc.value = coalesce(sec80GGCSysCalc.value);
	sec80IASysCal.value = coalesce(sec80IASysCal.value); sec80IABSysCal.value = coalesce(sec80IABSysCal.value);
	sec80IACSysCal.value = coalesce(sec80IACSysCal.value); sec80IBASysCal.value = coalesce(sec80IBASysCal.value);
	sec80IBSysCal.value = coalesce(sec80IBSysCal.value); sec80ICSysCal.value = coalesce(sec80ICSysCal.value);
	sec80LASysCalc.value = coalesce(sec80LASysCalc.value);sec80LA1ASysCal.value = coalesce(sec80LA1ASysCal.value);
	sec80PSysCalc.value=   coalesce(sec80PSysCalc.value); 
	sec80GGASysCal.value = coalesce(sec80GGASysCal.value);
	var BFLAii5 = document
	.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAi5 = document
	.getElementsByName('scheduleBFLA.hp.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var BFLAxiii5 = document
	.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
	var dedPartB=document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartb')[0];
	var dedPartC=document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0];

	var totalPartBSysCalTemp= eval(sec80GSysCalc.value) + eval(sec80GGCSysCalc.value)+ eval(sec80GGASysCal.value);


	if (eval(parseInt(totalPartBSysCalTemp, 10) > parseInt(BFLATotalFields,
			10))) {
		dedPartB.value = parseInt(BFLATotalFields, 10);
	} else {
		dedPartB.value = parseInt(totalPartBSysCalTemp, 10);
	}

	var totalPartCSysCalTemp= eval(sec80IASysCal.value)+ eval(sec80IABSysCal.value)+eval(sec80IACSysCal.value)+eval(sec80ICSysCal.value)+ eval(sec80IBSysCal.value)+
	eval(sec80IBASysCal.value)+eval(sec80JJASysCal.value)+eval(sec80JJAASysCal.value)+eval(sec80LASysCalc.value)+eval(sec80LA1ASysCal.value)+ eval(sec80PSysCalc.value);

	var deductUndChap80PTotal = document.getElementsByName('schedule80P.deductUndChap80P.total')[0];
	var bflaFields = eval(parseInt(eval(BFLAii5.value)+ eval(BFLAi5.value)+eval(BFLAxiii5.value),10));
	if(eval(parseInt(deductUndChap80PTotal.value, 10)) > 0)
	{
		if (eval(parseInt(totalPartCSysCalTemp, 10) > parseInt(bflaFields,
				10))) {
			dedPartC.value = parseInt(bflaFields, 10);
		} else {  
			dedPartC.value = parseInt(totalPartCSysCalTemp, 10);
		}
	}
	else
	{
		if (eval(parseInt(totalPartCSysCalTemp, 10) > parseInt(BFLAii5.value,
				10))) {
			dedPartC.value = parseInt(BFLAii5.value, 10);
		} else {
			dedPartC.value = parseInt(totalPartCSysCalTemp, 10);
		}
	}

	var totalDedVIASysCal = document.getElementsByName('scheduleVIA.deductUndChapVIA.totalChapVIADeductions')[0];


	var	totalDedVIASysCalTemp = eval(parseInt(dedPartB.value, 10))
	+ eval(parseInt(dedPartC.value, 10));



	if (eval(parseInt(totalDedVIASysCalTemp, 10) > parseInt(BFLATotalFields,
			10))) {
		totalDedVIASysCal.value = parseInt(BFLATotalFields, 10);
	} else {
		totalDedVIASysCal.value = parseInt(totalDedVIASysCalTemp, 10);
	}


	/*	var grossTotInc = document.getElementsByName('partBTI.grossTotalIncome')[0];
	var incChrgable=document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0];
//	var deductionsUnder10Aor10AA = document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0];
	var gtiLimit=eval(parseInt(coalesce(grossTotInc.value),10)-parseInt(coalesce(incChrgable.value),10)
	-parseInt(coalesce(deductionsUnder10Aor10AA.value),10));

	var profGainSpecifiedBus = document.getElementsByName('partBTI.profBusGain.profGainSpecifiedBus')[0];
	var gtiLimitC = zeroOrMore(parseInt(coalesce(gtiLimit),10) - parseInt(coalesce(profGainSpecifiedBus.value),10));

	if(gtiLimit<0){
		gtiLimit=0;0
	}

	dedPartB.value = Math.min(dedPartB.value, gtiLimit);
	dedPartC.value = Math.min(dedPartC.value, gtiLimitC);

	var temp2 = eval(parseInt(dedPartB.value,10) + parseInt(dedPartC.value,10));

	if(coalesce(grossTotInc.value) > parseInt('0',10)){
		if( temp2 >  parseInt(coalesce(gtiLimit) ,10)){
			totalDedVIASysCal.value = parseInt(coalesce(gtiLimit) ,10);
		} else{
			totalDedVIASysCal.value = temp2;
		}
	}else{
		totalDedVIASysCal.value = temp2;
	}
	 */


}

function calScheduleAmtc(){
	try{

		var taxSection115JC = $('[name="scheduleAMTC.taxSection115JC"]')[0];
		var taxOthProvisions = $('[name="scheduleAMTC.taxOthProvision"]')[0];
		var amtTaxCreditAvailable = $('[name="scheduleAMTC.amtTaxCreditAvailable"]')[0];
		var partBttiTotalTax=$('[name="partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.totalTax"]')[0];
		var partBttiGrossTaxLiability=$('[name="partBTTI.computationOfTaxLiability.grossTaxLiability"]')[0];

		taxSection115JC.value=partBttiTotalTax.value;
		taxOthProvisions.value=partBttiGrossTaxLiability.value;

		if(eval(parseInt(coalesce(taxOthProvisions.value),10)) > eval(parseInt(coalesce(taxSection115JC.value),10))){

			amtTaxCreditAvailable.value=eval(parseInt(coalesce(taxOthProvisions.value),10))-eval(parseInt(coalesce(taxSection115JC.value),10));
		}else{
			amtTaxCreditAvailable.value=parseInt('0',10);
		}

		var tab = document.getElementById('scheduleAmtc');
		var allInputTags = tab.getElementsByTagName('input');

		var totAMTGross = parseInt('0' ,10);
		var totBalBF = parseInt('0' ,10);
		var totAmtCreditUtilisedCY = parseInt('0' ,10);
		var totBalAMTCreditCF = parseInt('0' ,10);

		var amtCreditFwd = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditFwd')[0].value;
		var amtCreditSetOfEy = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].balAmtCreditCarryFwd')[0];

		var amtCreditFwd1 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditFwd')[0].value;
		var amtCreditSetOfEy1 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd1 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized1 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd1 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].balAmtCreditCarryFwd')[0];



		var amtCreditFwd2 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.CYamtCreditFwd')[0].value;
		var amtCreditBalBroughtFwd2 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.CYamtCreditBalBroughtFwd')[0];
		var balAmtCreditCarryFwd2 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.CYbalAmtCreditCarryFwd')[0];

		//14-15
		var amtCreditFwd3 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditFwd')[0].value;
		var amtCreditSetOfEy3 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd3 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized3 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd3 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].balAmtCreditCarryFwd')[0];


		var amtCreditFwd4 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditFwd')[0].value;
		var amtCreditSetOfEy4 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd4 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized4 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd4 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].balAmtCreditCarryFwd')[0];

		var amtCreditFwd5 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditFwd')[0].value;
		var amtCreditSetOfEy5 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd5 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized5 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd5 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].balAmtCreditCarryFwd')[0];

		var amtCreditFwd6 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditFwd')[0].value;
		var amtCreditSetOfEy6 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd6 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized6 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd6 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].balAmtCreditCarryFwd')[0];

		var amtCreditFwd7 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditFwd')[0].value;
		var amtCreditSetOfEy7 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditSetOfEy')[0].value;
		var amtCreditBalBroughtFwd7 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized7 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd7 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].balAmtCreditCarryFwd')[0];


		var amtCreditFwd8 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[7].amtCreditFwd')[0].value;
		var amtCreditBalBroughtFwd8 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[7].amtCreditBalBroughtFwd')[0];
		var amtCreditUtilized8 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[7].amtCreditUtilized')[0].value;
		var balAmtCreditCarryFwd8 = document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[7].balAmtCreditCarryFwd')[0];
		//12-13
		if(parseInt(coalesce(amtCreditSetOfEy),10) > parseInt(coalesce(amtCreditFwd),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd.value = eval(parseInt(coalesce(amtCreditFwd),10)) - eval(parseInt(coalesce(amtCreditSetOfEy),10));
		}

		//13-14
		if(parseInt(coalesce(amtCreditSetOfEy1),10) > parseInt(coalesce(amtCreditFwd1),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[1].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[1].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy1=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd1.value = eval(parseInt(coalesce(amtCreditFwd1),10)) - eval(parseInt(coalesce(amtCreditSetOfEy1),10));
		}
		// 14-15
		if(parseInt(coalesce(amtCreditSetOfEy3),10) > parseInt(coalesce(amtCreditFwd3),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[2].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[2].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy1=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd3.value = eval(parseInt(coalesce(amtCreditFwd3),10)) - eval(parseInt(coalesce(amtCreditSetOfEy3),10));
		}
		/*15-16*/
		if(parseInt(coalesce(amtCreditSetOfEy4),10) > parseInt(coalesce(amtCreditFwd4),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[3].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[3].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy4=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd4.value = eval(parseInt(coalesce(amtCreditFwd4),10)) - eval(parseInt(coalesce(amtCreditSetOfEy4),10));
		}

		/* 16-17*/
		if(parseInt(coalesce(amtCreditSetOfEy5),10) > parseInt(coalesce(amtCreditFwd5),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[4].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[4].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy5=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd5.value = eval(parseInt(coalesce(amtCreditFwd5),10)) - eval(parseInt(coalesce(amtCreditSetOfEy5),10));
		}


		if(parseInt(coalesce(amtCreditSetOfEy6),10) > parseInt(coalesce(amtCreditFwd6),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[5].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[5].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy6=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd6.value = eval(parseInt(coalesce(amtCreditFwd6),10)) - eval(parseInt(coalesce(amtCreditSetOfEy6),10));
		}

		if(parseInt(coalesce(amtCreditSetOfEy7),10) > parseInt(coalesce(amtCreditFwd7),10)){
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil[6].amtCreditSetOfEy','Set-off in earlier years (B2) should not be greater than Gross (B1)');
			addErrorXHTML(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditSetOfEy')[0],'Set-off in earlier years (B2) should not be greater than Gross (B1)',true);
			document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[6].amtCreditSetOfEy')[0].value=parseInt('0' ,10);
			amtCreditSetOfEy7=parseInt('0' ,10);
			document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value=parseInt('0' ,10);
		}else{
			amtCreditBalBroughtFwd7.value = eval(parseInt(coalesce(amtCreditFwd7),10)) - eval(parseInt(coalesce(amtCreditSetOfEy7),10));
		}

		amtCreditBalBroughtFwd2.value = parseInt(coalesce(amtCreditFwd2),10);


		amtCreditBalBroughtFwd8.value = parseInt(coalesce(amtCreditFwd8),10);

		totAMTGross = parseInt(coalesce(amtCreditFwd),10) + parseInt(coalesce(amtCreditFwd1),10) + parseInt(coalesce(amtCreditFwd2),10)+parseInt(coalesce(amtCreditFwd3),10)+parseInt(coalesce(amtCreditFwd4),10)+parseInt(coalesce(amtCreditFwd5),10)+parseInt(coalesce(amtCreditFwd6),10)+parseInt(coalesce(amtCreditFwd7),10)+parseInt(coalesce(amtCreditFwd8),10);
		totBalBF = parseInt(coalesce(amtCreditBalBroughtFwd.value),10) + parseInt(coalesce(amtCreditBalBroughtFwd1.value),10) + parseInt(coalesce(amtCreditBalBroughtFwd2.value),10)+ parseInt(coalesce(amtCreditBalBroughtFwd3.value),10)+parseInt(coalesce(amtCreditBalBroughtFwd4.value),10)+parseInt(coalesce(amtCreditBalBroughtFwd5.value),10)+parseInt(coalesce(amtCreditBalBroughtFwd6.value),10)+parseInt(coalesce(amtCreditBalBroughtFwd7),10)+parseInt(coalesce(amtCreditBalBroughtFwd8.value),10);

		balAmtCreditCarryFwd.value= parseInt(coalesce(amtCreditBalBroughtFwd.value),10) - parseInt(coalesce(amtCreditUtilized),10);
		balAmtCreditCarryFwd1.value= parseInt(coalesce(amtCreditBalBroughtFwd1.value),10) - parseInt(coalesce(amtCreditUtilized1),10);
		balAmtCreditCarryFwd3.value= parseInt(coalesce(amtCreditBalBroughtFwd3.value),10) - parseInt(coalesce(amtCreditUtilized3),10);
		balAmtCreditCarryFwd4.value= parseInt(coalesce(amtCreditBalBroughtFwd4.value),10) - parseInt(coalesce(amtCreditUtilized4),10);
		balAmtCreditCarryFwd5.value= parseInt(coalesce(amtCreditBalBroughtFwd5.value),10) - parseInt(coalesce(amtCreditUtilized5),10);
		balAmtCreditCarryFwd6.value= parseInt(coalesce(amtCreditBalBroughtFwd6.value),10) - parseInt(coalesce(amtCreditUtilized6),10);

		balAmtCreditCarryFwd2.value= parseInt(coalesce( amtCreditBalBroughtFwd2.value),10);

		balAmtCreditCarryFwd7.value= parseInt(coalesce(amtCreditBalBroughtFwd7.value),10) - parseInt(coalesce(amtCreditUtilized7),10);
		balAmtCreditCarryFwd8.value= parseInt(coalesce(amtCreditBalBroughtFwd8.value),10) - parseInt(coalesce(amtCreditUtilized8),10);

		totAmtCreditUtilisedCY = parseInt(coalesce(amtCreditUtilized),10) + parseInt(coalesce(amtCreditUtilized1),10)+ parseInt(coalesce(amtCreditUtilized3),10)+parseInt(coalesce(amtCreditUtilized4),10)+parseInt(coalesce(amtCreditUtilized5),10)+parseInt(coalesce(amtCreditUtilized6),10)+ parseInt(coalesce(amtCreditUtilized7),10)+parseInt(coalesce(amtCreditUtilized8),10);
		totBalAMTCreditCF = parseInt(coalesce(balAmtCreditCarryFwd.value),10) + parseInt(coalesce(balAmtCreditCarryFwd1.value),10) + parseInt(coalesce(balAmtCreditCarryFwd2.value),10)+ parseInt(coalesce(balAmtCreditCarryFwd3.value),10)+parseInt(coalesce(balAmtCreditCarryFwd4.value),10)+parseInt(coalesce(balAmtCreditCarryFwd5.value),10)+parseInt(coalesce(balAmtCreditCarryFwd6.value),10)+parseInt(coalesce(balAmtCreditCarryFwd7.value),10)+parseInt(coalesce(balAmtCreditCarryFwd8.value),10);

		document.getElementsByName('scheduleAMTC.totSetOffEys')[0].value= parseInt(coalesce(amtCreditSetOfEy1),10) + parseInt(coalesce(amtCreditSetOfEy),10)+parseInt(coalesce(amtCreditSetOfEy3),10)+parseInt(coalesce(amtCreditSetOfEy4),10)+parseInt(coalesce(amtCreditSetOfEy5),10)+parseInt(coalesce(amtCreditSetOfEy6),10)+parseInt(coalesce(amtCreditSetOfEy7),10);
		document.getElementsByName('scheduleAMTC.totAMTGross')[0].value=totAMTGross;
		document.getElementsByName('scheduleAMTC.totBalBF')[0].value=totBalBF;
		document.getElementsByName('scheduleAMTC.totAmtCreditUtilisedCY')[0].value=totAmtCreditUtilisedCY;
		document.getElementsByName('scheduleAMTC.totBalAMTCreditCF')[0].value=totBalAMTCreditCF;


		document.getElementsByName('scheduleAMTC.taxSection115JD')[0].value=totAmtCreditUtilisedCY;
		document.getElementsByName('scheduleAMTC.amtLiabilityAvailable')[0].value=totBalAMTCreditCF;

	}catch(e){
		alert(e.stack);
	}


}

function populateAMT(){

	var totIncomeTi=$('[name="partBTI.totalIncome"]')[0];
	var amtTotIncome=$('[name="itrScheduleAMT.totalIncItem11"]')[0];
	var deductClaimSec6A=$('[name="itrScheduleAMT.adjustmentSec115JC.deductClaimSec6A"]')[0];
	var deductClaimSec10AA=$('[name="itrScheduleAMT.adjustmentSec115JC.deductClaimSec10AA"]')[0];
	var deductClaimSec35AD=$('[name="itrScheduleAMT.adjustmentSec115JC.deductClaimSec35AD"]')[0];

	var sec115JCTotal=$('[name="itrScheduleAMT.adjustmentSec115JC.total"]')[0];
	var adjustedUnderSec115JC=$('[name="itrScheduleAMT.adjustedUnderSec115JC"]')[0];

	var taxPayableUnderSec115JC=$('[name="itrScheduleAMT.taxPayableUnderSec115JC"]')[0];

	var dedUnder10AA=$('[name="schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub"]')[0];

	var userType=$('[name="partAGEN1.orgFirmInfo.statusOrCompanyType"]')[0];
	var subuserType=$('[name="partAGEN1.orgFirmInfo.subStatus"]')[0];

	var grossTotInc = document.getElementsByName('partBTI.grossTotalIncome')[0];
	var incChargeSplRate=document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0];
	var sec80IASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IA')[0];
	var sec80IABSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IAB')[0];
	var sec80IACSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IAC')[0];
	var sec80IBSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IB')[0];
	var sec80ICSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IC')[0];
	/*	var sec80IDSysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80ID')[0];*/
	var sec80JJASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJA')[0];
	var sec80JJAASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJAA')[0];
	var sec80LASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80LA')[0];
	var sec80IBASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IBA')[0];
	var sec80GGASysCal=document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGA')[0];
	/*	Total of Schedule AMT Change*/

	var partBTotal5 = document.getElementsByName('partBTI.totalTI')[0].value;
	var partBCurntYerLoss6 = document.getElementsByName('partBTI.currentYearLoss')[0].value;
	var partBbrtFwdLossSetOff8 = document.getElementsByName('partBTI.broughtFwdLossesSetoff')[0].value;
	var partBTotInc13 = document.getElementsByName('partBTI.totalIncome')[0].value;

	var schBPAProfBefTaxA1 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.profBfrTaxPL')[0].value;
	var schBPnetProfLossSpecifiedBus2B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netProfLossSpecifiedBus')[0].value;
	var schBPdeductionUs35ADC46 = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD')[0].value;
	var schBPpLFrmSpecifiedBus47 = document.getElementsByName('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal')[0].value;

	/*	End*/



	var dedVIA=eval(parseInt(coalesce(sec80IASysCal.value),10))+eval(parseInt(coalesce(sec80IABSysCal.value),10))+eval(parseInt(coalesce(sec80IACSysCal.value),10))+eval(parseInt(coalesce(sec80IBSysCal.value),10))+
	eval(parseInt(coalesce(sec80ICSysCal.value),10))+eval(parseInt(coalesce(sec80JJASysCal.value),10))+eval(parseInt(coalesce(sec80IBASysCal.value),10))+
	eval(parseInt(coalesce(sec80JJAASysCal.value),10))+eval(parseInt(coalesce(sec80LASysCal.value),10))+eval(parseInt(coalesce(sec80GGASysCal.value),10));

	//	var deductionsUnder10Aor10AA=document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0];
	var profGainSpecifiedBus=document.getElementsByName('partBTI.profBusGain.profGainSpecifiedBus')[0];
	var gtiLimit=eval(parseInt(coalesce(grossTotInc.value),10)-parseInt(coalesce(incChargeSplRate.value),10)
			/*- parseInt(coalesce(deductionsUnder10Aor10AA.value),10)*/- parseInt(coalesce(profGainSpecifiedBus.value),10));

	if(gtiLimit < 0){gtiLimit=0;}
	if(eval(parseInt(coalesce(dedVIA),10)) > eval(parseInt(coalesce(gtiLimit),10))){
		dedVIA=gtiLimit;
	}
	if(partBTotal5 == 0 && partBCurntYerLoss6 == 0 && partBbrtFwdLossSetOff8 == 0 && partBTotInc13 == 0 && (schBPAProfBefTaxA1 == schBPnetProfLossSpecifiedBus2B) && schBPdeductionUs35ADC46 > 0 && schBPpLFrmSpecifiedBus47 < 0 ){
		amtTotIncome.value=schBPpLFrmSpecifiedBus47;
	}else{
		amtTotIncome.value=totIncomeTi.value;
	}

	deductClaimSec6A.value=dedVIA;
	var ded10A10AAAlwd = parseInt(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses'));
	var ded10A10AAAlwdPBti = parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'));

	deductClaimSec10AA.value=ded10A10AAAlwdPBti;

	//2c=2a+2b
	sec115JCTotal.value=eval(parseInt(coalesce(deductClaimSec6A.value),10))+eval(parseInt(coalesce(deductClaimSec10AA.value),10))+eval(parseInt(coalesce(deductClaimSec35AD.value),10));
	//3=1+2c
	adjustedUnderSec115JC.value=returnZeroIfNegative(eval(parseInt(coalesce(amtTotIncome.value),10))+eval(parseInt(coalesce(sec115JCTotal.value),10)));
	//4

	var intFinancialServices = document.getElementsByName('partAGEN1.filingStatus.intFinancialServices')[0].value;


	if(subuserType.value=="7" || subuserType.value=="8" || userType.value=="9"|| subuserType.value=="17" || subuserType.value=="15" || subuserType.value=="16" || subuserType.value=="4" || subuserType.value=="12"|| subuserType.value=="18" || subuserType.value=="19" || subuserType.value=="20"|| subuserType.value=="21"|| subuserType.value=="13"|| subuserType.value=="11"){


		if((eval(parseInt(coalesce(adjustedUnderSec115JC.value),10)) > eval('2000000'))
				&& (eval(parseInt(coalesce(sec115JCTotal.value),10)) >eval('0'))){
			if(intFinancialServices == "Y")
			{
				taxPayableUnderSec115JC.value=Math.round((9 * eval(parseInt(
						coalesce(adjustedUnderSec115JC.value), 10))) / 100);
			}
			else {
				taxPayableUnderSec115JC.value=Math.round((18.5 * eval(parseInt(
						coalesce(adjustedUnderSec115JC.value), 10))) / 100);
			}


		}else{
			taxPayableUnderSec115JC.value=parseInt('0',10);
		}

	}

	if(userType.value=="1" || userType.value=="2" || subuserType.value=="5" ){

		if(eval(parseInt(coalesce(sec115JCTotal.value),10)) >eval('0')){
			if(intFinancialServices == "Y")
			{
				taxPayableUnderSec115JC.value=Math.round((9 * eval(parseInt(
						coalesce(adjustedUnderSec115JC.value), 10))) / 100);
			}
			else {
				taxPayableUnderSec115JC.value=Math.round((18.5 * eval(parseInt(
						coalesce(adjustedUnderSec115JC.value), 10))) / 100);
			}


		}else{

			taxPayableUnderSec115JC.value=parseInt('0',10);
		}
	}


	//17 Schedule B-TI
	document.getElementsByName('partBTI.deemedTotIncSec115JC')[0].value=eval(parseInt(coalesce(adjustedUnderSec115JC.value),10));

}


function calcSchDEPFor6(){

	var deprBlockTot15Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot15Percent')[0]; deprBlockTot15Percent.value = coalesce(deprBlockTot15Percent.value);
	var deprBlockTot30Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot30Percent')[0]; deprBlockTot30Percent.value = coalesce(deprBlockTot30Percent.value);
	var deprBlockTot40Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot40Percent')[0]; deprBlockTot40Percent.value = coalesce(deprBlockTot40Percent.value);
	var deprBlockTot45Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot45Percent')[0]; deprBlockTot45Percent.value = coalesce(deprBlockTot45Percent.value);

	/*var deprBlockTot50Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot50Percent')[0]; deprBlockTot50Percent.value = coalesce(deprBlockTot50Percent.value);
	var deprBlockTot60Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot60Percent')[0]; deprBlockTot60Percent.value = coalesce(deprBlockTot60Percent.value);
	var deprBlockTot80Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot80Percent')[0]; deprBlockTot80Percent.value = coalesce(deprBlockTot80Percent.value);
	var deprBlockTot100Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.deprBlockTot100Percent')[0]; deprBlockTot100Percent.value = coalesce(deprBlockTot100Percent.value);*/
	var totPlntMach = document.getElementsByName('scheduleDEP.summaryFromDeprSch.plantMachinerySummary.totPlntMach')[0]; totPlntMach.value = coalesce(totPlntMach.value);
	var deprBlockTot5Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.buildingSummary.deprBlockTot5Percent')[0]; deprBlockTot5Percent.value = coalesce(deprBlockTot5Percent.value);
	var deprBlockTot10Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.buildingSummary.deprBlockTot10Percent')[0]; deprBlockTot10Percent.value = coalesce(deprBlockTot10Percent.value);
	var buildingDeprBlockTot40Percent = document.getElementsByName('scheduleDEP.summaryFromDeprSch.buildingSummary.deprBlockTot40Percent')[0]; buildingDeprBlockTot40Percent.value = coalesce(buildingDeprBlockTot40Percent.value);
	var totBuildng = document.getElementsByName('scheduleDEP.summaryFromDeprSch.buildingSummary.totBuildng')[0]; totBuildng.value = coalesce(totBuildng.value);
	var furnitureSummary = document.getElementsByName('scheduleDEP.summaryFromDeprSch.furnitureSummary')[0]; furnitureSummary.value = coalesce(furnitureSummary.value);
	var intangibleAssetSummary = document.getElementsByName('scheduleDEP.summaryFromDeprSch.intangibleAssetSummary')[0]; intangibleAssetSummary.value = coalesce(intangibleAssetSummary.value);
	var shipsSummary = document.getElementsByName('scheduleDEP.summaryFromDeprSch.shipsSummary')[0]; shipsSummary.value = coalesce(shipsSummary.value);
	var profBfrTaxPL = document.getElementsByName('scheduleDEP.summaryFromDeprSch.totalDepreciation')[0]; profBfrTaxPL.value = coalesce(profBfrTaxPL.value);

	if(coalesce( parseInt(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0){

		deprBlockTot15Percent.value =coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.proportionateAggDepreciation')[0].value)
	}else{
		deprBlockTot15Percent.value =coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.netAggregateDepreciation')[0].value)
	}
	//deprBlockTot15Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation')[0].value) ;

	if(coalesce( parseInt(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0){
		deprBlockTot30Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		deprBlockTot30Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}

	//deprBlockTot30Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation')[0].value) ;
	if(coalesce( parseInt(document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0)
	{
		deprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		deprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}



	if(coalesce( parseInt(document.getElementsByName('scheduleDPM.plantMachinery.rate45.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0)
	{
		deprBlockTot45Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate45.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		deprBlockTot45Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate45.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}


	/*	deprBlockTot15Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot30Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot50Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate50.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot60Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate60.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot80Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate80.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot100Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate100.depreciationDetail.totalDepreciation')[0].value) ;*/
	totPlntMach.value = eval(parseInt(deprBlockTot15Percent.value,10)) + eval(parseInt(deprBlockTot30Percent.value,10)) + eval(parseInt(deprBlockTot40Percent.value,10)) + eval(parseInt(deprBlockTot45Percent.value,10))/* + eval(parseInt(deprBlockTot60Percent.value,10)) + eval(parseInt(deprBlockTot80Percent.value,10)) + eval(parseInt(deprBlockTot100Percent.value,10))*/;
	if(coalesce( parseInt(document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0)
	{
		deprBlockTot5Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		deprBlockTot5Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}

	if(coalesce( parseInt(document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0)
	{
		deprBlockTot10Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		deprBlockTot10Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}

	if(coalesce( parseInt(document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.proportionateAggDepreciation')[0].value,10) ) >0)
	{
		buildingDeprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.proportionateAggDepreciation')[0].value) ;
	}
	else
	{
		buildingDeprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.netAggregateDepreciation')[0].value) ;
	}

	/*
	deprBlockTot5Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.totalDepreciation')[0].value) ;
	deprBlockTot10Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.totalDepreciation')[0].value) ;
	buildingDeprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.totalDepreciation')[0].value) ;*/
	totBuildng.value = eval(parseInt(deprBlockTot5Percent.value,10)) + eval(parseInt(deprBlockTot10Percent.value,10)) + eval(parseInt(buildingDeprBlockTot40Percent.value,10));


	if(parseInt(document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.proportionateAggDepreciation')[0].value,10)>0){
		furnitureSummary.value = coalesce(document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.proportionateAggDepreciation')[0].value);
	}
	else{
		furnitureSummary.value = coalesce(document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.netAggregateDepreciation')[0].value);
	}
	if(parseInt(document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.proportionateAggDepreciation')[0].value,10)>0){
		intangibleAssetSummary.value = coalesce(document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.proportionateAggDepreciation')[0].value);
	}
	else{
		intangibleAssetSummary.value = coalesce(document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.netAggregateDepreciation')[0].value);
	}
	if(parseInt(document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.proportionateAggDepreciation')[0].value,10)>0){
		shipsSummary.value = coalesce(document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.proportionateAggDepreciation')[0].value);
	}
	else{
		shipsSummary.value = coalesce(document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.netAggregateDepreciation')[0].value);
	}

	profBfrTaxPL.value = eval(parseInt(totPlntMach.value,10)) + eval(parseInt(totBuildng.value,10)) + eval(parseInt(furnitureSummary.value,10)) + eval(parseInt(intangibleAssetSummary.value,10)) + eval(parseInt(shipsSummary.value,10));

}
function validatepoint1513(){
	if(getAmt('scheduleDOA.building.rate5.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.building.rate5.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.building.rate5.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.building.rate10.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.building.rate10.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.building.rate10.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.building.rate40.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.building.rate40.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.building.rate40.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.furnitureFittings.rate10.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.furnitureFittings.rate10.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.furnitureFittings.rate10.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.intangibleAssets.rate25.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.intangibleAssets.rate25.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.intangibleAssets.rate25.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.ships.rate20.depreciationDetail.proportionateAggDepreciation')>getAmt('scheduleDOA.ships.rate20.depreciationDetail.netAggregateDepreciation')){
		j.setFieldError('scheduleDOA.ships.rate20.depreciationDetail.proportionateAggDepreciation','Amount cannot be more than the amount entered in Net aggregate depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.proportionateAggDepreciation')[0],
				'Amount cannot be more than the amount entered in Net aggregate depreciation',
				true);
	}
	if(getAmt('scheduleDOA.building.rate5.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.building.rate5.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.building.rate5.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
	if(getAmt('scheduleDOA.building.rate10.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.building.rate10.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.building.rate10.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
	if(getAmt('scheduleDOA.building.rate40.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.building.rate40.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.building.rate40.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
	if(getAmt('scheduleDOA.furnitureFittings.rate10.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.furnitureFittings.rate10.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.furnitureFittings.rate10.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
	if(getAmt('scheduleDOA.intangibleAssets.rate25.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.intangibleAssets.rate25.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.intangibleAssets.rate25.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}
	if(getAmt('scheduleDOA.ships.rate20.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDOA.ships.rate20.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDOA.ships.rate20.depreciationDetail.depDisAllowUs38_2','Amount cannot be more than the amount entered in Total depreciation');
		addErrorXHTML( document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.depDisAllowUs38_2')[0],
				'Amount cannot be more than the amount entered in Total depreciation',
				true);
	}

}
function calcSchDCGFor6(){

	var deprBlockTot15Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot15Percent')[0]; deprBlockTot15Percent.value = coalesce(deprBlockTot15Percent.value);
	var deprBlockTot30Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot30Percent')[0]; deprBlockTot30Percent.value = coalesce(deprBlockTot30Percent.value);
	var deprBlockTot40Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot40Percent')[0]; deprBlockTot40Percent.value = coalesce(deprBlockTot40Percent.value);
	var deprBlockTot45Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot45Percent')[0]; deprBlockTot45Percent.value = coalesce(deprBlockTot45Percent.value);

	/*var deprBlockTot50Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot50Percent')[0]; deprBlockTot50Percent.value = coalesce(deprBlockTot50Percent.value);
	var deprBlockTot60Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot60Percent')[0]; deprBlockTot60Percent.value = coalesce(deprBlockTot60Percent.value);
	var deprBlockTot80Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot80Percent')[0]; deprBlockTot80Percent.value = coalesce(deprBlockTot80Percent.value);
	var deprBlockTot100Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.deprBlockTot100Percent')[0]; deprBlockTot100Percent.value = coalesce(deprBlockTot100Percent.value);*/
	var totPlntMach = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.plantMachinerySummaryCG.totPlntMach')[0]; totPlntMach.value = coalesce(totPlntMach.value);
	var deprBlockTot5Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.buildingSummaryCG.deprBlockTot5Percent')[0]; deprBlockTot5Percent.value = coalesce(deprBlockTot5Percent.value);
	var deprBlockTot10Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.buildingSummaryCG.deprBlockTot10Percent')[0]; deprBlockTot10Percent.value = coalesce(deprBlockTot10Percent.value);
	var buildingDeprBlockTot40Percent = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.buildingSummaryCG.deprBlockTot40Percent')[0]; buildingDeprBlockTot40Percent.value = coalesce(buildingDeprBlockTot40Percent.value);
	var totBuildng = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.buildingSummaryCG.totBuildng')[0]; totBuildng.value = coalesce(totBuildng.value);
	var furnitureSummary = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.furnitureSummary')[0]; furnitureSummary.value = coalesce(furnitureSummary.value);
	var intangibleAssetSummary = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.intangibleAssetSummary')[0]; intangibleAssetSummary.value = coalesce(intangibleAssetSummary.value);
	var shipsSummary = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.shipsSummary')[0]; shipsSummary.value = coalesce(shipsSummary.value);
	var profBfrTaxPL = document.getElementsByName('scheduleDCG.summaryFromDeprSchCG.totalDepreciation')[0]; profBfrTaxPL.value = coalesce(profBfrTaxPL.value);


	deprBlockTot15Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate15.depreciationDetail.capGainUs50')[0].value) ;
	deprBlockTot30Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate30.depreciationDetail.capGainUs50')[0].value) ;
	deprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate40.depreciationDetail.capGainUs50')[0].value) ;
	deprBlockTot45Percent.value = coalesce(document.getElementsByName('scheduleDPM.plantMachinery.rate45.depreciationDetail.capGainUs50')[0].value) ;

	totPlntMach.value = eval(parseInt(deprBlockTot15Percent.value,10)) + eval(parseInt(deprBlockTot30Percent.value,10)) + eval(parseInt(deprBlockTot40Percent.value,10)) + eval(parseInt(deprBlockTot45Percent.value,10));


	deprBlockTot5Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate5.depreciationDetail.capGainUs50')[0].value) ;
	deprBlockTot10Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate10.depreciationDetail.capGainUs50')[0].value) ;
	buildingDeprBlockTot40Percent.value = coalesce(document.getElementsByName('scheduleDOA.building.rate40.depreciationDetail.capGainUs50')[0].value) ;
	totBuildng.value = eval(parseInt(deprBlockTot5Percent.value,10)) + eval(parseInt(deprBlockTot10Percent.value,10)) + eval(parseInt(buildingDeprBlockTot40Percent.value,10));

	furnitureSummary.value = coalesce(document.getElementsByName('scheduleDOA.furnitureFittings.rate10.depreciationDetail.capGainUs50')[0].value) ;
	intangibleAssetSummary.value = coalesce(document.getElementsByName('scheduleDOA.intangibleAssets.rate25.depreciationDetail.capGainUs50')[0].value) ;
	shipsSummary.value = coalesce(document.getElementsByName('scheduleDOA.ships.rate20.depreciationDetail.capGainUs50')[0].value);

	profBfrTaxPL.value = eval(parseInt(totPlntMach.value,10)) + eval(parseInt(totBuildng.value,10)) + eval(parseInt(furnitureSummary.value,10)) + eval(parseInt(intangibleAssetSummary.value,10)) + eval(parseInt(shipsSummary.value,10));
}

function calculateCYLA(cgosIncome){
	try{
		//prefill the CYLA-schedule
		prefillCYLA();

		//doing successive setoffs
		//Income of current year (Fill this column only if income is zero or positive)


		setOffOthSrcLossCYLA(cgosIncome);


		// Current year's Income remaining after set off
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead') -
			coalescePath('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.houseProperty.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');

		}

		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');


		}

		// Profit & gain us 115B
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}

		// Speculative Income
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}

		// Specified Business Income
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}


		//Short-term capital gain taxable @ 15%
		document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}
		//Short-term capital gain taxable @ 30%
		document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}

		//Short-term capital gain taxable at applicable rates
		document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}
		// 	Long term capital gain taxable @ 10%
		document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');

		}
		// 	Long term capital gain taxable @ 20%
		document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');

		}

		// 	Other sources
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff')[0].value=
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff');
		if(coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}
		// Profit from owning and maintaining race horses
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrAfterSetOff')[0].value=
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}
		//Short-term capital gain taxable at DTAA rates
		document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');
		}

//		Long term capital gain taxable @ DTAA
		document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');

		}

//		Other sources income taxable at DTAA rates
		document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrAfterSetOff')[0].value =
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')-
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrAfterSetOff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrAfterSetOff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff',
			'This figure cannot be negative. Please rearrange your figures');

		}

		//total loss setoff
		document.getElementsByName('scheduleCYLA.totalLossSetOff.totHPlossCurYrSetoff')[0].value=
			coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')+
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff');



		// Business
		document.getElementsByName('scheduleCYLA.totalLossSetOff.totBusLossSetoff')[0].value=
			coalescePath('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')+
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff');


		document.getElementsByName('scheduleCYLA.totalLossSetOff.totOthSrcLossNoRaceHorseSetoff')[0].value=
			coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')+
			coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff');


		//Loss remaining after set-off
		document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff')[0].value=
			coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-coalescePath('scheduleCYLA.totalLossSetOff.totHPlossCurYrSetoff');
		if(coalescePath('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff',
			'This figure cannot be negative. Please rearrange your figures');
		}
		document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff')[0].value=
			coalescePath('scheduleCYLA.totalCurYr.totBusLoss')-coalescePath('scheduleCYLA.totalLossSetOff.totBusLossSetoff');


		if(coalescePath('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff',
			'This figure cannot be negative. Please rearrange your figures');

		}

		document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balOthSrcLossNoRaceHorseAftSetoff')[0].value=
			coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-coalescePath('scheduleCYLA.totalLossSetOff.totOthSrcLossNoRaceHorseSetoff');
		if(coalescePath('scheduleCYLA.lossRemAftSetOff.balOthSrcLossNoRaceHorseAftSetoff')<0){
			addErrorXHTML(document.getElementsByName('scheduleCYLA.lossRemAftSetOff.balOthSrcLossNoRaceHorseAftSetoff')[0],
					'This figure cannot be negative. Please rearrange your figures',true);
			j.setFieldError('scheduleCYLA.lossRemAftSetOff.balOthSrcLossNoRaceHorseAftSetoff',
			'This figure cannot be negative. Please rearrange your figures');

		}

		/*cgosIncome.cgInc.stcg.prctgAr = coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff');
		cgosIncome.cgInc.stcg.prctg30 = coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff');*/
		/*cgosIncome.cgInc.ltcg.prctg20.sec112 = coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff');*/
		cgosIncome.bpNetInc = coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff');

		calcBFLA(cgosIncome);

	}catch(e){
		alert('error in calcCYLA=' + e.stack);
	}
}

function prefillCYLA(){
	try{

		//Field 3c of Schedule HP) , only if 3c is positive
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('scheduleHP.totalIncomeChargeableUnHP'));


		//prefilling column :: Income of current year (Fill this column only if income is zero or positive)- Business (excluding speculation income and income from specified business)
		// A37 of Sch BP,only if A37 is positive
		coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead');
		coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead');
		coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead');

		// Business income
		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.netPLBusOthThanSpec7A7B7C'));

		// Profit & gain 115B
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrAfterSetOff'));

		// Speculative Income
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrAfterSetOff'));

		// Specified Business Income
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrAfterSetOff'));

		//prefilling column :: Short-term capital gain taxable @ 15%
		//Field (7ii of item E of schedule CG)
		document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inStcg15Per.CurrYrLosSetOff');

		//prefilling column :: Short-term capital gain taxable @ 30%
		//Field (7iii of item E of schedule CG)
		document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inStcg30Per.currYrLosSetOff');

		//prefilling column :: Short-term capital gain taxable at applicable rates
		//Field (7iv of item E of schedule CG)
		document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inStcgAppRate.currYrLosSetOff');

		//prefilling column :: Long term capital gain taxable @ 10%
		//Field (7v of item E of schedule CG)
		document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inLtcg10Per.currYrLosSetOff');

		//prefilling column :: Long term capital gain taxable @ 20%
		//Field (7vi of item E of schedule CG)
		document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inLtcg20Per.CurrYrLosSetOff');
		document
		.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inStcgDTAARate.currYrLosSetOff');

		document
		.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleCGPost45.currYrLosses.inLtcgDTAARates.CurrYrLosSetOff');

		//prefilling column :: Other sources income
		//Field (1i of schedule OS)
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('scheduleOS.balanceNoRaceHorse'));

		/*document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead')[0].value =
			coalescePath('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa.totAmtUnderDtaa');*/

		//prefilling column :: Profit from owning and maintaining race horses
		//Field (3c of schedule OS)
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse'));

		//prefilling column :: Other sources income taxable at DTAA rates
		//Field (2f of schedule OS)
		document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa.totAmtUnderDtaa'));

		// populating losses in the respective heads
		coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr');
		if(!isPostv('scheduleHP.totalIncomeChargeableUnHP')){
			document.getElementsByName('scheduleCYLA.totalCurYr.totHPlossCurYr')[0].value =
				Math.abs(coalescePath('scheduleHP.totalIncomeChargeableUnHP'));
		}else{
			document.getElementsByName('scheduleCYLA.totalCurYr.totHPlossCurYr')[0].value = 0;
		}

		coalescePath('scheduleCYLA.totalCurYr.totBusLoss');
		document.getElementsByName('scheduleCYLA.totalCurYr.totBusLoss')[0].value =
			coalescePath('itr5ScheduleBP.busSetoffCurYr.lossRemainSetOffOnBus');

		coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse');
		if(!isPostv('scheduleOS.balanceNoRaceHorse')){
			document.getElementsByName('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')[0].value =
				Math.abs(coalescePath('scheduleOS.balanceNoRaceHorse')) ;

		}else{
			document.getElementsByName('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')[0].value = 0;
		}


	}catch(e){
		alert('error in prefillCYLA()=' + e.stack);
	}
}

function setOffOthSrcLossCYLA(cgosIncome){
	try{
		var stcgPercent15Sec111a = zeroOrMore(cgosIncome.cgInc.stcg.prctg15.sec111a);
		var stcgPercent15Sec115ad_1_b_ii = zeroOrMore(cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii);
		var stcgPercent15SecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctg15.secPti);
		var stcgPercent30Sec115AD = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.sec115AD);
		var stcgPercent30SecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.secPti);
		var stcgPercentArSecStcgApp = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.stcgApp);
		var stcgPercentArSecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.secPti);
		var ltcgPrctg20Sec112 = zeroOrMore(cgosIncome.cgInc.ltcg.prctg20.sec112);
		var ltcgPrctg20SecPti = zeroOrMore(cgosIncome.cgInc.ltcg.prctg20.secPti);
		var ltcgPrctg10SecProviso = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.secProviso);
		var ltcgPrctg10Sec112A = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec112A);
		var ltcgPrctg10Sec115ADiiiP = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP);
		var ltcgPrctg10Sec112c2 = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2);
		var ltcgPrctg10Sec115AC1 = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec115AC_1);
		var ltcgPrctg10Sec115AD3 = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec115AD_3);
		var ltcgPrctg10Sec115AB1B = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B);
		var ltcgPrctg10Sec112A = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec112A);
		var ltcgPrctg10Sec115ADiiiP = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP);
		var ltcgPrctg10SecPti = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.secPti);
		var ltcgPrctgPTI_LTCG10P112A = zeroOrMore(cgosIncome.cgInc.ltcg.prctg10.secPti112A);


		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;

		if (!checkIfChanged('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')) {
			document
			.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		}	 else {
			checkFirstLessThanMinOthTwo(
					'scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead',
					'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
					- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));

		}
		if( !checkIfChanged('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff') ){
			document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

		}

		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;


		if(!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		if( !checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0 ;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		if( !checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0 ;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		if( !checkIfChanged('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
			document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0 ;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		if( !checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
			document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0 ;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
					coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}
		if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
			document
			.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		} else {
			checkFirstLessThanMinOthTwo(
					'scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
					'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
					- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
			document
			.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = 0;
		} else {
			checkFirstLessThanMinOthTwo(
					'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
					'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
					'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
					- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));
		}

		var setOffRem = coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
		coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead');

		// 1. Race Horse
		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
				coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead');

		}else{
			document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
				coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse');
			setOffRem =0 ;
		}

		//os Dtaa

		var prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead');

		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead');
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		}else{

			if( !checkIfChanged('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			}else{
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem =0 ;
		}

		//2.House property
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			if( !checkIfChanged('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
					coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead');
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		}else{

			if( !checkIfChanged('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));


			}
			setOffRem =0 ;
		}

		//3. Business Income
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			if( !checkIfChanged('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
					coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead');
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		}else{

			if( !checkIfChanged('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));


			}
			setOffRem =0 ;
		}

		//4. Speculative Income
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
				coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead');
		} else{

			document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		//5. specified Income
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
				coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead');
		} else{

			document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}


		//3. Profit & gain Us 115B
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
				coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrUnderThatHead');
		} else{

			document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		// 8.Short-term capital gain taxable @ 30%
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead');
		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead');
				stcgPercent30Sec115AD = 0;
				stcgPercent30SecPti = 0;
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		} else {

			if (!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;

				// sec break up
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent30Sec115AD, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent30Sec115AD = parseInt(
							stcgPercent30Sec115AD, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent30Sec115AD, 10);
					stcgPercent30Sec115AD = 0;
				}

				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent30SecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent30SecPti = parseInt(
							stcgPercent30SecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent30SecPti, 10);
					stcgPercent30SecPti = 0;
				}

			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem = 0;
		}

		// 8.Short-term capital gain taxable @ AR%
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead');
		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead');
				stcgPercentArSecStcgApp = 0;
				stcgPercentArSecPti = 0;
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		} else {

			if (!checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;

				// sec break up
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercentArSecStcgApp, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercentArSecStcgApp = parseInt(
							stcgPercentArSecStcgApp, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercentArSecStcgApp, 10);
					stcgPercentArSecStcgApp = 0;
				}

				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercentArSecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercentArSecPti = parseInt(
							stcgPercentArSecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercentArSecPti, 10);
					stcgPercentArSecPti = 0;
				}

			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem = 0;
		}

		// 9)Long term capital gain taxable @ 20%
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead');
		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead');
				ltcgPrctg20Sec112 = 0;
				ltcgPrctg20SecPti = 0;
			} else {
				checkFirstLessThanMinOthTwo('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		} else {

			if (!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;

				// sec break up

				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(ltcgPrctg20SecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					ltcgPrctg20SecPti = parseInt(
							ltcgPrctg20SecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(ltcgPrctg20SecPti, 10);
					ltcgPrctg20SecPti = 0;
				}
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(ltcgPrctg20Sec112, 10) > parseInt(
								prevSetOffRem, 10)) {
					ltcgPrctg20Sec112 = parseInt(
							ltcgPrctg20Sec112, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(ltcgPrctg20Sec112, 10);
					ltcgPrctg20Sec112 = 0;
				}



			} else {
				checkFirstLessThanMinOthTwo('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'));

			}
			setOffRem = 0;
		}

		//9.Short-term capital gain taxable @ 15%
		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead');
		if(parseInt(setOffRem,10)>=0){
			if( !checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value =
					coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead');
				stcgPercent15Sec111a = 0;
				stcgPercent15Sec115ad_1_b_ii = 0;
				stcgPercent15SecPti = 0;

			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		}else{

			if( !checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')){
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;

				// sec break up
				if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec115ad_1_b_ii, 10) > parseInt(prevSetOffRem, 10)){
					stcgPercent15Sec115ad_1_b_ii = parseInt(stcgPercent15Sec115ad_1_b_ii, 10) -
					parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				}else{
					prevSetOffRem = parseInt(prevSetOffRem, 10) -
					parseInt(stcgPercent15Sec115ad_1_b_ii, 10) ;
					stcgPercent15Sec115ad_1_b_ii = 0;
				}
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent15SecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent15SecPti = parseInt(
							stcgPercent15SecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent15SecPti, 10);
					stcgPercent15SecPti = 0;
				}


				if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec111a, 10) > parseInt(prevSetOffRem, 10)){
					stcgPercent15Sec111a = parseInt(stcgPercent15Sec111a, 10) -
					parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				}else{
					prevSetOffRem = parseInt(prevSetOffRem, 10) -
					parseInt(stcgPercent15Sec111a, 10) ;
					stcgPercent15Sec111a = 0;
				}


			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem =0 ;
		}

		// 11)Long term capital gain taxable @ 10%
		prevSetOffRem = setOffRem;
		var ltcgSetOffRem = coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead');
		if(ltcgSetOffRem>=0 && setOffRem>=0){
			if(ltcgSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(ltcgSetOffRem,10);

				if(setOffRem>=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = parseInt(ltcgSetOffRem,10);
					ltcgPrctg10Sec112c2 = 0;
					ltcgPrctg10Sec115AC1 = 0;
					ltcgPrctg10Sec112A = 0;
					ltcgPrctg10Sec115ADiiiP = 0;
					ltcgPrctg10Sec115AD3 = 0;
					ltcgPrctg10Sec115AB1B = 0;
					ltcgPrctg10SecPti = 0;
					ltcgPrctgPTI_LTCG10P112A = 0;
					ltcgPrctg10SecProviso = 0;

					ltcgSetOffRem = zeroOrMore(ltcgSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
				}else{

					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = tempAk;
					setOffRem=0;
					//Section break up

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec112c2, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec112c2, 10) ;
						ltcgPrctg10Sec112c2 = 0;
					}
					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AB1B, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AB1B, 10) ;
						ltcgPrctg10Sec115AB1B = 0;
					}


					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AC1, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AC1, 10) ;
						ltcgPrctg10Sec115AC1 = 0;
					}



					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AD3, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AD3, 10) ;
						ltcgPrctg10Sec115AD3 = 0;
					}
					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115ADiiiP, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115ADiiiP = parseInt(ltcgPrctg10Sec115ADiiiP, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115ADiiiP, 10) ;
						ltcgPrctg10Sec115ADiiiP = 0;
					}


					if (parseInt(tempAk, 10) >= 0
							&& parseInt(ltcgPrctg10SecPti, 10) > parseInt(
									tempAk, 10)) {
						ltcgPrctg10SecPti = parseInt(ltcgPrctg10SecPti,
								10)
								- parseInt(tempAk, 10);
						tempAk = 0;
					} else {
						tempAk = parseInt(tempAk, 10)
						- parseInt(ltcgPrctg10SecPti, 10);
						ltcgPrctg10SecPti = 0;
					}


					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10SecProviso, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso, 10) - parseInt(tempAk, 10);
						tempAk = 0;
					} else{
						tempAk = parseInt(tempAk, 10) - parseInt(ltcgPrctg10SecProviso, 10) ;
						ltcgPrctg10SecProviso = 0;
					}

					if (parseInt(tempAk, 10) >= 0
							&& parseInt(ltcgPrctgPTI_LTCG10P112A, 10) > parseInt(
									tempAk, 10)) {
						ltcgPrctgPTI_LTCG10P112A = parseInt(ltcgPrctgPTI_LTCG10P112A,
								10)
								- parseInt(tempAk, 10);
						tempAk = 0;
					} else {
						tempAk = parseInt(tempAk, 10)
						- parseInt(ltcgPrctgPTI_LTCG10P112A, 10);
						ltcgPrctgPTI_LTCG10P112A = 0;
					}


					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec112A, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec112A = parseInt(ltcgPrctg10Sec112A, 10) - parseInt(tempAk, 10);
						tempAk = 0;
					} else{
						tempAk = parseInt(tempAk, 10) - parseInt(ltcgPrctg10Sec112A, 10) ;
						ltcgPrctg10Sec112A = 0;
					}
				}
			}else{
				var prevLtcgSetOffRem= ltcgSetOffRem;

				if(ltcgSetOffRem >=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = parseInt(ltcgSetOffRem,10);
					ltcgPrctg10Sec112c2 = 0;
					ltcgPrctg10Sec115AC1 = 0;
					ltcgPrctg10Sec112A = 0;
					ltcgPrctg10Sec115ADiiiP = 0;
					ltcgPrctg10Sec115AD3 = 0;
					ltcgPrctg10Sec115AB1B = 0;
					ltcgPrctg10SecPti = 0;
					ltcgPrctgPTI_LTCG10P112A= 0;
					ltcgPrctg10SecProviso = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
				}
			}}


		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead');
		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead');
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		} else {

			if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem = 0;
		}

		prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem, 10)
		- coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead');
		if (parseInt(setOffRem, 10) >= 0) {
			if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead');
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));

				setOffRem = parseInt(prevSetOffRem, 10)
				- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff');
			}
		} else {

			if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value = prevSetOffRem;
			} else {
				checkFirstLessThanMinOthTwo(
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
						coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')
						- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem = 0;
		}


		cgosIncome.cgInc.stcg.prctg15.sec111a = stcgPercent15Sec111a;
		cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii = stcgPercent15Sec115ad_1_b_ii;
		cgosIncome.cgInc.stcg.prctg15.secPti = stcgPercent15SecPti;
		cgosIncome.cgInc.stcg.prctg30.sec115AD = stcgPercent30Sec115AD;
		cgosIncome.cgInc.stcg.prctg30.secPti = stcgPercent30SecPti;
		cgosIncome.cgInc.stcg.prctgAr.stcgApp = stcgPercentArSecStcgApp;
		cgosIncome.cgInc.stcg.prctgAr.secPti = stcgPercentArSecPti;
		cgosIncome.cgInc.ltcg.prctg20.sec112 = ltcgPrctg20Sec112;
		cgosIncome.cgInc.ltcg.prctg20.secPti = ltcgPrctg20SecPti;
		cgosIncome.cgInc.ltcg.prctg10.secProviso = ltcgPrctg10SecProviso;
		cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2 = ltcgPrctg10Sec112c2;
		cgosIncome.cgInc.ltcg.prctg10.sec115AC_1 = ltcgPrctg10Sec115AC1;
		cgosIncome.cgInc.ltcg.prctg10.sec115AD_3 = ltcgPrctg10Sec115AD3;
		cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B = ltcgPrctg10Sec115AB1B;
		cgosIncome.cgInc.ltcg.prctg10.secPti = ltcgPrctg10SecPti;
		cgosIncome.cgInc.ltcg.prctg10.secPti112A = ltcgPrctgPTI_LTCG10P112A;
		cgosIncome.cgInc.ltcg.prctg10.sec112A=ltcgPrctg10Sec112A;
		cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP=ltcgPrctg10Sec115ADiiiP;

		setOffHPLossCYLA(cgosIncome);
	}catch(e){
		alert('error in setOffOthSrcLossCYLA()=' + e.stack);
	}
}


function setOffHPLossCYLA(cgosIncome){
	try{
		var stcgPercent15Sec111a = cgosIncome.cgInc.stcg.prctg15.sec111a;
		var stcgPercent15Sec115ad_1_b_ii = cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii;
		var stcgPercent15SecPti = cgosIncome.cgInc.stcg.prctg15.secPti;
		var stcgPercent30Sec115AD = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.sec115AD);
		var stcgPercent30SecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.secPti);
		var stcgPercentArSecStcgApp = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.stcgApp);
		var stcgPercentArSecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.secPti);
		var ltcgPrctg20SecPti = cgosIncome.cgInc.ltcg.prctg20.secPti;
		var ltcgPrctg20Sec112 = cgosIncome.cgInc.ltcg.prctg20.sec112;
		var ltcgPrctg10SecProviso = cgosIncome.cgInc.ltcg.prctg10.secProviso;
		var ltcgPrctg10Sec112c2 = cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2;
		var ltcgPrctg10Sec115AC1 = cgosIncome.cgInc.ltcg.prctg10.sec115AC_1;
		var ltcgPrctg10Sec115AD3 = cgosIncome.cgInc.ltcg.prctg10.sec115AD_3;
		var ltcgPrctg10Sec115AB1B = cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B;
		var ltcgPrctg10SecPti = cgosIncome.cgInc.ltcg.prctg10.secPti;

		var ltcgPrctg10Sec115ADiiiP = cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP;
		var ltcgPrctgPTI_LTCG10P112A = cgosIncome.cgInc.ltcg.prctg10.secPti112A;
		var ltcgPrctg10Sec112A = cgosIncome.cgInc.ltcg.prctg10.sec112A;


		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;


		if( !checkIfChanged('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkFirstLessThanMinOthTwo('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr'));
		}

		if(!checkIfChanged('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff'));
		}

		if(!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

		}

		if(!checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff'));
		}

		if(!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));
		}

		if(!checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
		}

		if(!checkIfChanged('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')){
			document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		}else{
			checkHPeditableValidity('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'
					,'scheduleCYLA.totalCurYr.totHPlossCurYr',
					coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
					coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')-
					coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff'));
		}

		if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
			document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		} else {
			checkFirstLessThanMinOthTwo(
					'scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
					'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
					- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.houseProperty.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
		}

		if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
			document
			.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
		} else {
			checkFirstLessThanMinOthTwo(
					'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff',
					'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
					'scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse',
					coalescePath('scheduleCYLA.totalCurYr.totOthSrcLossNoRaceHorse')
					- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.houseProperty.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')
					- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff'));
		}



		/*
		Order of adjustment :-
			1) Business Income
			2) Speculative Income
			3) Specified Income
			4) Other sources
			5) Profit from owning and maintaining race horses
			6) Short-term capital gain taxable @ 30%
			7) Short-term capital gain taxable at applicable rates
			8) Long term capital gain taxable @ 20%
			9) Short-term capital gain taxable @ 15%
			10) Long term capital gain taxable @ 10% (1. cgosIncome.cgInc.ltcg.prctg10.secProviso,
													2. cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2,
													3. cgosIncome.cgInc.ltcg.prctg10.sec115AC_1,
													4. cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1,
													5. cgosIncome.cgInc.ltcg.prctg10.sec115AD_3,
													6. cgosIncome.cgInc.ltcg.prctg10.sec115E_b)
		 */


		// 1.  Business Income
		var busIncSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff'));
		var prevSetOffRemStart = coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr');
		var hpLossRem = 200000;
		var prevSetOffRem =  Math.min(parseInt(prevSetOffRemStart,10),parseInt(hpLossRem,10));
		var setOffRem = prevSetOffRem - busIncSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if( !checkIfChanged('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')){
					document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].value =	busIncSetOffRem;
				}else{
					checkFirstLessThanMinOthTwo('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr'));
			}
			setOffRem =0 ;
		}



		// 3.  Speculative Income
		var specltvIncSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff'));
		prevSetOffRem = setOffRem;
		setOffRem = prevSetOffRem - specltvIncSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].value =	specltvIncSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		// 4.  Specified Income
		var specfidIncSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff'));
		prevSetOffRem = setOffRem;
		setOffRem = prevSetOffRem - specfidIncSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].value =	specfidIncSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		// 2.  Profit & gain Us 115B
		var profitGain115BSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff'));
		prevSetOffRem = setOffRem;
		setOffRem = prevSetOffRem - profitGain115BSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].value =	profitGain115BSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}
		//5. Other sources (excluding profit from owning race horses)

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead');

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if( (!checkIfChanged('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff'))){
					document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value =
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead');
				}else{
					checkFirstLessThanMinOthTwo('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			}else{
				checkFirstLessThanMinOthTwo('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr'));
			}
			setOffRem =0 ;
		}

		//6. Profit from owning and maintaining race horse
		var raceHrsSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - raceHrsSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if(!checkIfChanged('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')){
					document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = raceHrsSetOffRem;
				}else{
					checkHPeditableValidity('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'
							,'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
							coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			}else{
				checkHPeditableValidity('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'
						,'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem =0 ;
		}
		// 4) OS income taxable at DTAA rates
		var oSDtaaSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead')
				- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - oSDtaaSetOffRem;

		if (setOffRem >= 0) {
			if (prevSetOffRem == 0) {
				document
				.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			} else {
				if (!checkIfChanged('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')) {
					document
					.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')[0].value = oSDtaaSetOffRem;
				} else {
					checkHPeditableValidity(
							'scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead',
							'scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff',
							'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
							- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem, 10)
					- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff');
				}
			}
		} else {
			if (!checkIfChanged('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')) {
				document
				.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			} else {
				checkHPeditableValidity(
						'scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
						- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem = 0;
		}


		/*	// 7. Short-term capital gain taxable @ 30%

		var stcg30PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcg30PercntSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if(!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')){
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = stcg30PercntSetOffRem;
				}else{
					checkHPeditableValidity('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'
						,'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			}else{
				checkHPeditableValidity('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'
						,'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem =0 ;
		}
		 */

		// 8) Short-term capital gain taxable @ 30%
		var stcg30PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead')
				- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcg30PercntSetOffRem;

		if (setOffRem >= 0) {
			if (prevSetOffRem == 0) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			} else {
				if (!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')) {
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = stcg30PercntSetOffRem;
					stcg30PercntSetOffRem = 0;
					stcgPercent30Sec115AD = 0;
					stcgPercent30SecPti = 0;

				} else {
					checkHPeditableValidity(
							'scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead',
							'scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff',
							'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
							- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

					setOffRem = parseInt(prevSetOffRem, 10)
					- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff');
				}
			}
		} else {
			if (!checkIfChanged('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;

				// sec break up
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent30Sec115AD, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent30Sec115AD = parseInt(
							stcgPercent30Sec115AD, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent30Sec115AD, 10);
					stcgPercent30Sec115AD = 0;
				}
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent30SecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent30SecPti = parseInt(
							stcgPercent30SecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent30SecPti, 10);
					stcgPercent30SecPti = 0;
				}

			} else {
				checkHPeditableValidity(
						'scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
						- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));
			}
			setOffRem = 0;
		}

		// 8. Short-term capital gain taxable at applicable rates

		var stcgAppRateSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcgAppRateSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if(!checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')){
					document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')[0].value = stcgAppRateSetOffRem;
				}else{
					checkHPeditableValidity('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'
							,'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
							coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			}else{
				checkHPeditableValidity('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff'
						,'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem =0 ;
		}

		// 9. Long term capital gain taxable @ 20%
		prevSetOffRem = setOffRem;
		var ltcg20PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

		if(ltcg20PercntSetOffRem>=0 && setOffRem>=0){
			if(ltcg20PercntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(ltcg20PercntSetOffRem,10);

				if(setOffRem>=0){

					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value = parseInt(ltcg20PercntSetOffRem,10);
						ltcgPrctg20Sec112 = 0;

						ltcgPrctg20SecPti = 0;

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg20Sec112,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg20Sec112,10);
							ltcgPrctg20Sec112 = 0;
							/*if(parseInt(ltcgPrctg20Sec11EA,10) >= remaLTCGcomplete){
								ltcgPrctg20Sec11EA = parseInt(ltcgPrctg20Sec11EA,10) - remaLTCGcomplete;
							}else{
								ltcgPrctg20Sec11EA=0;
							}*/
							if (parseInt(ltcgPrctg20SecPti, 10) >= remaLTCGcomplete) {
								ltcgPrctg20SecPti = parseInt(
										ltcgPrctg20SecPti, 10)
										- remaLTCGcomplete;
							} else {

								ltcgPrctg20SecPti = 0;
							}

						}
					}

					ltcg20PercntSetOffRem = zeroOrMore(ltcg20PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
				}else{

					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value = tempAk;
						setOffRem=0;
						// sec break up

						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg20Sec112, 10) > parseInt(tempAk, 10)){
							ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112, 10) -
							parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) -
							parseInt(ltcgPrctg20Sec112, 10) ;
							ltcgPrctg20Sec112 = 0;
						}
						if (parseInt(tempAk, 10) >= 0
								&& parseInt(ltcgPrctg20SecPti, 10) > parseInt(
										tempAk, 10)) {
							ltcgPrctg20SecPti = parseInt(ltcgPrctg20SecPti,
									10)
									- parseInt(tempAk, 10);
							tempAk = 0;
						} else {
							tempAk = parseInt(tempAk, 10)
							- parseInt(ltcgPrctg20SecPti, 10);
							ltcgPrctg20SecPti = 0;
						}


					}
					else{
						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg20Sec112,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg20Sec112,10);
							ltcgPrctg20Sec112 = 0;

							if (parseInt(ltcgPrctg20SecPti, 10) >= remaLTCGcomplete) {
								ltcgPrctg20SecPti = parseInt(
										ltcgPrctg20SecPti, 10)
										- remaLTCGcomplete;
							} else {

								ltcgPrctg20SecPti = 0;
							}

						}
					}
					ltcg20PercntSetOffRem = zeroOrMore(ltcg20PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
				}

			}else{
				var prevLtcgSetOffRem= ltcg20PercntSetOffRem;

				if(ltcg20PercntSetOffRem >=0){
					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value = parseInt(ltcg20PercntSetOffRem,10);
						ltcg20PercntSetOffRem = 0;
						ltcgPrctg20Sec112 = 0;
						ltcgPrctg20SecPti = 0;

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg20Sec112,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg20Sec112,10);
							ltcgPrctg20Sec112 = 0;

							if (parseInt(ltcgPrctg20SecPti, 10) >= remaLTCGcomplete) {
								ltcgPrctg20SecPti = parseInt(
										ltcgPrctg20SecPti, 10)
										- remaLTCGcomplete;
							} else {

								ltcgPrctg20SecPti = 0;
							}

						}
					}
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
				}else{
					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value = prevLtcgSetOffRem;
						ltcg20PercntSetOffRem =0 ;
						ltcgPrctg20Sec112=0;
						ltcgPrctg20SecPti = 0;

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg20Sec112,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg20Sec112,10);
							ltcgPrctg20Sec112 = 0;

							if (parseInt(ltcgPrctg20SecPti, 10) >= remaLTCGcomplete) {
								ltcgPrctg20SecPti = parseInt(
										ltcgPrctg20SecPti, 10)
										- remaLTCGcomplete;
							} else {

								ltcgPrctg20SecPti = 0;
							}

						}
					}
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
				}
			}
		}


		// 10. Short-term capital gain taxable @ 15%
		var stcg15PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcg15PercntSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			}else{
				if(!checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')){
					document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')[0].value = stcg15PercntSetOffRem;
					stcg15PercntSetOffRem = 0;
					stcgPercent15Sec111a = 0;
					stcgPercent15Sec115ad_1_b_ii = 0;
					stcgPercent15SecPti = 0;

				}else{
					checkHPeditableValidity('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff'
							,'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
							coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
							coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
							coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem,10) - coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff');
				}
			}
		}else{
			if( !checkIfChanged('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')){
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;

				// sec break up
				if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec115ad_1_b_ii, 10) > parseInt(prevSetOffRem, 10)){
					stcgPercent15Sec115ad_1_b_ii = parseInt(stcgPercent15Sec115ad_1_b_ii, 10) -
					parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				}else{
					prevSetOffRem = parseInt(prevSetOffRem, 10) -
					parseInt(stcgPercent15Sec115ad_1_b_ii, 10) ;
					stcgPercent15Sec115ad_1_b_ii = 0;
				}
				if (parseInt(prevSetOffRem, 10) >= 0
						&& parseInt(stcgPercent15SecPti, 10) > parseInt(
								prevSetOffRem, 10)) {
					stcgPercent15SecPti = parseInt(
							stcgPercent15SecPti, 10)
							- parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				} else {
					prevSetOffRem = parseInt(prevSetOffRem, 10)
					- parseInt(stcgPercent15SecPti, 10);
					stcgPercent15SecPti = 0;
				}


				if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec111a, 10) > parseInt(prevSetOffRem, 10)){
					stcgPercent15Sec111a = parseInt(stcgPercent15Sec111a, 10) -
					parseInt(prevSetOffRem, 10);
					prevSetOffRem = 0;
				}else{
					prevSetOffRem = parseInt(prevSetOffRem, 10) -
					parseInt(stcgPercent15Sec111a, 10) ;
					stcgPercent15Sec111a = 0;
				}

			}else{
				checkHPeditableValidity('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff'
						,'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
						coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
						coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
						coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem =0 ;
		}

		// 11) Long term capital gain taxable @ 10%
		prevSetOffRem = setOffRem;
		var ltcg10PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'));

		if(ltcg10PercntSetOffRem>=0 && setOffRem>=0){
			if(ltcg10PercntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(ltcg10PercntSetOffRem,10);//mod

				if(setOffRem>=0){
					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value = parseInt(ltcg10PercntSetOffRem,10);
						ltcgPrctg10Sec112c2 = 0;
						ltcgPrctg10Sec115AC1 = 0;
						ltcgPrctg10Sec115AD3 = 0;
						ltcgPrctg10Sec115AB1B = 0;
						ltcgPrctg10SecPti = 0;
						ltcgPrctgPTI_LTCG10P112A = 0;
						ltcgPrctg10SecProviso = 0;
						ltcgPrctg10Sec115ADiiiP = 0;
						ltcgPrctg10Sec112A = 0;

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg10SecProviso,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10SecProviso,10);
							ltcgPrctg10SecProviso = 0;
							if(parseInt(ltcgPrctg10Sec112c2,10) >= remaLTCGcomplete){
								ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2,10) - remaLTCGcomplete;
							}else{
								remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec112c2,10);
								ltcgPrctg10Sec112c2=0;

								if(parseInt(ltcgPrctg10Sec115AB1B,10) >= remaLTCGcomplete){
									ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B,10) - remaLTCGcomplete;
								}else{
									remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
									ltcgPrctg10Sec115AB1B=0;

									if(parseInt(ltcgPrctg10Sec115AC1,10) >= remaLTCGcomplete){
										ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1,10) - remaLTCGcomplete;
									}else{
										remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
										ltcgPrctg10Sec115AC1=0;

										if(parseInt(ltcgPrctg10Sec115AD3,10) >= remaLTCGcomplete){
											ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3,10) - remaLTCGcomplete;
										}else{
											remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AD3,10);
											ltcgPrctg10Sec115AD3=0;
											if (parseInt(ltcgPrctg10Sec115ADiiiP, 10) >= remaLTCGcomplete) {
												ltcgPrctg10Sec115ADiiiP = parseInt(
														ltcgPrctg10Sec115ADiiiP, 10)
														- remaLTCGcomplete;
											} else {
												remaLTCGcomplete = document
												.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value
												- parseInt(
														ltcgPrctg10Sec115ADiiiP,
														10);
												ltcgPrctg10Sec115ADiiiP = 0;

												if (parseInt(ltcgPrctg10SecPti,
														10) >= remaLTCGcomplete) {
													ltcgPrctg10SecPti = parseInt(
															ltcgPrctg10SecPti, 10)
															- remaLTCGcomplete;
												}else {
													remaLTCGcomplete = document
													.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
													- parseInt(
															ltcgPrctg10SecPti,
															10);
													ltcgPrctg10SecPti = 0;

													if(parseInt(ltcgPrctg10SecProviso,10) >= remaLTCGcomplete){
														ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - remaLTCGcomplete;
													}else{
														remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
														ltcgPrctg10SecProviso=0;



														if (parseInt(ltcgPrctgPTI_LTCG10P112A,
																10) >= remaLTCGcomplete) {
															ltcgPrctgPTI_LTCG10P112A = parseInt(
																	ltcgPrctgPTI_LTCG10P112A, 10)
																	- remaLTCGcomplete;
														}else {
															remaLTCGcomplete = document
															.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
															- parseInt(
																	ltcgPrctgPTI_LTCG10P112A,
																	10);
															ltcgPrctgPTI_LTCG10P112A = 0;

															if (parseInt(ltcgPrctg10Sec112A, 10) >= remaLTCGcomplete) {
																ltcgPrctg10Sec112A = parseInt(
																		ltcgPrctg10Sec112A, 10)
																		- remaLTCGcomplete;
															} 	else {
																remaLTCGcomplete = document
																.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
																- parseInt(
																		ltcgPrctg10Sec112A,
																		10);
																ltcgPrctg10Sec112A = 0;
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
					ltcg10PercntSetOffRem = zeroOrMore(ltcg10PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
				}else{
					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value = tempAk;
						setOffRem=0;

						//Section break up

						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec112c2, 10) > parseInt(tempAk, 10)){
							ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2, 10) -
							parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) -
							parseInt(ltcgPrctg10Sec112c2, 10) ;
							ltcgPrctg10Sec112c2 = 0;
						}
						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AC1, 10) > parseInt(tempAk, 10)){
							ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1, 10) -
							parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) -
							parseInt(ltcgPrctg10Sec115AC1, 10) ;
							ltcgPrctg10Sec115AC1 = 0;
						}
						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AB1B, 10) > parseInt(tempAk, 10)){
							ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B, 10) -
							parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) -
							parseInt(ltcgPrctg10Sec115AB1B, 10) ;
							ltcgPrctg10Sec115AB1B = 0;
						}



						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AD3, 10) > parseInt(tempAk, 10)){
							ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3, 10) -
							parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) -
							parseInt(ltcgPrctg10Sec115AD3, 10) ;
							ltcgPrctg10Sec115AD3 = 0;
						}

						if (parseInt(tempAk, 10) >= 0
								&& parseInt(ltcgPrctg10Sec115ADiiiP, 10) > parseInt(
										tempAk, 10)) {
							ltcgPrctg10Sec115ADiiiP = parseInt(ltcgPrctg10Sec115ADiiiP,
									10)
									- parseInt(tempAk, 10);
							tempAk = 0;
						} else {
							tempAk = parseInt(tempAk, 10)
							- parseInt(ltcgPrctg10Sec115ADiiiP, 10);
							ltcgPrctg10Sec115ADiiiP = 0;
						}



						if (parseInt(tempAk, 10) >= 0
								&& parseInt(ltcgPrctg10SecPti, 10) > parseInt(
										tempAk, 10)) {
							ltcgPrctg10SecPti = parseInt(ltcgPrctg10SecPti,
									10)
									- parseInt(tempAk, 10);
							tempAk = 0;
						} else {
							tempAk = parseInt(tempAk, 10)
							- parseInt(ltcgPrctg10SecPti, 10);
							ltcgPrctg10SecPti = 0;
						}

						if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10SecProviso, 10) > parseInt(tempAk, 10)){
							ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso, 10) - parseInt(tempAk, 10);
							tempAk = 0;
						}else{
							tempAk = parseInt(tempAk, 10) - parseInt(ltcgPrctg10SecProviso, 10) ;
							ltcgPrctg10SecProviso = 0;
						}
						if (parseInt(tempAk, 10) >= 0
								&& parseInt(ltcgPrctgPTI_LTCG10P112A, 10) > parseInt(
										tempAk, 10)) {
							ltcgPrctgPTI_LTCG10P112A = parseInt(ltcgPrctgPTI_LTCG10P112A,
									10)
									- parseInt(tempAk, 10);
							tempAk = 0;
						} else {
							tempAk = parseInt(tempAk, 10)
							- parseInt(ltcgPrctgPTI_LTCG10P112A, 10);
							ltcgPrctgPTI_LTCG10P112A = 0;
						}


						if (parseInt(tempAk, 10) >= 0
								&& parseInt(ltcgPrctg10Sec112A, 10) > parseInt(
										tempAk, 10)) {
							ltcgPrctg10Sec112A = parseInt(ltcgPrctg10Sec112A,
									10)
									- parseInt(tempAk, 10);
							tempAk = 0;
						} else {
							tempAk = parseInt(tempAk, 10)
							- parseInt(ltcgPrctg10Sec112A, 10);
							ltcgPrctg10Sec112A = 0;
						}

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg10SecProviso,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10SecProviso,10);
							ltcgPrctg10SecProviso = 0;
							if(parseInt(ltcgPrctg10Sec112c2,10) >= remaLTCGcomplete){
								ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2,10) - remaLTCGcomplete;
							}else{
								remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec112c2,10);
								ltcgPrctg10Sec112c2=0;
								if(parseInt(ltcgPrctg10Sec115AB1B,10) >= remaLTCGcomplete){
									ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B,10) - remaLTCGcomplete;
								}else{
									remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
									ltcgPrctg10Sec115AB1B=0;

									if(parseInt(ltcgPrctg10Sec115AC1,10) >= remaLTCGcomplete){
										ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1,10) - remaLTCGcomplete;
									}else{
										remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
										ltcgPrctg10Sec115AC1=0;

										if(parseInt(ltcgPrctg10Sec115AD3,10) >= remaLTCGcomplete){
											ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3,10) - remaLTCGcomplete;
										}else{
											remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AD3,10);
											ltcgPrctg10Sec115AD3=0;
											if (parseInt(ltcgPrctg10Sec115ADiiiP, 10) >= remaLTCGcomplete) {
												ltcgPrctg10Sec115ADiiiP = parseInt(
														ltcgPrctg10Sec115ADiiiP, 10)
														- remaLTCGcomplete;
											} else {
												remaLTCGcomplete = document
												.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value
												- parseInt(
														ltcgPrctg10Sec115ADiiiP,
														10);
												ltcgPrctg10Sec115ADiiiP = 0;


												if (parseInt(ltcgPrctg10SecPti,
														10) >= remaLTCGcomplete) {
													ltcgPrctg10SecPti = parseInt(
															ltcgPrctg10SecPti, 10)
															- remaLTCGcomplete;
												}else {
													remaLTCGcomplete = document
													.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
													- parseInt(
															ltcgPrctg10SecPti,
															10);
													ltcgPrctg10SecPti = 0;

													if(parseInt(ltcgPrctg10SecProviso,10) >= remaLTCGcomplete){
														ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - remaLTCGcomplete;
													}else{
														remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AD3,10);
														ltcgPrctg10SecProviso=0;


														if (parseInt(ltcgPrctgPTI_LTCG10P112A,
																10) >= remaLTCGcomplete) {
															ltcgPrctgPTI_LTCG10P112A = parseInt(
																	ltcgPrctgPTI_LTCG10P112A, 10)
																	- remaLTCGcomplete;
														}else {
															remaLTCGcomplete = document
															.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
															- parseInt(
																	ltcgPrctgPTI_LTCG10P112A,
																	10);
															ltcgPrctgPTI_LTCG10P112A = 0;



															if (parseInt(ltcgPrctg10Sec112A, 10) >= remaLTCGcomplete) {
																ltcgPrctg10Sec112A = parseInt(
																		ltcgPrctg10Sec112A, 10)
																		- remaLTCGcomplete;
															} else {
																remaLTCGcomplete = document
																.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
																- parseInt(
																		ltcgPrctg10Sec112A,
																		10);
																ltcgPrctg10Sec112A = 0;
															}
														}
													}
												}

											}
										}
									}
								}
							}
						}
					}
					ltcg10PercntSetOffRem = zeroOrMore(ltcg10PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
				}
			}else{

				if(ltcg10PercntSetOffRem >=0){
					if(!checkIfChanged('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')){
						document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value = parseInt(ltcg10PercntSetOffRem,10);
						ltcg10PercntSetOffRem=0;
						ltcgPrctg10Sec112c2 = 0;
						ltcgPrctg10Sec115AB1B = 0;
						ltcgPrctg10Sec115AC1 = 0;
						ltcgPrctg10Sec115AD3 = 0;
						ltcgPrctg10SecPti = 0;
						ltcgPrctgPTI_LTCG10P112A = 0;
						ltcgPrctg10SecProviso = 0;
						ltcgPrctg10Sec115ADiiiP = 0;
						ltcgPrctg10Sec112A = 0;

					}else{

						checkHPeditableValidity('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff',
								'scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead','scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff'
								,'scheduleCYLA.totalCurYr.totHPlossCurYr',
								coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')-
								coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')-
								coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff'));

						if(parseInt(ltcgPrctg10SecProviso,10) >= document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value){
							ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value;
						}else{
							var remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10SecProviso,10);
							ltcgPrctg10SecProviso = 0;
							if(parseInt(ltcgPrctg10Sec112c2,10) >= remaLTCGcomplete){
								ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2,10) - remaLTCGcomplete;
							}else{
								remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec112c2,10);
								ltcgPrctg10Sec112c2=0;
								if(parseInt(ltcgPrctg10Sec115AB1B,10) >= remaLTCGcomplete){
									ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B,10) - remaLTCGcomplete;
								}else{
									remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
									ltcgPrctg10Sec115AB1B=0;
									if(parseInt(ltcgPrctg10Sec115AC1,10) >= remaLTCGcomplete){
										ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1,10) - remaLTCGcomplete;
									}else{
										remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AC1,10);
										ltcgPrctg10Sec115AC1=0;

										if(parseInt(ltcgPrctg10Sec115AD3,10) >= remaLTCGcomplete){
											ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3,10) - remaLTCGcomplete;
										}else{
											remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AD3,10);
											ltcgPrctg10Sec115AD3=0;
											if (parseInt(ltcgPrctg10Sec115ADiiiP, 10) >= remaLTCGcomplete) {
												ltcgPrctg10Sec115ADiiiP = parseInt(
														ltcgPrctg10Sec115ADiiiP, 10)
														- remaLTCGcomplete;
											} else {
												remaLTCGcomplete = document
												.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value
												- parseInt(
														ltcgPrctg10Sec115ADiiiP,
														10);
												ltcgPrctg10Sec115ADiiiP = 0;


												if (parseInt(ltcgPrctg10SecPti,
														10) >= remaLTCGcomplete) {
													ltcgPrctg10SecPti = parseInt(
															ltcgPrctg10SecPti, 10)
															- remaLTCGcomplete;
												}else {
													remaLTCGcomplete = document
													.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
													- parseInt(
															ltcgPrctg10SecPti,
															10);
													ltcgPrctg10SecPti = 0;

													if(parseInt(ltcgPrctg10SecProviso,10) >= remaLTCGcomplete){
														ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso,10) - remaLTCGcomplete;
													}else{
														remaLTCGcomplete = document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')[0].value - parseInt(ltcgPrctg10Sec115AD3,10);
														ltcgPrctg10SecProviso=0;

														if (parseInt(ltcgPrctgPTI_LTCG10P112A,
																10) >= remaLTCGcomplete) {
															ltcgPrctgPTI_LTCG10P112A = parseInt(
																	ltcgPrctgPTI_LTCG10P112A, 10)
																	- remaLTCGcomplete;
														}else {
															remaLTCGcomplete = document
															.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
															- parseInt(
																	ltcgPrctgPTI_LTCG10P112A,
																	10);
															ltcgPrctgPTI_LTCG10P112A = 0;

															if (parseInt(ltcgPrctg10Sec112A, 10) >= remaLTCGcomplete) {
																ltcgPrctg10Sec112A = parseInt(
																		ltcgPrctg10Sec112A, 10)
																		- remaLTCGcomplete;
															} else {
																remaLTCGcomplete = document
																.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')[0].value
																- parseInt(
																		ltcgPrctg10Sec112A,
																		10);
																ltcgPrctg10Sec112A = 0;
															}
														}
													}
												}
											}


										}
									}
								}
							}
						}
					}
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
				}
			}
		}
		// 10) Short-term capital gain taxable at DTAA rates

		var stcgDtaaRateSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead')
				- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcgDtaaRateSetOffRem;

		if (setOffRem >= 0) {
			if (prevSetOffRem == 0) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			} else {
				if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
					document
					.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = stcgDtaaRateSetOffRem;
				} else {
					checkHPeditableValidity(
							'scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
							'scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
							'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
							- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
							//		- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem, 10)
					- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff');
				}
			}
		} else {
			if (!checkIfChanged('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
				document
				.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			} else {
				checkHPeditableValidity(
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
						- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
						//	- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem = 0;
		}

		// 11) Long-term capital gain taxable at DTAA rates

		var ltcgDtaaRateSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead')
				- coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - ltcgDtaaRateSetOffRem;

		if (setOffRem >= 0) {
			if (prevSetOffRem == 0) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = 0;
			} else {
				if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
					document
					.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = ltcgDtaaRateSetOffRem;
				} else {
					checkHPeditableValidity(
							'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff',
							'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
							'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
							'scheduleCYLA.totalCurYr.totHPlossCurYr',
							coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')

							- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')
							- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff'));

					setOffRem = parseInt(prevSetOffRem, 10)
					- coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff');
				}
			}
		} else {
			if (!checkIfChanged('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')) {
				document
				.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')[0].value = prevSetOffRem;
			} else {
				checkHPeditableValidity(
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff',
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead',
						'scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff',
						'scheduleCYLA.totalCurYr.totHPlossCurYr',
						coalescePath('scheduleCYLA.totalCurYr.totHPlossCurYr')
						- coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff')
						- coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff'));
			}
			setOffRem = 0;
		}

		cgosIncome.cgInc.stcg.prctg15.sec111a = stcgPercent15Sec111a;
		cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii = stcgPercent15Sec115ad_1_b_ii;
		cgosIncome.cgInc.stcg.prctg15.secPti = stcgPercent15SecPti;
		cgosIncome.cgInc.stcg.prctg30.sec115AD = stcgPercent30Sec115AD;
		cgosIncome.cgInc.ltcg.prctg20.sec112 = ltcgPrctg20Sec112;
		cgosIncome.cgInc.stcg.prctg30.secPti = stcgPercent30SecPti;
		cgosIncome.cgInc.stcg.prctgAr.stcgApp = stcgPercentArSecStcgApp;
		cgosIncome.cgInc.stcg.prctgAr.secPti = stcgPercentArSecPti;
		cgosIncome.cgInc.ltcg.prctg20.secPti = ltcgPrctg20SecPti;
		cgosIncome.cgInc.ltcg.prctg10.secProviso = ltcgPrctg10SecProviso;
		cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2 = ltcgPrctg10Sec112c2;
		cgosIncome.cgInc.ltcg.prctg10.sec115AC_1 = ltcgPrctg10Sec115AC1;
		cgosIncome.cgInc.ltcg.prctg10.sec115AD_3 = ltcgPrctg10Sec115AD3;
		cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B = ltcgPrctg10Sec115AB1B;
		cgosIncome.cgInc.ltcg.prctg10.secPti = ltcgPrctg10SecPti;
		cgosIncome.cgInc.ltcg.prctg10.secPti112A = ltcgPrctgPTI_LTCG10P112A;
		cgosIncome.cgInc.ltcg.prctg10.sec112A = ltcgPrctg10Sec112A;
		cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP = ltcgPrctg10Sec115ADiiiP;
		setOffBussLossCYLA(cgosIncome);

	}catch(e){
		alert('error in setOffHPLossCYLA = ' + e.stack);
	}
}


function setOffBussLossCYLA(cgosIncome){
	try{
		var stcgPercent15Sec111a = cgosIncome.cgInc.stcg.prctg15.sec111a;
		var stcgPercent15Sec115ad_1_b_ii = cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii;
		var stcgPercent30Sec115AD = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.sec115AD);
		var stcgPercent30SecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctg30.secPti);
		var stcgPercent15SecPti = cgosIncome.cgInc.stcg.prctg15.secPti;
		var stcgPercentArSecStcgApp = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.stcgApp);
		var stcgPercentArSecPti = zeroOrMore(cgosIncome.cgInc.stcg.prctgAr.secPti);
		var ltcgPrctg20Sec112 = zeroOrMore(cgosIncome.cgInc.ltcg.prctg20.sec112);
		var ltcgPrctg20SecPti = cgosIncome.cgInc.ltcg.prctg20.secPti;
		var ltcgPrctg10SecProviso = cgosIncome.cgInc.ltcg.prctg10.secProviso;
		var ltcgPrctg10Sec112c2 = cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2;
		var ltcgPrctg10Sec115AC1 = cgosIncome.cgInc.ltcg.prctg10.sec115AC_1;
		var ltcgPrctg10Sec115AD3 = cgosIncome.cgInc.ltcg.prctg10.sec115AD_3;
		var ltcgPrctg10Sec115AB1B = cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B;
		var ltcgPrctg10SecPti = cgosIncome.cgInc.ltcg.prctg10.secPti;
		var ltcgPrctg10Sec115ADiiiP = cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP;
		var ltcgPrctg10Sec112A = cgosIncome.cgInc.ltcg.prctg10.sec112A;


		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')[0].value = 0;
		document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff')[0].value = 0;



		/*
		Order of adjustment :-
			1) HP Income
			2) Other sources
			3) Profit from owning and maintaining race horses
			4) Short-term capital gain taxable @ 30%
			5) Short-term capital gain taxable at applicable rates
			6) Long term capital gain taxable @ 20% (1.cgosIncome.cgInc.ltcg.prctg20.sec112, 2.cgosIncome.cgInc.ltcg.prctg20.sec11EA)
			7) Short-term capital gain taxable @ 15%
			8) Long term capital gain taxable @ 10% (1. cgosIncome.cgInc.ltcg.prctg10.secProviso,
													2. cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2,
													3. cgosIncome.cgInc.ltcg.prctg10.sec115AC_1,
													4. cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1,
													5. cgosIncome.cgInc.ltcg.prctg10.sec115AD_3,
													6. cgosIncome.cgInc.ltcg.prctg10.sec115E_b)
		 */

		// 1. HP Income

		var hpSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff'));
		var prevSetOffRem = coalescePath('scheduleCYLA.totalCurYr.totBusLoss');
		var setOffRem = prevSetOffRem - hpSetOffRem;
		if(setOffRem>=0){
			if(coalescePath('scheduleCYLA.totalCurYr.totBusLoss')==0){
				document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].value = hpSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].value =
				coalescePath('scheduleCYLA.totalCurYr.totBusLoss');
			setOffRem =0 ;
		}

		// 2. Other sources

		var osIncSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff'));
		prevSetOffRem = setOffRem;
		setOffRem = prevSetOffRem - osIncSetOffRem;

		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].value =	osIncSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		//3) Profit from owning and maintaining race horse

		var raceHrsSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')-
				coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - raceHrsSetOffRem;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].value = raceHrsSetOffRem;
			}
		}else{
			document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		//4) OS DTAA

		var oSDTAA = zeroOrMore(coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.hPlossCurYrSetoff')-
				coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - oSDTAA;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff')[0].value = oSDTAA;
			}
		}else{
			document.getElementsByName('scheduleCYLA.otherSourceDtaa.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		// 4) Short-term capital gain taxable @ 30%
		prevSetOffRem = setOffRem;
		var stcg30PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
				coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.hPlossCurYrSetoff'));
		if(stcg30PercntSetOffRem>=0 && setOffRem>=0){
			if(stcg30PercntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(stcg30PercntSetOffRem,10);

				if(setOffRem>=0){
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')[0].value = parseInt(stcg30PercntSetOffRem,10);
					stcgPercent30Sec115AD = 0;
					stcgPercent30SecPti = 0;

					stcg30PercntSetOffRem = zeroOrMore(stcg30PercntSetOffRem - coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')[0].value = tempAk;
					setOffRem=0;
					// sec break up

					if(parseInt(tempAk, 10) >= 0 && parseInt(stcgPercent30Sec115AD, 10) > parseInt(tempAk, 10)){
						stcgPercent30Sec115AD = parseInt(stcgPercent30Sec115AD, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(stcgPercent30Sec115AD, 10) ;
						stcgPercent30Sec115AD = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(stcgPercent30SecPti, 10) > parseInt(tempAk, 10)){
						stcgPercent30SecPti = parseInt(stcgPercent30SecPti, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(stcgPercent30SecPti, 10) ;
						stcgPercent30SecPti = 0;
					}

					stcg30PercntSetOffRem = zeroOrMore(stcg30PercntSetOffRem - coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff'));
				}
			}else{
				var prevLtcgSetOffRem= stcg30PercntSetOffRem;

				if(stcg30PercntSetOffRem >=0){
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')[0].value = parseInt(stcg30PercntSetOffRem,10);
					stcg30PercntSetOffRem = 0;
					stcgPercent30SecPti = 0;
					stcgPercent30Sec115AD = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff')[0].value = prevLtcgSetOffRem;
					stcg30PercntSetOffRem =0 ;
					stcgPercent30SecPti=0;
					stcgPercent30Sec115AD = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.busLossSetoff'));
				}
			}
		}
		// 5) Short-term capital gain taxable at applicable rates

		prevSetOffRem = setOffRem;
		var stcgAppRatecntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
				coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));
		if(stcgAppRatecntSetOffRem>=0 && setOffRem>=0){
			if(stcgAppRatecntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(stcgAppRatecntSetOffRem,10);

				if(setOffRem>=0){
					document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = parseInt(stcgAppRatecntSetOffRem,10);
					var stcgPercentArSecStcgApp = 0;
					var stcgPercentArSecPti = 0;

					stcgAppRatecntSetOffRem = zeroOrMore(stcgAppRatecntSetOffRem - coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = tempAk;
					setOffRem=0;
					// sec break up


					if(parseInt(tempAk, 10) >= 0 && parseInt(stcgPercentArSecStcgApp, 10) > parseInt(tempAk, 10)){
						stcgPercentArSecStcgApp = parseInt(stcgPercentArSecStcgApp, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(stcgPercentArSecStcgApp, 10) ;
						stcgPercentArSecStcgApp = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(stcgPercentArSecPti, 10) > parseInt(tempAk, 10)){
						stcgPercentArSecPti = parseInt(stcgPercentArSecPti, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(stcgPercentArSecPti, 10) ;
						stcgPercentArSecPti = 0;
					}

					stcgAppRatecntSetOffRem = zeroOrMore(stcgAppRatecntSetOffRem - coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff'));
				}
			}else{
				var prevLtcgSetOffRem= stcgAppRatecntSetOffRem;

				if(stcgAppRatecntSetOffRem >=0){
					document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = parseInt(stcgAppRatecntSetOffRem,10);
					stcgAppRatecntSetOffRem = 0;
					stcgPercentArSecStcgApp = 0;
					stcgPercentArSecPti = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = prevLtcgSetOffRem;
					stcgAppRatecntSetOffRem =0 ;
					stcgPercentArSecStcgApp=0;
					stcgPercentArSecPti = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff'));
				}
			}
		}

		/*var stcgAppRateSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.othSrcLossNoRaceHorseSetoff')-
			coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.hPlossCurYrSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcgAppRateSetOffRem;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = stcgAppRateSetOffRem;
			}
		}else{
				document.getElementsByName('scheduleCYLA.stcg.stcgAppRate.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
				setOffRem =0 ;
		}*/

		// 6) Long term capital gain taxable @ 20%
		prevSetOffRem = setOffRem;
		var ltcg20PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
				coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.hPlossCurYrSetoff'));

		if(ltcg20PercntSetOffRem>=0 && setOffRem>=0){
			if(ltcg20PercntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(ltcg20PercntSetOffRem,10);
				if(setOffRem>=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')[0].value = parseInt(ltcg20PercntSetOffRem,10);
					ltcgPrctg20Sec112 = 0;
					ltcgPrctg20SecPti = 0;

					ltcg20PercntSetOffRem = zeroOrMore(ltcg20PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')[0].value = tempAk;
					setOffRem=0;
					// sec break up


					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg20SecPti, 10) > parseInt(tempAk, 10)){
						ltcgPrctg20SecPti = parseInt(ltcgPrctg20SecPti, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg20SecPti, 10) ;
						ltcgPrctg20SecPti = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg20Sec112, 10) > parseInt(tempAk, 10)){
						ltcgPrctg20Sec112 = parseInt(ltcgPrctg20Sec112, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg20Sec112, 10) ;
						ltcgPrctg20Sec112 = 0;
					}

					ltcg20PercntSetOffRem = zeroOrMore(ltcg20PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff'));
				}
			}else{
				var prevLtcgSetOffRem= ltcg20PercntSetOffRem;

				if(ltcg20PercntSetOffRem >=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')[0].value = parseInt(ltcg20PercntSetOffRem,10);
					ltcg20PercntSetOffRem = 0;
					ltcgPrctg20Sec112 = 0;
					ltcgPrctg20SecPti = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff')[0].value = prevLtcgSetOffRem;
					ltcg20PercntSetOffRem =0 ;
					ltcgPrctg20Sec112=0;
					ltcgPrctg20SecPti = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.busLossSetoff'));
				}
			}
		}
		// 7) Short-term capital gain taxable @ 15%
		var stcg15PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
				coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.hPlossCurYrSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcg15PercntSetOffRem;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')[0].value = stcg15PercntSetOffRem;
				stcg15PercntSetOffRem = 0;
				stcgPercent15Sec111a = 0;
				stcgPercent15Sec115ad_1_b_ii = 0;
				stcgPercent15SecPti = 0;


			}
		}else{
			document.getElementsByName('scheduleCYLA.stcg.stcg15Per.incCYLA.busLossSetoff')[0].value = prevSetOffRem;

			// sec break up
			if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec115ad_1_b_ii, 10) > parseInt(prevSetOffRem, 10)){
				stcgPercent15Sec115ad_1_b_ii = parseInt(stcgPercent15Sec115ad_1_b_ii, 10) -
				parseInt(prevSetOffRem, 10);
				prevSetOffRem = 0;
			}else{
				prevSetOffRem = parseInt(prevSetOffRem, 10) -
				parseInt(stcgPercent15Sec115ad_1_b_ii, 10) ;
				stcgPercent15Sec115ad_1_b_ii = 0;
			}
			if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15SecPti, 10) > parseInt(prevSetOffRem, 10)){
				stcgPercent15SecPti = parseInt(stcgPercent15SecPti, 10) -
				parseInt(prevSetOffRem, 10);
				prevSetOffRem = 0;
			}else{
				prevSetOffRem = parseInt(prevSetOffRem, 10) -
				parseInt(stcgPercent15SecPti, 10) ;
				stcgPercent15SecPti = 0;
			}


			if(parseInt(prevSetOffRem, 10) >= 0 && parseInt(stcgPercent15Sec111a, 10) > parseInt(prevSetOffRem, 10)){
				stcgPercent15Sec111a = parseInt(stcgPercent15Sec111a, 10) -
				parseInt(prevSetOffRem, 10);
				prevSetOffRem = 0;
			}else{
				prevSetOffRem = parseInt(prevSetOffRem, 10) -
				parseInt(stcgPercent15Sec111a, 10) ;
				stcgPercent15Sec111a = 0;
			}

			setOffRem =0 ;
		}

		// 8) Long term capital gain taxable @ 10%
		prevSetOffRem = setOffRem;
		var ltcg10PercntSetOffRem = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.othSrcLossNoRaceHorseSetoff')-
				coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.hPlossCurYrSetoff'));
		if(ltcg10PercntSetOffRem>=0 && setOffRem>=0){
			if(ltcg10PercntSetOffRem>=setOffRem){
				var tempAk = setOffRem;
				setOffRem = setOffRem - parseInt(ltcg10PercntSetOffRem,10);

				if(setOffRem>=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')[0].value = parseInt(ltcg10PercntSetOffRem,10);
					ltcgPrctg10Sec112c2 = 0;
					ltcgPrctg10Sec115AC1 = 0;
					ltcgPrctg10Sec115AD3 = 0;
					ltcgPrctg10Sec115AB1B = 0;
					ltcgPrctg10SecProviso = 0;
					ltcgPrctg10SecPti = 0;
					ltcgPrctg10Sec115ADiiiP = 0;
					ltcgPrctg10Sec112A = 0;

					ltcg10PercntSetOffRem = zeroOrMore(ltcg10PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff'));
				}else{
					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')[0].value = tempAk;
					setOffRem=0;

					//Section break up

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec112c2, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec112c2 = parseInt(ltcgPrctg10Sec112c2, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec112c2, 10) ;
						ltcgPrctg10Sec112c2 = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AB1B, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AB1B = parseInt(ltcgPrctg10Sec115AB1B, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AB1B, 10) ;
						ltcgPrctg10Sec115AB1B = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AC1, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AC1 = parseInt(ltcgPrctg10Sec115AC1, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AC1, 10) ;
						ltcgPrctg10Sec115AC1 = 0;
					}


					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115AD3, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115AD3 = parseInt(ltcgPrctg10Sec115AD3, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115AD3, 10) ;
						ltcgPrctg10Sec115AD3 = 0;
					}
					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec115ADiiiP, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec115ADiiiP = parseInt(ltcgPrctg10Sec115ADiiiP, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10Sec115ADiiiP, 10) ;
						ltcgPrctg10Sec115ADiiiP = 0;
					}
					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10SecPti, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10SecPti = parseInt(ltcgPrctg10SecPti, 10) -
						parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) -
						parseInt(ltcgPrctg10SecPti, 10) ;
						ltcgPrctg10SecPti = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10SecProviso, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10SecProviso = parseInt(ltcgPrctg10SecProviso, 10) - parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) - parseInt(ltcgPrctg10SecProviso, 10) ;
						ltcgPrctg10SecProviso = 0;
					}

					if(parseInt(tempAk, 10) >= 0 && parseInt(ltcgPrctg10Sec112A, 10) > parseInt(tempAk, 10)){
						ltcgPrctg10Sec112A = parseInt(ltcgPrctg10Sec112A, 10) - parseInt(tempAk, 10);
						tempAk = 0;
					}else{
						tempAk = parseInt(tempAk, 10) - parseInt(ltcgPrctg10Sec112A, 10) ;
						ltcgPrctg10Sec112A = 0;
					}


					ltcg10PercntSetOffRem = zeroOrMore(ltcg10PercntSetOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff'));
				}
			}else{
				var prevLtcgSetOffRem= ltcg10PercntSetOffRem;

				if(ltcg10PercntSetOffRem >=0){
					document.getElementsByName('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff')[0].value = parseInt(ltcg10PercntSetOffRem,10);
					ltcg10PercntSetOffRem=0;
					ltcgPrctg10Sec112c2 = 0;
					ltcgPrctg10Sec115AC1 = 0;
					ltcgPrctg10Sec115AD3 = 0;
					ltcgPrctg10Sec115AB1B = 0;
					ltcgPrctg10SecProviso = 0;
					ltcgPrctg10SecPti = 0;
					ltcgPrctg10Sec115ADiiiP = 0;
					ltcgPrctg10Sec112A = 0;
					setOffRem = zeroOrMore(setOffRem - coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.busLossSetoff'));
				}
			}
		}
		//4) STCG DTAA
		var stcgDTAA = zeroOrMore(coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.hPlossCurYrSetoff')-
				coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - stcgDTAA;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')[0].value = stcgDTAA;
			}
		}else{
			document.getElementsByName('scheduleCYLA.stcg.stcgDTAARate.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		//4) LTCG DTAA
		var ltcgDTAA = zeroOrMore(coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrUnderThatHead')-
				coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.hPlossCurYrSetoff')-
				coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.othSrcLossNoRaceHorseSetoff'));

		prevSetOffRem = setOffRem;
		setOffRem = setOffRem - ltcgDTAA;
		if(setOffRem>=0){
			if(prevSetOffRem==0){
				document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')[0].value = 0;
			}else{
				document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')[0].value = ltcgDTAA;
			}
		}else{
			document.getElementsByName('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		cgosIncome.cgInc.stcg.prctg15.sec111a = stcgPercent15Sec111a;
		cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii = stcgPercent15Sec115ad_1_b_ii;
		cgosIncome.cgInc.stcg.prctg15.secPti = stcgPercent15SecPti;
		cgosIncome.cgInc.stcg.prctg30.sec115AD = stcgPercent30Sec115AD;
		cgosIncome.cgInc.stcg.prctg30.secPti = stcgPercent30SecPti;
		cgosIncome.cgInc.stcg.prctgAr.stcgApp = stcgPercentArSecStcgApp;
		cgosIncome.cgInc.stcg.prctgAr.secPti = stcgPercentArSecPti;
		cgosIncome.cgInc.ltcg.prctg20.secPti = ltcgPrctg20SecPti;
		cgosIncome.cgInc.ltcg.prctg10.secProviso = ltcgPrctg10SecProviso;
		cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2 = ltcgPrctg10Sec112c2;
		cgosIncome.cgInc.ltcg.prctg10.sec115AC_1 = ltcgPrctg10Sec115AC1;
		cgosIncome.cgInc.ltcg.prctg10.sec115AD_3 = ltcgPrctg10Sec115AD3;
		cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B = ltcgPrctg10Sec115AB1B;
		cgosIncome.cgInc.ltcg.prctg10.secPti = ltcgPrctg10SecPti;
		cgosIncome.cgInc.ltcg.prctg10.sec112A = ltcgPrctg10Sec112A;
		cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP = ltcgPrctg10Sec115ADiiiP;
		cgosIncome.cgInc.ltcg.prctg20.sec112 = ltcgPrctg20Sec112;
		cgosIncome.cgInc.ltcg.prctg10.secPti = ltcgPrctg10SecPti;

	}catch(e){
		alert('error in  setOffBussLossCYLA() = ' + e.stack);
	}
}

function calcBFLA(cgosIncome){
	try{
		prefillBFLA();
		calcCFL_sumAll();
		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.hpLossCFTotal',
				'scheduleBFLA.hp.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF',
				'scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF',
				'scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		var specltvIncSetOff = document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value ;

		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF',
				'scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		var specfdIncSetOff = document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value ;

//		2020 changes
			setFirstToSecondMax(
					'scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmInsuCF',
					'scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA',
					'scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
			var bfla115B = document
			.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value;
		
		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal',
				'scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		
		
		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal',
				'scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal',
				'scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal',
				'scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal',
				'scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.othSrcLossRaceHorseCF',
				'scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax(
				'scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal',
				'scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		setFirstToSecondMax(
				'scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal',
				'scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff');


		// setting off loss from business
		var setOffBusLoss = coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF')-
		coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		//b
		var setOffNotDoneInSpecInc = coalescePath('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		var prevSetOffBusLoss = setOffBusLoss;
		setOffBusLoss = setOffBusLoss - setOffNotDoneInSpecInc;
		if(setOffBusLoss>=0){
			document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
				coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') + setOffNotDoneInSpecInc;
		}else{
			document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
				coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') + prevSetOffBusLoss;
			setOffBusLoss = 0;
		}

		//c
		var setOffNotDoneInSpecfdInc = coalescePath('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		prevSetOffBusLoss = setOffBusLoss;
		setOffBusLoss = setOffBusLoss - setOffNotDoneInSpecfdInc;
		if(setOffBusLoss>=0){
			document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
				coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') + setOffNotDoneInSpecfdInc;

		}else{
			document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
				coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') + prevSetOffBusLoss;
			setOffBusLoss = 0;
		}

//		2020 changes


		var setOffNotDone115b = coalescePath('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA')
					- coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
			prevSetOffBusLoss = setOffBusLoss;
			setOffBusLoss = setOffBusLoss - setOffNotDone115b;
			if (setOffBusLoss >= 0) {
				document
						.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value = coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')
						+ setOffNotDone115b;

			} else {
				document
						.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value = coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')
						+ prevSetOffBusLoss;
				setOffBusLoss = 0;
			}


		/*var busLossOthThanSpecLossCFLL = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF')-
				coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				zeroOrMore(coalesceSetRet('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF'))-
				zeroOrMore(coalesceSetRet('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF')));
*/
		/*setFirstToSecondMaxMod(busLossOthThanSpecLossCFLL,
				'scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA',
		'scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');*/


		//setting off STCG and LTCG
		var stcgCFL = coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal');  var tempstcgCFL = stcgCFL;
		var ltcgCFL = coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal');	 var tempLtcgCFL = ltcgCFL;

		var stcgBreakUp1 = cgosIncome.cgInc.stcg.prctg30.sec115AD;
		var stcgBreakUp7 = cgosIncome.cgInc.stcg.prctg30.secPti;
		var stcgBreakUp2 = cgosIncome.cgInc.stcg.prctgAr.stcgApp;
		var stcgBreakUp8 = cgosIncome.cgInc.stcg.prctgAr.secPti;
		var stcgBreakUp3  = cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii;
		var stcgBreakUp6 = cgosIncome.cgInc.stcg.prctg15.secPti;
		var stcgBreakUp4  = cgosIncome.cgInc.stcg.prctg15.sec111a;
		var stcgBreakUp5 = coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA');


		var ltcgBreakUp12 = cgosIncome.cgInc.ltcg.prctg20.secPti;
		var ltcgBreakUp1 = cgosIncome.cgInc.ltcg.prctg20.sec112;
		var ltcgBreakUp2 = cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2;
		var ltcgBreakUp3 = cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B;
		var ltcgBreakUp4 = cgosIncome.cgInc.ltcg.prctg10.sec115AC_1;
		var ltcgBreakUp5 = cgosIncome.cgInc.ltcg.prctg10.sec115AD_3;
		var ltcgBreakUp10 = cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP;
		var ltcgBreakUp13 = cgosIncome.cgInc.ltcg.prctg10.secPti;
		var ltcgBreakUp6 = cgosIncome.cgInc.ltcg.prctg10.secProviso;
		var ltcgBreakUp14 = cgosIncome.cgInc.ltcg.prctg10.secPti112A;
		var ltcgBreakUp9 = cgosIncome.cgInc.ltcg.prctg10.sec112A;
		var ltcgBreakUp11 = coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA');



		var tempstcgBreakUp1  = parseInt(stcgBreakUp1,10);
		var tempstcgBreakUp7  = parseInt(stcgBreakUp7,10);
		var tempstcgBreakUp2  = parseInt(stcgBreakUp2,10);
		var tempstcgBreakUp8 = parseInt(stcgBreakUp8, 10);
		var tempstcgBreakUp3  = parseInt(stcgBreakUp3,10);
		var tempstcgBreakUp6 = parseInt(stcgBreakUp6, 10);
		var tempstcgBreakUp4  = parseInt(stcgBreakUp4,10);
		var tempstcgBreakUp5 = parseInt(stcgBreakUp5, 10);


		var templtcgBreakUp12 = parseInt(ltcgBreakUp12, 10);
		var templtcgBreakUp1 = parseInt(ltcgBreakUp1,10);
		var templtcgBreakUp2 = parseInt(ltcgBreakUp2,10);
		var templtcgBreakUp3 = parseInt(ltcgBreakUp3,10);
		var templtcgBreakUp4 = parseInt(ltcgBreakUp4,10);
		var templtcgBreakUp5 = parseInt(ltcgBreakUp5,10);
		var templtcgBreakUp10 = parseInt(ltcgBreakUp10, 10);
		var templtcgBreakUp13 = parseInt(ltcgBreakUp13, 10);
		var templtcgBreakUp6 = parseInt(ltcgBreakUp6,10);
		var templtcgBreakUp14 = parseInt(ltcgBreakUp14, 10);
		var templtcgBreakUp9 = parseInt(ltcgBreakUp9, 10);
		var templtcgBreakUp11 = parseInt(ltcgBreakUp11, 10);


		if (tempLtcgCFL > templtcgBreakUp12) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp12;
			templtcgBreakUp12 = 0;

		} else {
			templtcgBreakUp12 = zeroOrMore(templtcgBreakUp12 - tempLtcgCFL);
			tempLtcgCFL = 0;

		}

		if(tempLtcgCFL>templtcgBreakUp1){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp1;
			templtcgBreakUp1 =0;


		}else{
			templtcgBreakUp1 = zeroOrMore(templtcgBreakUp1 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp2){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp2;
			templtcgBreakUp2 =0;
		}else{
			templtcgBreakUp2 = zeroOrMore(templtcgBreakUp2 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp3){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp3;
			templtcgBreakUp3 =0;
		}else{
			templtcgBreakUp3 = zeroOrMore(templtcgBreakUp3 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp4){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp4;
			templtcgBreakUp4 =0;
		}else{
			templtcgBreakUp4 = zeroOrMore(templtcgBreakUp4 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp5){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp5;
			templtcgBreakUp5 =0;
		}else{
			templtcgBreakUp5 = zeroOrMore(templtcgBreakUp5 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if (tempLtcgCFL > templtcgBreakUp10) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp10;
			templtcgBreakUp10 = 0;
		} else {
			templtcgBreakUp10 = zeroOrMore(templtcgBreakUp10 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if (tempLtcgCFL > templtcgBreakUp13) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp13;
			templtcgBreakUp13 = 0;
		} else {
			templtcgBreakUp13 = zeroOrMore(templtcgBreakUp13 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if(tempLtcgCFL>templtcgBreakUp6){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp6;
			templtcgBreakUp6 =0;
		}else{
			templtcgBreakUp6 = zeroOrMore(templtcgBreakUp6 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if (tempLtcgCFL > templtcgBreakUp14) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp14;
			templtcgBreakUp14 = 0;
		} else {
			templtcgBreakUp14 = zeroOrMore(templtcgBreakUp14 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}


		if (tempLtcgCFL > templtcgBreakUp9) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp9;
			templtcgBreakUp9 = 0;
		} else {
			templtcgBreakUp9 = zeroOrMore(templtcgBreakUp9 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if (tempLtcgCFL > templtcgBreakUp11) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp11;
			templtcgBreakUp11 = 0;
		} else {
			templtcgBreakUp11 = zeroOrMore(templtcgBreakUp11 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}



		//setting the "adjustment of above losses in BFLA" - LTCG value in CFL


		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.ltcgLossCFTotal')[0].value =
			parseInt(zeroOrMore(parseInt(ltcgBreakUp1,10) - templtcgBreakUp1),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp2,10) - templtcgBreakUp2),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp12, 10)	- templtcgBreakUp12), 10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp3,10) - templtcgBreakUp3),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp4,10) - templtcgBreakUp4),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp5,10) - templtcgBreakUp5),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp6,10) - templtcgBreakUp6),10)+
			parseInt(zeroOrMore(parseInt(ltcgBreakUp14, 10)- templtcgBreakUp14), 10)+
			parseInt(zeroOrMore(parseInt(ltcgBreakUp13, 10) - templtcgBreakUp13), 10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp9, 10) - templtcgBreakUp9), 10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp10, 10) - templtcgBreakUp10), 10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp11, 10) - templtcgBreakUp11), 10);




		var storeSTCG1 = tempstcgBreakUp1;
		var storeSTCG7 = tempstcgBreakUp7;
		var storeSTCG2 = tempstcgBreakUp2;
		var storeSTCG8 = tempstcgBreakUp8;
		var storeLTCG12 = templtcgBreakUp12;
		var storeLTCG1 = templtcgBreakUp1;
		var storeSTCG3 = tempstcgBreakUp3;
		var storeSTCG6 = tempstcgBreakUp6;
		var storeSTCG4 = tempstcgBreakUp4;
		var storeLTCG2 = templtcgBreakUp2;
		var storeLTCG3 = templtcgBreakUp3;
		var storeLTCG4 = templtcgBreakUp4;
		var storeLTCG5 = templtcgBreakUp5;
		var storeLTCG10 = templtcgBreakUp10;
		var storeLTCG14 = templtcgBreakUp14;
		var storeLTCG13 = templtcgBreakUp13;
		var storeLTCG6 = templtcgBreakUp6;
		var storeLTCG9 = templtcgBreakUp9;
		var storeSTCG5 = tempstcgBreakUp5;
		var storeLTCG11 = templtcgBreakUp11;



//		adjusting with STCG

		if(tempstcgCFL>tempstcgBreakUp1){
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp1;
			tempstcgBreakUp1 =0;
		}else{
			tempstcgBreakUp1 = zeroOrMore(tempstcgBreakUp1 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if (tempstcgCFL > tempstcgBreakUp7) {
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp7;
			tempstcgBreakUp7 = 0;
		} else {
			tempstcgBreakUp7 = zeroOrMore(tempstcgBreakUp7 - tempstcgCFL);
			tempstcgCFL = 0;
		}


		if(tempstcgCFL>tempstcgBreakUp2){
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp2;
			tempstcgBreakUp2 =0;
		}else{
			tempstcgBreakUp2 = zeroOrMore(tempstcgBreakUp2 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if (tempstcgCFL > tempstcgBreakUp8) {
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp8;
			tempstcgBreakUp8 = 0;
		} else {
			tempstcgBreakUp8 = zeroOrMore(tempstcgBreakUp8 - tempstcgCFL);
			tempstcgCFL = 0;
		}


		if (tempstcgCFL > templtcgBreakUp12) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp12;
			templtcgBreakUp12 = 0;
		} else {
			templtcgBreakUp12 = zeroOrMore(templtcgBreakUp12 - tempstcgCFL);
			tempstcgCFL = 0;
		}

		if(tempstcgCFL>templtcgBreakUp1){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp1;
			templtcgBreakUp1 =0;
		}else{
			templtcgBreakUp1 = zeroOrMore(templtcgBreakUp1 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if(tempstcgCFL>tempstcgBreakUp3){
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp3;
			tempstcgBreakUp3 =0;
		}else{
			tempstcgBreakUp3 = zeroOrMore(tempstcgBreakUp3 - tempstcgCFL);
			tempstcgCFL=0;
		}
		if (tempstcgCFL > tempstcgBreakUp6) {
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp6;
			tempstcgBreakUp6 = 0;
		} else {
			tempstcgBreakUp6 = zeroOrMore(tempstcgBreakUp6 - tempstcgCFL);
			tempstcgCFL = 0;
		}

		if(tempstcgCFL>tempstcgBreakUp4){
			tempstcgCFL = tempstcgCFL - tempstcgBreakUp4;
			tempstcgBreakUp4 =0;
		}else{
			tempstcgBreakUp4 = zeroOrMore(tempstcgBreakUp4 - tempstcgCFL);
			tempstcgCFL=0;
		}
		if(tempstcgCFL>templtcgBreakUp2){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp2;
			templtcgBreakUp2 =0;
		}else{
			templtcgBreakUp2= zeroOrMore(templtcgBreakUp2 - tempstcgCFL);
			tempstcgCFL=0;
		}
		if(tempstcgCFL>templtcgBreakUp3){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp3;
			templtcgBreakUp3 =0;
		}else{
			templtcgBreakUp3= zeroOrMore(templtcgBreakUp3 - tempstcgCFL);
			tempstcgCFL=0;
		}
		if(tempstcgCFL>templtcgBreakUp4){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp4;
			templtcgBreakUp4 =0;
		}else{
			templtcgBreakUp4= zeroOrMore(templtcgBreakUp4 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if(tempstcgCFL>templtcgBreakUp5){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp5;
			templtcgBreakUp5 =0;
		}else{
			templtcgBreakUp5= zeroOrMore(templtcgBreakUp5 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if (tempstcgCFL > templtcgBreakUp10) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp10;
			templtcgBreakUp10 = 0;
		} else {
			templtcgBreakUp10 = zeroOrMore(templtcgBreakUp10 - tempstcgCFL);
			tempstcgCFL = 0;
		}


		if (tempstcgCFL > templtcgBreakUp13) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp13;
			templtcgBreakUp13 = 0;
		} else {
			templtcgBreakUp13 = zeroOrMore(templtcgBreakUp13 - tempstcgCFL);
			tempstcgCFL = 0;
		}



		if(tempstcgCFL>templtcgBreakUp6){
			tempstcgCFL = tempstcgCFL - templtcgBreakUp6;
			templtcgBreakUp6 =0;
		}else{
			templtcgBreakUp6 = zeroOrMore(templtcgBreakUp6 - tempstcgCFL);
			tempstcgCFL=0;
		}

		if (tempstcgCFL > templtcgBreakUp14) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp14;
			templtcgBreakUp14 = 0;
		} else {
			templtcgBreakUp14 = zeroOrMore(templtcgBreakUp14 - tempstcgCFL);
			tempstcgCFL = 0;
		}


		if (tempstcgCFL > templtcgBreakUp9) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp9;
			templtcgBreakUp9 = 0;
		} else {
			templtcgBreakUp9 = zeroOrMore(templtcgBreakUp9 - tempstcgCFL);
			tempstcgCFL = 0;
		}

		if (tempstcgCFL > tempstcgBreakUp5) {
			tempstcgCFL =tempstcgCFL - tempstcgBreakUp5;
			tempstcgBreakUp5 = 0;
		} else {
			tempstcgBreakUp5 = zeroOrMore(tempstcgBreakUp5 -tempstcgCFL);
			tempstcgCFL = 0;
		}

		if (tempstcgCFL > templtcgBreakUp11) {
			tempstcgCFL = tempstcgCFL - templtcgBreakUp11;
			templtcgBreakUp11 = 0;
		} else {
			templtcgBreakUp11 = zeroOrMore(templtcgBreakUp11 - tempstcgCFL);
			tempstcgCFL = 0;
		}

//		adjusting with LTCG


		if (tempLtcgCFL > templtcgBreakUp12) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp12;
			templtcgBreakUp12 = 0;
		} else {
			templtcgBreakUp12 = zeroOrMore(templtcgBreakUp12 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if(tempLtcgCFL>templtcgBreakUp1){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp1;
			templtcgBreakUp1 =0;
		}else{
			templtcgBreakUp1 = zeroOrMore(templtcgBreakUp1 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp2){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp2;
			templtcgBreakUp2 =0;
		}else{
			templtcgBreakUp2 = zeroOrMore(templtcgBreakUp2 - tempLtcgCFL);
			tempLtcgCFL=0;
		}
		if(tempLtcgCFL>templtcgBreakUp3){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp3;
			templtcgBreakUp3 =0;
		}else{
			templtcgBreakUp3 = zeroOrMore(templtcgBreakUp3 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp4){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp4;
			templtcgBreakUp4 =0;
		}else{
			templtcgBreakUp4 = zeroOrMore(templtcgBreakUp4 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if(tempLtcgCFL>templtcgBreakUp5){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp5;
			templtcgBreakUp5 =0;
		}else{
			templtcgBreakUp5= zeroOrMore(templtcgBreakUp5 - tempLtcgCFL);
			tempLtcgCFL=0;
		}
		if (tempLtcgCFL > templtcgBreakUp10) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp10;
			templtcgBreakUp10 = 0;
		} else {
			templtcgBreakUp10 = zeroOrMore(templtcgBreakUp10 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if (tempLtcgCFL > templtcgBreakUp13) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp13;
			templtcgBreakUp13 = 0;
		} else {
			templtcgBreakUp13 = zeroOrMore(templtcgBreakUp13 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if(tempLtcgCFL>templtcgBreakUp6){
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp6;
			templtcgBreakUp6 =0;
		}else{
			templtcgBreakUp6 = zeroOrMore(templtcgBreakUp6 - tempLtcgCFL);
			tempLtcgCFL=0;
		}

		if (tempLtcgCFL > templtcgBreakUp14) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp14;
			templtcgBreakUp14 = 0;
		} else {
			templtcgBreakUp14 = zeroOrMore(templtcgBreakUp14 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}


		if (tempLtcgCFL > templtcgBreakUp9) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp9;
			templtcgBreakUp9 = 0;
		} else {
			templtcgBreakUp9 = zeroOrMore(templtcgBreakUp9 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}

		if (tempLtcgCFL > templtcgBreakUp11) {
			tempLtcgCFL = tempLtcgCFL - templtcgBreakUp11;
			templtcgBreakUp11 = 0;
		} else {
			templtcgBreakUp11 = zeroOrMore(templtcgBreakUp11 - tempLtcgCFL);
			tempLtcgCFL = 0;
		}



		document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
			parseInt(zeroOrMore(parseInt(stcgBreakUp1,10) - tempstcgBreakUp1),10)+
			parseInt(zeroOrMore(parseInt(stcgBreakUp7,10) - tempstcgBreakUp7),10);

		document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
			parseInt(zeroOrMore(parseInt(stcgBreakUp2,10) - tempstcgBreakUp2),10)+
			parseInt(zeroOrMore(parseInt(stcgBreakUp8,10) - tempstcgBreakUp8),10);

		document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
			parseInt(zeroOrMore(parseInt(stcgBreakUp3,10) - tempstcgBreakUp3),10) +
			parseInt(zeroOrMore(parseInt(stcgBreakUp6,10) - tempstcgBreakUp6),10) +
			parseInt(zeroOrMore(parseInt(stcgBreakUp4,10) - tempstcgBreakUp4),10);

		document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
			parseInt(zeroOrMore(parseInt(ltcgBreakUp1,10) - templtcgBreakUp1),10)+
			parseInt(zeroOrMore(parseInt(ltcgBreakUp12,10) - templtcgBreakUp12),10);




		document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value =
			parseInt(zeroOrMore(parseInt(ltcgBreakUp2,10) - templtcgBreakUp2),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp3,10) - templtcgBreakUp3),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp4,10) - templtcgBreakUp4),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp5,10) - templtcgBreakUp5),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp10, 10)	- templtcgBreakUp10), 10)+
			parseInt(zeroOrMore(parseInt(ltcgBreakUp14, 10)- templtcgBreakUp14), 10)+
			parseInt(zeroOrMore(parseInt(ltcgBreakUp13, 10)	- templtcgBreakUp13), 10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp6,10) - templtcgBreakUp6),10) +
			parseInt(zeroOrMore(parseInt(ltcgBreakUp9, 10) - templtcgBreakUp9), 10);

		document
		.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value = parseInt(zeroOrMore(parseInt(stcgBreakUp5, 10)
				- tempstcgBreakUp5), 10);

		document
		.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value = parseInt(zeroOrMore(parseInt(ltcgBreakUp11, 10)
				- templtcgBreakUp11), 10);



		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.stcgLossCFTotal')[0].value =
			parseInt(zeroOrMore( storeSTCG1 - tempstcgBreakUp1 ),10)+
			parseInt(zeroOrMore( storeSTCG2 - tempstcgBreakUp2 ),10)+
			parseInt(zeroOrMore( storeSTCG3 - tempstcgBreakUp3 ),10)+
			parseInt(zeroOrMore( storeSTCG4 - tempstcgBreakUp4 ),10)+
			parseInt(zeroOrMore( storeLTCG1 - templtcgBreakUp1 ),10)+
			parseInt(zeroOrMore( storeLTCG2 - templtcgBreakUp2 ),10)+
			parseInt(zeroOrMore( storeLTCG3 - templtcgBreakUp3 ),10)+
			parseInt(zeroOrMore( storeLTCG4 - templtcgBreakUp4 ),10)+

			parseInt(zeroOrMore( storeLTCG5 - templtcgBreakUp5 ),10)+
			parseInt(zeroOrMore( storeLTCG6 - templtcgBreakUp6 ),10)+
			parseInt(zeroOrMore( storeSTCG7 - tempstcgBreakUp7 ),10)+
			parseInt(zeroOrMore( storeSTCG8 - tempstcgBreakUp8 ),10)+
			parseInt(zeroOrMore( storeLTCG12 - templtcgBreakUp12 ),10)+

			parseInt(zeroOrMore( storeSTCG6 - tempstcgBreakUp6 ),10)+
			parseInt(zeroOrMore( storeLTCG10 - templtcgBreakUp10 ),10)+
			parseInt(zeroOrMore(storeLTCG14 - templtcgBreakUp14), 10)+
			parseInt(zeroOrMore( storeLTCG13 - templtcgBreakUp13 ),10)+
			parseInt(zeroOrMore( storeLTCG9 - templtcgBreakUp9 ),10)+
			parseInt(zeroOrMore( storeSTCG5 - tempstcgBreakUp5 ),10)+
			parseInt(zeroOrMore( storeLTCG11 - templtcgBreakUp11 ),10);

		var totalUDDeprctn = document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0].value;

		var busProfSpecProfset=coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		if(busProfSpecProfset>0){
			if(busProfSpecProfset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')[0].value = busProfSpecProfset;
				totalUDDeprctn = totalUDDeprctn - busProfSpecProfset;

			} else {
				document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}



		var Speculativeset=coalescePath('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(Speculativeset>0){
			if(Speculativeset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = Speculativeset;
				totalUDDeprctn = totalUDDeprctn - Speculativeset;

			} else {
				document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

		var specifiedSet=coalescePath('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(specifiedSet>0){
			if(specifiedSet<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = specifiedSet;
				totalUDDeprctn = totalUDDeprctn - specifiedSet;

			} else {
				document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}
		var profitGainUs115B=coalescePath('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(profitGainUs115B>0){
			if(profitGainUs115B<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = profitGainUs115B;
				totalUDDeprctn = totalUDDeprctn - profitGainUs115B;

			} else {
				document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}
		var hpset=coalescePath('scheduleBFLA.hp.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(hpset>0){
			if(hpset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')[0].value = hpset;
				totalUDDeprctn = totalUDDeprctn - hpset;

			} else {
				document.getElementsByName('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff')[0].value=
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrUnderThatHead')-
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')-
			coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff');
		document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff');
		var otherSrcset=coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA');
		if(otherSrcset>0){
			if(otherSrcset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = otherSrcset;
				totalUDDeprctn = totalUDDeprctn - otherSrcset;

			} else {
				document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

		var profitOwnset=coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(profitOwnset>0){

			if(profitOwnset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = profitOwnset;
				totalUDDeprctn = totalUDDeprctn - profitOwnset;

			} else {
				document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

		var otherSrcDtaasetOff=coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(otherSrcDtaasetOff>0){
			if(otherSrcDtaasetOff<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = otherSrcDtaasetOff;
				totalUDDeprctn = totalUDDeprctn - otherSrcDtaasetOff;

			} else {
				document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}


//		1
		var stcg30Perset=coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(stcg30Perset>0){
			if(stcg30Perset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = stcg30Perset;
				totalUDDeprctn = totalUDDeprctn - stcg30Perset;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}


		var stcgAppset=coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(stcgAppset>0){
			if(stcgAppset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = stcgAppset;
				totalUDDeprctn = totalUDDeprctn - stcgAppset;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}



		var ltcg20Perset=coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');

		if(ltcg20Perset>0){
			if(ltcg20Perset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = ltcg20Perset;
				totalUDDeprctn = totalUDDeprctn - ltcg20Perset;


			} else {
				document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}


		var stcg15Perset=coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(stcg15Perset>0){
			if(stcg15Perset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = stcg15Perset;
				totalUDDeprctn = totalUDDeprctn - stcg15Perset;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

		var ltcg10Perset=coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
		coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if(ltcg10Perset>0){
			if(ltcg10Perset<=totalUDDeprctn){
				document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = ltcg10Perset;
				totalUDDeprctn = totalUDDeprctn - ltcg10Perset;

			} else {
				document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;
		}





		var profitstcgDtaa = coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')
		- coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if (profitstcgDtaa > 0) {
			if (profitstcgDtaa <= totalUDDeprctn) {
				document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = profitstcgDtaa;
				totalUDDeprctn = totalUDDeprctn - profitstcgDtaa;

			} else {
				document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {

			document
			.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

		var profitltcgDtaa = coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')
		- coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff');
		if (profitltcgDtaa > 0) {
			if (profitltcgDtaa <= totalUDDeprctn) {
				document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = profitltcgDtaa;
				totalUDDeprctn = totalUDDeprctn - profitltcgDtaa;

			} else {
				document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = totalUDDeprctn;
				totalUDDeprctn = 0;

			}
		} else {
			document
			.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')[0].value = 0;

		}

//		calculating sum of column 3
		document.getElementsByName('scheduleBFLA.totalBFLossSetOff.totUnabsorbedDeprSetoff')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')+
			/*		coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
			 */		coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff');
		;


//		checking max limits of "Brought forward depreciation set off" --- column 4

		var busProfSpecAllwnceSet = (coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff'));
		var totalUDAllwnce = document.getElementsByName('itrScheduleUD.amountASACYIncome')[0].value;


		if(busProfSpecAllwnceSet>0){
			if(busProfSpecAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfAllUs35Cl4Setoff')[0].value = busProfSpecAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - busProfSpecAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;
			}
		} else {
			document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var SpeculatvAllwnceSet = (coalescePath('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff'));

		if(SpeculatvAllwnceSet>0){
			if(SpeculatvAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = SpeculatvAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - SpeculatvAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}


		var SpecfiedAllwnceSet = (coalescePath('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff'));

		if(SpecfiedAllwnceSet>0){
			if(SpecfiedAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = SpecfiedAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - SpecfiedAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var profitGainUs115B=(coalescePath('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff'));
		if(profitGainUs115B>0){
			if(profitGainUs115B<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitGainUs115B;
				totalUDAllwnce = totalUDAllwnce - profitGainUs115B;

			} else {
				document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;

		}

		var hpAllwnceSet = (coalescePath('scheduleBFLA.hp.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff'));

		if(hpAllwnceSet>0){
			if(hpAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.hp.incBFLA.bfAllUs35Cl4Setoff')[0].value = hpAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - hpAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.hp.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.hp.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var othrSrcAllwnceSet = (coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff'));

		if(othrSrcAllwnceSet>0){
			if(othrSrcAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = othrSrcAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - othrSrcAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}


		var profitAllwnceSet = (coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff'));

		if(profitAllwnceSet>0){
			if(profitAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - profitAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}
		var othrSrcdtaaSet = eval(parseInt(coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA'),10)-
				parseInt(coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff'),10));
		if(othrSrcdtaaSet>0){
			if(othrSrcdtaaSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = othrSrcdtaaSet;
				totalUDAllwnce = totalUDAllwnce - othrSrcdtaaSet;

			} else {
				document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}




//		1
		var stcg30PerAllwnceSet = (coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff'));

		if(stcg30PerAllwnceSet>0){
			if(stcg30PerAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = stcg30PerAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - stcg30PerAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var stcgAppAllwnceSet = (coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff'));

		if(stcgAppAllwnceSet>0){
			if(stcgAppAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff')[0].value = stcgAppAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - stcgAppAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}
		/*var profitstcgSet = (coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')
			- coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff') -
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff'));

	if (profitstcgSet > 0) {
		if (profitstcgSet <= totalUDAllwnce) {
			document
					.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitstcgSet;
			totalUDAllwnce = totalUDAllwnce - profitstcgSet;

		} else {
			document
					.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
			totalUDAllwnce = 0;

		}
	} else {
		document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
	}

	var profitltcgSet = (coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')
			- coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff') -
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff'));

	if (profitltcgSet > 0) {
		if (profitltcgSet <= totalUDAllwnce) {
			document
					.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitltcgSet;
			totalUDAllwnce = totalUDAllwnce - profitltcgSet;

		} else {
			document
					.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
			totalUDAllwnce = 0;

		}
	} else {
		document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
	}*/

		var ltcg20PerAllwnceSet = (coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff'));

		if(ltcg20PerAllwnceSet>0){
			if(ltcg20PerAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = ltcg20PerAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - ltcg20PerAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var stcg15PerAllwnceSet = (coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff'));

		if(stcg15PerAllwnceSet>0){
			if(stcg15PerAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = stcg15PerAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - stcg15PerAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var ltcg10PerAllwnceSet = (coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
				coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
				coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff'));

		if(ltcg10PerAllwnceSet>0){
			if(ltcg10PerAllwnceSet<=totalUDAllwnce){
				document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = ltcg10PerAllwnceSet;
				totalUDAllwnce = totalUDAllwnce - ltcg10PerAllwnceSet;

			} else {
				document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var profitstcgSet = (coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')
				- coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff') -
				coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff'));

		if (profitstcgSet > 0) {
			if (profitstcgSet <= totalUDAllwnce) {
				document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitstcgSet;
				totalUDAllwnce = totalUDAllwnce - profitstcgSet;

			} else {
				document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document
			.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

		var profitltcgSet = (coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')
				- coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff') -
				coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff'));

		if (profitltcgSet > 0) {
			if (profitltcgSet <= totalUDAllwnce) {
				document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = profitltcgSet;
				totalUDAllwnce = totalUDAllwnce - profitltcgSet;

			} else {
				document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = totalUDAllwnce;
				totalUDAllwnce = 0;

			}
		} else {
			document
			.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')[0].value = 0;
		}

//		calculating the income after setOff
		document.getElementsByName('scheduleBFLA.hp.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.hp.incBFLA.bfAllUs35Cl4Setoff');

		document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff');

		document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff');

		document.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff');

		document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff');

		document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff');
		document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value =
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')-
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff')-
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')-
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff');


//		Total of brought forward loss set off
		document.getElementsByName('scheduleBFLA.totalBFLossSetOff.totBFLossSetoff')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff')+
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bFlossPrevYrUndSameHeadSetoff');


		document.getElementsByName('scheduleBFLA.totalBFLossSetOff.totUnabsorbedDeprSetoff')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfUnabsorbedDeprSetoff');

		document.getElementsByName('scheduleBFLA.totalBFLossSetOff.totAllUs35Cl4Setoff')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.bfAllUs35Cl4Setoff')+
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.bfAllUs35Cl4Setoff');


//		x :: sum
		document.getElementsByName('scheduleBFLA.incomeOfCurrYrAftCYLABFLA')[0].value =
			coalescePath('scheduleBFLA.hp.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')+
			coalescePath('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses');

		var sumUD35_4_stcg15Per = coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.stcg.stcg15Per.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_stcg30Per = coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.stcg.stcg30Per.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_stcgAppPer = coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.stcg.stcgAppRate.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_ltcg20Per = coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.ltcg.ltcg20Per.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_ltcg10Per = coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.ltcg.ltcg10Per.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_stcgDtaa = coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.stcg.stcgDTAARate.incBFLA.bfAllUs35Cl4Setoff');
		var sumUD35_4_ltcgDtaa = coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfUnabsorbedDeprSetoff')+
		coalescePath('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.bfAllUs35Cl4Setoff');
		if(sumUD35_4_stcg30Per>tempstcgBreakUp1){
			sumUD35_4_stcg30Per = sumUD35_4_stcg30Per - tempstcgBreakUp1;
			tempstcgBreakUp1 =0;
		}else{
			tempstcgBreakUp1 = zeroOrMore(tempstcgBreakUp1 - sumUD35_4_stcg30Per);
			sumUD35_4_stcg30Per=0;
		}
		if (sumUD35_4_stcg30Per > tempstcgBreakUp7) {
			sumUD35_4_stcg30Per = sumUD35_4_stcg30Per - tempstcgBreakUp7;
			tempstcgBreakUp7 = 0;
		} else {
			tempstcgBreakUp7 = zeroOrMore(tempstcgBreakUp7 - sumUD35_4_stcg30Per);
			sumUD35_4_stcg30Per = 0;
		}

		if(sumUD35_4_stcgAppPer>tempstcgBreakUp2){
			sumUD35_4_stcgAppPer = sumUD35_4_stcgAppPer - tempstcgBreakUp2;
			tempstcgBreakUp2 =0;
		}else{
			tempstcgBreakUp2 = zeroOrMore(tempstcgBreakUp2 - sumUD35_4_stcgAppPer);
			sumUD35_4_stcgAppPer=0;
		}
		if (sumUD35_4_stcgAppPer > tempstcgBreakUp8) {
			sumUD35_4_stcgAppPer = sumUD35_4_stcgAppPer - tempstcgBreakUp8;
			tempstcgBreakUp8 = 0;
		} else {
			tempstcgBreakUp8 = zeroOrMore(tempstcgBreakUp8 - sumUD35_4_stcgAppPer);
			sumUD35_4_stcgAppPer = 0;
		}


		if(sumUD35_4_ltcg20Per>templtcgBreakUp12){
			sumUD35_4_ltcg20Per = sumUD35_4_ltcg20Per - templtcgBreakUp12;
			templtcgBreakUp12 =0;
		}else{
			templtcgBreakUp12 = zeroOrMore(templtcgBreakUp12 - sumUD35_4_ltcg20Per);
			sumUD35_4_ltcg20Per=0;
		}
		if(sumUD35_4_ltcg20Per>templtcgBreakUp1){
			sumUD35_4_ltcg20Per = sumUD35_4_ltcg20Per - templtcgBreakUp1;
			templtcgBreakUp1 =0;
		}else{
			templtcgBreakUp1 = zeroOrMore(templtcgBreakUp1 - sumUD35_4_ltcg20Per);
			sumUD35_4_ltcg20Per=0;
		}


		if(sumUD35_4_stcg15Per>tempstcgBreakUp3){
			sumUD35_4_stcg15Per = sumUD35_4_stcg15Per - tempstcgBreakUp3;
			tempstcgBreakUp3 =0;
		}else{
			tempstcgBreakUp3 = zeroOrMore(tempstcgBreakUp3 - sumUD35_4_stcg15Per);
			sumUD35_4_stcg15Per=0;
		}
		if(sumUD35_4_stcg15Per>tempstcgBreakUp6){
			sumUD35_4_stcg15Per = sumUD35_4_stcg15Per - tempstcgBreakUp6;
			tempstcgBreakUp6 =0;
		}else{
			tempstcgBreakUp6 = zeroOrMore(tempstcgBreakUp6 - sumUD35_4_stcg15Per);
			sumUD35_4_stcg15Per=0;
		}


		if(sumUD35_4_stcg15Per>tempstcgBreakUp4){
			sumUD35_4_stcg15Per = sumUD35_4_stcg15Per - tempstcgBreakUp4;
			tempstcgBreakUp4 =0;
		}else{
			tempstcgBreakUp4 = zeroOrMore(tempstcgBreakUp4 - sumUD35_4_stcg15Per);
			sumUD35_4_stcg15Per=0;
		}




//		adjusting STCG first


		if(sumUD35_4_ltcg10Per>templtcgBreakUp2){
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp2;
			templtcgBreakUp2 =0;
		}else{
			templtcgBreakUp2 = zeroOrMore(templtcgBreakUp2 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per=0;
		}
		if(sumUD35_4_ltcg10Per>templtcgBreakUp3){
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp3;
			templtcgBreakUp3 =0;
		}else{
			templtcgBreakUp3 = zeroOrMore(templtcgBreakUp3 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per=0;
		}
		if(sumUD35_4_ltcg10Per>templtcgBreakUp4){
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp4;
			templtcgBreakUp4 =0;
		}else{
			templtcgBreakUp4 = zeroOrMore(templtcgBreakUp4 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per=0;
		}

		if(sumUD35_4_ltcg10Per>templtcgBreakUp5){
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp5;
			templtcgBreakUp5 =0;
		}else{
			templtcgBreakUp5 = zeroOrMore(templtcgBreakUp5 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per=0;
		}

		if (sumUD35_4_ltcg10Per > templtcgBreakUp10) {
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp10;
			templtcgBreakUp10 = 0;
		} else {
			templtcgBreakUp10 = zeroOrMore(templtcgBreakUp10 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per = 0;
		}
		if (sumUD35_4_ltcg10Per > templtcgBreakUp13) {
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp13;
			templtcgBreakUp13 = 0;
		} else {
			templtcgBreakUp13 = zeroOrMore(templtcgBreakUp13 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per = 0;
		}

		if(sumUD35_4_ltcg10Per>templtcgBreakUp6){
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp6;
			templtcgBreakUp6 =0;
		}else{
			templtcgBreakUp6 = zeroOrMore(templtcgBreakUp6 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per=0;
		}
		if (sumUD35_4_ltcg10Per > templtcgBreakUp9) {
			sumUD35_4_ltcg10Per = sumUD35_4_ltcg10Per - templtcgBreakUp9;
			templtcgBreakUp9 = 0;
		} else {
			templtcgBreakUp9 = zeroOrMore(templtcgBreakUp9 - sumUD35_4_ltcg10Per);
			sumUD35_4_ltcg10Per = 0;
		}



		if (sumUD35_4_stcgDtaa > tempstcgBreakUp5) {
			sumUD35_4_stcgDtaa = sumUD35_4_stcgDtaa - tempstcgBreakUp5;
			tempstcgBreakUp5 = 0;
		} else {
			tempstcgBreakUp5 = zeroOrMore(tempstcgBreakUp5 - sumUD35_4_stcgDtaa);
			sumUD35_4_stcgDtaa = 0;
		}

		if (sumUD35_4_ltcgDtaa > templtcgBreakUp11) {
			sumUD35_4_ltcgDtaa = sumUD35_4_ltcgDtaa - templtcgBreakUp11;
			templtcgBreakUp11 = 0;
		} else {
			templtcgBreakUp11 = zeroOrMore(templtcgBreakUp11 - sumUD35_4_ltcgDtaa);
			sumUD35_4_ltcgDtaa = 0;
		}

		cgosIncome.cgInc.stcg.prctg30.sec115AD = tempstcgBreakUp1;
		cgosIncome.cgInc.stcg.prctg30.secPti = tempstcgBreakUp7;
		cgosIncome.cgInc.stcg.prctgAr.stcgApp = tempstcgBreakUp2;
		cgosIncome.cgInc.stcg.prctgAr.secPti = tempstcgBreakUp8;
		cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii = tempstcgBreakUp3;
		cgosIncome.cgInc.stcg.prctg15.secPti = tempstcgBreakUp6;
		cgosIncome.cgInc.stcg.prctg15.sec111a = tempstcgBreakUp4;
		cgosIncome.cgInc.ltcg.prctg20.sec112 = templtcgBreakUp1;
		cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2 = templtcgBreakUp2;
		cgosIncome.cgInc.ltcg.prctg20.secPti = templtcgBreakUp12;
		cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B = templtcgBreakUp3;
		cgosIncome.cgInc.ltcg.prctg10.sec115AC_1 = templtcgBreakUp4;
		cgosIncome.cgInc.ltcg.prctg10.sec115AD_3 = templtcgBreakUp5;
		cgosIncome.cgInc.ltcg.prctg10.secProviso = templtcgBreakUp6;
		cgosIncome.cgInc.ltcg.prctg10.secPti = templtcgBreakUp13;
		cgosIncome.cgInc.ltcg.prctg10.secPti112A = templtcgBreakUp14;
		cgosIncome.cgInc.ltcg.prctg10.sec112A = templtcgBreakUp9;
		cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP = templtcgBreakUp10;


		calcCFL(specltvIncSetOff, specfdIncSetOff,bfla115B);

	}catch(e){
		alert('error in calcBFLA' + e.stack);
	}

}

function prefillBFLA(){
	try{



		document.getElementsByName('scheduleBFLA.hp.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value = coalescePath('scheduleCYLA.houseProperty.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.busProfInclSpecProf.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.profitgainsInc.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.speculativeInc.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.specifiedInc.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.stcg.stcg15Per.incCYLA.incOfCurYrAfterSetOff');//4iv of CYLA --> 3i of BFLA
		document.getElementsByName('scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.stcg.stcg30Per.incCYLA.incOfCurYrAfterSetOff');//4v of CYLA --> 4i of BFLA
		document.getElementsByName('scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.stcg.stcgAppRate.incCYLA.incOfCurYrAfterSetOff');//4Vi of CYLA --> 5i of BFLA
		document.getElementsByName('scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.ltcg.ltcg10Per.incCYLA.incOfCurYrAfterSetOff');//4Vii of CYLA --> 6i of BFLA
		document.getElementsByName('scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.ltcg.ltcg20Per.incCYLA.incOfCurYrAfterSetOff');//4Viii of CYLA --> 7i of BFLA
		document.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.othSrcInclRaceHorse.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value =  coalescePath('scheduleCYLA.profitFrmRaceHorse.incCYLA.incOfCurYrAfterSetOff');
		document.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value = coalescePath('scheduleCYLA.stcg.stcgDTAARate.incCYLA.incOfCurYrAfterSetOff');// 4Vii
		document.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value = coalescePath('scheduleCYLA.ltcg.ltcgDTAARate.incCYLA.incOfCurYrAfterSetOff');//
		document.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrUndHeadFromCYLA')[0].value = coalescePath('scheduleCYLA.otherSourceDtaa.incCYLA.incOfCurYrAfterSetOff');// 4Vii




	}catch(e){
		alert('error in prefillBFLA' + e.stack);
	}
}

function setFirstToSecondMaxMod(first,second,target){
	try{
		if(coalesce(first) > coalesceSetRet(second)){
			document.getElementsByName(target)[0].value= coalesceSetRet(second);
		}else{
			document.getElementsByName(target)[0].value= coalesce(first);
		}
	}catch(e){
		alert('error in setFirstToSecondMaxMod= '+e.stack );
	}
}

function setFirstToSecondMax(first,second,target){
	try{
		if(coalescePath(first) > coalescePath(second)){
			document.getElementsByName(target)[0].value= coalescePath(second);
		}else{
			document.getElementsByName(target)[0].value= coalescePath(first);
		}
	}catch(e){
		alert('error in setFirstToSecondMax= '+e.stack );
	}
}

function calcCFL(specltvIncSetOff, specfdIncSetOff,bfla115B){
	try {

		// setting values to 0 before populating - specu, specified, stcg , ltcg
		//document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0].value = parseInt(0,10);
		//document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value = parseInt(0,10);
		//document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].value = parseInt(0,10);
		//document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].value = parseInt(0,10);

		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.hpLossCFTotal')[0].value = zeroOrMore(document.getElementsByName('scheduleBFLA.hp.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value);

		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.busLossOthThanSpecLossCF')[0].value =
			parseInt(zeroOrMore(document.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value),10)+
			parseInt(zeroOrMore(coalescePath('scheduleBFLA.speculativeInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') - specltvIncSetOff),10)+
			parseInt(zeroOrMore(coalescePath('scheduleBFLA.specifiedInc.incBFLA.bFlossPrevYrUndSameHeadSetoff') - specfdIncSetOff),10)+
			parseInt(zeroOrMore(coalescePath('scheduleBFLA.profitgainInc.incBFLA.bFlossPrevYrUndSameHeadSetoff'),10));

		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmSpecBusCF')[0].value = specltvIncSetOff;
		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value = specfdIncSetOff;
		//2020 changes
document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmInsuCF')[0].value = bfla115B;

		document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.othSrcLossRaceHorseCF')[0].value = zeroOrMore(document.getElementsByName('scheduleBFLA.profitFrmRaceHorse.incBFLA.bFlossPrevYrUndSameHeadSetoff')[0].value);

		// scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.hpLossCFTotal
		var hpLossCFL = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0];

		setEditableFieldValue(hpLossCFL,Math
				.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff')));

		if(hpLossCFL.value > Math
				.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff')))
		{
			hpLossCFL.value = Math.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balHPlossCurYrAftSetoff'));
		}else
		{
			hpLossCFL.value=hpLossCFL.value;
		}

		var busLossOthThanSpecLossCFL = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF')[0];
		setEditableFieldValue(busLossOthThanSpecLossCFL,Math
				.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff')));

		if(busLossOthThanSpecLossCFL.value > Math
				.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff')))
		{
			busLossOthThanSpecLossCFL.value = Math.abs(coalescePath('scheduleCYLA.lossRemAftSetOff.balBusLossAftSetoff'));
		}else
		{
			busLossOthThanSpecLossCFL.value=busLossOthThanSpecLossCFL.value;
		}






		// speculative  ---- mod(B41) of schedule BP if B41 is -ve
		if(coalescePath('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus') < 0 ){
			var lossFrmSpecBusCFL = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF')[0];
			setEditableFieldValue(lossFrmSpecBusCFL,Math
					.abs(coalescePath('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus')));
			if(lossFrmSpecBusCFL.value > Math
					.abs(coalescePath('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus')))
			{
				lossFrmSpecBusCFL.value = Math.abs(coalescePath('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus'));
			}else
			{
				lossFrmSpecBusCFL.value=lossFrmSpecBusCFL.value;
			}
		}

		// specified   ---- mod(C47)  of schedule BP only if C47 is -ve
		if(coalescePath('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal') < 0){
			var lossFrmSpecifiedBusCFL = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF')[0];
			setEditableFieldValue(lossFrmSpecifiedBusCFL,Math
					.abs(coalescePath('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal')));

			if(lossFrmSpecifiedBusCFL.value > Math
					.abs(coalescePath('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal')))
			{
				lossFrmSpecifiedBusCFL.value = Math.abs(coalescePath('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal'));
			}else
			{
				lossFrmSpecifiedBusCFL.value=lossFrmSpecifiedBusCFL.value;
			}
		}

		
		//2020 changes
				if(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.Profitgains') < 0){
					var lossFrmInsuCF = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmInsuCF')[0];
					setEditableFieldValue(lossFrmInsuCF,Math
							.abs(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.Profitgains')));

					if(lossFrmInsuCF.value > Math
							.abs(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.Profitgains')))
					{
						lossFrmInsuCF.value = Math.abs(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.Profitgains'));
					}else
					{
						lossFrmInsuCF.value=lossFrmInsuCF.value;
					}
				}
		var totalSTCG = coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.stclSetoff15Per') +
		coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.stclSetoff30Per') +
		coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.stclSetoffAppRate')+
		coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.stclSetoffDtaaRate');


		var totalLTCG = coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.ltclSetOff10Per') +
		coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.ltclSetOff20Per')+
		coalescePath('scheduleCGPost45.currYrLosses.lossRemainSetOff.ltclSetOffDtaaRate');


		var stcgTotal = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0];

		setEditableFieldValue(stcgTotal, totalSTCG);

		if(stcgTotal.value > totalSTCG )
		{
			stcgTotal.value = totalSTCG;
		}else
		{
			stcgTotal.value=stcgTotal.value;
		}

		var ltcgTotal = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0];

		setEditableFieldValue(ltcgTotal, totalLTCG);

		if(ltcgTotal.value > totalLTCG )
		{
			ltcgTotal.value = totalLTCG;
		}else
		{
			ltcgTotal.value=ltcgTotal.value;
		}

		// os ----- Enter current year OS if any from 4c of Sch OS. ie. any negative figure.
		if(coalescePath('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse') < 0){
			var othSrcLossRaceHorseCFL = document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0];
			setEditableFieldValue(othSrcLossRaceHorseCFL,Math
					.abs(coalescePath('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse')));

			if(othSrcLossRaceHorseCFL.value > Math
					.abs(coalescePath('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse')))
			{
				othSrcLossRaceHorseCFL.value = Math.abs(coalescePath('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse'));
			}else
			{
				othSrcLossRaceHorseCFL.value=othSrcLossRaceHorseCFL.value;
			}
		}
		else
		{
			document.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].value=0;
		}

		var secondHp = document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0].value;
		var secondBus = document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.busLossOthThanSpecLossCF')[0].value;
		var secondSpeculatvBus = document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.lossFrmSpecBusCF')[0].value;
		var firstSpecifiedBusC = document.getElementsByName('scheduleCFL.lossCFFromPrev9ThYearFromAY.carryFwdLossDetail.lossFrmSpecifiedBusCF')[0].value;
		var second115b = document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.lossFrmInsuCF')[0].value;

		var secondShortTerm = document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0].value;
		var secondLongTerm = document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0].value;
		var secondOth = document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.othSrcLossRaceHorseCF')[0].value;
		var adjstHp = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.hpLossCFTotal')[0].value;
		var adjstBus = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.busLossOthThanSpecLossCF')[0].value;
		var adjstSpeculatvBus = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmSpecBusCF')[0].value;
		//2020 changes

		var adjst115b = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmInsuCF')[0].value;

				
		
		var adjstSpecifdBus = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value;
		var adjstShortTerm = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.stcgLossCFTotal')[0].value;
		var adjstLongTerm = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.ltcgLossCFTotal')[0].value;
		var adjstOth = document.getElementsByName('scheduleCFL.adjTotBFLossInBFLA.lossSummaryDetail.othSrcLossRaceHorseCF')[0].value;

		if(parseInt(secondHp, 10)>parseInt(adjstHp, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.hpLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.hpLossCFTotal') - secondHp +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.hpLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.hpLossCFTotal') - adjstHp +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal'));
		}

		if(parseInt(secondBus, 10)>parseInt(adjstBus, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.busLossOthThanSpecLossCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF')- secondBus  +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.busLossOthThanSpecLossCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF')- adjstBus +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF'));
		}


		if(parseInt(secondSpeculatvBus, 10) > parseInt(adjstSpeculatvBus, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecBusCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF')-secondSpeculatvBus +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecBusCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF')-adjstSpeculatvBus+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF'));
		}

		

		//2020 changes
		if(parseInt(second115b, 10) > parseInt(adjst115b, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmInsuCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmInsuCF')-second115b +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmInsuCF'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmInsuCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmInsuCF')-adjst115b+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmInsuCF'));
		}
		

		/*document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecBusCF')[0].value =
			zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF')-adjstSpeculatvBus+
			coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF'));*/


		if(parseInt(firstSpecifiedBusC, 10) > parseInt(adjstSpecifdBus, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF')-firstSpecifiedBusC +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF')-adjstSpecifdBus+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF'));
		}


		document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.lossFrmSpecifiedBusCF')[0].value =
			zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF')-adjstSpecifdBus+
					coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF'));

		if(parseInt(secondShortTerm, 10)>parseInt(adjstShortTerm, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.stcgLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal')-secondShortTerm +
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.stcgLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal')-adjstShortTerm+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal'));
		}

		if(parseInt(secondLongTerm, 10)>parseInt(adjstLongTerm, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.ltcgLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal')-secondLongTerm+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal'));
		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.ltcgLossCFTotal')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal')-adjstLongTerm+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal'));
		}


		if(parseInt(secondOth, 10)>parseInt(adjstOth, 10)){
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.othSrcLossRaceHorseCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.othSrcLossRaceHorseCF')-secondOth+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF'));

		}else{
			document.getElementsByName('scheduleCFL.totalLossCFSummary.lossSummaryDetail.othSrcLossRaceHorseCF')[0].value =
				zeroOrMore(coalescePath('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.othSrcLossRaceHorseCF')-adjstOth+
						coalescePath('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF'));

		}

	}catch(e){
		alert('error in calcCFL()= '+e.stack);
	}

}

function calcBalSheet(){
	//1
	var totResrNSurp = document.getElementsByName('partabs.fundSrc.partnerOrMemberFund.resrNSurp.totResrNSurp')[0];
	totResrNSurp.value = coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.resrNSurp.revResr') +
	coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.resrNSurp.capResr') +
	coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.resrNSurp.statResr') +
	coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.resrNSurp.othResr')+
	coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.resrNSurp.creditBalOfPLAccount');
	var totPartnerOrMemberFund = document.getElementsByName('partabs.fundSrc.partnerOrMemberFund.totPartnerOrMemberFund')[0];
	totPartnerOrMemberFund.value = parseInt(totResrNSurp.value, 10) +
	coalesceSetRet('partabs.fundSrc.partnerOrMemberFund.partnerOrMemberCap');

	//2

	var totRupeeLoan = document.getElementsByName('partabs.fundSrc.loanFunds.secrLoan.rupeeLoan.totRupeeLoan')[0];
	totRupeeLoan.value =  coalesceSetRet('partabs.fundSrc.loanFunds.secrLoan.rupeeLoan.frmBank') +
	coalesceSetRet('partabs.fundSrc.loanFunds.secrLoan.rupeeLoan.frmOthrs');
	var totSecrLoan = document.getElementsByName('partabs.fundSrc.loanFunds.secrLoan.totSecrLoan')[0];
	totSecrLoan.value =  parseInt(totRupeeLoan.value, 10) +
	coalesceSetRet('partabs.fundSrc.loanFunds.secrLoan.foreignCurrLoan');

	var totUnsecrRupeeLoan=document.getElementsByName('partabs.fundSrc.loanFunds.unsecrLoan.rupeeLoan.totRupeeLoan')[0];
	totUnsecrRupeeLoan.value=coalesceSetRet('partabs.fundSrc.loanFunds.unsecrLoan.rupeeLoan.frmBank') +
	coalesceSetRet('partabs.fundSrc.loanFunds.unsecrLoan.rupeeLoan.frmPersonSpcfdUs40A2B')+
	coalesceSetRet('partabs.fundSrc.loanFunds.unsecrLoan.rupeeLoan.frmOthrs');

	var totUnSecrLoan = document.getElementsByName('partabs.fundSrc.loanFunds.unsecrLoan.totUnSecrLoan')[0];
	totUnSecrLoan.value =parseInt(totUnsecrRupeeLoan.value, 10) +
	coalesceSetRet('partabs.fundSrc.loanFunds.unsecrLoan.foreignCurrencyLoans');

	var totLoanFund = document.getElementsByName('partabs.fundSrc.loanFunds.totLoanFund')[0];
	totLoanFund.value =  parseInt(totSecrLoan.value, 10) +
	parseInt(totUnSecrLoan.value, 10);

	//4
	var totAdvances = document.getElementsByName('partabs.fundSrc.advances.totalAdvances')[0];
	totAdvances.value =  coalesceSetRet('partabs.fundSrc.advances.frmPersonSpcfdUs40A2B') +
	coalesceSetRet('partabs.fundSrc.advances.frmOthers');

	//5

	var totFundSrc = document.getElementsByName('partabs.fundSrc.totFundSrc')[0];
	totFundSrc.value = parseInt(totPartnerOrMemberFund.value, 10) +
	parseInt(totLoanFund.value, 10) +
	coalesceSetRet('partabs.fundSrc.deferredTax')+
	parseInt(totAdvances.value, 10);


	//1
	var netBlock = document.getElementsByName('partabs.fundApply.fixedAsset.netBlock')[0];
	netBlock.value =  zeroOrMore(coalesceSetRet('partabs.fundApply.fixedAsset.grossBlock') -
			coalesceSetRet('partabs.fundApply.fixedAsset.depreciation'));

	var totFixedAsset = document.getElementsByName('partabs.fundApply.fixedAsset.totFixedAsset')[0];
	totFixedAsset.value =  parseInt(netBlock.value, 10) +
	coalesceSetRet('partabs.fundApply.fixedAsset.capWrkProg');

	//2
	var totLongTermEquityInstruments = document.getElementsByName('partabs.fundApply.investments.longTermInv.equityInstruments.total')[0];
	totLongTermEquityInstruments.value =coalesceSetRet('partabs.fundApply.investments.longTermInv.equityInstruments.listedEquities') +
	coalesceSetRet('partabs.fundApply.investments.longTermInv.equityInstruments.unListedEquities');


	var totLongTermInv = document.getElementsByName('partabs.fundApply.investments.longTermInv.totLongTermInv')[0];
	totLongTermInv.value =coalesceSetRet('partabs.fundApply.investments.longTermInv.invInProperty') +
	parseInt(totLongTermEquityInstruments.value, 10)+
	coalesceSetRet('partabs.fundApply.investments.longTermInv.preferenceShares') +
	coalesceSetRet('partabs.fundApply.investments.longTermInv.govtOrTrustSecurities')+
	coalesceSetRet('partabs.fundApply.investments.longTermInv.debenturesOrBonds')+
	coalesceSetRet('partabs.fundApply.investments.longTermInv.mutualFunds')+
	coalesceSetRet('partabs.fundApply.investments.longTermInv.others')


	var totShortTermEquities = document.getElementsByName('partabs.fundApply.investments.shortTermInv.equityInst.totalEquities')[0];
	totShortTermEquities.value =coalesceSetRet('partabs.fundApply.investments.shortTermInv.equityInst.listedEquities') +
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.equityInst.unlistedEquities');

	var totShortTermInv = document.getElementsByName('partabs.fundApply.investments.shortTermInv.totshortTermInv')[0];
	totShortTermInv.value =parseInt(totShortTermEquities.value, 10)+
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.preferenceShares') +
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.governmentOrTrustSecurities')+
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.debentureOrBonds')+
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.mutualFunds')+
	coalesceSetRet('partabs.fundApply.investments.shortTermInv.others');


	var totInvestments = document.getElementsByName('partabs.fundApply.investments.totInvestments')[0];
	totInvestments.value =  parseInt(totLongTermInv.value, 10) +
	parseInt(totShortTermInv.value, 10);


	//3
	var totInventries = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.totInventries')[0];
	totInventries.value =coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.rawMatl') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.workInProgress') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.finOrTradGood') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.stkInTrade')+
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.storesConsumables')+
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.looseTools')+
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.inventories.others');

	var totalSundryDebtors = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currAsset.sundryDebtorsDtls.totalSundryDebtors')[0];
	totalSundryDebtors.value =coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.sundryDebtorsDtls.outstandindMorethanOneYr') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.sundryDebtorsDtls.others');

	var totCashOrBankBal = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currAsset.cashOrBankBal.totCashOrBankBal')[0];
	totCashOrBankBal.value =  coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.cashOrBankBal.cashinHand') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.cashOrBankBal.bankBal') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.cashOrBankBal.others');

	var totCurrAsset = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currAsset.totCurrAsset')[0];
	totCurrAsset.value = parseInt(totInventries.value, 10) +
	parseInt(totalSundryDebtors.value, 10) +
	parseInt(totCashOrBankBal.value, 10) +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currAsset.othCurrAsset');

	var totLoanAdv = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.loanAdv.totLoanAdv')[0];
	totLoanAdv.value =  coalesceSetRet('partabs.fundApply.currAssetLoanAdv.loanAdv.advRecoverable') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.loanAdv.deposits') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.loanAdv.balWithRevAuth') ;


	var totCurrAssetLoanAdv = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.totCurrAssetLoanAdv')[0];
	totCurrAssetLoanAdv.value =  parseInt(totCurrAsset.value, 10) +
	parseInt(totLoanAdv.value, 10) ;


	var totalSundryCreditors = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.sundryCreditors.totalSundryCreditors')[0];
	totalSundryCreditors.value =  coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.sundryCreditors.outstandindMorethanOneYr') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.sundryCreditors.others') ;

	var totCurrLiabilities = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.totCurrLiabilities')[0];
	totCurrLiabilities.value =  parseInt(totalSundryCreditors.value, 10) +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.liabForLeasedAsset') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.accrIntonLeasedAsset') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.accrIntNotDue') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.incRecvdInAdv') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.currLiabilities.otherPayables');

	var totProvisions = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.provisions.totProvisions')[0];
	totProvisions.value =  coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.provisions.itProvision') +
	/*coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.provisions.wtProvision') + */
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.provisions.elSuperAnnGratProvision') +
	coalesceSetRet('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.provisions.othProvision');

	var totCurrLiabilitiesProvision = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.currLiabilitiesProv.totCurrLiabilitiesProvision')[0];
	totCurrLiabilitiesProvision.value =  parseInt(totCurrLiabilities.value, 10) +
	parseInt(totProvisions.value, 10) ;

	var netCurrAsset = document.getElementsByName('partabs.fundApply.currAssetLoanAdv.netCurrAsset')[0];
	netCurrAsset.value =  parseInt(totCurrAssetLoanAdv.value, 10) -
	parseInt(totCurrLiabilitiesProvision.value, 10) ;

	//4
	var totMiscAdjust = document.getElementsByName('partabs.fundApply.miscAdjust.totMiscAdjust')[0];
	totMiscAdjust.value =coalesceSetRet('partabs.fundApply.miscAdjust.miscExpndr') +
	coalesceSetRet('partabs.fundApply.miscAdjust.defTaxAsset') +
	coalesceSetRet('partabs.fundApply.miscAdjust.accumultedLosses');
	//5
	var totFundApply = document.getElementsByName('partabs.fundApply.totFundApply')[0];
	totFundApply.value =  	parseInt(totFixedAsset.value, 10)  +
	parseInt(totInvestments.value, 10)  +
	parseInt(netCurrAsset.value, 10) +
	parseInt(totMiscAdjust.value, 10) ;

	coalesceSetRet('partabs.noBooksOfAccBS.totSundryDbtAmt');
	coalesceSetRet('partabs.noBooksOfAccBS.totSundryCrdAmt');
	coalesceSetRet('partabs.noBooksOfAccBS.totStkInTradAmt');
	coalesceSetRet('partabs.noBooksOfAccBS.cashBalAmt');
}

function calculateSI115B(){

	var firstSchTAct155B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.firstSchTAct.115B')[0]; firstSchTAct155B.value = coalesce(firstSchTAct155B.value);
	var incUS115B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B')[0]; incUS115B.value = coalesce(incUS115B.value);
	var schSI115B = document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0]; schSI115B.value = coalesce(schSI115B.value);
	incUS115B.value=eval(parseInt(firstSchTAct155B.value,10));
	schSI115B.value=eval(parseInt(incUS115B.value,10));
}


function calcSchBP()
{
	try
	{
		calcculateAnyOtherInc();
		var profBfrTaxPL = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.profBfrTaxPL')[0]; profBfrTaxPL.value = coalesce(profBfrTaxPL.value);
		var netPLFromSpecBus = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLFromSpecBus')[0]; netPLFromSpecBus.value = coalesce(netPLFromSpecBus.value);
		var netProfLossSpecifiedBus = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netProfLossSpecifiedBus')[0]; netProfLossSpecifiedBus.value = coalesce(netProfLossSpecifiedBus.value);
		var incRecCredPLOthHeadsHp = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.houseProperty')[0]; incRecCredPLOthHeadsHp.value = coalesce(incRecCredPLOthHeadsHp.value);
		var incRecCredPLOthHeadsCg = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.capitalGains')[0]; incRecCredPLOthHeadsCg.value = coalesce(incRecCredPLOthHeadsCg.value);
		var incRecCredPLOthHeadsOs = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.othSources')[0]; incRecCredPLOthHeadsOs.value = coalesce(incRecCredPLOthHeadsOs.value);
		var incRecCredPL5BBFHeadsOs = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF')[0]; incRecCredPL5BBFHeadsOs.value = coalesce(incRecCredPL5BBFHeadsOs.value);
		var incRecCredPL5BBGHeadsOs = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG')[0]; incRecCredPL5BBGHeadsOs.value = coalesce(incRecCredPL5BBGHeadsOs.value);
		/*var plUs44SChapXIIG = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.plUs44SChapXIIG')[0]; plUs44SChapXIIG.value = coalesce(plUs44SChapXIIG.value);*/
		var incUS115B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B')[0]; incUS115B.value = coalesce(incUS115B.value);
		var incUSprfB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.Profitgains')[0]; incUSprfB.value = coalesce(incUSprfB.value);

		var incUsOther = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther')[0]; incUsOther.value = coalesce(incUsOther.value);

		var firmShareInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.firmShareInc')[0]; firmShareInc.value = coalesce(firmShareInc.value);
		var aopboiSharInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.aopboiSharInc')[0]; aopboiSharInc.value = coalesce(aopboiSharInc.value);
		var totExempInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.totExempIncPL')[0];  totExempInc.value = coalesce(totExempInc.value);
		var othExempInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.othExempInc')[0];  othExempInc.value = coalesce(othExempInc.value);

		var balancePLOthThanSpecBus = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.balancePLOthThanSpecBus')[0]; balancePLOthThanSpecBus.value = coalesce(balancePLOthThanSpecBus.value);
		var expDebToPLOthHeadsHouseProperty = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.houseProperty')[0]; expDebToPLOthHeadsHouseProperty.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.houseProperty');
		var expDebToPLOthHeadsCapitalGains = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.capitalGains')[0]; expDebToPLOthHeadsCapitalGains.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.capitalGains');
		var expDebToPLOthHeadsOthSources = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.othSources')[0]; expDebToPLOthHeadsOthSources.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.othSources');
		var expDebToPLOthHeadsUndSec115BBF = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.underSec115BBF')[0]; expDebToPLOthHeadsUndSec115BBF.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.underSec115BBF');
		var expDebToPLOthHeadsUndSec115BBG = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.underSec115BBG')[0]; expDebToPLOthHeadsUndSec115BBG.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.underSec115BBG');
		var expDebToPLExemptInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.expDebToPLExemptInc')[0];  expDebToPLExemptInc.value = coalesce(expDebToPLExemptInc.value);
		var expDebToPLExemptIncfromOI = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.expDebToPLExemptIncfromOI')[0];  expDebToPLExemptIncfromOI.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.expDebToPLExemptIncfromOI');

		var totExpDebPL = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.totExpDebPL')[0]; totExpDebPL.value = coalesce(totExpDebPL.value);
		var adjustedPLOthThanSpecBus = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.adjustedPLOthThanSpecBus')[0]; adjustedPLOthThanSpecBus.value = coalesce(adjustedPLOthThanSpecBus.value);
		var depreciationDebPLCosAct = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationDebPLCosAct')[0]; depreciationDebPLCosAct.value = coalesce(depreciationDebPLCosAct.value);

		var depreciationAllowUs321Ii = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321Ii')[0]; depreciationAllowUs321Ii.value = coalesce(depreciationAllowUs321Ii.value);
		var depreciationAllowUs321I = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0]; depreciationAllowUs321I.value = coalesce(depreciationAllowUs321I.value);
		var totDeprAllowITAct = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.totDeprAllowITAct')[0]; totDeprAllowITAct.value = coalesce(totDeprAllowITAct.value);

		var adjustPLAfterDeprOthSpecInc = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.adjustPLAfterDeprOthSpecInc')[0]; adjustPLAfterDeprOthSpecInc.value = coalesce(adjustPLAfterDeprOthSpecInc.value);
		var amtDebPLDisallowUs36 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDebPLDisallowUs36')[0]; amtDebPLDisallowUs36.value = coalesce(amtDebPLDisallowUs36.value);
		var amtDebPLDisallowUs37 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDebPLDisallowUs37')[0]; amtDebPLDisallowUs37.value = coalesce(amtDebPLDisallowUs37.value);
		var amtDebPLDisallowUs40 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDebPLDisallowUs40')[0]; amtDebPLDisallowUs40.value = coalesce(amtDebPLDisallowUs40.value);
		var amtDebPLDisallowUs40A = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDebPLDisallowUs40A')[0]; amtDebPLDisallowUs40A.value = coalesce(amtDebPLDisallowUs40A.value);
		var amtDebPLDisallowUs43B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDebPLDisallowUs43B')[0]; amtDebPLDisallowUs43B.value = coalesce(amtDebPLDisallowUs43B.value);
		var interestDisAllowUs23SMEAct = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.interestDisAllowUs23SMEAct')[0]; interestDisAllowUs23SMEAct.value = coalesce(interestDisAllowUs23SMEAct.value);
		var deemIncUs41 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs41')[0]; deemIncUs41.value = coalesce(deemIncUs41.value);
		var deemIncUs3380HHD80IA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs3380HHD80IA')[0]; deemIncUs3380HHD80IA.value = coalesce(deemIncUs3380HHD80IA.value);
		var deemIncUs43ca = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedIncomeUs43CA')[0]; deemIncUs43ca.value = coalesce(deemIncUs43ca.value);
		var othItemDisallowUs28To44DA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.othItemDisallowUs28To44DA')[0]; othItemDisallowUs28To44DA.value = coalesce(othItemDisallowUs28To44DA.value);
		var anyOthIncNotInclInExpDisallowPL = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInclInExpDisallowPL')[0];
		var incProfDecLossAccICDSAdj = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incProfDecLossAccICDSAdj')[0];  incProfDecLossAccICDSAdj.value = coalesce(incProfDecLossAccICDSAdj.value);
		var totAfterAddToPLDeprOthSpecInc =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.totAfterAddToPLDeprOthSpecInc')[0]; totAfterAddToPLDeprOthSpecInc.value = coalesce(totAfterAddToPLDeprOthSpecInc.value);
		var profDeviatDueAcctMeth = document.getElementsByName('partaoi.profDeviatDueAcctMeth')[0]; profDeviatDueAcctMeth.value = coalesce(profDeviatDueAcctMeth.value);
		var profDeviatDueAcctMethN = document.getElementsByName('partaoi.decProfDeviatDueAcctMeth')[0]; profDeviatDueAcctMethN.value = coalesce(profDeviatDueAcctMethN.value);
		var effectOnPL = document.getElementsByName('partaoi.methodOfValClgStk.effectOnPL')[0]; effectOnPL.value = coalesce(effectOnPL.value);
		var effectOnPLN = document.getElementsByName('partaoi.methodOfValClgStk.decProOrIncLossUs145_A')[0]; effectOnPLN.value = coalesce(effectOnPLN.value);
		var adjICDS = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.decProfIncLossAccICDSAdj')[0];adjICDS.value = coalesce(adjICDS.value);

		var deductUs321Iii =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deductUs321Iii')[0]; deductUs321Iii.value = coalesce(deductUs321Iii.value);
		var debPLUs35ExcessAmt = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.debPLUs35ExcessAmt')[0];  debPLUs35ExcessAmt.value = coalesce(debPLUs35ExcessAmt.value);
		var amtDisallUs40NowAllow =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDisallUs40NowAllow')[0];  amtDisallUs40NowAllow.value = coalesce(amtDisallUs40NowAllow.value);
		var amtDisallUs43BNowAllow =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.amtDisallUs43BNowAllow')[0]; amtDisallUs43BNowAllow.value = coalesce(amtDisallUs43BNowAllow.value);

		var anyOthAmtAllDeduct =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.anyOthAmtAllDeduct')[0]; anyOthAmtAllDeduct.value = coalesce(anyOthAmtAllDeduct.value);
		var decProfIncLossAccICDSAdj =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.decProfIncLossAccICDSAdj')[0]; decProfIncLossAccICDSAdj.value = coalesce(decProfIncLossAccICDSAdj.value);
		var totDeductionAmts =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.totDeductionAmts')[0]; totDeductionAmts.value = coalesce(totDeductionAmts.value);
		var plAftAdjDedBusOthThanSpec =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.plAftAdjDedBusOthThanSpec')[0]; plAftAdjDedBusOthThanSpec.value = coalesce(plAftAdjDedBusOthThanSpec.value);

		var section44AD = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0];  section44AD.value = coalesce(section44AD.value);
		var section44ADA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA')[0];  section44ADA.value = coalesce(section44ADA.value);
		var section44AE = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AE')[0];  section44AE.value = coalesce(section44AE.value);
		var section44B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44B')[0];  section44B.value = coalesce(section44B.value);
		var section44BB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44BB')[0];  section44BB.value = coalesce(section44BB.value);
		var section44BBA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44BBA')[0];  section44BBA.value = coalesce(section44BBA.value);
		var section44BBB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44BBB')[0];  section44BBB.value = coalesce(section44BBB.value);
		var section44D = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44D')[0];  section44D.value = coalesce(section44D.value);
		var section44DA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44DA')[0];  section44DA.value = coalesce(section44DA.value);
		var section44DB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44DB')[0];  section44DB.value = coalesce(section44DB.value);
		var firstSchTAct155B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.firstSchTAct.115B')[0]; firstSchTAct155B.value = coalesce(firstSchTAct155B.value);
		//var firstSchTActOther = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.firstSchTAct.other')[0]; firstSchTActOther.value = coalesce(firstSchTActOther.value);
		var totDeemedProfitBusUs = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.totDeemedProfitBusUs')[0];   totDeemedProfitBusUs.value = coalesce(totDeemedProfitBusUs.value);
		var netPLAftAdjBusOthThanSpec =  document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLAftAdjBusOthThanSpec')[0];   netPLAftAdjBusOthThanSpec.value = coalesce(netPLAftAdjBusOthThanSpec.value);
		var schSI115B = document.getElementsByName('scheduleSI.splCodeRateTax[1].splRateInc')[0]; schSI115B.value = coalesce(schSI115B.value);

		var netPLBusOthThanSpec7A7B7C = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLBusOthThanSpec7A7B7C')[0];   netPLBusOthThanSpec7A7B7C.value = coalesce(netPLBusOthThanSpec7A7B7C.value);

		var netPLFrmSpecBus = document.getElementsByName('itr5ScheduleBP.specBusinessInc.netPLFrmSpecBus')[0]; netPLFrmSpecBus.value = coalesce(netPLFrmSpecBus.value);
		var additionUs28To44DA = document.getElementsByName('itr5ScheduleBP.specBusinessInc.additionUs28To44DA')[0]; additionUs28To44DA.value = coalesce(additionUs28To44DA.value);
		var deductUs28To44DA = document.getElementsByName('itr5ScheduleBP.specBusinessInc.deductUs28To44DA')[0];  deductUs28To44DA.value = coalesce(deductUs28To44DA.value);
		var adjustedPLFrmSpecuBus = document.getElementsByName('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus')[0];  adjustedPLFrmSpecuBus.value = coalesce(adjustedPLFrmSpecuBus.value);

		var netPLFrmSpecifiedBus = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.netPLFrmSpecifiedBus')[0];  netPLFrmSpecifiedBus.value = coalesce(netPLFrmSpecifiedBus.value);
		var netPLFrmSpecInsu = document.getElementsByName('itr5ScheduleBP.compuBusinessInc.netPLFrmSpecInsu')[0];  netPLFrmSpecInsu.value = coalesce(netPLFrmSpecInsu.value);
		var netPLFrmAccord = document.getElementsByName('itr5ScheduleBP.compuBusinessInc.netPLFrmAccord')[0];  netPLFrmAccord.value = coalesce(netPLFrmAccord.value);
		var netPLFrmDeduct = document.getElementsByName('itr5ScheduleBP.compuBusinessInc.netPLFrmDeduct')[0];  netPLFrmDeduct.value = coalesce(netPLFrmDeduct.value);

		var section444AD = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44AD')[0];  section444AD.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44AD');
		var section444ADA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44ADA')[0];  section444ADA.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44ADA');
		var section444AE = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44AE')[0];  section444AE.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44AE');
		var section444B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44B')[0];  section444B.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44B');
		var section444BB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BB')[0];  section444BB.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BB');
		var section444BBA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BBA')[0];  section444BBA.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BBA');
		var section444BBB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BBB')[0];  section444BBB.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44BBB');
		var section444D = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44D')[0];  section444D.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44D');
		var section444DA = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44DA')[0];  section444DA.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44DA');
		var section444DB = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44DB')[0];  section444DB.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSec115B.section44DB');

		var section444115B = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.Profitgains115B')[0];  section444115B.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.Profitgains115B');


		var incUsOther = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther')[0];  incUsOther.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther');
		var section7 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7')[0];  section7.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7');
		var section7a = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7a')[0];  section7a.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7a');
		var section7b1 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b1')[0];  section7b1.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b1');
		var section7b2 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b2')[0];  section7b2.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b2');
		var section8 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section8')[0];  section8.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section8');


		var addSec28To44DA = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.addSec28To44DA')[0]; addSec28To44DA.value = coalesce(addSec28To44DA.value);
		var dedSec28To44DAOTDedSec35AD = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.dedSec28To44DAOTDedSec35AD')[0];  dedSec28To44DAOTDedSec35AD.value = coalesce(dedSec28To44DAOTDedSec35AD.value);
		var profitLossSpecifiedBusiness = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.profitLossSpecifiedBusiness')[0]; profitLossSpecifiedBusiness.value = coalesce(profitLossSpecifiedBusiness.value);
		var netPLFrmLifeInsu = document.getElementsByName('itr5ScheduleBP.compuBusinessInc.netPLFrmLifeInsu')[0]; netPLFrmLifeInsu.value = coalesce(netPLFrmLifeInsu.value);

		var dedSec35AD = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD')[0]; dedSec35AD.value = coalesce(dedSec35AD.value);
		var profitLossSpecifiedBusFinal = document.getElementsByName('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal')[0]; profitLossSpecifiedBusFinal.value = coalesce(profitLossSpecifiedBusFinal.value);
		var incChrgUnHdProftGain = document.getElementsByName('itr5ScheduleBP.incChrgUnHdProftGain')[0]; incChrgUnHdProftGain.value = coalesce(incChrgUnHdProftGain.value);
		var section7_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7')[0];  section7_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7');
		var section7A_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7A')[0];  section7A_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7A');
		var section7B_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B')[0];  section7B_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7B');
		var section7B1A_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B1A')[0];  section7B1A_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7B1A');
		var section8_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section8')[0];  section8_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section8');
		var sectionOther_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.sectionOther')[0];  sectionOther_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.sectionOther');
		var BalanceOfIncomeDeemed = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.BalanceOfIncomeDeemed')[0];  BalanceOfIncomeDeemed.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.BalanceOfIncomeDeemed');

		/*dedSec35AD.value = eval(
			parseInt(coalesceSetRet('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD1'),10)+
			parseInt(coalesceSetRet('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD1A'),10)
			);*/

		deemIncUs3380HHD80IA.value = eval(
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs32AC'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs32AD'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs33AB'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs33ABA'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs35ABA'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs35ABB'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs35AC'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs40A3A'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs33AC'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs72A'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs80HHD'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemIncUs80IA'),10)
		);

		netPLBusOthThanSpec7A7B7C.value = (eval(parseInt(section7_38.value,10)) + eval(parseInt(section7A_38.value,10))
				+ eval(parseInt(section7B_38.value,10)) + eval(parseInt(section7B1A_38.value,10)) + eval(parseInt(section8_38.value,10)) + eval(parseInt(sectionOther_38.value,10)));

		var tab = document.getElementById('scheduleBP1');
		var Count_SCH_BP=document.getElementsByName('Count_SCH_BP')[0]; Count_SCH_BP.value =0;

		for(var i = 0; i < tab.rows.length-3; i++) {

			Count_SCH_BP.value = eval(parseInt(Count_SCH_BP.value,10) + parseInt(coalesce(document.getElementsByName('itr5ScheduleBP.otherExempt['+i+'].totalAmount')[0].value),10));

		}
				document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.othExempInc')[0].value =Count_SCH_BP.value ;
		 		var presumptive44ADii = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive44ADii')[0];
		 presumptive44ADii.value = coalesce(presumptive44ADii.value);

		 var presumptive44ADA = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA')[0];
		 presumptive44ADA.value = coalesce(presumptive44ADA.value);

		 var grossReceipts63 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.presincome')[0];
		 grossReceipts63.value = coalesce(grossReceipts63.value);

		 var netProfit = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.netProfit')[0];
		 netProfit.value = coalesce(netProfit.value);

		 var netIncome65 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.netIncome65')[0];
		 netIncome65.value = coalesce(netIncome65.value);

		 var pbt = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.pbt')[0];
		 pbt.value = coalesce(pbt.value);


		 profBfrTaxPL.value = eval(parseInt(pbt.value,10))
		 + eval(parseInt(presumptive44ADii.value,10))
		 + eval(parseInt(presumptive44ADA.value,10))
		 + eval(parseInt(grossReceipts63.value,10))
		 + eval(parseInt(netProfit.value,10))
		 + eval(parseInt(netIncome65.value,10));

		 //+ eval(coalesceSetRet('partapl.noBooksOfAccPL.totalNetProfit'))
		 var temp2a = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLFromSpecBus')[0];
			if(temp2a.old != netIncome65.value){
				temp2a.old = netIncome65.value;
				temp2a.value = netIncome65.value;
			}
		 //netPLFromSpecBus.value = netIncome65.value;


		 //8b.
		 expDebToPLExemptIncfromOI.value = coalesce(document.getElementsByName('partaoi.priorAmtIncCrDrPL14A')[0].value);



		 //+ eval(coalesceSetRet('partapl.noBooksOfAccPL.totalNetProfit'))
		 //11. Depreciation and amoritisation debited to profit and loss account. as from 42 of part A- P&L
		 // depreciationDebPLCosAct.value = zeroOrMore(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.depreciationAmort')[0].value)) + zeroOrMore(coalesce(document.getElementsByName('partama.openingInventory.openingStockdepOffactory')[0].value));

		 if(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.depreciationAmort')[0].value=='')
		 {
			 var a= 0;
		 }
		 else
		 {
			 var a= parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.depreciationAmort')[0].value);
		 }
		 if(document.getElementsByName('partama.openingInventory.openingStockdepOffactory')[0].value=='')
		 {
			 var b= 0;
		 }
		 else
		 {
			 var b= parseInt(document.getElementsByName('partama.openingInventory.openingStockdepOffactory')[0].value);
		 }
		 depreciationDebPLCosAct.value= a + b;
		 // 12. Depreciation allowable under section 32(1)(ii) (column 6 of Schedule-DEP)
		 depreciationAllowUs321Ii.value = coalesce(document.getElementsByName('scheduleDEP.summaryFromDeprSch.totalDepreciation')[0].value);
		 // 14. Amounts debited to the profit and loss account, to the extent disallowable under section 36 (6p of Part-OI)
		 amtDebPLDisallowUs36.value = coalesce(document.getElementsByName('partaoi.amtDisallUs36.totAmtDisallUs36')[0].value);
		 // 15. Amounts debited to the profit and loss account, to the extent disallowable under section 37 (7h of Part-OI)
		 amtDebPLDisallowUs37.value = coalesce(document.getElementsByName('partaoi.amtDisallUs37.totAmtDisallUs37')[0].value);
		 // 16. Amounts debited to the profit and loss account, to the extent disallowable under section 40 (8Af of Part-OI)
		 amtDebPLDisallowUs40.value = coalesce(document.getElementsByName('partaoi.amtDisallUs40.totAmtDisallUs40')[0].value);
		 // 17. Amounts debited to the profit and loss account, to the extent disallowable under section 40A (9f of Part-OI)
		 amtDebPLDisallowUs40A.value = coalesce(document.getElementsByName('partaoi.amtDisallUs40A.totAmtDisallUs40A')[0].value);
		 // 18. Any amount debited to profit and loss account of the previous year but disallowable under section 43B (11g of Part-OI)
		 amtDebPLDisallowUs43B.value = coalesce(document.getElementsByName('partaoi.amtDisall43B.amtUs43B.totAmtUs43B')[0].value);
		 // 26. Amount of deduction under section 35 in excess of the amount debited to profit and loss account (item vii(4) of Schedule ESR)
		 debPLUs35ExcessAmt.value = coalesce(document.getElementsByName('scheduleESR.deductionUs35.totUs35.deductUs35.excessAmtOverDebPL')[0].value);
		 // 27. Any amount disallowed under section 40 in any preceding previous year but allowable during the previous year(8B of Part-OI)
		 amtDisallUs40NowAllow.value = coalesce(document.getElementsByName('partaoi.amtDisallUs40.anyAmtOfSec40AllowPrevYr')[0].value);
		 // 28. Any amount disallowed under section 43B in any preceding previous year but allowable during the previous year(10 g of Part-OI)
		 amtDisallUs43BNowAllow.value = coalesce(document.getElementsByName('partaoi.amtDisallUs43BPyNowAll.amtUs43B.totAmtUs43B')[0].value);
		 //33 new
		 adjICDS.value = eval(parseInt(profDeviatDueAcctMethN.value,10)) + eval(parseInt(effectOnPLN.value,10));
		 //25 new
		 incProfDecLossAccICDSAdj.value = eval(parseInt(profDeviatDueAcctMeth.value,10)) + eval(parseInt(effectOnPL.value,10));



		 // 34. Deduction allowable under section 32(1)(iii)
		 totDeemedProfitBusUs.value = eval(parseInt(section44AD.value,10))  + eval(parseInt(section44ADA.value,10))  + eval(parseInt(section44AE.value,10)) + eval(parseInt(section44B.value,10)) + eval(parseInt(section44BB.value,10)) + eval(parseInt(section44BBA.value,10)) + eval(parseInt(section44BBB.value,10)) + eval(parseInt(section44D.value,10)) + eval(parseInt(section44DA.value,10)) + eval(parseInt(section44DB.value,10)) + eval(parseInt(firstSchTAct155B.value,10)) /*+ eval(parseInt(firstSchTActOther.value,10))*/;

		 // 4. Profit or loss included in 1, 44AE etc Chapter-XII-G/ populates from point 33(xi)
		 incUS115B.value = eval(parseInt(section444AD.value,10)) + eval(parseInt(section444ADA.value,10))  + eval(parseInt(section444AE.value,10)) + eval(parseInt(section444B.value,10)) + eval(parseInt(section444BB.value,10)) + eval(parseInt(section444BBA.value,10)) + eval(parseInt(section44BBB.value,10)) + eval(parseInt(section44D.value,10)) +  eval(parseInt(section444DA.value,10)) + eval(parseInt(section44DB.value,10)) + eval(parseInt(firstSchTAct155B.value,10));


		 /*        incUS115B.value = eval(parseInt(totDeemedProfitBusUs.value,10));
		  */       // incUS115B.value=eval(parseInt(firstSchTAct155B.value,10));

		 incUsOther.value=eval(parseInt(totDeemedProfitBusUs.value,10))-eval(parseInt(firstSchTAct155B.value,10));
		 // 4b
		 incUsOther.value = eval(parseInt(section7.value,10)) + eval(parseInt(section7a.value,10))  + eval(parseInt(section7b1.value,10)) + eval(parseInt(section7b2.value,10)) + eval(parseInt(section8.value,10));

		 // 5. Income credited to Profit and Loss account (included in 1)which is exempt
		 totExempInc.value = eval(parseInt(firmShareInc.value ,10)) + eval(parseInt(aopboiSharInc.value ,10)) + eval(parseInt(Count_SCH_BP.value,10));
		 // 6. Balance ((1- 2a - 2b - 3a -3b - 3c - 3d - 4 - 5d))
		 balancePLOthThanSpecBus.value = eval(parseInt(profBfrTaxPL.value ,10)) - eval(parseInt(netPLFromSpecBus.value ,10)) - eval(parseInt(netProfLossSpecifiedBus.value,10)) - eval(parseInt(incRecCredPLOthHeadsHp.value,10)) - eval(parseInt(incRecCredPLOthHeadsCg.value,10)) - eval(parseInt(incRecCredPLOthHeadsOs.value,10)) - eval(parseInt(incRecCredPL5BBFHeadsOs.value,10)) - eval(parseInt(incRecCredPL5BBGHeadsOs.value,10)) - eval(parseInt(incUS115B.value,10))- eval(parseInt(incUSprfB.value,10)) - eval(parseInt(incUsOther.value,10)) - eval(parseInt(totExempInc.value,10));
		 // 9. Total (7 + 8)
		 totExpDebPL.value = eval(parseInt(expDebToPLOthHeadsHouseProperty.value,10)) + eval(parseInt(expDebToPLOthHeadsCapitalGains.value,10)) + eval(parseInt(expDebToPLOthHeadsOthSources.value,10))  + eval(parseInt(expDebToPLOthHeadsUndSec115BBF.value,10)) + eval(parseInt(expDebToPLOthHeadsUndSec115BBG.value,10))  + eval(parseInt(expDebToPLExemptInc.value,10))+ eval(parseInt(expDebToPLExemptIncfromOI.value,10)) ;
		 // 10. Adjusted profit or loss (6+9)
		 adjustedPLOthThanSpecBus.value = eval(parseInt(balancePLOthThanSpecBus.value,10)) + eval(parseInt(totExpDebPL.value,10));
		 // 12. Depreciation allowable under Income-tax Act
		 totDeprAllowITAct.value = eval(parseInt(depreciationAllowUs321Ii.value,10)) + eval(parseInt(depreciationAllowUs321I.value,10));
		 // 13. Profit or loss after adjustment for depreciation (10 +11 - 12iii)
		 adjustPLAfterDeprOthSpecInc.value = eval(parseInt(adjustedPLOthThanSpecBus.value,10)) + eval(parseInt(depreciationDebPLCosAct.value,10)) - eval(parseInt(totDeprAllowITAct.value,10));
		 //38(b)
		 BalanceOfIncomeDeemed.value =zeroOrMore(eval(parseInt(incUsOther.value,10)) - (eval(parseInt(section7_38.value,10)) + eval(parseInt(section7A_38.value,10))
				 + eval(parseInt(section7B_38.value,10)) + eval(parseInt(section7B1A_38.value,10)) + eval(parseInt(section8_38.value,10))));

		 document.getElementsByName('scheduleEI.AgriIncOrOthrIncRule7')[0].value = BalanceOfIncomeDeemed.value;

		 // 25. Total (14 + 15 + 16 + 17 + 18 + 19 + 20 + 21+22 +23+24)
		 totAfterAddToPLDeprOthSpecInc.value = eval(parseInt(amtDebPLDisallowUs36.value,10)) + eval(parseInt(deemIncUs43ca.value,10)) + eval(parseInt(amtDebPLDisallowUs37.value,10)) + eval(parseInt(amtDebPLDisallowUs40.value,10)) + eval(parseInt(amtDebPLDisallowUs40A.value,10)) + eval(parseInt(amtDebPLDisallowUs43B.value,10)) + eval(parseInt(interestDisAllowUs23SMEAct.value,10)) + eval(parseInt(deemIncUs41.value,10)) + eval(parseInt(deemIncUs3380HHD80IA.value,10)) + eval(parseInt(othItemDisallowUs28To44DA.value,10)) + eval(parseInt(anyOthIncNotInclInExpDisallowPL.value,10)) + eval(parseInt(incProfDecLossAccICDSAdj.value,10));

		 var deductAllowus32ad= parseInt(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deductAllowus32ad')[0].value);

		 deductAllowus32ad= coalesce(deductAllowus32ad);
		 // 32. Total (26 + 27+28 +29 +30c + 31)
		 totDeductionAmts.value = eval(parseInt(deductUs321Iii.value,10)) + eval(parseInt(debPLUs35ExcessAmt.value,10)) + eval(parseInt(amtDisallUs40NowAllow.value,10)) + eval(parseInt(amtDisallUs43BNowAllow.value,10)) + eval(parseInt(anyOthAmtAllDeduct.value,10)
				 +eval(deductAllowus32ad))+eval(parseInt(decProfIncLossAccICDSAdj.value,10));

		 // 33. Income (13 + 25 ? 32)
		 plAftAdjDedBusOthThanSpec.value = eval(parseInt(adjustPLAfterDeprOthSpecInc.value,10)) + eval(parseInt(totAfterAddToPLDeprOthSpecInc.value,10)) - eval(parseInt(totDeductionAmts.value,10));


		 // 35. Net profit or loss from business or profession other than speculative and specified business(33 + 34x)
		 netPLAftAdjBusOthThanSpec.value = eval(parseInt(plAftAdjDedBusOthThanSpec.value,10)) + eval(parseInt(totDeemedProfitBusUs.value,10));

		 //36.

		 section44AD.value = coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive44ADii')[0].value);
		 section44ADA.value = coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA')[0].value);
		 section44AE.value = coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.presincome')[0].value);

		 //36 populate in 4

		 section444AD.value  =  eval(parseInt(section44AD.value,10)) ;
		 section444ADA.value  =  eval(parseInt(section44ADA.value,10)) ;
		 section444AE.value  =  eval(parseInt(section44AE.value,10)) ;
		 section444B.value  =  eval(parseInt(section44B.value,10)) ;
		 section444BB.value  =  eval(parseInt(section44BB.value,10)) ;
		 section444BBA.value  =  eval(parseInt(section44BBA.value,10)) ;
		 section444DA.value  =  eval(parseInt(section44DA.value,10)) ;
		 section444BBB.value = eval(parseInt(section44BBB.value,10)) ;
		 section444D.value = eval(parseInt(section44D.value,10)) ;
		 section444DB.value = eval(parseInt(section44DB.value,10)) ;
		 section444115B.value = eval(parseInt(firstSchTAct155B.value,10)) ;





		 // 37. Net Profit or loss from business or profession other than speculative business and specified business after applying rule  7A, 7B  or 7C, if applicable (If rule 7A, 7B or 7C is not applicable, enter same figure as in 36)


		 // 38. Net profit or loss from speculative business as per profit or loss account - auto populates from field 2A of Sch BP
		 netPLFrmSpecBus.value = eval(parseInt(netPLFromSpecBus.value,10)) ;

		 sectionOther_38.value = eval(coalesce(parseInt(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLAftAdjBusOthThanSpec')[0].value)));


		 // B40. Computation of income from speculative business
		 adjustedPLFrmSpecuBus.value = eval(parseInt(netPLFrmSpecBus.value,10)) + eval(parseInt(additionUs28To44DA.value,10)) - eval(parseInt(deductUs28To44DA.value,10));
		 // 42. Net profit or loss from specified business as per profit or loss account (populates from 2B of Sch BP)
		 netPLFrmSpecifiedBus.value = eval(parseInt(netProfLossSpecifiedBus.value,10));

		 //new change
		 netPLFrmSpecInsu.value = eval(parseInt(incUSprfB.value,10));

		 // 45. Profit or loss from specified business (42+43-44)
		 profitLossSpecifiedBusiness.value = eval(parseInt(netPLFrmSpecifiedBus.value,10)) + eval(parseInt(addSec28To44DA.value,10)) - eval(parseInt(dedSec28To44DAOTDedSec35AD.value,10));
		 //E new change(E1+E2-E3)
		 netPLFrmLifeInsu.value = eval(parseInt(netPLFrmSpecInsu.value,10)) + eval(parseInt(netPLFrmAccord.value,10)) - eval(parseInt(netPLFrmDeduct.value,10));

		 // 47 Profit or loss from specified business (44-45) (enter nil if loss)
		 profitLossSpecifiedBusFinal.value = eval(parseInt(profitLossSpecifiedBusiness.value,10)) - eval(parseInt(dedSec35AD.value,10));

		 var tempPLFrmSpecuBus = adjustedPLFrmSpecuBus.value ;
		 var tempSpecifiedBusFinal = profitLossSpecifiedBusFinal.value;

		 if(parseInt(tempPLFrmSpecuBus,10) < 0){
			 tempPLFrmSpecuBus = parseInt(0,10);
		 }
		 if(parseInt(tempSpecifiedBusFinal,10) < 0){
			 tempSpecifiedBusFinal = parseInt(0,10);
		 }
		 // D. Income chargeable under the head 'Profits and gains' (A37+B41+C47)
		 incChrgUnHdProftGain.value = eval(parseInt(netPLBusOthThanSpec7A7B7C.value,10)) + eval(parseInt(tempPLFrmSpecuBus,10)) + eval(parseInt(tempSpecifiedBusFinal,10));

		 setOffSchBP();

	}catch(e){
		alert(' error in calcSchBP() =  ' + e.stack);
	}
}

function calcculateAnyOtherInc(){
	var totalOSIntGross = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInclInExpDisallowPL')[0];
	totalOSIntGross.value = eval(
			parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInc.Salary'),10)
			+ parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInc.Bonus'),10)
			+ parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInc.Interest'),10)
			+ parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInc.Others'),10)
			+ parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.anyOthIncNotInc.Commission'),10)
	);

}

function setOffSchBP() {
	try{
		prefillSchBP();
		setOffBPBusLoss();
	} catch(e){
		alert('error in setOffSchBP()=' + e.stack);
	}

}

function prefillSchBP() {
	try{
		//prefilling column :: Income from speculative business
		//Field (B40 of schedule BP)

		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus'));

		//prefilling column ::  	Income from specified business
		//Field (C46 of schedule BP)
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal'));


		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrUnderThatHead')[0].value =
			zeroOrMore(coalescePath('itr5ScheduleBP.compuBusinessInc.netPLFrmLifeInsu'));

		// populating losses Business loss set off
		//Field (A36 of schedule BP)
		coalescePath('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss');

		if(!isPostv('itr5ScheduleBP.businessIncOthThanSpec.netPLBusOthThanSpec7A7B7C')){
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss')[0].value =
				Math.abs(coalescePath('itr5ScheduleBP.businessIncOthThanSpec.netPLBusOthThanSpec7A7B7C'));
		}else{
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss')[0].value = 0;
		}

	} catch(e){
		alert('error in prefillSchBP()=' + e.stack);
	}
}

function setOffBPBusLoss() {
	try{
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.busLossSetoff')[0].value = 0;
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.busLossSetoff')[0].value = 0;
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.profitgainInc.busLossSetoff')[0].value = 0;

		/*
		Order of adjustment :-
			1) Income from speculative business
			2) Income from specified business
		 */

		var setOffRem = coalescePath('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss')-
		coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrUnderThatHead');

		// 1. Income from speculative business
		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.busLossSetoff')[0].value =
				coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrUnderThatHead');

		}else{
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.busLossSetoff')[0].value =
				coalescePath('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss');
			setOffRem =0 ;
		}

		//2. Income from specified business
		var prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrUnderThatHead');

		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.busLossSetoff')[0].value =
				coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrUnderThatHead');
		}else{
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}

		//3. Profit and gains from life insurance business u/s 115B
		var prevSetOffRem = setOffRem;
		setOffRem = parseInt(setOffRem,10) - coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrUnderThatHead');

		if(parseInt(setOffRem,10)>=0){
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.profitgainInc.busLossSetoff')[0].value =
				coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrUnderThatHead');
		}else{
			document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.profitgainInc.busLossSetoff')[0].value = prevSetOffRem;
			setOffRem =0 ;
		}


		// Income from speculative business income remaining after set off
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrAfterSetOff')[0].value=
			coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrUnderThatHead')-
			coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.busLossSetoff');

		//  	Income from specified business income remaining after set off
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrAfterSetOff')[0].value=
			coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrUnderThatHead')-
			coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.busLossSetoff');

		//  	Profit and gains from life insurance business u/s 115B
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrAfterSetOff')[0].value=
			coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrUnderThatHead')-
			coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.busLossSetoff');


		//total loss setoff
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.totLossSetOffOnBus')[0].value=
			coalescePath('itr5ScheduleBP.busSetoffCurYr.speculativeInc.busLossSetoff')+
			coalescePath('itr5ScheduleBP.busSetoffCurYr.specifiedInc.busLossSetoff')+
			coalescePath('itr5ScheduleBP.busSetoffCurYr.profitgainInc.busLossSetoff');

		//Loss remaining after set-off
		document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.lossRemainSetOffOnBus')[0].value=
			coalescePath('itr5ScheduleBP.busSetoffCurYr.lossSetOffOnBusLoss')-coalescePath('itr5ScheduleBP.busSetoffCurYr.totLossSetOffOnBus');
	} catch(e){
		alert('error in setOffBPBusLoss()=' + e.stack);
	}
}




function calcPartAOI(){
	try{
		//5f
		coalesceSetRet('partaoi.noCredToPLAmt.totNoCredToPLAmt');
		document.getElementsByName('partaoi.noCredToPLAmt.totNoCredToPLAmt')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.noCredToPLAmt.section28Items'),10)+
				parseInt(coalesceSetRet('partaoi.noCredToPLAmt.proformaCreditsDue'),10)+
				parseInt(coalesceSetRet('partaoi.noCredToPLAmt.prevYrEscalClaim'),10)+
				parseInt(coalesceSetRet('partaoi.noCredToPLAmt.othItemInc'),10)+
				parseInt(coalesceSetRet('partaoi.noCredToPLAmt.capReceipt'),10));

		//6p
		coalesceSetRet('partaoi.amtDisallUs36.totAmtDisallUs36');
		document.getElementsByName('partaoi.amtDisallUs36.totAmtDisallUs36')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.stkInsurPrem'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.empHealthInsurPrem'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.empBonusCommSum'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.intOnBorrCap'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.zeroCoupBondDisc'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.recogPFContribAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.appSuperAnnFundAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.pensionScheme80CCD'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.appGratFundAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.othFundAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.esiAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.badDebtDoubtAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.badDebtDoubtProvn'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.specResrvTranfr'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.famPlanPromoExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.securityAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUS36.securitymarket'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.expGovtApprovedSugarPrice'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.anyOthDisallowance'),10)
		);

		//6qiii
		coalesceSetRet('partaoi.amtDisallUs36.noOfEmployeesEmployed.total');
		document.getElementsByName('partaoi.amtDisallUs36.noOfEmployeesEmployed.total')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.noOfEmployeesEmployed.deployedInIndia'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs36.noOfEmployeesEmployed.deployedOutSideIndia'),10)
		);

		//7h
		coalesceSetRet('partaoi.amtDisallUs37.totAmtDisallUs37');
		document.getElementsByName('partaoi.amtDisallUs37.totAmtDisallUs37')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.capitalExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.personalExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.businessExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.politicPartyExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.lawVoilatPenalExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.othPenalFineExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.offenceExp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.contigentLiability'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs37.othAmtNotAllowUs37'),10)
		);

		//8j
		coalesceSetRet('partaoi.amtDisallUs40.totAmtDisallUs40');
		document.getElementsByName('partaoi.amtDisallUs40.totAmtDisallUs40')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.nonCompChapXVIIBAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.nonCompChapXVIIBAmt40aia'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.nonComp40aibChapXVIIBAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.nonCompChapXVIIBAmt40aiii'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.taxAmtOnProfits'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.wtAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.royaltyAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.intSalBonPartner'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40.anyOthDisallowance'),10)
		);

		//9f
		coalesceSetRet('partaoi.amtDisallUs40A.totAmtDisallUs40A');
		document.getElementsByName('partaoi.amtDisallUs40A.totAmtDisallUs40A')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs40A.amtPaidUs40A2B'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40A.amtGT20KCash'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40A.provPmtGrat'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40A.contToSetupTrust'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs40A.anyOthDisallowance'),10)
		);

		//10g
		coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.totAmtUs43B');
		document.getElementsByName('partaoi.amtDisallUs43BPyNowAll.amtUs43B.totAmtUs43B')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.taxDutyCesAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.contToEmpPFSFGF'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.empBonusComm'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.intPayaleToFI'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.intPayaleToFISchBank'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.leaveEncashPayable'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisallUs43BPyNowAll.amtUs43B.railwayAsstsPyble'),10)
		);

		//11h
		coalesceSetRet('partaoi.amtDisall43B.amtUs43B.totAmtUs43B');
		document.getElementsByName('partaoi.amtDisall43B.amtUs43B.totAmtUs43B')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.taxDutyCesAmt'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.contToEmpPFSFGF'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.empBonusComm'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.intPayaleToFI'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.intPayaleToFinComp'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.intPayaleToFISchBank'),10)+
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.railwayAsstsPyble'),10) +
				parseInt(coalesceSetRet('partaoi.amtDisall43B.amtUs43B.leaveEncashPayable'),10)
		);

		//12e
		coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.totExciseCustomsVAT');
		document.getElementsByName('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.totExciseCustomsVAT')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.unionExciseDuty'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.serviceTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.vaTorSaleTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.centralGoodServiceTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.stateGoodServiceTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.integratedGoodServiceTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.unionTerrGoodServiceTax'),10)+
				parseInt(coalesceSetRet('partaoi.amtExciseCustomsVATOutstanding.exciseCustomsVAT.othDutyTaxCess'),10)
		);

		//13
		coalesceSetRet('partaoi.deemedProfUs33ABs');
		document.getElementsByName('partaoi.deemedProfUs33ABs')[0].value = eval(
				parseInt(coalesceSetRet('partaoi.deemedProfUs33AB'),10)+
				parseInt(coalesceSetRet('partaoi.deemedProfUs33ABA'),10)+
				parseInt(coalesceSetRet('partaoi.deemedProfUs33AC'),10)
		);

	}catch(e){
		alert(e.stack);
	}
}

function calcUD(){
	try{
		var table = document.getElementById('scheduleUD');
		var rowCount = table.rows.length;
		var sumTotal=0;
		for(var i=0;i<rowCount-5;i++){
			if(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtBFUD')[0].value!='' || document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtDepCurYr')[0].value!=''
				|| document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountBFUA')[0].value!='' || document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountASACYIncome')[0].value!=''  )
			{

				document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value =
					eval(parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtBFUD')[0].value) ,10)-
							parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtDepCurYr')[0].value) ,10));

				document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balOfAllowance')[0].value =
					eval(parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountBFUA')[0].value) ,10)-
							parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountASACYIncome')[0].value) ,10));



				if(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value <0)  {
					document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value=0;

				}
				if(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balOfAllowance')[0].value <0)  {
					document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balOfAllowance')[0].value=0;

				}

			}
			else{
				document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value = '';
			}
			sumTotal = eval( parseInt(sumTotal,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value),10));

		}


		coalesceSetRet('itrScheduleUD.totalBalCFNY');
		calcTotalUD();
	}
	catch(e){
		alert(e.stack);
	}
}
function calcTotalUD(){
	try{
		var table = document.getElementById('scheduleUD');
		var rowCount = table.rows.length;
		var totalamtBFUD = 0;
		var totalamtDepCurYr = 0;
		var totalbalCFNY = 0;
		var totalamountBFUA = 0;
		var totalamountASACYIncome = 0;
		var totalbalOfAllowance = 0;
		for(var i=0;i<rowCount-5;i++){

			totalamtBFUD=eval( parseInt(totalamtBFUD,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtBFUD')[0].value),10));
			totalamtDepCurYr=eval( parseInt(totalamtDepCurYr,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtDepCurYr')[0].value),10));
			totalbalCFNY=eval( parseInt(totalbalCFNY,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balCFNY')[0].value),10));
			totalamountBFUA=eval( parseInt(totalamountBFUA,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountBFUA')[0].value),10));
			totalamountASACYIncome=eval( parseInt(totalamountASACYIncome,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountASACYIncome')[0].value),10));
			totalbalOfAllowance=eval( parseInt(totalbalOfAllowance,10) + parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].balOfAllowance')[0].value),10));

			if((document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtBFUD')[0].value)< (document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtDepCurYr')[0].value)) {
				document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0].value=0;
			}
		}

		var CurYrbalCFNY = parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD.CurYrbalCFNY')[0].value),10);
		var CurYrbalOfAllowance = parseInt(coalesce(document.getElementsByName('itrScheduleUD.scheduleUD.CurYrbalOfAllowance')[0].value),10);

		document.getElementsByName('itrScheduleUD.totalamtBFUD')[0].value =parseInt(totalamtBFUD,10);
		document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0].value =parseInt(totalamtDepCurYr,10);
		document.getElementsByName('itrScheduleUD.totalBalCFNY')[0].value =parseInt(totalbalCFNY,10)+parseInt(CurYrbalCFNY,10);
		document.getElementsByName('itrScheduleUD.totalamountBFUA')[0].value =parseInt(totalamountBFUA,10);
		document.getElementsByName('itrScheduleUD.amountASACYIncome')[0].value =parseInt(totalamountASACYIncome,10);
		document.getElementsByName('itrScheduleUD.totalbalOfAllowance')[0].value =parseInt(totalbalOfAllowance,10)+parseInt(CurYrbalOfAllowance,10);

		if(document.getElementsByName('itrScheduleUD.totalamtBFUD')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.totalamtBFUD')[0].value=0;
		}
		if(document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0].value=0;
		}
		if(document.getElementsByName('itrScheduleUD.totalBalCFNY')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.totalBalCFNY')[0].value=0;
		}

		if(document.getElementsByName('itrScheduleUD.totalamountBFUA')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.totalamountBFUA')[0].value=0;
		}
		if(document.getElementsByName('itrScheduleUD.amountASACYIncome')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.amountASACYIncome')[0].value=0;
		}
		if(document.getElementsByName('itrScheduleUD.totalbalOfAllowance')[0].value <0)  {
			document.getElementsByName('itrScheduleUD.totalbalOfAllowance')[0].value=0;
		}
	}
	catch(e){
		alert(e.stack);
	}
}

function deleteRowTableScheduleUD(tx,ty,tz){
	deleteRowTableUD(tx,ty,tz);
	calcUD();
}








function addRowToTable80(tx,ty,tz,tn){
	addRowToTable(tx,ty,tz);
	var table = document.getElementById(tx);
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-2;i++){
		var name=tn+'['+i+']';
		document.getElementsByName(name)[0].parentNode.previousSibling.previousSibling.innerHTML=
			'Undertaking No.'+eval(parseInt(i,10)+1);
	}
}

function deleteRowTableTaxDed80(tx,ty,tz,tn){
	deleteRowTable(tx,ty,tz);

	var table = document.getElementById(tx);
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-2;i++){
		var name=tn+'['+i+']';
		document.getElementsByName(name)[0].parentNode.previousSibling.previousSibling.innerHTML=
			'Undertaking No.'+eval(parseInt(i,10)+1);
	}
}

function calc10AA(){
	try{
		var table = document.getElementById('taxDed10AAId');
		var rowCount = table.rows.length;
		var sumTotal=0;
		for(var i=0;i<rowCount-4;i++){
			sumTotal = eval(parseInt(sumTotal,10) + parseInt(coalesce(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].value),10));
		}
		coalesceSetRet('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub');
		document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value  = parseInt(coalesce(sumTotal),10);
		document.getElementsByName('scheduleDI.deductionUnd10AA.TotalDedn10AAInvstmntDtls')[0].value = parseInt(coalesce(sumTotal),10);

	}catch(e){
		alert(e.stack);
	}
}


//Add Row to Schedule 10AA.
function addRowToTable10AA(tx,ty,tz){
	addRowToTable(tx,ty,tz);
	var table = document.getElementById('taxDed10AAId');
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-4;i++){
		document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].parentNode.previousSibling.previousSibling.previousSibling.previousSibling.innerHTML=
			'Undertaking No.'+eval(parseInt(i,10)+1);
	}
}

function deleteRowTableTaxDed10AAId(tx,ty,tz){
	deleteRowTable(tx,ty,tz);
	calc10AA();

	var table = document.getElementById('taxDed10AAId');
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-3;i++){
		document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].parentNode.previousSibling.previousSibling.previousSibling.previousSibling.innerHTML=
			'Undertaking No.'+eval(parseInt(i,10)+1);
	}

}


function validateUD(){
	var tab = document.getElementById('scheduleUD');
	var allInputTags = tab.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amtDepCurYr$")) {
			if(parseInt(allInputTags[i].value,10) >  parseInt(allInputTags[i-1].value,10)){
				j.setFieldError(allInputTags[i].name,'Amount of depreciation set-off against the current year income cannot be more than Amount of brought forward unabsorbed depreciation.');
				addError(allInputTags[i],'Amount of depreciation set-off against the current year income cannot be more than Amount of brought forward unabsorbed depreciation.',true);
			}
		}
		if (allInputTags[i].name.match("amountASACYIncome$")) {
			if(parseInt(allInputTags[i].value,10) >  parseInt(allInputTags[i-1].value,10)){
				j.setFieldError(allInputTags[i].name,'Amount of allowance set-off against the current year income cannot exceed amount of brought forward unabsorbed allowance.');
				addError(allInputTags[i],'Amount of allowance set-off against the current year income cannot exceed amount of brought forward unabsorbed allowance.',true);
			}
		}
	}
}
function appendzeroto5or6TCS() {
	var mainTab = document.getElementById('scheduleTCS');
	var mainTabRows = mainTab.rows.length;
	for (var i = 0; i < mainTabRows - 5; i++) {
		if (document.getElementsByName('scheduleTCS.tcs['+i+'].totalTCS')[0].value != '') {
			if(document.getElementsByName('scheduleTCS.tcs['+i+'].amountBF')[0].value>parseInt('0', 10)){
				j.setFieldError('scheduleTCS.tcs['+i+'].amountBF','Unclaimed TCS brought forward and details of TCS of current FY should be provided in different rows');
				addErrorXHTML(document.getElementsByName('scheduleTCS.tcs[' + i + '].amountBF')[0],'Unclaimed TCS brought forward and details of TCS of current FY should be provided in different rows',true);
			}
		}
	}
}
function calculateTCS(){
	var TCS = parseInt('0' ,10);
	var tcsTAB = document.getElementById('scheduleTCS');
	var allInputTags = tcsTAB.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amtTCSClaimedThisYear$")) {

			if(eval(parseInt(coalesce(allInputTags[i].value),10)) >  eval(parseInt(coalesce(allInputTags[i-1].value),10) + parseInt(coalesce(allInputTags[i-2].value),10))){

				addError(allInputTags[i],'Amount claimed cannot exceed Total Tax collected',true);
				j.setFieldError(allInputTags[i].name,'Amount claimed cannot exceed Total Tax collected');
				allInputTags[i].value = '0';

				TCS = eval(parseInt(TCS ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			}else{
				TCS = eval(parseInt(TCS ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			}
			allInputTags[i+1].value=eval(parseInt(isNVL(allInputTags[i-1].value) ,10) + parseInt(isNVL(allInputTags[i-2].value) ,10)-parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}
	document.getElementsByName('partBTTI.taxPaid.taxesPaid.tcs')[0].value = parseInt(TCS,10);
	document.getElementsByName('scheduleTCS.totalTcSSalary')[0].value = parseInt(TCS,10);
	return TCS;
}



function calculatePL()
{

	var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	if(residentialStatus == 'NRI')
	{
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia")[0].value='';
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode")[0].value='';
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib")[0].value='';
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia")[0].value='';
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm")[0].value='';

		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62")[0].value='';

		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA")[0].disabled=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA")[0].value='';
	}
	else
	{

		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia")[0].disabled=false;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode")[0].disabled=false;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib")[0].disabled=false;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia")[0].disabled=false;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62")[0].disabled=false;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA")[0].disabled=false;
	}




	/*	var tableOprtRevTableId = document.getElementById('oprtRevTableId');
	var rowCountOprtRevTableId = tableOprtRevTableId.rows.length;
	var sumTotalOprtRevTableId=0;
	for(var i=0;i<rowCountOprtRevTableId-3;i++){
		sumTotalOprtRevTableId = eval(parseInt(sumTotalOprtRevTableId,10) +
										parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.otherOperatingRevenueDtls['+i+'].operatingRevenueAmt')[0].value),10));
	}
	var totExciseCustomsVAT2 = document.getElementsByName('partapl.creditsToPL.operatingRevenueTotAmt')[0];
	totExciseCustomsVAT2.value = coalesce(totExciseCustomsVAT2.value);
	totExciseCustomsVAT2.value =parseInt(sumTotalOprtRevTableId,10) ;

	var businessReceipts = document.getElementsByName('partapl.creditsToPL.businessReceipts')[0];
	businessReceipts.value = coalesce(businessReceipts.value);
	businessReceipts.value= eval(
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.saleOfGoods')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.saleOfServices')[0].value,10))+
		parseInt(totExciseCustomsVAT2.value,10));

	var profReceipts = document.getElementsByName('partapl.creditsToPL.plGrossReceipts')[0];
	profReceipts.value = coalesce(profReceipts.value);

	var totExciseCustomsVAT = document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.totExciseCustomsVAT')[0];
	totExciseCustomsVAT.value = coalesce(totExciseCustomsVAT.value);
	totExciseCustomsVAT.value= eval(
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.unionExciseDuty')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.serviceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.vaTorSaleTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.centralGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.stateGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.integratedGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.unionTerrGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.exciseCustomsVAT.othDutyTaxCess')[0].value,10)));

	var totRevenueFrmOperations1= document.getElementsByName('partapl.creditsToPL.totRevenueFrmOperations')[0];
	totRevenueFrmOperations1.value = coalesce(totRevenueFrmOperations1.value);
	totRevenueFrmOperations1.value= eval(
		parseInt(totExciseCustomsVAT.value,10)+
		parseInt(businessReceipts.value,10) +
		parseInt(profReceipts.value,10));*/

	var tableOthIncTableId = document.getElementById('othIncTableId');
	var rowCountOthIncTableId = tableOthIncTableId.rows.length;
	var sumTotalOthIncTableId=0;
	for(var i=0;i<rowCountOthIncTableId-3;i++){
		sumTotalOthIncTableId = eval(parseInt(sumTotalOthIncTableId,10) +
				parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.otherIncDtls['+i+'].amount')[0].value),10));
	}
	var miscOthIncome = document.getElementsByName('partapl.creditsToPL.othIncome.miscOthIncome')[0];
	miscOthIncome.value = coalesce(miscOthIncome.value);
	miscOthIncome.value =parseInt(sumTotalOthIncTableId,10) ;


	var totOthIncome2 = document.getElementsByName('partapl.creditsToPL.othIncome.totOthIncome')[0];
	totOthIncome2.value = coalesce(totOthIncome2.value);
	totOthIncome2.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.rentInc')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.comissions')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.dividends')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.interestInc')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnSaleFixedAsset')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnInvChrSTT')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnOthInv')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnCurrFluct')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnConIntoCapitalAsset')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.profitOnAgriIncome')[0].value,10))+
			parseInt(miscOthIncome.value,10));

	var totalCreditsPL1314= document.getElementsByName('partapl.creditsToPL.othIncome.totalCreditsPL1314')[0];
	totalCreditsPL1314.value = coalesce(totalCreditsPL1314.value);
	totalCreditsPL1314.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.grossPLTrading')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.totOthIncome')[0].value,10)));

	/*var closingStock3= document.getElementsByName('partapl.creditsToPL.closingStockDtls.closingStock')[0];
	closingStock3.value = coalesce(closingStock3.value);
	closingStock3.value= eval(
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.closingStockDtls.rawMaterial')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.closingStockDtls.workInProgress')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.closingStockDtls.finishedGoods')[0].value,10)));

	var totCreditsToPL4= document.getElementsByName('partapl.creditsToPL.totCreditsToPL')[0];
	totCreditsToPL4.value = coalesce(totCreditsToPL4.value);
	totCreditsToPL4.value= eval(
		parseInt(totRevenueFrmOperations1.value,10)+
		parseInt(totOthIncome2.value,10)+
		parseInt(closingStock3.value,10));



	var openingStock5= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.openingStockDtls.openingStock')[0];
	openingStock5.value = coalesce(openingStock5.value);
	openingStock5.value= eval(
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.openingStockDtls.rawMaterial')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.openingStockDtls.workInProgress')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.openingStockDtls.finishedGoods')[0].value,10)));

	var totExciseCustomsVAT7= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.totExciseCustomsVAT')[0];
	totExciseCustomsVAT7.value = coalesce(totExciseCustomsVAT7.value);
	totExciseCustomsVAT7.value= eval(
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.customDuty')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.counterVailDuty')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.splAddDuty')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.unionExciseDuty')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.serviceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.vaTorSaleTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.centralGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.stateGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.integratedGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.unionTerrGoodServiceTax')[0].value,10))+
		parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.dutyTaxPay.exciseCustomsVAT.othDutyTaxCess')[0].value,10)));
	 */

	var totEmployeeComp14xi= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.totEmployeeComp')[0];
	totEmployeeComp14xi.value = coalesce(totEmployeeComp14xi.value);
	totEmployeeComp14xi.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.salsWages')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.bonus')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.medExpReimb')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.leaveEncash')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.leaveTravelBenft')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.contToSuperAnnFund')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.contToPF')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.contToGratFund')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.contToOthFund')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.employeeComp.othEmpBenftExpdr')[0].value,10)));


	var totInsurances15= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.insurances.totInsurances')[0];
	totInsurances15.value = coalesce(totInsurances15.value);
	totInsurances15.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.insurances.medInsur')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.insurances.lifeInsur')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.insurances.keyManInsur')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.insurances.othInsur')[0].value,10)));


	var total22= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.commissionExpdrDtls.total')[0];
	total22.value = coalesce(total22.value);
	total22.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.commissionExpdrDtls.nonResOtherCompany')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.commissionExpdrDtls.others')[0].value,10)));


	var total23= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.royalityDtls.total')[0];
	total23.value = coalesce(total23.value);
	total23.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.royalityDtls.nonResOtherCompany')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.royalityDtls.others')[0].value,10)));


	var total24= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.professionalConstDtls.total')[0];
	total24.value = coalesce(total24.value);
	total24.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.professionalConstDtls.nonResOtherCompany')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.professionalConstDtls.others')[0].value,10)));


	var totExciseCustomsVAT36= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.totExciseCustomsVAT')[0];
	totExciseCustomsVAT36.value = coalesce(totExciseCustomsVAT36.value);
	totExciseCustomsVAT36.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.unionExciseDuty')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.serviceTax')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.vaTorSaleTax')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.cess')[0].value,10))+

			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.csAtxCgst')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.csAtxSgst')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.csAtxIgst')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.csAtxUTgst')[0].value,10))+

			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.ratesTaxesPays.exciseCustomsVAT.othDutyTaxCess')[0].value,10)));

	var tableExpPLTableId = document.getElementById('othExpPLTableId');
	var rowCountExpPLTableId = tableExpPLTableId.rows.length;
	var sumTotalExpPLTableId=0;
	for(var i=0;i<rowCountExpPLTableId-3;i++){
		sumTotalExpPLTableId = eval(parseInt(sumTotalExpPLTableId,10) +
				parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.otherExpensesDtls['+i+'].amount')[0].value),10));
	}
	var otherExpenses38 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.otherExpenses')[0];
	otherExpenses38.value = coalesce(otherExpenses38.value);
	otherExpenses38.value =parseInt(sumTotalExpPLTableId,10) ;


	var tablebadDebtPL = document.getElementById('badDebtPL');
	var rowCountbadDebtPL = tablebadDebtPL.rows.length;
	var sumTotalbadDebtPL39=0;
	for(var i=0;i<rowCountbadDebtPL-2;i++){
		sumTotalbadDebtPL39 = eval(parseInt(sumTotalbadDebtPL39,10) +
				parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls['+i+'].amount')[0].value),10));
	}

	var tablebadDebtPLOthers = document.getElementById('badDebtPLOthers');
	var rowCountbadDebtPLOthers = tablebadDebtPLOthers.rows.length;
	var sumTotalbadDebtPLOthers39=0;
	for(var i=0;i<rowCountbadDebtPLOthers-3;i++){
		sumTotalbadDebtPLOthers39 = eval(parseInt(sumTotalbadDebtPLOthers39,10) +
				parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers['+i+'].amount')[0].value),10));
	}




	var badDebt39 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebt')[0];
	badDebt39.value = coalesce(badDebt39.value);
	badDebt39.value= eval(
			parseInt(sumTotalbadDebtPL39,10)+
			parseInt(sumTotalbadDebtPLOthers39,10)+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.othersAmtLt1Lakh')[0].value,10)));


	var pbidta42 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.pbidta')[0];
	pbidta42.value = coalesce(pbidta42.value);
	pbidta42.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.creditsToPL.othIncome.totalCreditsPL1314')[0].value,10)) -
			(

					parseInt(totEmployeeComp14xi.value,10)+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.freight')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.consumptionOfStores')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.powerFuel')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.rentExpdr')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.repairsBldg')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.repairMach')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.staffWelfareExp')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.entertainment')[0].value,10))+

					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.hospitality')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.conference')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.salePromoExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.advertisement')[0].value,10))+
					parseInt(totInsurances15.value,10)+
					parseInt(total22.value,10)+
					parseInt(total23.value,10)+
					parseInt(total24.value,10)+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.hotelBoardLodge')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.travelExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.foreignTravelExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.conveyanceExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.telephoneExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.guestHouseExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.clubExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.festivalCelebExp')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.scholarship')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.gift')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.donation')[0].value,10))+
					parseInt(totExciseCustomsVAT36.value,10)+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.auditFee')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.salRemuneration')[0].value,10))+
					parseInt(otherExpenses38.value,10)+
					parseInt(badDebt39.value,10)+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.provForBadDoubtDebt')[0].value,10))+
					parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.othProvisionsExpdr')[0].value,10))));

	var interestExpdr43 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.interestExpdrtDtls.interestExpdr')[0];
	interestExpdr43.value = coalesce(interestExpdr43.value);
	interestExpdr43.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.interestExpdrtDtls.partners')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.interestExpdrtDtls.others')[0].value,10))
			+parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.interestExpdrtDtls.paidIndia.partners')[0].value,10))
			+parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.interestExpdrtDtls.paidIndia.others')[0].value,10)));

	var pbt45 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.pbt')[0];
	pbt45.value = coalesce(pbt45.value);
	pbt45.value= eval(
			parseInt(pbidta42.value,10)-parseInt(interestExpdr43.value,10)-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.depreciationAmort')[0].value,10)));


	var profitAfterTax48 = document.getElementsByName('partapl.debitsToPL.taxProvAppr.profitAfterTax')[0];
	profitAfterTax48.value = coalesce(profitAfterTax48.value);
	profitAfterTax48.value= eval(
			parseInt(pbt45.value,10)-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.taxProvAppr.provForCurrTax')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.taxProvAppr.provDefTax')[0].value,10)));

	var amtAvlAppr50 = document.getElementsByName('partapl.debitsToPL.taxProvAppr.amtAvlAppr')[0];
	amtAvlAppr50.value = coalesce(amtAvlAppr50.value);
	amtAvlAppr50.value= eval(
			parseInt(profitAfterTax48.value,10)+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.taxProvAppr.balBFPrevYr')[0].value,10)));

	var partnerAccBalTrf52 = document.getElementsByName('partapl.debitsToPL.taxProvAppr.partnerAccBalTrf')[0];
	partnerAccBalTrf52.value = coalesce(partnerAccBalTrf52.value);
	partnerAccBalTrf52.value= eval(
			parseInt(amtAvlAppr50.value,10)-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.taxProvAppr.trfToReserves')[0].value,10)));
	var grossReceipts61 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceipts61')[0];
	grossReceipts61.value = coalesce(grossReceipts61.value);
	grossReceipts61.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode')[0].value,10)));


	var presumptive44ADii = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive44ADii')[0];
	presumptive44ADii.value = coalesce(presumptive44ADii.value);
	presumptive44ADii.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib')[0].value,10)));


	var presumtiveInc44AEReg = document.getElementById('presumtiveInc44AEReg');
	var rowCountpresumtiveInc44AEReg = presumtiveInc44AEReg.rows.length;
	var sumTotalpresumtiveInc44AEReg=0;
	var sumTotalpoint4=0;
	for(var i=0;i<rowCountpresumtiveInc44AEReg-2;i++){
		sumTotalpresumtiveInc44AEReg = eval(parseInt(sumTotalpresumtiveInc44AEReg,10) +
				parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg['+i+'].income')[0].value),10));

		sumTotalpoint4 = eval(parseInt(sumTotalpoint4,10) +
				parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg['+i+'].noOfMonths')[0].value),10));


	}


	var grossReceipts63 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.grossReceipts63')[0];
	grossReceipts63.value = coalesce(grossReceipts63.value);
	grossReceipts63.value =parseInt(sumTotalpresumtiveInc44AEReg,10) ;

	var total62Point4 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.totalOfClm4')[0];
	total62Point4.value = coalesce(total62Point4.value);
	total62Point4.value =parseInt(sumTotalpoint4,10) ;

	var total62Point5 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.totalOfClm5')[0];
	total62Point5.value = coalesce(total62Point5.value);
	total62Point5.value =parseInt(sumTotalpresumtiveInc44AEReg,10) ;

	var grossReceipts64iaBus = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ia')[0];
	grossReceipts64iaBus.value = coalesce(grossReceipts64iaBus.value);
	grossReceipts64iaBus.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.throughCheque')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.anyOtherMode')[0].value,10)));


	var netProfitBus = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.netProfit')[0];
	netProfitBus.value = coalesce(netProfitBus.value);
	netProfitBus.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ib')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.expenses')[0].value,10)));


	var grossReceipts64iaProf = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ia')[0];
	grossReceipts64iaProf.value = coalesce(grossReceipts64iaProf.value);
	grossReceipts64iaProf.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.throughCheque')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.anyOtherMode')[0].value,10)));


	var netProfitProf = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.netProfit')[0];
	netProfitProf.value = coalesce(netProfitProf.value);
	netProfitProf.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ib')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.expenses')[0].value,10)));


	var netProfit64iii = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.netProfit')[0];
	netProfit64iii.value = coalesce(netProfit64iii.value);
	netProfit64iii.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.netProfit')[0].value,10))+
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.netProfit')[0].value,10)));


	var netIncome65 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.netIncome65')[0];
	netIncome65.value = coalesce(netIncome65.value);
	netIncome65.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.grossProfit65')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.expenditure65')[0].value,10)));

	var total99= document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.presincome')[0];
	total99.value = coalesce(total99.value);
	/*if((eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.grossReceipts63')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm')[0].value,10))))>=0)
	{*/
	total99.value= eval(
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.grossReceipts63')[0].value,10))-
			parseInt(coalesce(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm')[0].value,10)));
	/*}
	else
	{
		total99.value=0;
	}
	 */


	//53d
	/*document.getElementsByName('partapl.noBooksOfAccPL.netProfit')[0].value = eval(
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.grossProfit')[0].value),10)-
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.expenses')[0].value),10));

	document.getElementsByName('partapl.noBooksOfAccPL.netProfitProf')[0].value = eval(
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.grossProfitProf')[0].value),10)-
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.expensesProf')[0].value),10));

	document.getElementsByName('partapl.noBooksOfAccPL.totalBusProf')[0].value = eval(
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.netProfit')[0].value),10) +
			parseInt(coalesce(document.getElementsByName('partapl.noBooksOfAccPL.netProfitProf')[0].value),10));*/

}

var rateCase = -1;

function calculateTaxPayableOnTotalInc(netTxblIncome, addExemption){
	rateCase = -1;
	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	var subtaxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0];
	//1-Firm,2-Local Auth,3-Co-Op-Bank,4-Co-Op-Society,5-LLP,6-AOP/BOI/AJP				2013
	//1-Firm,2-Local Auth,3-Co-Op-Bank,4-Co-Op-Society,5-LLP,7-PDT,8-AOP/BOI,9-AJP		2014
	var executorStatusCount=false;
	var statusCode = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].status')[0].value;
	if(statusCode=='EXECUTOR')
	{
		executorStatusCount=true;
	}


	if(addExemption){
		netTxblIncome = parseInt(netTxblIncome) + parseInt(getExemption());
	}

	var incTaxTemp = 0;

	if((taxPayer.value=='14' && subtaxPayer.value=='11') ||(taxPayer.value=='9' && subtaxPayer.value=='12')||(taxPayer.value=='9' && subtaxPayer.value=='19') ){

		if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('0',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('250000',10)){
			incTaxTemp = parseInt('0',10);
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('250001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('500000',10)){
			incTaxTemp = eval( eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('250000',10) )  * parseFloat('0.05')) ;
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('500001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('1000000',10)){
			incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('500000',10) )* parseFloat('0.2')) + parseInt('12500',10));
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('1000001',10)){
			incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('1000000',10) )* parseFloat('0.3')) + parseInt('112500',10));
		}

	}else if((taxPayer.value=='14' &&  subtaxPayer.value=='8')||(taxPayer.value=='14' && subtaxPayer.value=='20')||(taxPayer.value=='14' && subtaxPayer.value=='21')){
		var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
		var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
		var shares = getPercentOfShare();
		var total = shares.foreignPerc+shares.otherPerc;
		if(isSharedForeign=='NO' && shares.otherPerc<=100 && shares.otherPerc>=99.9){
			if(totIncFrmMemberOfAop=='Y'){
				rateCase = 1;
				incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));

			}else{
				rateCase = 2;
				if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('0',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('250000',10)){
					incTaxTemp = parseInt('0',10);
				}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('250001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('500000',10)){
					incTaxTemp = eval( eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('250000',10) )  * parseFloat('0.05')) ;
				}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('500001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('1000000',10)){
					incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('500000',10) )* parseFloat('0.2')) + parseInt('12500',10));
				}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('1000001',10)){
					incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('1000000',10) )* parseFloat('0.3')) + parseInt('112500',10));
				}
			}
		}else if(isSharedForeign=='NO'){
			rateCase = 3;
			incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));
		}else if(isSharedForeign=='YES' && total<=100 && total>=99.9){

			var taxForeign = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat(shares.foreignPerc==0?0:shares.foreignPerc/100) * parseFloat('0.4'));
			var taxOth = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat(shares.otherPerc==0?0:shares.otherPerc/100) * parseFloat('0.3'));
			rateCase = 4;
			incTaxTemp = Math.round(parseFloat(taxForeign) + parseFloat(taxOth));
		}else{
			rateCase = 5;
			incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.4'));
		}

	}else if(taxPayer.value=='14' && (subtaxPayer.value=='7' || subtaxPayer.value=='13')){

		var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
		var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;
		var thirdFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value;
		var fourthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].value;
		var fifthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].value;
		var sixthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].value;
		var seventhFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].value;

		var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
		var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
		var shares = getPercentOfShare();
		var total = shares.foreignPerc+shares.otherPerc;

		if( (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='Y' ) || (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='Y') || (firstFlag=='N' && secondFlag=='N' && (fourthFlag=='Y' || fifthFlag=='Y' || sixthFlag=='Y' || seventhFlag=='Y')) ||(firstFlag=='Y' && secondFlag=='N' ) ){

			if(isSharedForeign=='NO' && shares.otherPerc<=100 && shares.otherPerc>=99.9){
				if(totIncFrmMemberOfAop=='Y'){
					rateCase = 1;
					incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));

				}else{
					rateCase = 2;
					if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('0',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('250000',10)){
						incTaxTemp = parseInt('0',10);
					}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('250001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('500000',10)){
						incTaxTemp = eval( eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('250000',10) )  * parseFloat('0.05')) ;
					}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('500001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('1000000',10)){
						incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('500000',10) )* parseFloat('0.2')) + parseInt('12500',10));
					}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('1000001',10)){
						incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('1000000',10) )* parseFloat('0.3')) + parseInt('112500',10));
					}
				}
			}else if(isSharedForeign=='NO'){
				rateCase = 3;
				incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));
			}else if(isSharedForeign=='YES' && total<=100 && total>=99.9){

				var taxForeign = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat(shares.foreignPerc==0?0:shares.foreignPerc/100) * parseFloat('0.4'));
				var taxOth = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat(shares.otherPerc==0?0:shares.otherPerc/100) * parseFloat('0.3'));
				rateCase = 4;
				incTaxTemp = Math.round(parseFloat(taxForeign) + parseFloat(taxOth));
			}else{
				rateCase = 5;
				incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.4'));
			}
		}else if( (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='N' ) || (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='N') || (firstFlag=='N' && secondFlag=='N' && fourthFlag=='N' && fifthFlag=='N' && sixthFlag=='N' && seventhFlag=='N')){

			incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));

		}

	}else if(taxPayer.value=='2' || (taxPayer.value=='1' && ( subtaxPayer.value=='5' || subtaxPayer.value=='10')) || (taxPayer.value=='9' && subtaxPayer.value=='18')){
		incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));

	}else if(taxPayer.value=='14' && (subtaxPayer.value=='17' || subtaxPayer.value=='15' || subtaxPayer.value=='16' || subtaxPayer.value=='4')){
		if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('0',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('10000',10)){
			incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.1'));
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('10001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('20000',10)){
			incTaxTemp = eval( eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('10000',10) )  * parseFloat('0.2') + parseInt('1000',10)) ;
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('20001',10)){
			incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('20000',10) )* parseFloat('0.3')) + parseInt('3000',10));
		}
	}
	var sharePercentage = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].sharePercentage')[0].value;
	if(sharePercentage==100 && (taxPayer.value=='9' && subtaxPayer.value=='12') && executorStatusCount){
		if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('0',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('250000',10)){
			incTaxTemp = parseInt('0',10);
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('250001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('500000',10)){
			incTaxTemp = eval( eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('250000',10) )  * parseFloat('0.05')) ;
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('500001',10) && parseInt(rndOffNrsTen(netTxblIncome),10) <= parseInt('1000000',10)){
			incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('500000',10) )* parseFloat('0.2')) + parseInt('12500',10));
		}else if(parseInt(rndOffNrsTen(netTxblIncome),10) >= parseInt('1000001',10)){
			incTaxTemp = eval(eval(eval(parseInt(rndOffNrsTen(netTxblIncome),10) - parseInt('1000000',10) )* parseFloat('0.3')) + parseInt('112500',10));
		}
	}else if(taxPayer.value=='9' && subtaxPayer.value=='12'){
		incTaxTemp = eval(parseInt(rndOffNrsTen(netTxblIncome),10) * parseFloat('0.3'));
	}

	return incTaxTemp;
}


function showTaxRateMsg(){
	switch(rateCase)
	{
	case 1:
		addErrorXHTML('','Since none of members is Foreign Company, and since the total income of members (as selected in D of sheet Nature of Business) exceeds the maximum amount not chargeable to tax, AOP will be taxed @30%.');
		break;
	case 2:
		addErrorXHTML('',"Since none of members is Foreign Company, and since none of the member's total income  (as selected in D of sheet Nature of Business) exceeds the maximum amount not chargeable to tax, AOP will be taxed at slab rates.");
		break;
	case 4:
		addErrorXHTML('','Share of Foreign Company will be taxed @ 40% & income of other members will be taxed @ 30%');
		break;
	case 3:
		addErrorXHTML('','The share of AOP is indeterminate hence AOP will be taxed @ 30%');
		break;
	case 5:
		addErrorXHTML('','The share of AOP is indeterminate & Foreign Company is a member hence AOP will be taxed @ 40%');
		break;
	default:
		break;
	}
}

function getDueDate234A(){
	var duedate = '31/07/2020';	
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
	var scheduleIF92Eflag = false;
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("applicableToFirm$") && allInputTags[i].value=='Y') {
				scheduleIF92Eflag=true;
				break;
			}
		}
	if (auditFlag92E == 'Y' || scheduleIF92Eflag) {
		duedate = '30/11/2020';
	}else if(auditFlag=='Y'){
		duedate = "31/10/2020";
	}
	else
	{
	var tab92E=document.getElementById('othSecDateTabId');
	var allInputTags = tab92E.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("auditedSection$")) {
			//if (allInputTags[i].name.match("furOthAudReportFlg")) {
			if(allInputTags[i].value!=''){
				duedate = "31/10/2020";
				break;
			}
		}
	}

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$") ) {
			if(allInputTags[i].value!=''){
				duedate = "31/10/2020";
			}

		}
	}
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("isLiableToAudit$")) {
			if(allInputTags[i].value=='Y'){
				duedate = "31/10/2020";
				break;
			}
		}
	}
	}
	return duedate;

}
function getDueDate234AForLessthan(){
	//var duedate = '31/12/2020';	
	var duedate = '10/01/2021';	
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
	var scheduleIF92Eflag = false;
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("applicableToFirm$") && allInputTags[i].value=='Y') {
				scheduleIF92Eflag=true;
				break;
			}
		}
	if (auditFlag92E == 'Y' || scheduleIF92Eflag) {
		duedate = '15/02/2021';
	}else if(auditFlag=='Y'){
		duedate = "15/02/2021";
	}
	else
	{
	var tab92E=document.getElementById('othSecDateTabId');
	var allInputTags = tab92E.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		//if (allInputTags[i].name.match("auditedSection$")) {
			if (allInputTags[i].name.match("furOthAudReportFlg")) {
			if(allInputTags[i].value!=''){
				duedate = "15/02/2021";
				break;
			}
		}
	}

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$") ) {
			if(allInputTags[i].value!=''){
				duedate = "15/02/2021";
			}

		}
	}
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');
	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("isLiableToAudit$")) {
			if(allInputTags[i].value=='Y'){
				duedate = "15/02/2021";
				break;
			}
		}
	}
	}
	return duedate;

}
function getDueDate234AForLessthanPlus1(){
	alert('samplecheckcentering');
	//var duedate = '31/12/2020';	
	var duedate = '11/01/2021';	
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
	var scheduleIF92Eflag = false;
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("applicableToFirm$") && allInputTags[i].value=='Y') {
				scheduleIF92Eflag=true;
				break;
			}
		}
	if (auditFlag92E == 'Y' || scheduleIF92Eflag) {
		duedate = '16/02/2021';
	}else if(auditFlag=='Y'){
		duedate = "16/02/2021";
	}
	else
	{
	var tab92E=document.getElementById('othSecDateTabId');
	var allInputTags = tab92E.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		//if (allInputTags[i].name.match("auditedSection$")) {
			if (allInputTags[i].name.match("furOthAudReportFlg")) {
			if(allInputTags[i].value!=''){
				duedate = "16/02/2021";
				break;
			}
		}
	}

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$") ) {
			if(allInputTags[i].value!=''){
				duedate = "16/02/2021";
			}

		}
	}
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');
	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("isLiableToAudit$")) {
			if(allInputTags[i].value=='Y'){
				duedate = "15/02/2021";
				break;
			}
		}
	}
	}
	return duedate;

}

function getDueDate(){
	var duedate = Filing_dueDate;
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;

	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	if(auditFlag=='Y'){
		if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
			duedate = "01/01/2021";
		} else {
			duedate = "31/12/2020";
		}
	}


	var tab92E=document.getElementById('othSecDateTabId');
	var allInputTags = tab92E.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("auditedSection$")) {
			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){


					duedate = '01/01/2021';
					break;
				}
				duedate = '31/12/2020';
				break;
			}
			else if(allInputTags[i].value!='' && auditFlag != 'Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = "01/01/2021";
				} else {
					duedate = "31/12/2020";
				}
				//duedate = '30/09/2019';
			}
		}
	}

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$") ) {
			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){


					duedate = '01/01/2021';
					break;
				}
				duedate = '31/12/2020';
				break;
			}
			else if(allInputTags[i].value!='' && auditFlag != 'Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = "01/01/2021";
				} else {
					duedate = "31/12/2020";
				}
				//duedate = '30/09/2019';
			}

		}
	}
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("isLiableToAudit$")) {

			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){


					duedate = '01/01/2021';
					break;
				}

				duedate = '31/12/2020';
				break;
			}
			else if(allInputTags[i].value=='Y'){
				if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){

					duedate = "01/01/2021";

				} else {
					duedate = "31/12/2020";

				}

				//duedate = '30/09/2019';
				break;
			}
		}
	}
	return duedate;

}

//Return Due Date for 234F.
alert(1);
function getAuditFlag234F()
{
	var auditFlag234F = false;
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
	if(auditFlag92E == 'Y'){
		auditFlag234F = true;
	}else if(auditFlag == 'Y'){
		auditFlag234F = true;
	}else {
		var tab92E=document.getElementById('othSecDateTabId');
		var allInputTags = tab92E.getElementsByTagName('select');
		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("auditedSection$")) {
				if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
					auditFlag234F = true;
					break;
					}
				else if(allInputTags[i].value!='' && auditFlag != 'Y'){
					auditFlag234F = true;
					break;
				}
			}
		}
		var tab = document.getElementById('othSecDateTabId1');
		var allInputTags = tab.getElementsByTagName('select');

		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("auditReportAct$")) {
				if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
					auditFlag234F=true;
					break;
				}
				else if(allInputTags[i].value!='' && auditFlag != 'Y'){
					auditFlag234F=true;
					break;
				}

			}
		}
		var tabIf = document.getElementById('scheduleIF');
		var allInputTags = tabIf.getElementsByTagName('select');
		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("isLiableToAudit$")) {
				if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
					auditFlag234F=true;
					break;
				}
				else if(allInputTags[i].value=='Y'){
					auditFlag234F=true;
					break;
				}
			}
		}
	}
return auditFlag234F;
}

function getDueDate234F(){
	var duedate = Filing_dueDate;
	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
	var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
    	var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
    	alert('FilingDueDate' +Filing_dueDate);
	
    if(auditFlag=='Y'){
		/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
			duedate = "01/02/2021";
		} else {
			duedate = "31/01/2021";
		}*/
		duedate = "15/01/2021";
	}else if(auditFlag92E == 'Y'){
		duedate = "15/01/2021";
		alert('duedate92E' +duedate); 
	}else{
	var tab92E=document.getElementById('othSecDateTabId');
	var allInputTags = tab92E.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("auditedSection$")) {
			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = '01/02/2021';
					break;
				}
				duedate = '31/01/2021';*/
				duedate = "15/01/2021";
				break;
			}
			else if(allInputTags[i].value!='' && auditFlag != 'Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = "01/02/2021";
				} else {
					duedate = "31/01/2021";
				}*/
				//duedate = '31/10/2019';
				duedate = "15/01/2021";
			}
		}
	}

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$")) {
			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){


					duedate = '01/02/2021';
					break;
				}
				duedate = '31/01/2021';*/
				duedate = "15/01/2021";
				break;
			}
			else if(allInputTags[i].value!='' && auditFlag != 'Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = "01/02/2021";
				} else {
					duedate = "31/01/2021";
				}
				//duedate = '31/10/2019';
*/			duedate = "15/01/2021";
				}

		}
	}
	var tabIf = document.getElementById('scheduleIF');
	var allInputTags = tabIf.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("isLiableToAudit$")) {
			if(document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value=='Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){


					duedate = '01/02/2021';
					break;
				}
				duedate = '31/01/2021';*/
				duedate = "15/01/2021";
				break;
			}
			else if(allInputTags[i].value=='Y'){
				/*if(document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='14' || document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0].value=='37'){
					duedate = "01/02/2021";
				} else {
					duedate = "31/01/2021";
				}
				//duedate = '31/10/2019';
*/				duedate = "15/01/2021";
				break;
			}
		}
	}
	}

	return duedate;

}


function calcInterestPayable(cgosIncome){

	try{

		var advanceTax = document.getElementsByName('partBTTI.taxPaid.taxesPaid.advanceTax')[0].value;
		var AMT = document.getElementsByName('partBTTI.computationOfTaxLiability.creditUS115JD')[0].value;

		var TDSToDisplay = document.getElementsByName('partBTTI.taxPaid.taxesPaid.tds')[0];
		TDSToDisplay.value = coalesce(TDSToDisplay.value);
		var TDS = TDSToDisplay.value;

		var TCSToDisplay = document.getElementsByName('partBTTI.taxPaid.taxesPaid.tcs')[0];
		TCSToDisplay.value = coalesce(TCSToDisplay.value);
		var TCS = TCSToDisplay.value;

		var balTaxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.netTaxLiability')[0];
		balTaxPayable.value = coalesce(balTaxPayable.value);



		var duedate = Int_234A_Due_date_234A;


		var advanceTax234A = parseInt('0', 10);

		var tempIntrst234APrinciple = parseInt(balTaxPayable.value, 10) - parseInt(advanceTax, 10)
		- parseInt(TDS, 10) - parseInt(TCS, 10);
		var statusP = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].status')[0].value;
		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		/*var calcAge = calcAgeCommon(document
				.getElementsByName('partAGEN1.orgFirmInfo.dateOFFormOrIncorp')[0]);
		var seniorCitizen = false;
		if(parseInt(calcAge, 10) > parseInt(59, 0))
		{
			seniorCitizen = true;
		}*/
		var auditFlag92E = document.getElementsByName('partAGEN2.liableSec92Eflg')[0].value;
		var auditFlag = document.getElementsByName('partAGEN2.liableSec44ABflg')[0].value;
		var duedate;
		
		var tempSelfAssmntTax= calculateAdvancedTax234A('31/07/2020');
		if(parseInt(tempIntrst234APrinciple,10)> parseInt('100000', 10))
		{
			advanceTax234A = calculateAdvancedTax234A(getDueDate234A());
		}
		else
		{
			
			//advanceTax234A = calculateAdvancedTax234A(Int_234A_IF_NO_dt);
			advanceTax234A = calculateAdvancedTax234A(getDueDate234AForLessthan());
		}
		var intrst234Aprinciple	;

		if(parseInt(balTaxPayable.value ,10) - parseInt(advanceTax ,10) - parseInt(advanceTax234A ,10) - parseInt(TDS ,10) - parseInt(TCS ,10) < 0){
			intrst234Aprinciple = parseInt('0' ,10);
		}else {

			intrst234Aprinciple = parseInt(balTaxPayable.value ,10) - parseInt(advanceTax ,10) - parseInt(advanceTax234A ,10) - parseInt(TDS ,10) - parseInt(TCS ,10);
			// Rounding off to previous hundered
			if(parseInt(intrst234Aprinciple,10) > 100){
				intrst234Aprinciple= Math.floor(parseInt(intrst234Aprinciple,10)/100)*parseInt('100' ,10);
			}
		}
		var currentDate = document.getElementsByName('verification.date')[0].value;
		var filingType = document.getElementsByName('partAGEN1.filingStatus.secHidden')[0].value;



		if(checkFirstDateBefore(currentDate, getCurrentDate())){
			currentDate = getCurrentDate();
		}

		var actualdate = currentDate;



		var originalFilingDate = document.getElementsByName('partAGEN1.filingStatus.origRetFiledDate')[0].value;

		if((filingType=='17' || filingType=='19' || filingType=='18') && originalFilingDate !=undefined && originalFilingDate!=null && originalFilingDate!=''){
			currentDate = originalFilingDate;
		}

		if(parseInt(tempIntrst234APrinciple,10)> parseInt('100000', 10))
		{
			duedate = getDueDate234A();
			var MonthsAfterDueDate =  calcNoOfMonths(currentDate , duedate);
			MonthsAfterDueDate = MonthsAfterDueDate - 1;
		}
		else
		{
			//duedate=Int_234A_Due_date_234A;
			//duedate =getDueDate234AForLessthan();
            duedate = getDueDate234AForLessthanPlus1();

			var MonthsAfterDueDate =  calcNoOfMonths(currentDate , duedate);
			alert('Monthsafter duedate'+MonthsAfterDueDate);
			//MonthsAfterDueDate = MonthsAfterDueDate-1;
			MonthsAfterDueDate = MonthsAfterDueDate;//duedate is middle of month else uncomment above line
			
		}

		var intrst234A = zeroOrMore(eval(parseInt(intrst234Aprinciple,10) * parseFloat('0.01') * parseInt(MonthsAfterDueDate))) ;


		var intrst234B = parseInt('0' ,10);
		var	intrst234C = parseInt('0' ,10);
		var	intrst234F = parseInt('0' ,10);

		var slab0 = parseInt('0' ,10);
		var slab1 = parseInt('0' ,10);
		var slab2 = parseInt('0' ,10);
		var slab3 = parseInt('0' ,10);
		var slab4 = parseInt('0' ,10);

		var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];

		var tab4 = document.getElementById('scheduleIt');
		var allInputTags = tab4.getElementsByTagName('input');
		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("dateDep$")) {

				if(checkFirstDateBefore(FY_start_date , allInputTags[i].value) && checkFirstDateBefore( allInputTags[i].value , slab0_end_date ) ){
					slab0 = eval(parseInt(slab0 ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
				}
				if(checkFirstDateBefore(slab1_start_date , allInputTags[i].value) && checkFirstDateBefore( allInputTags[i].value , slab1_end_date ) ){
					slab1 = eval(parseInt(slab1 ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
				}
				if(checkFirstDateBefore(slab2_start_date , allInputTags[i].value) && checkFirstDateBefore( allInputTags[i].value , slab2_end_date ) ){
					slab2 = eval(parseInt(slab2 ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
				}
				else if(checkFirstDateBefore(slab3_start_date , allInputTags[i].value) && checkFirstDateBefore( allInputTags[i].value , slab3_end_date ) ){
					slab3 = eval(parseInt(slab3 ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
				}
				else if(checkFirstDateBefore(slab4_start_date , allInputTags[i].value) && checkFirstDateBefore( allInputTags[i].value , FY_end_date ) ){
					slab4 = eval(parseInt(slab4 ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
				}
			}
		}

		//Calculate tax on CG
		var intrstRates = [0.1040, 0.2080, 0.1560, 0.3120];

		var totalUpto15Of6 = 0;

		var totalUpto15Of9 = 0;

		var totalUp16Of9To15Of12 = 0;

		var totalUp16Of12To15Of3 = 0;

		var totalUp16Of3To31Of3 = 0;


		intrst234C = calculate234cIntrst(TDS, TCS, [slab0, slab1, slab2, slab3, slab4], cgosIncome,AMT);


		// ===============Interest234F calculation=======================
		setSecRespOnSave();
		var filingType = document.getElementsByName('partAGEN1.filingStatus.secHidden')[0].value;

		var originalFilingDate = document.getElementsByName('partAGEN1.filingStatus.origRetFiledDate')[0].value;
		if((filingType=='17' || filingType=='19' || filingType=='18') && originalFilingDate !=undefined && originalFilingDate!=null && originalFilingDate!=''){
			currentDate = originalFilingDate;
		}

		var intrst234F = parseInt('0',10);
		var filerType=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;


		if (filingType=='11' || filingType=='12' || filingType=='17' ||filingType=='18' || filingType=='13'){

			var totInc = document.getElementsByName('partBTI.totalIncome')[0].value;
			var grossInc = getAmt('partBTI.grossTotalIncome');

			var gtiInc =grossInc/* + getAmt('scheduleEI.ltcgWhereSTTPaid')*/;

			//var currentDate234F = Int_start_date_234A; //01/08/2019
			var status=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
			/*
     				var dueDate234A = getDueDate234F();

     			    if(dueDate234A == '31/10/2019'){
     			    	currentDate234F = '01/11/2019';

     				 }else if(dueDate234A == '30/11/2019'){
     					currentDate234F = '01/12/2019';

     				}else if(dueDate234A == '31/03/2020'){

         			    	currentDate234F = '01/04/2020';

     				 }

			 */
			var currentDate234F = getDueDate234F();
			var auditFlag234F = getAuditFlag234F();
			
			var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
			var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
			var shares = getPercentOfShare();
			var total = parseInt(shares.foreignPerc,10)+parseInt(shares.otherPerc,10);
			var executorStatusCount=false;
			var statusCode = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].status')[0].value;
				if(statusCode=='EXECUTOR')
				{
					executorStatusCount=true;
				}


			var subfiler=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
			var pershare = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].sharePercentage')[0].value;
			if((isSharedForeign=='NO' && totIncFrmMemberOfAop == 'N' && total == 100 && filerType=='14' && (subfiler=='8' || subfiler=='20' || subfiler=='21'))){

				if(parseInt(gtiInc,10)> eval('250000')){

					if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){


						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '5000';
						}
					}
					else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else{
						intrst234F= parseInt('0',10);
					}
				}
				else{

					intrst234F= parseInt('0',10);
				}

			}
			else {
				if(!(subfiler=='11'||filerType=='9')){
					if(parseInt(gtiInc,10) > eval('0')){
						if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '5000';
							}
						}
						else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								alert('flag1');
								intrst234F= '10000';
							}
						}
						else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								alert('flag2');
								intrst234F= '10000';
							}
						}
						else{
							intrst234F= parseInt('0',10);
						}
					}
				}
			}



			if(filerType=='14'&&(subfiler=='17'|| subfiler=='15'|| subfiler=='16'|| subfiler=='4'|| subfiler=='12' || subfiler=='7' || subfiler=='13')){
				if(subfiler=='7' || subfiler=='13'){

					var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
					var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
					var shares = getPercentOfShare();
					var total = parseInt(shares.foreignPerc,10)+parseInt(shares.otherPerc,10);

					var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
					var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;
					var thirdFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value;
					var fourthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].value;
					var fifthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].value;
					var sixthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].value;
					var seventhFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].value;
					if( (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='Y' ) || (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='Y') || (firstFlag=='N' && secondFlag=='N' && (fourthFlag=='Y' || fifthFlag=='Y' || sixthFlag=='Y' || seventhFlag=='Y'))||(firstFlag=='Y' && secondFlag=='N') ){
						if(isSharedForeign=='NO' && totIncFrmMemberOfAop == 'N' && total == 100){
							if(parseInt(gtiInc,10)> eval('250000')){
								if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										intrst234F= '5000';
									}
								}
								else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										alert('flag3');
										intrst234F= '10000';
									}
								}
								else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										intrst234F= '10000';
									}
								}
								else{
									intrst234F= parseInt('0',10);
								}
							}
							else{
								intrst234F= parseInt('0',10);
							}

						}
						else{
							if(parseInt(gtiInc,10)> eval('0')){
								if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										intrst234F= '5000';
									}
								}
								else if(audtiFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										intrst234F= '10000';
									}
								}
								else if(audtiFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
									if(parseInt(totInc,10)<= eval('500000')){
										intrst234F= '1000';
									}
									else if(parseInt(totInc,10)> eval('500000')){
										intrst234F= '10000';
									}
								}
								else{
									intrst234F= parseInt('0',10);
								}
							}
						}
					}

				}
				else{

					if(parseInt(gtiInc,10)> eval('0')){
						if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '5000';
							}
						}
						else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '10000';
							}
						}
						else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';
							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '10000';
							}
						}

						else{
							intrst234F= parseInt('0',10);
						}
					}
				}

			}
			if(filerType=='14'&&gtiInc>250000){

				if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						intrst234F= '5000';
					}
				}
				else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						intrst234F= '10000';
					}
				}
				else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						intrst234F= '10000';
					}
				}
				else{
					intrst234F= parseInt('0',10);
				}
			}
			if((filerType=='9'&& subfiler=='18')){

				if(parseInt(gtiInc,10)> eval('0')){
					if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '5000';
						}
					}
					else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
						alert('Int3');
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
						alert('Int2');
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else{
						intrst234F= parseInt('0',10);
					}
				}
			}
			var sharePercentage = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].sharePercentage')[0].value;
			var executorStatusCount=false;
			var statusCode = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].status')[0].value;
				if(statusCode=='EXECUTOR')
				{
					executorStatusCount=true;
				}
			if(sharePercentage==100 && executorStatusCount && (filerType=='9'&& subfiler=='12')){

				if(parseInt(gtiInc,10)> eval('250000')){
					if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '5000';
						}
					}
					else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){
						if(parseInt(totInc,10)<= eval('500000')){
							intrst234F= '1000';
						}
						else if(parseInt(totInc,10)> eval('500000')){
							intrst234F= '10000';
						}
					}
					else{
						intrst234F= parseInt('0',10);
					}
				}
				else{
					intrst234F= parseInt('0',10);
				}
			}/*else if(parseInt(gtiInc,10)> eval('0')){
  				
		  					if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){
		  						
		    				if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';

							}
					    else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '5000';
							}
		  					}
						else if(auditFlag234F && checkFirstDateBefore('01/02/2021', currentDate)){
							
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';

							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '10000';
							}
						}
                         else if(auditFlag234F == false && checkFirstDateBefore('01/01/2021', currentDate)){
							
							if(parseInt(totInc,10)<= eval('500000')){
								intrst234F= '1000';

							}
							else if(parseInt(totInc,10)> eval('500000')){
								intrst234F= '10000';
							}
						}
		  					
						else{
							intrst234F= parseInt('0',10);
						}
		  			}*/

			if((filerType=='9'||subfiler=='11')&&gtiInc>250000){
				if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						intrst234F= '5000';
					}
				}
				else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						alert('flag5');
						intrst234F= '10000';
					}
				}
				else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						alert('flag7');
						intrst234F= '10000';
					}
				}
				else{
					intrst234F= parseInt('0',10);
				}
			}
			else{
				if(filerType!='2'){
					if(filerType!='9'){

						if(!(filerType=='14'&&(subfiler=='17'|| subfiler=='15'|| subfiler=='16'|| subfiler=='4' ||subfiler=='11' || 
								subfiler=='8' || subfiler=='7'  || subfiler=='12' || subfiler=='13'|| subfiler=='20'|| subfiler=='21'))){

							if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){

								if(parseInt(totInc,10)<= eval('500000')){
									intrst234F= '1000';
								}
								else if(parseInt(totInc,10)> eval('500000')){
									intrst234F= '5000';
								}
							}
							else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){

								if(parseInt(totInc,10)<= eval('500000')){
									intrst234F= '1000';
								}
								else if(parseInt(totInc,10)> eval('500000')){
									//intrst234F= '10000';
									alert('flag7');
									intrst234F= '10000';
								}
							}
							else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){

								if(parseInt(totInc,10)<= eval('500000')){
									intrst234F= '1000';
								}
								else if(parseInt(totInc,10)> eval('500000')){
									//intrst234F= '10000';
									alert('flag8');
									intrst234F= '10000';
								}
							}
							else{
								intrst234F= parseInt('0',10);
							}
						}
					}
				}
			}
			var prevFlag = document.getElementsByName('partBTTI.assetOutIndiaFlag')[0].value;
			var cflLoss = document.getElementsByName('partBTI.lossesOfCurrentYearCarriedFwd')[0].value;
			if(prevFlag=='YES'||parseInt(cflLoss,10)>eval('0')){

				if(checkFirstDateBefore(currentDate234F , currentDate) && checkFirstDateBefore( currentDate , '31/12/2020' )){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						intrst234F= '5000';
					}
				}

				else if(auditFlag234F && checkFirstDateBefore('16/02/2021', currentDate)){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						alert('flag9');
						intrst234F= '10000';
					}
				}
				else if(auditFlag234F == false && checkFirstDateBefore('11/01/2021', currentDate)){

					if(parseInt(totInc,10)<= eval('500000')){
						intrst234F= '1000';
					}
					else if(parseInt(totInc,10)> eval('500000')){
						alert('flag99');
						intrst234F= '10000';
					}
				}
				else{
					intrst234F= parseInt('0',10);
				}

			}

			/*var fileType=document.getElementsByName('partAGEN1.filingStatus.returnType')[0].value;
  			if(fileType=='T'){
  				document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234F')[0].readOnly=false;
  			}
  			if(fileType!='T'){
  				document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234F')[0].readOnly=true;
  			}*/
		}

		// ===============Interest234B calculation=======================
		var presInc44AD = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0];
		var dtaa = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0].value;
		var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

		var winLottRacePuzz = parseInt(coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount'));
		var rebateOnAgriInc = parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture'), 10);


		var totalCG = 	  parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg30.sec115AD, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctgAr.stcgApp, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg15.sec111a, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.sec112, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.sec11EA, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.secProviso, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115AC_1, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115AD_3, 10)))
		+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115E_b, 10)));

		var normalBalIncome = eval(
				parseInt(coalesceSetRet('partBTI.grossTotalIncome'))
				- totalCG
				- parseInt(coalesceSetRet('partBTI.totalDeductionsUnderScheduleVIA'))
				- parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'))
				- parseInt(coalesceSetRet('partBTI.invstUnder23FBor23FBA'))
				- parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'))
				- parseInt(winLottRacePuzz)
		);

		if(parseInt(rebateOnAgriInc, 10) > parseInt('0', 10)){
			normalBalIncome = eval(parseInt(normalBalIncome, 10)
					+ parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'), 10));
		}

		var surchrge1 = parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge'));
		var totalInc = parseInt(coalesceSetRet('partBTI.totalIncome'));

		presInc44AD = parseInt(coalesce(presInc44AD.value),10);

		if(presInc44AD > 0 && ((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

				(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0)) && taxPayer=='1'){


			surcharge= surchrge1;

			var sumSIWithDtaa = calculatePureSITax()- parseInt(coalesce(dtaa),10);
			var totSplRateIncTax = 0;
			var pureSIIncFor234B = totSplRateIncTax - parseInt(sumSIWithDtaa);
		}

		//	balTaxPayable=balTaxPayable.value;

		var intrst234Bprinciple;
		var intrst234Bi=parseInt('0',10);
		var earliestSelfAsspaidDate=parseInt('0',10);
		var noOfMonthsTillSelfasst= parseInt('0',10);


		if(parseInt(balTaxPayable.value,10) - parseInt(TDS,10) - parseInt(TCS ,10) >= parseInt('10000' ,10)) {
			if(parseInt(advanceTax,10) < ((parseInt(balTaxPayable.value,10) - parseInt(TDS,10) - parseInt(TCS ,10)) * parseFloat('0.90'))) {
				intrst234Bprinciple = (parseInt(balTaxPayable.value ,10) - parseInt(advanceTax ,10) - parseInt(TDS,10) - parseInt(TCS ,10));

				// Rounding off to previous hundered
				if(parseInt(intrst234Bprinciple,10) > 100){
					intrst234Bprinciple= Math.floor(parseInt(intrst234Bprinciple,10)/100)*parseInt('100' ,10);

				}

				//======== Interest 234B first part calc==========

				var selfAsspaidDates=new Array();
				var selfAsspaidAmts=new Array();
				var x=parseInt('0',10);
				var tempDate=parseInt('0',10);
				var tempAmt=parseInt('0',10);


				currentDate = actualdate;

				// to get all self assesment tax values
				for(var p = 0; p < allInputTags.length; p++) {
					if(allInputTags[p].name.match("dateDep$")){
						if( checkFirstDateBefore(AY_start_date , allInputTags[p].value) && checkFirstDateBefore(allInputTags[p].value, currentDate) ){
							if(allInputTags[p+2].value!=0){
								selfAsspaidDates[x]=allInputTags[p].value;
								selfAsspaidAmts[x]=allInputTags[p+2].value;
								x++;
							}
						}
					}
				}

				// to sort all self assesment tax values according to date

				if(selfAsspaidDates.length > 1){
					for(var q = 0; q < selfAsspaidDates.length-1; q++) {
						for(var r = q+1; r < selfAsspaidDates.length; r++) {
							if(checkFirstDateBefore(selfAsspaidDates[q], selfAsspaidDates[r])){

							}else{
								tempDate=selfAsspaidDates[q];
								tempAmt=selfAsspaidAmts[q];

								selfAsspaidDates[q]=selfAsspaidDates[r];
								selfAsspaidAmts[q]=selfAsspaidAmts[r];

								selfAsspaidDates[r]=tempDate;
								selfAsspaidAmts[r]=tempAmt;
							}
						}
					}
					var arrLen = selfAsspaidDates.length;
					var lastMonth = 0;
					var lastIndex = -1;
					var lastYear =0;
					for(var q = 0; q < arrLen; q++) {
						if(parseInt(selfAsspaidDates[q].substr(3,2), 10) == lastMonth && parseInt(selfAsspaidDates[q].substr(8,2), 10) == lastYear){
							selfAsspaidAmts[lastIndex] = parseInt(selfAsspaidAmts[lastIndex], 10) + parseInt(selfAsspaidAmts[q], 10);
						}else{
							lastMonth = parseInt(selfAsspaidDates[q].substr(3,2), 10);
							lastYear = parseInt(selfAsspaidDates[q].substr(8,2), 10);
							selfAsspaidAmts[++lastIndex] = selfAsspaidAmts[q];
							selfAsspaidDates[lastIndex] = selfAsspaidDates[q];
						}
					}
					selfAsspaidAmts.length = ++lastIndex;
					selfAsspaidDates.length = lastIndex;
				}

				if(selfAsspaidDates.length==0){
					noOfMonthsTillSelfasst=calcNoOfMonths(currentDate,AY_start_date);
				}else{
					noOfMonthsTillSelfasst=calcNoOfMonths(selfAsspaidDates[0],AY_start_date);
				}

				/*				intrst234Bi= parseInt(intrst234Bprinciple,10) * parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst) ;
				 */
				if(selfAsspaidDates.length!=0 && checkFirstDateBefore(selfAsspaidDates[0], '30/06/2020'))
				{
					intrst234Bi = parseInt(intrst234Bprinciple, 10)
					* parseFloat('0.0075')
					* parseInt(noOfMonthsTillSelfasst);
				}
				else
				{
					intrst234Bi = parseInt(intrst234Bprinciple, 10)
					* parseFloat('0.01')
					* parseInt(noOfMonthsTillSelfasst);
				}


				//======== Interest 234B second part calc==========
				var intrst234Bprinciple2=parseInt('0',10);  // intrst234Bprinciple if self assesment is paid
				var selfAsspart=parseInt('0',10);
				var noOfMonthsTillSelfasst2;
				var intrst234Bii=parseInt('0',10);
				var partialSelfAssPaid=parseInt('0',10);
				var k=parseInt('0',10);
				var interestFrom;
				var interestTill;

				if(selfAsspaidDates.length!=0){

					for(var i = 0; i < selfAsspaidDates.length; i++) {
						partialSelfAssPaid= eval(parseInt(partialSelfAssPaid ,10) +parseInt(selfAsspaidAmts[i] ,10));

						intrst234Bprinciple2=zeroOrMore(eval(parseInt(balTaxPayable.value ,10) - parseInt(advanceTax ,10) - parseInt(TDS,10) - parseInt(TCS ,10)+
								parseInt(intrst234A ,10)+parseInt(intrst234C ,10)+parseInt(intrst234Bi ,10)+parseInt(intrst234Bii ,10)+parseInt(intrst234F ,10)
								-parseInt(partialSelfAssPaid,10)));

						// Rounding off to previous hundered
						if(parseInt(intrst234Bprinciple2,10) > parseInt('100' ,10)){
							intrst234Bprinciple2= Math.floor(parseInt(intrst234Bprinciple2,10)/100)*parseInt('100' ,10);

						}

						//calclulating remaining months to levy interest
						var intrst234bflag=false;
						if(checkFirstDateBefore(AY_start_date,selfAsspaidDates[i])
								&& checkFirstDateBefore(selfAsspaidDates[i], '30/06/2020'))
						{
							intrst234bflag=true;
						}

						interestTill=currentDate;
						interestFrom=selfAsspaidDates[i];

						if(i != eval(selfAsspaidDates.length-parseInt('1' ,10))){

							for(k=i;k < eval(selfAsspaidDates.length-parseInt('1' ,10)); k++){
								if(selfAsspaidDates[k]!=selfAsspaidDates[k+1]){
									interestTill=selfAsspaidDates[k+1];
									interestFrom=selfAsspaidDates[k];
									k=selfAsspaidDates.length;
								}
							}
						}

						noOfMonthsTillSelfasst2=calcNoOfMonths(interestTill,interestFrom)-parseInt('1' ,10) ;
						var temp = interestTill;

						/*if(parseInt(intrst234Bprinciple2,10) < parseInt(intrst234Bprinciple,10)){
							intrst234Bprinciple = intrst234Bprinciple2;
							intrst234Bii= eval(parseInt(intrst234Bii,10) +
									(parseInt(intrst234Bprinciple2,10) * parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2))) ;
						}else{
							intrst234Bii= eval(parseInt(intrst234Bii,10) +
									(parseInt(intrst234Bprinciple,10) * parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2))) ;
						}*/

						var interFlag=false;
						if(checkFirstDateBefore(interestFrom, '30/06/2020') && checkFirstDateBefore('30/06/2020',interestTill))
						{

							interFlag=true;
							interestTill='30/06/2020';
							noOfMonthsTillSelfasst2 = calcNoOfMonths(interestTill, interestFrom) - parseInt('1', 10);
							if (parseInt(intrst234Bprinciple2, 10) < parseInt(intrst234Bprinciple, 10)) {
								intrst234Bprinciple = intrst234Bprinciple2;
								if(intrst234bflag)
								{
									intrst234Bii = eval(parseInt(intrst234Bii, 10) + (parseInt(intrst234Bprinciple2, 10) * parseFloat('0.0075') * parseInt(noOfMonthsTillSelfasst2)));
								}
								else
								{
									intrst234Bii = eval(parseInt(intrst234Bii, 10) + (parseInt(intrst234Bprinciple2, 10) * parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2)));
								}
							} else {
								if(intrst234bflag)
								{
									intrst234Bii = eval(parseInt(intrst234Bii, 10) + (parseInt(intrst234Bprinciple, 10) * parseFloat('0.0075') * parseInt(noOfMonthsTillSelfasst2)));
								}
								else
								{
									intrst234Bii = eval(parseInt(intrst234Bii, 10) + (parseInt(intrst234Bprinciple, 10) * parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2)));
								}
							}
							interestFrom='01/07/2020';
							interestTill =temp;
							noOfMonthsTillSelfasst2 = calcNoOfMonths(interestTill, interestFrom);

						}
						if (parseInt(intrst234Bprinciple2, 10) < parseInt(
								intrst234Bprinciple, 10)) {
							intrst234Bprinciple = intrst234Bprinciple2;
							if(intrst234bflag && !interFlag)
							{
								intrst234Bii = eval(parseInt(intrst234Bii, 10)
										+ (parseInt(intrst234Bprinciple2, 10)
												* parseFloat('0.0075') * parseInt(noOfMonthsTillSelfasst2)));
							}
							else
							{
								intrst234Bii = eval(parseInt(intrst234Bii, 10)
										+ (parseInt(intrst234Bprinciple2, 10)
												* parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2)));
							}
						} else {
							if(intrst234bflag && !interFlag)
							{
								intrst234Bii = eval(parseInt(intrst234Bii, 10)
										+ (parseInt(intrst234Bprinciple, 10)
												* parseFloat('0.0075') * parseInt(noOfMonthsTillSelfasst2)));
							}
							else
							{
								intrst234Bii = eval(parseInt(intrst234Bii, 10)
										+ (parseInt(intrst234Bprinciple, 10)
												* parseFloat('0.01') * parseInt(noOfMonthsTillSelfasst2)));
							}
						}

					}
				}
				intrst234B=eval(parseInt(intrst234Bi,10) +parseInt(intrst234Bii,10));
			}
		}else{
			intrst234B = parseInt('0' ,10);
		}

		intrst234A = parseInt(intrst234A ,10);
		intrst234B = parseInt(intrst234B ,10);
		intrst234C = parseInt(intrst234C ,10);
		intrst234F = parseInt(intrst234F ,10);

		var intrstPayUs234A = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234A')[0];
		if(intrstPayUs234A.old != intrst234A){
			intrstPayUs234A.old = intrst234A;
			intrstPayUs234A.value = intrst234A;
		}

		var intrstPayUs234B = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234B')[0];
		if(intrstPayUs234B.old != intrst234B){
			intrstPayUs234B.old =	intrst234B;
			intrstPayUs234B.value =	intrst234B;
		}

		var intrstPayUs234C = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234C')[0];
		if(intrstPayUs234C.old != intrst234C){
			intrstPayUs234C.old =	intrst234C;
			intrstPayUs234C.value =	intrst234C;
		}

		var intrstPayUs234F = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.intrstPayUs234F')[0];
		if(intrstPayUs234F.old != intrst234F){
			intrstPayUs234F.old =	intrst234F;
			intrstPayUs234F.value =	intrst234F;
		}

		var intrstPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.totalIntrstPay')[0]; intrstPayable.value = coalesce(intrstPayable.value);
		intrstPayable.value = Math.round(eval(parseInt(intrstPayUs234A.value ,10) + parseInt(intrstPayUs234B.value ,10) + parseInt(intrstPayUs234C.value ,10) + parseInt(intrstPayUs234F.value ,10)));

		var balTaxPay = document.getElementsByName('partBTTI.computationOfTaxLiability.netTaxLiability')[0]; balTaxPay.value = coalesce(balTaxPay.value);
		var totIntrstPay = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.totalIntrstPay')[0]; totIntrstPay.value = coalesce(totIntrstPay.value);
		var totTaxIntrstPay = document.getElementsByName('partBTTI.computationOfTaxLiability.aggregateTaxInterestLiability')[0]; totTaxIntrstPay.value = coalesce(totTaxIntrstPay.value);

		totTaxIntrstPay.value = eval(balTaxPay.value) + eval(totIntrstPay.value);


	}catch(e){
		alert('Exception in calcInterestPayable() = ' + e.stack);
	}
}

function calculate234cIntrst(TDS, TCS, slabs, cgosIncome,AMT){
	try{
		var slab0 = parseInt(slabs[0] ,10);
		var slab1 = parseInt(slabs[1] ,10);
		var slab2 = parseInt(slabs[2] ,10);
		var slab3 = parseInt(slabs[3] ,10);
		var slab4 = parseInt(slabs[4] ,10);

		var winLottRacePuzz = parseInt(coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount'));
		var rebateOnAgriInc = parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture'), 10);
		var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

		var totalCG =
			parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg30.sec115AD, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg30.secPti, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctgAr.stcgApp, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctgAr.secPti, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg15.sec111a, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg15.sec115ad_1_b_ii, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctg15.secPti, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.sec112, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.secPti, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.sec11EA, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.secProviso, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115AC_1, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115ACA_1, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115_AB_1_B, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115AD_3, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.secPti, 10)))
			+ parseInt(zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP, 10)))
			+ parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg10.sec115E_b, 10)))
			+ parseInt(zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg10.sec112A, 10)))
			+ parseInt(zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg10.secPti112A, 10)));

		var sumSchBpOth = eval(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')+
				coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
				coalesceSetRet('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
				coalesceSetRet('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrAfterSetOffBFLosses'));

		var normalBalIncome = eval(
				parseInt(coalesceSetRet('partBTI.grossTotalIncome'))
				- totalCG- parseInt(coalesceSetRet('partBTI.incFromOS.incChargeSplRate')) - parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF')) - parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG'))
				- parseInt(coalesceSetRet('partBTI.capGain.shortTerm.shortTermChargableDtaa'))  - parseInt(coalesceSetRet('partBTI.capGain.longTerm.longTermDtaa')) - parseInt(coalesceSetRet('partBTI.totalDeductionsUnderScheduleVIA'))
				- parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'))-parseInt(coalesceSetRet('partBTI.invstUnder23FBor23FBA'))-parseInt(coalesceSetRet('partBTI.invstUnder23FCor23FCA'))-parseInt(coalesce(sumSchBpOth)));


		if(parseInt(rebateOnAgriInc, 10) > parseInt('0', 10)){
			normalBalIncome = eval(parseInt(normalBalIncome, 10)
					+ parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'), 10));
		}

		var normalBalIncIncl44Ad = normalBalIncome;
		var sec44AD = parseInt(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0].value, 10);
		var sec44ADA = parseInt(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA')[0].value, 10);

		/*var dtaan11b = parseInt(coalesce(document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0].value));*/

		var dtaan11b = 0;

		var siexmption = getLTCG20ExmpFrmSI();
		var exemption10Pct = eval(siexmption["10"]);
		var exemption15Pct = eval(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[3].splRateInc')) - parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[3].taxableInc')));
		var exemption20Pct = eval(siexmption["20"]);
		var exemption30Pct = eval(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[7].splRateInc')) - parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[7].taxableInc')));
		var exemptionOth111A = parseInt(getExemption()) -  eval(
				parseInt(exemption10Pct)
				+ parseInt(exemption15Pct)
				+ parseInt(exemption20Pct)
				+ parseInt(exemption30Pct)
		);
		//Calculate tax on CG
		var intrstRates = [0.1, 0.2, 0.15,0.3];
		var appRateSurcharge = 1;

		var totalIncome = coalesceSetRet('partBTI.totalIncome');

		var marginal = isMarginalRelfApplcbl();

		var totalUpto15Of6 = 0;
		var totalUpto15Of9 = 0;
		var totalUp16Of9To15Of12 = 0;
		var totalUp16Of12To15Of3 = 0;
		var totalUp16Of3To31Of3 = 0;
		var avaTdsTcs =0;
		var taxOnWinLottRacePuzz = 0;

		var balTaxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.netTaxLiability')[0];
		var netTaxLiability = balTaxPayable.value;

		var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		var othExemptions = 0;

		var siTax=0;
		var marginal1 = isMarginalRelfApplcblCheck();

		if(parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.totalTax'))!=
			parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.grossTaxPayable'))){

			siTax = parseInt(coalesceSetRet('scheduleSI.totSplRateIncTax')) - calculatePureSITax()-parseInt(coalesce(dtaan11b),10);


			var SISurcharge = 0;
			var totalInc = parseInt(document.getElementsByName('partBTI.totalIncome')[0].value);

			var remove115BBE = eval(parseInt(
					coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
					10));

			var totalInc = parseInt(document.getElementsByName('partBTI.totalIncome')[0].value) - remove115BBE;


			var SurchargeUnderSec = 0; //both sec44AD & sec44ADA surcharge
			var TaxpayableUnderSec = 0; // both sec44AD & sec44ADA taxpayable
			var taxpayableIncSec44 = 0;
			var secIncome = 0;

			if (sec44AD>0 && sec44ADA>0){
				secIncome = sec44AD + sec44ADA;
			}
			else if (sec44AD>0 && sec44ADA<=0){
				secIncome = sec44AD;
			}
			else if (sec44AD<=0 && sec44ADA>0){
				secIncome = sec44ADA;
			}
			else{
				secIncome=0;
			}


			if(secIncome > 0 &&((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

					(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0)) && taxPayer=='1'){

				taxpayableIncSec44=calculateTaxPayableOnTotalInc(normalBalIncome+parseInt(( parseInt(cgosIncome.cgInc.stcg.prctgAr, 10))))+parseInt(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].value);
				TaxpayableUnderSec=calculateTaxPayableOnTotalInc(normalBalIncome+parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctgAr, 10)))-secIncome+parseInt(coalesce(sumSchBpOth)))+parseInt(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].value)-(remove115BBE*0.6)-rebateOnAgriInc;

				SurchargeUnderSec=(parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F'))*((totalInc-secIncome)/totalInc));


				var TaxpayableOnTotalInc=calculateTaxPayableOnTotalInc(normalBalIncome+parseInt(zeroOrMore( parseInt(cgosIncome.cgInc.stcg.prctgAr, 10))))+parseInt(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].value)-rebateOnAgriInc;
				var taxad = calculateTaxPayableOnTotalInc(parseInt(coalesce(sumSchBpOth)));
				var TaxPayableOnly44AD=eval(parseInt(taxad)+parseInt(TaxpayableOnTotalInc)-parseInt(TaxpayableUnderSec)- (remove115BBE*0.6));

				var SurchargeOnly44AD=(parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F'))-SurchargeUnderSec);

			}else{
				SurchargeUnderSec=document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].value;
				TaxpayableUnderSec=eval(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0].value - (remove115BBE*0.6));
				taxpayableIncSec44=document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0].value;
				TaxPayableOnly44AD=0;

			}

			if(parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F'))>0){

				if(marginal1 ||(secIncome>0 && ((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

						(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0))) && taxPayer=='1'){


					SISurcharge= parseInt((parseInt(SurchargeUnderSec)*(coalesce((siTax-(remove115BBE*0.6))/TaxpayableUnderSec))),10);

				}else {

					if( statusCompany == "1" || statusCompany == "2" || substatusCompany == "17" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4"){

						SISurcharge=(siTax -(remove115BBE*0.6)) *0.12;
					}else
					{
						SISurcharge=(siTax -(remove115BBE*0.6)) *0.15;
					}


				}
			}

			siTax= (siTax-(remove115BBE*0.6));


			siTax = (siTax+SISurcharge) * 1.04;




			taxOnWinLottRacePuzz = parseInt(winLottRacePuzz) *  intrstRates[3];

			if(secIncome>0 &&((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

					(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0)) && taxPayer=='1'){

				//normalBalIncome = zeroOrMore(normalBalIncome - secIncome);

			}else if(secIncome>0){

				secIncome = 0;
			}


			//App Rate
			if(parseInt(normalBalIncome) > parseInt(exemptionOth111A)){
				normalBalIncome = parseInt(normalBalIncome) - parseInt(exemptionOth111A);
				exemptionOth111A = 0;
			}else if(parseInt(normalBalIncome, 0) > 0){
				exemptionOth111A = parseInt(exemptionOth111A) - parseInt(normalBalIncome);
				normalBalIncome = 0;
			}

			var dateOfCommenceMent = document.getElementsByName('partAGEN1.orgFirmInfo.dateOFFormOrCommenc')[0].value;

			var dateOfComAmount0 = 0;

			var dateOfComAmount1 = 0;

			var dateOfComAmount2 = 0;

			var dateOfComAmount3 = 0;

			var dateOfComAmount4 = 0;

			var incOfCurYrAfterSetOffBFLosses = Math.min(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses'),parseInt(secIncome));

			var schBp44AD = eval(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')-parseInt(incOfCurYrAfterSetOffBFLosses));

			var sumSchBpOthIncome = eval(schBp44AD+
					coalesceSetRet('scheduleBFLA.speculativeInc.incBFLA.incOfCurYrAfterSetOffBFLosses')+
					coalesceSetRet('scheduleBFLA.specifiedInc.incBFLA.incOfCurYrAfterSetOffBFLosses'));
			var sum115BBFBBG115B = coalesceSetRet('scheduleSI.splCodeRateTax[8].splRateInc')+coalesceSetRet('scheduleSI.splCodeRateTax[9].splRateInc')
			+coalesceSetRet('scheduleSI.splCodeRateTax[0].splRateInc');


			var sumBP115B0 = 0;
			var sumBP115B1 = 0;
			var sumBP115B2 = 0;
			var sumBP115B3 = 0;
			var sumBP115B4 = 0;
			var sumBP115B41 = 0;

			var schBp5BBG5BBF = eval(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF')+coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG'));
			var schBp5BBG5BBF0 = 0;
			var schBp5BBG5BBF1 = 0;
			var schBp5BBG5BBF2 = 0;
			var schBp5BBG5BBF3 = 0;
			var schBp5BBG5BBF4 = 0;


			if(checkFirstDateBefore( dateOfCommenceMent , slab0_end_date ) || dateOfCommenceMent=='' ){
				dateOfComAmount0 = parseInt(coalesce(sumSchBpOthIncome));
				sumBP115B0 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses'))*0.125);
				schBp5BBG5BBF0 = eval(parseInt(schBp5BBG5BBF)*0.1);
			}
			if(checkFirstDateBefore(slab1_start_date , dateOfCommenceMent) && checkFirstDateBefore( dateOfCommenceMent , slab1_end_date ) ){
				dateOfComAmount1 = parseInt(coalesce(sumSchBpOthIncome));
				sumBP115B1 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses'))*0.125);
				schBp5BBG5BBF1 = eval(parseInt(schBp5BBG5BBF)*0.1);
			}
			if(checkFirstDateBefore(slab2_start_date , dateOfCommenceMent) && checkFirstDateBefore( dateOfCommenceMent , slab2_end_date ) ){
				dateOfComAmount2 = parseInt(coalesce(sumSchBpOthIncome));
				sumBP115B2 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses'))*0.125);
				schBp5BBG5BBF2 = eval(parseInt(schBp5BBG5BBF)*0.1);
			}
			else if(checkFirstDateBefore(slab3_start_date , dateOfCommenceMent) && checkFirstDateBefore( dateOfCommenceMent , slab3_end_date ) ){
				dateOfComAmount3 = parseInt(coalesce(sumSchBpOthIncome));
				sumBP115B3 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses'))*0.125);
				schBp5BBG5BBF3 = eval(parseInt(schBp5BBG5BBF)*0.1);
			}
			else if(checkFirstDateBefore(slab4_start_date , dateOfCommenceMent) && checkFirstDateBefore( dateOfCommenceMent , FY_end_date ) ){
				dateOfComAmount4 = parseInt(coalesce(sumSchBpOthIncome));
				sumBP115B4 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses'))*0.125);
				schBp5BBG5BBF4 = eval(parseInt(schBp5BBG5BBF)*0.1);
			}


			sumBP115B41 = eval(parseInt(coalesceSetRet('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses')));
			if(dateOfCommenceMent==''){
				dateOfComAmount0 = parseInt(coalesce(sumSchBpOthIncome));
			}



			sumBP115B0 = eval(parseInt(sumBP115B0));
			sumBP115B1 = eval(parseInt(sumBP115B0)+parseInt(sumBP115B1));
			sumBP115B2 = eval(parseInt(sumBP115B1)+parseInt(sumBP115B2));
			sumBP115B3 = eval(parseInt(sumBP115B2)+parseInt(sumBP115B3));
			sumBP115B4 = eval(parseInt(sumBP115B4));

			schBp5BBG5BBF0 = eval(parseInt(schBp5BBG5BBF0));
			schBp5BBG5BBF1 = eval(parseInt(schBp5BBG5BBF0)+parseInt(schBp5BBG5BBF1));
			schBp5BBG5BBF2 = eval(parseInt(schBp5BBG5BBF1)+parseInt(schBp5BBG5BBF2));
			schBp5BBG5BBF3 = eval(parseInt(schBp5BBG5BBF2)+parseInt(schBp5BBG5BBF3));
			schBp5BBG5BBF4 = eval(parseInt(schBp5BBG5BBF4));



			var taxOnstcgOthers0 =     eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of6'), 10) + parseInt(normalBalIncome)  + parseInt(dateOfComAmount0));
			var taxOnstcgOthers1 =     eval(parseInt(taxOnstcgOthers0) + eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of9'), 10) )+ parseInt(dateOfComAmount1));
			var taxOnstcgOthers2 =     eval(parseInt(taxOnstcgOthers1) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of9To15Of12'), 10)+ parseInt(dateOfComAmount2));
			var taxOnstcgOthers3 =     eval(parseInt(taxOnstcgOthers2) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of12To15Of3'), 10)+ parseInt(dateOfComAmount3)+parseInt(incOfCurYrAfterSetOffBFLosses));
			var taxOnstcgOthers4 =     eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of3To31Of3'), 10)+parseInt(taxOnstcgOthers3) + parseInt(dateOfComAmount4));

			var dtaastcgRate=parseFloat('0.00001');
			var dtaaltcgRate=parseFloat('0.00001');


			if(coalesceSetRet('scheduleSI.splCodeRateTax[11].taxableInc')>parseInt('0',10)){
				if(!coalesceSetRet('scheduleSI.splCodeRateTax[11].splRateIncTax')>0){
					dtaastcgRate=eval(parseInt('1',10)/coalesceSetRet('scheduleSI.splCodeRateTax[11].taxableInc'));
				}else{
					dtaastcgRate=eval(coalesceSetRet('scheduleSI.splCodeRateTax[11].splRateIncTax')/coalesceSetRet('scheduleSI.splCodeRateTax[11].taxableInc'));
				}
			}
			if(coalesceSetRet('scheduleSI.splCodeRateTax[12].taxableInc')>parseInt('0',10)){
				if(!coalesceSetRet('scheduleSI.splCodeRateTax[12].splRateIncTax')>0){
					dtaaltcgRate=eval(parseInt('1',10)/coalesceSetRet('scheduleSI.splCodeRateTax[12].taxableInc'));
				}else{
					dtaaltcgRate=eval(coalesceSetRet('scheduleSI.splCodeRateTax[12].splRateIncTax')/coalesceSetRet('scheduleSI.splCodeRateTax[12].taxableInc'));
				}
			}


			var taxOnstcgDtaa0 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.upto15Of6'),10));
			var taxOnstcgDtaa1 = eval(parseInt(taxOnstcgDtaa0,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.upto15Of9'),10));
			var taxOnstcgDtaa2 = eval(parseInt(taxOnstcgDtaa1,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of9To15Of12'),10));
			var taxOnstcgDtaa3 = eval(parseInt(taxOnstcgDtaa2,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of12To15Of3'),10));
			var taxOnstcgDtaa4 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of3To31Of3'),10));

			taxOnstcgDtaa0 = zeroOrMore(parseInt(taxOnstcgDtaa0,10))*dtaastcgRate;
			taxOnstcgDtaa1 = zeroOrMore(parseInt(taxOnstcgDtaa1,10))*dtaastcgRate;
			taxOnstcgDtaa2 = zeroOrMore(parseInt(taxOnstcgDtaa2,10))*dtaastcgRate;
			taxOnstcgDtaa3 = zeroOrMore(parseInt(taxOnstcgDtaa3,10))*dtaastcgRate;
			taxOnstcgDtaa4 = zeroOrMore(parseInt(taxOnstcgDtaa4,10))*dtaastcgRate;

			var totalStcgDtaatax = eval(parseInt(taxOnstcgDtaa3,10)+parseInt(taxOnstcgDtaa4,10));

			var taxOnltcgDtaa0 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.upto15Of6'),10));
			var taxOnltcgDtaa1 = eval(parseInt(taxOnltcgDtaa0,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.upto15Of9'),10));
			var taxOnltcgDtaa2 = eval(parseInt(taxOnltcgDtaa1,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of9To15Of12'),10));
			var taxOnltcgDtaa3 = eval(parseInt(taxOnltcgDtaa2,10)+ parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of12To15Of3'),10));
			var taxOnltcgDtaa4 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of3To31Of3'),10));
			taxOnltcgDtaa0 = zeroOrMore(parseInt(taxOnltcgDtaa0,10))*dtaaltcgRate;
			taxOnltcgDtaa1 = zeroOrMore(parseInt(taxOnltcgDtaa1,10))*dtaaltcgRate;
			taxOnltcgDtaa2 = zeroOrMore(parseInt(taxOnltcgDtaa2,10))*dtaaltcgRate;
			taxOnltcgDtaa3 = zeroOrMore(parseInt(taxOnltcgDtaa3,10))*dtaaltcgRate;
			taxOnltcgDtaa4 = zeroOrMore(parseInt(taxOnltcgDtaa4,10))*dtaaltcgRate;

			var totalLtcgDtaatax = eval(parseInt(taxOnltcgDtaa3,10)+parseInt(taxOnltcgDtaa4,10));

			//2019 changes
			var taxon15BDA0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/6'),10)));
			var taxon15BDA1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/9'),10)+parseInt(taxon15BDA0,10)));
			var taxon15BDA2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/12'),10)+parseInt(taxon15BDA1,10)));
			var taxon15BDA3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/3'),10)+parseInt(taxon15BDA2,10)));
			var taxon15BDA4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto31/3'),10)));


			taxon15BDA0 = zeroOrMore(parseInt(taxon15BDA0,10))*0.10;
			taxon15BDA1 = zeroOrMore(parseInt(taxon15BDA1,10))*0.10;
			taxon15BDA2 = zeroOrMore(parseInt(taxon15BDA2,10))*0.10;
			taxon15BDA3 = zeroOrMore(parseInt(taxon15BDA3,10))*0.10;
			taxon15BDA4 = zeroOrMore(parseInt(taxon15BDA4,10))*0.10;

			var totalBBDAtax = eval(parseInt(taxon15BDA3,10)+parseInt(taxon15BDA4,10))*parseFloat('1.04');


			var taxonLottery0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/6'),10)));
			var taxonLottery1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/9'),10)+parseInt(taxonLottery0,10)));
			var taxonLottery2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/12'),10)+parseInt(taxonLottery1,10)));
			var taxonLottery3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/3'),10)+parseInt(taxonLottery2,10)));
			var taxonLottery4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto31/3'),10)));


			taxonLottery0 = zeroOrMore(parseInt(taxonLottery0,10))*0.30;
			taxonLottery1 = zeroOrMore(parseInt(taxonLottery1,10))*0.30;
			taxonLottery2 = zeroOrMore(parseInt(taxonLottery2,10))*0.30;
			taxonLottery3 = zeroOrMore(parseInt(taxonLottery3,10))*0.30;
			taxonLottery4 = zeroOrMore(parseInt(taxonLottery4,10))*0.30;



			var totalLotteryTax;
			totalLotteryTax = eval(parseInt(taxonLottery3,10)+parseInt(taxonLottery4,10))*parseFloat('1.04');



			var totalQuarterlyTax = ((parseInt(sumBP115B41)*0.125)+parseInt(totalStcgDtaatax)+parseInt(totalLtcgDtaatax)+parseInt(totalBBDAtax)+parseInt(totalLotteryTax)+parseInt(SISurcharge))*1.04;



			siTax = zeroOrMore((siTax) - totalQuarterlyTax);


			//30%
			var shortTermUnder30Per0 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of6'), 10) );
			var shortTermUnder30Per1 = eval(parseInt(shortTermUnder30Per0) + eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of9'), 10) ));
			var shortTermUnder30Per2 = eval(parseInt(shortTermUnder30Per1) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of9To15Of12'), 10) );
			var shortTermUnder30Per3 = eval(parseInt(shortTermUnder30Per2) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of12To15Of3'), 10) );
			var shortTermUnder30Per4 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of3To31Of3'), 10) );


			//20%
			var taxOnltcgNonProviso0 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of6'), 10) );
			var taxOnltcgNonProviso1 = eval(parseInt(taxOnltcgNonProviso0) + eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of9'), 10) ));
			var taxOnltcgNonProviso2 = eval(parseInt(taxOnltcgNonProviso1) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of9To15Of12'), 10) );
			var taxOnltcgNonProviso3 = eval(parseInt(taxOnltcgNonProviso2) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of12To15Of3'), 10) );
			var taxOnltcgNonProviso4 = eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of3To31Of3'), 10) );


			//15%
			var taxOnstcg111A0 =       eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of6'), 10)  );
			var taxOnstcg111A1 =       eval(parseInt(taxOnstcg111A0) + eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of9'), 10)  ));
			var taxOnstcg111A2 =       eval(parseInt(taxOnstcg111A1) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of9To15Of12'), 10) );
			var taxOnstcg111A3 =       eval(parseInt(taxOnstcg111A2) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of12To15Of3'), 10) );
			var taxOnstcg111A4 =       eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of3To31Of3'), 10) );


			//10%
			var taxOnltcgProviso0 =    eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of6'), 10) );
			var taxOnltcgProviso1 =    eval(parseInt(taxOnltcgProviso0) + eval(parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of9'), 10) ));
			var taxOnltcgProviso2 =    eval(parseInt(taxOnltcgProviso1) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of9To15Of12'), 10) );
			var taxOnltcgProviso3 =    eval(parseInt(taxOnltcgProviso2) + parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of12To15Of3'), 10) );
			var taxOnltcgProviso4 =    eval( parseInt(coalesceSetRet('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of3To31Of3'), 10) );


			var temp = applyExemption2017([taxOnltcgProviso0,taxOnltcgProviso1,taxOnltcgProviso2,taxOnltcgProviso3,taxOnltcgProviso4], exemption10Pct);
			taxOnltcgProviso0 = temp[0],taxOnltcgProviso1 = temp[1],taxOnltcgProviso2 = temp[2],taxOnltcgProviso3 = temp[3],taxOnltcgProviso4 = temp[4];
			taxOnltcgProviso0 *= intrstRates[0],taxOnltcgProviso1*= intrstRates[0],taxOnltcgProviso2 *= intrstRates[0],taxOnltcgProviso3 *= intrstRates[0],taxOnltcgProviso4 *= intrstRates[0];


			temp = applyExemption2017([shortTermUnder30Per0,shortTermUnder30Per1,shortTermUnder30Per2,shortTermUnder30Per3,shortTermUnder30Per4], exemption30Pct);
			shortTermUnder30Per0=temp[0], shortTermUnder30Per1=temp[1], shortTermUnder30Per2=temp[2], shortTermUnder30Per3=temp[3],shortTermUnder30Per4=temp[4];
			shortTermUnder30Per0 *= intrstRates[3],shortTermUnder30Per1 *= intrstRates[3],shortTermUnder30Per2 *= intrstRates[3],shortTermUnder30Per3 *= intrstRates[3],shortTermUnder30Per4 *= intrstRates[3];


			temp = applyExemption2017([taxOnltcgNonProviso0,taxOnltcgNonProviso1,taxOnltcgNonProviso2,taxOnltcgNonProviso3,taxOnltcgNonProviso4], exemption20Pct);
			taxOnltcgNonProviso0=temp[0],taxOnltcgNonProviso1=temp[1],taxOnltcgNonProviso2=temp[2],taxOnltcgNonProviso3=temp[3],taxOnltcgNonProviso4=temp[4];
			taxOnltcgNonProviso0 *= intrstRates[1],taxOnltcgNonProviso1 *= intrstRates[1],taxOnltcgNonProviso2 *= intrstRates[1],taxOnltcgNonProviso3 *= intrstRates[1],taxOnltcgNonProviso4 *= intrstRates[1];


			temp = applyExemption2017([taxOnstcg111A0,taxOnstcg111A1,taxOnstcg111A2,taxOnstcg111A3,taxOnstcg111A4], exemption15Pct);
			taxOnstcg111A0=temp[0],taxOnstcg111A1=temp[1],taxOnstcg111A2=temp[2],taxOnstcg111A3=temp[3],taxOnstcg111A4=temp[4];
			taxOnstcg111A0 *= intrstRates[2],taxOnstcg111A1 *= intrstRates[2],taxOnstcg111A2 *= intrstRates[2],taxOnstcg111A3 *= intrstRates[2],taxOnstcg111A4 *= intrstRates[2];


			temp = applyExemption2017([taxOnstcgOthers0,taxOnstcgOthers1,taxOnstcgOthers2,taxOnstcgOthers3,taxOnstcgOthers4], exemptionOth111A, true);
			taxOnstcgOthers0=temp[0],taxOnstcgOthers1=temp[1],taxOnstcgOthers2=temp[2],taxOnstcgOthers3=temp[3],taxOnstcgOthers4=temp[4];

			if(totalCG>0){

				taxOnstcgOthers0 = ((calculateTaxPayableOnTotalInc(taxOnstcgOthers0, true)  + parseInt(dtaan11b)) * appRateSurcharge) ;
				taxOnstcgOthers1 = ((calculateTaxPayableOnTotalInc(taxOnstcgOthers1, true)  + parseInt(dtaan11b)) * appRateSurcharge) ;
				taxOnstcgOthers2 = ((calculateTaxPayableOnTotalInc(taxOnstcgOthers2, true)  + parseInt(dtaan11b)) * appRateSurcharge );
				taxOnstcgOthers3 = calculateTaxPayableOnTotalInc(taxOnstcgOthers3, true);

				if ((calculateTaxPayableOnTotalInc(taxOnstcgOthers4, true)- parseInt(taxOnstcgOthers3) - parseInt(coalesce(dtaan11b))) > 0) {

					taxOnstcgOthers4 = ((zeroOrMore(calculateTaxPayableOnTotalInc(taxOnstcgOthers4, true) - parseInt(taxOnstcgOthers3) - parseInt(coalesce(dtaan11b)))))  ;

				} else{
					taxOnstcgOthers4 = 0;
				}
				taxOnstcgOthers3 = ((taxOnstcgOthers3 + parseInt(dtaan11b)) * appRateSurcharge );
			}else{

				taxOnstcgOthers0 = (calculateTaxPayableOnTotalInc(taxOnstcgOthers0, true) + parseInt(dtaan11b));
				taxOnstcgOthers1 = (calculateTaxPayableOnTotalInc(taxOnstcgOthers1, true) + parseInt(dtaan11b));
				taxOnstcgOthers2 = (calculateTaxPayableOnTotalInc(taxOnstcgOthers2, true) + parseInt(dtaan11b));
				taxOnstcgOthers3 = calculateTaxPayableOnTotalInc(taxOnstcgOthers3, true);
				if ((calculateTaxPayableOnTotalInc(taxOnstcgOthers4, true) - parseInt(taxOnstcgOthers3) - parseInt(coalesce(dtaan11b))) > 0) {

					taxOnstcgOthers4 = (zeroOrMore(calculateTaxPayableOnTotalInc(taxOnstcgOthers4, true) - parseInt(taxOnstcgOthers3)  - parseInt(coalesce(dtaan11b))));
				} else{
					taxOnstcgOthers4 = 0;
				}
				taxOnstcgOthers3 = taxOnstcgOthers3 + parseInt(dtaan11b);
			}


			totalUpto15Of6 = eval(parseInt(taxOnltcgProviso0, 10)
					+ parseInt(taxOnltcgNonProviso0, 10)
					+ parseInt(taxOnstcg111A0, 10) + parseInt(taxOnstcgOthers0, 10)
					+ parseInt(shortTermUnder30Per0, 10) + parseInt(taxon15BDA0, 10)+ parseInt(taxonLottery0, 10)+parseInt(taxOnstcgDtaa0,10)+parseInt(taxOnltcgDtaa0,10)+parseInt(sumBP115B0,10)+parseInt(schBp5BBG5BBF0,10));



			totalUpto15Of9 = eval(parseInt(taxOnltcgProviso1, 10)
					+ parseInt(taxOnltcgNonProviso1, 10)
					+ parseInt(taxOnstcg111A1, 10) + parseInt(taxOnstcgOthers1, 10)
					+ parseInt(shortTermUnder30Per1, 10) + parseInt(taxon15BDA1, 10)+parseInt(taxonLottery1, 10)+parseInt(taxOnstcgDtaa1,10)+parseInt(taxOnltcgDtaa1,10)+parseInt(sumBP115B1,10)+parseInt(schBp5BBG5BBF1,10));

			totalUp16Of9To15Of12 = eval(parseInt(taxOnltcgProviso2, 10)
					+ parseInt(taxOnltcgNonProviso2, 10)
					+ parseInt(taxOnstcg111A2, 10) + parseInt(taxOnstcgOthers2, 10)
					+ parseInt(shortTermUnder30Per2, 10) + parseInt(taxon15BDA2, 10)+parseInt(taxonLottery2, 10)+parseInt(taxOnstcgDtaa2,10)+parseInt(taxOnltcgDtaa2,10)+parseInt(sumBP115B2,10)+parseInt(schBp5BBG5BBF2,10));

			totalUp16Of12To15Of3 = eval(parseInt(taxOnltcgProviso3, 10)
					+ parseInt(taxOnltcgNonProviso3, 10)
					+ parseInt(taxOnstcg111A3, 10) + parseInt(taxOnstcgOthers3, 10)
					+ parseInt(shortTermUnder30Per3, 10) + parseInt(taxon15BDA3, 10)+parseInt(taxonLottery3, 10)+parseInt(taxOnstcgDtaa3,10)+parseInt(taxOnltcgDtaa3,10)+parseInt(sumBP115B3,10)+parseInt(schBp5BBG5BBF3,10));

			totalUp16Of3To31Of3 = eval(parseInt(taxOnltcgProviso4, 10)
					+ parseInt(taxOnltcgNonProviso4, 10)
					+ parseInt(taxOnstcg111A4, 10) + parseInt(taxOnstcgOthers4, 10)
					+ parseInt(shortTermUnder30Per4, 10)+ parseInt(taxon15BDA4, 10)+parseInt(taxonLottery4, 10)+parseInt(taxOnstcgDtaa4,10)+parseInt(taxOnltcgDtaa4,10)+parseInt(sumBP115B4,10)+parseInt(schBp5BBG5BBF4,10));


			//for checking agri_rebate

			var oldTotalUp16Of12To15Of3 = totalUp16Of12To15Of3;

			totalUpto15Of6= zeroOrMore(eval(parseInt(totalUpto15Of6)- parseInt(rebateOnAgriInc)));
			totalUpto15Of9= zeroOrMore(eval(parseInt(totalUpto15Of9)- parseInt(rebateOnAgriInc)));
			totalUp16Of9To15Of12= zeroOrMore(eval(parseInt(totalUp16Of9To15Of12)- parseInt(rebateOnAgriInc)));
			totalUp16Of12To15Of3= zeroOrMore(eval(parseInt(totalUp16Of12To15Of3)- parseInt(rebateOnAgriInc)));


			var avaRebate =parseInt(rebateOnAgriInc) - Math.min(parseInt(rebateOnAgriInc), parseInt(oldTotalUp16Of12To15Of3));

			totalUp16Of3To31Of3 = zeroOrMore(eval(parseInt(totalUp16Of3To31Of3)- parseInt(avaRebate)));


			var actualTax = [(totalUpto15Of6),(totalUpto15Of9 - totalUpto15Of6),(totalUp16Of9To15Of12 - totalUpto15Of9),(totalUp16Of12To15Of3 - totalUp16Of9To15Of12),(totalUp16Of3To31Of3)];


			var surcharge115BBE= document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surcharge25ofSI')[0].value;


			if(marginal1 ||(secIncome>0 && ((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

					(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0))) && taxPayer=='1'){
				totalUpto15Of6 = (parseInt(totalUpto15Of6) +parseInt((parseInt(remove115BBE)*0.6)) +parseInt(surcharge115BBE) + parseInt(coalesce(parseInt(SurchargeUnderSec) * coalesce((actualTax[0])/TaxpayableUnderSec)))) * 1.04;

				totalUpto15Of9 = parseInt(totalUpto15Of6) + (parseInt(actualTax[1]) + parseInt(coalesce(parseInt(SurchargeUnderSec) * coalesce(actualTax[1]/TaxpayableUnderSec)))) * 1.04;
				totalUp16Of9To15Of12 = parseInt(totalUpto15Of9) + (parseInt(actualTax[2]) + parseInt(coalesce(parseInt(SurchargeUnderSec) * coalesce(actualTax[2]/TaxpayableUnderSec)))) * 1.04;


				totalUp16Of12To15Of3 = (parseInt(coalesce(totalUp16Of9To15Of12), 10)+(parseInt(coalesce(actualTax[3]), 10)+
						parseInt(coalesce(SurchargeOnly44AD), 10) +	(parseInt(coalesce(SurchargeUnderSec), 10) *
								((parseInt(coalesce(actualTax[3]), 10)-parseInt(coalesce(TaxPayableOnly44AD), 10))/
										parseInt(coalesce(TaxpayableUnderSec), 10))))* 1.04); // old working changes


				if (parseInt(coalesce(TaxpayableUnderSec), 10) == 0)
				{
					totalUp16Of12To15Of3 = (parseInt(coalesce(totalUp16Of9To15Of12), 10)+(parseInt(coalesce(actualTax[3]), 10)+
							parseInt(coalesce(SurchargeOnly44AD), 10) )* 1.04);
				}

				totalUp16Of3To31Of3 = (parseInt(actualTax[4]) + parseInt(coalesce( parseInt(SurchargeUnderSec) * actualTax[4]/TaxpayableUnderSec))) * 1.04;



			}else{

				if(SurchargeUnderSec>0){

					if( statusCompany == "1" || statusCompany == "2" || statusCompany == "17" || statusCompany == "15" || statusCompany == "16" || statusCompany == "4" || statusCompany == "5"){

						totalUpto15Of6 =parseInt( (parseInt(totalUpto15Of6) + parseInt(surcharge115BBE) + parseInt(actualTax[0])*0.12) * 1.04);
						totalUpto15Of9 = parseInt(totalUpto15Of6) + (parseInt(actualTax[1]) + actualTax[1]*0.12) * 1.04;
						totalUp16Of9To15Of12 = parseInt(totalUpto15Of9) + (parseInt(actualTax[2]) + actualTax[2]*0.12) * 1.04;
						totalUp16Of12To15Of3 = parseInt(totalUp16Of9To15Of12) + (parseInt(actualTax[3]) + actualTax[3]*0.12) * 1.04;


						totalUp16Of3To31Of3 = (parseInt(actualTax[4]) + actualTax[4]*0.12) * 1.04;

					}else
					{
						totalUpto15Of6 =parseInt( (parseInt(totalUpto15Of6) + parseInt(surcharge115BBE) + parseInt(actualTax[0])*0.15) * 1.04);
						totalUpto15Of9 = parseInt(totalUpto15Of6) + (parseInt(actualTax[1]) + actualTax[1]*0.15) * 1.04;
						totalUp16Of9To15Of12 = parseInt(totalUpto15Of9) + (parseInt(actualTax[2]) + actualTax[2]*0.15) * 1.04;
						totalUp16Of12To15Of3 = parseInt(totalUp16Of9To15Of12) + (parseInt(actualTax[3]) + actualTax[3]*0.15) * 1.04;

						totalUp16Of3To31Of3 = (parseInt(actualTax[4]) + actualTax[4]*0.15) * 1.04;

					}
				}
				else{
					totalUpto15Of6 = parseInt((parseInt(totalUpto15Of6) + parseInt(surcharge115BBE)) * 1.04);
					totalUpto15Of9 = parseInt(totalUpto15Of6) + (parseInt(actualTax[1]) ) * 1.04;
					totalUp16Of9To15Of12 = parseInt(totalUpto15Of9) + (parseInt(actualTax[2]) ) * 1.04;
					totalUp16Of12To15Of3 = parseInt(totalUp16Of9To15Of12) + (parseInt(actualTax[3])) * 1.04;

					totalUp16Of3To31Of3 = (parseInt(actualTax[4]) ) * 1.04;


				}
			}

			netTaxLiability = 0;

			othExemptions = eval(
					+	parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxRelief.totTaxRelief'), 10)
					+ parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.creditUS115JD'), 10)
			);

		}else{
			taxOnWinLottRacePuzz = 0;
			totSplRateIncTax = 0;
			othExemptions = 0;
		}




		var intrst234C0 = parseInt('0' ,10);
		var intrst234Ci = parseInt('0' ,10);
		var intrst234Cii = parseInt('0' ,10);
		var intrst234Ciii = parseInt('0' ,10);
		var intrst234Civ = parseInt('0' ,10);

		var tempintrstBeforeSlab0 = parseInt('0' ,10);
		var tempintrstBeforeSlab1 = parseInt('0' ,10);
		var tempintrstBeforeSlab2 = parseInt('0' ,10);
		var tempintrstBeforeSlab3 = parseInt('0' ,10);
		var totSlab = parseInt('0' ,10);


		if(( eval(parseInt(balTaxPayable.value ,10) - parseInt(TDS ,10) - parseInt(TCS ,10)) >=  parseInt('10000',10))){

			var totSplRateIncTax = 0;

			siTax=parseInt(siTax);



			if(parseInt(slab0 ,10) < eval((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10) + totalUpto15Of6 + parseInt(siTax)  - parseInt(othExemptions)  - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.12'))){

				tempintrstBeforeSlab0 = (parseInt(netTaxLiability, 10) + parseInt(totSplRateIncTax ,10) + totalUpto15Of6 + siTax - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10)  * parseFloat('0.15'));

				var tempintrst234C0 = (((parseInt(netTaxLiability, 10) + parseInt(totSplRateIncTax ,10) + totalUpto15Of6 + siTax  - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.15'))  - parseInt(slab0 ,10));

				if(parseInt(tempintrst234C0,10) > 100){
					tempintrst234C0= Math.floor(parseInt(tempintrst234C0,10)/100)*parseInt('100' ,10);
				}

				intrst234C0=parseInt(tempintrst234C0,10)* parseFloat('0.01') * parseInt('3' ,10);

			}



			if(eval(parseInt(slab0 ,10) + parseInt(slab1 ,10)) < eval((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax, 10) + totalUpto15Of9 + siTax - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.36') )){

				tempintrstBeforeSlab1 = ((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10) + totalUpto15Of9 + siTax - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10))* parseFloat('0.45')) ;

				var tempintrst234Ci = (((parseInt(netTaxLiability, 10) + parseInt(totSplRateIncTax, 10) + totalUpto15Of9 - parseInt(othExemptions) + siTax - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.45') )  - parseInt(slab0 ,10) - parseInt(slab1 ,10) );

				if(parseInt(tempintrst234Ci,10) > 100){
					tempintrst234Ci= Math.floor(parseInt(tempintrst234Ci,10)/100)*parseInt('100' ,10);
				}
				intrst234Ci=parseInt(tempintrst234Ci,10)* parseFloat('0.01') * parseInt('3' ,10) ;
			}


			if(eval(parseInt(slab0 ,10) + parseInt(slab1 ,10) + parseInt(slab2 ,10)) < eval((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10) + totalUp16Of9To15Of12 + siTax - parseInt(othExemptions) -  parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.75') )){
				tempintrstBeforeSlab2 =((parseInt(netTaxLiability, 10) + parseInt(totSplRateIncTax ,10) + totalUp16Of9To15Of12 + siTax - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.75')) ;
				var tempintrst234Cii = (((parseInt(netTaxLiability, 10) + parseInt(totSplRateIncTax ,10) + totalUp16Of9To15Of12 + siTax - parseInt(othExemptions) - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('0.75') )  - parseInt(slab0 ,10) -parseInt(slab1 ,10) - parseInt(slab2 ,10) );
				if(parseInt(tempintrst234Cii,10) > 100){
					tempintrst234Cii= Math.floor(parseInt(tempintrst234Cii,10)/100)*parseInt('100' ,10);
				}
				intrst234Cii=parseInt(tempintrst234Cii,10)* parseFloat('0.01') * parseInt('3' ,10) ;
			}


			var tempintrstForAdvTax = zeroOrMore((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10)  + totalUp16Of12To15Of3 + siTax - parseInt(othExemptions)  - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('1'));


			if(eval(parseInt(slab0 ,10) + parseInt(slab1 ,10) + parseInt(slab2 ,10) + parseInt(slab3 ,10)) < eval((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10) + totalUp16Of12To15Of3 + siTax - parseInt(othExemptions) -  parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('1' ,10))){

				tempintrstBeforeSlab3 = ((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10)  + totalUp16Of12To15Of3 + siTax - parseInt(othExemptions)  - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('1'));

				var tempintrst234Ciii = zeroOrMore(((parseInt(netTaxLiability, 10)  + parseInt(totSplRateIncTax ,10)  + totalUp16Of12To15Of3 + siTax - parseInt(othExemptions)  - parseInt(TDS ,10) - parseInt(TCS ,10)) * parseFloat('1')) - parseInt(slab0 ,10)- parseInt(slab1 ,10)- parseInt(slab2 ,10) - parseInt(slab3 ,10) );


				if(parseInt(tempintrst234Ciii,10) > 100){
					tempintrst234Ciii= Math.floor(parseInt(tempintrst234Ciii,10)/100)*parseInt('100' ,10);
				}
				intrst234Ciii=parseInt(tempintrst234Ciii,10)* parseFloat('0.01') * parseInt('1' ,10) ;

			}


			totSlab =  parseInt(slab0 ,10) + parseInt(slab1 ,10) + parseInt(slab2 ,10) + parseInt(slab3 ,10);


			var usedTdsTcs = zeroOrMore(parseInt(TDS ,10) + parseInt(TCS ,10) + parseInt(othExemptions));
			var avlTdsTcs =0;


			avlTdsTcs = zeroOrMore(parseInt(usedTdsTcs) - Math.min(parseInt(usedTdsTcs), parseInt(totalUp16Of12To15Of3)));

			totalUp16Of3To31Of3 =zeroOrMore(eval( totalUp16Of3To31Of3 - parseInt(avlTdsTcs, 10)));



			var avalSlab = parseInt('0',10);

			if( parseInt(tempintrstBeforeSlab3,10) == 0){
				avalSlab = parseInt(totSlab) - Math.min(parseInt(totSlab), parseInt(tempintrstForAdvTax));
			}

			else {

				avalSlab = parseInt(totSlab) - Math.min(parseInt(totSlab), parseInt(tempintrstBeforeSlab3));
			}

			if(eval( parseInt(slab4 ,10)) < totalUp16Of3To31Of3){
				var tempintrst234Civ =zeroOrMore(totalUp16Of3To31Of3 -  parseInt(slab4 ,10) -  parseInt(avalSlab ,10));
				if(parseInt(tempintrst234Civ,10) > 100){
					tempintrst234Civ= Math.floor(parseInt(tempintrst234Civ,10)/100)*parseInt('100' ,10);
				}
				intrst234Civ=parseInt(tempintrst234Civ,10)* parseFloat('0.01') * parseInt('1' ,10) ;
			}

		}

		else {
			intrst234C0 = parseInt('0',10);
			intrst234Ci = parseInt('0',10);
			intrst234Cii = parseInt('0',10);
			intrst234Ciii = parseInt('0',10);
			intrst234Civ = parseInt('0',10);
		}




		intrst234C = eval(parseInt(intrst234C0 ,10) + parseInt(intrst234Ci ,10) + parseInt(intrst234Cii ,10) + parseInt(intrst234Ciii ,10) + parseInt(intrst234Civ ,10));




		if((secIncome > 0 &&((coalesce(parseInt(document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartC')[0].value, 10))+

				(coalesce(parseInt(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub')[0].value, 10))) == 0)) && taxPayer=='1') && ((parseInt((taxpayableIncSec44-othExemptions)*1.04)- parseInt(TDS ,10) - parseInt(TCS ,10))  <  parseInt('10000',10))){

			intrst234C = parseInt('0',10);
		}

	}catch(e){
		alert('Error in calculate234cIntrst: ' + e.stack);
	}

	return intrst234C;

}

function isMarginalRelfApplcbl(){
	var surcharge = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge')[0];
	var taxPybl = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0];
	if(parseInt(surcharge.value) > 0){
		if(parseInt(surcharge.value * 0.15) != taxPybl.value){
			return true;
		}
	}
	return false;
}

//To calculate exemptions
function applyExemption2017(original, exemption,appRate) {
	var remaining = exemption;
	var nonZero = 0;
	for (var i = original.length - 1; i >= 0; i--) {
		if (i > 0 && (i < original.length - 1 || (appRate && i < original.length))) {
			original[i] = original[i] - original[i - 1];
		}
		if (original[i] != 0) {
			nonZero++;
		}
	}
	if (nonZero == 0) {
		return original;
	}
	var total = 0;
	for (var i = 0; i < original.length; i++) {
		if (parseInt(original[i], 10) > parseInt(0, 10)) {
			if (parseInt(original[i]) > parseInt(remaining)) {
				original[i] = (parseInt(original[i], 10)) - remaining;
				remaining = 0;
			} else {
				remaining = remaining - original[i];
				original[i] = 0;
			}
		}
		if (i > 0
				&& (i < original.length - 1 || (appRate && i < original.length))) {
			original[i] = original[i] + original[i - 1];
		}
		total = eval(parseInt(total, 10) + parseInt(original[i]));
	}
	if (parseInt(remaining, 10) > parseInt(0, 10) && total > parseInt(0, 10)) {
		original = applyExemption2017(original, remaining);
	}

	return original;
}


function rndOffNrsTen(newVar){

	if(  parseInt(newVar.toString().charAt(newVar.toString().length-1),10) >= parseInt('5',10)){
		newVar = eval(Math.floor(eval(parseInt(newVar,10) / parseInt('10',10))) * parseInt('10',10));
		newVar = eval(parseInt(newVar,10) + parseInt('10',10));

		return newVar;
	}else{
		newVar = eval(Math.floor(eval(parseInt(newVar,10) / parseInt('10',10))) * parseInt('10',10));

		return newVar;
	}

}

/*function calsurchargeOnAmtcAboveCrore(){
	var taxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.taxDeemedTISec115JC')[0];
	var surchargeOnAboveCrore = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.surchargeA')[0];
	var totInc = document.getElementsByName('itrScheduleAMT.adjustedUnderSec115JC')[0];	totInc.value = coalesce(totInc.value);

	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

	var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	// for surcharge
				var taxOnTotInc =  parseInt(taxPayable.value,10);

				var taxOnCutOffInc = (10000000 * .185);

				if( rndOffNrsTen(totInc.value) > 10000000 ){

						if( statusCompany == "1" || statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "3" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")) || (statusCompany == "1" && substatusCompany == "5")){

							var surchargeRate = 0.12;
						}else
							{
							var surchargeRate = 0.15;
							}

						var tempSurcharge = taxOnTotInc  * surchargeRate;

						//check if eligible for marginal relief
						var extraInc = rndOffNrsTen(totInc.value) - 10000000;

						if( statusCompany == "1" || statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "3" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")) || (statusCompany == "1" && substatusCompany == "5")){
									if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc + (taxOnCutOffInc * 0.10)) ){

										var marginalRelief =zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc));

										surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
										surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

									}else {
										surchargeOnAboveCrore.value = tempSurcharge;
										surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
										}
						}else
							{
									if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc + (taxOnCutOffInc * 0.10)) ){

										var marginalRelief =zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc + (taxOnCutOffInc * 0.10)));

										surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
										surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

									}else {
										surchargeOnAboveCrore.value = tempSurcharge;
										surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
										}
							}

				} else if( (rndOffNrsTen(totInc.value) > 5000000 && rndOffNrsTen(totInc.value) <= 10000000) && !( statusCompany == "1" || statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "3" ||  substatusCompany == "15" ||  substatusCompany == "16" || substatusCompany == "4")) || (statusCompany == "1" && substatusCompany == "5")) ){

						var taxOnCutOffInc1= (5000000 * .185);
						var surchargeRate = 0.10;

						var tempSurcharge = taxOnTotInc  * surchargeRate;

						//check if eligible for marginal relief
						var extraInc = rndOffNrsTen(totInc.value) - 5000000;

						if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc1 + extraInc)){
							var marginalRelief =zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc1 + extraInc ));
							surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
							surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

						}else {
							surchargeOnAboveCrore.value = tempSurcharge;
							surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
							}

				} else {
					 surchargeOnAboveCrore.value = parseInt('0' ,10);
				}
	}*/
function calsurchargeOnAmtcAboveCrore(){
	try{

		var taxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.taxDeemedTISec115JC')[0];
		var surchargeOnAboveCrore = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.surchargeA')[0];
		var totInc = document.getElementsByName('itrScheduleAMT.adjustedUnderSec115JC')[0];	totInc.value = coalesce(totInc.value);

		var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;


		// for surcharge
		var taxOnTotInc =  parseInt(taxPayable.value,10);

		var finanInt = document.getElementsByName('partAGEN1.filingStatus.intFinancialServices')[0].value;

		var taxOnCutOffInc = 0;

		if(finanInt == "N")
		{

			taxOnCutOffInc = (10000000 * .185);

		}
		if(finanInt == "Y")
		{
			taxOnCutOffInc = (10000000 * .09);
			console.log("taxOnCutOffInc  else::: "+taxOnCutOffInc);
		}
		if(rndOffNrsTen(totInc.value) > 10000000 && (statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "17" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")) ||(statusCompany == "1" && (substatusCompany == "5" || substatusCompany == "10"))))
		{
			var tempSurcharge = taxOnTotInc  * 0.12 ;
			var extraInc = rndOffNrsTen(totInc.value) - 10000000;
			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc)){
				var marginalRelief = taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc );
				surchargeOnAboveCrore.value = tempSurcharge - marginalRelief;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

			}else {
				surchargeOnAboveCrore.value = tempSurcharge;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
			}
		}else if((rndOffNrsTen(totInc.value) > 10000000 && rndOffNrsTen(totInc.value) <= 20000000)&& ( statusCompany == "9" || (statusCompany == "14" && (substatusCompany == "8" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "4" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "20" || substatusCompany == "21")) ) )
		{
			if(finanInt == "N")
			{
				taxOnCutOffInc1 = (10000000 * .185);

			}else if(finanInt == "Y")
			{
				taxOnCutOffInc1 = (10000000 * .09);

			}
			var tempSurcharge = taxOnTotInc  * 0.15; // old calcn 2016-17

			//check if eligible for marginal relief
			var extraInc = rndOffNrsTen(totInc.value) - 10000000;
			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc1 + extraInc  + (taxOnCutOffInc1 * 0.10))){
				var marginalRelief = zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc1 + extraInc + (taxOnCutOffInc1 * 0.10)));
				surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

			}else {
				surchargeOnAboveCrore.value = tempSurcharge;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
			}
		}
		else if((rndOffNrsTen(totInc.value) > 20000000 && rndOffNrsTen(totInc.value) <= 50000000)&& ( statusCompany == "9" || (statusCompany == "14" && (substatusCompany == "8" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "4" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "20" || substatusCompany == "21")) ) ){
			var taxOnCutOffInc1 = 0;
			if(finanInt == "N")
			{
				taxOnCutOffInc1 = (20000000 * .185);
				console.log("taxOnCutOffInc1  ::: "+taxOnCutOffInc1);
			}else if(finanInt == "Y")
			{
				taxOnCutOffInc1 = (20000000 * .09);
				console.log("taxOnCutOffInc1  ::: "+taxOnCutOffInc1);
			}

			var surchargeRate = 0.25;

			var tempSurcharge = taxOnTotInc  * surchargeRate;

			//check if eligible for marginal relief
			var extraInc = rndOffNrsTen(totInc.value) - 20000000;


			console.log("taxOnTotInc  ::: "+taxOnTotInc);
			console.log("tempSurcharge  ::: "+tempSurcharge);
			console.log("taxOnCutOffInc  ::: "+taxOnCutOffInc);
			console.log("extraInc  ::: "+extraInc);

			console.log("taxOnTotInc + tempSurcharge  ::: "+(taxOnTotInc + tempSurcharge));
			console.log("taxOnCutOffInc1 + extraInc  ::: "+(taxOnCutOffInc1 + extraInc));



			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc1 + extraInc + (taxOnCutOffInc1 * 0.15))){
				var marginalRelief =zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc1 + extraInc + (taxOnCutOffInc1 * 0.15)));
				console.log("marginalRelief  ::: "+marginalRelief);
				surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

			}else {
				surchargeOnAboveCrore.value = tempSurcharge;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
			}

		}
		else if((rndOffNrsTen(totInc.value) > 50000000)&& ( statusCompany == "9" || (statusCompany == "14" && (substatusCompany == "8" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "4" || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "20" || substatusCompany == "21")) ) ){

			if(finanInt == "N")
			{
				taxOnCutOffInc1 = (50000000 * .185);

			}else if(finanInt == "Y")
			{
				taxOnCutOffInc1 = (50000000 * .09);

			}

			var tempSurcharge = taxOnTotInc  * 0.37; // old calcn 2016-17

			//check if eligible for marginal relief
			var extraInc = rndOffNrsTen(totInc.value) - 50000000;

			console.log("taxOnTotInc  ::: "+taxOnTotInc);
			console.log("tempSurcharge  ::: "+tempSurcharge);
			console.log("taxOnCutOffInc1  ::: "+taxOnCutOffInc1);
			console.log("extraInc  ::: "+extraInc);



			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc1 + extraInc  + (taxOnCutOffInc1 * 0.25))){


				var marginalRelief = taxOnTotInc + tempSurcharge - (taxOnCutOffInc1 + extraInc + (taxOnCutOffInc1 * 0.25));
				surchargeOnAboveCrore.value = tempSurcharge - marginalRelief;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);

			}else {
				surchargeOnAboveCrore.value = tempSurcharge;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
			}
		}
		else if( (rndOffNrsTen(totInc.value) > 5000000 && rndOffNrsTen(totInc.value) <= 10000000)&& (statusCompany == "9" || (statusCompany == "14" && (substatusCompany == "8" || substatusCompany == "13" || substatusCompany == "11"  || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "20" || substatusCompany == "21")) ) ){

			if(finanInt == "N")
			{
				taxOnCutOffInc1 = (5000000 * .185);

			}else if(finanInt == "Y")
			{
				taxOnCutOffInc1 = (5000000 * .09);

			}



			var surchargeRate = 0.10;



			var tempSurcharge = taxOnTotInc  * surchargeRate;

			//check if eligible for marginal relief

			var tempSurcharge = taxOnTotInc  * 0.10;

			var extraInc = rndOffNrsTen(totInc.value) - 5000000;

			console.log("taxOnTotInc  ::: "+taxOnTotInc);
			console.log("tempSurcharge  ::: "+tempSurcharge);
			console.log("taxOnCutOffInc  ::: "+taxOnCutOffInc);
			console.log("extraInc  ::: "+extraInc);

			console.log("taxOnTotInc + tempSurcharge  ::: "+(taxOnTotInc + tempSurcharge));
			console.log("taxOnCutOffInc1 + extraInc  ::: "+(taxOnCutOffInc1 + extraInc));




			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc1 + extraInc)){
				var marginalRelief =zeroOrMore( taxOnTotInc + tempSurcharge - (taxOnCutOffInc1 + extraInc ));
				surchargeOnAboveCrore.value = zeroOrMore(tempSurcharge - marginalRelief);
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);



			}else {
				surchargeOnAboveCrore.value = tempSurcharge;
				surchargeOnAboveCrore.value  = Math.round(surchargeOnAboveCrore.value);
			}

		}

		else {
			surchargeOnAboveCrore.value = parseInt('0' ,10);
		}

	}catch(e){
		alert("surchargeOnAboveCrore"+e);
	}
}

function calculatePartBTTI_first(cgosIncome)
{
	try{
		//1

		var taxOnDeemedTotIncSec115JB = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.taxDeemedTISec115JC')[0];
		taxOnDeemedTotIncSec115JB.value = eval(parseInt(coalesceSetRet('itrScheduleAMT.taxPayableUnderSec115JC'),10));

		//surcharge on 1a
		calsurchargeOnAmtcAboveCrore();

		var educationCess = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.educationCess')[0];

		educationCess.value = Math.round((parseInt(taxOnDeemedTotIncSec115JB.value, 10)+
				parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.surchargeA'),10)) * 0.04	);

		var totalTax = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.totalTax')[0];
		totalTax.value = eval(parseInt(taxOnDeemedTotIncSec115JB.value,10)+ parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.surchargeA'),10)+
				+ parseInt(educationCess.value,10));
		//2

		var incTax = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0];
		setEditableFieldValue(incTax,parseInt(calculateTaxPayableOnTotalInc(zeroOrMore( eval( parseInt(coalesceSetRet('partBTI.aggregateIncome'),10)))),10));

		var taxAtSpecialRates = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0];
		var substatusCompany = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(substatusCompany==7 || substatusCompany==13 || substatusCompany==12){
			setEditableFieldValue(taxAtSpecialRates,eval(	parseInt(coalesceSetRet('scheduleSI.totSplRateIncTax'),10)));
		}else{
			taxAtSpecialRates.value = eval(	parseInt(coalesceSetRet('scheduleSI.totSplRateIncTax'),10));
		}
		calculateRebateAgriculture();
		var rebateAgriculture = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0];
		var taxPayableOnTotInc = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0];

		taxPayableOnTotInc.value = zeroOrMore(eval(parseInt(incTax.value,10)
				+ parseInt(coalesce(taxAtSpecialRates.value,10))
				- parseInt(coalesce(rebateAgriculture.value),10)));

		//Surcharge on 2d
		calsurchargeOnAboveCrore(cgosIncome);
		surcharge201718();

		var surchargeOnAboveCrore = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge')[0];

		//3
		var educationCess = document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0];

		var cess = Math.round(eval((parseInt(taxPayableOnTotInc.value,10) +
				parseInt(surchargeOnAboveCrore.value,10)) * 0.04));

		setEditableFieldValue(educationCess,cess);

		//4
		var surchargeTotal = coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge');
		var grossTaxLiability = document.getElementsByName('partBTTI.computationOfTaxLiability.grossTaxLiability')[0];
		grossTaxLiability.value = eval(
				parseInt(taxPayableOnTotInc.value,10)
				+ parseInt(surchargeTotal,10)
				+ parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.educationCess'),10));

		//5
		var grossTaxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.grossTaxPayable')[0];
		grossTaxPayable.value = Math.max(parseInt(grossTaxLiability.value,10),parseInt(totalTax.value,10));

	}catch(e){
		alert('calculatePartBTTI_first: ' + e.stack);
	}
}

function calsurchargeOnAboveCrore(cgosIncome){

	var taxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0];

	var surchargeOnAboveCrore = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge')[0];

	var surchargeOn2F = document
	.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0];

	var totInc = document.getElementsByName('partBTI.totalIncome')[0].value;	totInc = coalesce(totInc);

	var surcharge = 0;
	var totalIncome = document.getElementsByName('partBTI.totalIncome')[0].value;
	var incChargeTaxSplRate111A112 = document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0].value;
	var taxAtSpecialRates = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].value;
	var dtaaInc = eval(parseInt(coalesce(document
			.getElementsByName('scheduleSI.splCodeRateTax[13].splRateInc')[0].value))+parseInt(coalesce(document
					.getElementsByName('scheduleSI.splCodeRateTax[12].splRateInc')[0].value))+parseInt(coalesce(document
							.getElementsByName('scheduleSI.splCodeRateTax[11].splRateInc')[0].value)));
	var dtaaTax = eval(parseInt(coalesce(document
			.getElementsByName('scheduleSI.splCodeRateTax[13].splRateIncTax')[0].value))+parseInt(coalesce(document
					.getElementsByName('scheduleSI.splCodeRateTax[12].splRateIncTax')[0].value))+parseInt(coalesce(document
							.getElementsByName('scheduleSI.splCodeRateTax[11].splRateIncTax')[0].value)));

	var b115Taxed = 0;
	var b115Tax = 0;

	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	// for surcharge

	var taxOnTotInc = parseInt(calculateTaxPayableOnTotalInc(totalIncome - incChargeTaxSplRate111A112)) + parseInt(taxAtSpecialRates);

	var normalInc = getSlabbedIncome(parseInt(totalIncome - incChargeTaxSplRate111A112));


	if( rndOffNrsTen(totInc) > 5000000 && rndOffNrsTen(totInc) <= 10000000 ){

		var toBeTaxed = 5000000 - coalesce(dtaaInc);
	}else if ( rndOffNrsTen(totInc) > 10000000 && rndOffNrsTen(totInc) < 20000000) {
		var toBeTaxed = 10000000 - coalesce(dtaaInc);
	}
	else if ( rndOffNrsTen(totInc)> 20000000 && rndOffNrsTen(totInc)< 50000000) {
		var toBeTaxed = 20000000 - coalesce(dtaaInc);
	}
	else if ( rndOffNrsTen(totInc)> 50000000) {
		var toBeTaxed = 50000000 - coalesce(dtaaInc);
	}
	else 
	{
		var toBeTaxed = 10000000 - coalesce(dtaaInc);
	}

	var rowCount1 = countRowInTable('scheduleSI.splCodeRateTax', 'splRateInc');

	var percent5SIInc = 0;

	var percent10SIInc = 0;

	var percent15SIInc = 0;

	var percent20SIInc = 0;

	var percent125SIInc = 0;

	var percent25SIInc = 0;

	var percent30SIInc = 0;

	var percent50SIInc = 0;

	var percent60SIInc= 0;


	for ( var i = 0; i < rowCount1; i++) {

		var splCodeValue = document
		.getElementsByName('scheduleSI.splCodeRateTax[' + i
				+ '].splRateInc')[0].value;
		var splRatePercent = document
		.getElementsByName('scheduleSI.splCodeRateTax[' + i
				+ '].splRatePercent')[0].value;

		if (splRatePercent == 5) {

			percent5SIInc = eval(parseInt(percent5SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		} else if (splRatePercent == 10) {

			percent10SIInc = eval(parseInt(percent10SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		} else if (splRatePercent == 12.5) {

			percent125SIInc = eval(parseInt(percent125SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		}else if (splRatePercent == 15) {

			percent15SIInc = eval(parseInt(percent15SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		} else if (splRatePercent == 20) {

			percent20SIInc = eval(parseInt(percent20SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		} else if (splRatePercent == 25) {

			percent25SIInc = eval(parseInt(percent25SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		} else if (splRatePercent == 30) {

			percent30SIInc = eval(parseInt(percent30SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));

		}else if (splRatePercent == 60) {

			percent60SIInc = eval(parseInt(percent60SIInc, 10)
					+ parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax[' + i
									+ '].taxableInc')[0].value, 10));
		}
	}

	var cgTax = 0;

	var cgTaxed = 0;

	/*	var exmptn10 = coalesceSetRet('scheduleSI.splCodeRateTax[3].splRateInc') + coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateInc') -
	coalesceSetRet('scheduleSI.splCodeRateTax[3].taxableInc')-coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc');*/

	var splCodeValuePti112a=0;
	var taxableIncPti112a=0;
	var rowCount1 = countRowInTable('scheduleSI.splCodeRateTax', 'splRateInc');
	for (var i = 12; i < rowCount1; i++) {
		var secCode = document
		.getElementsByName('scheduleSI.splCodeRateTax[' + i
				+ '].secCode')[0].value;
		if (secCode == 'PTI_LTCG10P112A') {
			splCodeValuePti112a = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateInc');
			taxableIncPti112a=coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
		}
	}
	var exmptn10 = coalesceSetRet('scheduleSI.splCodeRateTax[3].splRateInc')+coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateInc') + splCodeValuePti112a
	- coalesceSetRet('scheduleSI.splCodeRateTax[3].taxableInc')-coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc') - taxableIncPti112a;





	var temp112A =0;
	if(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'))<=100000){
		temp112A = 0;
	}else{
		temp112A = parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'))-parseInt(100000);
	}
	var rowCount1 = countRowInTable('scheduleSI.splCodeRateTax', 'splRateInc');
	var taxableInc112A=parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'));
	var taxableIncPti112A=0;
	var tempPti112A = 0;
	for (var i = 12; i < rowCount1; i++) {
		var secCode = document
				.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].secCode')[0].value;
		var splCodeValue = document
				.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].splRateInc')[0].value;
		var splRatePercent = document
				.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].splRatePercent')[0].value;
		var splRateIncTaxPti112A = document
				.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].splRateIncTax')[0].value;
		if (secCode == 'PTI_LTCG10P112A') {
			if (taxableInc112A <= 100000) {
				taxableIncPti112A=document.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].taxableInc')[0].value;
				var exmp = parseInt('100000', 10) - parseInt(coalesce(taxableInc112A));
				if (parseInt(document
						.getElementsByName('scheduleSI.splCodeRateTax[' + i
								+ '].taxableInc')[0].value) <= exmp) {
					tempPti112A = 0;
				} else {
					tempPti112A = parseInt(document
							.getElementsByName('scheduleSI.splCodeRateTax['
									+ i + '].taxableInc')[0].value)
							- exmp;
				}
			} 
		}
	}
	
	var temp115ADp =0;
	if(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[10].taxableInc'))<=100000){
		temp115ADp = 0;
	}else{
		temp115ADp = parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[10].taxableInc'))-parseInt(100000);
	}

	var exemption1125Ad = (-(parseInt(coalesce(taxableIncPti112A)))+tempPti112A) + (-(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'))+temp112A) + (-(coalesceSetRet('scheduleSI.splCodeRateTax[10].taxableInc'))+temp115ADp);

	var exmptn15 = coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateInc') -
	coalesceSetRet('scheduleSI.splCodeRateTax[1].taxableInc');

	var exmptn20 = coalesceSetRet('scheduleSI.splCodeRateTax[2].splRateInc') -
	coalesceSetRet('scheduleSI.splCodeRateTax[2].taxableInc');

	var exemption = getExemption() - exmptn10 - exmptn15 - exmptn20;


	var normal10Tax = 0;

	var normal20Tax = 0;

	var normal30Tax = 0;

	var exemptionUsed = 0;

	if (parseInt(totalIncome - incChargeTaxSplRate111A112) > 0) {
		if (parseInt(totalIncome - incChargeTaxSplRate111A112) >= getExemption()) {
			exemptionUsed = getExemption();
		} else {
			exemptionUsed = parseInt(totalIncome - incChargeTaxSplRate111A112);
		}

	}



	toBeTaxed = zeroOrMore(parseInt(toBeTaxed - exemptionUsed - exmptn10 - exmptn15 - exmptn20));


	percent5SIInc = parseInt(percent5SIInc, 10)+ parseInt(normalInc["5"], 10);

	if (parseInt(percent5SIInc, 10) < parseInt(toBeTaxed, 0)) {

		cgTax = parseInt(cgTax, 10) + (percent5SIInc) * 0.05;
		cgTaxed = parseInt(cgTaxed) + percent5SIInc;
		toBeTaxed -= parseInt(percent5SIInc, 0);
	} else {

		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * 0.05;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}


	percent10SIInc = parseInt(percent10SIInc, 10)+ parseInt(normalInc["10"], 10);


	if (parseInt(percent10SIInc, 10) < parseInt(toBeTaxed, 0)) {


		cgTax = parseInt(cgTax, 10) + (percent10SIInc+exemption1125Ad) * 0.1;
		cgTaxed = parseInt(cgTaxed) + percent10SIInc;
		toBeTaxed -= parseInt(percent10SIInc, 0);
	} else {


		cgTax = parseInt(cgTax, 10) + (toBeTaxed+exemption1125Ad) * 0.1;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}


	if (parseInt(percent125SIInc, 10) < parseInt(toBeTaxed, 0)) {
		cgTax = parseInt(cgTax, 10) + (percent125SIInc) *parseFloat(0.125);
		cgTaxed = parseInt(cgTaxed) + percent125SIInc;
		toBeTaxed -= parseInt(percent125SIInc, 0);
	} else {
		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * parseFloat(0.125);
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}

	if (parseInt(percent15SIInc, 10) < parseInt(toBeTaxed, 0)) {
		cgTax = parseInt(cgTax, 10) + (percent15SIInc) * parseFloat(0.15);
		cgTaxed = parseInt(cgTaxed) + percent15SIInc;
		toBeTaxed -= parseInt(percent15SIInc, 0);
	} else {
		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * parseFloat(0.15);
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}


	percent20SIInc = parseInt(percent20SIInc, 10) + parseInt(normalInc["20"], 10);

	if (parseInt(percent20SIInc, 10) < parseInt(toBeTaxed, 0)) {


		cgTax = parseInt(cgTax, 10) + (percent20SIInc) * 0.2;
		cgTaxed = parseInt(cgTaxed) + percent20SIInc;
		toBeTaxed -= parseInt(percent20SIInc, 0);
	} else {


		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * 0.2;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}



	if (parseInt(percent25SIInc, 10) < parseInt(toBeTaxed, 0)) {
		cgTax = parseInt(cgTax, 10) + (percent25SIInc) * 0.25;
		cgTaxed = parseInt(cgTaxed) + percent25SIInc;
		toBeTaxed -= parseInt(percent25SIInc, 0);
	} else {
		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * 0.25;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}

	percent30SIInc = parseInt(percent30SIInc, 10)
	+ parseInt(normalInc["30"], 10);


	if (parseInt(percent30SIInc, 10) < parseInt(toBeTaxed, 0)) {


		cgTax = parseInt(cgTax, 10) + (percent30SIInc) * 0.3;
		cgTaxed = parseInt(cgTaxed) + percent30SIInc;
		toBeTaxed -= parseInt(percent30SIInc, 0);
	} else {


		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * 0.3;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}

	if (parseInt(normalInc["40"], 10) < parseInt(toBeTaxed, 0)) {
		cgTax = parseInt(cgTax, 10) + (normalInc["40"]) * 0.4;
		cgTaxed = parseInt(cgTaxed) + normalInc["40"];
		toBeTaxed -= parseInt(normalInc["40"], 0);
	} else {
		cgTax = parseInt(cgTax, 10) + (toBeTaxed) * 0.4;
		cgTaxed = parseInt(cgTaxed) + toBeTaxed;
		toBeTaxed = 0;
	}

	//Added for 5BBE 60%

	percent60SIInc= parseInt(percent60SIInc,10);

	var taxbefore60per = parseInt(coalesce(cgTax));


	if(parseInt(percent60SIInc, 10) < parseInt(toBeTaxed, 0)){
		cgTax =  parseInt(cgTax, 10)+(percent60SIInc) * 0.60 * 1.25;
		cgTaxed = parseInt(cgTaxed)+ percent60SIInc;
		toBeTaxed -= parseInt(percent60SIInc, 0);
	}else{
		cgTax = parseInt(cgTax, 10)+ (toBeTaxed ) * 0.60 * 1.25;
		cgTaxed = parseInt(cgTaxed)+toBeTaxed;
		toBeTaxed = 0;
	}

	var taxOnCutOffInc = eval(parseInt(coalesce(cgTax)) + parseInt(coalesce(dtaaTax)));



	//start
	var rowCount1 = countRowInTable('scheduleSI.splCodeRateTax', 'splRateInc');
	var taxableIncPti112a=0;
	var splRateIncTaxPti112a=0;
	var taxableInc115AD1bii=0;
	var splRateIncTax115AD1bii=0;
	var taxableIncPtiStcg15=0;
	var splRateIncTaxPtiStcg15=0;
	var taxableIncPtiStcg30=0;
	var splRateIncTaxPtiStcg30=0;
	var taxableInc5ADiii=0;
	var splRateIncTax5ADiii=0;
	for (var i = 12; i < rowCount1; i++) {
		var secCode = document
		.getElementsByName('scheduleSI.splCodeRateTax[' + i
				+ '].secCode')[0].value;
		if (secCode == 'PTI_LTCG10P112A') {
			taxableIncPti112a = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
			splRateIncTaxPti112a = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax');
		}
		if (secCode == '5AD1biip') {
			taxableInc115AD1bii = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
			splRateIncTax115AD1bii = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax');
		}
		if (secCode == 'PTI_STCG15P') {
			taxableIncPtiStcg15 = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
			splRateIncTaxPtiStcg15 = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax');
		}
		if (secCode == 'PTI_STCG30P') {
			taxableIncPtiStcg30 = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
			splRateIncTaxPtiStcg30 = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax');
		}
		if (secCode == '5ADiii') {
			taxableInc5ADiii = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].taxableInc');
			splRateIncTax5ADiii = coalesceSetRet('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax');
		}
	}


	if((rndOffNrsTen(totInc) > 10000000 ) && (statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "17" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")) ||(statusCompany == "1" && (substatusCompany == "5" || substatusCompany == "10"))))
	{

		var surchargeRate = 0.12;

		//For 115BBE
		var f_115BBE = eval(parseInt(
				coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
				10)
				- ((parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),10)+parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
						10)) * 0.60));


		var tempSurcharge = eval((surchargeRate * parseInt(f_115BBE, 10))
				+ ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60 * 0.25));



		//check if eligible for marginal relief

		var extraInc = rndOffNrsTen(totInc) - 10000000;



		var surchargeOn1Cr = taxbefore60per*0.1;
		if(statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "17" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")) ||(statusCompany == "1" && (substatusCompany == "5" || substatusCompany == "10")))
		{

			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc)){
				var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc));
				surcharge = zeroOrMore(tempSurcharge - marginalRelief);
				surcharge  = Math.round(surcharge);



			}else {
				surcharge = tempSurcharge;

				surcharge  = Math.round(surcharge);
			}
		}else
		{

			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc + surchargeOn1Cr)){



				var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc + surchargeOn1Cr));





				surcharge = zeroOrMore(tempSurcharge - marginalRelief);
				surcharge  = Math.round(surcharge);

			}else {
				surcharge = tempSurcharge;
				surcharge  = Math.round(surcharge);
			}
		}

	}
	else if( statusCompany == "9" || (statusCompany == "14" && (substatusCompany == "8" || substatusCompany == "13" || substatusCompany == "11"  || substatusCompany == "13" || substatusCompany == "11" || substatusCompany == "20" || substatusCompany == "21")) )
	{
		if(rndOffNrsTen(totInc) > 20000000)
		{
			var inc115ad1ii=coalesceSetRet('scheduleSI.splCodeRateTax[7].taxableInc');
			var inc115ADiiiP=coalesceSetRet('scheduleSI.splCodeRateTax[10].taxableInc');
			var tax115ad1ii =coalesceSetRet('scheduleSI.splCodeRateTax[7].splRateIncTax');
			var tax115ADiiiP =coalesceSetRet('scheduleSI.splCodeRateTax[10].splRateIncTax');
			var f_111_112A=eval(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].taxableInc'),10)+
			parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'),10)+
			parseInt(inc115ad1ii,10)+
			parseInt(inc115ADiiiP,10)+
			parseInt(taxableInc115AD1bii,10)+
			parseInt(taxableIncPtiStcg15,10)+
			parseInt(taxableIncPtiStcg30,10)+
			parseInt(taxableInc5ADiii,10)+
			parseInt(taxableIncPti112a,10));
			
			var f_111_112A_Othr=eval(parseInt(totInc,10)
					-((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].taxableInc'),10)+
					parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].taxableInc'),10)+
					parseInt(inc115ad1ii,10)+
					parseInt(inc115ADiiiP,10)+
					parseInt(taxableInc115AD1bii,10)+
					parseInt(taxableIncPtiStcg15,10)+
					parseInt(taxableIncPtiStcg30,10)+
					parseInt(taxableInc5ADiii,10)+
					parseInt(taxableIncPti112a,10))));
			
			if(f_111_112A==0 && rndOffNrsTen(totInc) > 20000000 && rndOffNrsTen(totInc) <= 50000000)
			{
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.25 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25));
				console.log("tempSurcharge"+tempSurcharge);

				var extraInc = rndOffNrsTen(totInc) - 20000000;

				console.log("extraInc"+extraInc);

				var surofTaxon1cr = taxbefore60per * 0.15; // surcharge on 1 Cr tax
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);

				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A==0 && rndOffNrsTen(totInc) > 50000000)
			{

				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.37 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25));
				console.log("tempSurcharge"+tempSurcharge);

				var extraInc = rndOffNrsTen(totInc) - 50000000;

				console.log("extraInc"+extraInc);

				var surofTaxon1cr = taxbefore60per * 0.25; // surcharge on 1 Cr tax
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);

				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A>0  && f_111_112A_Othr <= 20000000 && (parseInt(f_111_112A,10)+parseInt(f_111_112A_Othr,10))<=50000000)
			{
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60) -(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.15 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25)+ ((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
			parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
			parseInt(tax115ad1ii,10)+
			parseInt(tax115ADiiiP,10)+
			parseInt(splRateIncTax115AD1bii,10)+
			parseInt(splRateIncTaxPtiStcg15,10)+
			parseInt(splRateIncTaxPtiStcg30,10)+
			parseInt(splRateIncTax5ADiii,10)+
			parseInt(splRateIncTaxPti112a,10)) * 0.15));
				console.log("tempSurcharge"+tempSurcharge);

				var extraInc = rndOffNrsTen(totInc) - 20000000;

				console.log("extraInc"+extraInc);
				
				var surofTaxon1cr = taxbefore60per * 0.15; // surcharge on 1 Cr tax
				
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);
					
				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A>0  && f_111_112A_Othr <= 20000000 && (parseInt(f_111_112A,10)+parseInt(f_111_112A_Othr,10))>50000000)
			{
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60) -(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.15 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25)+ ((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)) * 0.15));
				console.log("tempSurcharge"+tempSurcharge);

				var extraInc = rndOffNrsTen(totInc) - 50000000;

				console.log("extraInc"+extraInc);
				
				var surofTaxon1cr = taxbefore60per * 0.15; // surcharge on 1 Cr tax
				
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);
					
				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A>0 && f_111_112A_Othr > 20000000 && f_111_112A_Othr <= 50000000 && (parseInt(f_111_112A,10)+parseInt(f_111_112A_Othr,10))<=50000000)
			{
				
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60) -(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				
				var tempSurcharge = eval((0.25 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25) + ((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)) * 0.15)) ;
				console.log("tempSurcharge"+tempSurcharge);
				
				var extraInc = rndOffNrsTen(totInc) - 20000000;

				console.log("extraInc"+extraInc);

				var surofTaxon1cr = taxbefore60per * 0.15;// surcharge on 1 Cr tax
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);

				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A>0 && f_111_112A_Othr > 20000000 && f_111_112A_Othr <= 50000000 && (parseInt(f_111_112A,10)+parseInt(f_111_112A_Othr,10))>50000000)
			{
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60) -(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.25 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25) + ((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)) * 0.15)) ;
				console.log("tempSurcharge"+tempSurcharge);
				var extraInc = rndOffNrsTen(totInc) - 50000000;

				console.log("extraInc"+extraInc);
				var surofTaxon1cr=0;
				var temp= eval(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
			parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
			parseInt(tax115ad1ii,10)+
			parseInt(tax115ADiiiP,10)+
			parseInt(splRateIncTax115AD1bii,10)+
			parseInt(splRateIncTaxPtiStcg15,10)+
			parseInt(splRateIncTaxPtiStcg30,10)+
			parseInt(splRateIncTax5ADiii,10)+
			parseInt(splRateIncTaxPti112a,10));
				if((parseInt('50000000',10)-parseInt(f_111_112A,10)) > 20000000)
				{
					 surofTaxon1cr = eval(((parseInt(taxbefore60per,10)-parseInt(temp,10))*0.25)+ parseInt(temp,10)*0.15);// surcharge on 1 Cr tax
				}
				else
				{
					 surofTaxon1cr = taxbefore60per * 0.15;// surcharge on 1 Cr tax
				}
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);

				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
			else if(f_111_112A>0 && f_111_112A_Othr >  50000000)
			{
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60)-(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10)));
				console.log("f_115BBE"+f_115BBE);
				var tem = ((parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
						10)+parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
								10)) * 0.60);
				console.log("tem"+tem);
				var tempSurcharge = eval((0.37 * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25) + ((parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
												parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
												parseInt(tax115ad1ii,10)+
												parseInt(tax115ADiiiP,10)+
												parseInt(splRateIncTax115AD1bii,10)+
												parseInt(splRateIncTaxPtiStcg15,10)+
												parseInt(splRateIncTaxPtiStcg30,10)+
												parseInt(splRateIncTax5ADiii,10)+
												parseInt(splRateIncTaxPti112a,10))* 0.15)) ;
				console.log("tempSurcharge"+tempSurcharge);

				var extraInc = rndOffNrsTen(totInc) - 50000000;

				console.log("extraInc"+extraInc);
				var temp= eval(parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[1].splRateIncTax'),10)+
						parseInt(coalesceSetRet('scheduleSI.splCodeRateTax[5].splRateIncTax'),10)+
						parseInt(tax115ad1ii,10)+
						parseInt(tax115ADiiiP,10)+
						parseInt(splRateIncTax115AD1bii,10)+
						parseInt(splRateIncTaxPtiStcg15,10)+
						parseInt(splRateIncTaxPtiStcg30,10)+
						parseInt(splRateIncTax5ADiii,10)+
						parseInt(splRateIncTaxPti112a,10));
				if((parseInt('50000000',10)-parseInt(f_111_112A,10)) > 20000000)
				{
					var surofTaxon1cr = eval(((parseInt(taxbefore60per,10)-parseInt(temp,10))*0.25)+ parseInt(temp,10)*0.15);// surcharge on 1 Cr tax
				}
				else
				{
					var surofTaxon1cr = taxbefore60per * 0.15;// surcharge on 1 Cr tax
				}
				console.log("surchargea"+surcharge);
				if ((taxOnTotInc + tempSurcharge) > (taxOnCutOffInc + extraInc + surofTaxon1cr)) {
					console.log("surchargeaasdad");
					console.log("taxOnTotInc"+taxOnTotInc);
					console.log("tempSurcharge"+tempSurcharge);
					console.log("taxOnCutOffInc"+taxOnCutOffInc);
					console.log("extraInc"+extraInc);
					console.log("surofTaxon1cr"+surofTaxon1cr);

					var totaltax1 = eval(parseInt(coalesce(tempSurcharge))
							+ parseInt(coalesce(taxOnTotInc)));

					var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge
							- (taxOnCutOffInc + extraInc + surofTaxon1cr));

					surcharge = zeroOrMore(tempSurcharge - marginalRelief);
					surcharge = Math.round(surcharge);

				} else {
					console.log("surchargeb"+surcharge);
					surcharge = tempSurcharge;
					surcharge = Math.round(surcharge);
				}
				console.log("surchargec"+surcharge);
			}
		}
		else if(rndOffNrsTen(totInc) > 10000000 && rndOffNrsTen(totInc) <= 20000000)
		{
			var surchargeRate = 0.15;

				//For 115BBE
				var f_115BBE = eval(parseInt(
						coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),
						10)
						- ((parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),10)+parseInt(
							coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
							10)) * 0.60));


				var tempSurcharge = eval((surchargeRate * parseInt(f_115BBE, 10))
						+ ((parseInt(
								coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
								10)+parseInt(
										coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
										10)) * 0.60 * 0.25));



				//check if eligible for marginal relief

				var extraInc = rndOffNrsTen(totInc) - 10000000;



				var surchargeOn1Cr = taxbefore60per*0.1;
				if(statusCompany == "1" || statusCompany == "2" || (statusCompany == "14" && (substatusCompany == "17" || substatusCompany == "15" || substatusCompany == "16" || substatusCompany == "4")))
					{

							if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc)){
								var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc));
								surcharge = zeroOrMore(tempSurcharge - marginalRelief);
								surcharge  = Math.round(surcharge);

							

							}else {
								surcharge = tempSurcharge;

								surcharge  = Math.round(surcharge);
								}
					}else
						{

								if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc + surchargeOn1Cr)){
									
									
									
									var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc + surchargeOn1Cr));
									
								
									
									

									surcharge = zeroOrMore(tempSurcharge - marginalRelief);
									surcharge  = Math.round(surcharge);
									
								}else {
									surcharge = tempSurcharge;
									surcharge  = Math.round(surcharge);
									}
						}
		}
		else if(rndOffNrsTen(totInc) > 5000000 && rndOffNrsTen(totInc) <= 10000000)
		{

			var surchargeRate = 0.10;

			//For 115BBE
			var f_115BBE = eval(parseInt(
					coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc'),10)
									- ((parseInt(
				coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
				10)+parseInt(
						coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
						10)) * 0.60));

			var tempSurcharge = eval((0.10 * parseInt(f_115BBE, 10))				+ ((parseInt(
					coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),
					10)+parseInt(
							coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI'),
							10)) * 0.60 * 0.25));


			//check if eligible for marginal relief
			var extraInc = rndOffNrsTen(totInc) - 5000000;




			if( (taxOnTotInc + tempSurcharge ) > (taxOnCutOffInc + extraInc)){

				var marginalRelief = zeroOrMore(taxOnTotInc + tempSurcharge - (taxOnCutOffInc + extraInc));

				surcharge = zeroOrMore(tempSurcharge - marginalRelief);
				surcharge  = Math.round(surcharge);


			}else {
				surcharge = tempSurcharge;
				surcharge  = Math.round(surcharge);
				}

	}
	}
	else {

		surcharge = parseInt('0' ,10);
	}



	setEditableFieldValue(surchargeOnAboveCrore, surcharge);

	var surcharge2F = zeroOrMore(eval(surcharge-
			(parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),10) * 0.60* 0.25)));

	setEditableFieldValue(surchargeOn2F, surcharge2F);
}

function calculatePartBTTI_second(cgosIncome)
{
	try{

		surcharge201718();
		//1
		var totalTax = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.totalTax')[0];
		//4
		var grossTaxLiability = document.getElementsByName('partBTTI.computationOfTaxLiability.grossTaxLiability')[0];

		//5
		var grossTaxPayable = document.getElementsByName('partBTTI.computationOfTaxLiability.grossTaxPayable')[0];

		//6
		var credUs115JAATaxPaid = document.getElementsByName('partBTTI.computationOfTaxLiability.creditUS115JD')[0];
		if(parseInt(grossTaxLiability.value,10) > parseInt(totalTax.value,10)){

			credUs115JAATaxPaid.value = coalesceSetRet('scheduleAMTC.taxSection115JD');
		}else{
			credUs115JAATaxPaid.value = 0;
		}

		//7
		var taxPaidUnderCredit = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPaidUnderCredit')[0];
		taxPaidUnderCredit.value = zeroOrMore(eval(parseInt(grossTaxPayable.value,10)
				- parseInt(credUs115JAATaxPaid.value,10)));

		//8
		var section90 = document.getElementsByName('partBTTI.computationOfTaxLiability.taxRelief.section90')[0];
		section90.value = eval(
				parseInt(coalesceSetRet('scheduleTR1.totalIncomeOutIndia'),10)
		);
		var section91 = document.getElementsByName('partBTTI.computationOfTaxLiability.taxRelief.section91')[0];
		section91.value = eval(
				parseInt(coalesceSetRet('scheduleTR1.totalIncomeOutIndiaDTAA'),10)
		);
		var totTaxRelief = document.getElementsByName('partBTTI.computationOfTaxLiability.taxRelief.totTaxRelief')[0];
		totTaxRelief.value = eval(	parseInt(section90.value,10)
				+ parseInt(section91.value,10));

		//9
		var netTaxLiability = document.getElementsByName('partBTTI.computationOfTaxLiability.netTaxLiability')[0];
		netTaxLiability.value = zeroOrMore(eval(
				parseInt(taxPaidUnderCredit.value,10)
				- parseInt(totTaxRelief.value,10)	));

		//12

		calculateAdvancedTax();
		calculateTDS();
		calculateTCS();


		var totalTaxesPaid = document.getElementsByName('partBTTI.taxPaid.taxesPaid.totalTaxesPaid')[0];
		totalTaxesPaid.value = eval(
				parseInt(coalesceSetRet('partBTTI.taxPaid.taxesPaid.advanceTax'),10)
				+ parseInt(coalesceSetRet('partBTTI.taxPaid.taxesPaid.selfAssessmentTax'),10)
				+ parseInt(coalesceSetRet('partBTTI.taxPaid.taxesPaid.tds'),10)
				+ parseInt(coalesceSetRet('partBTTI.taxPaid.taxesPaid.tcs'),10)
		);

		//10
		calcInterestPayable(cgosIncome);

		var totIntrstPay = document.getElementsByName('partBTTI.computationOfTaxLiability.intrstPay.totalIntrstPay')[0]; totIntrstPay.value = coalesce(totIntrstPay.value);

		//11
		var aggregateTaxInterestLiability = document.getElementsByName('partBTTI.computationOfTaxLiability.aggregateTaxInterestLiability')[0]; aggregateTaxInterestLiability.value = coalesce(aggregateTaxInterestLiability.value);
		aggregateTaxInterestLiability.value = eval(netTaxLiability.value) + eval(totIntrstPay.value);

		//13
		var balTaxPayable = document.getElementsByName('partBTTI.taxPaid.balTaxPayable')[0];
		//14
		var refundsDue = document.getElementsByName('partBTTI.refundsDue')[0];

		var totFinalAmtPayorRefund = parseInt(aggregateTaxInterestLiability.value,10) - parseInt(totalTaxesPaid.value,10);

		if(zeroOrMore(totFinalAmtPayorRefund)){
			balTaxPayable.value =  rndOffNrsTen(Math.abs(totFinalAmtPayorRefund));
			refundsDue.value = parseInt(0,10);
		}else{
			balTaxPayable.value = parseInt(0,10);
			refundsDue.value =  rndOffNrsTen(Math.abs(totFinalAmtPayorRefund));
		}

		showEpay();

	}catch(e){
		alert('calculatePartBTTI_second:' + e.stack);
	}
}


function calculateAdvancedTax(){
	var advanceTax = parseInt('0' ,10) ;
	var selfAssessmentTax = parseInt('0' ,10) ;
	var tab3 = document.getElementById('scheduleIt');
	var allInputTags = tab3.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if(allInputTags[i].name.match("dateDep$")){
			if(checkFirstDateBefore(FY_start_date , allInputTags[i].value) && checkFirstDateBefore(allInputTags[i].value , FY_end_date)){
				advanceTax = eval( parseInt(isNVL(advanceTax) ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
			}else if( checkFirstDateBefore(AY_start_date, allInputTags[i].value)){
				selfAssessmentTax = eval(parseInt(isNVL(selfAssessmentTax) ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10)) ;
			}
		}
	}
	document.getElementsByName('partBTTI.taxPaid.taxesPaid.advanceTax')[0].value = advanceTax;
	document.getElementsByName('partBTTI.taxPaid.taxesPaid.selfAssessmentTax')[0].value = selfAssessmentTax;
	return advanceTax;
}

function calculateAdvancedTax234A(date){
	var advanceTax = parseInt('0' ,10) ;
	var selfAssessmentTax = parseInt('0' ,10) ;
	var tab3 = document.getElementById('scheduleIt');
	var allInputTags = tab3.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if(allInputTags[i].name.match("dateDep$")){
			if(checkFirstDateBefore(AY_start_date , allInputTags[i].value) && checkFirstDateBefore(allInputTags[i].value , date)){
				advanceTax = eval( parseInt(isNVL(advanceTax) ,10) + parseInt(isNVL(allInputTags[i+2].value) ,10));
			}
		}
	}
	return advanceTax;
}
function calculate80P(){
	var tot80P=parseInt('0' ,10);
	var tot80PUser=parseInt('0' ,10);
	var tab1 = document.getElementById('Schedule80P');
	var allInputTags = tab1.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (!allInputTags[i].name.match("total$")) {
			if (allInputTags[i].name.match("usrDeductUndSec80P")) {
				tot80P = eval(parseInt(tot80P ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			}
		}
	}
	if(tot80P>=0){
		document.getElementsByName('schedule80P.usrDeductUndSec80P.total')[0].value = tot80P;
	}

	for(var i = 0; i < allInputTags.length; i++) {
		if (!allInputTags[i].name.match("total$")) {
			if (allInputTags[i].name.match("deductUndChap80P")) {
				tot80PUser = eval(parseInt(tot80PUser ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			}
		}
	}
	if(tot80PUser>=0){
		document.getElementsByName('schedule80P.deductUndChap80P.total')[0].value = tot80PUser;
	}
}


function calculateTDS2AmntFwd(el){

	try{
		var mainTab = document.getElementById('scheduleTDS2');
		var mainTabRows = mainTab.rows.length;

		var sum = 0;

		while ((el = el.parentNode) && el.nodeName.toLowerCase() !== 'tr')
			;
		if (el) {
			var index = el.rowIndex - 4;
		}
		for (var i = 0; i < mainTabRows - 6; i++) {
			if (i == index) {

				totTDSOnAmtPaid = document
				.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].totTDSOnAmtPaid')[0].value;

				taxDeductedOwnHands = document
				.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;

				taxDeductedTDS = document
				.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value;

				taxCreditedOwnHands = document
				.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0].value;

				taxCreditedTDS = document
				.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value;

				sum = zeroOrMore(eval(parseInt(sum, 10)
						+ parseInt(coalesce(totTDSOnAmtPaid), 10)
						+ parseInt(coalesce(taxDeductedOwnHands), 10)
						+ parseInt(coalesce(taxDeductedTDS), 10)
						- parseInt(coalesce(taxCreditedOwnHands), 10)
						- parseInt(coalesce(taxCreditedTDS), 10)));

				document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].amntCarryForward')[0].value = sum;

			}
		} }
	catch(e){

		alert(e.stack);
	}

}
function calculateTDS3AmntFwd(el){
	var mainTab = document.getElementById('scheduleTDS3');
	var mainTabRows = mainTab.rows.length;

	var sum = 0;

	while ((el = el.parentNode) && el.nodeName.toLowerCase() !== 'tr')
		;
	if (el) {
		var index = el.rowIndex - 4;
	}
	for (var i = 0; i < mainTabRows - 6; i++) {
		if (i == index) {

			totTDSOnAmtPaid = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].totTDSOnAmtPaid')[0].value;

			taxDeductedOwnHands = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;

			taxDeductedTDS = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value;

			taxCreditedOwnHands = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0].value;

			taxCreditedTDS = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value;

			sum = zeroOrMore(eval(parseInt(sum, 10)
					+ parseInt(coalesce(totTDSOnAmtPaid), 10)
					+ parseInt(coalesce(taxDeductedOwnHands), 10)
					+ parseInt(coalesce(taxDeductedTDS), 10)
					- parseInt(coalesce(taxCreditedOwnHands), 10)
					- parseInt(coalesce(taxCreditedTDS), 10)));

			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].amntCarryForward')[0].value = sum;

		}
	}
}
function populateMobileCodeonLoad()
{

	state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	if (state.value != '99' && state.value != '-1') {

		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].value = '91';
		//	document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].disabled = true;
	} else if (state.value == '99') {
		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobileNoSec')[0].disabled = false;
	}

}
function populateMobileCode()

{

	state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	if (state.value != '99' && state.value != '-1') {

		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].value = '91';
		//	document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].disabled = true;
	} else if (state.value == '99') {
		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].value = '';
		//	document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobile')[0].disabled = false;
		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobileNoSec')[0].value = '';
		document.getElementsByName('partAGEN1.personalInfo.address.countryCodeMobileNoSec')[0].disabled = false;
	}




}
/*function validateTCS(){
	var mainTab = document.getElementById('scheduleTCS');
	var mainTabRows = mainTab.rows.length;

	for (var i = 0; i < mainTabRows - 6; i++) {
			var taxDeductedOwnHands = document.getElementsByName('scheduleTCS.tcs[' + i + '].amountBF')[0].value;
			var totTDSOnAmtPaid = document.getElementsByName('scheduleTCS.tcs[' + i + '].totalTCS')[0].value ;
		if (taxDeductedOwnHands !='' && totTDSOnAmtPaid !=''){


			addErrorXHTML(
					'',
					'Unclaimed TCS brought forward and details of TCS of current FY should be provided in different rows');
			j.setFieldError('scheduleTCS.tcs[' + i + '].amountBF','Unclaimed TCS brought forward and details of TCS of current FY should be provided in different rows');


			}
	}

}*/
function validateTDS2(){

	var mainTab = document.getElementById('scheduleTDS2');
	var mainTabRows = mainTab.rows.length;

	for (var i = 0; i < mainTabRows - 6; i++) {
		var taxDeductedOwnHands = document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;
		var totTDSOnAmtPaid = document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i + '].totTDSOnAmtPaid')[0].value ;
		var totTDSOn32 = document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedTDS')[0].value ;
		if (taxDeductedOwnHands !='' && totTDSOnAmtPaid !=''){


			addErrorXHTML(
					'',
			'Unclaimed TDS brought forward and details of TDS of current FY should be provided in different rows in Sch TDS 1.');
			j.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i+ '].totTDSOnAmtPaid','Unclaimed TDS brought forward and details of TDS of current FY should be provided in different rows in Sch TDS 1.');


		}
		if (totTDSOnAmtPaid !='' && totTDSOn32 !=''){
			addErrorXHTML(
					'',
			'Unclaimed TDS brought forward and Income details of TDS Deducted in the hands of any other person as per rule 37BA(2) should be provided in different rows in Sch TDS 1');
			j.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedTDS','Unclaimed TDS brought forward and Income details of TDS Deducted in the hands of any other person as per rule 37BA(2) should be provided in different rows in Sch TDS 1');


		}
	}
}

function enableSch80p(){
	var tab1 = document.getElementById('Schedule80P');
	var allInputTags = tab1.getElementsByTagName('input');
	var allSelectTags = tab1.getElementsByTagName('select');

	var fileSection=document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;

	var substatusOrCompanyType=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var enableFlag=false;
	if((substatusOrCompanyType=='15'|| substatusOrCompanyType=='16'|| substatusOrCompanyType=='4')&& fileSection !='12')
	{
		enableFlag=true;
		for(var i = 0; i < allInputTags.length; i++) {
			if (!allInputTags[i].name.match("total$")) {
				allInputTags[i].readOnly=false;
			}
		}
		for(var i = 0; i < allSelectTags.length; i++) {
			allSelectTags[i].disabled=false;
		}
	}
	else{
		enableFlag=false;
		for(var i = 0; i < allInputTags.length; i++) {
			if (!allInputTags[i].name.match("total$")) {
				allInputTags[i].readOnly=true;
				allInputTags[i].value='';
			}
		}
		for(var i = 0; i < allSelectTags.length; i++) {
			allSelectTags[i].disabled=true;
			allSelectTags[i].value='';
		}

	}
		var table = document.getElementById('natOfBustTradeTableId');
		var rowCount = table.rows.length;

		var section1= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2aiCode')[0].value;
		var section2= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2aiiCode')[0].value;
		var section3= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2aiiiCode')[0].value;
		var section4= document.getElementsByName('schedule80P.coSocietyActSec80P.Sec80P2aivCode')[0].value;
		var section5= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2avCode')[0].value;
		var section6= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2aviCode')[0].value;
		var section7= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2aviiCode')[0].value;
		var section8= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2bCode')[0].value;
		var section9= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2ciCode')[0].value;
		var section10= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2ciiCode')[0].value;
		var section11= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2dCode')[0].value;
		var section12= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2eCode')[0].value;
		var section13= document.getElementsByName('schedule80P.coSocietyActSec80P.sec80P2fCode')[0].value;
		var section1Disabled=true;
		var section2Disabled=true;
		var section3Disabled=true;
		var section4Disabled=true;
		var section5Disabled=true;
		var section6Disabled=true;
		var section7Disabled=true;
		var section8Disabled=true;
		var section9Disabled=true;
		var section10Disabled=true;
		var section11Disabled=true;
		var section12Disabled=true;
		var section13Disabled=true;
		for(var i=0;i<rowCount-2;i++){
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section1)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0].readOnly=false;
				section1Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section2)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0].readOnly=false;
				section2Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section3)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0].readOnly=false;
				section3Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section4)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0].readOnly=false;
				section4Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section5)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0].readOnly=false;
				section5Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section6)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0].readOnly=false;
				section6Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section7)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0].readOnly=false;
				section7Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section8)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0].readOnly=false;
				section8Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section9)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0].readOnly=false;
				section9Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section10)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0].readOnly=false;
				section10Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section11)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0].readOnly=false;
				section11Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section12)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0].readOnly=false;
				section12Disabled = false;
			}
			if(enableFlag && document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value==section13)
			{
				document.getElementsByName('schedule80P.deductUndChap80P.others')[0].readOnly=false;
				section13Disabled = false;
			}
		}
		if(section1Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.bankCreditFacilties','Please enter Amount eligible for deduction in Schedule 80P');


			}
					}
		if(section2Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.cottageIndustry','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section3Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.marketingOfAgricture','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		
		if(section4Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.pruchaseOfAgricuture','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section5Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.processingOfAgriculture','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section6Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.collectiveDisposal','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section7Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.fishingActivities','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section8Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.primaryCooperative','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section9Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.cosumerCooperative','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section10Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.cooperativeSociety','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section11Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.interestFromInvestment','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section12Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.incomeFromLetting','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
		if(section13Disabled)
		{
			document.getElementsByName('schedule80P.deductUndChap80P.others')[0].readOnly=true;
			document.getElementsByName('schedule80P.deductUndChap80P.others')[0].value='';
		}
		else
		{
			if(document.getElementsByName('schedule80P.deductUndChap80P.others')[0].value=='')
			{
				addErrorXHTML(document.getElementsByName('schedule80P.deductUndChap80P.others')[0],'Please enter Amount eligible for deduction in Schedule 80P');
				j.setFieldError('schedule80P.deductUndChap80P.others','Please enter Amount eligible for deduction in Schedule 80P');


			}
		}
	
}



function validateTDS3(){

	var mainTab = document.getElementById('scheduleTDS3');
	var mainTabRows = mainTab.rows.length;


	for (var i = 0; i < mainTabRows - 6; i++) {

		var taxDeductedOwnHands = document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;
		var totTDSOnAmtPaid = document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i + '].totTDSOnAmtPaid')[0].value ;
		var totTDSon32 = document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedTDS')[0].value ;
		if (taxDeductedOwnHands !='' && totTDSOnAmtPaid !=''){

			addErrorXHTML(
					'',
			'Unclaimed TDS brought forward and details of TDS of current FY should be provided in different rows in Sch TDS 2.');
			j.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i+ '].totTDSOnAmtPaid','Unclaimed TDS brought forward and details of TDS of current FY should be provided in different rows in Sch TDS 2.');



		}
		if (totTDSOnAmtPaid !='' && totTDSon32 !=''){

			addErrorXHTML(
					'',
			'Unclaimed TDS brought forward and Income details of TDS Deducted in the hands of any other person as per rule 37BA(2) should be provided in different rows in Sch TDS 2');
			j.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i + '].taxDeductCreditDtls.taxDeductedTDS','Unclaimed TDS brought forward and Income details of TDS Deducted in the hands of any other person as per rule 37BA(2) should be provided in different rows in Sch TDS 2');



		}
	}
}

function calculateTDS(){

	var TDS = parseInt('0',10);
	var TDS2 = parseInt('0' ,10);
	var tab1 = document.getElementById('scheduleTDS2');
	var allInputTags = tab1.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("taxCreditedOwnHands$")) {
			/*if(eval(parseInt(coalesce(allInputTags[i].value),10)) >  eval(parseInt(coalesce(allInputTags[i-1].value),10) + parseInt(coalesce(allInputTags[i-2].value),10))){
						addError(allInputTags[i],'Amount claimed for this year cannot be more than total tax deducted',true);
						j.setFieldError(allInputTags[i].name,'Amount claimed for this year cannot be more than total tax deducted');
						TDS2 = eval(parseInt(TDS2 ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
					}else{*/
			TDS2 = eval(parseInt(TDS2 ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			/*}
					allInputTags[i+1].value = zeroOrMore(parseInt(coalesce(allInputTags[i-2].value)) + parseInt(coalesce(allInputTags[i-1].value))
					- parseInt(coalesce(allInputTags[i].value)));*/
		}
	}

	var TDS3 = parseInt('0' ,10);
	var tab1 = document.getElementById('scheduleTDS3');
	var allInputTags = tab1.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("taxCreditedOwnHands$")) {
			/*if(eval(parseInt(coalesce(allInputTags[i].value),10)) >  eval(parseInt(coalesce(allInputTags[i-1].value),10) + parseInt(coalesce(allInputTags[i-2].value),10))){
						addError(allInputTags[i],'Amount claimed for this year cannot be more than total tax deducted',true);
						j.setFieldError(allInputTags[i].name,'Amount claimed for this year cannot be more than total tax deducted');
						TDS2 = eval(parseInt(TDS2 ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
					}else{*/
			TDS3 = eval(parseInt(TDS3 ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
			/*}
					allInputTags[i+1].value = zeroOrMore(parseInt(coalesce(allInputTags[i-2].value)) + parseInt(coalesce(allInputTags[i-1].value))
					- parseInt(coalesce(allInputTags[i].value)));*/
		}
	}



	TDS=eval(parseInt(TDS2,10)+parseInt(TDS3,10));
	document.getElementsByName('partBTTI.taxPaid.taxesPaid.tds')[0].value = TDS;
	/*
	document.getElementsByName('scheduleTDS3.tdSonOthThanSal.totalTDSonOthThanSals')[0].value = parseInt(TDS3,10);*/
	return TDS;
}

function calcTotalTDS2()
{

	var tdsTable = document.getElementById('scheduleTDS2');
	var noOfRows = tdsTable.rows.length;

	var sum = 0;

	for (var i = 0; i < (noOfRows - 6); i++) {

		var taxCreditedOwnHands =  document
		.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i + '].taxDeductCreditDtls.taxCreditedOwnHands')[0].value;

		sum = eval(parseInt(sum, 10) + parseInt(coalesce(taxCreditedOwnHands), 10));

	}

	document.getElementsByName('scheduleTDS2.tdSonOthThanSal.totalTDSonOthThanSals')[0].value = sum;

}


function calcTotalTDS3()
{

	var tdsTable = document.getElementById('scheduleTDS3');
	var noOfRows = tdsTable.rows.length;

	var sum = 0;

	for (var i = 0; i < (noOfRows - 6); i++) {

		var taxCreditedOwnHands =  document
		.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i	+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0].value;

		sum = eval(parseInt(sum, 10) + parseInt(coalesce(taxCreditedOwnHands), 10));

	}

	document.getElementsByName('scheduleTDS3.tDS3onOthThanSal.totalTDS3OnOthThanSal')[0].value = sum;

}
function validateTDS29Grtthen67() {

	var mainTab = document.getElementById('scheduleTDS2');

	var mainTabRows = mainTab.rows.length;

	for (var i = 0; i < mainTabRows - 6; i++) {

		tDSCreditName = document.getElementsByName('scheduleTDS2.tdSonOthThanSal['
				+ i + '].tDSCreditName')[0].value;

		if (tDSCreditName == 'S') {

			var amt6 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].totTDSOnAmtPaid')[0].value;

			var amt7 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;

			var amt9 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0];

			var tempVal = eval(parseInt(coalesce(amt6),10) + parseInt(coalesce(amt7),10));

			if (amt9.value > tempVal) {
				j
				.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedOwnHands',
				'Amount entered in Column (10) cannot be more than amount entered in Column (7) or TDS field of Column (9) in Schedule TDS 1');				addErrorXHTML(
						document
						.getElementsByName('scheduleTDS2.tdSonOthThanSal['
								+ i
								+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0],
								'Amount in Col (10) cannot be more than the amount entered in Col (7) or col (8) in Schedule TDS 1',
								true);
			}
		}
		else
		{
			var amt6 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].totTDSOnAmtPaid')[0].value;

			var amt8 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value;

			var amt9 = document
			.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0];

			var tempVal =  eval(parseInt(coalesce(amt6),10) + parseInt(coalesce(amt8),10));

			if (amt9.value > tempVal) {
				j
				.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedOwnHands',
				'Amount entered in Column (10) cannot be more than amount entered in Column (7) or TDS field of Column (9) in Schedule TDS 1');
				addErrorXHTML(
						document
						.getElementsByName('scheduleTDS2.tdSonOthThanSal['
								+ i
								+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0],
								'Amount entered in Column (10) cannot be more than amount entered in Column (7) or TDS field of Column (9) in Schedule TDS 1',
								true);
			}


		}
	}
}


function validateTDS39Grtthen67() {

	var mainTab = document.getElementById('scheduleTDS3');

	var mainTabRows = mainTab.rows.length;

	for (var i = 0; i < mainTabRows - 6; i++) {

		tDSCreditName = document.getElementsByName('scheduleTDS3.tDS3onOthThanSal['
				+ i + '].tDSCreditName')[0].value;

		if (tDSCreditName == 'S') {

			var amt6 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].totTDSOnAmtPaid')[0].value;


			var amt7 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value;

			var amt9 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0];

			var tempVal = eval(parseInt(coalesce(amt6),10) + parseInt(coalesce(amt7),10));

			if (amt9.value > tempVal) {
				j
				.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedOwnHands',
				'Amount in Col (11) cannot be more than the amount entered in Col (8) or col (9) in Schedule TDS 2');
				addErrorXHTML(
						document
						.getElementsByName('scheduleTDS3.tDS3onOthThanSal['
								+ i
								+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0],
								'Amount in Col (11) cannot be more than the amount entered in Col (8) or col (9) in Schedule TDS 2',
								true);
			}
		}
		else
		{

			var amt6 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].totTDSOnAmtPaid')[0].value;

			var amt8 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value;

			var amt9 = document
			.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0];

			var tempVal = eval(parseInt(coalesce(amt6),10) + parseInt(coalesce(amt8),10));

			if (amt9.value > tempVal) {
				j
				.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i
						+ '].taxDeductCreditDtls.taxCreditedOwnHands',
				'Amount entered in Column (11) cannot be more than amount entered in Column (8) or TDS field of Column (10)  in Schedule TDS 2');
				addErrorXHTML(
						document
						.getElementsByName('scheduleTDS3.tDS3onOthThanSal['
								+ i
								+ '].taxDeductCreditDtls.taxCreditedOwnHands')[0],
								'Amount entered in Column (11) cannot be more than amount entered in Column (8) or TDS field of Column (10) in Schedule TDS 2',
								true);
			}



		}
	}
}


function disableTDS2Fields() {
	var tdsTable = document.getElementById('scheduleTDS2');
	var noOfRows = tdsTable.rows.length;

	for (var i = 0; i < (noOfRows - 6); i++) {


		if(parseInt(document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].taxDeductCreditDtls.taxCreditedOwnHands')[0].value)==0)
		{



			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].value = '';
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].headOfIncome')[0].value = '';
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].headOfIncome')[0].disabled = true;
		}
		else
		{

			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].headOfIncome')[0].disabled = false;
		}





		tDSCreditName = document
		.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
				+ '].tDSCreditName')[0].value;

		if (tDSCreditName == 'O') {
			
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].PAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].aadharrNo')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = false;
			
		} else if (tDSCreditName == 'S') {
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].PAN')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].PAN')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].aadharrNo')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].aadharrNo')[0].value = "";

			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value = "";
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].value = "";
			
		} else {
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = false;

		}

	}

}

function disableTDS3Fields() {
	var tdsTable = document.getElementById('scheduleTDS3');
	var noOfRows = tdsTable.rows.length;

	for (var i = 0; i < (noOfRows - 6); i++) {

		tDSCreditName = document
				.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
						+ '].tDSCreditName')[0].value;

		if (tDSCreditName == 'O') {

			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].PAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].aadharNo')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].value = "";
		}

		else if (tDSCreditName == 'S') {

			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].PAN')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].PAN')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].aadharNo')[0].disabled = true;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].aadharNo')[0].value = "";
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpouseAadhaarNo')[0].disabled = false;
		}

		else {
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedOwnHands')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedTDS')[0].disabled = false;
			document.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxDeductedIncome')[0].disabled = false;

		}

	}

}
function threeFieldsValidationforTDS2OnSave() {

	var mainTab = document.getElementById('scheduleTDS2');
	var mainTabRows = mainTab.rows.length;

	var sum = 0;

	for (var i = 0; i < mainTabRows - 6; i++) {
		taxCreditedIncome = document
		.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedIncome')[0].value;

		taxCreditedTDS = document
		.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value;

		taxCreditedSpousePAN = document
		.getElementsByName('scheduleTDS2.tdSonOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].value;

		if (taxCreditedIncome != ''
			&& (taxCreditedTDS == null || taxCreditedSpousePAN == null
					|| taxCreditedTDS == '' || taxCreditedSpousePAN == '')) {
			j.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS2 point 10.');
			return;
		}
		if (taxCreditedTDS != ''
			&& (taxCreditedIncome == null || taxCreditedSpousePAN == null
					|| taxCreditedIncome == '' || taxCreditedSpousePAN == '')) {

			j.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS2 point 10.');
			return;
		}

		if (taxCreditedSpousePAN != ''
			&& (taxCreditedIncome == null || taxCreditedTDS == null
					|| taxCreditedIncome == '' || taxCreditedTDS == '')) {
			j.setFieldError('scheduleTDS2.tdSonOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS2 point 10.');
			return;
		}
	}
}

function threeFieldsValidationforTDS3OnSave() {

	var mainTab = document.getElementById('scheduleTDS3');
	var mainTabRows = mainTab.rows.length;

	var sum = 0;

	for (var i = 0; i < mainTabRows - 6; i++) {
		taxCreditedIncome = document
		.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedIncome')[0].value;

		taxCreditedTDS = document
		.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedTDS')[0].value;

		taxCreditedSpousePAN = document
		.getElementsByName('scheduleTDS3.tDS3onOthThanSal[' + i
				+ '].taxDeductCreditDtls.taxCreditedSpousePAN')[0].value;

		if (taxCreditedIncome != ''
			&& (taxCreditedTDS == null || taxCreditedSpousePAN == null
					|| taxCreditedTDS == '' || taxCreditedSpousePAN == '')) {
			j.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS3 point 10.');
			return;
		}
		if (taxCreditedTDS != ''
			&& (taxCreditedIncome == null || taxCreditedSpousePAN == null
					|| taxCreditedIncome == '' || taxCreditedSpousePAN == '')) {

			j.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS3 point 10.');
			return;
		}

		if (taxCreditedSpousePAN != ''
			&& (taxCreditedIncome == null || taxCreditedTDS == null
					|| taxCreditedIncome == '' || taxCreditedTDS == '')) {
			j.setFieldError('scheduleTDS3.tDS3onOthThanSal[' + i
					+ '].taxDeductCreditDtls.taxCreditedIncome',
			'Please enter all the mandatory fields in TDS3 point 10.');
			return;
		}
	}
}

function zeroOrLess(val){
	if(parseInt(val, 10) > 0 ){
		return 0;
	}
	return parseInt(val, 10);
}

function calculateSchDPM() {
	dpmCeasesMesg='';
	var rate15Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.realizationTotalPeriod");
	var rate30Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.realizationTotalPeriod");
	var rate40Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.realizationTotalPeriod");
	var rate45Adjustment =  coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.realizationTotalPeriod");

	/*var rate50Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.realizationTotalPeriod");
	var rate60Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.realizationTotalPeriod");
	var rate80Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.realizationTotalPeriod");
	var rate100Adjustment = coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.realizationTotalPeriod");*/

	// For Field 6

	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate15Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate30Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate40Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate45Adjustment);

	/*document.getElementsByName("scheduleDPM.plantMachinery.rate50.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate50Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate60.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate60Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate80.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate80Adjustment);
	document.getElementsByName("scheduleDPM.plantMachinery.rate100.depreciationDetail.fullRateDeprAmt")[0].value = zeroOrMore(rate100Adjustment);*/

	rate15Adjustment = zeroOrLess(rate15Adjustment );
	rate30Adjustment = zeroOrLess(rate30Adjustment );
	rate40Adjustment = zeroOrLess(rate40Adjustment );
	rate45Adjustment = zeroOrLess(rate45Adjustment );
	/*rate50Adjustment = zeroOrLess(rate50Adjustment );
	rate60Adjustment = zeroOrLess(rate60Adjustment );
	rate80Adjustment = zeroOrLess(rate80Adjustment );
	rate100Adjustment =zeroOrLess(rate100Adjustment);*/

	// For Field 9

	rate15Adjustment  =	coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate15Adjustment, 10);
	rate30Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate30Adjustment, 10);
	rate40Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate40Adjustment, 10);
	rate45Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate45Adjustment, 10);

	/*rate50Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate50Adjustment, 10);
	rate60Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate60Adjustment, 10);
	rate80Adjustment  = coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate80Adjustment, 10);
	rate100Adjustment =	coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.realizationPeriodDuringYear") + parseInt(rate100Adjustment, 10);*/


	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate15Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate30Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate40Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate45Adjustment );

	/*document.getElementsByName("scheduleDPM.plantMachinery.rate50.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate50Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate60.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate60Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate80.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore( rate80Adjustment );
	document.getElementsByName("scheduleDPM.plantMachinery.rate100.depreciationDetail.halfRateDeprAmt")[0].value = zeroOrMore(rate100Adjustment);*/

	rate15Adjustment = zeroOrLess(rate15Adjustment );
	rate30Adjustment = zeroOrLess(rate30Adjustment );
	rate40Adjustment = zeroOrLess(rate40Adjustment );
	rate45Adjustment = zeroOrLess(rate45Adjustment );
	/*rate50Adjustment = zeroOrLess(rate50Adjustment );
	rate60Adjustment = zeroOrLess(rate60Adjustment );
	rate80Adjustment = zeroOrLess(rate80Adjustment );
	rate100Adjustment =zeroOrLess(rate100Adjustment);*/

	// For Field 10
	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.fullRateDeprAmt") * 0.15);
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.fullRateDeprAmt") * 0.30);
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.fullRateDeprAmt") * 0.40);
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.fullRateDeprAmt") * 0.45);

	/*document.getElementsByName("scheduleDPM.plantMachinery.rate50.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.fullRateDeprAmt") * 0.50);
	document.getElementsByName("scheduleDPM.plantMachinery.rate60.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.fullRateDeprAmt") * 0.60);
	document.getElementsByName("scheduleDPM.plantMachinery.rate80.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.fullRateDeprAmt") * 0.80);
	document.getElementsByName("scheduleDPM.plantMachinery.rate100.depreciationDetail.depreciationAtFullRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.fullRateDeprAmt"));*/

	// For Field 11
	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.halfRateDeprAmt") * 0.075);
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.halfRateDeprAmt") * 0.15);
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.halfRateDeprAmt") * 0.20);
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.halfRateDeprAmt") * 0.225);

	/*document.getElementsByName("scheduleDPM.plantMachinery.rate50.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.halfRateDeprAmt") * 0.25);
	document.getElementsByName("scheduleDPM.plantMachinery.rate60.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.halfRateDeprAmt") * 0.30);
	document.getElementsByName("scheduleDPM.plantMachinery.rate80.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.halfRateDeprAmt") * 0.40);
	document.getElementsByName("scheduleDPM.plantMachinery.rate100.depreciationDetail.depreciationAtHalfRate")[0].value = Math.round(coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.halfRateDeprAmt") * 0.50);*/

	// For Field 15
	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.addlnDeprDuringYearAdditions")+ coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));

	/*document.getElementsByName("scheduleDPM.plantMachinery.rate50.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate50.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate60.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate60.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate80.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate80.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));
	document.getElementsByName("scheduleDPM.plantMachinery.rate100.depreciationDetail.totalDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.depreciationAtHalfRate")+ coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.addlnDeprOnGT180DayAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.addlnDeprDuringYearAdditions") + coalesceSetRet("scheduleDPM.plantMachinery.rate100.depreciationDetail.addlnDeprOnLessThan180DayAdditions"));*/

	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(eval
			(coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation") -
					coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.depDisAllowUs38_2")));

	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(eval
			(coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation") -
					coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.depDisAllowUs38_2")));

	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(eval
			(coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.totalDepreciation") -
					coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.depDisAllowUs38_2")));


	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(eval
			(coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.totalDepreciation") -
					coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.depDisAllowUs38_2")));

	if(getAmt('scheduleDPM.plantMachinery.rate45.depreciationDetail.depDisAllowUs38_2')>getAmt('scheduleDPM.plantMachinery.rate45.depreciationDetail.totalDepreciation')){
		j.setFieldError('scheduleDPM.plantMachinery.rate45.depreciationDetail.depDisAllowUs38_2','Depreciation disallowed under section 38(2) of the I.T. Act (out of column  15) field value cannot be more than field 15 Total depreciation (10+11+12+13+ 14)');
		addErrorXHTML( document.getElementsByName('scheduleDPM.plantMachinery.rate45.depreciationDetail.depDisAllowUs38_2')[0],
				'Depreciation disallowed under section 38(2) of the I.T. Act (out of column  15) field value cannot be more than field 15 Total depreciation (10+11+12+13+ 14)',true);
		document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.depDisAllowUs38_2")[0].value = 0;
	}
	
	// For Field 17
	document.getElementsByName("scheduleDPM.plantMachinery.rate15.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDPM.plantMachinery.rate15.depreciationDetail.totalDepreciation") +  	parseInt(rate15Adjustment , 10));
	document.getElementsByName("scheduleDPM.plantMachinery.rate30.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDPM.plantMachinery.rate30.depreciationDetail.totalDepreciation") +  	parseInt(rate30Adjustment , 10));
	document.getElementsByName("scheduleDPM.plantMachinery.rate40.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDPM.plantMachinery.rate40.depreciationDetail.totalDepreciation") +  	parseInt(rate40Adjustment , 10));
	document.getElementsByName("scheduleDPM.plantMachinery.rate45.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDPM.plantMachinery.rate45.depreciationDetail.totalDepreciation") +  	parseInt(rate45Adjustment , 10));

	calculatePointNo16DPM('rate15');
	calculatePointNo16DPM('rate30');
	calculatePointNo16DPM('rate40');
	calculatePointNo16DPM('rate45');
}


function calculatePointNo16DPM(percentRate) {
	if( $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value!=0 &&  $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value!="") {

		var CapGainUs50 = calcPoint16DPMvalue(percentRate);


		if(CapGainUs50>0 && $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value>parseInt("0", 10) && $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<CapGainUs50) {
			if(document.getElementsByName('scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed==true){

				document.getElementsByName('scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed=false;
			}
			main.generateMsgDialogWithOk('The calculated value of Capital Gain/Loss u/s 50 in S.No 20 is '+CapGainUs50+' and is different from what has been entered by you (value entered by user). Please enter correct value of sale consideration in S.No 5 or 8 of this schedule. Else the entered value will be replaced with the calculated value.',"");
			overrideDpmCapGainUs50(percentRate,CapGainUs50);
			calcSchDCGFor6();
		}

		if(CapGainUs50<0 && $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<parseInt("0", 10) && $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value>CapGainUs50) {
			if(document.getElementsByName('scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed==true){

				document.getElementsByName('scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed=false;
			}
			main.generateMsgDialogWithOk('The calculated value of Capital Gain/Loss u/s 50 in S.No 20 is '+CapGainUs50+' and is different from what has been entered by you. Please enter correct value of sale consideration in S.No 5 or 8 of this schedule. Else the entered value will be replaced with the calculated value.',"");
			overrideDpmCapGainUs50(percentRate,CapGainUs50);
			calcSchDCGFor6();

		}

		if(CapGainUs50<0 && $('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<0) {
			dpmCeasesMesg=dpmCeasesMesg+'Block Depreciation - Plant and Machinery @ '+percentRate.substring(4)+'% ceases to exist.<br/>';

		}

		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.depreciationAtFullRate"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.depreciationAtHalfRate"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.addlnDeprOnGT180DayAdditions"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.addlnDeprDuringYearAdditions"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.totalDepreciation"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.netAggregateDepreciation"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.depDisAllowUs38_2"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.proportionateAggDepreciation"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.wdvLastDay"]')[0].value=0;
		$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.addlnDeprOnLessThan180DayAdditions"]')[0].value=0;

	}

}

function calcPoint16DPMvalue(percentRate) {
	if (percentRate == 'rate40') {
		   return coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationTotalPeriod")
				+ coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationPeriodDuringYear")
				- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.wdvFirstDay")
				- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsGrThan180Days")
				- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsLessThan180Days")
				- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.expdrOnTrforSaleAsset");
	}
	else if(percentRate == 'rate45')
	{
		return coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationTotalPeriod")
		+ coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationPeriodDuringYear")
		- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsGrThan180Days")
		- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsLessThan180Days")
		- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.expdrOnTrforSaleAsset");
	}
	   return coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationTotalPeriod")
			+ coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.realizationPeriodDuringYear")
			- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsGrThan180Days")
			- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.additionsLessThan180Days")
			- coalesceSetRet("scheduleDPM.plantMachinery." + percentRate+ ".depreciationDetail.expdrOnTrforSaleAsset");
}

function overrideDpmCapGainUs50(percentRate,CapGainUs50) {
	$('[name="scheduleDPM.plantMachinery.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value = parseInt(CapGainUs50,10);

}

function calculateSchDOA() {
	doaCeasesMesg = '';
	var buildingRate5FullRateDeprAmt = coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.realizationTotalPeriod");
	var buildingRate10FullRateDeprAmt = coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.realizationTotalPeriod");
	var buildingRate40FullRateDeprAmt = coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.realizationTotalPeriod");
	var furnitureFittingsRate10FullRateDeprAmt = coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.realizationTotalPeriod");
	var intangibleAssetsRate25FullRateDeprAmt = coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.realizationTotalPeriod");
	var shipsRate20FullRateDeprAmt = coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.wdvFirstDay") + coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.realizationTotalPeriod");


	// For Field 6
	$('[name="scheduleDOA.building.rate5.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(buildingRate5FullRateDeprAmt);
	$('[name="scheduleDOA.building.rate10.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(buildingRate10FullRateDeprAmt);
	$('[name="scheduleDOA.building.rate40.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(buildingRate40FullRateDeprAmt);
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(furnitureFittingsRate10FullRateDeprAmt);
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(intangibleAssetsRate25FullRateDeprAmt);
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.fullRateDeprAmt"]')[0].value = zeroOrMore(shipsRate20FullRateDeprAmt);

	buildingRate5FullRateDeprAmt = zeroOrLess(buildingRate5FullRateDeprAmt);
	buildingRate10FullRateDeprAmt = zeroOrLess(buildingRate10FullRateDeprAmt);
	buildingRate40FullRateDeprAmt = zeroOrLess(buildingRate40FullRateDeprAmt);
	furnitureFittingsRate10FullRateDeprAmt = zeroOrLess(furnitureFittingsRate10FullRateDeprAmt);
	intangibleAssetsRate25FullRateDeprAmt = zeroOrLess(intangibleAssetsRate25FullRateDeprAmt);
	shipsRate20FullRateDeprAmt = zeroOrLess(shipsRate20FullRateDeprAmt);


	buildingRate5FullRateDeprAmt = 				(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.realizationPeriodDuringYear") + buildingRate5FullRateDeprAmt);
	buildingRate10FullRateDeprAmt =             (coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.realizationPeriodDuringYear") + buildingRate10FullRateDeprAmt);
	buildingRate40FullRateDeprAmt =            (coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.realizationPeriodDuringYear") + buildingRate40FullRateDeprAmt);
	furnitureFittingsRate10FullRateDeprAmt =    (coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.realizationPeriodDuringYear") + furnitureFittingsRate10FullRateDeprAmt);
	intangibleAssetsRate25FullRateDeprAmt =     (coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.realizationPeriodDuringYear") + intangibleAssetsRate25FullRateDeprAmt);
	shipsRate20FullRateDeprAmt =                (coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.realizationPeriodDuringYear") + shipsRate20FullRateDeprAmt);


	// For Field 9

	$('[name="scheduleDOA.building.rate5.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(buildingRate5FullRateDeprAmt);
	$('[name="scheduleDOA.building.rate10.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(buildingRate10FullRateDeprAmt);
	$('[name="scheduleDOA.building.rate40.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(buildingRate40FullRateDeprAmt);
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(furnitureFittingsRate10FullRateDeprAmt);
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(intangibleAssetsRate25FullRateDeprAmt);
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.halfRateDeprAmt"]')[0].value = zeroOrMore(shipsRate20FullRateDeprAmt);

	buildingRate5FullRateDeprAmt = zeroOrLess(buildingRate5FullRateDeprAmt);
	buildingRate10FullRateDeprAmt = zeroOrLess(buildingRate10FullRateDeprAmt);
	buildingRate40FullRateDeprAmt = zeroOrLess(buildingRate40FullRateDeprAmt);
	furnitureFittingsRate10FullRateDeprAmt = zeroOrLess(furnitureFittingsRate10FullRateDeprAmt);
	intangibleAssetsRate25FullRateDeprAmt = zeroOrLess(intangibleAssetsRate25FullRateDeprAmt);
	shipsRate20FullRateDeprAmt = zeroOrLess(shipsRate20FullRateDeprAmt);

	// For Field 10
	$('[name="scheduleDOA.building.rate5.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.fullRateDeprAmt") * 0.05);
	$('[name="scheduleDOA.building.rate10.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.fullRateDeprAmt") * 0.10);
	$('[name="scheduleDOA.building.rate40.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.fullRateDeprAmt") * 0.4);
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.fullRateDeprAmt") * 0.10);
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.fullRateDeprAmt") * 0.25);
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.depreciationAtFullRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.fullRateDeprAmt") * 0.20);

	// For Field 11
	$('[name="scheduleDOA.building.rate5.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.halfRateDeprAmt") * 0.025);
	$('[name="scheduleDOA.building.rate10.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.halfRateDeprAmt") * 0.05);
	$('[name="scheduleDOA.building.rate40.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.halfRateDeprAmt") * 0.20);
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.halfRateDeprAmt") * 0.05);
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.halfRateDeprAmt") * 0.125);
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.depreciationAtHalfRate"]')[0].value = Math.round(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.halfRateDeprAmt") * 0.10);

	// For Field 14
	$('[name="scheduleDOA.building.rate5.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.depreciationAtHalfRate"));
	$('[name="scheduleDOA.building.rate10.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.depreciationAtHalfRate"));
	$('[name="scheduleDOA.building.rate40.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.depreciationAtHalfRate"));
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.depreciationAtHalfRate"));
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.depreciationAtHalfRate"));
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.totalDepreciation"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.depreciationAtFullRate") + coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.depreciationAtHalfRate"));

	document.getElementsByName("scheduleDOA.building.rate5.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.depDisAllowUs38_2"));
	document.getElementsByName("scheduleDOA.building.rate10.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.depDisAllowUs38_2"));
	document.getElementsByName("scheduleDOA.building.rate40.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.depDisAllowUs38_2"));
	document.getElementsByName("scheduleDOA.furnitureFittings.rate10.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.depDisAllowUs38_2"));
	document.getElementsByName("scheduleDOA.intangibleAssets.rate25.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.depDisAllowUs38_2"));
	document.getElementsByName("scheduleDOA.ships.rate20.depreciationDetail.netAggregateDepreciation")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.totalDepreciation") - coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.depDisAllowUs38_2"));

	// For Field 17
	$('[name="scheduleDOA.building.rate5.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.totalDepreciation")	+ parseInt(buildingRate5FullRateDeprAmt,10));
	$('[name="scheduleDOA.building.rate10.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.totalDepreciation")	+ parseInt(buildingRate10FullRateDeprAmt,10));
	$('[name="scheduleDOA.building.rate40.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.totalDepreciation") + parseInt(buildingRate40FullRateDeprAmt,10));
	$('[name="scheduleDOA.furnitureFittings.rate10.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.totalDepreciation")	+ parseInt(furnitureFittingsRate10FullRateDeprAmt ,10));
	$('[name="scheduleDOA.intangibleAssets.rate25.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.totalDepreciation") + parseInt(intangibleAssetsRate25FullRateDeprAmt  ,10));
	$('[name="scheduleDOA.ships.rate20.depreciationDetail.wdvLastDay"]')[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.fullRateDeprAmt") + coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.halfRateDeprAmt") - coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.totalDepreciation") + parseInt(shipsRate20FullRateDeprAmt ,10));

	document
	.getElementsByName("scheduleDOA.building.rate5.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.building.rate5.depreciationDetail.totalDepreciation") + parseInt(buildingRate5FullRateDeprAmt,10));

	document
	.getElementsByName("scheduleDOA.building.rate10.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.building.rate10.depreciationDetail.totalDepreciation")+ parseInt(buildingRate10FullRateDeprAmt,10));

	document
	.getElementsByName("scheduleDOA.building.rate40.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.building.rate40.depreciationDetail.totalDepreciation") + parseInt(buildingRate40FullRateDeprAmt,10));

	document
	.getElementsByName("scheduleDOA.furnitureFittings.rate10.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.furnitureFittings.rate10.depreciationDetail.totalDepreciation")+ parseInt(furnitureFittingsRate10FullRateDeprAmt ,10));

	document
	.getElementsByName("scheduleDOA.intangibleAssets.rate25.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.intangibleAssets.rate25.depreciationDetail.totalDepreciation") + parseInt(intangibleAssetsRate25FullRateDeprAmt  ,10));

	document
	.getElementsByName("scheduleDOA.ships.rate20.depreciationDetail.wdvLastDay")[0].value = zeroOrMore(coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.fullRateDeprAmt")
			+ coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.halfRateDeprAmt")
			- coalesceSetRet("scheduleDOA.ships.rate20.depreciationDetail.totalDepreciation")+ parseInt(shipsRate20FullRateDeprAmt ,10));





//	Nil value form 3 to 18
	document.getElementsByName("scheduleDOA.building.rateNil.depreciationDetail.wdvLastDay")[0].value =
		zeroOrMore(coalesceSetRet("scheduleDOA.landWDVFirstDay") );

	calculatePointNo16DOA('building','rate5');
	calculatePointNo16DOA('building','rate10');
	calculatePointNo16DOA('building','rate40');
	calculatePointNo16DOA('furnitureFittings','rate10');
	calculatePointNo16DOA('intangibleAssets','rate25');
	calculatePointNo16DOA('ships','rate20');

}

function calculatePointNo16DOA(assetName,percentRate) {
	if( $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value!=0 &&  $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value!="") {

		var CapGainUs50 = calcPoint16DOAvalue(assetName,percentRate);
		if(CapGainUs50>0 && $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value>parseInt("0", 10) && $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<CapGainUs50) {
			if(document.getElementsByName('scheduleDOA.'+ assetName +'.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed==true){

				document.getElementsByName('scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed=false;
			}

			main.generateMsgDialogWithOk('The calculated value of Capital Gain/Loss u/s 50 in S.No 17 is '+CapGainUs50+' and is different from what has been entered by you (value entered by user). Please enter correct value of sale consideration in S.No 5 or 8 of this schedule. Else the entered value will be replaced with the calculated value.',"");
			overrideDoaCapGainUs50(percentRate,CapGainUs50,assetName);
			calcSchDCGFor6();
		}

		if(CapGainUs50<0 && $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<parseInt("0", 10) && $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value>CapGainUs50) {
			if(document.getElementsByName('scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed==true){

				document.getElementsByName('scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50')[0].changed=false;
			}

			main.generateMsgDialogWithOk('The calculated value of Capital Gain/Loss u/s 50 in S.No 17 is '+CapGainUs50+' and is different from what has been entered by you. Please enter correct value of sale consideration in S.No 5 or 8 of this schedule. Else the entered value will be replaced with the calculated value.',"");
			overrideDoaCapGainUs50(percentRate,CapGainUs50,assetName);
			calcSchDCGFor6();
		}

		if(CapGainUs50<0 && $('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value<0) {
			doaCeasesMesg=doaCeasesMesg+'Block Depreciation - '+assetName+' @ '+percentRate.substring(4)+'% ceases to exist.<br/>';

		}

		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.netAggregateDepreciation"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.proportionateAggDepreciation"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.depDisAllowUs38_2"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.depreciationAtFullRate"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.depreciationAtHalfRate"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.totalDepreciation"]')[0].value=0;
		$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.wdvLastDay"]')[0].value=0;

	}

}

function calcPoint16DOAvalue(assetName,percentRate) {
	return coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.realizationTotalPeriod") + coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.realizationPeriodDuringYear") - coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.wdvFirstDay") - coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.additionsGrThan180Days") - coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.additionsLessThan180Days") - coalesceSetRet("scheduleDOA."+assetName+"."+percentRate+".depreciationDetail.expdrOnTrforSaleAsset");
}

function overrideDoaCapGainUs50(percentRate,CapGainUs50,assetName) {
	$('[name="scheduleDOA.'+assetName+'.'+percentRate+'.depreciationDetail.capGainUs50"]')[0].value = parseInt(CapGainUs50,10);
}


function calcSchESRFor5() {
	var amtDebPL1i = document.getElementsByName('scheduleESR.deductionUs35.section351I.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section351I.deductUs35.amtDebPL');
	var amtUs35Allowable1i = document.getElementsByName('scheduleESR.deductionUs35.section351I.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section351I.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1i = document.getElementsByName('scheduleESR.deductionUs35.section351I.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section351I.deductUs35.excessAmtOverDebPL');

	var amtDebPL1ii = document.getElementsByName('scheduleESR.deductionUs35.section351Ii.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section351Ii.deductUs35.amtDebPL');
	var amtUs35Allowable1ii = document.getElementsByName('scheduleESR.deductionUs35.section351Ii.deductUs35.amtUs35Allowable')[0]; 		coalesceSetRet('scheduleESR.deductionUs35.section351Ii.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1ii = document.getElementsByName('scheduleESR.deductionUs35.section351Ii.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section351Ii.deductUs35.excessAmtOverDebPL');

	var amtDebPL1iia = document.getElementsByName('scheduleESR.deductionUs35.section351Iia.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section351Iia.deductUs35.amtDebPL');
	var amtUs35Allowable1iia = document.getElementsByName('scheduleESR.deductionUs35.section351Iia.deductUs35.amtUs35Allowable')[0]; 		coalesceSetRet('scheduleESR.deductionUs35.section351Iia.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1iia = document.getElementsByName('scheduleESR.deductionUs35.section351Iia.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section351Iia.deductUs35.excessAmtOverDebPL');

	var amtDebPL1iii = document.getElementsByName('scheduleESR.deductionUs35.section351Iii.deductUs35.amtDebPL')[0];					coalesceSetRet('scheduleESR.deductionUs35.section351Iii.deductUs35.amtDebPL');
	var amtUs35Allowable1iii = document.getElementsByName('scheduleESR.deductionUs35.section351Iii.deductUs35.amtUs35Allowable')[0];	coalesceSetRet('scheduleESR.deductionUs35.section351Iii.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1iii = document.getElementsByName('scheduleESR.deductionUs35.section351Iii.deductUs35.excessAmtOverDebPL')[0];coalesceSetRet('scheduleESR.deductionUs35.section351Iii.deductUs35.excessAmtOverDebPL');

	var amtDebPL1iiv = document.getElementsByName('scheduleESR.deductionUs35.section351Iv.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section351Iv.deductUs35.amtDebPL');
	var amtUs35Allowable1iiv = document.getElementsByName('scheduleESR.deductionUs35.section351Iv.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section351Iv.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1iv = document.getElementsByName('scheduleESR.deductionUs35.section351Iv.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section351Iv.deductUs35.excessAmtOverDebPL');

	var amtDebPL2AA = document.getElementsByName('scheduleESR.deductionUs35.section352AA.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section352AA.deductUs35.amtDebPL');
	var amtUs35Allowable2AA = document.getElementsByName('scheduleESR.deductionUs35.section352AA.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section352AA.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL2AA = document.getElementsByName('scheduleESR.deductionUs35.section352AA.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section352AA.deductUs35.excessAmtOverDebPL');

	var amtDebPL2AB = document.getElementsByName('scheduleESR.deductionUs35.section352AB.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section352AB.deductUs35.amtDebPL');
	var amtUs35Allowable2AB = document.getElementsByName('scheduleESR.deductionUs35.section352AB.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section352AB.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL2AB = document.getElementsByName('scheduleESR.deductionUs35.section352AB.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section352AB.deductUs35.excessAmtOverDebPL');

	var amtDebPLCCC = document.getElementsByName('scheduleESR.deductionUs35.section35CCC.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section35CCC.deductUs35.amtDebPL');
	var amtUs35AllowableCCC = document.getElementsByName('scheduleESR.deductionUs35.section35CCC.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section35CCC.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPLCCC = document.getElementsByName('scheduleESR.deductionUs35.section35CCC.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section35CCC.deductUs35.excessAmtOverDebPL');

	var amtDebPLCCD = document.getElementsByName('scheduleESR.deductionUs35.section35CCD.deductUs35.amtDebPL')[0];						coalesceSetRet('scheduleESR.deductionUs35.section35CCD.deductUs35.amtDebPL');
	var amtUs35AllowableCCD = document.getElementsByName('scheduleESR.deductionUs35.section35CCD.deductUs35.amtUs35Allowable')[0];		coalesceSetRet('scheduleESR.deductionUs35.section35CCD.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPLCCD = document.getElementsByName('scheduleESR.deductionUs35.section35CCD.deductUs35.excessAmtOverDebPL')[0];	coalesceSetRet('scheduleESR.deductionUs35.section35CCD.deductUs35.excessAmtOverDebPL');

	var amtDebPLTot = document.getElementsByName('scheduleESR.deductionUs35.totUs35.deductUs35.amtDebPL')[0];							coalesceSetRet('scheduleESR.deductionUs35.totUs35.deductUs35.amtDebPL');
	var amtUs35AllowableTot = document.getElementsByName('scheduleESR.deductionUs35.totUs35.deductUs35.amtUs35Allowable')[0];			coalesceSetRet('scheduleESR.deductionUs35.totUs35.deductUs35.amtUs35Allowable');
	var excessAmtOverDebPL1iTot = document.getElementsByName('scheduleESR.deductionUs35.totUs35.deductUs35.excessAmtOverDebPL')[0];		coalesceSetRet('scheduleESR.deductionUs35.totUs35.deductUs35.excessAmtOverDebPL');

	excessAmtOverDebPL1i.value = eval(parseInt(amtUs35Allowable1i.value,10)) - eval(parseInt(amtDebPL1i.value,10));
	if(eval(excessAmtOverDebPL1i.value,10) < 0){
		excessAmtOverDebPL1i.value =  parseInt(0,10);
	}

	excessAmtOverDebPL1ii.value = eval(parseInt(amtUs35Allowable1ii.value,10)) - eval(parseInt(amtDebPL1ii.value,10));
	if(eval(excessAmtOverDebPL1ii.value,10) < 0){
		excessAmtOverDebPL1ii.value =  parseInt(0,10);
	}

	excessAmtOverDebPL1iia.value = eval(parseInt(amtUs35Allowable1iia.value,10)) - eval(parseInt(amtDebPL1iia.value,10));
	if(eval(excessAmtOverDebPL1iia.value,10) < 0){
		excessAmtOverDebPL1iia.value =  parseInt(0,10);
	}

	excessAmtOverDebPL1iii.value = eval(parseInt(amtUs35Allowable1iii.value,10)) - eval(parseInt(amtDebPL1iii.value,10));
	if(eval(excessAmtOverDebPL1iii.value,10) < 0){
		excessAmtOverDebPL1iii.value =  parseInt(0,10);
	}

	excessAmtOverDebPL1iv.value = eval(parseInt(amtUs35Allowable1iiv.value,10)) - eval(parseInt(amtDebPL1iiv.value,10));
	if(eval(excessAmtOverDebPL1iv.value,10) < 0){
		excessAmtOverDebPL1iv.value =  parseInt(0,10);
	}

	excessAmtOverDebPL2AA.value = eval(parseInt(amtUs35Allowable2AA.value,10)) - eval(parseInt(amtDebPL2AA.value,10));
	if(eval(excessAmtOverDebPL2AA.value,10) < 0){
		excessAmtOverDebPL2AA.value =  parseInt(0,10);
	}

	excessAmtOverDebPL2AB.value = eval(parseInt(amtUs35Allowable2AB.value,10)) - eval(parseInt(amtDebPL2AB.value,10));
	if(eval(excessAmtOverDebPL2AB.value,10) < 0){
		excessAmtOverDebPL2AB.value =  parseInt(0,10);
	}

	excessAmtOverDebPLCCC.value = eval(parseInt(amtUs35AllowableCCC.value,10)) - eval(parseInt(amtDebPLCCC.value,10));
	if(eval(excessAmtOverDebPLCCC.value,10) < 0){
		excessAmtOverDebPLCCC.value =  parseInt(0,10);
	}

	excessAmtOverDebPLCCD.value = eval(parseInt(amtUs35AllowableCCD.value,10)) - eval(parseInt(amtDebPLCCD.value,10));
	if(eval(excessAmtOverDebPLCCD.value,10) < 0){
		excessAmtOverDebPLCCD.value =  parseInt(0,10);
	}

	amtDebPLTot.value = eval(parseInt(amtDebPL1i.value,10)) + eval(parseInt(amtDebPL1ii.value,10))+ eval(parseInt(amtDebPL1iia.value,10))+ eval(parseInt(amtDebPL1iii.value,10))+ eval(parseInt(amtDebPL1iiv.value,10))+ eval(parseInt(amtDebPL2AA.value,10))+ eval(parseInt(amtDebPL2AB.value,10))+ eval(parseInt(amtDebPLCCC.value,10))+ eval(parseInt(amtDebPLCCD.value,10));
	amtUs35AllowableTot.value = eval(parseInt(amtUs35Allowable1i.value,10)) + eval(parseInt(amtUs35Allowable1ii.value,10))+ eval(parseInt(amtUs35Allowable1iia.value,10))+ eval(parseInt(amtUs35Allowable1iii.value,10))+ eval(parseInt(amtUs35Allowable1iiv.value,10))+ eval(parseInt(amtUs35Allowable2AA.value,10))+ eval(parseInt(amtUs35Allowable2AB.value,10))+ eval(parseInt(amtUs35AllowableCCC.value,10))+ eval(parseInt(amtUs35AllowableCCD.value,10));
	excessAmtOverDebPL1iTot.value = eval(parseInt(excessAmtOverDebPL1i.value,10)) + eval(parseInt(excessAmtOverDebPL1ii.value,10))+ eval(parseInt(excessAmtOverDebPL1iia.value,10))+ eval(parseInt(excessAmtOverDebPL1iii.value,10))+ eval(parseInt(excessAmtOverDebPL1iv.value,10))+ eval(parseInt(excessAmtOverDebPL2AA.value,10))+ eval(parseInt(excessAmtOverDebPL2AB.value,10))+ eval(parseInt(excessAmtOverDebPLCCC.value,10))+ eval(parseInt(excessAmtOverDebPLCCD.value,10));

}




function getExemption(){
	var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var taxPayer = document.getElementsByName("partAGEN1.orgFirmInfo.statusOrCompanyType")[0];
	var sharePercentage = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].sharePercentage')[0].value;
	var subtaxPayer = document.getElementsByName("partAGEN1.orgFirmInfo.subStatus")[0];
	var executorStatusCount=false;
	var statusCode = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].status')[0].value;
		if(statusCode=='EXECUTOR')
		{
			executorStatusCount=true;
		}
	if((taxPayer.value=='9' && subtaxPayer.value=='19')  || (taxPayer.value=='14' && subtaxPayer.value=='11') ){
		return 250000;
	}else if(taxPayer.value=='14' && (subtaxPayer.value=='8'||subtaxPayer.value=='20' || subtaxPayer.value=='21')){
		var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
		var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
		var shares = getPercentOfShare();
		var total = parseInt(shares.foreignPerc,10)+parseInt(shares.otherPerc,10);
		if(isSharedForeign=='NO' && totIncFrmMemberOfAop == 'N' && total == 100){
			return 250000;
		}
		return 0;
	}else if(taxPayer.value=='14' && (subtaxPayer.value=='7' || subtaxPayer.value=='13')){

		var isSharedForeign = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;
		var totIncFrmMemberOfAop = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].totIncFrmMemberOfAop')[0].value;
		var shares = getPercentOfShare();
		var total = parseInt(shares.foreignPerc,10)+parseInt(shares.otherPerc,10);

		var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
		var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;
		var thirdFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value;
		var fourthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].value;
		var fifthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].value;
		var sixthFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].value;
		var seventhFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].value;
		if( (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='Y' ) || (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='Y') || (firstFlag=='N' && secondFlag=='N' && (fourthFlag=='Y' || fifthFlag=='Y' || sixthFlag=='Y' || seventhFlag=='Y'))||(firstFlag=='Y' && secondFlag=='N') ){
			if(isSharedForeign=='NO' && totIncFrmMemberOfAop == 'N' && total == 100){
				return 250000;
			}
			return 0;

		}else{
			return 0;
		}
	}else if(sharePercentage==100 && executorStatusCount && (taxPayer.value=='9' && subtaxPayer.value=='12')){
		return 250000;

	}else{
		return 0;
	}

}

/*function getPercentOfShare(){
	var tab = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var inputs = tab.getElementsByTagName('input');
	var foreignPerc = 0;
	var otherPerc = 0;

	for(var i =0; i < inputs.length; i++){
		if(inputs[i].name!=undefined && inputs[i].name.match('sharePercentage$')){

			var index = inputs[i].name.substr(eval(inputs[i].name.indexOf("["))+1,1);

			alert('indexindex '+index);

			var type = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+index+'].status')[0].value;

			alert('getPercentOfSharetypetype '+type);

			if(type=='FOREIGN_COMPANY'){
				foreignPerc = eval(foreignPerc + (mulFloatBy100(inputs[i].value)));
			}else if(status==1 || (status==1 && substatus==5)){
				if(type !='IND_RETIRED' ){
					otherPerc = eval(otherPerc + (mulFloatBy100(inputs[i].value)));
				}

			}else{
				otherPerc = eval(otherPerc + (mulFloatBy100(inputs[i].value)));
			}
		}
	}
	alert('getPercentOfShare foreignPercforeignPerc '+foreignPerc);
	alert('getPercentOfShare otherPercotherPerc '+otherPerc);

	return {'foreignPerc':foreignPerc/100, 'otherPerc':otherPerc/100};
}*/

function getPercentOfShare(){
	var tab = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var noOfRows = tab.rows.length;
	var allInputTags = tab.getElementsByTagName('input');
	var allSelectTags = tab.getElementsByTagName('select');
	var foreignPerc = 0;
	var otherPerc = 0;

	for ( var i = 0; i < eval(parseInt(noOfRows, 10) - 4); i++) {

		var statusCode = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].status')[0].value;

		var sharePerc = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].sharePercentage')[0].value;

		if(statusCode=='FOREIGN_COMPANY'){
			foreignPerc = eval(foreignPerc + (mulFloatBy100(sharePerc)));
		}else if(status==1 || (status==1 && substatus==5)){
			if(statusCode !='IND_RETIRED' ){
				otherPerc = eval(otherPerc + (mulFloatBy100(sharePerc)));
			}

		}else{
			otherPerc = eval(otherPerc + (mulFloatBy100(sharePerc)));
		}
	}
	return {'foreignPerc':foreignPerc/100, 'otherPerc':otherPerc/100};
}

function calculatePartBTI_first(){
	try{
		surcharge201718();
		//1
		var incomeFromHP = document.getElementsByName('partBTI.incomeFromHP')[0];
		incomeFromHP.value =  zeroOrMore( coalesceSetRet('scheduleHP.totalIncomeChargeableUnHP') );

		//2
		var adjustedBp41 = parseInt(
				coalesceSetRet('itr5ScheduleBP.specBusinessInc.adjustedPLFrmSpecuBus'), 10);
		var bp37 = parseInt(
				coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.netPLBusOthThanSpec7A7B7C'), 10);

		var adjustedBp47 = parseInt(
				coalesceSetRet('itr5ScheduleBP.incSpecifiedBusiness.profitLossSpecifiedBusFinal'), 10);

		var bp3d = parseInt(
				coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF'), 10);

		var bp3e = parseInt(
				coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG'), 10);

		if (bp37 > 0) {
			document.getElementsByName('partBTI.profBusGain.profGainNoSpecBus')[0].value = bp37;
		} else {
			document.getElementsByName('partBTI.profBusGain.profGainNoSpecBus')[0].value = parseInt(0, 10);
		}

		if (eval(adjustedBp41) > 0) {
			var speclBusinessAfterSet = document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.speculativeInc.incOfCurYrAfterSetOff')[0].value;
			document.getElementsByName('partBTI.profBusGain.profGainSpecBus')[0].value = eval(speclBusinessAfterSet);

		} else {
			document.getElementsByName('partBTI.profBusGain.profGainSpecBus')[0].value = parseInt(0, 10);
		}

		if (eval(adjustedBp47) > 0) {
			var specBuisnessAfterSet= document.getElementsByName('itr5ScheduleBP.busSetoffCurYr.specifiedInc.incOfCurYrAfterSetOff')[0].value;
			document.getElementsByName('partBTI.profBusGain.profGainSpecifiedBus')[0].value = eval(specBuisnessAfterSet);

		} else {
			document.getElementsByName('partBTI.profBusGain.profGainSpecifiedBus')[0].value = parseInt(0, 10);
		}

		/*if (bp3d > 0) {
			document.getElementsByName('partBTI.profBusGain.underSecBBF')[0].value = bp3d;
		} else {
			document.getElementsByName('partBTI.profBusGain.underSecBBF')[0].value = parseInt(0, 10);
		}
		 */
		/*if (bp3e > 0) {
			document.getElementsByName('partBTI.profBusGain.underSecBBG')[0].value = bp3e;
		} else {
			document.getElementsByName('partBTI.profBusGain.underSecBBG')[0].value = parseInt(0, 10);
		}*/

		document.getElementsByName('partBTI.profBusGain.totProfBusGain')[0].value = eval(
				parseInt(coalesceSetRet('partBTI.profBusGain.profGainNoSpecBus'),10)
				+ parseInt(coalesceSetRet('partBTI.profBusGain.profGainSpecBus'),10)
				+ parseInt(coalesceSetRet('partBTI.profBusGain.profGainSpecifiedBus'),10)
				+ parseInt(coalesceSetRet('partBTI.profBusGain.underSecBBF'),10)
				//+ parseInt(coalesceSetRet('partBTI.profBusGain.underSecBBG'),10)
		);

		//3a
		document.getElementsByName('partBTI.capGain.shortTerm.shortTerm15Per')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inStcg15Per.CurrYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.shortTerm.shortTerm30Per')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inStcg30Per.currYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.shortTerm.shortTermAppRate')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inStcgAppRate.currYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.shortTerm.shortTermChargableDtaa')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inStcgDTAARate.currYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.shortTerm.totalShortTerm')[0].value = eval(
				parseInt(coalesceSetRet('partBTI.capGain.shortTerm.shortTerm15Per'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.shortTerm.shortTerm30Per'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.shortTerm.shortTermAppRate'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.shortTerm.shortTermChargableDtaa'),10)
		);
		//3b
		document.getElementsByName('partBTI.capGain.longTerm.longTerm10Per')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inLtcg10Per.currYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.longTerm.longTerm20Per')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inLtcg20Per.CurrYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.longTerm.longTermDtaa')[0].value =
			parseInt(coalesceSetRet('scheduleCGPost45.currYrLosses.inLtcgDTAARates.CurrYrLosSetOff'),10);

		document.getElementsByName('partBTI.capGain.longTerm.totalLongTerm')[0].value = eval(
				parseInt(coalesceSetRet('partBTI.capGain.longTerm.longTerm10Per'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.longTerm.longTerm20Per'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.longTerm.longTermDtaa'),10)
		);

		if (eval(document.getElementsByName('partBTI.capGain.longTerm.totalLongTerm')[0].value,10) < 0) {
			document.getElementsByName('partBTI.capGain.longTerm.totalLongTerm')[0].value = parseInt(0,10);
		}


		var totalCapGains = document.getElementsByName('partBTI.capGain.totalCapGains')[0];
		totalCapGains.value = parseInt(document.getElementsByName('partBTI.capGain.shortTerm.totalShortTerm')[0].value)
		+ parseInt(document.getElementsByName('partBTI.capGain.longTerm.totalLongTerm')[0].value);

		//4
		var otherSrcThanOwnRaceHorse = document.getElementsByName('partBTI.incFromOS.otherSrcThanOwnRaceHorse')[0];
		otherSrcThanOwnRaceHorse.value = zeroOrMore(coalesceSetRet('scheduleOS.balanceNoRaceHorse'));



		var incChargeSplRate = document.getElementsByName('partBTI.incFromOS.incChargeSplRate')[0];
		incChargeSplRate.value = zeroOrMore(coalesceSetRet('scheduleOS.totalOSGross'));

		var fromOwnRaceHorse = document.getElementsByName('partBTI.incFromOS.fromOwnRaceHorse')[0];
		fromOwnRaceHorse.value = zeroOrMore(coalesceSetRet('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse'));



		var totIncFromOS = document.getElementsByName('partBTI.incFromOS.totIncFromOS')[0];
		totIncFromOS.value = eval(parseInt(otherSrcThanOwnRaceHorse.value, 10)
				+ parseInt(incChargeSplRate.value, 10)
				+ parseInt(fromOwnRaceHorse.value, 10)
		);

		//5
		document.getElementsByName('partBTI.totalTI')[0].value = eval(
				parseInt(coalesceSetRet('partBTI.incomeFromHP'),10)
				+ parseInt(coalesceSetRet('partBTI.profBusGain.totProfBusGain'),10)
				+ parseInt(coalesceSetRet('partBTI.capGain.totalCapGains'),10)
				+ parseInt(coalesceSetRet('partBTI.incFromOS.totIncFromOS'),10)
		);

		//6
		document.getElementsByName('partBTI.currentYearLoss')[0].value = eval(
				parseInt(coalesceSetRet('scheduleCYLA.totalLossSetOff.totHPlossCurYrSetoff'),10)
				+ parseInt(coalesceSetRet('scheduleCYLA.totalLossSetOff.totBusLossSetoff'),10)
				+ parseInt(coalesceSetRet('scheduleCYLA.totalLossSetOff.totOthSrcLossNoRaceHorseSetoff'),10)
		);

		//7
		document.getElementsByName('partBTI.balanceAfterSetoffLosses')[0].value = eval(
				parseInt(coalesceSetRet('partBTI.totalTI'),10)
				- parseInt(coalesceSetRet('partBTI.currentYearLoss'),10)
		);

		//8
		document.getElementsByName('partBTI.broughtFwdLossesSetoff')[0].value = zeroOrMore(eval(
				parseInt(coalesceSetRet('scheduleBFLA.totalBFLossSetOff.totBFLossSetoff'),10)
				+ parseInt(coalesceSetRet('scheduleBFLA.totalBFLossSetOff.totUnabsorbedDeprSetoff'),10)
				+ parseInt(coalesceSetRet('scheduleBFLA.totalBFLossSetOff.totAllUs35Cl4Setoff'),10)
		));

		//9
		document.getElementsByName('partBTI.grossTotalIncome')[0].value = zeroOrMore(eval(
				parseInt(coalesceSetRet('partBTI.balanceAfterSetoffLosses'),10)
				- parseInt(coalesceSetRet('partBTI.broughtFwdLossesSetoff'),10)
		));

		//10
		document.getElementsByName('partBTI.incChargeTaxSplRate111A112')[0].value = eval(
				parseInt(coalesceSetRet('scheduleSI.totSplRateInc'),10)
		);

		//11

	}catch(e){
		alert(e.stack);
	}
}

function calculatePartBTI_second(){
	try{
		surcharge201718();
		//12
		var dedPartBLimit=zeroOrMore(eval(
				parseInt(coalesceSetRet('partBTI.grossTotalIncome'),10)-
				parseInt(coalesceSetRet('partBTI.incChargeTaxSplRate111A112'),10)
				// parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'),10)
		));
		var dedPartCLimit=zeroOrMore(eval(
				parseInt(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses'),10)
				//-parseInt(coalesceSetRet('partBTI.incChargeTaxSplRate111A112'),10)
				// parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'),10)-
				//-parseInt(coalesceSetRet('partBTI.profBusGain.profGainSpecifiedBus'),10)
		));
		var dedPartCLimit1=zeroOrMore(eval(
				parseInt(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses'),10)
				-parseInt(coalesceSetRet('partBTI.incChargeTaxSplRate111A112'),10)
				// parseInt(coalesceSetRet('partBTI.deductionsUnder10Aor10AA'),10)-
				//-parseInt(coalesceSetRet('partBTI.profBusGain.profGainSpecifiedBus'),10)
		));
		var BFLAii5 = document
		.getElementsByName('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
		var BFLAi5 = document
		.getElementsByName('scheduleBFLA.hp.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
		var BFLAxiii5 = document
		.getElementsByName('scheduleBFLA.othSrcInclRaceHorse.incBFLA.incOfCurYrAfterSetOffBFLosses')[0];
		var bflaFields = eval(parseInt(eval(BFLAii5.value)+ eval(BFLAi5.value)+eval(BFLAxiii5.value),10));
		var dedPartB=zeroOrMore(eval(
				parseInt(coalesceSetRet('scheduleVIA.deductUndChapVIA.totalDeductionPartb'),10)
		));
		//13a
		if(dedPartB<dedPartBLimit){
			document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartB')[0].value=dedPartB
		}else{
			document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartB')[0].value=dedPartBLimit;
		}
		//13b
		var dedPartC=zeroOrMore(eval(
				parseInt(coalesceSetRet('scheduleVIA.deductUndChapVIA.totalDeductionPartC'),10)
		));

		var deductUndChap80PTotal = document.getElementsByName('schedule80P.deductUndChap80P.total')[0];
		if(eval(parseInt(deductUndChap80PTotal.value, 10)) > 0)
		{
			if(dedPartC<bflaFields){
				document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartC')[0].value=dedPartC;
			}else{
				document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartC')[0].value=bflaFields;
			}
		}
		else
		{
			if(dedPartC<dedPartCLimit){
				document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartC')[0].value=dedPartC;
			}else{
				document.getElementsByName('partBTI.deductionsUnderScheduleVIAPartC')[0].value=dedPartCLimit;
			}
		}
		//13c
		var totalDedChapVIA=zeroOrMore(eval(
				parseInt(coalesceSetRet('partBTI.deductionsUnderScheduleVIAPartB'),10)+
				parseInt(coalesceSetRet('partBTI.deductionsUnderScheduleVIAPartC'),10)
		));

		if(dedPartBLimit<totalDedChapVIA){
			document.getElementsByName('partBTI.totalDeductionsUnderScheduleVIA')[0].value=dedPartBLimit;
		}else{

			document.getElementsByName('partBTI.totalDeductionsUnderScheduleVIA')[0].value=totalDedChapVIA;
		}

		//12

		var ded10A10AAAlwd = parseInt(coalesceSetRet('scheduleBFLA.busProfInclSpecProf.incBFLA.incOfCurYrAfterSetOffBFLosses'));

		var minValue10AA = zeroOrMore(eval(
				parseInt(coalesceSetRet('partBTI.grossTotalIncome'),10)-
				parseInt(coalesceSetRet('partBTI.incChargeTaxSplRate111A112'),10)-
				parseInt(coalesceSetRet('partBTI.totalDeductionsUnderScheduleVIA'),10)
		));


		document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0].value=Math.min(parseInt(coalesceSetRet('schedule10AA.deductSEZ.dedUs10Detail.totalDedUs10Sub'),10),parseInt(minValue10AA, 10),  ded10A10AAAlwd);


		calculatePartBTI23FBC();
		//12
		document.getElementsByName('partBTI.totalIncome')[0].value = rndOffNrsTen(zeroOrMore(eval(
				parseInt(coalesceSetRet('partBTI.grossTotalIncome'),10)-
				parseInt(coalesceSetRet('partBTI.incomeNtFormtotal'),10)
				- parseInt(coalesceSetRet('partBTI.totalDeductionsUnderScheduleVIA'),10)
		)));

		//13
		// calling SI before 13
		calcScheduleSI();

		document.getElementsByName('partBTI.incomeChargeableTotTax')[0].value = eval(
				parseInt(coalesceSetRet('scheduleSI.totSplRateTaxableInc'),10)
		);


		//14
		if(eval(
				parseInt(coalesceSetRet('scheduleEI.netAgriIncOrOthrIncRule7'),10))>5000){
			document.getElementsByName('partBTI.netAgricultureIncomeOrOtherIncomeForRate')[0].value = eval(
					parseInt(coalesceSetRet('scheduleEI.netAgriIncOrOthrIncRule7'),10));
		} else {
			document.getElementsByName('partBTI.netAgricultureIncomeOrOtherIncomeForRate')[0].value=0;
		}

		//15
		calculateAggregateIncome();


		//16
		if(document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value=='21')
		{
			document.getElementsByName('partBTI.lossesOfCurrentYearCarriedFwd')[0].value = eval(
					parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmInsuCF'),10)
			);
		}
		else
		{
			document.getElementsByName('partBTI.lossesOfCurrentYearCarriedFwd')[0].value = eval(
					parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.busLossOthThanSpecLossCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecBusCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmSpecifiedBusCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.lossFrmInsuCF'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal'),10)
					+ parseInt(coalesceSetRet('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF'),10)
			);
		}
		//19
		/*document.getElementsByName('partBTI.deemedIncomeunderSec115JC')[0].value =
		eval(parseInt(coalesceSetRet('itrScheduleAMT.adjustedUnderSec115JC'),10));

		 */
	}catch(e){
		alert(e.stack);
	}
}



function adjustFormPartAGEN2(){

	var pan=document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var fourth;
	if(pan!=undefined && pan!=''){
		pan = pan.toUpperCase();
		fourth= pan.charAt(3);
	}


	if(substatusCompany==8 || substatusCompany==12 || substatusCompany==20 || substatusCompany==21 ){
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].disabled = false;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].disabled = false;
	}else{
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].value='';
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value='';
	}

	if(statusCompany=='2' || statusCompany=='9' || statusCompany==''){
		document.getElementsByName('partAGEN2.prevYrMemPartChange')[0].disabled = true;
		document.getElementsByName('partAGEN2.prevYrMemPartChange')[0].value='';
	}else{
		document.getElementsByName('partAGEN2.prevYrMemPartChange')[0].disabled = false;

	}

	//Enable 80P for co-op

	if(substatusCompany== '17' ||  substatusCompany== '15' || substatusCompany== '16' || substatusCompany== '4'){
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80P')[0].disabled = false;

	}else{
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80P')[0].disabled = true;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80P')[0].value='';
	}

}


function enableYesNoForForeignCompFlg(element1,element2){

	if(document.getElementsByName(element1)[0].value=='NO'){

		document.getElementsByName(element2)[0].disabled=true;
		document.getElementsByName(element2)[0].value="";
	}
	else if(document.getElementsByName(element1)[0].value=='YES'){

		document.getElementsByName(element2)[0].disabled=false;

	}
	else{
		document.getElementsByName(element2)[0].disabled=true;
		document.getElementsByName(element2)[0].value="";

	}

}



function deleteRowTablebadDebtPL(tx,ty,tz){
	deleteRowTable(tx,ty,tz);
	calculatePL();
}

function deleteRowTableOprtRev(tx,ty,tz){
	deleteRowTable(tx,ty,tz);
	calculatePL();
}

function deleteRowTableOthExp(tx,ty,tz){
	deleteRowTable(tx,ty,tz);
	calculatePL();
}

function deleteRowTableOthInc(tx,ty,tz){
	deleteRowTable(tx,ty,tz);
	calculatePL();
}

function validateOnSubmit() {

	try{
		validateOSdropDown();
		validateOSEAdropDown();
		validateOSPTI115dropDown();
		validateOSPTIEAdropDown();
		validateOSDTAAEAdropDown();
		validateOSDTAAPTIEAdropDown();
		validateOSDTAAPTI115dropDown();
		validateOSDTAA115dropDown();
		calculatePercentageSharePrpty();
		selfOccupiedPrprtyCheck();
		validateBPPL();
		validateNatureOfBusiness();
		validateOsBbdaLottery();
		appendzeroto5or6TCS();
		checkDropdownSelectedin1d();
		validatePLafter61();
		validateBPforPoint38();
		verificationPanValidation('partAGEN2PartnerOrMemberInfoTable');
		threeFieldsValidationforTDS2OnSave();
		threeFieldsValidationforTDS3OnSave();
		validateTDS2();
		validateTDS3();
		validate80GGA();
		validateSchRA();
		calculateRemurationPaid46();
		othergener1();
		//validateReturnFilingType();
		//validateCGDedDate();
		showTaxRateMsg();
		checkForeignSelected();
		calcSchCGLtcgStcg();
		validateCGSecwiseDed();
		validateScheduleHP();
		intrstBorowdCheck();
		calculateFullVal50CStcg();
		calculateFullVal50CLtcg();
		checkSchFAMandatory();
		checkSchRAMandatory();
		checkQDRawMatMandatory('scheduleQDRaw','scheduleQDFin');
		validateUD();
		balSheetWarnig();
		validatepoint1513();
		checkAmtcSubmit();
		checkAMTCCurAY();
		validatePartners();
		validateHPRent();
		calculateTDS();
		calculateTCS();
		checkAMTCCurAY();
		validateFSI();
		priBankMandtry();
		CheckHPShareProperty();
		checkUniqueOSSec();
		//CheckPLExpenses();
		//CheckProfExpenses();
		CheckBFLAUDMismatch();
		checkEmptySchUDAmt();
		validatePercentA1B1();
		//checkSIAmount();
		validateSI();
		scheduleHPCalcFor5();
		calculateTotalTaxIT('scheduleIt');
		checkPercentShare(); // Part A gen 2 Table E
		checkUniqueTableCol('scheduleFSI', 'countryCode$','Same Country cannot be selected more than once.');
		makePartAGenRowOneMandate();
		checkLLIPNForTwoLLP();
		percentageShareMan();
		
		validatePriceShare();
		validateSTCGSectionWiseDTAA();
		validateLTCGSectionWiseDTAA();
		panValidation80G('ded100PerWithoutQual');
		panValidation80G('ded50WithoutQual');
		panValidation80G('ded100Qual');
		panValidation80G('ded50WithQual');
		panValidation80GGA('schedule80GGA');
		setSecRespOnSave();
		validateSecHidden();
		setCG54Dtls();
		validateScheduleVIA();
		mandateA6();
		mandateB8();
		calculatePL();
		calcTotSchPL47i();
		validateSEBI();
		validatePartAGen2();
		validateAuditDtls();
		calcTotalAmt('schEIMinorChild');
		hideAddButtonIF();
		//Always keep alertItr2User() at the last
		alertItr5User();
		pdtItr5NotReqd();
		validateDTAAStcg();
		validateDTAALtcg();
		validateTDS29Grtthen67();
		validateTDS39Grtthen67();
		validateOSPoint8();
		checkFor16thFiledValue();
		calculateTotalDeductions();
		validateNatureOfBussiness();
		validate80GTableAForCashAndOtherMode();
		validate80GTableBForCashAndOtherMode();
		validate80GTableCForCashAndOtherMode();
		validate80GTableDForCashAndOtherMode();
		validateOSd();
		validateOSe();
		validateSchOSDTAA1a1b();
		sysDateCompOfDOF();
		sysDateCompOfResToNotice();
		checkFor80PFiledValue();
		enableSch80p();
		
		natureOfBusChck('natOfBustTradeTableId',2,1);		
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.assYr')[0].value='2020-21';

		document.getElementsByName('scheduleDI.deductionUndChapVIA[0].section')[0].value='80G';
		document.getElementsByName('scheduleDI.deductionUndChapVIA[1].section')[0].value='80GGA';
		document.getElementsByName('scheduleDI.deductionUndChapVIA[2].section')[0].value='80GGC';

	}catch(e){
		alert('error in validate=' + e.stack);
	}

}

function validatePartAGen2() {
	var tab1 = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var noOfRows=tab1.rows.length;
	for ( var i = 0; i < (noOfRows-4); i++) {
		var status = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].status')[0].value;
		var pan = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].pan')[0].value;
		if(status == 'PRINCIPAL_OFFICER' && pan == '') {
			addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].pan')[0],'Please enter a PAN',true);
			j.setFieldError('partAGEN2.partnerOrMemberInfo[0].pan','Please enter a PAN');
		}
	}
}
function calcTotFullConA(a,b,c) {

	var afield = document.getElementsByName(a)[0];
	var bfield = document.getElementsByName(b)[0];
	var cfield = document.getElementsByName(c)[0];
	if(parseInt(coalesce(afield.value),10) > parseInt(coalesce(bfield.value),10)){
		cfield.value = parseInt(coalesce(afield.value),10);
	}
	else{
		cfield.value = parseInt(coalesce(bfield.value),10);
	}

}
function fullConsideration(){
	var totalfullvale =document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration')[0].value;
	//if(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration')[0].value  )
		
//if(totalfullvale != 0){
	document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.totalDedn')[0].value = eval(coalesceSetRet("scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.aquisitCost") +
				coalesceSetRet("scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.improveCost")+
				coalesceSetRet("scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.expOnTrans"));
//}
	
}





function validateSEBI() {

	var value = document.getElementsByName('partAGEN1.filingStatus.sebiRegnNo')[0].value;
	var fiiFpiFlg = document.getElementsByName('partAGEN1.filingStatus.fiiFpiFlg')[0].value;

	if (fiiFpiFlg == 'Y' && !isNaN(value) && parseInt(value,10) == 0) {
		addErrorXHTML(document.getElementsByName('partAGEN1.filingStatus.sebiRegnNo')[0],'Please enter valid SEBI Registration Number.', true);
		j.setFieldError('partAGEN1.filingStatus.sebiRegnNo','Please enter valid SEBI Registration Number.');
	}
}


//mandatory Field A6.
function mandateA6()
{
	var valueA13 = parseInt('0',10);
	var valueAb4 = parseInt('0',10);

	var table = document.getElementById('scheduleCGstcg1');
	var noOfRows = table.rows.length;

	var tempa13=parseInt('0',10);
	var tempa131=parseInt('0',10);

	var tempaAb4=parseInt('0',10);
	var tempaAb41=parseInt('0',10);

	for (var i = 0; i <noOfRows/14; i++) {
		//calcBalance
		var valueA13 = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+i+'].fullConsideration50C')[0].value;

		tempa13 = parseInt(valueA13.value)+parseInt(tempa131);

		tempa131=  parseInt(tempa13);
		var valueAb4 = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+i+'].deductSec48totalDedn')[0].value;

		tempaAb4 = parseInt(valueAb4.value)+parseInt(tempaAb41);

		tempaAb41=  parseInt(tempaAb4);

	}

	valueA13 = tempa13;

	valueAb4 = tempaAb4;

	var valueA1d = parseInt('0',10);
	for (var i = 0; i <noOfRows/14; i++) {
		var r = i+1;
		var tableId = 'stcgDeduction_ded'+r;
		var table1 = document.getElementById(tableId);
		var noOfRows1 = table1.rows.length;
		for (var f = 0; f<parseInt(noOfRows1)-3; f++) {
			valueA1d = eval(parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+i+'].exemptionOrDedn['+f+'].amount')[0].value),10)+valueA1d);
		}
	}


	
	var valueA2ia=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].fullConsideration')[0].value;
	var valueA2b4=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48totalDedn')[0].value;
	var valueA2d=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].lossSec94of7Or94of8')[0].value;


	var valueA3a=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid')[0].value;
	var valueA3b=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid')[0].value;


	var valueA4a=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0].value;
	var valueA44=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48totalDedn')[0].value;
	var valueA4d=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.capgainonAssets')[0].value;


	var valueA5a=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsideration')[0].value;
	var valueA54=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.deductSec48.totalDedn')[0].value;
	var valueA5d=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.capgainonAssets')[0].value;

	var valueA6=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.totAmtStcgUnderDtaa')[0].value;
	//var valueA8=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.amtDeemedCGDepAssets')[0];

	var valueSTCG= parseInt(coalesce(valueA13),10) + parseInt(coalesce(valueAb4),10) + parseInt(coalesce(valueA1d),10)
	+ parseInt(coalesce(valueA2ia),10) + parseInt(coalesce(valueA2b4),10) + parseInt(coalesce(valueA2d),10)
	+ parseInt(coalesce(valueA3a),10) + parseInt(coalesce(valueA3b),10) + parseInt(coalesce(valueA4a),10)
	+ parseInt(coalesce(valueA44),10) + parseInt(coalesce(valueA4d),10) + parseInt(coalesce(valueA5a),10)
	+ parseInt(coalesce(valueA54),10) + parseInt(coalesce(valueA5d),10) + parseInt(coalesce(valueA6),10);

	var fieldSTCG = document
	.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unutilizedCapgainFlag')[0];


	if ((valueSTCG > 0 || valueSTCG < 0) && fieldSTCG.value == "") {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.unutilizedCapgainFlag',
		'Please select whether any amount of unutilized capital gain on asset transferred during the previous years in A9a of Schedule CG');
		addErrorXHTML(
				fieldSTCG,
				'Please select whether any amount of unutilized capital gain on asset transferred during the previous years in A9 of Schedule CG',
				true);
	}

}


//Mandatory Field B8.
//Mandatory Field B8.
function mandateB8()
{

	var valueBa3 = parseInt('0',10);
	var valueBb4 = parseInt('0',10);

	var table = document.getElementById('scheduleCGltcg1');
	var noOfRows = table.rows.length;

	var tempa13=parseInt('0',10);
	var tempa131=parseInt('0',10);

	var tempaAb4=parseInt('0',10);
	var tempaAb41=parseInt('0',10);

	for (var i = 0; i <noOfRows/14; i++) {
		//calcBalance
		var valueBa3 = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+i+'].fullConsideration50C')[0].value;

		tempa13 = parseInt(valueBa3.value)+parseInt(tempa131);

		tempa131=  parseInt(tempa13);

		var valueBb4 = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+i+'].deductSec48totalDedn')[0].value;

		tempaAb4 = parseInt(valueBb4.value)+parseInt(tempaAb41);

		tempaAb41=  parseInt(tempaAb4);

	}

	valueBa3 = tempa13;

	valueBb4 = tempaAb4;

	var valueB1d = parseInt('0',10);
	for (var i = 0; i <noOfRows/14; i++) {
		var r = i+1;
		var tableId = 'ltcgDeduction1_ded'+r;
		var table1 = document.getElementById(tableId);
		var noOfRows1 = table1.rows.length;
		for (var f = 0; f<parseInt(noOfRows1)-3; f++) {
			valueB1d = eval(parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+i+'].exemptionOrDedn['+f+'].amount')[0].value),10)+valueB1d);
		}
	}

	var valueB2a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.fullConsideration')[0].value;
	var value2Bb4=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.deductSec48.totalDedn')[0].value;


	var valueB3a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].fullConsideration')[0].value;
	var valueB34=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].deductSec48.totalDedn')[0].value;

	/*	var valueB4a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.ltcgWithoutBenefit')[0].value;
	 *//*	var valueB4b=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.exemptionOrDednUs54')[0].value;
	 */
	var valueB5a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].fullConsideration')[0].value;
	var valueB54=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].deductSec48.totalDedn')[0].value;
	/*	var valueB5d=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].exemptionOrDednUs54S')[0].value;
	 */
	/*var valueB6a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRISaleofForeignAsset.saleonSpecAsset')[0].value;
	var valueB6b=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRISaleofForeignAsset.dednSpecAssetus115')[0].value;
	var valueB6d=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRISaleofForeignAsset.saleOtherSpecAsset')[0].value;
	var valueB6e=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRISaleofForeignAsset.dednOtherSpecAssetus115')[0].value;*/

	var valueB7a=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration')[0].value;
	var valueB74=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.totalDedn')[0].value;
	var valueB7d=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.exemptionOrDednUs54S')[0].value;
	coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.exemptionOrDednUs54S');


	var valueB9=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.totAmtLtcgUnderDtaa')[0].value;

	var valueB8=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')[0].value;

	var fieldLTCG=document.getElementsByName('scheduleCGPost45.LongTermCapGainPost45.unutilizedCapgainFlag')[0];

	var valueLTCG=parseInt(coalesce(valueBa3),10) + parseInt(coalesce(valueBb4),10)
	+ parseInt(coalesce(valueB1d),10) + parseInt(coalesce(valueB2a),10) + parseInt(coalesce(value2Bb4),10)
	+ parseInt(coalesce(valueB3a),10) + parseInt(coalesce(valueB34),10)
	+ parseInt(coalesce(valueB5a),10) + parseInt(coalesce(valueB54),10)
	+ parseInt(coalesce(valueB7a),10) 
	+ parseInt(coalesce(valueB74),10)
	+ parseInt(coalesce(valueB7d),10) + parseInt(coalesce(valueB9),10)  + parseInt(coalesce(valueB8),10);

	var fieldLTCG = document.getElementsByName('scheduleCGPost45.LongTermCapGainPost45.unutilizedCapgainFlag')[0];

	if ((valueLTCG > 0 || valueLTCG < 0) && fieldLTCG.value == "") {
		j.setFieldError(
				'scheduleCGPost45.LongTermCapGainPost45.unutilizedCapgainFlag',
		'Please select whether any amount of unutilized capital gain on asset transferred during the previous years in B13 of Schedule CG');
		addErrorXHTML(
				fieldLTCG,
				'Please select whether any amount of unutilized capital gain on asset transferred during the previous years in B13 of Schedule CG',
				true);
	}

}


function setCG54Dtls() {
	var tab1 = document.getElementById('scheduleStcgunUtilizedCapGain54');
	var noOfRows=tab1.rows.length;

	for ( var i = 0; i < (noOfRows-3); i++) {
		var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['+i+'].section')[0].value;
		if(section != '') {
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['+i+'].ay')[0].value = '2016-17';
		} else {
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['+i+'].ay')[0].value = '';
		}
	}


	var tab1 = document.getElementById('scheduleLtcgunUtilizedCapGain54');
	var noOfRows=tab1.rows.length;

	for ( var i = 0; i < (noOfRows-3); i++) {
		var section = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['+i+'].section')[0].value;
		if(section != '') {
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['+i+'].ay')[0].value = '2016-17';
		} else {
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['+i+'].ay')[0].value = '';
		}
	}
}

function checkPercentShare() {
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if(status==1 || (status==1 && substatus==5)) {
		var tab = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
		var rowCount = tab.rows.length;
		var sharePercentage = 0;
		var retiredSharePercentage = 0;
		for(var i=0;i<eval(parseInt(rowCount,10)-4);i++){

			var patnerStatus = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].status')[0].value;
			if(patnerStatus != "IND_RETIRED"){
				sharePercentage = eval(sharePercentage + (mulFloatBy100(document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].sharePercentage')[0].value)));
			}
		}

		if(checkHPShareSum(sharePercentage/100)){
			j.setFieldError('partAGEN2.partnerOrMemberInfo[0].sharePercentage','Please ensure that total share of percentage for existing partners must be equal to 100.');
			addErrorXHTML('','Please ensure that total share of percentage for existing partners must be equal to 100.',true);
		}
	}

}

//Calculate Total Tax for Schedule-IT.
function calculateTotalTaxIT(tableId){

	var tab1 = document.getElementById('scheduleIt');
	var noOfRows=tab1.rows.length;
	var sum = 0;
	var amt = 0;

	for ( var i = 0; i < (noOfRows-3); i++) {
		amt = document.getElementsByName('scheduleIT.taxPayment['+i+'].amt')[0].value;
		sum = eval(parseInt(sum,10) + parseInt(coalesce(amt),10));
	}
	document.getElementsByName('scheduleIT.taxPayment.totalTaxPayments')[0].value = parseInt(sum,10);
}

function scheduleFSIAlert()
{
	var tableFSI = checkRowBlank('scheduleFSI', 3, 2);
	if(tableFSI==false){

		addErrorXHTML('','Please ensure that the incomes shown in Schedule FSI  are also reflected under respective income schedules.');

	}

}


//Function to check if Schedule FA is Mandatory.
/*2019 changes*/
function checkSchFAMandatory() {

	var table1 = checkRowBlank('schFADtlsFrignAssetsA1', 2, 1);
	var table2 = checkRowBlank('schFADtlsFrignAssetsA2', 2, 1);
	var table3 = checkRowBlank('schFADtlsFrignAssetsA3', 2, 1);
	var table4 = checkRowBlank('schFADtlsFrignAssetsA4', 2, 1);
	var table5 = checkRowBlank('schFADtlsFinIntrest', 2, 1);
	var table6 = checkRowBlank('schFADtlsImmvbleProp', 2, 1);
	var table7 = checkRowBlank('schFADtlsOtherAsset', 2, 1);
	var table8 = checkRowBlank('schFADtlsSigningAuth', 2, 1);
	var table9 = checkRowBlank('schFADtlsTrusts', 2, 1);
	var table10 = checkRowBlank('DetailsOthIncomeOutsideIndia', 2, 1);

	if(document.getElementsByName('partBTTI.assetOutIndiaFlag')[0].value=='YES' && document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value!='NRI') {
		if(table1 && table2 && table3 && table4 && table5 && table6 && table7 && table8 && table9 && table10) {
			j.setFieldError('scheduleFA.detailsForiegnBank[0].countryCode','Please enter any one table in Schedule FA.');
			addErrorXHTML('','Please enter any one table in Schedule FA.');
		}
	}
	if(document.getElementsByName('partBTTI.assetOutIndiaFlag')[0].value=='NO' && document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value!='NRI') {
		if( !(table1 && table2 && table3 && table4 && table5 && table6 && table7 && table8 && table9 && table10) ) {
			j.setFieldError('partBTTI.assetOutIndiaFlag','Please correct your selection of assets outside India in Part B -TTI.');
			addErrorXHTML('','Please correct your selection of assets outside India in Part B -TTI.');
		}
	}
}


function validateScheduleHP(){
	var tab = document.getElementById('scheduleHPMain');
	var allInputTags = tab.getElementsByTagName('select');
	var count = 0;
	for(var i=0; i<allInputTags.length; i++ ){
		if(allInputTags[i].name.match("ifLetOut$")){
			if(allInputTags[i].value=="N"){
				if(++count > 2){
					j.setFieldError(allInputTags[i].name,'Where there is more than Two Self occupied House property(SOP) , one of them shall be treated as SOP and all other House properties shall be deemed to be let out');
					break;
				}
			}
		}
	}
}
function checkQDRawMatMandatory(tableId1,tableId2){
	try{
		var tab = document.getElementById(tableId1);
		var allInputTags = tab.getElementsByTagName('input');

		var tabFin = document.getElementById(tableId2);
		var allInputTagsFin = tabFin.getElementsByTagName('input');

		var rawMatCheck=false;
		var finGoodsCheck=false;

		var allInputTagsSelect = tab.getElementsByTagName('select');
		var allInputTagsSelectFin = tabFin.getElementsByTagName('select');

		if(tableId1=='scheduleQDRaw'){

			for(var i=0;i<allInputTags.length;i++ ){

				if(allInputTags[i].value !='' && !rawMatCheck && allInputTags[i].type !='checkbox' && allInputTags[i].type !='hidden'){

					rawMatCheck=true;
					break;

				}
			}

			for(var i=0;i<allInputTagsSelect.length;i++ ){
				if( allInputTagsSelect[i].value !='' && !rawMatCheck){
					rawMatCheck=true;
					break;

				}
			}

		}

		if(tableId2=='scheduleQDFin'){

			for(var i=0;i<allInputTagsFin.length;i++ ){
				if(allInputTagsFin[i].value !='' && !finGoodsCheck && allInputTagsFin[i].type !='checkbox' && allInputTagsFin[i].type !='hidden'){
					finGoodsCheck=true;
					break;
				}
			}


			for(var i=0;i<allInputTagsSelectFin.length;i++ ){
				if(allInputTagsSelectFin[i].value !='' && !finGoodsCheck ){
					finGoodsCheck=true;

					break;
				}
			}

		}

		if(rawMatCheck && !finGoodsCheck){

			addErrorXHTML('','At least one entry is required in Finished goods in the sheet Quantitative Details');
			j.setFieldError('partaqd.manfactrConcern.finishrByProd.quantitDet[0].itemName','At least one entry is required in Finished goods in the sheet Quantitative Details');
		}

		if(!rawMatCheck && finGoodsCheck){

			addErrorXHTML('','At least one entry is required in Raw Materials in the sheet Quantitative Details');
			j.setFieldError('partaqd.manfactrConcern.rawMaterial.quantitDet[0].itemName','At least one entry is required in Raw Materials in the sheet Quantitative Details');

		}
	}catch(e){
		alert('errorrrrr checkQDRawMatMandatory: ' +e);
	}
}
function totAmtOfSchedFSIFor6(tableId){

	var tab = document.getElementById(tableId);
	var allInputTags = tab.getElementsByTagName('input');
	var totIncFromHPPartBTIA = parseInt('0' ,10);
	var totIncBusinessPartBTIB = parseInt('0' ,10);
	var totIncCapGainPartBTIC = parseInt('0' ,10);
	var totIncOthSrcPartBTID = parseInt('0' ,10);
	var totalAmtCountryWise = parseInt('0' ,10);
	var totalCountryWise = parseInt('0' ,10);
	var totalIncomeOutIndiaWoDTAA = document.getElementsByName('itrScheduleFSI.totalIncomeOutIndiaWoDTAA')[0]; totalIncomeOutIndiaWoDTAA.value = coalesce(totalIncomeOutIndiaWoDTAA.value);

	for(var i = 0; i < allInputTags.length; i++) {

		if (allInputTags[i].name.match("incFromHPPartBTIA$")) {
			totIncFromHPPartBTIA = eval ( parseInt(totIncFromHPPartBTIA ,10) + parseInt( coalesce(allInputTags[i].value) ,10) );
			totIncBusinessPartBTIB = eval ( parseInt(totIncBusinessPartBTIB ,10) + parseInt( coalesce(allInputTags[i+1].value) ,10));
			totIncCapGainPartBTIC = eval ( parseInt(totIncCapGainPartBTIC ,10) + parseInt( coalesce(allInputTags[i+2].value) ,10) );
			totIncOthSrcPartBTID = eval ( parseInt(totIncOthSrcPartBTID ,10) + parseInt( coalesce(allInputTags[i+3].value) ,10) );
			if(allInputTags[i].value=='' && allInputTags[i+1].value=='' && allInputTags[i+2].value=='' && allInputTags[i+3].value==''){
				allInputTags[i+4].value = '';
			}else{
				allInputTags[i+4].value=eval(parseInt( coalesce(allInputTags[i].value) ,10)+ parseInt( coalesce(allInputTags[i+1].value)) + parseInt( coalesce(allInputTags[i+2].value)) + parseInt( coalesce(allInputTags[i+3].value)));
			}
			totalAmtCountryWise = eval ( parseInt(totalAmtCountryWise ,10) + parseInt( coalesce(allInputTags[i+4].value) ,10) );
		}
	}

	document.getElementsByName('itrScheduleFSI.totIncFromHPPartBTIA')[0].value=totIncFromHPPartBTIA;
	document.getElementsByName('itrScheduleFSI.totIncBusinessPartBTIB')[0].value=totIncBusinessPartBTIB;
	document.getElementsByName('itrScheduleFSI.totIncCapGainPartBTIC')[0].value=totIncCapGainPartBTIC;
	document.getElementsByName('itrScheduleFSI.totIncOthSrcPartBTID')[0].value=totIncOthSrcPartBTID;
	document.getElementsByName('itrScheduleFSI.totalAmtCountryWise')[0].value=totalAmtCountryWise;
	document.getElementsByName('itrScheduleFSI.totalIncomeOutIndia')[0].value=totalAmtCountryWise;
	var totalIncomeOutIndiaWoDTAATemp = eval(totalAmtCountryWise)-eval(parseInt(coalesce(document.getElementsByName('itrScheduleFSI.totalIncomeOutIndiaDTAA')[0].value ,10)));

	if( parseInt(totalIncomeOutIndiaWoDTAATemp ,10) >0 ){
		totalIncomeOutIndiaWoDTAA.value = totalIncomeOutIndiaWoDTAATemp;
	}else{
		totalIncomeOutIndiaWoDTAA.value = parseInt(0,10);
	}


}

function convertPercentToDecimal(element){

	var fieldName=element.name;
	var fieldVal=element.value;
	if(fieldVal.indexOf('%') !='-1'){
		fieldVal=fieldVal.substring(0,fieldVal.indexOf('%'));
		fieldVal=Math.round(fieldVal);
		element.value=fieldVal/100;

	}

}

function populatePincode(state,pin){
	var stateId = document.getElementsByName(state)[0];
	var pinCode = document.getElementsByName(pin)[0];

	if(stateId.value != '99' && stateId.value != '-1'){
		pinCode.value='';
	}else if(stateId.value == '99'){
		pinCode.value='999999';
	}
}

/*function validateReturnFilingType(){
	var fileSec=document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var returnType=document.getElementsByName('partAGEN1.filingStatus.returnType')[0].value;

	if(fileSec!='17' && returnType=='R'){

		addErrorXHTML(document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0],'"Section" field in "Part A-General information" can only be "Revised return under section 139(5)" for Filing type "Revised"',true);
		j.setFieldError('partAGEN1.filingStatus.returnFileSec.incomeTaxSec',"'Section' field in 'Part A-General information' can only be 'Revised return under section 139(5)' for Filing type 'Revised'");
	}

	if(fileSec=='18' && (returnType=='T')){

		addErrorXHTML(document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0],'"Section" field in "Part A-General information" cannot be "In response to notice under section 139(9)" for Filing type "Rectification"',true);
		j.setFieldError('partAGEN1.filingStatus.returnFileSec.incomeTaxSec',"'Section' field in 'Part A-General information' cannot be 'In response to notice under section 139(9)' for Filing type 'Rectification'");
	}

	if(fileSec!='18' && (returnType=='C')){

		addErrorXHTML(document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0],'"Section" field in "Part A-General information" can be only "In response to notice under section 139(9)" for Filing type "In response to a notice u/s 139(9)"',true);
		j.setFieldError('partAGEN1.filingStatus.returnFileSec.incomeTaxSec',"'Section' field in 'Part A-General information' can be only 'In response to notice under section 139(9)' for Filing type 'In response to a notice u/s 139(9)'");
	}

	if((fileSec=='17'|| fileSec=='18')&& returnType=='O'){

		addErrorXHTML(document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0],'"Section" field in "Part A-General information" cannot be "In response to notice under section 139(9)" / "revised return under section 139(5)" for Filing type "Original"',true);
		j.setFieldError('partAGEN1.filingStatus.returnFileSec.incomeTaxSec',"'Section' field in 'Part A-General information' cannot be 'In response to notice under section 139(9)' / 'revised return under section 139(5)' for Filing type 'Original'");
	}

}

 */

function calcTotSchEIOthers(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('schEIMinorChild');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("othAmount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}

	document.getElementsByName('scheduleEI.others')[0].value = amtTotal;
}


function calcTotSchEIDTAA(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('incomeDTAAEITable');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amountOfIncome$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}

	document.getElementsByName('scheduleEI.incChrgblAsPerDTAA')[0].value = amtTotal;
}

//Calculate Total Income for Schedule EI.
function calTotalEI(){
	//document.getElementsByName('scheduleEI.AgriIncOrOthrIncRule7')[0].value=document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.BalanceOfIncomeDeemed')[0].value;

	document.getElementsByName('scheduleEI.totalExemptInc')[0].value=
		coalesceSetRet('scheduleEI.interestInc')+
		coalesceSetRet('scheduleEI.dividendInc')+
		coalesceSetRet('scheduleEI.netAgriIncOrOthrIncRule7')+
		coalesceSetRet('scheduleEI.others')+
		coalesceSetRet('scheduleEI.incChrgblAsPerDTAA')+
		coalesceSetRet('scheduleEI.incNotChrgblToTax');
}

//To calculate NetAgricultureIncomeforEI
function calculateNetAgricultureIncomeforEI() {
	var grossAgriReceipt7B8 = document.getElementsByName('scheduleEI.grossAgriReceipt7B8')[0].value;
	var expendAgriculture = document.getElementsByName('scheduleEI.expendAgriculture')[0].value;
	var expendAgricultureUnabsorbed = document.getElementsByName('scheduleEI.expendAgricultureUnabsorbed')[0].value;
	var expendAgricultureinc= document.getElementsByName('scheduleEI.AgriIncOrOthrIncRule7')[0].value;

	var result = parseInt(zeroOrMore(parseInt(grossAgriReceipt7B8)))
	- parseInt(zeroOrMore(parseInt(expendAgriculture)))
	- parseInt(zeroOrMore(parseInt(expendAgricultureUnabsorbed)))
	+ parseInt(zeroOrMore(parseInt(expendAgricultureinc)));
	if(result<0)
	{
		document.getElementsByName('scheduleEI.netAgriIncOrOthrIncRule7')[0].value =0;
	}
	else
	{
		document.getElementsByName('scheduleEI.netAgriIncOrOthrIncRule7')[0].value = result;
	}

}

function copySourceDestn(source,destination){

	document.getElementsByName(destination)[0].value=document.getElementsByName(source)[0].value;
}

function calculateTiTti(cgosIncome) {
	var varDate = document.getElementsByName('verification.date')[0];
	if(varDate.value=='' || varDate.value==undefined || varDate.value== null){
		var dt = new Date();
		varDate.value= ("00" + dt.getDate()).slice(-2) + '/' + ("00" + (dt.getMonth()+1)).slice(-2)+ '/' + dt.getFullYear() ;
	}

	calculatePartBTTI_first(cgosIncome);


}

function coalesce(value){
	if (isNaN(value) || value=='') {
		value = 0;
	}
	return value;
}

function zeroOrMore(val){
	val = coalesce(val);
	if(val < 0){
		return 0;
	}
	return val;
}

function rndOffNrsTen(newVar){

	if(  parseInt(newVar.toString().charAt(newVar.toString().length-1),10) >= parseInt('5',10)){
		newVar = eval(Math.floor(eval(parseInt(newVar,10) / parseInt('10',10))) * parseInt('10',10));
		newVar = eval(parseInt(newVar,10) + parseInt('10',10));

		return newVar;
	}else{
		newVar = eval(Math.floor(eval(parseInt(newVar,10) / parseInt('10',10))) * parseInt('10',10));

		return newVar;
	}

}
function revisedSetFor6OnLoad(section){

	var fileSec=document.getElementsByName(section)[0].value;

	if(fileSec=='17' || fileSec=='19')
	{

		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;

	}
	else if(fileSec=='18')
	{

		//document.getElementsByName(type)[0].value='C';
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = false;
		
	}
	else if(fileSec !='17' || fileType.value!='R')
	{
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=true;
		if(fileSec=='20'){
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;
			document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled=false;
		}
	} else if (fileSec == '20') {
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value = '';
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled = false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled=false;
	}
	if (fileSec == '13' || fileSec == '14' || fileSec == '15'|| fileSec == '16' || fileSec == '18' || fileSec == '19')
	{
		enableField('partAGEN1.filingStatus.secHidden',
				fileSec, 'partAGEN1.filingStatus.returnFileSec.noticeDate');
		enableField('partAGEN1.filingStatus.secHidden',
				fileSec, 'partAGEN1.filingStatus.uniqNumOrDocIdNum');
	} else if (fileSec == '11' || fileSec == '12' || fileSec == '17' || fileSec == '') {
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value = '';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = true;
	}
	if (fileSec == '11' || fileSec == '12' || fileSec == '13'
		|| fileSec == '14' || fileSec == '15' || fileSec == '16')
	{
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].value='';

		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=true;

	}
	if (fileSec == '11' || fileSec == '12' || fileSec == '13'
		|| fileSec == '14' || fileSec == '15' || fileSec == '16')
	{
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;
	}
	if (fileSec == '13' || fileSec == '14' || fileSec == '15'
		|| fileSec == '16' || fileSec == '19'|| fileSec == '20')
	{
		document
		.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled = false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = false;
	}
	if (fileSec == '19')
	{
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = true;
	}
}


function revisedSetFor6(section)
{

	var fileSec=document.getElementsByName(section)[0].value;

	if(fileSec=='17' || fileSec=='19')
	{

		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;

	}
	else if(fileSec=='18')
	{
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = false;

	}
	else if(fileSec !='17')
	{
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=true;
		if(fileSec == '20')
		{
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;
			document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0],disabled=false;
		}
	} else if(fileSec == '20')
	{

		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value = '';
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled = false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled=false;

	}
	if (fileSec == '13' || fileSec == '14' || fileSec == '15'|| fileSec == '16' || fileSec == '18' || fileSec == '19')
	{
		enableField(section,fileSec, 'partAGEN1.filingStatus.returnFileSec.noticeDate');
		enableField(section,fileSec, 'partAGEN1.filingStatus.uniqNumOrDocIdNum');
	}
	else if (fileSec == '11' || fileSec == '12' || fileSec == '17' || fileSec == '')
	{
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value = '';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = true;
	}
	if (fileSec == '11' || fileSec == '12' || fileSec == '13'
		|| fileSec == '14' || fileSec == '15' || fileSec == '16')
	{
		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].value='';

		document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=true;
		document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=true;

	}
	if (fileSec == '13' || fileSec == '14' || fileSec == '15' || fileSec == '16' || fileSec == '19'|| fileSec == '20')
	{
		document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled = false;
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = false;

	}
	if (fileSec == '19' ||fileSec == '20')
	{
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].value='';
		document.getElementsByName("partAGEN1.filingStatus.uniqNumOrDocIdNum")[0].disabled = true;
	}

}

function returnSecCheck(Sec,Resp){
	var Sec = document.getElementsByName(Sec)[0];
	var Resp = document.getElementsByName(Resp)[0];
	var secHidden = document.getElementsByName('partAGEN1.filingStatus.secHidden')[0];
	if(Sec.value!=''){
		Resp.value='';
		secHidden.value=Sec.value;
	}

}

function returnSecRespCheck(Sec,Resp){
	var Sec = document.getElementsByName(Sec)[0];
	var Resp = document.getElementsByName(Resp)[0];
	var secHidden = document.getElementsByName('partAGEN1.filingStatus.secHidden')[0];
	if(Resp.value!=''){
		Sec.value='';
		secHidden.value=Resp.value;
	}

}
/*function sectionSetFor6(section,type){
  var fileSec = document.getElementsByName(section)[0];
  var fileType=document.getElementsByName(type)[0].value;

      if(fileType=='R' && fileSec.value!='17'){
          fileSec.value='17';
      }
      else if(fileType=='C' && fileSec.value!='18'){
          fileSec.value='18';
      }
      else if(fileType=='T' && fileSec.value!='18'){
			document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
			document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;
  			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
  			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].disabled=true;
			if(fileSec.value=='13' || fileSec.value=='14' || fileSec.value=='15' || fileSec.value=='16' || fileSec.value=='19'){
				document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;
			}
      }else{
    	  fileSec.value='';
      }

      if(fileType=='R') {
          document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;
          document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].readOnly=false;
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].readOnly=false;
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].value='';
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].disabled=true;
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].value='';
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=true;

      } else if(fileType=='C'){
    	  document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;
          document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].readOnly=false;
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].readOnly=false;
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].disabled=false;
          document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;

      } else if(fileType=='T'){
			document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=false;
			document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=false;

			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].value='';
			document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeNo")[0].disabled=true;
			if(fileSec.value=='13' || fileSec.value=='14' || fileSec.value=='15' || fileSec.value=='16' || fileSec.value=='19'){
				document.getElementsByName("partAGEN1.filingStatus.returnFileSec.noticeDate")[0].disabled=false;
			}

      } else{
    	  document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].value='';
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].value='';
          document.getElementsByName("partAGEN1.filingStatus.receiptNo")[0].disabled=true;
          document.getElementsByName("partAGEN1.filingStatus.origRetFiledDate")[0].disabled=true;
      }
}
 */
function disHoldComp(){

	var i=document.getElementsByName('partAGEN2For6.natOfCompFlg')[0].value;

	$('#natOfComSubBoth').find(':input').prop('disabled', true);
	$('#natOfComSubBoth').find('.addbtn').prop('hidden', true);
	$('#natOfComHoldBoth').find(':input').prop('disabled', true);
	$('#natOfComHoldBoth').find('.addbtn').prop('hidden', true);

	if(i=='2' || i== '3'){
		$('#natOfComSubBoth').find('.addbtn').prop('hidden', false);
		$('#natOfComSubBoth').find(':input').prop('disabled', false);
	}else{
		$('#natOfComSubBoth').find('[type=\"checkbox\"]').attr('checked','checked');
		deleteRowTable('natOfComSubBoth',2,1);
		$('#natOfComSubBoth').find(':input').prop('disabled', true);
		$('#natOfComSubBoth').find('.addbtn').prop('hidden', true);
	}

	if(i=='1' || i== '3'){
		$('#natOfComHoldBoth').find('.addbtn').prop('hidden', false);
		$('#natOfComHoldBoth').find(':input').prop('disabled', false);
	}else{
		$('#natOfComHoldBoth').find('[type=\"checkbox\"]').attr('checked','checked');
		deleteRowTable('natOfComHoldBoth',2,1);
		$('#natOfComHoldBoth').find(':input').prop('disabled', true);
		$('#natOfComHoldBoth').find('.addbtn').prop('hidden', true);
	}

}


function totAmtOfSchedTRFor6(tableId){

	var table=document.getElementById('scheduleTR');
	var noOfRows=table.rows.length;
	var totTaxPaidOutsideInd = parseInt('0' ,10);
	var totReliefAvailable = parseInt('0' ,10);
	var totReliefAvailable9090A = parseInt('0' ,10);
	var totReliefAvailable91 = parseInt('0' ,10);

	for(var i=0;i<eval(parseInt(noOfRows,10)-4);i++){
		if(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].relavantArticleDTAA')[0].value=='91'){
			totReliefAvailable91=eval(totReliefAvailable91+ parseInt(coalesce(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].taxReliefOutsideIndia')[0].value),10));

		} else if(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].relavantArticleDTAA')[0].value=='90' ||
				document.getElementsByName('scheduleTR1.scheduleTR['+i+'].relavantArticleDTAA')[0].value=='90A'){
			totReliefAvailable9090A=eval(totReliefAvailable9090A+parseInt(coalesce(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].taxReliefOutsideIndia')[0].value),10));
		}

		totTaxPaidOutsideInd = eval(parseInt(totTaxPaidOutsideInd,10) + parseInt(coalesce(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].taxPaidOutsideIndia')[0].value,10)));
		totReliefAvailable = eval(parseInt(totReliefAvailable,10) + parseInt(coalesce(document.getElementsByName('scheduleTR1.scheduleTR['+i+'].taxReliefOutsideIndia')[0].value,10)));

	}

	document.getElementsByName('scheduleTR1.totalIncomeOutIndia')[0].value = totReliefAvailable9090A;
	document.getElementsByName('scheduleTR1.totalIncomeOutIndiaDTAA')[0].value = totReliefAvailable91;
	document.getElementsByName('scheduleTR1.totTaxPaidDeclaredInFSI')[0].value = totTaxPaidOutsideInd;
	document.getElementsByName('scheduleTR1.totReliefClaimUs9090A')[0].value = totReliefAvailable;

}



function addRowSchedFSIFor2(nocheck){

	var mainTable=document.getElementById('scheduleFSI').rows;
	var noOfRows=mainTable.length;

	var tobeInsertBefore=document.getElementById('scheduleFSIAddRow');
	var flag=true;
	var checkFirst=true;
	var totRow=document.getElementById('scheduleFSIFirst').cells[0].textContent;

	var iterate=eval(parseInt(totRow,10));

	var indexValue=eval(((parseInt(noOfRows,10)-4)/5)+1);

	var isRowBlank = true;
	for(var i=0;i<6;i++){
		if(!checkRowBlank('scheduleFSI', (3+i), 0)){
			isRowBlank = false;
			break;
		}
	}

	if(!isRowBlank || nocheck){

		for(var i=2;i<mainTable.length;i++){
			var cloneNode=mainTable[i].cloneNode(true);
			if(flag){
				var cellsTot=cloneNode.cells;
				var newVal=eval(parseInt(totRow)+1);
				if(checkFirst){
					iterate=eval(indexValue-1);

					cloneNode.cells[0].innerHTML=indexValue;
					checkFirst=false;
				}

				//Numbering
				var inputTags=cloneNode.getElementsByTagName('input');
				for(var a=0;a<inputTags.length;a++){
					inputTags[a].name=inputTags[a].name.replace('[0]','['+iterate+']');

					inputTags[a].id=inputTags[a].name.replace(/([\.\[\]])/g,'_').replace(/(__)/g,'_');
					inputTags[a].value='';
					var blurAttr=inputTags[a].getAttribute('onblur');
					if(blurAttr!=null){
						blurAttr=blurAttr+";";
					}else{
						blurAttr="";
					}
					inputTags[a].setAttribute('onblur',blurAttr+'j.blur(this,this.name,this.value);');
				}

				var selectTags=cloneNode.getElementsByTagName('select');
				for(var a=0;a<selectTags.length;a++){
					selectTags[a].name=selectTags[a].name.replace('[0]','['+iterate+']');
					selectTags[a].value='';

					selectTags[a].id=selectTags[a].name.replace(/([\.\[\]])/g,'_').replace(/(__)/g,'_');

					var blurAttr=selectTags[a].getAttribute('onblur');
					if(blurAttr!=null){
						blurAttr=blurAttr+";";
					}else{
						blurAttr="";
					}
					selectTags[a].setAttribute('onblur',blurAttr+'j.blur(this,this.name,this.value);');
				}



				document.getElementById('scheduleFSI').getElementsByTagName('tr')[0].parentNode.insertBefore(cloneNode,tobeInsertBefore);
			}
			if(mainTable[i].id =='scheduleFSIEnd'){
				flag=false;
				break;
			}
		}
		if($('#scheduleFSIAddRow')[0].parentNode.children.length==10){
			$('#delFSIButtonId').prop('disabled', true);
		}else if($('#scheduleFSIAddRow')[0].parentNode.children.length>10){
			$('#delFSIButtonId').prop('disabled', false);
		}
		checkMaxLengthLimit();
	}else{
		addErrorXHTML('', 'Please fill in all the mandatory fields in the last row before adding another row.');
	}

}


function zeroOrLess(val){
	if(parseInt(val, 10) > 0 ){
		return 0;
	}
	return parseInt(val, 10);
}
function addRowToCG(tableId) {
	try{
		var tab = document.getElementById(tableId);
		var body = tab.tBodies[0];
		var clone = body.cloneNode(true);
		var index = parseInt(tab.tBodies.length, 10) + 1;
		clone.rows[0].cells[0].innerHTML = index;
		var inputs = clone.getElementsByTagName('INPUT');
		for (var i = 0; i < inputs.length; i++) {
			inputs[i].name = inputs[i].name.replace(/\[[\d]+\]/, '[' + (index - 1)
					+ ']');
			inputs[i].value = '';
			var blurAttr = inputs[i].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			inputs[i].setAttribute('onblur', blurAttr
					+ 'j.blur(this,this.name,this.value);');
		}
		var selects = clone.getElementsByTagName('SELECT');
		for (var i = 0; i < selects.length; i++) {
			selects[i].name = selects[i].name.replace(/\[[\d]+\]/, '['
					+ (index - 1) + ']');
			selects[i].selectedIndex = 0;
			var blurAttr = selects[i].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			selects[i].setAttribute('onblur', blurAttr
					+ 'j.blur(this,this.name,this.value);');
		}
		if(tableId=='scheduleCGstcg1'){
			if (clone.getElementsByTagName('table').length > 1) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,13);
				var newTableId1 = clone.getElementsByTagName('table')[1].id.substring(0,14);
				clone.getElementsByTagName('table')[0].setAttribute('id', newTableId
						+ '_ded' + index);
				clone.getElementsByTagName('img')[0].setAttribute('onclick',
						'addRowToTable(' + '\'' + newTableId + '_ded' + index
						+ '\',3,2,this);');
				clone.getElementsByTagName('img')[1]
				.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId
						+ '_ded' + index + '\',1,2)');
				clone.getElementsByTagName('table')[1].setAttribute('id', newTableId1
						+ '_ded' + index);
				clone.getElementsByTagName('img')[2].setAttribute('onclick',
						'addRowToTable(' + '\'' + newTableId1 + '_ded' + index
						+ '\',2,1);');
				clone.getElementsByTagName('img')[3]
				.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId1
						+ '_ded' + index + '\',2,1)');
			}
		}else{
			if(tableId=='scheduleCGltcg1'){
				if(clone.getElementsByTagName('table').length > 1){
					var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,14);
					clone.getElementsByTagName('table')[0].setAttribute('id', newTableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[0].setAttribute('onclick',
							'addRowToTable(' + '\'' + newTableId + '_ded' + index
							+ '\',3,2,this);');
					clone.getElementsByTagName('img')[1]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId
							+ '_ded' + index + '\',1,2)');
					clone.getElementsByTagName('table')[1].setAttribute('id', tableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[2].setAttribute('onclick',
							'addRowToTable(' + '\'' + tableId + '_ded' + index
							+ '\',2,1);');
					clone.getElementsByTagName('img')[3]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + tableId
							+ '_ded' + index + '\',2,1)');
				}

			}else{

				if (clone.getElementsByTagName('table').length > 0) {
					clone.getElementsByTagName('table')[0].setAttribute('id', tableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[0].setAttribute('onclick',
							'addRowToTable(' + '\'' + tableId + '_ded' + index
							+ '\',3,2,this);');
					clone.getElementsByTagName('img')[1]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + tableId
							+ '_ded' + index + '\',1,2)');
				}
			}

		}


		tab.appendChild(clone);
		modifyRow(tab);

		if(tableId=='scheduleCGltcg1'){
			if (clone.getElementsByTagName('table').length > 0) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,14);
				var newTableId1 = tableId.substring(0,15);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId + '_ded' + index, 1, 2);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", false);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId1 + '_ded' + index, 2, 1);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", false);
			}
		}else if(tableId=='scheduleCGstcg1'){
			if (clone.getElementsByTagName('table').length > 0) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,13);
				var newTableId1 = tableId.substring(0,14);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId + '_ded' + index, 1, 2);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", false);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId1 + '_ded' + index, 2, 1);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", false);
			}

		}else{
			if (clone.getElementsByTagName('table').length > 0) {
				$('#' + tableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(tableId + '_ded' + index, 1, 2);
				$('#' + tableId + '_ded' + index + ' input').attr("checked", false);
			}
		}
	}catch(e){
		alert(e.stack);
	}

}


function addRowToCGOnimportItr5(tableId) {
	try{
		var tab = document.getElementById(tableId);
		var body = tab.tBodies[0];
		var clone = body.cloneNode(true);
		var index = parseInt(tab.tBodies.length, 10) + 1;
		clone.rows[0].cells[0].innerHTML = index;
		var inputs = clone.getElementsByTagName('INPUT');
		for (var i = 0; i < inputs.length; i++) {
			inputs[i].name = inputs[i].name.replace(/\[[\d]+\]/, '[' + (index - 1)
					+ ']');
			inputs[i].value = '';
			var blurAttr = inputs[i].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			inputs[i].setAttribute('onblur', blurAttr
					+ 'j.blur(this,this.name,this.value);');
		}
		var selects = clone.getElementsByTagName('SELECT');
		for (var i = 0; i < selects.length; i++) {
			selects[i].name = selects[i].name.replace(/\[[\d]+\]/, '['
					+ (index - 1) + ']');
			selects[i].selectedIndex = 0;
			var blurAttr = selects[i].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			selects[i].setAttribute('onblur', blurAttr
					+ 'j.blur(this,this.name,this.value);');
		}
		if(tableId=='scheduleCGstcg1'){
			if (clone.getElementsByTagName('table').length > 1) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,13);
				var newTableId1 = clone.getElementsByTagName('table')[1].id.substring(0,14);
				clone.getElementsByTagName('table')[0].setAttribute('id', newTableId
						+ '_ded' + index);
				clone.getElementsByTagName('img')[0].setAttribute('onclick',
						'addRowToTable(' + '\'' + newTableId + '_ded' + index
						+ '\',3,2,this);');
				clone.getElementsByTagName('img')[1]
				.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId
						+ '_ded' + index + '\',1,2)');
				clone.getElementsByTagName('table')[1].setAttribute('id', newTableId1
						+ '_ded' + index);
				clone.getElementsByTagName('img')[2].setAttribute('onclick',
						'addRowToTable(' + '\'' + newTableId1 + '_ded' + index
						+ '\',2,1);');
				clone.getElementsByTagName('img')[3]
				.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId1
						+ '_ded' + index + '\',2,1)');
			}
		}else{
			if(tableId=='scheduleCGltcg1'){
				if(clone.getElementsByTagName('table').length > 1){
					var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,14);
					clone.getElementsByTagName('table')[0].setAttribute('id', newTableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[0].setAttribute('onclick',
							'addRowToTable(' + '\'' + newTableId + '_ded' + index
							+ '\',3,2,this);');
					clone.getElementsByTagName('img')[1]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + newTableId
							+ '_ded' + index + '\',1,2)');
					clone.getElementsByTagName('table')[1].setAttribute('id', tableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[2].setAttribute('onclick',
							'addRowToTable(' + '\'' + tableId + '_ded' + index
							+ '\',2,1);');
					clone.getElementsByTagName('img')[3]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + tableId
							+ '_ded' + index + '\',2,1)');
				}

			}else{

				if (clone.getElementsByTagName('table').length > 0) {
					clone.getElementsByTagName('table')[0].setAttribute('id', tableId
							+ '_ded' + index);
					clone.getElementsByTagName('img')[0].setAttribute('onclick',
							'addRowToTable(' + '\'' + tableId + '_ded' + index
							+ '\',3,2,this);');
					clone.getElementsByTagName('img')[1]
					.setAttribute('onclick', 'deleteRowTable(' + '\'' + tableId
							+ '_ded' + index + '\',1,2)');
				}
			}

		}


		tab.appendChild(clone);
		modifyRow(tab);

		if(tableId=='scheduleCGltcg1'){
			if (clone.getElementsByTagName('table').length > 0) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,14);
				var newTableId1 = tableId.substring(0,15);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId + '_ded' + index, 1, 2);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", false);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId1 + '_ded' + index, 2, 1);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", false);
			}
		}else if(tableId=='scheduleCGstcg1'){
			if (clone.getElementsByTagName('table').length > 0) {
				var newTableId = clone.getElementsByTagName('table')[0].id.substring(0,13);
				var newTableId1 = tableId.substring(0,14);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId + '_ded' + index, 1, 2);
				$('#' + newTableId + '_ded' + index + ' input').attr("checked", false);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(newTableId1 + '_ded' + index, 2, 1);
				$('#' + newTableId1 + '_ded' + index + ' input').attr("checked", false);
			}

		}else{
			if (clone.getElementsByTagName('table').length > 0) {
				$('#' + tableId + '_ded' + index + ' input').attr("checked", true);
				deleteRowTable(tableId + '_ded' + index, 1, 2);
				$('#' + tableId + '_ded' + index + ' input').attr("checked", false);
			}
		}
	}catch(e){
		alert(e.stack);
	}

}

function deleteRowToCG(tableId){
	var tab = document.getElementById(tableId);
	var len = tab.tBodies.length;
	if(len>1){
		tab.removeChild(tab.tBodies[len-1]);
	}
	modifyRow(tab);
}


function calcSchCG(cgosIncome){
	try{

		calculateSTCG(cgosIncome);
		calculateLTCG(cgosIncome);

		var totScheduleCGPost45 = document.getElementsByName('scheduleCGPost45.totScheduleCGPost45')[0];
		totScheduleCGPost45.value = eval(coalesceSetRet('scheduleCGPost45.shortTermCapGainPost45.totalSTCG') +
				parseInt(zeroOrMore(coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.totalLTCG'))));

		/*calculateCGDeductions();*/

		doCGSetOff(cgosIncome);


	}catch(e){
		alert('error in calcSchCG=' + e.stack);
	}
}

function calcSchCGLtcgStcg(){

	try{

		var stcg15Per = coalesceSetRet("scheduleBFLA.stcg.stcg15Per.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var shortTermUnder15Per = 		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of6") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of9") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of9To15Of12") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of12To15Of3") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.up16Of3To31Of3");

		var stcgAppRate = coalesceSetRet("scheduleBFLA.stcg.stcgAppRate.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var shortTermUnderAppRate = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of6") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of9") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of9To15Of12") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of12To15Of3") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.up16Of3To31Of3");

		var stcg30Per = coalesceSetRet("scheduleBFLA.stcg.stcg30Per.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var shortTermUnder30Per = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of6") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of9") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of9To15Of12") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of12To15Of3") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.up16Of3To31Of3") ;

		var stcgDtaaRate = coalesceSetRet("scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var shortTermUnderDtaaRate = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.upto15Of6")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.upto15Of9")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of9To15Of12")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of12To15Of3")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.shortTermUnderDtaaRate.up16Of3To31Of3");


		var ltcg10Per = coalesceSetRet("scheduleBFLA.ltcg.ltcg10Per.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var longTermUnder10Per = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of6") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of9") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of9To15Of12") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of12To15Of3") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.up16Of3To31Of3") ;

		var ltcg20Per = coalesceSetRet("scheduleBFLA.ltcg.ltcg20Per.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var longTermUnder20Per = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of6") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of9") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of9To15Of12") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of12To15Of3") +
		coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.up16Of3To31Of3") ;

		var ltcgDtaaRate = coalesceSetRet("scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses");
		var longTermUnderDtaaRate = coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.upto15Of6")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.upto15Of9")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of9To15Of12")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of12To15Of3")
		+ coalesceSetRet("scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaa.up16Of3To31Of3");

		// check for STCG


		if(stcg15Per > shortTermUnder15Per) {

			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of6','Total of Quarterly breakup in STCG 15% is less by ' + (stcg15Per-shortTermUnder15Per));
			addErrorXHTML('',"Total of Quarterly breakup in STCG 111A is less by " + (stcg15Per-shortTermUnder15Per));
		}



		if(stcg15Per > shortTermUnder15Per) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of6','Total of Quarterly breakup in STCG 15% is less by ' + (stcg15Per-shortTermUnder15Per));
			addErrorXHTML('',"Total of Quarterly breakup in STCG 111A is less by " + (stcg15Per-shortTermUnder15Per));
		}
		if(stcg15Per < shortTermUnder15Per) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnder15Per.upto15Of6','Total of Quarterly breakup in STCG 15% is more by ' + Math.abs(stcg15Per-shortTermUnder15Per));
			addErrorXHTML('',"Total of Quarterly breakup in STCG 111A is more by " + Math.abs(stcg15Per-shortTermUnder15Per));
		}

		if(stcgAppRate > shortTermUnderAppRate) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of6','Total of Quarterly breakup in STCG Applicable Rates is less by ' + (stcgAppRate-shortTermUnderAppRate));
			addErrorXHTML('',"Total of Quarterly breakup in STCG Others is less by " + (stcgAppRate-shortTermUnderAppRate));
		}
		if(stcgAppRate < shortTermUnderAppRate) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of6','Total of Quarterly breakup in STCG Applicable Rates is more by ' + Math.abs(stcgAppRate-shortTermUnderAppRate));
			addErrorXHTML('',"Total of Quarterly breakup in STCG Others is more by " + Math.abs(stcgAppRate-shortTermUnderAppRate));
		}
		if (stcgDtaaRate > shortTermUnderDtaaRate) {
			j
			.setFieldError(
					'scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of9',
					'Total of Quarterly breakup in STCG Dtaa Rates is less by '
					+ (stcgDtaaRate - shortTermUnderDtaaRate));
			addErrorXHTML('',
					"Total of Quarterly breakup in STCG Others is less by "
					+ (stcgDtaaRate - shortTermUnderDtaaRate));
		}
		if (stcgDtaaRate < shortTermUnderDtaaRate) {
			j
			.setFieldError(
					'scheduleCGPost45.accruOrRecOfCG.shortTermUnderAppRate.upto15Of9',
					'Total of Quarterly breakup in STCG Dtaa Rates is more by '
					+ Math.abs(stcgDtaaRate
							- shortTermUnderDtaaRate));
			addErrorXHTML('',
					"Total of Quarterly breakup in STCG Others is more by "
					+ Math.abs(stcgDtaaRate - shortTermUnderDtaaRate));
		}



		if(stcg30Per > shortTermUnder30Per) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of6', 'Total of Quarterly breakup in STCG 30% is less by ' + (stcg30Per-shortTermUnder30Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Proviso is less by " + (stcg30Per-shortTermUnder30Per));
		}
		if(stcg30Per < shortTermUnder30Per) {
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.shortTermUnder30Per.upto15Of6', 'Total of Quarterly breakup in STCG 30% is more by ' + Math.abs(stcg30Per-shortTermUnder30Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Proviso is more by " + Math.abs(stcg30Per-shortTermUnder30Per));
		}

		// check for LTCG

		if(ltcg10Per > longTermUnder10Per)	{
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of6','Total of Quarterly breakup in LTCG 10% is less by ' + (ltcg10Per-longTermUnder10Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Non Proviso is less by " + (ltcg10Per-longTermUnder10Per));
		}

		if(ltcg10Per < longTermUnder10Per)	{
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.longTermUnder10Per.upto15Of6','Total of Quarterly breakup in LTCG 10% is more by ' + Math.abs(ltcg10Per-longTermUnder10Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Non Proviso is more by " + Math.abs(ltcg10Per-longTermUnder10Per));
		}

		if(ltcg20Per > longTermUnder20Per)	{
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of6','Total of Quarterly breakup in LTCG 20% is less by ' + (ltcg20Per-longTermUnder20Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Non Proviso is less by " + (ltcg20Per-longTermUnder20Per));
		}

		if(ltcg20Per < longTermUnder20Per)	{
			j.setFieldError('scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of6','Total of Quarterly breakup in LTCG 20% is more by ' + Math.abs(ltcg20Per-longTermUnder20Per));
			addErrorXHTML('',"Total of Quarterly breakup in LTCG Non Proviso is more by " + Math.abs(ltcg20Per-longTermUnder20Per));
		}

		if (ltcgDtaaRate > longTermUnderDtaaRate) {
			j
			.setFieldError(
					'scheduleCGPost45.accruOrRecOfCG.longTermUnder20Per.upto15Of9',
					'Total of Quarterly breakup in LTCG Dtaa Rate is less by '
					+ (ltcgDtaaRate - longTermUnderDtaaRate));
			addErrorXHTML('',
					"Total of Quarterly breakup in LTCG DTAA is less by "
					+ (ltcgDtaaRate - longTermUnderDtaaRate));
		}

		if (ltcgDtaaRate < longTermUnderDtaaRate) {
			j
			.setFieldError(
					'scheduleCGPost45.accruOrRecOfCG.longTermUnderDtaaRate.upto15Of9',
					'Total of Quarterly breakup in LTCG Dtaa Rate is more by '
					+ Math.abs(ltcgDtaaRate - longTermUnderDtaaRate));
			addErrorXHTML('',
					"Total of Quarterly breakup in LTCG DTAA is more by "
					+ Math.abs(ltcgDtaaRate - longTermUnderDtaaRate));
		}



		var table = document.getElementById('scheduleCGstcg1');
		var noOfRows = table.rows.length;

		for (var i = 0; i <noOfRows/14; i++) {


			var fullConsideration = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration')[0];
			var propertyValuation = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].propertyValuation')[0];
			var fullConsideration50C = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0];

			if (fullConsideration.value!='' && fullConsideration50C.value != fullConsideration.value
					&& propertyValuation.value!='' && fullConsideration50C.value != propertyValuation.value) {

				j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C',"Please enter value from 'ai' or 'aii' only");
				addErrorXHTML(fullConsideration50C ,"Please enter value from 'ai' or 'aii' only");
			}
		}

		var table = document.getElementById('scheduleCGltcg1');
		var noOfRows = table.rows.length;

		for (var i = 0; i <noOfRows/14; i++) {


			fullConsideration = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration')[0];
			propertyValuation = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].propertyValuation')[0];
			fullConsideration50C = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0];

			if (fullConsideration.value!='' && fullConsideration50C.value != fullConsideration.value
					&& propertyValuation.value!='' && fullConsideration50C.value != propertyValuation.value) {

				j.setFieldError('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C',"Please enter value from 'ai' or 'aii' only");
				addErrorXHTML(fullConsideration50C ,"Please enter value from 'ai' or 'aii' only");
			}
		}
		var balanceCG = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG')[0];


		var tab = document.getElementById('stcg10pctTab');
		var selects = tab.getElementsByTagName('SELECT');
		var count = {"21ciii": 0,"5AC1c": 0,"5ADiii": 0,"5ACA1b": 0};
		for(var i=0;i<selects.length;i++){
			count[selects[i].value] = count[selects[i].value]+1;
			if(count[selects[i].value] > 1){
				j.setFieldError(selects[i].name,' A particular drop down cannot be selected twice');
				addErrorXHTML(selects[i] ," A particular drop down cannot be selected twice");
				break;
			}
		}

		/*		dropDownSelection('ltcgDeduction54ec54ee1');
		 */		/*	dropDownSelection('ltcgDeduction54ec54ee2');
		 *//*	dropDownSelection('ltcgDeduction54ec54ee4');*/

	}catch(e){
		alert('error in calcSchCGLtcgStcg=' + e.stack);
	}
}

function dropDownSelection(tabName){
	var tab = document.getElementById(tabName);
	var selects = tab.getElementsByTagName('SELECT');
	var count = {"54EC": 0};
	for(var i=0;i<selects.length;i++){
		count[selects[i].value] = count[selects[i].value]+1;
		if(count[selects[i].value] > 1){
			j.setFieldError(selects[i].name,' A particular drop down cannot be selected twice');
			addErrorXHTML(selects[i] ," A particular drop down cannot be selected twice");
			break;
		}
	}
}

function calculateOS(cgosIncome) {

	try{

		var simap = initMapForSI(cgosIncome);

		coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount');

		calculateOSGross(simap)

		validateSchOSDTAA1a1b();
		var totalIncomeGross = document.getElementsByName('scheduleOS.totalIncomeGross')[0];
		totalIncomeGross.value = eval(parseInt(
				coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.dividendGross'),
				10)
				+ parseInt(
						coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.interestGross'),
						10)
						+ parseInt(
								coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.rentFromMachPlantBldgs'),
								10)
								+ parseInt(coalesceSetRet('scheduleOS.incomeFromNature.underSec560.sourceAmount'), 10)
								+ parseInt(coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.totalOtherIncome'), 10));

		var tabl = document.getElementById('schduleOsinc');
		var allSelects = tabl.getElementsByTagName('SELECT');
		var tempSum = parseInt('0',10);
		for(var i=0;i<allSelects.length;i++){
			var index = name
			.substring(name.indexOf('[') + 1, name.indexOf(']'));
			tempSum = parseInt(tempSum)+parseInt(coalesce(document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
					+ i + '].sourceAmount')[0].value));
		}
		var tabl1 = document.getElementById('schduleOsincPti');
		var allSelects1 = tabl1.getElementsByTagName('SELECT');
		var tempSum1 = parseInt('0',10);
		for(var i=0;i<allSelects1.length;i++){
			var index = name
			.substring(name.indexOf('[') + 1, name.indexOf(']'));
			tempSum1 = parseInt(tempSum1)+parseInt(coalesce(document.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['+ i + '].sourceAmount')[0].value));
		}


		var totalOSGross = document.getElementsByName('scheduleOS.totalOSGross')[0];
		totalOSGross.value = eval(parseInt(
				coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount'),
				10)
				+ parseInt(
						coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls1.sourceAmount'),
						10)
						+ parseInt(tempSum,10)
						+ parseInt(tempSum1,10)
						+ parseInt(sum56to2(),10));

		var totAmtUnderDtaa = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa.totAmtUnderDtaa')[0];
		var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
		var rowcount = tab.rows.length;
		var sum =0;
		for (var i = 0; i <parseInt(rowcount-2); i++) {
			if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value == 'NRI' && document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].taxResidCertFlag')[0].value == 'Y')
			{
				sum=eval(parseInt(coalesce(sum), 10)
						+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
			}
			else if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value != 'NRI')
			{
				sum=eval(parseInt(coalesce(sum), 10)
						+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
			}
		}
		totAmtUnderDtaa.value=sum;

		/*	totAmtUnderDtaa.value = addCGDeductions('scheduleOsNriIncTaxDtaa');
		 */
		var totDeductions = document
		.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.deductions.totDeductions')[0];
		totDeductions.value = eval(parseInt(
				coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.deductions.expenses'),
				10)
				+ parseInt(
						coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.deductions.depreciation'),
						10));
		var amtNotDeductibleUs58 = document
		.getElementsByName('scheduleOS.amtNotDeductibleUs58')[0];

		var profitChargTaxUs59 = document
		.getElementsByName('scheduleOS.profitChargTaxUs59')[0];

		var balanceNoRaceHorse = document.getElementsByName('scheduleOS.balanceNoRaceHorse')[0];

		var incChargblSplRateOS56i = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56i')[0];
		var incChargblSplRateOS56 = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56')[0];
		var incChargblSplRateOS562 = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562')[0];
		var incChargblSplRateOS562x = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562x')[0];


		var tab = document.getElementById('anyOtherIncome');
		var rowcount = tab.rows.length;
		var temp=parseInt('0',10);

		for(var i=0;i<rowcount-3;i++){
			temp = eval(parseInt(coalesce(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.otherIncome['+i+'].anyOtherIncomeAmount')[0].value),10)) + temp;
		}

		var residentStatus =document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
		var rowcount = tab.rows.length;
		var section1a =0;
		var section1b =0;
		var section1c =0;
		var section1d =0;
		for (var i = 0; i <parseInt(rowcount-2); i++) {
			var taxResidCertFlag = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].taxResidCertFlag')[0].value;
			var itemIncluded = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].itemIncluded')[0].value;
			if(residentStatus=='NRI')
			{
				if(itemIncluded=='56i' && taxResidCertFlag == 'Y')
				{
					section1a=eval(parseInt(coalesce(section1a), 10)
							+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
				}
				if(itemIncluded=='56' && taxResidCertFlag == 'Y')
				{
					section1b=eval(parseInt(coalesce(section1b), 10)
							+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
				}
				if(itemIncluded=='562iii' && taxResidCertFlag == 'Y')
				{
					section1c=eval(parseInt(coalesce(section1c), 10)
							+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
				}
				if(itemIncluded=='562x' && taxResidCertFlag == 'Y')
				{
					section1d=eval(parseInt(coalesce(section1d), 10)
							+ parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].amount')[0].value), 10));
				}
			}
			else if(residentStatus != 'NRI')
			{
				section1a=parseInt(coalesce('0'), 10);
				section1b=parseInt(coalesce('0'), 10);
				section1c=parseInt(coalesce('0'), 10);
				section1d=parseInt(coalesce('0'), 10);

			}
		}
		var totalIncomeFromDtaa = eval(parseInt(incChargblSplRateOS56i.value,10)
				+parseInt(incChargblSplRateOS56.value,10)
				+parseInt(incChargblSplRateOS562.value,10)
				+parseInt(incChargblSplRateOS562x.value,10));


		balanceNoRaceHorse.value = eval(parseInt(totalIncomeFromDtaa,10)+parseInt(temp,10)-parseInt(totDeductions.value, 10)
				+ parseInt(coalesce(amtNotDeductibleUs58.value), 10)
				+ parseInt(coalesce(profitChargTaxUs59.value), 10));

		document.getElementsByName('scheduleOS.balanceNoRaceHorse')[0].value=balanceNoRaceHorse.value;

		var totOthSrcNoRaceHorse = document
		.getElementsByName('scheduleOS.totOthSrcNoRaceHorse')[0];

		var IncmOthrSrc = document
		.getElementsByName('scheduleOS.balanceNoRaceHorse')[0];

		totOthSrcNoRaceHorse.value = eval(parseInt(
				totalOSGross.value, 10)
				+ parseInt(zeroOrMore(parseInt(IncmOthrSrc.value, 10))));

		var balanceOwnRaceHorse = document
		.getElementsByName('scheduleOS.incFromOwnHorse.balanceOwnRaceHorse')[0];
		balanceOwnRaceHorse.value = eval(parseInt(
				coalesceSetRet('scheduleOS.incFromOwnHorse.receipts'), 10)
				- parseInt(
						coalesceSetRet('scheduleOS.incFromOwnHorse.deductSec57'),
						10)
						+ parseInt(
								coalesceSetRet('scheduleOS.incFromOwnHorse.amtNotDeductibleUs58'),
								10)
								+ parseInt(
										coalesceSetRet('scheduleOS.incFromOwnHorse.profitChargTaxUs59'),
										10));
		var incChargeable = document.getElementsByName('scheduleOS.incChargeable')[0];
		incChargeable.value = eval(parseInt(totOthSrcNoRaceHorse.value, 10)
				+ parseInt(zeroOrMore(parseInt(balanceOwnRaceHorse.value, 10))));


		return simap;
	}
	catch(e){
		alert(e.stack);
	}
}

function sum56to2(){
	var table = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowCount = table.rows.length - 2;
	var temp = parseInt('0',10);
	var residentFlag= document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	for (var i = 0; i < rowCount; i++) {

		var section = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
				+ i + '].itemIncluded')[0];
		var itemIncludedIn = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
				+ i + '].itemIncludedIn')[0];
		var taxResidCertFlag = document   
		.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
				+ i + '].taxResidCertFlag')[0];
		if (residentFlag == 'NRI') {
			if ((itemIncludedIn.value == '1a' || itemIncludedIn.value == '1b'
				|| itemIncludedIn.value == '1c' || itemIncludedIn.value == '1d')
				&& taxResidCertFlag.value == 'Y') {

				if (section.value != '' && (section.value == '56i' ||  section.value == '562iii' ||  section.value == '562x' || section.value == '56')) {
					temp= parseInt(temp)+coalesceSetRet('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].amount');
				}
			}
		}

		else {
			if (section.value != ''
				&& (section.value == '56i' || section.value == '562iii'
					|| section.value == '562x' || section.value == '56')) {
				temp = parseInt(temp)
				+ coalesceSetRet('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].amount');
			}
		}

	}
	return temp;
}

function calcAnyOtherIncome(){
	var tab = document.getElementById('anyOtherIncome');
	var rowcount = tab.rows.length;
	var totalOtherIncome=document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.totalOtherIncome')[0];
	var temp=parseInt('0',10);
	for(var i=0;i<rowcount-3;i++){
		temp = eval(parseInt(coalesce(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.otherIncome['+i+'].anyOtherIncomeAmount')[0].value),10)) + temp;
	}
	totalOtherIncome.value=temp;
}

function validateOSd(){
	var tab = document.getElementById('schduleOsincPti');
	var selects = tab.getElementsByTagName("SELECT");

	var arr = new Array();
	for(var i=0;i<selects.length;i++){
		if(selects[i].name.match('sourceDescription') && selects[i].value!=''){
			if(arr.indexOf(selects[i].value)==-1){
				arr.push(selects[i].value);
			}else if(selects[i].value!='Others'){
				var msg = 'Dropdown can select only once' || 'A particular drop down cannot be selected twice';
				j.setFieldError(selects[i].name, msg);
				addErrorXHTML(selects[i], msg ,true);
			}
		}
	}
}
function validateOSe(){
	var tab = document.getElementById('schduleOsinc');
	var selects = tab.getElementsByTagName("SELECT");
	var arr = new Array();
	for(var i=0;i<selects.length;i++){
		if(selects[i].name.match('sourceDescription') && selects[i].value!=''){
			if(arr.indexOf(selects[i].value)==-1){
				arr.push(selects[i].value);
			}else if(selects[i].value!='Others'){
				var msg = 'Dropdown can select only once' || 'A particular drop down cannot be selected twice';
				j.setFieldError(selects[i].name, msg);
				addErrorXHTML(selects[i], msg ,true);
			}
		}
	}
}


function calcualteOSInterestTotal() {
	var sum = 0;

	var intrstFrmSavingBank = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.intrstFrmSavingBank');
	var intrstFrmTermDeposit = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.intrstFrmTermDeposit');
	var intrstFrmIncmTaxRefund = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.intrstFrmIncmTaxRefund');
	var intrstFrmOthers = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.intrstFrmOthers');
	var intrstFrmPTI = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.intrstFrmPTI');

	sum = eval(eval(parseInt(sum, 10)
			+ parseInt(coalesce(intrstFrmSavingBank), 10)
			+ parseInt(coalesce(intrstFrmTermDeposit), 10)
			+ parseInt(coalesce(intrstFrmIncmTaxRefund), 10)
			+ parseInt(coalesce(intrstFrmOthers), 10)
			+ parseInt(coalesce(intrstFrmPTI), 10)));

	document
	.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.interestGross')[0].value = sum;
}

function validateSchOSDTAA1a1b() {
	var dividendGross = parseInt(coalesce(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.dividendGross')[0].value),10);
	var interestGross = parseInt(coalesce(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.interestGross')[0].value),10);


	var rentGross = parseInt(
			coalesce(document
					.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.rentFromMachPlantBldgs')[0].value),
					10);

	var incomeGross = parseInt(
			coalesce(document
					.getElementsByName('scheduleOS.incomeFromNature.underSec560.sourceAmount')[0].value),
					10);
	var table = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowCount = table.rows.length - 2;

	var dividendGrossTot = parseInt('0',10);
	var interestGrossTot = parseInt('0',10);
	var rentGrossTot = parseInt('0', 10);
	var incomeGrossTot = parseInt('0', 10);
	for(var k=0; k<rowCount; k++) {
		if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+k+'].itemIncluded')[0].value == '56i') {
			dividendGrossTot = eval(dividendGrossTot + parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+k+'].amount')[0].value),10));
			if(eval(dividendGrossTot > dividendGross)) {
				if (document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0].value != '') {
					document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0].value = 0;
					addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0],'For Dividend - The sum of amount should not exceed amount entered in 1a.',true);
					j.setFieldError('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount','For Dividend - The sum of amount should not exceed amount entered in 1a.');
				}
			}
		} else if (document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+k+'].itemIncluded')[0].value == '56') {
			interestGrossTot = eval(interestGrossTot + parseInt(coalesce(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+k+'].amount')[0].value),10));
			if(eval(interestGrossTot > interestGross)) {
				if (document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0].value != '') {
					document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0].value = 0;
					addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount')[0],'For Interest - The sum of amount should not exceed amount entered in 1b.',true);
					j.setFieldError('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ k + '].amount','For Interest - The sum of amount should not exceed amount entered in 1b.');
				}
			}
		}

		else if (document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ k + '].itemIncluded')[0].value == '562iii') {
			rentGrossTot = eval(rentGrossTot
					+ parseInt(
							coalesce(document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value), 10));
			if (eval(rentGrossTot > rentGross)) {
				if (document
						.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
								+ k + '].amount')[0].value != '') {
					document
					.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].amount')[0].value = 0;
					addErrorXHTML(
							document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].amount')[0],
									'The sum of amount should not exceed amount entered in 1c.',
									true);
					j
					.setFieldError(
							'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].amount',
					'The sum of amount should not exceed amount entered in 1c.');
				}
			}
		}
		else if (document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ k + '].itemIncluded')[0].value == '562x') {
			incomeGrossTot = eval(incomeGrossTot
					+ parseInt(
							coalesce(document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value), 10));
			if (eval(incomeGrossTot > incomeGross)) {
				if (document
						.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
								+ k + '].amount')[0].value != '') {
					document
					.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].amount')[0].value = 0;
					addErrorXHTML(
							document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].amount')[0],
									'The sum of amount should not exceed amount entered in 1d.',
									true);
					j
					.setFieldError(
							'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].amount',
					'The sum of amount should not exceed amount entered in 1d.');
				}
			}
		}
	}

}
function calculateOSGross(simap){

	var total = parseInt('0' ,10);

	try{
		var resStatus = document
		.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0];

		var tabl = document.getElementById('schduleOsinc');
		var temp = eval(parseInt(
				coalesce(document
						.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls1.sourceAmount')[0].value),
						10));

		var temp562X = eval(parseInt(
				coalesce(document
						.getElementsByName('scheduleOS.incomeFromNature.underSec560.sourceAmount')[0].value),
						10));

		var dividendIncome115BBDA = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0];
		var dividendIncome115BBF = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0];
		var dividendIncome115BBE = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBE')[0];
		dividendIncome115BBE.value = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls1.sourceAmount');
		simap['5BBE'] = coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE');

		var dividendIncome115BBG = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0];

		var dividendIncome115BBDA_PTI = document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA_PTI')[0];
		var dividendIncome115BBF_PTI = document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF_PTI')[0];
		var dividendIncome115BBE_PTI = document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI')[0];
		var dividendIncome115BBG_PTI = document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG_PTI')[0];
		var dividendIncome115BB_PTI = document.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries_PTI')[0];

		var dropDownBBDA = parseInt(0, 10);
		var dropDownBBF = parseInt(0, 10);
		var dropDownBBE = parseInt(0, 10);
		var dropDownBBG = parseInt(0, 10);
		var dropDownBB = parseInt(0, 10);

		var dropDownBBDA_PTI = parseInt(0, 10);
		var dropDownBBF_PTI = parseInt(0, 10);
		var dropDownBBE_PTI = parseInt(0, 10);
		var dropDownBBG_PTI = parseInt(0, 10);
		var dropDownBB_PTI = parseInt(0, 10);
		var dropDown1_PTI = parseInt(0, 10);

		var total = parseInt('0', 10);
		var allInputTags = tabl.getElementsByTagName('input');
		for (var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("sourceAmount$")) {
				total = eval(parseInt(total, 10)
						+ parseInt(isNVL(allInputTags[i].value), 10));
			}
		}

		document.getElementsByName('scheduleOS.usOthersGross')[0].value=total;
		var allSelects = tabl.getElementsByTagName('SELECT');
		var residentFlag= document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var table = document.getElementById('scheduleOsNriIncTaxDtaa');
		var rowCount = table.rows.length - 2;
		var arr = {
				'5A1ai' : 0,
				'5A1aii' : 0,
				'5A1aiia' : 0,
				'5A1aiiaa' : 0,
				'5A1aiiab' : 0,
				'5A1aiiac' : 0,
				'5A1aiii' : 0,
				'5A1bA' : 0,
				//'5A1bB' : 0,
				'5AC1ab' : 0,
				'5BBA' : 0,
				'5Ea' : 0,
				'5BBDA' : 0,
				'5BBC' : 0,
				'PTI_5A1ai' : 0,
				'PTI_5A1aii' : 0,
				'PTI_5A1aiia' : 0,
				'PTI_5A1aiiaa' : 0,
				'PTI_5A1aiiab' : 0,
				'PTI_5A1aiiac' : 0,
				'PTI_5A1aiii' : 0,
				'PTI_5A1bA' : 0,
				//'PTI_5A1bB' : 0,
				'PTI_5AC1ab' : 0,
				'PTI_5BBA' : 0,
				'PTI_5Ea' : 0,
				'PTI_5BBDA' : 0,
				'PTI_5BBC' : 0,
				'PTI_5BB' :0,
				'PTI_5BBE':0
		};

		var winningFrmLotteries = document.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries')[0];
		winningFrmLotteries.value = document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount')[0].value;
		var sum = 0;
		var sumPti = 0;
		for (var i = 0; i < allSelects.length; i++) {
			var name = allSelects[i].name;
			var index = name
			.substring(name.indexOf('[') + 1, name.indexOf(']'));
			simap[allSelects[i].value] = coalesce(document
					.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
							+ i + '].sourceAmount')[0].value);

			if (allSelects[i].value == '5BBDA') {

				dividendIncome115BBDA.value = document
				.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == '5BBF') {

				dividendIncome115BBF.value = document
				.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == '5BBG') {

				dividendIncome115BBG.value = document
				.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}
			var taxResidCertFlag= false;
			if (allSelects[i].value != 'DTAA') {
				sum = parseInt(sum)
				+ parseInt(coalesce(document
						.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
								+ index + '].sourceAmount')[0].value));
				for (var k = 0; k < rowCount; k++) {
					if (( document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].itemIncluded')[0].value == '1'))
						if (document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value > parseInt(coalesce(document
												.getElementsByName('scheduleOS.totalOSGross')[0].value))) {
							if (document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value != '') {

								document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value = 0;
								calcITR5();
								addErrorXHTML(
										document
										.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
												+ k + '].amount')[0],
												'The sum of amount should not exceed amount entered in 2c.',
												true);
								j
								.setFieldError(
										'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount',
								'The sum of amount should not exceed amount entered in 2c.');
							}

						}


					if ((document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].itemIncluded')[0].value == allSelects[i].value)) {
						if(residentFlag=='NRI')
						{
							if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].taxResidCertFlag')[0].value=='Y')
							{


								arr[allSelects[i].value] = eval(parseInt(coalesce(arr[allSelects[i].value]))
										+ parseInt(coalesce(document
												.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
														+ k + '].amount')[0].value)));
							}
						}
						else
						{
							arr[allSelects[i].value] = eval(parseInt(coalesce(arr[allSelects[i].value]))
									+ parseInt(coalesce(document
											.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
													+ k + '].amount')[0].value)));
						}

						if ((arr[allSelects[i].value]) > parseInt(coalesce(document
								.getElementsByName('scheduleOS.usOthersGross')[0].value))) {

							if (document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value != '') {
								document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value = 0;
								calcITR5();
								addErrorXHTML(
										document
										.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
												+ k + '].amount')[0],
												'The sum of amount should not exceed amount entered in 2c.',
												true);
								j
								.setFieldError(
										'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount',
								'The sum of amount should not exceed amount entered in 2c.');
							}
						} else {


							if(residentFlag=='NRI')
							{
								if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].taxResidCertFlag')[0].value=='Y')
								{
									taxResidCertFlag=true;
									sum -= document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value;

								}
							}
							else
							{
								taxResidCertFlag=false;
								sum -= document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value;
							}
						}
					}
				}
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag)
					{
						simap[allSelects[i].value] -= parseInt(
								coalesce(arr[allSelects[i].value]), 10);
					}
				}
				else
				{
					simap[allSelects[i].value] -= parseInt(
							coalesce(arr[allSelects[i].value]), 10);
				}
			}
		}



		for (var k = 0; k < rowCount; k++) {
			if ((document
					.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].itemIncluded')[0].value == '5BB')) {

				if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ k + '].amount')[0].value>coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount'))
					if (document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].amount')[0].value != '') {
						document
						.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
								+ k + '].amount')[0].value = 0;
						calcITR5();
						addErrorXHTML(
								document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0],
										'The amount should not exceed amount entered in 2a.',
										true);
						j
						.setFieldError(
								'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
								+ k + '].amount',
						'The  amount should not exceed amount entered in 2a.');
					}
			}
		}

		var tabl = document.getElementById('schduleOsincPti');
		var allSelects = tabl.getElementsByTagName('SELECT');

		var total = parseInt('0', 10);
		var allInputTags = tabl.getElementsByTagName('input');
		for (var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("sourceAmount$")) {
				total = eval(parseInt(total, 10)
						+ parseInt(isNVL(allInputTags[i].value), 10));
			}
		}

		document.getElementsByName('scheduleOS.pTiOthersGross')[0].value=total;

		for (var i = 0; i < allSelects.length; i++) {
			var name = allSelects[i].name;
			var index = name
			.substring(name.indexOf('[') + 1, name.indexOf(']'));
			simap[allSelects[i].value] = coalesce(document
					.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
							+ i + '].sourceAmount')[0].value);

			if (allSelects[i].value == 'PTI_5BBDA') {

				dividendIncome115BBDA_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}
			if (allSelects[i].value == 'PTI_5BB') {

				dividendIncome115BB_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == 'PTI_5BBF') {

				dividendIncome115BBF_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == 'PTI_5BBE') {

				dividendIncome115BBE_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == 'PTI_5BBG') {

				dividendIncome115BBG_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == 'PTI_5BB') {

				dividendIncome115BBG_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}

			if (allSelects[i].value == 'PTI_5BBE') {

				dividendIncome115BBG_PTI.value = document
				.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
						+ index + '].sourceAmount')[0].value;
			}
			var taxResidCertFlag=false;
			if (allSelects[i].value != 'DTAA') {
				sumPti = parseInt(sum)
				+ parseInt(coalesce(document
						.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
								+ index + '].sourceAmount')[0].value));
				for (var k = 0; k < rowCount; k++) {
					if ((document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].itemIncluded')[0].value == allSelects[i].value)) {

						if(residentFlag=='NRI')
						{
							if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ k + '].taxResidCertFlag')[0].value=='Y')
							{


								arr[allSelects[i].value] = eval(parseInt(coalesce(arr[allSelects[i].value]))
										+ parseInt(coalesce(document
												.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
														+ k + '].amount')[0].value)));

							}
						}
						else
						{
							arr[allSelects[i].value] = eval(parseInt(coalesce(arr[allSelects[i].value]))
									+ parseInt(coalesce(document
											.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
													+ k + '].amount')[0].value)));
						}

						if ((arr[allSelects[i].value]) > parseInt(coalesce(document
								.getElementsByName('scheduleOS.pTiOthersGross')[0].value))) {//add OS e total

							if (document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value != '') {
								document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value = 0;
								calcITR5();
								addErrorXHTML(
										document
										.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
												+ k + '].amount')[0],
												'The sum of amount should not exceed amount entered in 2d.',
												true);
								j
								.setFieldError(
										'scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount',
								'The sum of amount should not exceed amount entered in 2d.');
							}
						} else {

							if(residentFlag=='NRI')
							{
								if(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].taxResidCertFlag')[0].value=='Y')
								{
									taxResidCertFlag=true;
									sumPti -= document
									.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
											+ k + '].amount')[0].value;
								}
							}
							else
							{
								taxResidCertFlag=false;
								sumPti -= document
								.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
										+ k + '].amount')[0].value;
							}
						}
					}
				}
			}
			if(residentFlag=='NRI')
			{
				if(taxResidCertFlag)
				{
					simap[allSelects[i].value] -= parseInt(
							coalesce(arr[allSelects[i].value]), 10);
				}
			}
			else
			{
				simap[allSelects[i].value] -= parseInt(
						coalesce(arr[allSelects[i].value]), 10);
			}

		}



		var dropDown56i =parseInt('0',10);
		var dropDown56 =parseInt('0',10);
		var dropDown562 =parseInt('0',10);
		var dropDown562x =parseInt('0',10);

		for (var j = 0; j < rowCount; j++) {

			var dropDownOS = document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ j + '].itemIncluded')[0].value;

			var amountofSum = document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ j + '].amount')[0].value;

			var taxResidCertFlag = document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ j + '].taxResidCertFlag')[0].value;

			if (dropDownOS == '5BBDA') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBDA = coalesce(eval(parseInt(dropDownBBDA)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBDA = coalesce(eval(parseInt(dropDownBBDA)
							+ parseInt(amountofSum)));
				}
			}

			if (dropDownOS == '5BBF') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBF = coalesce(eval(parseInt(dropDownBBF)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBF = coalesce(eval(parseInt(dropDownBBF)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '5BBE') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBE = coalesce(eval(parseInt(dropDownBBE)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBE = coalesce(eval(parseInt(dropDownBBE)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '5BBG') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBG = coalesce(eval(parseInt(dropDownBBG)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBG = coalesce(eval(parseInt(dropDownBBG)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '5BB') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBB = coalesce(eval(parseInt(dropDownBB)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBB = coalesce(eval(parseInt(dropDownBB)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == 'PTI_5BBDA') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBDA_PTI = coalesce(eval(parseInt(dropDownBBDA_PTI)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBDA_PTI = coalesce(eval(parseInt(dropDownBBDA_PTI)
							+ parseInt(amountofSum)));
				}
			}

			if (dropDownOS == 'PTI_5BBF') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBF_PTI = coalesce(eval(parseInt(dropDownBBF_PTI)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBF_PTI = coalesce(eval(parseInt(dropDownBBF_PTI)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == 'PTI_5BBE') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBE_PTI = coalesce(eval(parseInt(dropDownBBE_PTI)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBE_PTI = coalesce(eval(parseInt(dropDownBBE_PTI)
							+ parseInt(amountofSum)));
				}	
			}
			if (dropDownOS == 'PTI_5BBG') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBBG_PTI = coalesce(eval(parseInt(dropDownBBG_PTI)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBBG_PTI = coalesce(eval(parseInt(dropDownBBG_PTI)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == 'PTI_5BB') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDownBB_PTI = coalesce(eval(parseInt(dropDownBB_PTI)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDownBB_PTI = coalesce(eval(parseInt(dropDownBB_PTI)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '56i') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDown56i = coalesce(eval(parseInt(dropDown56i)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDown56i = coalesce(eval(parseInt(dropDown56i)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '56') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDown56 = coalesce(eval(parseInt(dropDown56)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDown56 = coalesce(eval(parseInt(dropDown56)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '562iii') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDown562 = coalesce(eval(parseInt(dropDown562)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDown562 = coalesce(eval(parseInt(dropDown562)
							+ parseInt(amountofSum)));
				}
			}
			if (dropDownOS == '562x') {
				if(residentFlag=='NRI')
				{
					if(taxResidCertFlag=='Y')
					{
						dropDown562x = coalesce(eval(parseInt(dropDown562x)
								+ parseInt(amountofSum)));
					}
				}
				else
				{
					dropDown562x = coalesce(eval(parseInt(dropDown562x)
							+ parseInt(amountofSum)));
				}
			}
		}



		var incChargblSplRateOS56i = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56i')[0];
		var incChargblSplRateOS56 = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56')[0];
		var incChargblSplRateOS562 = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562')[0];
		var incChargblSplRateOS562x = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562x')[0];

		incChargblSplRateOS56i.value = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.dividendGross');
		incChargblSplRateOS56.value = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.interestGross');
		incChargblSplRateOS562.value = coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.rentFromMachPlantBldgs');
		incChargblSplRateOS562x.value = coalesceSetRet('scheduleOS.incomeFromNature.underSec560.sourceAmount');

		var final56i = parseInt(0, 10);
		final56i = incChargblSplRateOS56i.value - dropDown56i;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56i')[0].value = final56i;

		var final56 = parseInt(0, 10);
		final56 = incChargblSplRateOS56.value - dropDown56;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.56')[0].value = final56;

		var final562 = parseInt(0, 10);
		final562 = incChargblSplRateOS562.value - dropDown562;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562')[0].value = final562;

		var final562x = parseInt(0, 10);
		final562x = incChargblSplRateOS562x.value - dropDown562x;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.562x')[0].value = final562x;

		var finalBBDA = parseInt(0, 10);
		finalBBDA = dividendIncome115BBDA.value - dropDownBBDA;

		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0].value = finalBBDA;

		var finalBBF = parseInt(0, 10);
		finalBBF = dividendIncome115BBF.value - dropDownBBF;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0].value = finalBBF;

		var finalBBE = parseInt(0, 10);
		finalBBE = dividendIncome115BBE.value - dropDownBBE;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBE')[0].value = finalBBE;

		var finalBBG = parseInt(0, 10);
		finalBBG = dividendIncome115BBG.value - dropDownBBG;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0].value = finalBBG;

		var finalBB = parseInt(0, 10);
		finalBB = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries')[0].value
		- dropDownBB;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries')[0].value = finalBB;

		simap['5BBE'] = coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE');
		simap['5BB'] = coalesceSetRet('scheduleOS.incChargblSplRateOS.winningFrmLotteries');


		var finalBBG = parseInt(0, 10);
		finalBBG = dividendIncome115BBG.value - dropDownBBG;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0].value = finalBBG;

		var finalBBDA_PTI = parseInt(0, 10);
		finalBBDA_PTI = dividendIncome115BBDA_PTI.value - dropDownBBDA_PTI;

		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA_PTI')[0].value = finalBBDA_PTI;

		var finalBBF = parseInt(0, 10);
		finalBBF_PTI = dividendIncome115BBF_PTI.value - dropDownBBF_PTI;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF_PTI')[0].value = finalBBF_PTI;

		var finalBBE_PTI = parseInt(0, 10);
		finalBBE_PTI = dividendIncome115BBE_PTI.value - dropDownBBE_PTI;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBE_PTI')[0].value = finalBBE_PTI;

		var finalBBG_PTI = parseInt(0, 10);
		finalBBG_PTI = dividendIncome115BBG_PTI.value - dropDownBBG_PTI;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG_PTI')[0].value = finalBBG_PTI;

		var finalBB_PTI = parseInt(0, 10);
		finalBB_PTI = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries_PTI')[0].value
		- dropDownBB_PTI;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries_PTI')[0].value = finalBB_PTI;

		var final1_PTI = parseInt(0, 10);
		final1_PTI = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.1_PTI')[0].value
		- dropDownBB_PTI;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.1_PTI')[0].value = finalBB_PTI;



		var tempWinningFromLotteries = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries')[0].value;

		var temp115BBDA = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0].value;

		var temp115BBF = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0].value;

		var temp115BBG = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0].value;

		var temp115BBE = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBE')[0].value;

		var secXIIOth = document
		.getElementsByName('scheduleOS.incChargblSplRateOS.secXIIOth')[0];
		/*if (eval(parseInt(
		coalesce(document
				.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.totalIncomeBenefit')[0].value),
		10)) > 0) {
	sum = sum
			+ eval(parseInt(
					coalesce(document
							.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.totalIncomeBenefit')[0].value),
					10));
	sum = calculateSec111(sum);
}
		 */
		secXIIOth.value = zeroOrMore(eval( temp - tempWinningFromLotteries
				- temp115BBDA - temp115BBF - temp115BBE - temp115BBG
				- (2 * temp562X)));

	} catch (e) {
		alert('Exception in calculateOSGross : ' + e);
	}
}

function calculateSec111(sum) {
	var table = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowCount = table.rows.length - 2;
	var osNriInc111 = 0;
	for (var i = 0; i < rowCount; i++) {
		if (document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].itemIncluded')[0].value == '1') {

			osNriInc111 = osNriInc111
			+ eval(parseInt(
					coalesce(document
							.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
									+ i + '].amount')[0].value), 10));
		}

	}
	return (sum - osNriInc111);
}

/*function calculateScheduleOStaxBenifit() {
	var tab1 = document.getElementById('accumalatedBalance');
	var noOfRows = tab1.rows.length;
	var amt1 = 0;
	var amt2 = 0;
	for (var i = 0; i < (noOfRows - 4); i++) {
		amt1 = parseInt(
				zeroOrMore(document
						.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.taxAccmltdBalRecPFDtls['
								+ i + '].taxBenefit')[0].value), 10)
				+ parseInt(amt2, 10);
		amt2 = amt1;
	}

	document
			.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.totalTaxBenefit')[0].value = amt1;
}*/


function setFirstToSecondMax(first,second,target){
	try{
		if(coalesceSetRet(first) > coalesceSetRet(second)){
			document.getElementsByName(target)[0].value= coalesceSetRet(second);
		}else{
			document.getElementsByName(target)[0].value= coalesceSetRet(first);
		}
	}catch(e){
		alert('error in setFirstToSecondMax= '+e.stack );
	}
}

function enablepl()

{
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	if(status == '1' && substatus == '10')
	{
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm")[0].readOnly=false;
	}else
	{

		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm")[0].readOnly=true;
		document.getElementsByName("partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm")[0].value='';


	}

}
function adjustForm(){
	try{

		enableField('partAGEN1.orgFirmInfo.subStatus',['13'],
				'partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare',
				'partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc'
		);
		enableField('partAGEN1.orgFirmInfo.subStatus',['15','16','17','4','5','7','8','10','11','13','20','21'],
				'scheduleVIA.usrDeductUndChapVIA.section80GGC'
		);

		enableField('partAGEN1.orgFirmInfo.subStatus',['5'],
				'scheduleVIA.usrDeductUndChapVIA.section80IAC'
		);

		enableField('partAGEN2.liableSec44ABflg','Y',
				'partAGEN2.auditedByAccountantFlg'
				
		);
		 
		enableField('partAGEN2.liableSec92Eflg','Y',
				'partAGEN2.sec92Edate'
		);
		
		
		enableField('partAGEN2.auditedByAccountantFlg','Y',
				'partAGEN2.auditInfo.auditReportFurnishDate',
				'partAGEN2.auditInfo.auditorName',
				'partAGEN2.auditInfo.audFrmRegNo',
				'partAGEN2.auditInfo.auditorMemNo',
				'partAGEN2.auditInfo.audFrmName',
				'partAGEN2.auditInfo.audFrmPAN',
				'partAGEN2.auditInfo.audFrmAadhaar',
				'partAGEN2.auditInfo.auditDate'
		);
		
		enableField('scheduleTR1.taxPaidOutsideIndFlg','YES',
				'scheduleTR1.amtTaxRefunded',
				'scheduleTR1.assmtYrTaxRelief'
				);

		/*enableField('partAGEN1.filingStatus.residentialStatus','NRI',
					'scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.ltcgWithoutBenefit'
					);*/
		/*enableField('partAGEN1.filingStatus.residentialStatus','NRI',
					'scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.exemptionOrDednUs54'
					);*/
		enableField('partAGEN1.filingStatus.residentialStatus','NRI',
				'partAGEN1.filingStatus.nripe'
		);
		enableField('partAGEN1.orgFirmInfo.statusOrCompanyType',['1','9','14'],
				'partAGEN1.orgFirmInfo.subStatus'
		);
		enableField('partAGEN1.filingStatus.asseseeRepFlg','Y',
				'partAGEN1.filingStatus.assesseeRep.repName',
				'partAGEN1.filingStatus.assesseeRep.repcapac',
				'partAGEN1.filingStatus.assesseeRep.repAddress',
				'partAGEN1.filingStatus.assesseeRep.repPAN',
		'partAGEN1.filingStatus.assesseeRep.repAadhaar');

		enableField('partAGEN1.filingStatus.residentialStatus','RES',
				'partBTTI.assetOutIndiaFlag'
		);
		enableField('partAGEN1.filingStatus.residentialStatus','NRI',
				'scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG'
		);
		enableField('partAGEN1.filingStatus.residentialStatus','RES',
				'itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF',
				'itr5ScheduleBP.businessIncOthThanSpec.expDebToPLOthHeads.underSec115BBF'
		);

		

		enableTable('partAGEN2.prevYrMemPartChange', 'Y', 'partnerTableId');
		disableSebiRegNo('partAGEN1.filingStatus.fiiFpiFlg');
		adjustCG();
		//adjustOS();

		enableField('partAGEN1.orgFirmInfo.subStatus',['4'],
				'partaoi.amtDisallUs36.expGovtApprovedSugarPrice'
		);


		enableField('partAGEN1.orgFirmInfo.subStatus',['15','16','17'],
				'itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44DB'
		);

		coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD');
		coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA');
		coalesceSetRet('partapl.debitsToPL.debitPlAcnt.salRemuneration');
		enableFieldsPDTAOT();

	}catch(e){
		alert('Error in adjustForm:'+e);
	}
}

function adjustOS() {
	var tabl = document.getElementById('schduleOsf');

	var allSelects = tabl.getElementsByTagName('SELECT');

	for(var i = 0; i < allSelects.length; i++) {
		var name = allSelects[i].name;
		var index = name.substring(name.indexOf('[')+1, name.indexOf(']'));
		if(allSelects[i].value=='Others'){
			document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].style.display='';
		} else {
			document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].style.display='none';
			document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].value='';
		}
	}
}

function adjustCG() {

	try{

		enableTable('scheduleCGPost45.shortTermCapGainPost45.unutilizedCapgainFlag','Y','scheduleStcgunUtilizedCapGain54');
		enableTable('scheduleCGPost45.LongTermCapGainPost45.unutilizedCapgainFlag','Y','scheduleLtcgunUtilizedCapGain54');
		/*enableNRItables();*/


		if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value=='NRI'){

			//A3
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid')[0].readOnly=false;
			//A4
			//document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48aquisitCost')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48improveCost')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48expOnTrans')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.lossSec94of7Or94of8')[0].readOnly=false;

			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdRecvUnqshr')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fairMrktValueUnqshr')[0].readOnly=false;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdSec50CA')[0].readOnly=true;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdOthUnqshr')[0].readOnly=false;




			//B5
			var tab = document.getElementById('stcg10pctTab');
			var inputs = tab.getElementsByTagName('INPUT');
			var selects =  tab.getElementsByTagName('SELECT');
			for(var i=0;i<inputs.length;i++){
				if(!(inputs[i].classList.contains("readonly"))){
					inputs[i].readOnly=false;
				}
			}
			for(var i=0;i<selects.length;i++){
				if( !(selects[i].classList.contains("readonly"))){
					selects[i].disabled=false;
				}
			}


			/*tab = document.getElementById('ltcgDeduction54ec54ee4');
		inputs = tab.getElementsByTagName('INPUT');
		selects =  tab.getElementsByTagName('SELECT');
		for(var i=0;i<inputs.length;i++){
			if(!(inputs[i].classList.contains("readonly"))){
				inputs[i].readOnly=false;
			}
		}
		for(var i=0;i<selects.length;i++){
			if( !(selects[i].classList.contains("readonly"))){
				selects[i].disabled=false;
			}
		}*/

			/*		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.exemptionOrDednUs54')[0].readOnly=true;
			 */	}else{
				 //A3
				 var nRItaxSTTPaid = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid')[0];
				 nRItaxSTTPaid.readOnly=true;
				 nRItaxSTTPaid.value = 0;

				 var nRItaxSTTNotPaid = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid')[0];
				 nRItaxSTTNotPaid.readOnly=true;
				 nRItaxSTTNotPaid.value = 0;

				 //A4
				 //var fullConsideration = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0];
				 //fullConsideration.readOnly=true;
				 //fullConsideration.value = 0;
				 var aquisitCost = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48aquisitCost')[0];
				
				 aquisitCost.readOnly=true;
				 aquisitCost.value = 0;
				 var improveCost = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48improveCost')[0];
				 improveCost.readOnly=true;
				 improveCost.value = 0;
				 var expOnTrans = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48expOnTrans')[0];
				 expOnTrans.readOnly=true;
				 expOnTrans.value = 0;
				 var lossSec94of7Or94of8 = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.lossSec94of7Or94of8')[0];
				 lossSec94of7Or94of8.readOnly=true;
				 lossSec94of7Or94of8.value = 0;
				 var aquisitCost = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.deductSec48aquisitCost')[0];
				 aquisitCost.readOnly=true;
				 aquisitCost.value = 0;
				 var fullConsidtnia = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdRecvUnqshr')[0];
				 var fullConsidtnib = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fairMrktValueUnqshr')[0];
				 var fullConsidtnic = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdSec50CA')[0];
				 var fullConsidtnii = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdOthUnqshr')[0];
				 var fullConsideration = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0];

				 fullConsidtnia.readOnly=true;
				 fullConsidtnia.value=0;

				 fullConsidtnib.readOnly=true;
				 fullConsidtnib.value=0;

				 fullConsidtnic.readOnly=true;
				 fullConsidtnic.value=0;

				 fullConsidtnii.readOnly=true;
				 fullConsidtnii.value=0;

				 fullConsideration.readOnly=true;
				 fullConsideration.value = 0;

				 //B4
				 /*var ltcgWithoutBenefit = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.ltcgWithoutBenefit')[0];
		ltcgWithoutBenefit.readOnly=true;
		ltcgWithoutBenefit.value = 0;*/
				 /*var exemptionOrDednUs54 = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.exemptionOrDednUs54')[0];
		exemptionOrDednUs54.readOnly=true;
		exemptionOrDednUs54.value = 0;*/




				//B5
				 var tab = document.getElementById('stcg10pctTab');
				 var inputs = tab.getElementsByTagName('INPUT');
				 var selects =  tab.getElementsByTagName('SELECT');
				 for(var i=0;i<inputs.length;i++){
					 if(!inputs[i].classList.contains("readonly")){
						 inputs[i].readOnly=true;
						 inputs[i].value = '';
					 }
					 
				 }
				 for(var i=0;i<selects.length;i++){
					 if(!selects[i].classList.contains("readonly")){
						 selects[i].disabled=true;
						 selects[i].selectedIndex=0;
					 }
				 

				 }
				 //B8

				 /*				 document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0].value=0;
				  */
				 /*var tab = document.getElementById('ltcgDeduction54ec54ee4');
		var inputs = tab.getElementsByTagName('INPUT');
		var selects =  tab.getElementsByTagName('SELECT');

		$("#ltcgDeduction54ec54ee4 input").attr("checked" , true);
	    deleteRowTable('ltcgDeduction54ec54ee4',1,2);
		$("#ltcgDeduction54ec54ee4 input").attr("checked" , false);

		for(var i=0;i<inputs.length;i++){
			if(!inputs[i].classList.contains("readonly")){
				inputs[i].readOnly=true;
				inputs[i].value = '';
			}
		}
		for(var i=0;i<selects.length;i++){
			if(!selects[i].classList.contains("readonly")){
				selects[i].disabled=true;
				selects[i].selectedIndex=0;
			}
		}*/
			 }
	}catch(e){
		alert("error in cg: "+e.stack);
	}
}

//B8



function enableField(src,val,targets){
	var srcField = document.getElementsByName(src)[0];
	if(contains(val,srcField.value)){
		for(var i=2;i<arguments.length; i++){
			var targetField = document.getElementsByName(arguments[i])[0];
			targetField.disabled= false;
			targetField.readOnly=false;
		}
	}else{
		for(var i=2;i<arguments.length; i++){
			var targetField = document.getElementsByName(arguments[i])[0];
			if(targetField.type=='select-one'){
				targetField.selectedIndex = 0;
			}else{
				targetField.value='';
			}
			targetField.disabled= true;
			targetField.readOnly=true;
		}
	}

}
function contains(arr, val){
	if(arr.constructor.name=="Array"){
		for(var i=0;i<arr.length; i++){
			if(arr[i]==val){
				return true;
			}
		}
		return false;
	}else{
		return (arr==val);
	}
}



function removeAuditAllDetails(elem){
	if(elem.value!='Y'){
		$('.auditDetailsRow:not(:first)').remove();
		$('.auditDetailsRow').find(':input').val('');
		$('.auditDetailsRow').find(':input').prop('disabled', true);
		$('#auditDetailsButton').find(':button').prop('disabled', true);

	}else{
		$('.auditDetailsRow').find(':input').prop('disabled', false);
		$('#auditDetailsButton').find(':button').prop('disabled', false);
		if($('.auditDetailsRow').length==1){
			$('#deleteAuditBtnId').prop('disabled', true);
		}
	}

}

function setAuditSectionCode() {
	var repSec92EFlag =	document.getElementsByName('partAGEN2.repSec92EFlag')[0].value;

	if(repSec92EFlag=='YES') {
		document.getElementsByName('partAGEN2.auditDetails[0].auditedSection')[0].value='92E';
	} else {
		document.getElementsByName('partAGEN2.auditDetails[0].auditedSection')[0].value='';
	}
}

function onChngState(state,str1,str2) {

	var position = parseInt(state.name.substring(state.name.indexOf("[") + 1, state.name.indexOf("]")));

	if(state.value == '99'){
		document.getElementsByName(str1+'['+position+'].'+str2)[0].value='999999';
	} else if(state.value != '99' && document.getElementsByName(str1+'['+position+'].'+str2)[0].value == '999999') {
		document.getElementsByName(str1+'['+position+'].'+str2)[0].value='';
	}

}

function checkMembershipNoLength(memberShipNO) {

	if(memberShipNO.value.length==5) {
		memberShipNO.value=0+memberShipNO.value;
	} else if(memberShipNO.value.length==4) {
		memberShipNO.value='00'+memberShipNO.value;
	} else if(memberShipNO.value.length==3) {
		memberShipNO.value='000'+memberShipNO.value;
	} else if(memberShipNO.value.length==2) {
		memberShipNO.value='0000'+memberShipNO.value;
	} else if(memberShipNO.value.length==1 && memberShipNO.value!=0) {
		memberShipNO.value='00000'+memberShipNO.value;
	}
}


function onStateChngSetCountry(state,country) {
	var country = document.getElementsByName(country)[0];
	if(state.value != '99' && state.value != '-1' && state.value != '') {
		country.value='91';
	} else {
		country.value='';
	}
}

function onStateChng(){
	try{
		var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
		var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];
		var pinCode = document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0];

		if(state.value != '99' && state.value != '-1'){
			country.value='91';
			pinCode.value='';
		}else if(state.value == '99'){
			pinCode.value='999999';
		}
	}catch(e){
		alert(e.stack);
	}
}



function ensureToFillSchTrFsi(field) {
	var claimUs9090A91Flag = document.getElementsByName(field)[0];
	var resStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	if(field.value=='YES' && resStatus=='RES') {
		addErrorXHTML('','Do not forget to fill Schedule TR and Schedule FSI to claim Tax relief.');
	}
}



function enableField(src,val,targets){
	var srcField = document.getElementsByName(src)[0];
	if(contains(val,srcField.value)){
		for(var i=2;i<arguments.length; i++){
			var targetField = document.getElementsByName(arguments[i])[0];
			targetField.disabled= false;
			targetField.readOnly=false;
		}
	}else{
		for(var i=2;i<arguments.length; i++){
			var targetField = document.getElementsByName(arguments[i])[0];
			if(targetField.type=='select-one'){
				targetField.selectedIndex = 0;
			}else{
				targetField.value='';
			}
			targetField.disabled= true;
			targetField.readOnly=true;
		}
	}

}

function contains(arr, val){
	if(arr.constructor.name=="Array"){
		for(var i=0;i<arr.length; i++){
			if(arr[i]==val){
				return true;
			}
		}
		return false;
	}else{
		return (arr==val);
	}
}



function calculateTotalInTable(iteratorValue,columnName,tableId,totalField){
	var total=0,i=0;
	var nameTemp="";
	var tableInput=document.getElementById(tableId).getElementsByTagName('input');
	while(true){
		nameTemp=iteratorValue+'['+(i++)+'].'+columnName;
		if(document.getElementsByName(nameTemp).length!=0){
			var val=parseInt(document.getElementsByName(nameTemp)[0].value);
			if(isNaN(val)){
				val=0;
			}
			total=parseInt(total)+parseInt(val);
		}
		else{
			break;
		}
	}
	document.getElementsByName(totalField)[0].value=total;
}

function coalesceString(val){
	if(val==undefined || val == null){
		return 0;
	}
	return val;
}

function scheduleHPCalcFor5() {

	var totHp = eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent) - 1);
	var total = 0;
	var thirtyPercentOfBalanceTemp = 0;

	for (var i = 0; i < totHp; i++) {

		document.getElementsByName('scheduleHP.propertyDetails[' + i
				+ '].rentdetails.totalUnrealizedAndTax')[0].value = eval(parseInt(document
						.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].rentdetails.rentNotRealized')[0].value == "" ? 0
										: coalesceSetRet('scheduleHP.propertyDetails[' + i
												+ '].rentdetails.rentNotRealized'))
												+ parseInt(document
														.getElementsByName('scheduleHP.propertyDetails[' + i
																+ '].rentdetails.localTaxes')[0].value == "" ? 0
																		: coalesceSetRet('scheduleHP.propertyDetails[' + i
																				+ '].rentdetails.localTaxes')));

		document.getElementsByName('scheduleHP.propertyDetails[' + i
				+ '].rentdetails.balanceALV')[0].value = eval(parseInt(document
						.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].rentdetails.annualLetableValue')[0].value == "" ? 0
										: coalesceSetRet('scheduleHP.propertyDetails[' + i
												+ '].rentdetails.annualLetableValue'))
												- parseInt(document
														.getElementsByName('scheduleHP.propertyDetails[' + i
																+ '].rentdetails.totalUnrealizedAndTax')[0].value == "" ? 0
																		: coalesceSetRet('scheduleHP.propertyDetails[' + i
																				+ '].rentdetails.totalUnrealizedAndTax')));

		var incomeChargbleOwnHands = document
		.getElementsByName('scheduleHP.propertyDetails[' + i
				+ '].rentdetails.incomeChargbleOwnHands')[0];
		setEditableFieldValue(
				incomeChargbleOwnHands,
				Math
				.round(eval(parseInt(document
						.getElementsByName('scheduleHP.propertyDetails['
								+ i + '].rentdetails.balanceALV')[0].value)
								* (parseFloat(document
										.getElementsByName('scheduleHP.propertyDetails['
												+ i + '].asseseeShareProperty')[0].value))
												/ 100)));

		thirtyPercentOfBalanceTemp = Math
		.round(eval(parseInt(document
				.getElementsByName('scheduleHP.propertyDetails[' + i
						+ '].rentdetails.incomeChargbleOwnHands')[0].value == "" ? 0
								: document
								.getElementsByName('scheduleHP.propertyDetails['
										+ i
										+ '].rentdetails.incomeChargbleOwnHands')[0].value) * 0.3));
		if (parseInt(thirtyPercentOfBalanceTemp, 10) > 0) {
			document.getElementsByName('scheduleHP.propertyDetails[' + i
					+ '].rentdetails.thirtyPercentOfBalance')[0].value = thirtyPercentOfBalanceTemp;
		} else {
			document.getElementsByName('scheduleHP.propertyDetails[' + i
					+ '].rentdetails.thirtyPercentOfBalance')[0].value = parseInt(
							0, 10);
		}

		document.getElementsByName('scheduleHP.propertyDetails[' + i
				+ '].rentdetails.totalDeduct')[0].value = eval(parseInt(document
						.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].rentdetails.thirtyPercentOfBalance')[0].value == "" ? 0
										: coalesceSetRet('scheduleHP.propertyDetails[' + i
												+ '].rentdetails.thirtyPercentOfBalance'))
												+ parseInt(document
														.getElementsByName('scheduleHP.propertyDetails[' + i
																+ '].rentdetails.intOnBorwCap')[0].value == "" ? 0
																		: coalesceSetRet('scheduleHP.propertyDetails[' + i
																				+ '].rentdetails.intOnBorwCap')));

		document.getElementsByName('scheduleHP.propertyDetails[' + i
				+ '].rentdetails.incomeOfHP')[0].value = eval(parseInt(document
						.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].rentdetails.balanceALV')[0].value == "" ? 0
										: coalesce(document
												.getElementsByName('scheduleHP.propertyDetails[' + i
														+ '].rentdetails.incomeChargbleOwnHands')[0].value))
														- parseInt(document
																.getElementsByName('scheduleHP.propertyDetails[' + i
																		+ '].rentdetails.totalDeduct')[0].value == "" ? 0
																				: document
																				.getElementsByName('scheduleHP.propertyDetails['
																						+ i + '].rentdetails.totalDeduct')[0].value)
																						+ parseInt(document
																								.getElementsByName('scheduleHP.propertyDetails[' + i
																										+ '].rentdetails.arrears')[0].value == "" ? 0
																												: document
																												.getElementsByName('scheduleHP.propertyDetails['
																														+ i + '].rentdetails.arrears')[0].value)
				);

		total = eval(parseInt(total)
				+ parseInt(document
						.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].rentdetails.incomeOfHP')[0].value));
	}
	document.getElementsByName('scheduleHP.totalIncomeChargeableUnHP')[0].value = eval(parseInt(document
			.getElementsByName('scheduleHP.passThroughIncome')[0].value == "" ? 0
					: document
					.getElementsByName('scheduleHP.passThroughIncome')[0].value)
					+ parseInt(total));

}

//To add Schedule HP property

function calcScheduleSI(){
	try{
		var secCode1A =  document.getElementsByName('scheduleSI.splCodeRateTax[1].secCode')[0]; secCode1A.value = coalesceString(secCode1A.value);
		var splRatePercent1A = document.getElementsByName('scheduleSI.splCodeRateTax[1].splRatePercent')[0]; splRatePercent1A.value = coalesce(splRatePercent1A.value);
		var splRateInc1A = document.getElementsByName('scheduleSI.splCodeRateTax[1].splRateInc')[0]; splRateInc1A.value = coalesce(splRateInc1A.value);
		var taxableInc1A = document.getElementsByName('scheduleSI.splCodeRateTax[1].taxableInc')[0]; taxableInc1A.value = coalesce(taxableInc1A.value);
		var splRateIncTax1A = document.getElementsByName('scheduleSI.splCodeRateTax[1].splRateIncTax')[0]; splRateIncTax1A.value = coalesce(splRateIncTax1A.value);

		var secCode22 =  document.getElementsByName('scheduleSI.splCodeRateTax[3].secCode')[0]; secCode22.value = coalesceString(secCode22.value);
		var splRatePercent22 = document.getElementsByName('scheduleSI.splCodeRateTax[3].splRatePercent')[0]; splRatePercent22.value = coalesce(splRatePercent22.value);
		var splRateInc22 = document.getElementsByName('scheduleSI.splCodeRateTax[3].splRateInc')[0]; splRateInc22.value = coalesce(splRateInc22.value);
		var taxableInc22 = document.getElementsByName('scheduleSI.splCodeRateTax[3].taxableInc')[0]; taxableInc22.value = coalesce(taxableInc22.value);
		var splRateIncTax22 = document.getElementsByName('scheduleSI.splCodeRateTax[3].splRateIncTax')[0]; splRateIncTax22.value = coalesce(splRateIncTax22.value);

		var secCode21ciii =  document.getElementsByName('scheduleSI.splCodeRateTax[4].secCode')[0]; secCode21ciii.value = coalesceString(secCode21ciii.value);
		var splRatePercent21ciii = document.getElementsByName('scheduleSI.splCodeRateTax[4].splRatePercent')[0]; splRatePercent21ciii.value = coalesce(splRatePercent21ciii.value);
		var splRateInc21ciii = document.getElementsByName('scheduleSI.splCodeRateTax[4].splRateInc')[0]; splRateInc21ciii.value = coalesce(splRateInc21ciii.value);
		var taxableInc21ciii = document.getElementsByName('scheduleSI.splCodeRateTax[4].taxableInc')[0]; taxableInc21ciii.value = coalesce(taxableInc21ciii.value);
		var splRateIncTax21ciii = document.getElementsByName('scheduleSI.splCodeRateTax[4].splRateIncTax')[0]; splRateIncTax21ciii.value = coalesce(splRateIncTax21ciii.value);

		var secCode21 =  document.getElementsByName('scheduleSI.splCodeRateTax[2].secCode')[0]; secCode21.value = coalesceString(secCode21.value);
		var splRatePercent21 = document.getElementsByName('scheduleSI.splCodeRateTax[2].splRatePercent')[0]; splRatePercent21.value = coalesce(splRatePercent21.value);
		var splRateInc21 = document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0]; splRateInc21.value = coalesce(splRateInc21.value);
		var taxableInc21 = document.getElementsByName('scheduleSI.splCodeRateTax[2].taxableInc')[0]; taxableInc21.value = coalesce(taxableInc21.value);
		var splRateIncTax21 = document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateIncTax')[0]; splRateIncTax21.value = coalesce(splRateIncTax21.value);

		var secCode5BB =  document.getElementsByName('scheduleSI.splCodeRateTax[6].secCode')[0]; secCode5BB.value = coalesceString(secCode5BB.value);
		var splRatePercent5BB = document.getElementsByName('scheduleSI.splCodeRateTax[6].splRatePercent')[0]; splRatePercent5BB.value = coalesce(splRatePercent5BB.value);
		var splRateInc5BB = document.getElementsByName('scheduleSI.splCodeRateTax[6].splRateInc')[0]; splRateInc5BB.value = coalesce(splRateInc5BB.value);
		var taxableInc5BB = document.getElementsByName('scheduleSI.splCodeRateTax[6].taxableInc')[0]; taxableInc5BB.value = coalesce(taxableInc5BB.value);
		var splRateIncTax5BB = document.getElementsByName('scheduleSI.splCodeRateTax[6].splRateIncTax')[0]; splRateIncTax5BB.value = coalesce(splRateIncTax5BB.value);

		/*var secCode1 =  document.getElementsByName('scheduleSI.splCodeRateTax[0].secCode')[0]; secCode1.value = coalesceString(secCode1.value);
		var splRatePercent1 = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRatePercent')[0]; splRatePercent1.value = coalesce(splRatePercent1.value);
		var splRateInc1 = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateInc')[0]; splRateInc1.value = coalesce(splRateInc1.value);
		var taxableInc1 = document.getElementsByName('scheduleSI.splCodeRateTax[0].taxableInc')[0];
		var splRateIncTax1 = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0];splRateIncTax1.value = coalesce(splRateIncTax1.value);
*/

		var secCode5b =  document.getElementsByName('scheduleSI.splCodeRateTax[0].secCode')[0]; secCode5b.value = coalesceString(secCode5b.value);
		var splRatePercent5b = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRatePercent')[0]; splRatePercent5b.value = coalesce(splRatePercent5b.value);
		var splRateInc5b = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateInc')[0]; splRateInc5b.value = coalesce(splRateInc5b.value);
		var taxableInc5b = document.getElementsByName('scheduleSI.splCodeRateTax[0].taxableInc')[0]; taxableInc5b.value = coalesce(taxableInc5b.value);
		var splRateIncTax5b = document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0]; splRateIncTax5b.value = coalesce(splRateIncTax5b.value);

		var secCode112A = document.getElementsByName('scheduleSI.splCodeRateTax[5].secCode')[0];secCode112A.value = coalesceString(secCode112A.value);
		var splRatePercent112A = document.getElementsByName('scheduleSI.splCodeRateTax[5].splRatePercent')[0];splRatePercent112A.value = coalesce(splRatePercent112A.value);
		var splRateInc112A = document.getElementsByName('scheduleSI.splCodeRateTax[5].splRateInc')[0];splRateInc112A.value = coalesce(splRateInc112A.value);
		var taxableInc112A = document.getElementsByName('scheduleSI.splCodeRateTax[5].taxableInc')[0];taxableInc112A.value = coalesce(taxableInc112A.value);
		var splRateIncTax112A = document.getElementsByName('scheduleSI.splCodeRateTax[5].splRateIncTax')[0];splRateIncTax112A.value = coalesce(splRateIncTax112A.value);

		var splRateIncDTAA = document.getElementsByName('scheduleSI.splCodeRateTax[13].splRateInc')[0];splRateIncDTAA.value = coalesce(splRateIncDTAA.value);
		var taxableIncDTAA = document.getElementsByName('scheduleSI.splCodeRateTax[13].taxableInc')[0];taxableIncDTAA.value = coalesce(taxableIncDTAA.value);
		var splRateIncTaxDTAA = document.getElementsByName('scheduleSI.splCodeRateTax[13].splRateIncTax')[0];splRateIncTaxDTAA.value = coalesce(splRateIncTaxDTAA.value);

		var splRateIncLtcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[12].splRateInc')[0];splRateIncLtcgDtaa.value = coalesce(splRateIncLtcgDtaa.value);
		var taxableIncLtcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[12].taxableInc')[0];taxableIncLtcgDtaa.value = coalesce(taxableIncLtcgDtaa.value);
		var splRateIncTaxLtcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[12].splRateIncTax')[0];splRateIncTaxLtcgDtaa.value = coalesce(splRateIncTaxLtcgDtaa.value);

		var splRateIncStcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[11].splRateInc')[0];splRateIncStcgDtaa.value = coalesce(splRateIncStcgDtaa.value);
		var taxableIncStcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[11].taxableInc')[0];taxableIncStcgDtaa.value = coalesce(taxableIncStcgDtaa.value);
		var splRateIncTaxStcgDtaa = document.getElementsByName('scheduleSI.splCodeRateTax[11].splRateIncTax')[0];splRateIncTaxStcgDtaa.value = coalesce(splRateIncTaxStcgDtaa.value);

		var splRateInc5ADii = document.getElementsByName('scheduleSI.splCodeRateTax[7].splRateInc')[0];	splRateInc5ADii.value = coalesce(splRateInc5ADii.value);
		var taxableInc5ADii = document.getElementsByName('scheduleSI.splCodeRateTax[7].taxableInc')[0]; taxableInc5ADii.value = coalesce(taxableInc5ADii.value);
		var splRateIncTax5ADii = document.getElementsByName('scheduleSI.splCodeRateTax[7].splRateIncTax')[0]; splRateIncTax5ADii.value = coalesce(splRateIncTax5ADii.value);

		var secCode115ADiiiP = document.getElementsByName('scheduleSI.splCodeRateTax[10].secCode')[0];secCode115ADiiiP.value = coalesceString(secCode115ADiiiP.value);
		var splRatePercent115ADiiiP = document.getElementsByName('scheduleSI.splCodeRateTax[10].splRatePercent')[0];splRatePercent115ADiiiP.value = coalesce(splRatePercent115ADiiiP.value);
		var splRateInc115ADiiiP = document.getElementsByName('scheduleSI.splCodeRateTax[10].splRateInc')[0];	splRateInc115ADiiiP.value = coalesce(splRateInc115ADiiiP.value);
		var taxableInc115ADiiiP = document.getElementsByName('scheduleSI.splCodeRateTax[10].taxableInc')[0];taxableInc115ADiiiP.value = coalesce(taxableInc115ADiiiP.value);
		var splRateIncTax115ADiiiP = document.getElementsByName('scheduleSI.splCodeRateTax[10].splRateIncTax')[0];splRateIncTax115ADiiiP.value = coalesce(splRateIncTax115ADiiiP.value);


		var splRateInc115BBFBP = document.getElementsByName('scheduleSI.splCodeRateTax[8].splRateInc')[0];	splRateInc115BBFBP.value = coalesce(splRateInc115BBFBP.value);
		var taxableInc115BBFBP = document.getElementsByName('scheduleSI.splCodeRateTax[8].taxableInc')[0]; taxableInc115BBFBP.value = coalesce(taxableInc115BBFBP.value);
		var splRateIncTax115BBFBP = document.getElementsByName('scheduleSI.splCodeRateTax[8].splRateIncTax')[0]; splRateIncTax115BBFBP.value = coalesce(splRateIncTax115BBFBP.value);


		var splRateInc115BGFBP = document.getElementsByName('scheduleSI.splCodeRateTax[9].splRateInc')[0];	splRateInc115BGFBP.value = coalesce(splRateInc115BGFBP.value);
		var taxableInc115BBGBP = document.getElementsByName('scheduleSI.splCodeRateTax[9].taxableInc')[0]; taxableInc115BBGBP.value = coalesce(taxableInc115BBGBP.value);
		var splRateIncTax115BBGBP = document.getElementsByName('scheduleSI.splCodeRateTax[9].splRateIncTax')[0]; splRateIncTax115BBGBP.value = coalesce(splRateIncTax115BBGBP.value);


		//Taxable Income autopopulate

		taxableIncDTAA.value=zeroOrMore(splRateIncDTAA.value);
		taxableInc5ADii.value = zeroOrMore(splRateInc5ADii.value);
		taxableIncLtcgDtaa.value = zeroOrMore(splRateIncLtcgDtaa.value);
		taxableIncStcgDtaa.value = zeroOrMore(splRateIncStcgDtaa.value);

		taxableInc21.value=zeroOrMore(splRateInc21.value);
		taxableInc1A.value=zeroOrMore(splRateInc1A.value);
		taxableInc22.value =zeroOrMore(splRateInc22.value);
		taxableInc21ciii.value=zeroOrMore(splRateInc21ciii.value);
		taxableInc5BB.value=zeroOrMore(splRateInc5BB.value);
		taxableInc112A.value=zeroOrMore(splRateInc112A.value);
		taxableInc5b.value=zeroOrMore(splRateInc5b.value);
		taxableInc115ADiiiP.value=zeroOrMore(splRateInc115ADiiiP.value);
		taxableInc115BBFBP.value = zeroOrMore(splRateInc115BBFBP.value);
		taxableInc115BBGBP.value = zeroOrMore(splRateInc115BGFBP.value);

		//Column 'Tax thereon' values for fixed rows


		var temp115ADp =0;
		if(parseInt(taxableInc115ADiiiP.value)<=100000){
			temp115ADp = 0;
		}else{
			temp115ADp = parseInt(taxableInc115ADiiiP.value)-parseInt(100000);
		}
		var temp112A =0;
		if(parseInt(taxableInc112A.value)<=100000){
			temp112A = 0;
		}else{
			temp112A = parseInt(taxableInc112A.value)-parseInt(100000);
		}
		splRateIncTax115ADiiiP.value = Math.round((10 * eval(parseInt(temp115ADp,
				10)))
				/ parseInt('100', 10));
		splRateIncTax112A.value = Math.round((10 * eval(parseInt(temp112A,
				10)))
				/ parseInt('100', 10));
		splRateIncTax5ADii.value = Math.round((30 * eval(parseInt(taxableInc5ADii.value, 10)))/ parseInt('100', 10));

		splRateIncTax1A.value = Math.round((15*eval(parseInt(taxableInc1A.value,10)))/parseInt('100' ,10));
		splRateIncTax22.value = Math.round((10*eval(parseInt(taxableInc22.value,10)))/parseInt('100' ,10));
		splRateIncTax21ciii.value = Math.round((10*eval(parseInt(taxableInc21ciii.value,10)))/parseInt('100' ,10));
		splRateIncTax21.value = Math.round((20*eval(parseInt(taxableInc21.value,10)))/parseInt('100' ,10));
		splRateIncTax5BB.value = Math.round((30*eval(parseInt(taxableInc5BB.value,10)))/parseInt('100' ,10));
		splRateIncTax115BBFBP.value = Math.round((10 * eval(parseInt(taxableInc115BBFBP.value,10)))/ parseInt('100', 10));
		splRateIncTax115BBGBP.value = Math.round((10 * eval(parseInt(taxableInc115BBGBP.value,10)))/ parseInt('100', 10));

		splRateIncTax5b.value = Math.round((12.5*eval(parseInt(taxableInc5b.value,10)))/parseInt('100' ,10));

		var totSplRateInc = eval(parseInt(splRateInc1A.value ,10)) +
		eval(parseInt(splRateInc22.value ,10))+
		eval(parseInt(splRateInc21ciii.value ,10)) +
		eval(parseInt(splRateInc21.value ,10)) +
		eval(parseInt(splRateInc5BB.value ,10)) +
		eval(parseInt(splRateInc5ADii.value, 10))+
		eval(parseInt(splRateIncDTAA.value ,10))+
		eval(parseInt(splRateIncLtcgDtaa.value, 10))+
		eval(parseInt(splRateIncStcgDtaa.value, 10))+
		eval(parseInt(splRateInc5b.value ,10))	+
		eval(parseInt(splRateInc115ADiiiP.value, 10))+
		eval(parseInt(splRateInc112A.value, 10))+
		eval(parseInt(splRateInc115BBFBP.value, 10))+
		eval(parseInt(splRateInc115BGFBP.value, 10));


		var totSplRateIncTax = eval(parseInt(splRateIncTax1A.value ,10)) +
		eval(parseInt(splRateIncTax22.value ,10))+
		eval(parseInt(splRateIncTax21ciii.value ,10)) +
		eval(parseInt(splRateIncTax21.value ,10)) +
		eval(parseInt(splRateIncTax5BB.value ,10)) +
		eval(parseInt(splRateIncTax5ADii.value, 10))+
		eval(parseInt(splRateIncTaxDTAA.value ,10))+
		eval(parseInt(splRateIncTaxLtcgDtaa.value, 10))+
		eval(parseInt(splRateIncTaxStcgDtaa.value, 10))+
		eval(parseInt(splRateIncTax5b.value ,10))	+
		eval(parseInt(splRateIncTax115ADiiiP.value, 10))+
		eval(parseInt(splRateIncTax112A.value, 10))+
		eval(parseInt(splRateIncTax115BBFBP.value, 10))+
		eval(parseInt(splRateIncTax115BBGBP.value, 10));

		var totTaxableInc = eval(parseInt(taxableInc1A.value ,10)) +
		eval(parseInt(taxableInc22.value ,10))+
		eval(parseInt(taxableInc21ciii.value ,10)) +
		eval(parseInt(taxableInc21.value ,10)) +
		eval(parseInt(taxableInc5BB.value ,10)) +
		eval(parseInt(taxableInc5ADii.value, 10))+
		eval(parseInt(taxableIncDTAA.value ,10))+
		eval(parseInt(taxableIncLtcgDtaa.value, 10))+
		eval(parseInt(taxableIncStcgDtaa.value, 10))+
		eval(parseInt(taxableInc5b.value ,10))	+
		eval(parseInt(taxableInc115ADiiiP.value, 10))+
		eval(parseInt(taxableInc112A.value, 10))+
		eval(parseInt(taxableInc115BBFBP.value, 10))+
		eval(parseInt(taxableInc115BBGBP.value, 10));

		var exemption = getExemption_SI();
		var rowCount1 = countRowInTable('scheduleSI.splCodeRateTax', 'splRateInc');
		for (var i = 14; i < rowCount1; i++) {
			var secCode = document
			.getElementsByName('scheduleSI.splCodeRateTax[' + i
					+ '].secCode')[0].value;
			var splCodeValue = document
			.getElementsByName('scheduleSI.splCodeRateTax[' + i
					+ '].splRateInc')[0].value;
			var splRatePercent = document
			.getElementsByName('scheduleSI.splCodeRateTax[' + i
					+ '].splRatePercent')[0].value;
			var splRateIncTaxPti112A = document
			.getElementsByName('scheduleSI.splCodeRateTax[' + i
					+ '].splRateIncTax')[0].value;
			if (secCode == 'PTI_LTCG10P112A') {
				document.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].taxableInc')[0].value = zeroOrMore(coalesce(splCodeValue));
				if (exemption <= splCodeValue) {
					document.getElementsByName('scheduleSI.splCodeRateTax[' + i
							+ '].taxableInc')[0].value = zeroOrMore(parseInt(
									coalesce(splCodeValue), 10)
									- exemption);
					exemption = 0;
				} else {
					document.getElementsByName('scheduleSI.splCodeRateTax[' + i
							+ '].taxableInc')[0].value = 0;
					exemption = zeroOrMore(exemption
							- parseInt(coalesce(splCodeValue), 10));
				}

				document.getElementsByName('scheduleSI.splCodeRateTax[' + i
						+ '].splRateIncTax')[0].value = Math
						.round(eval((parseFloat(coalesce(splRatePercent), 10) * parseInt(
								coalesce(splCodeValue), 10))
								/ parseInt('100', 10)));
								var tempPti112A = 0;
								if (taxableInc112A.value <= 100000) {
									var exmp = parseInt('100000', 10) - taxableInc112A.value;
									if (parseInt(document
											.getElementsByName('scheduleSI.splCodeRateTax[' + i
													+ '].taxableInc')[0].value) <= exmp) {
										tempPti112A = 0;
									} else {
										tempPti112A = parseInt(document
												.getElementsByName('scheduleSI.splCodeRateTax['
														+ i + '].taxableInc')[0].value)
														- exmp;
									}
								} else {
									tempPti112A = parseInt(document
											.getElementsByName('scheduleSI.splCodeRateTax[' + i
													+ '].taxableInc')[0].value);
								}
								document
								.getElementsByName('scheduleSI.splCodeRateTax[' + i
										+ '].splRateIncTax')[0].value = Math.round((10 * eval(parseInt(
												tempPti112A, 10)))
												/ parseInt('100', 10));

												totSplRateInc = eval(parseInt(totSplRateInc, 10)
														+ parseInt(coalesce(splCodeValue), 10));
										totSplRateIncTax = eval(parseInt(totSplRateIncTax, 10)
												+ parseInt(coalesce(document
														.getElementsByName('scheduleSI.splCodeRateTax[' + i
																+ '].splRateIncTax')[0].value), 10));
										totTaxableInc = eval(parseInt(totTaxableInc, 10)
												+ parseInt(coalesce(document
														.getElementsByName('scheduleSI.splCodeRateTax[' + i
																+ '].taxableInc')[0].value), 10));

			}
		}


		var rowCount1=countRowInTable('scheduleSI.splCodeRateTax','splRateInc');

		for(var i = 14; i < rowCount1; i++) {

			var secCode= document
			.getElementsByName('scheduleSI.splCodeRateTax[' + i
					+ '].secCode')[0].value;

			if(secCode=='PTI_LTCG10P112A')
			{
				continue;
			}

			var splCodeValue=document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRateInc')[0].value;
			var splRatePercent = document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRatePercent')[0].value;
			document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].taxableInc')[0].value=zeroOrMore(coalesce(splCodeValue));
			document.getElementsByName('scheduleSI.splCodeRateTax['+i
					+'].splRateIncTax')[0].value=Math.round(eval((parseFloat(
							coalesce(splRatePercent) ,10) * parseInt(
									coalesce(splCodeValue),10))
									/parseInt('100' ,10) ));


									totSplRateInc = eval ( parseInt(totSplRateInc ,10) + parseInt( coalesce(splCodeValue) ,10) );
					totSplRateIncTax = eval ( parseInt(totSplRateIncTax ,10) + parseInt( coalesce(document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRateIncTax')[0].value) ,10) );
					totTaxableInc=eval ( parseInt(totTaxableInc ,10) + parseInt( coalesce(document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].taxableInc')[0].value) ,10) );

		}
		document.getElementsByName('scheduleSI.totSplRateIncTax')[0].value = zeroOrMore(totSplRateIncTax);
		document.getElementsByName('scheduleSI.totSplRateInc')[0].value = zeroOrMore(totSplRateInc);
		document.getElementsByName('scheduleSI.totSplRateTaxableInc')[0].value = zeroOrMore(totTaxableInc);
		//checkSIAmount();
	}catch(e){
		alert('Errror in SI:'+e.stack);
	}
}


function addSchSIRow(SecCode,SecCodeValue){
	try{
		var tableId=document.getElementById('scheduleSI');
		var mainTable=document.getElementById('scheduleSI').rows;
		var noOfRows=tableId.rows.length;
		var toInsertBefore=document.getElementById('scheduleSILastRow');

		var lastIndex=eval(parseInt(noOfRows,10)-2);


		var cloneNode=mainTable[lastIndex].cloneNode(true);
		var newSlNo=cloneNode.cells[0].textContent;

		var iterate=eval(parseInt(newSlNo,10)-1);


		cloneNode.cells[0].innerHTML=eval(parseInt(newSlNo,10)+1);
		//getSection
		cloneNode.cells[1].innerHTML=getSectionTextMap(SecCode);
		var inputTags=cloneNode.getElementsByTagName('input');
		for(var a=0;a<inputTags.length;a++){

			inputTags[a].name=inputTags[a].name.replace('['+iterate+']','['+lastIndex+']');

			inputTags[a].id=inputTags[a].name.replace(/([\.\[\]])/g,'_').replace(/(__)/g,'_');
			//Display Section Rate
			inputTags[1].value=getSectionTaxRate(SecCode);
			//Income
			inputTags[2].value=zeroOrMore(parseInt(SecCodeValue,10));


			if(inputTags[a].getAttribute('type')=='hidden' && inputTags[a].name.match("secCode$")){
				inputTags[a].value=SecCode;
			}


			var blurAttr=inputTags[a].getAttribute('onblur');
			if(blurAttr!=null){
				blurAttr=blurAttr+";";
			}else{
				blurAttr="";
			}
			inputTags[a].setAttribute('onblur',blurAttr+'j.blur(this,this.name,this.value);');
		}
		document.getElementById('scheduleSI').getElementsByTagName('tr')[0].parentNode.insertBefore(cloneNode,toInsertBefore);



	}catch(e){
		alert('addSchSIRow'+ e.stack);
	}
}




function populateSI(cgosIncome,simap){
	try{
		updateMapForSI(cgosIncome, simap);
		var sec111grosstot=0;

		var table = document.getElementById('scheduleOsNriIncTaxDtaa');
		var rowCount = table.rows.length - 2;

		for (var k = 0; k < rowCount; k++) {
			if (document
					.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
							+ k + '].itemIncluded')[0].value == '1') {
				sec111grosstot = eval(sec111grosstot
						+ parseInt(
								coalesce(document
										.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
												+ k + '].amount')[0].value), 10));
			}
		}

		//111
		/*document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0].value= zeroOrMore(parseInt(
	    document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.totalTaxBenefit')[0].value
		- sec111grosstot, 10));
	    document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateInc')[0].value = zeroOrMore(parseInt(document
				.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.taxAccumulatedBalRecPF.totalIncomeBenefit')[0].value));
	    document.getElementsByName('scheduleSI.splCodeRateTax[0].taxableInc')[0].value = document
		.getElementsByName('scheduleSI.splCodeRateTax[0].splRateInc')[0].value;
		 */
		// DTAAOS
		document.getElementsByName('scheduleSI.splCodeRateTax[11].splRateInc')[0].value = zeroOrMore(parseInt(
				document
				.getElementsByName('scheduleBFLA.stcg.stcgDTAARate.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value,
				10));
		document.getElementsByName('scheduleSI.splCodeRateTax[12].splRateInc')[0].value = zeroOrMore(parseInt(
				document
				.getElementsByName('scheduleBFLA.ltcg.ltcgDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value,
				10));

		document.getElementsByName('scheduleSI.splCodeRateTax[13].splRateInc')[0].value = zeroOrMore(parseInt(
				document
				.getElementsByName('scheduleBFLA.othSrcDtaaRates.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value,
				10));

		//111A
		document.getElementsByName('scheduleSI.splCodeRateTax[1].splRateInc')[0].value= zeroOrMore(parseInt(cgosIncome.cgInc.stcg.prctg15.sec111a,10));

		//112
		document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0].value = zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg20.sec112,10));

		//112proviso
		document.getElementsByName('scheduleSI.splCodeRateTax[3].splRateInc')[0].value = zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg10.secProviso,10));

		//112(1)(c)(iii)
		document.getElementsByName('scheduleSI.splCodeRateTax[4].splRateInc')[0].value = zeroOrMore(parseInt(cgosIncome.cgInc.ltcg.prctg10.sec112_1_c_2,10));

		//112A
		document.getElementsByName('scheduleSI.splCodeRateTax[5].splRateInc')[0].value = zeroOrMore(parseInt(
				cgosIncome.cgInc.ltcg.prctg10.sec112A, 10));

		//5BB
		document.getElementsByName('scheduleSI.splCodeRateTax[6].splRateInc')[0].value = zeroOrMore(parseInt(
				document
				.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls0.sourceAmount')[0].value,
				10));


		//115BB
		/*document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateInc')[0].value = zeroOrMore(parseInt(
				document
				.getElementsByName('scheduleBFLA.profitgainInc.incBFLA.incOfCurYrAfterSetOffBFLosses')[0].value,
				10));*/

		//5ADii
		document.getElementsByName('scheduleSI.splCodeRateTax[7].splRateInc')[0].value = zeroOrMore(parseInt(
				cgosIncome.cgInc.stcg.prctg30.sec115AD, 10));


		document.getElementsByName('scheduleSI.splCodeRateTax[8].splRateInc')[0].value =  zeroOrMore(parseInt(
				document
				.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF')[0].value,
				10));

		document.getElementsByName('scheduleSI.splCodeRateTax[9].splRateInc')[0].value =zeroOrMore(parseInt(
				document
				.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG')[0].value,
				10));

		document.getElementsByName('scheduleSI.splCodeRateTax[10].splRateInc')[0].value =zeroOrMore(parseInt(
				cgosIncome.cgInc.ltcg.prctg10.sec115ADiiiP, 10));

		document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0].value=zeroOrMore( parseInt(cgosIncome.cgInc.ltcg.prctg20.sec112, 10));

		deleteSIRow();

		for(var i in simap){
			if(simap[i]!='undefined' && simap[i]!=null && simap[i]!=0 && i !=''){
				var secAdded=checkSectionAddedSI(i,simap[i]);
				if (!secAdded && !( i == '')) {
					addSchSIRow(i, coalesce(simap[i]));
				}
			}


		}

		for(var si in simap){

			simap[si]='';
		}
		calcScheduleSI();
	}catch(e){
		alert('Error in populateSI:' +e.stack);
	}

}

function checkSectionAddedSI(secCode,secValue){
	try{


		var tab=document.getElementById('scheduleSI');
		var noofRows=tab.rows.length;
		var secAdded=false;
		for(var i=0;i<eval(parseInt(noofRows,10)-5);i++){
			if(document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].secCode')[0].value==secCode ){
				document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRateInc')[0].value=zeroOrMore(parseInt(secValue,10));
				secAdded=true;
			}

		}
	}catch(e){
		alert('error in checkSectionAddedSI' +e);
	}
	return secAdded;
}

function deleteSIRow(){
	try{
		var siTable=document.getElementById('scheduleSI');
	
		var noRows=siTable.rows.length;
		if(parseInt(noRows,10) > 10){
			for(var i=15;i<parseInt(noRows,10)-1;i++){
				siTable.deleteRow(15);
			}

		}
	}catch(e){
		alert('Error in deleteSIRow:'+ e.stack)
	}
}


function getSectionTextMap(key){
	var sectionTextMap={
			"1A":"111A (STCG on shares/equity oriented MF on which STT paid)",
			"21":"112 (LTCG on others)",
			"22":"112 proviso (LTCG on listed securities/ units without indexation)",
			"21ciii":"112(1)(c)(iii)(LTCG for non-resident on unlisted securities)",
			"5A1ai":"115A(1)(a)(i)- Dividends interest and income from units purchase in foreign currency",
			"5A1aii":"115A(1)(a)(ii)- Interest received from govt/Indian Concerns recived in Foreign Currency",
			"5A1aiia":"115A(1) (a)(iia) -Interest from Infrastructure Debt Fund",
			"5A1aiiaa":"115A(1) (a)(iiaa) -Interest as per Sec. 194LC",
			"5A1aiiab":"115A(1) (a)(iiab) -Interest as per Sec. 194LD",
			"5A1aiiac" : "115A(1)(a)(iiac) -Interest as per Sec. 194LBA",
			"5A1aiii":"115A(1) (a)(iii) - Income received in respect of units of UTI purchased in Foreign Currency",
			"5ACA1a" : "115ACA(1)(a) - Income by way of dividends from GDRs purchased in foreign currency by residents - chargeable u/s 115ACA",
			"5A1bA":"115A(1)(b)(A) & 115A(1)(b)(B)- Income from royalty & technical services",
			//  "5A1bB":"115A(1)(b)(B) Income from royalty & technical services",
			"5AC1ab":"115AC(1)(a & b) - Income from bonds or GDR purchased in foreign currency - non-resident",
			"5AC1c":"115AC(1)(c) -LTCG arising from the transfer of bonds or GDR purchased in foreign currency - non-resident",
			"5AB1b":"115AB(1)(b) - Income by way of long-term capital gains arising from the transfer of units purchased in foreign currency by a off-shore fund",
			"5ACA1b":"115ACA(1)(b)-long term capital gains arising from their transfer in case of a resident employee of an Indian company, engaged in knowledge based industry or service",
			"5AD1i":"115AD(1)(i) -Income received by an FII in respect of securities (other than units as per Sec 115AB)",
			"5AD1iP":"115AD(1)(i) -Income received by an FII in respect of bonds or government securities as per Sec 194LD ",
			"5ADii":"115AD(1)(ii) -STCG (other than on equity share or equity oriented mutual fund referred to in section 111A) by an FII",
			"5ADiii":"115AD(1)(iii)-Long term capital gains by an FII",
			"5B":"115B - Profits and gains of life insurance business",
			"5BB":"115BB (Winnings from lotteries, puzzles, races, games etc.)",
			"5BBA":"115BBA - Tax on non-residents sportsmen or sports associations",
			"5BBDA":"115BBDA - Tax on certain dividends received from domestic companies",
			"5BBC":"115BBC - Anonymous donations",
			"5BBE":"115BBE - Tax on income referred to in sections 68 or 69 or 69A or 69B or 69C or 69D",
			"5BBF":"115BBF - Tax on income from patent",
			"5BBF_BP":"115BBF - Tax on income from patent (Income under head business or profession)",
			"5BBG":"115BBG - Tax on Transfer of carbon credits",
			"5BBG_BP":"115BBG - Tax on Transfer of carbon credits (Income under head business or profession)",                    
			"5Eacg":"115E(a)-LTCG on any asset other than a specified asset-non resident Indian",
			"5Eb":"115E(b) -Long term capital gains of a non-resident Indian on any specified asset",
			"PTI_LTCG10P112A" : "Pass Through Income in the nature of Long Term Capital Gain chargeable @ 10% u/s 112A",
			"PTI_LTCG10P" : "Pass Through Income in the nature of Long Term Capital Gain chargeable @ 10% u/s other than u/s 112A",                		
			"PTI_LTCG20P" : "Pass Through Income in the nature of Long Term Capital Gain chargeable @ 20%",
			"PTI_STCG30P" : "Pass Through Income in the nature of Short Term Capital Gain chargeable @ 30%",
			"PTI_STCG15P" : "Pass Through Income in the nature of Short Term Capital Gain chargeable @ 15%",
			"DTAAOS" : "Chargeable under DTAA rate",
			"2A" : "112A - LTCG on equity shares/units of equity oriented fund/units of business trust on which STT is paid",
			"5ADiiiP" : "115AD(1)(iii)(p)From sale of equity share or unit of equity oriented fund or unit of a business trust on which STT is paid under section 112A",
			"DTAASTCG" : "STCG Chargeable under DTAA rates",
			"DTAALTCG" : "LTCG Chargeable under DTAA rates",
			"DTAAOS" : "Other source income chargeable under DTAA rates",
			"5AB1a":"115AB(1)(a) - Income in respect of units - off -shore fund",
			"PTI_5AB1a":"PTI-115AB(1)(a) - Income in respect of units - off -shore fund",
			"5AD1biip":"115AD(1)(b)(ii)- Short term capital gains referred to in section 111A",
			"5Ea":"115E(a) - Investment Income of a Non-Resident Indian -chargeable u/s 115E",
			"5Eacg":"115E(a)-LTCG on any asset other than a specified asset-non resident Indian",
			"5Eb":"115E(b) - Income by way of long term capital gains",
			"DTAAOS":"Other source income chargeable under DTAA rates",
			"sec11EA" : "115E(a)-LTCG on any asset other than a specified asset-non resident Indian",
			"56i":"56(2)(i)- Dividends",
			"56":"56(2)- Interest",
			"562iii": "56(2)(iii)- Rental income from machinery, plants, buildings etc",
			"562x": "56(2)(x)- Income under section",
			"A1e":"A1e",
			"A2c":"A2c",
			"A3e_111A":"A3e-111A",
			"A3e_115AD":"A3e-115AD",
			"A4a":"A4a",
			"A4b":"A4b",
			"A5e":"A5e",
			"A6g":"A6g",
			"A7":"A7",
			"A8a":"A8(a)",
			"A8b":"A8(b)",
			"A8c":"A8(c)",
			"B1e":"B1e",
			"B2e":"B2e",
			"B3c":"B3c",
			"B4c":"B4c",
			"B5":"B5",
			"B6":"B6",
			"B7c112(1)(c)":"B7c-112(1)(c)",
			"B7c115AB1b":"B7c115AB1b",
			"B7c115AC":"B7c-115AC",
			"B7c115AD":"B7c-115AD",
			"B8":"B8",
			"B9e":"B9e",
			"B10":"B10",
			"B11a1" : "B11a1",
			"B11a2" : "B11a2",
			"B11b":"B11(b)",

			"Others":"Others",
			"PTI_5A1ai" : "PTI-115A(1)(a)(i)- Dividends interest and income from units purchase in foreign currency",
			"PTI_5A1aii" : "PTI-115A(1)(a)(ii)- Interest received from govt/Indian Concerns received in Foreign Currency",
			"PTI_5A1aiia" : "PTI-115A(1) (a)(iia)-Interest from Infrastructure Debt Fund",
			"PTI_5A1aiiaa" : "PTI-115A(1) (a)(iiaa)	-Interest as per Sec. 194LC",
			"PTI_5A1aiiab" : "PTI-115A(1) (a)(iiab)	-Interest as per Sec. 194LD",
			"PTI_5A1aiiac" : "PTI-115A(1)(a)(iiac)	-Interest as per Sec. 194LBA",
			"PTI_5A1aiii" : "PTI-115A(1) (a)(iii) -	Income received in respect of units of UTI purchased in Foreign Currency",
			"PTI_5A1bA" : "PTI-115A(1)(b)(A) & PTI-115A(1)(b)(B)- Income from royalty & technical services",
			//	"PTI_5A1bB" : "PTI-115A(1)(b)(B) Income	from royalty & technical services",
			"PTI_5AC1ab" : "PTI-115AC(1)(a & b) - Income from bonds or GDR purchased in foreign	currency - non-resident",
			"PTI_5ACA1a" : "PTI-115ACA(1)(a) - PTI- Income by way of dividends from GDRs purchased in foreign currency by residents - chargeable u/s 115ACA",
			"PTI_5AD1i" : "PTI-115AD(1)(i) -Income received by an FII in respect of securities (other than units as per Sec 115AB)",
			"PTI_5AD1iP" : "PTI-115AD(1)(i) -Income	received by an FII in respect of bonds or government securities as per Sec 194LD",
			"PTI_5BBA" : "PTI-115BBA - Tax on	non-residents sportsmen or sports associations",
			"PTI_5BBDA" : "PTI-115BBDA - Dividend Income from domestic company exceeding 10Lakh",
			"PTI_5BBF" : "PTI-115BBF -Tax on income	from patent",
			"PTI_5BBG" : "PTI-115BBG -Tax on income from transfer of carbon credits.",
			"PTI_5BBC" : "PTI-115BBC - Anonymous	donations",
			"PTI_5Ea" : "PTI-115E(a) -PTI-Investment Income of a Non-Resident Indian -chargeable u/s 115E"
			/*"PTI_5BB" : "PTI-115BB - Winnings from lotteries, crossword puzzles etc.",
			        		"PTI_5BBE" : "PTI-115BBE -  Tax on income under section 68, 69, 69A, 69B, 69C or 69D"*/

	};

	return sectionTextMap[key];
}

function getSectionTaxRate(key){
	var sectionRateMap={"1A":"15",
			"PTI_STCG15P" : "15",
			"PTI_STCG30P" : "30",
			"PTI_LTCG10P" : "10",
			"PTI_LTCG10P112A" : "10",
			"PTI_LTCG20P" : "20",
			"5ACA1a" : "10",
			"21":"20",
			"22":"10",
			"21ciii":"10",
			"5A1ai":"20",
			"5A1aii":"20",
			"5A1aiia":"5",
			"5A1aiiaa":"5",
			"5A1aiiab":"5",
			"5A1aiiac" : "5",
			"5A1aiii":"20",
			"5ADiiiP" : "10",
			"2A" : "10",
			"5A1bA":"10",
			// "5A1bB":"10",
			"5AC1ab":"10",
			"5AC1c":"10",
			"5AB1b":"10",
			"5ACA1b":"10",
			"5AD1i":"20",
			"5AD1iP":"5",
			"5ADii":"30",
			"5ADiii":"10",
			"5B":"12.5",
			"5BB":"30",
			"5BBA":"20",
			"5BBDA":"10",
			"5BBC":"30",
			"5BBE":"60",
			"5BBF":"10",
			"5BBF_BP":"10",
			"5BBG":"10",
			"5BBG_BP":"10",
			"5Ea":"20",
			"5Eacg":"20",
			"5Eb":"10",
			"5AB1a":"10",
			"PTI_5AB1a":"10",
			"5AD1biip":"15",
			"sec11EA" : "10",
			"PTI_5A1ai" : "20",
			"PTI_5A1aii" : "20",
			"PTI_5A1aiia" : "5",
			"PTI_5A1aiiaa" : "5",
			"PTI_5A1aiiab" : "5",
			"PTI_5A1aiiac" : "5",
			"PTI_5A1aiii" : "20",
			"PTI_5A1bA" : "10",
			//"PTI_5A1bB" : "10",
			"PTI_5AC1ab" : "10",
			"PTI_5AC1c" : "10",
			"PTI_5ACA1a" : "10",
			"PTI_5ACA1b" : "10",
			"PTI_5AD1i" : "20",
			"PTI_5AD1iP" : "5",
			"PTI_5ADii" : "30",
			"PTI_5ADiii" : "10",
			"PTI_5BB" : "30",
			"PTI_5BBA" : "20",
			"PTI_5BBC" : "30",
			"PTI_5BBDA" : "10",
			"PTI_5BBE" : "60",
			"PTI_5BBF" : "10",
			"PTI_5BBG" : "10",
			"PTI_5Ea" : "20",
			"PTI_5Eacg" : "20",
			"PTI_5Eb" : "10"

	};

	return sectionRateMap[key];

}

/*function natureOfBusChck(tableId){
	var noRows=4;
	var tab = document.getElementById(tableId);
	var rowCount = tab.rows.length;
	if(rowCount > noRows) {

		addErrorXHTML('','Cannot insert more than 3 rows');
		return false;
	}
	return true;

}

 */

//Validate Balance Sheets.

function balSheetWarnig(){
	var totLaibilty = document.getElementsByName('partabs.fundSrc.totFundSrc')[0].value;
	var totAsests = document.getElementsByName('partabs.fundApply.totFundApply')[0].value;

	if(totLaibilty != totAsests){
		addErrorXHTML('','Sources of funds must be equal to Total application of funds');
		j.setFieldError('partabs.fundSrc.totFundSrc','Sources of funds must be equal to Total application of funds');
	}

}



//to add rows to table sch HP tenants
function addRowToTableSchHpTenants(tableId, noOfRow, last, elem) {

	addRowToTable(tableId, noOfRow, last);
	setSerialNumberTenants(elem, 2);
}

//set serial number tenants
function setSerialNumberTenants(element, header) {
	try {

		var tableId = element.getAttribute('onclick').substring(27,
				element.getAttribute('onclick').lastIndexOf('\''));

		var index = tableId.substring(16);

		index = eval(index - 1);

		var table = document.getElementById(tableId);
		var noOfRows = table.rows.length;

		for ( var i = 0; i < eval(parseInt(noOfRows, 10) - header); i++) {

			document.getElementsByName('scheduleHP.propertyDetails[' + index
					+ '].coTenants[' + i + '].coTenantsSNo')[0].value = i + 1;

		}
	} catch (e) {
		alert('Exception in setSerialNumberTenants method :: ' + e.stack);
	}

}

function addScheduleHP() {
	try{
		var mainTable = document.getElementById('scheduleHPMain').rows;
		var tobeInsertBefore = document.getElementById('scheduleHPAddRow');
		var flag = false;
		var totRow = document.getElementById('scheduleHPLast').cells[0].textContent;

		var iterate = eval(parseInt(totRow) -1);
		for ( var i = 0; i < mainTable.length; i++) {
			var cloneNode = mainTable[i].cloneNode(true);
			if (mainTable[i].id == 'scheduleHP1st') {
				flag = true;
				cloneNode.cells[0].innerHTML = totRow;
			}
			if (mainTable[i].id == 'coOwnerTr') {
				cloneNode.getElementsByTagName('table')[0].setAttribute('id','scheduleHP' + totRow);
				cloneNode.getElementsByTagName('img')[0].setAttribute('onclick','addRowToTableSchHp(' + '\'scheduleHP' + totRow + '\',2,1,this);');
				cloneNode.getElementsByTagName('img')[1].setAttribute('onclick','deleteRowTable(' + '\'scheduleHP' + totRow + '\',1,1)');

			}

			if (mainTable[i].id == 'coTenantTr') {
				cloneNode.getElementsByTagName('table')[0].setAttribute('id','scheduleHPTenant' + totRow);
				cloneNode.getElementsByTagName('img')[0].setAttribute('onclick','addRowToTableSchHpTenants(' + '\'scheduleHPTenant' + totRow + '\',2,1,this);');
				cloneNode.getElementsByTagName('img')[1].setAttribute('onclick', 'deleteRowTable(' + '\'scheduleHPTenant' + totRow + '\',1,1)');
			}

			if (flag) {

				var cellsTot = cloneNode.cells;
				for ( var j = 0; j < cellsTot.length; j++) {
					cloneNode.cells[j].innerHTML = cloneNode.cells[j].innerHTML
					.replace('1a', totRow + 'a')
					.replace('1b', totRow + 'b')
					.replace('1c', totRow + 'c')
					.replace('1d', totRow + 'd')
					.replace('1e', totRow + 'e')
					.replace('1f', totRow + 'f')
					.replace('1g', totRow + 'g')
					.replace('1h', totRow + 'h')
					.replace('1i', totRow + 'i')
					.replace('1j', totRow + 'j').replace('1k', totRow + 'k').replace('property 1',
							'property ' + totRow).replace('property 1',
									'property ' + totRow).replace('property 1',
											'property ' + totRow);
				}

				var inputTags = cloneNode.getElementsByTagName('input');
				for ( var a = 0; a < inputTags.length; a++) {
					inputTags[a].name = inputTags[a].name.replace('[0]', '['+ iterate + ']');
					if (inputTags[a].name.indexOf('coOwnersSNo') == '-1') {
						inputTags[a].value = '';
					}

					if (inputTags[a].name.indexOf('coTenantsSNo') == '-1') {
						inputTags[a].value = '';
					}
					inputTags[a].id = inputTags[a].name.replace(/([\.\[\]])/g, '_').replace(/(__)/g, '_');

					var blurAttr = inputTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					inputTags[a].setAttribute('onblur', blurAttr + 'j.blur(this,this.name,this.value);');
				}

				var selectTags = cloneNode.getElementsByTagName('select');
				for ( var a = 0; a < selectTags.length; a++) {
					selectTags[a].name = selectTags[a].name.replace('[0]', '['
							+ iterate + ']');
					selectTags[a].value = '';
					var name = "scheduleHP.propertyDetails["+iterate+"].addressDetail.stateCode";
					var Countryname = "scheduleHP.propertyDetails["+iterate+"].addressDetail.country";
					if(selectTags[a].name== name){
						if (selectTags[a].name.indexOf('stateCode') != '') {
							selectTags[a].onchange = function() {
								setCounrtyForStateNew('scheduleHP.propertyDetails[' + iterate + '].addressDetail.stateCode','scheduleHP.propertyDetails[' + iterate + '].addressDetail.country','scheduleHP.propertyDetails[' + iterate + '].addressDetail.pinCode','scheduleHP.propertyDetails[' + iterate + '].addressDetail.zipCode');
							};
						}
					}else if(selectTags[a].name== Countryname){

						if (selectTags[a].name.indexOf('country') != '') {
							selectTags[a].onchange = function() {
								setStateForCountryNew('scheduleHP.propertyDetails[' + iterate + '].addressDetail.stateCode','scheduleHP.propertyDetails[' + iterate + '].addressDetail.country','scheduleHP.propertyDetails[' + iterate + '].addressDetail.pinCode','scheduleHP.propertyDetails[' + iterate + '].addressDetail.zipCode');
							};
						}
					}
					selectTags[a].id = selectTags[a].name.replace(/([\.\[\]])/g,
					'_').replace(/(__)/g, '_');

					var blurAttr = selectTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					selectTags[a].setAttribute('onblur', blurAttr + 'j.blur(this,this.name,this.value);');
				}

				var textareaTags = cloneNode.getElementsByTagName('textarea');
				for ( var a = 0; a < textareaTags.length; a++) {
					textareaTags[a].name = textareaTags[a].name.replace('[0]', '['+ iterate + ']');
					textareaTags[a].value = '';
					textareaTags[a].id = textareaTags[a].name.replace(/([\.\[\]])/g, '_').replace(/(__)/g, '_');

					var blurAttr = textareaTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					textareaTags[a].setAttribute('onblur', blurAttr + 'j.blur(this,this.name,this.value);');
				}

				document.getElementById('scheduleHPMain')
				.getElementsByTagName('tr')[0].parentNode.insertBefore(
						cloneNode, tobeInsertBefore);
			}
			if (mainTable[i].id == 'scheduleHPEnd') {
				flag = false;
				break;
			}
		}
		var newVal = eval(parseInt(totRow) + 1);
		var newText = 'Total (';
		for ( var k = 1; k < newVal; k++) {
			newText = newText + k + 'j +';
		}
		newText=newText+newVal+'a )';
		document.getElementById('scheduleHPLast').cells[0].innerHTML=newVal;
		document.getElementById('scheduleHPLast').cells[2].innerHTML=newVal;
		document.getElementById('scheduleHPLast').nextElementSibling.cells[0].innerHTML=newVal+1;
		document.getElementById('scheduleHPLast').nextElementSibling.cells[2].innerHTML=newVal+1;


		if ($('#scheduleHPAddRow')[0].parentNode.children.length == 28) {
			$('#delHPButtonId').prop('disabled', true);
		} else if ($('#scheduleHPAddRow')[0].parentNode.children.length > 28) {
			$('#delHPButtonId').prop('disabled', false);
		}

		$('#scheduleHPTenant' + eval(parseInt(totRow))).find('[type=\"checkbox\"]') .attr('checked', 'checked');
		deleteRowTable('scheduleHPTenant' + eval(parseInt(totRow)), 1, 1);

		document.getElementsByName('scheduleHP.propertyDetails['
				+ (parseInt(totRow) - 1) + '].hpSno')[0].value = totRow;
		var table = document.getElementById('scheduleHPMain');
		modifyRow(table);
		var onchange1 = document.getElementsByName('scheduleHP.propertyDetails['+ (parseInt(totRow) - 1) + '].propCoOwnedFlg')[0].getAttribute('onchange');
		var onchange2 = document.getElementsByName('scheduleHP.propertyDetails['+ (parseInt(totRow) - 1) + '].ifLetOut')[0].getAttribute('onchange');
		onchange1 = onchange1.substring(0, onchange1.indexOf('('));
		onchange2 = onchange2.substring(0, onchange2.indexOf('('));
		window[onchange1]();
		window[onchange2]();
		checkMaxLengthLimit();
	}
	catch (e) {
		console.log("exception in HP : "+e.stack);
	}

}

function delScheduleHPForITR5(){

	if ($('#scheduleHPAddRow')[0].parentNode.children.length > 26) {
		for (var i = 0; i < 23; i++) {
			$('#scheduleHPAddRow')[0].parentNode
			.deleteRow($('#scheduleHPAddRow')[0].parentNode.children.length - 5);
		}
		if ($('#scheduleHPAddRow')[0].parentNode.children.length == 27) {
			$('#delHPButtonId').prop('disabled', true);
		}
	} else if ($('#scheduleHPAddRow')[0].parentNode.children.length == 27) {
		$('#delHPButtonId').prop('disabled', true);
	}

	($('#scheduleHPLast')[0].children)[0].innerHTML = parseInt(($('#scheduleHPLast')[0].children)[0].innerHTML) - 1;

	var totRow = document.getElementById('scheduleHPLast').cells[0].textContent;

	var newVal = eval(parseInt(totRow));
	var newText = 'Income under the head â€œIncome from house propertyâ€ ';
	for (var k = 1; k < newVal; k++) {
		newText = newText + k + 'k +';
	}
	newText = newText + newVal + '(if negative take the figure to 2i of schedule CYLA)';
	document.getElementById('scheduleHPLast').cells[0].innerHTML = newVal;
	document.getElementById('scheduleHPLast').cells[2].innerHTML = newVal;
	document.getElementById('scheduleHPLast').nextElementSibling.cells[2].innerHTML = newVal+1;
	document.getElementById('scheduleHPLast').nextElementSibling.cells[1].innerHTML = newText;
	document.getElementById('scheduleHPLast').nextElementSibling.cells[0].innerHTML = newVal+1;

	var table = document.getElementById('scheduleHPMain');

	modifyRow(table);
	calcITR5();
}


function setSerialNumber(element,header){
	try{

		var tableId=element.getAttribute('onclick').substring(20,element.getAttribute('onclick').lastIndexOf('\''));

		var index=tableId.substring(10);

		index=eval(index-1);

		var table = document.getElementById(tableId);
		var noOfRows = table.rows.length;

		for ( var i = 0; i < eval(parseInt(noOfRows, 10) - header); i++) {

			document.getElementsByName('scheduleHP.propertyDetails['+index+'].coOwners['+i+'].coOwnersSNo')[0].value=i+1;

		}
	}catch(e){
		alert('errror:' +e);
	}

}

function onchangeSetPartnerInfo(){

	var partnerForeignCompFlg=document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value;
	var percentageOfShareForeignComp=document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].value;
	var totIncFrmMemberOfAop=document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].value;

	var tab=document.getElementById('partAGEN2PartnerOrMemberInfoTable').rows;
	for(var i=0;i<(parseInt(tab.length,10)-4);i++){

		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+ i +'].partnerForeignCompFlg')[0].value=partnerForeignCompFlg;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].percentageOfShareForeignComp')[0].value=percentageOfShareForeignComp;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].totIncFrmMemberOfAop')[0].value=totIncFrmMemberOfAop;

	}

}
function onloadSetPartnerInfo(){

	var partnerForeignCompFlg=document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value;
	var percentageOfShareForeignComp=document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].value;
	var totIncFrmMemberOfAop=document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].value;

	var tab=document.getElementById('partAGEN2PartnerOrMemberInfoTable').rows;
	for(var i=0;i<(parseInt(tab.length,10)-4);i++){

		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+ i +'].partnerForeignCompFlg')[0].value=partnerForeignCompFlg;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].percentageOfShareForeignComp')[0].value=percentageOfShareForeignComp;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].totIncFrmMemberOfAop')[0].value=totIncFrmMemberOfAop;
	}

	if(document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value=='YES'){
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].disabled=false;
	} else {
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].disabled=true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].value = '';
	}
}

function checkForeignSelected(){
	try{
		var partnerForeignCompFlg=document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerForeignCompFlg')[0].value;

		var tabl = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
		var selectTags=tabl.getElementsByTagName('select');

		var isForeign=false;

		if(partnerForeignCompFlg=='YES'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('status$')){
					if(selectTags[i].value=='FOREIGN_COMPANY'){
						isForeign=true;
						break;
					}
				}

			}
			if(!isForeign){
				j.setFieldError('partAGEN2.partnerOrMemberInfo[0].status','Please select atleast one member as foreign company');
				addErrorXHTML('','Please select atleast one member as foreign company');
			}

		}
	}catch(e){
		alert(e.stack);
	}

}

function isCoOwned(){
	var totHp=eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent)-1);

	for(var i=0;i<totHp;i++){
		var tempName='scheduleHP.propertyDetails['+i+'].propCoOwnedFlg';
		var val=document.getElementsByName(tempName)[0].value;
		var assessePercentShareProp = document.getElementsByName('scheduleHP.propertyDetails['+i+'].asseseeShareProperty')[0];
		if(val=='YES'){
			$('#scheduleHP'+eval(parseInt(i)+1)).find(':input').prop('disabled', false);
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].coOwners[0].coOwnersSNo')[0].value = 1;
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].asseseeShareProperty')[0].value = 100;

		}else{
			$('#scheduleHP'+eval(parseInt(i)+1)).find('[type=\"checkbox\"]').attr('checked','checked');
			deleteRowTable('scheduleHP'+eval(parseInt(i)+1),1,1);
			$('#scheduleHP'+eval(parseInt(i)+1)).find(':input').prop('disabled', true);
			assessePercentShareProp.disabled=true;
			if(val=='NO'){
				assessePercentShareProp.value='100';
			}else{
				assessePercentShareProp.value='0.0';
			}
		}
	}
}
function checkAmtcSubmit(){
	var taxValue=document.getElementsByName('scheduleAMTC.amtTaxCreditAvailable')[0].value;
	var totalValue=document.getElementsByName('scheduleAMTC.taxSection115JD')[0];

	if(eval(totalValue.value)>eval(taxValue)){
		addError(totalValue,'The total amount of credit utilzed during the current year cannot be greater than amount of Tax against which credit is available',true);
		j.setFieldError(totalValue.name,'The total amount of credit utilzed during the current year cannot be greater than amount of Tax against which credit is available');
	}
}

function checkAMTCValue(minValueName,maxValueName){
	try{
		var minValue=minValueName.value;
		var maxValue=$('[name="' + maxValueName+ '"]')[0].value;

		var taxValue=$('[name="scheduleAMTC.amtTaxCreditAvailable"]')[0].value;

		if(eval(minValue)>eval(maxValue)){

			minValueName.value=0;
			addError(minValueName,'The amount of credit utilized cannot be greater than amount of credit brought forward',true);
			j.setFieldError(minValueName.name,'The total amount of credit utilzed during the current year cannot be greater than amount of Tax against which credit is available');
		}
		if(eval(minValue)>eval(taxValue)){

			minValueName.value=0;
			addError(minValueName,'The amount of credit utilized cannot be greater than amount of tax against which credit is available',true);
			j.setFieldError(minValueName.name,'The amount of credit utilized cannot be greater than amount of tax against which credit is available');
		}
	}catch(e){
		alert(e.stack);
	}
}

function isLetOut() {

	var totHp = eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent) - 1);
	for ( var i = 0; i < totHp; i++) {
		var tempName = 'scheduleHP.propertyDetails[' + i + '].ifLetOut';
		var val = document.getElementsByName(tempName)[0].value;

		if (val == 'Y') {

			$('#scheduleHPTenant' + eval(parseInt(i) + 1)).find(':input').prop('disabled', false);
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].coTenants[0].coTenantsSNo')[0].value = 1;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.annualLetableValue')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.rentNotRealized')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.localTaxes')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.incomeChargbleOwnHands')[0].disabled = true;
		} else if (val == 'D') {
			$('#scheduleHPTenant' + eval(parseInt(i) + 1)).find('[type=\"checkbox\"]').attr('checked', 'checked');
			deleteRowTable('scheduleHPTenant' + eval(parseInt(i) + 1), 1, 1);
			$('#scheduleHPTenant' + eval(parseInt(i) + 1)).find(':input').prop('disabled', true);
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.annualLetableValue')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.rentNotRealized')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.localTaxes')[0].disabled = false;
			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.incomeChargbleOwnHands')[0].disabled = true;
		} else {

			$('#scheduleHPTenant' + eval(parseInt(i) + 1)).find('[type=\"checkbox\"]').attr('checked', 'checked');
			deleteRowTable('scheduleHPTenant' + eval(parseInt(i) + 1), 1, 1);
			$('#scheduleHPTenant' + eval(parseInt(i) + 1)).find(':input').prop('disabled', true);

			document.getElementsByName('scheduleHP.propertyDetails[' + i+ '].rentdetails.annualLetableValue')[0].disabled = true;
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.annualLetableValue')[0].value = '';
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.rentNotRealized')[0].disabled = true;
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.rentNotRealized')[0].value = '';
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.localTaxes')[0].disabled = true;
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.localTaxes')[0].value = '';
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.incomeChargbleOwnHands')[0].disabled = true;
			document.getElementsByName('scheduleHP.propertyDetails[' + i + '].rentdetails.incomeChargbleOwnHands')[0].value = '';
		}

	}

}

function calculateTax(){
	clearOldValues();
	calcITR5();
}

function profLossWarning(){

	var businessReceipts=document.getElementsByName('partapl.creditsToPL.totRevenueFrmOperations')[0];

	if(businessReceipts.value > parseInt('10000000',10)){
		addErrorXHTML(businessReceipts,'Total Revenue from operations (1C of Part A-P & L) of Business & Profession is greater than 1 crore then AUDIT INFORMATION must be completely filled',true);
	}
}

function deleteRowToTableScheduleSI(tableId,noOfRow,last){

	deleteRowTableModified(tableId,noOfRow,last);
	calcScheduleSI();
}

function checkIfChanged(pathToCheck){
	try{
		if( (document.getElementsByName(pathToCheck)[0].fieldChanged == undefined) ||
				(document.getElementsByName(pathToCheck)[0].fieldChanged != undefined &&
						document.getElementsByName(pathToCheck)[0].fieldChanged =='false')){
			return false;
		}else{
			return true;
		}
	}catch(e){
		alert("error at:"+e.stack);
		alert("error in:"+e)
	}
}

function checkFirstLessThanMinOthTwo(path1, path2, path3,verticalCeiling){
	if(coalesceSetRet(path2) <= verticalCeiling){
		if(coalesceSetRet(path1) > coalesceSetRet(path2)){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+ coalesceSetRet(path2),true );
			document.getElementsByName(path1)[0].value = coalesceSetRet(path2);
		}
	}else if(verticalCeiling < coalesceSetRet(path2)){
		if(coalesceSetRet(path1) > verticalCeiling){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+ verticalCeiling,true );
			document.getElementsByName(path1)[0].value = verticalCeiling;
		}
	}
}

function checkHPeditableValidity(path1,path2,path4,path3,verticalCeilingHP){
	var tempVal =coalesceSetRet(path2)- coalesceSetRet(path4);
	if(tempVal <= verticalCeilingHP){
		if(coalesceSetRet(path1) > tempVal){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+tempVal,true );
			document.getElementsByName(path1)[0].value = tempVal;
		}
	}else if(verticalCeilingHP < tempVal){
		if(coalesceSetRet(path1) > verticalCeilingHP){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+ verticalCeilingHP,true );
			document.getElementsByName(path1)[0].value = verticalCeilingHP;
		}
	}

}

function checkBPeditableValidity(path1,path2,path4,path5,path3,verticalCeilingBP){

	var tempVal = coalesceSetRet(path2)-coalesceSetRet(path4)-coalesceSetRet(path5);

	if(tempVal <= verticalCeilingBP){
		if(coalesceSetRet(path1) > tempVal){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+tempVal,true );
			document.getElementsByName(path1)[0].value = tempVal;
		}
	}else if(verticalCeilingBP < tempVal){
		if(coalesceSetRet(path1) > verticalCeilingBP){
			addErrorXHTML(document.getElementsByName(path1)[0] , 'This value cannot be greater than '+ verticalCeilingBP,true );
			document.getElementsByName(path1)[0].value = verticalCeilingBP;
		}
	}
}

function clearCYLA(){

	if(document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].fieldChanged=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.busLossSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.busLossSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.busLossSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.busLossSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].fieldChanged=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.hPlossCurYrSetoff')[0].oldvalue=undefined;
	}

	if(document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.busLossSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.busLossSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.busLossSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.busLossSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.busLossSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.othSrcInclRaceHorse.incCYLA.busLossSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.profitFrmRaceHorse.incCYLA.busLossSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.houseProperty.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.busProfInclSpecProf.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.profitgainsInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.speculativeInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.specifiedInc.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.stcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.stcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}
	if(document.getElementsByName('scheduleCYLA.ltcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue!=undefined){
		document.getElementsByName('scheduleCYLA.ltcg.incCYLA.othSrcLossNoRaceHorseSetoff')[0].oldvalue=undefined;
	}

	calcITR5();
}

function checkAMTCCurAY(){
	try{
		var curAYGross=$('[name="scheduleAMTC.scheduleAMTCUtil.CYamtCreditFwd"]')[0];
		var taxSection115JC = $('[name="scheduleAMTC.taxSection115JC"]')[0];
		var taxOthProvisions = $('[name="scheduleAMTC.taxOthProvision"]')[0];
		var curAYGrossTemp;

		if(eval(parseInt(coalesce(taxOthProvisions.value),10)) < eval(parseInt(coalesce(taxSection115JC.value),10))){

			curAYGrossTemp=eval(parseInt(coalesce(taxSection115JC.value),10))-eval(parseInt(coalesce(taxOthProvisions.value),10));

		}else{
			curAYGross.value='0';
			curAYGrossTemp=parseInt('0',10);
		}

		if(curAYGross.value>curAYGrossTemp){

			addError(document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.CYamtCreditFwd')[0],'Gross income for current AY cannot be greater than 1-2',true);
			j.setFieldError('scheduleAMTC.scheduleAMTCUtil.CYamtCreditFwd','Gross income for current AY cannot be greater than 1-2');


		}
	}catch(e){
		alert('Error in checkAMTCCurAY:' +e);
	}
}

function setForeignPartner(){
	try{
		var partnerForeignCompFlg=document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0];
		if(partnerForeignCompFlg.value!='YES'){
			var tabl = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
			var selectTags=tabl.getElementsByTagName('select');

			var isForeign=false;


			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('status$')){
					if(selectTags[i].value=='FOREIGN_COMPANY'){
						isForeign=true;
						break;
					}
				}

			}
			if(isForeign){
				if(partnerForeignCompFlg.disabled!=true){
					partnerForeignCompFlg.value = 'YES';
				}
				enableYesNoForForeignCompFlg('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg','partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp');onchangeSetPartnerInfo();
			}

		}
	}catch(e){
		alert(e.stack);
	}
}

function validatePartners(){
	var fshare = document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0].value;
	var shares = getPercentOfShare();

	var partnerForeignCompFlg = document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0];
	if(parseFloat(shares.foreignPerc) + parseFloat(shares.otherPerc) > 100 ){
		j.setFieldError('partAGEN2.partnerOrMemberInfo[0].sharePercentage','Total share cannot be more than 100%');
		addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].sharePercentage')[0],'Total share cannot be more than 100%');
	}else if(partnerForeignCompFlg.value=='YES'){

		if(parseFloat(fshare) != parseFloat(shares.foreignPerc)){
			j.setFieldError('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp','Foreign Company share mismatch.');
			addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo.percentageOfShareForeignComp')[0],'Foreign Company share mismatch.');
		}
	}
	else if(parseFloat(shares.foreignPerc) > 0  && partnerForeignCompFlg.disabled!=true){

		j.setFieldError('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg','Invalid details of Partner Foreign Company.');
		addErrorXHTML(partnerForeignCompFlg,'Invalid details of Partner Foreign Company.');
	}

	var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if(substatus == 5 || status == 1|| substatus == 15|| substatus == 16|| substatus == 17 || substatus == 4 || substatus == 8 || substatus == 11){
		if(document.getElementById('partAGEN2PartnerOrMemberInfoTable').rows.length < 6){
			j.setFieldError('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName','Atleast two members are required');
			addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName')[0],'Atleast two members are required');
		}
	}
	if(substatus == 12 || substatus == 7|| substatus == 13 || substatus == 20 || substatus == 21){
		if(document.getElementById('partAGEN2PartnerOrMemberInfoTable').rows.length < 5){
			j.setFieldError('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName','Atleast one members are required');
			addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName')[0],'Atleast one members are required');
		}
	}

}

function validateHPRent(){

	var tab=document.getElementById('scheduleHPMain');
	var allInputTags = tab.getElementsByTagName('input');
	var selectTags=tab.getElementsByTagName('select');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("rentdetails.annualLetableValue$")) {
			if( parseInt(allInputTags[i+1].value,10) > parseInt(allInputTags[i].value ,10)) {

				addError(allInputTags[i+1],
						'Rent not realized cannot exceed Annual Letable Value',true);
				j.setFieldError(allInputTags[i+1].name,'Rent not realized cannot exceed Annual Letable Value');
				break;
			}
		}
	}

}

function onEmptySetZero(element){

	if(element.value==""){

		element.value='0';
	}

}

function getPan(){

	var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	return pan;
}

//Function to disable Schedule FA.

/*2019 changes*/

function disableScheduleFA(){

	var resStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	removeTableData('schFADtlsFrignAssetsA1',resStatus);
	removeTableData('schFADtlsFrignAssetsA2',resStatus);
	removeTableData('schFADtlsFrignAssetsA3',resStatus);
	removeTableData('schFADtlsFrignAssetsA4',resStatus);
	removeTableData('schFADtlsFinIntrest',resStatus);
	removeTableData('schFADtlsImmvbleProp',resStatus);
	removeTableData('schFADtlsOtherAsset',resStatus);
	removeTableData('schFADtlsSigningAuth',resStatus);
	removeTableData('schFADtlsTrusts',resStatus);
	removeTableData('DetailsOthIncomeOutsideIndia', resStatus);
}

//Enable Fields for Point-1B for Schedule FA.
function enableFieldsForPoint1B(tableId){

	var tab = document.getElementById(tableId);
	var rows = tab.getElementsByTagName('tr');
	var rowCount = rows.length;

	for(var  i = 0; i<rowCount - 4; i++){
		var selectedOptionId = document.getElementsByName('scheduleFA.dtlsForeignCustodialAcc['+i+'].grossAmtPaidCreditedReason')[0];
		var selectedOption = selectedOptionId.options[selectedOptionId.selectedIndex].value;

		if (selectedOption == 'INTEREST' || selectedOption == 'DIVIDEND' || selectedOption == 'SALEREDEEM' || selectedOption == 'OTHINC'|| selectedOption == 'NOPAIDCRED'){
			document.getElementsByName('scheduleFA.dtlsForeignCustodialAcc['+i+'].grossAmtPaidCredited')[0].disabled = false;

		}else{
			document.getElementsByName('scheduleFA.dtlsForeignCustodialAcc['+i+'].grossAmtPaidCredited')[0].disabled = true;
			document.getElementsByName('scheduleFA.dtlsForeignCustodialAcc['+i+'].grossAmtPaidCredited')[0].value = '';

		}
	}
}


//Delete Data from table.

function removeTableData(tableID,resStatus){

	var tab = document.getElementById(tableID);
	var asstFlag = document.getElementsByName('partBTTI.assetOutIndiaFlag')[0].value;

	if (!(resStatus == 'RES'  && asstFlag == 'YES')) {
		$('#' + tableID + ' input').attr("checked", true);
		deleteRowTable(tableID,3, 1);
		$('#' + tableID + ' input').attr("checked", false);
	}

	var allInputTags = tab.getElementsByTagName('input');
	var selectTags=tab.getElementsByTagName('select');

	for ( var i = 0; i < allInputTags.length; i++) {
		if (resStatus == 'RES' && asstFlag == 'YES') {
			allInputTags[i].disabled = false;
			allInputTags[i].readOnly = false;

		} else {

			allInputTags[i].disabled = true;
			allInputTags[i].readOnly = true;
			allInputTags[i].value = "";
		}
	}

	for ( var i = 0; i < selectTags.length; i++) {
		if (resStatus == 'RES'  && asstFlag == 'YES') {
			selectTags[i].disabled = false;
		} else {
			selectTags[i].disabled = true;
			selectTags[i].value = "";

		}
	}
}





function numberOfCoOwnersCheck(tableId,noRows){
	var tab = document.getElementById(tableId);
	var rowCount = tab.rows.length;
	if(rowCount > noRows) {
		addErrorXHTML('','Cannot insert more than 5 rows',true);
		return false;
	}
	return true;

}

function numberOfRowsForQDCheck(tableId){
	var noRows=21;
	var tab = document.getElementById(tableId);
	var rowCount = tab.rows.length;
	if(rowCount > noRows) {
		addErrorXHTML('','Cannot insert more than 20 rows');
		return false;
	}
	return true;

}

function addRowToTableSchHp(tableId, noOfRow, last,elem) {

	addRowToTable(tableId,noOfRow,last);
	setSerialNumber(elem,2);

}

function schTRonLoad() {

	var fsiTable = document.getElementById('scheduleFSI');
	var noRows = (fsiTable.rows.length-4)/5;

	for(var i=0;i<noRows;i++) {
		var index = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].selectedIndex;
		var countryCodeName = document.getElementsByName('scheduleTR1.scheduleTR['+i+'].countryCodeName')[0];

		countryCodeName.value = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].options[index].text;

		if(countryCodeName.value == "Select"){
			countryCodeName.value = '';
		}
	}
	totAmtOfSchedTRFor6();
}
function schTRonLoad1() {

	var fsiTable = document.getElementById('scheduleFSI');
	var noRows = (fsiTable.rows.length-4)/5;

	for(var i=0;i<noRows;i++) {
		var index = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].selectedIndex;
		var countryCodeName = document.getElementsByName('scheduleTR1.scheduleTR['+i+'].countryCodeName')[0];

		countryCodeName.value = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].options[index].text;

		if(countryCodeName.value == "Select"){
			countryCodeName.value = '';
		}
	}
}

function validateFSI() {
	var table=document.getElementById('scheduleFSI');
	var noOfRows=table.rows.length;
	var indexValue=eval(((parseInt(noOfRows,10)-4)/5));
	var empty2,empty3,empty4;
	for(var i=0;i<indexValue;i++){
		if(document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].value!=''){
			var empty = true;
			var errors = ['Income from outside India(included in PART B-TI) is required',
			              'Tax paid outside India is required',
			              'Tax payable on such income under normal provisions in India is required',
			              'Relevant article of DTAA if relief claimed u/s 90 or 90A is required'];
			empty2 = empty && !validateAllFilled(['itrScheduleFSI.scheduleFSI['+i+'].incFromHP.incFrmOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromHP.taxPaidOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromHP.taxPayableinInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromHP.dtaaReliefUs90or90A'],errors);
			empty3 = empty && !validateAllFilled(['itrScheduleFSI.scheduleFSI['+i+'].incCapGain.incFrmOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incCapGain.taxPaidOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incCapGain.taxPayableinInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incCapGain.dtaaReliefUs90or90A'],errors);
			empty4 = empty && !validateAllFilled(['itrScheduleFSI.scheduleFSI['+i+'].incOthSrc.incFrmOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incOthSrc.taxPaidOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incOthSrc.taxPayableinInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incOthSrc.dtaaReliefUs90or90A'],errors);
			empty5 = empty && !validateAllFilled(['itrScheduleFSI.scheduleFSI['+i+'].incFromBusiness.incFrmOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromBusiness.taxPaidOutsideInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromBusiness.taxPayableinInd',
			                                      'itrScheduleFSI.scheduleFSI['+i+'].incFromBusiness.dtaaReliefUs90or90A'],errors);
			if(empty2&&empty3&&empty4&&empty5){
				j.setFieldError('itrScheduleFSI.scheduleFSI['+i+'].incFromHP.incFrmOutsideInd','Please fill atleast one income');
				addErrorXHTML(document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].incFromHP.incFrmOutsideInd')[0],'Please fill atleast one income',true);
			}
		}
	}
}

function validateAllFilled(fieldNames,errors){
	var fields = [];
	var filled = 0;
	for(var i=0; i<fieldNames.length; i++){
		fields[i] = document.getElementsByName(fieldNames[i])[0];
		if(fields[i].value!='' && fields[i].value!=undefined){
			filled++;
		}
	}
	if(filled>0){
		for(var i=0; i<fieldNames.length; i++){
			if(fields[i].value=='' || fields[i].value==undefined){
				if(i==fieldNames.length-1){
					if(Math.min(coalesce(fields[1].value),coalesce(fields[2].value)) == parseInt(0)){
						continue;
					}
				}
				j.setFieldError(fieldNames[i],errors[i]);
				addErrorXHTML(fields[i],errors[i],true);
				break;
			}
		}
		return true;
	}
	return false;
}

function calcScheduleFSI(){
	try{
		var table=document.getElementById('scheduleFSI');
		var noOfRows=table.rows.length;
		var indexValue=eval(((parseInt(noOfRows,10)-4)/5));

		for(var i=0;i<indexValue;i++){

			document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].totalCountryWise.incFrmOutsideInd")[0].value=
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.incFrmOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.incFrmOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.incFrmOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.incFrmOutsideInd")[0].value),10));

			document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].totalCountryWise.taxPaidOutsideInd")[0].value=
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPaidOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPaidOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPaidOutsideInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPaidOutsideInd")[0].value),10));

			document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].totalCountryWise.taxPayableinInd")[0].value=
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPayableinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPayableinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPayableinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPayableinInd")[0].value),10));

			if(eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPaidOutsideInd")[0].value)<
					eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPayableinInd")[0].value)){
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPaidOutsideInd")[0].value;
			}else{
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxPayableinInd")[0].value;
			}

			if(eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPaidOutsideInd")[0].value)<
					eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPayableinInd")[0].value)){
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPaidOutsideInd")[0].value;
			}else{
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxPayableinInd")[0].value;
			}

			if(eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPaidOutsideInd")[0].value)<
					eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPayableinInd")[0].value)){
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPaidOutsideInd")[0].value;
			}else{
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxPayableinInd")[0].value;
			}

			if(eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPaidOutsideInd")[0].value)<
					eval(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPayableinInd")[0].value)){
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPaidOutsideInd")[0].value;
			}else{
				document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxReliefinInd")[0].value=
					document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxPayableinInd")[0].value;
			}

			document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].totalCountryWise.taxReliefinInd")[0].value=
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromHP.taxReliefinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incFromBusiness.taxReliefinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incCapGain.taxReliefinInd")[0].value),10))+
				eval(parseInt(coalesce(document.getElementsByName("itrScheduleFSI.scheduleFSI["+i+"].incOthSrc.taxReliefinInd")[0].value),10));
		}
		populateTR();
	}catch(e){
		alert('error in calcScheduleFSI = '  +e.stack);
	}
}

function populateTR() {
	try {
		deleteTRRow();
		var fsiTable = document.getElementById('scheduleFSI');
		var noRows = (fsiTable.rows.length-4)/5;
		var pos = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].countryCode')[0].selectedIndex;

		document.getElementsByName('scheduleTR1.scheduleTR[0].countryCode')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].countryCode')[0].value;
		document.getElementsByName('scheduleTR1.scheduleTR[0].countryName')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].countryName')[0].value;

		if(document.getElementsByName('itrScheduleFSI.scheduleFSI[0].countryCode')[0].options[pos].text=="Select") {
			document.getElementsByName('scheduleTR1.scheduleTR[0].countryCodeName')[0].value = '';
		} else {
			document.getElementsByName('scheduleTR1.scheduleTR[0].countryCodeName')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].countryCode')[0].options[pos].text;
		}

		document.getElementsByName('scheduleTR1.scheduleTR[0].taxIdentificationNo')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].taxIdentificationNo')[0].value;
		document.getElementsByName('scheduleTR1.scheduleTR[0].taxPaidOutsideIndia')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].totalCountryWise.taxPaidOutsideInd')[0].value;
		document.getElementsByName('scheduleTR1.scheduleTR[0].taxReliefOutsideIndia')[0].value = document.getElementsByName('itrScheduleFSI.scheduleFSI[0].totalCountryWise.taxReliefinInd')[0].value;

		var firstSecCode = document.getElementsByName('scheduleTR1.scheduleTR[0].countryCodeName')[0].value+'_'+document.getElementsByName('scheduleTR1.scheduleTR[0].taxIdentificationNo')[0].value;

		document.getElementsByName('scheduleTR1.scheduleTR[0].relavantArticleDTAA')[0].value=sectionClaimed[firstSecCode];

		if(noRows>1) {

			var countryCodeName='';
			var taxIdentificationNo='';
			var taxPaidOutsideIndia='';
			var taxReliefOutsideIndia='';

			for(var i=1;i<noRows;i++) {
				var index = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].selectedIndex;

				countryCodeName = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].options[index].text;

				if(countryCodeName=="Select"){
					countryCodeName = '';
				}

				taxIdentificationNo = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].taxIdentificationNo')[0].value;
				taxPaidOutsideIndia = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].totalCountryWise.taxPaidOutsideInd')[0].value;
				taxReliefOutsideIndia = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].totalCountryWise.taxReliefinInd')[0].value;

				addSchTRRow(countryCodeName,taxIdentificationNo,taxPaidOutsideIndia,taxReliefOutsideIndia);

				var countryCode=document.getElementsByName('scheduleTR1.scheduleTR['+i+'].countryCode')[0];
				var countryName=document.getElementsByName('scheduleTR1.scheduleTR['+i+'].countryName')[0];

				countryCode.value = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryCode')[0].value;
				countryName.value = document.getElementsByName('itrScheduleFSI.scheduleFSI['+i+'].countryName')[0].value;


				document.getElementsByName('scheduleTR1.scheduleTR['+i+'].relavantArticleDTAA')[0].value = sectionClaimed[countryCodeName+'_'+taxIdentificationNo];


			}

		}
		for(var i=0;i<noRows;i++) {
			var relavantArticleDTAA = document.getElementsByName('scheduleTR1.scheduleTR['+i+'].relavantArticleDTAA')[0];
			if(relavantArticleDTAA.value != '90' && relavantArticleDTAA.value != '90A' && relavantArticleDTAA.value != '91') {
				relavantArticleDTAA.value='';
			}
		}
		totAmtOfSchedTRFor6('scheduleTR');
	} catch (e) {
		alert('Error in populateTR:' + e);
	}

}

function deleteTRRow() {
	try {
		var trTable = document.getElementById('scheduleTR');
		var noRows = trTable.rows.length;

		if (parseInt(noRows, 10) > 4) {
			for ( var i = 2; i < parseInt(noRows, 10) - 3; i++) {
				var countryCode = document.getElementsByName('scheduleTR1.scheduleTR['+(i-1)+'].countryCodeName')[0];
				var taxIdentificationNo = document.getElementsByName('scheduleTR1.scheduleTR['+(i-1)+'].taxIdentificationNo')[0];
				sectionClaimed[countryCode.value+'_'+taxIdentificationNo.value] = document.getElementsByName('scheduleTR1.scheduleTR['+(i-1)+'].relavantArticleDTAA')[0].value;
				trTable.deleteRow(3);
			}
		}
		sectionClaimed[document.getElementsByName('scheduleTR1.scheduleTR[0].countryCodeName')[0].value+'_'+document.getElementsByName('scheduleTR1.scheduleTR[0].taxIdentificationNo')[0].value] = document.getElementsByName('scheduleTR1.scheduleTR[0].relavantArticleDTAA')[0].value;

		document.getElementsByName('scheduleTR1.scheduleTR[0].countryCode')[0].value='';
		document.getElementsByName('scheduleTR1.scheduleTR[0].taxIdentificationNo')[0].value='';
		document.getElementsByName('scheduleTR1.scheduleTR[0].taxPaidOutsideIndia')[0].value='';
		document.getElementsByName('scheduleTR1.scheduleTR[0].taxReliefOutsideIndia')[0].value='';


	} catch (e) {
		alert('Error in deleteTRRow:' + e);
	}
}

function addSchTRRow(countryCodeName, taxIdentificationNo, taxPaidOutsideIndia,taxReliefOutsideIndia) {
	try {
		var tableId = document.getElementById('scheduleTR');
		var mainTable = document.getElementById('scheduleTR').rows;
		var noOfRows = tableId.rows.length;
		var toInsertBefore = document.getElementById('scheduleTRLastRow');

		var lastIndex = eval(parseInt(noOfRows, 10) - 3);

		var cloneNode = mainTable[lastIndex].cloneNode(true);
		var newSlNo = cloneNode.cells[0].textContent;

		var iterate = eval(parseInt(newSlNo, 10) - 1);

		cloneNode.cells[0].innerHTML = eval(parseInt(newSlNo, 10) + 1);
		var inputTags = cloneNode.getElementsByTagName('input');
		var selectTags = cloneNode.getElementsByTagName('select');
		for ( var a = 0; a < inputTags.length; a++) {
			inputTags[a].name = inputTags[a].name.replace('[' + iterate + ']','[' + (lastIndex - 1) + ']');

			inputTags[a].id = inputTags[a].name.replace(/([\.\[\]])/g, '_').replace(/(__)/g, '_');

			inputTags[0].value = countryCodeName;

			inputTags[3].value = taxIdentificationNo;

			inputTags[4].value = parseInt(taxPaidOutsideIndia, 10);
			inputTags[5].value = parseInt(taxReliefOutsideIndia, 10);

			var blurAttr = inputTags[a].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			inputTags[a].setAttribute('onblur', blurAttr+ 'j.blur(this,this.name,this.value);');
		}

		for ( var a = 0; a < selectTags.length; a++) {
			selectTags[a].name = selectTags[a].name.replace('[' + iterate + ']', '[' + (lastIndex - 1) + ']');
			selectTags[a].id = selectTags[a].name.replace(/([\.\[\]])/g, '_').replace(/(__)/g, '_');

			var blurAttr = inputTags[a].getAttribute('onblur');
			if (blurAttr != null) {
				blurAttr = blurAttr + ";";
			} else {
				blurAttr = "";
			}
			selectTags[a].setAttribute('onblur', blurAttr+ 'j.blur(this,this.name,this.value);');
		}
		document.getElementById('scheduleTR').getElementsByTagName('tr')[0].parentNode.insertBefore(cloneNode, toInsertBefore);

	} catch (e) {
		alert('addSchTRRow' + e);
	}
}
function calculateTotalDeductions()
{

	/*var tab = document.getElementById('schduleCGDed54B');
	var noOfRows = tab.rows.length;
	var sum = 0;
	var amt = 0;
	for (var i = 0; i < (noOfRows -3); i++) {
		amt = document
				.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].AmtClaimed')[0].value;
		sum = eval(parseInt(sum, 10) + parseInt(coalesce(amt), 10));
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point4')[0].value="N";
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point23')[0].value="N";
		if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].dateofOrginalAsset')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].AmtClaimed')[0].value!=""){
		if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].AmtDeposited')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].costOfAgLand')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].dateofAcquist')[0].value==""){
			j.setFieldError('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54B');
			addErrorXHTML('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54B',true);
		}
		else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].costOfAgLand')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].dateofAcquist')[0].value!=""){
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point23')[0].value="N";
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point4')[0].value="N";
		}
		else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].AmtDeposited')[0].value!=""){
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point4')[0].value="N";
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point23')[0].value="N";
		}
		else{
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point4')[0].value="Y";
			document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54B[' + i + '].point23')[0].value="Y";

		}
	}
	}
	 */
	var tab1 = document.getElementById('schduleCGDed54D');
	var noOfRows1 = tab1.rows.length;
	var sum1 = 0;
	var amt1 = 0;

	for (var i = 0; i < (noOfRows1 -3); i++) {
		amt1 = document
		.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].AmtClaimed')[0].value;
		sum1 = eval(parseInt(sum1, 10) + parseInt(coalesce(amt1), 10));
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point4')[0].value="N";
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point23')[0].value="N";
		if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].dateofOrginalAsset')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].AmtClaimed')[0].value!=""){
			if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].AmtDeposited')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].costOfAgLand')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].dateofAcquist')[0].value==""){
				j.setFieldError('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54D');
				addErrorXHTML('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54D',true);
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].costOfAgLand')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].dateofAcquist')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point23')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point4')[0].value="N";
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].AmtDeposited')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point4')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point23')[0].value="N";
			}
			else{
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point4')[0].value="Y";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].point23')[0].value="Y";

			}
		}

	}

	var tab2 = document.getElementById('schduleCGDed54EC');
	var noOfRows2 = tab2.rows.length;
	var sum2 = 0;
	var amt2 = 0;

	for (var i = 0; i < (noOfRows2 -3); i++) {
		amt2 = document
		.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54EC[' + i + '].AmtClaimed')[0].value;
		sum2 = eval(parseInt(sum2, 10) + parseInt(coalesce(amt2), 10));
	}

	/*var tab3 = document.getElementById('schduleCGDed54EE');
	var noOfRows3 = tab3.rows.length;
	var sum3 = 0;
	var amt3 = 0;

	for (var i = 0; i < (noOfRows3 -3); i++) {
		amt3 = document
				.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54EE[' + i + '].AmtClaimed')[0].value;
		sum3 = eval(parseInt(sum3, 10) + parseInt(coalesce(amt3), 10));

	}*/

	var tab4 = document.getElementById('schduleCGDed54G');
	var noOfRows4 = tab4.rows.length;
	var sum4 = 0;
	var amt4 = 0;

	for (var i = 0; i < (noOfRows4 -3); i++) {
		amt4 = document
		.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].AmtClaimed')[0].value;
		sum4 = eval(parseInt(sum4, 10) + parseInt(coalesce(amt4), 10));
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point23')[0].value="N";
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point4')[0].value="N";
		if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].dateofOrginalAsset')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].AmtClaimed')[0].value!=""){
			if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].AmtDeposited')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].costOfAgLand')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].dateofAcquist')[0].value==""){
				j.setFieldError('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54G');
				addErrorXHTML('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54G',true);
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].costOfAgLand')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].dateofAcquist')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point23')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point4')[0].value="N";
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].AmtDeposited')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point4')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point23')[0].value="N";
			}
			else{
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point4')[0].value="Y";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].point23')[0].value="Y";

			}
		}

	}

	var tab5 = document.getElementById('schduleCGDed54GA');
	var noOfRows5 = tab5.rows.length;
	var sum5 = 0;
	var amt5 = 0;

	for (var i = 0; i < (noOfRows5 -3); i++) {
		amt5 = document
		.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].AmtClaimed')[0].value;
		sum5 = eval(parseInt(sum5, 10) + parseInt(coalesce(amt5), 10));
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point23')[0].value="N";
		document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point4')[0].value="N";
		if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].dateofOrginalAsset')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].AmtClaimed')[0].value!=""){
			if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].AmtDeposited')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].costOfAgLand')[0].value==""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].dateofAcquist')[0].value==""){
				j.setFieldError('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54GA');
				addErrorXHTML('','Please enter Cost and Date of purchase or Amount Deposited in Deduction claimed u/s 54GA',true);
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].costOfAgLand')[0].value!=""&&document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].dateofAcquist')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point23')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point4')[0].value="N";
			}
			else if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].AmtDeposited')[0].value!=""){
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point4')[0].value="N";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point23')[0].value="N";
			}
			else{
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point4')[0].value="Y";
				document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].point23')[0].value="Y";

			}
		}

	}
	var totalDed=parseInt(sum1, 10) + parseInt(sum2, 10)  + parseInt(sum4, 10) + parseInt(sum5, 10);

	var totVal = document.getElementsByName('scheduleCGPost45.deducClaimInfo.totDeductClaim')[0];
	totVal.value = totalDed;


}

function validateCGSecwiseDed(){
	var arr = {'54EC':0,'54D':0,'54G':0,'54GA':0};
	var arrDed = {'54EC':0,'54D':0,'54G':0,'54GA':0};
	var table = document.getElementById('scheduleCGstcg1');
	var noOfRows = table.rows.length;
	alert("nnnkk" +noOfRows);
	var valueA1d = parseInt('0',10);
	for (var i = 0; i <noOfRows/14; i++) {
		var r = i+1;
		var tableId = 'stcgDeduction_ded'+r;
		sumSectionWise(tableId, arr);
	}
	sumSectionWise('stcgDeduction2', arr);

	var table = document.getElementById('scheduleCGltcg1');
	var noOfRows = table.rows.length;
alert("lllll" +noOfRows);
	var valueB1d = parseInt('0',10);
	for (var i = 0; i <noOfRows/14; i++) {
		alert("lllbb" +noOfRows);
		var r = i+1;
		var tableId = 'ltcgDeduction1_ded'+r; 

		sumSectionWise(tableId, arr);
	}

	sumSectionWise('scheduleCGltcg7', arr);

	sumSectionWise('scheduleCGltcg3',arr);
	var amt = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.capGainSlumpSale.exemptionOrDednUs54')[0].value;
	arr['54EC']=parseInt(arr['54EC'],10) + parseInt(amt,10);
		
		
	/*	sumSectionWise('ltcgDeduction54ec54ee1', arr);
	 */
	len = document.getElementById('stcg10pctTab').tBodies.length;

	/*arr['54EE'] = parseInt(arr['54EE'])
		+ coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.exemptionOrDednUs54');*/
	/*arr['54EE'] = parseInt(arr['54EE'])
	+ coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].exemptionOrDednUs54S');
	 */
	/*arr['54EE'] = parseInt(arr['54EE'])
	+ coalesceSetRet('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.deduction54F');

	arr['54EE'] = parseInt(arr['54EE'])
	+ coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.exemptionOrDednUs54'); 
	arr['54EE'] = parseInt(arr['54EE'])
	+ coalesceSetRet('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.deduction54F'); */
/*
	arr['54EE'] = parseInt(arr['54EE'])
	+ sumSectionWiseNEW('stcg10pctTab');
*/
	/*	sumSectionWiseCGTableD('schduleCGDed54B', arrDed,'54B');
	 */	sumSectionWiseCGTableD('schduleCGDed54D', arrDed,'54D');
	 sumSectionWiseCGTableD('schduleCGDed54EC', arrDed,'54EC');
	 /*sumSectionWiseCGTableD('schduleCGDed54EE', arrDed,'54EE');*/
	 sumSectionWiseCGTableD('schduleCGDed54G', arrDed,'54G');
	 sumSectionWiseCGTableD('schduleCGDed54GA', arrDed,'54GA');

	 //sumSectionWise('schduleCGDed', arrDed);

	/* if(arr['54']!=arrDed['54']){
		 j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54 must match with deduction in table D');
		 addErrorXHTML('','Deduction under 54 must match with deduction in table D',true);
	 }

*/
	 /*if(arr['54B']!=arrDed['54B']){
		j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54B must match with deduction in table D');
		addErrorXHTML('','Deduction under 54B must match with deduction in table D',true);
	}*/
	
	 /*	
	if(arr['54EE']!=arrDed['54EE']){
		j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54EE must match with deduction in table D');
		addErrorXHTML('','Deduction under 54EE must match with deduction in table D',true);
	}*/
	 if(arr['54D']!=arrDed['54D']){
		 j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54D must match with deduction in table D');
		 addErrorXHTML('','Deduction under 54D must match with deduction in table D',true);
	 }
	 if(arr['54G']!=arrDed['54G']){
		 j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54G must match with deduction in table D');
		 addErrorXHTML('','Deduction under 54G must match with deduction in table D',true);
	 }
	 if(arr['54GA']!=arrDed['54GA']){
		 j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54GA must match with deduction in table D');
		 addErrorXHTML('','Deduction under 54GA must match with deduction in table D',true);
	 }
	 if(arr['54EC']!=arrDed['54EC']){
		 j.setFieldError('scheduleCGPost45.deducClaimInfo.deducClaimDtls[0].deductedSecCode','Deduction under 54EC must match with deduction in table D');
		 addErrorXHTML('','Deduction under 54EC must match with deduction in table D',true);
	 }
	 if(arr){
		 if(arr['54D']>0){
			 document.getElementsByName('scheduleCG54D')[0].value="Y";
		 }
		 else{
			 document.getElementsByName('scheduleCG54D')[0].value="N";

		 }
		 if(arr['54EC']>0){
			 document.getElementsByName('scheduleCG54EC')[0].value="Y";
		 }
		 else{
			 document.getElementsByName('scheduleCG54EC')[0].value="N";

		 }
		 
		 if(arr['54G']>0){
			 document.getElementsByName('scheduleCG54G')[0].value="Y";
		 }
		 else{
			 document.getElementsByName('scheduleCG54G')[0].value="N";

		 }
		 if(arr['54GA']>0){
			 document.getElementsByName('scheduleCG54GA')[0].value="Y";
		 }
		 else{
			 document.getElementsByName('scheduleCG54GA')[0].value="N";

		 }
		 var tab4 = document.getElementById('schduleCGDed54G');
		 var noOfRows4 = tab4.rows.length;

		 for (var i = 0; i < (noOfRows4 -3); i++) {
			 if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].costOfAgLand')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].dateofAcquist')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54D[' + i + '].AmtDeposited')[0].value!=""){
				 document.getElementsByName('scheduleCG54D')[0].value="Y";
			 }
			 if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].costOfAgLand')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].dateofAcquist')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54G[' + i + '].AmtDeposited')[0].value!=""){
				 document.getElementsByName('scheduleCG54G')[0].value="Y";
			 }
			 if(document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].costOfAgLand')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].dateofAcquist')[0].value!=""||document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls54GA[' + i + '].AmtDeposited')[0].value!=""){
				 document.getElementsByName('scheduleCG54GA')[0].value="Y";
			 }
			
		 }
	 }
}

function sumSectionWiseCGTableDNew(tableId, arr,section) {
	var tab = document.getElementById(tableId);
	var input = tab.getElementsByTagName("INPUT");
	for (var i = 0; i < input.length; i++) {
		if ((input[i].name.match('exemptionOrDednUs54S$')) && input[i].value != '') {
			arr[section] = parseInt(arr[section])
			+ parseInt(coalesce(input[i].value ));

		}
	}
	return arr;
}

function sumSectionWiseCGTableD(tableId, arr,section) {
	var tab = document.getElementById(tableId);
	var input = tab.getElementsByTagName("INPUT");
	for (var i = 0; i < input.length; i++) {
		if ((input[i].name.match('AmtClaimed$')) && input[i].value != '') {
			arr[section] = parseInt(arr[section])
			+ parseInt(coalesce(input[i].value ));

		}
	}
	return arr;
}


function sumSectionWise(tableId, arr){
	var tab = document.getElementById(tableId);
	var selects = tab.getElementsByTagName("SELECT");
	for(var i=0;i<selects.length;i++){
		if((selects[i].name.match('section$') || selects[i].name.match('deductedSecCode$')) && selects[i].value!=''){
			var name = selects[i].name;
			var str1 = name.substr(0,name.lastIndexOf('[')+1);
			var amt = document.getElementsByName(str1+i+'].amount')[0];
			/*if(tableId=='schduleCGDed'){
				amt = document.getElementsByName(str1+i+'].amtDed')[0];
			}*/
			arr[selects[i].value] = parseInt(arr[selects[i].value]) + parseInt(coalesce(amt.value));
		}
	}
	return arr;
}


function sumSectionWiseNEW(tableId){
	var table2 = document.getElementById('stcg10pctTab');
	var rowCount2 = table2.rows.length/14;
	var amt =0;
	for(var i=0;i<rowCount2;i++){
		amt = parseInt(amt);
	}
	return amt;
}

/*function validateCGDedDate(){
	var tab = document.getElementById('schduleCGDed');
	var selects  = tab.getElementsByTagName('SELECT');
	for(var i=0; i<selects.length;i++){
		var name = selects[i].name;
		var index = name.substring(name.indexOf("[")+1,name.indexOf("]"));
		var dedDt = document.getElementsByName('scheduleCGPost45.deducClaimInfo.deducClaimDtls['+index+'].dateofAcquist')[0];
		if(dedDt!='' && selects[i].value!=''){
			if(isFirstDateBefore(dedDt.value, Cg_ded_start_date) || isFirstDateBefore(Cg_ded_end_date, dedDt.value)){
	            j.setFieldError(dedDt.name,'Date must be between 01/04/2015 and 31/03/2020');
	            addErrorXHTML(dedDt,'Date must be between 01/04/2015 and 31/03/2020',true);
			}
		}
	}
}*/
/*
function enableScheduleOSOther(){
	var tabl = document.getElementById('schduleOsf');
		var allSelects = tabl.getElementsByTagName('SELECT');
		for(var i = 0; i < allSelects.length; i++) {
				var name = allSelects[i].name;
				var index = name.substring(name.indexOf('[')+1, name.indexOf(']'));
				if(allSelects[i].value=='Others'){
					document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].style.display='';
				} else {
					document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].style.display='none';
					document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls['+ index +'].otherDesc')[0].value='';
				}
		}
}
 */
function CheckHPShareProperty(){
	var totHp=eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent)-1);

	for(var i=0;i<totHp;i++){

		if(document.getElementsByName('scheduleHP.propertyDetails['+i+'].propCoOwnedFlg')[0].value=='YES') {
			var count = i;
			var AssessPerc = document.getElementsByName('scheduleHP.propertyDetails['+i+'].asseseeShareProperty')[0];
			var tab = document.getElementById('scheduleHP'+(++count));

			var sumOfCoOwner = parseFloat('0');

			var rowCount = tab.rows.length;

			for(var k=0;k<rowCount-2;k++) {

				sumOfCoOwner = sumOfCoOwner + (mulFloatBy100(document.getElementsByName('scheduleHP.propertyDetails['+i+'].coOwners['+k+'].percentShareProperty')[0].value));
			}


			if(checkHPShareSum((parseInt(sumOfCoOwner)+mulFloatBy100(AssessPerc.value))/100)){
				addErrorXHTML(AssessPerc,'Sum of Assessee Percentage and Co-owner(s) Percentage should be equal to 100 percent',true);
				j.setFieldError('scheduleHP.propertyDetails['+i+'].asseseeShareProperty','Sum of Assessee Percentage and Co-owner(s) Percentage should be equal to 100 percent');
			}
		}
	}
}

function checkHPShareSum(total) {
	if(total>=99.9 && total<=100) {
		return false;
	}
	return true;
}



function CheckPLExpenses(){

	var grossRec = document.getElementsByName('partapl.noBooksOfAccPL.grossReceipt')[0].value;
	var grosProf = document.getElementsByName('partapl.noBooksOfAccPL.grossProfit')[0].value;
	var expnses = document.getElementsByName('partapl.noBooksOfAccPL.expenses')[0].value;
	if((grossRec+grosProf)<=0 && expnses>0){
		addErrorXHTML(document.getElementsByName('partapl.noBooksOfAccPL.expenses')[0],
				'In order claim Expenses, Either Gross Receipts or Gross Profit must be greater than zero',true);
		j.setFieldError('partapl.noBooksOfAccPL.expenses',
		'In order claim Expenses, Either Gross Receipts or Gross Profit must be greater than zero');
	}

}

function CheckProfExpenses(){
	var grossRec = document.getElementsByName('partapl.noBooksOfAccPL.grossReceiptProf')[0].value;
	var grosProf = document.getElementsByName('partapl.noBooksOfAccPL.grossProfitProf')[0].value;
	var expnses = document.getElementsByName('partapl.noBooksOfAccPL.expensesProf')[0].value;
	if((grossRec+grosProf)<=0 && expnses>0){
		addErrorXHTML(document.getElementsByName('partapl.noBooksOfAccPL.expensesProf')[0],
				'In order claim Expenses, Either Gross Receipts or Gross Profit must be greater than zero',true);
		j.setFieldError('partapl.noBooksOfAccPL.expensesProf',
		'In order claim Expenses, Either Gross Receipts or Gross Profit must be greater than zero');
	}

}

function CheckBFLAUDMismatch(){
	if(coalescePath('scheduleBFLA.totalBFLossSetOff.totUnabsorbedDeprSetoff')
			!= coalescePath('itrScheduleUD.totalamtDepCurYr')){
		addErrorXHTML(document.getElementsByName('itrScheduleUD.totalamtDepCurYr')[0],
				'This figure must match with Total of brought forward loss set off in BFLA',true);
		j.setFieldError('itrScheduleUD.totalamtDepCurYr',
		'This figure must match with Total of brought forward loss set off in BFLA');
	}

	if(coalescePath('scheduleBFLA.totalBFLossSetOff.totAllUs35Cl4Setoff')
			!= coalescePath('itrScheduleUD.amountASACYIncome')){
		addErrorXHTML(document.getElementsByName('itrScheduleUD.amountASACYIncome')[0],
				'This figure must match with Total of brought forward loss set off in BFLA',true);
		j.setFieldError('itrScheduleUD.amountASACYIncome',
		'This figure must match with Total of brought forward loss set off in BFLA');
	}
}

function checkEmptySchUDAmt(){
	var tab1 = document.getElementById('scheduleUD');
	var rowCount = tab1.rows.length;

	for(var i = 0; i < rowCount - 5; i++) {
		var assYr = document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].assYr')[0].value;
		if(assYr != '' && assYr != undefined && assYr !=null){
			var amtBFUD = document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtBFUD')[0];
			var amountBFUA = document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountBFUA')[0];

			var amtDepCurYr = document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amtDepCurYr')[0];
			var amountASACYIncome = document.getElementsByName('itrScheduleUD.scheduleUD['+i+'].amountASACYIncome')[0];

			if(amtBFUD.value == ''&& amountBFUA.value == ''){
				addError(amtBFUD,'Please enter amount of brought forward unabsorbed depreciation or Allowance u/s 35(4)',true);
				j.setFieldError(amtBFUD.name,'Please enter amount of brought forward unabsorbed depreciation or Allowance u/s 35(4)');
			} else {
				if(amtBFUD.value>0 && amtDepCurYr.value==''){
					addError(amtDepCurYr,'Please enter amount of depreciation set-off against the current year income u/s 35(4)',true);
					j.setFieldError(amtDepCurYr.name,'Please enter amount of depreciation set-off against the current year income u/s 35(4)');
				}
				if(amountBFUA.value>0 && amountASACYIncome.value==''){
					addError(amountASACYIncome,'Please enter amount of allowance set-off against the current year income u/s 35(4)',true);
					j.setFieldError(amountASACYIncome.name,'Please enter amount of allowance set-off against the current year income u/s 35(4)');
				}
			}

		}
	}
}

function populateAMTC(){
	try{
		var taxSec115JC=$('[name="scheduleAMTC.taxSection115JC"]')[0];
		var taxProvAct=$('[name="scheduleAMTC.taxOthProvision"]')[0];
		var amtCreditAvail=$('[name="scheduleAMTC.amtTaxCreditAvailable"]')[0];
		var partBttiTotalTax=$('[name="partBTTI.computationOfTaxLiability.taxPayableOnDeemedTI.totalTax"]')[0];
		var partBttiGrossTaxLiability=$('[name="partBTTI.computationOfTaxLiability.grossTaxLiability"]')[0];

		taxSec115JC.value=partBttiTotalTax.value;
		taxProvAct.value=partBttiGrossTaxLiability.value;

		if(eval(parseInt(coalesce(taxProvAct.value),10)) > eval(parseInt(coalesce(taxSec115JC.value),10))){

			amtCreditAvail.value=eval(parseInt(coalesce(taxProvAct.value),10))-eval(parseInt(coalesce(taxSec115JC.value),10));
		}else{
			amtCreditAvail.value=parseInt('0',10);
		}

		var amtCreditFwd=document.getElementsByName('scheduleAMTC.scheduleAMTCUtil.CYamtCreditFwd')[0];
		var taxRelief=document.getElementsByName('partBTTI.computationOfTaxLiability.taxRelief.totTaxRelief')[0];
		var grossTaxLiab=document.getElementsByName('partBTTI.computationOfTaxLiability.grossTaxLiability')[0];
		var taxlaib=parseInt(coalesce(taxRelief.value),10)-parseInt(coalesce(grossTaxLiab.value),10);
		var taxlaibsub=parseInt(coalesce(taxRelief.value),10)-parseInt(coalesce(grossTaxLiab.value),10);
		if(taxlaibsub > parseInt('0',10)){
			amtCreditFwd.value = zeroOrMore((coalesce(taxSec115JC.value)-coalesce(taxProvAct.value))- coalesce(taxlaib));
			if(amtCreditFwd.value < parseInt('0',10)){
				amtCreditFwd.value=parseInt('0',10);
			}
		}
		else{
			amtCreditFwd.value = zeroOrMore(coalesce(taxSec115JC.value)-coalesce(taxProvAct.value));
		}


	}catch(e){
		alert('error in populateAMTC:-' +e);
	}
}

/*function checkSI5BWarning(){

	if(document.getElementsByName('scheduleSI.splCodeRateTax[2].splRateInc')[0].value>0){

		addErrorXHTML('','Please ensure that income u/s 115B forms part of Sch BP',true);
	}
}
 */
/*function checkSIAmount(){
	var taxableInc1 = document.getElementsByName('scheduleSI.splCodeRateTax[1].taxableInc')[0]; taxableInc1.value = coalesce(taxableInc1.value);
	var splRateInc1 = document.getElementsByName('scheduleSI.splCodeRateTax[1].splRateInc')[0]; splRateInc1.value = coalesce(splRateInc1.value);
	if(parseInt(taxableInc1.value,10) > parseInt(splRateInc1.value,10)){
		addError(taxableInc1,'Taxable Income after adjusting cannot be greater than Income shown in Schedule OS',true);
		j.setFieldError(taxableInc1.name,'Taxable Income after adjusting cannot be greater than Income shown in Schedule OS');

	}
}*/

function setSch80HiddenField(tableId,SecDesc){
	var tab = document.getElementById(tableId);
	var inputs = tab.getElementsByTagName('INPUT');

	for(var i=0;i<inputs.length;i++){

		if(inputs[i].name.match('SectionDesc$')){
			inputs[i].value=SecDesc;
		}
	}

}

function makePartAGenRowOneMandate(){
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0];
	var nameOfMem = document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName')[0];
	if( (substatus.value==7 || substatus.value==13)  && (document.getElementsByName('partAGEN2.partnerOrMemberInfo[0].partnerOrMemberName')[0].value == '')){

		addError(nameOfMem,'Please enter the Name',true);
		j.setFieldError(nameOfMem.name,'Please enter the Name');

	}


}

function checkLLIPNForTwoLLP(){

	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0];


	var tab = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var inputs = tab.getElementsByTagName('input');
	var foreignPerc = 0;
	var otherPerc = 0;
	var count = 0;
	var elem;
	if(substatus.value==5){

		for(var i =0; i < inputs.length; i++){
			if(inputs[i].value!='' && inputs[i].name.match('designPartnerIdNumber$')){
				count++;
			}else if(inputs[i].name.match('designPartnerIdNumber$')){
				elem = inputs[i];
			}
		}
		if(count<2){
			addError(elem,'Please enter Designated Partner Identification Number.',true);
			j.setFieldError(elem.name,'Please enter Designated Partner Identification Number.');
		}
	}
}


function makeSurchargeCessEditable(){

	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if( status == '14' ){
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].readOnly = true;
	}else if( substatus == '8'){
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].readOnly = false;
	} else{
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].readOnly = true;
	}

}
function ifscCheckNRIForeignComp(){


	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0];
	var ifscCode = document.getElementsByName('itr.refund.depositToBankAccount.iFSCCode')[0];

	if(resStatus.value=='RES'){
		if(ifscCode.value=='NNNN0NNNNNN'){
			addError(ifscCode,'Mention a valid IFS code',true);
			j.setFieldError(ifscCode.name,'Mention a valid IFS code');

		}

	}
}

//To get Ifsc Bank Details
function getIfscBankDetails(elem) {

	var position = parseInt(elem.name.substring(elem.name.indexOf("[") + 1,	elem.name.indexOf("]")));

	var ifscCode = document.getElementsByName('itr.scheduleBA[' + position + '].ifscCode')[0].value;

	document.getElementsByName('itr.scheduleBA[' + position + '].bankName')[0].value = main.getBankName(ifscCode);

}


function getIfscBankName(field) {

	document.getElementsByName('itr.refund.depositToBankAccount.bankName')[0].value = main.getBankName(field.value);

}

//To enable point FA-E fields
function enableFieldsForPointE(tableId) {

	var tab = document.getElementById(tableId);
	var rows = tab.getElementsByTagName('tr');
	var rowCount = rows.length;

	for ( var i = 0; i < rowCount - 4; i++) {
		var selectedOptionId = document
		.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
				+ i + '].taxableIncomeFlag')[0];
		var selectedOption = selectedOptionId.options[selectedOptionId.selectedIndex].value;

		if (selectedOption == 'Y') {
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].interestInAccount')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].amount')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].scheduleOffered')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].itemNo')[0].disabled = false;

		} else {
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].interestInAccount')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].amount')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].scheduleOffered')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].itemNo')[0].disabled = true;

			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].interestInAccount')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].amount')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].scheduleOffered')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfAccntsHvngSigningAuth['
					+ i + '].itemNo')[0].value = '';

		}
	}
}

//To enable point F fields
function enableFieldsForPointF(tableId) {

	var tab = document.getElementById(tableId);
	var rows = tab.getElementsByTagName('tr');
	var rowCount = rows.length;

	for ( var i = 0; i < rowCount - 4; i++) {
		var selectedOptionId = document
		.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
				+ i + '].trustIncomeFlag')[0];
		var selectedOption = selectedOptionId.options[selectedOptionId.selectedIndex].value;

		if (selectedOption == 'Y') {
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].trustIncome')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].amount')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].scheduleOffered')[0].disabled = false;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].itemNo')[0].disabled = false;

		} else {
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].trustIncome')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].amount')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].scheduleOffered')[0].disabled = true;
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].itemNo')[0].disabled = true;

			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].trustIncome')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].amount')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].scheduleOffered')[0].value = '';
			document
			.getElementsByName('scheduleFA.detailsOfTrustOutIndiaTrustee['
					+ i + '].itemNo')[0].value = '';

		}
	}
}

///To enable point G fields
function enableFieldsForPointG(tableId) {

	var tab = document.getElementById(tableId);
	var rows = tab.getElementsByTagName('tr');
	var rowCount = rows.length;

	for ( var i = 0; i < rowCount - 4; i++) {
		var selectedOptionId = document
		.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
				+ '].trustIncomeFlag')[0];
		var selectedOption = selectedOptionId.options[selectedOptionId.selectedIndex].value;

		if (selectedOption == 'Y') {
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].amount')[0].disabled = false;
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].scheduleOffered')[0].disabled = false;
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].itemNo')[0].disabled = false;

		} else {

			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].amount')[0].disabled = true;
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].scheduleOffered')[0].disabled = true;
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].itemNo')[0].disabled = true;

			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].amount')[0].value = '';
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].scheduleOffered')[0].value = '';
			document.getElementsByName('scheduleFA.detailsOfOtherIncome[' + i
					+ '].itemNo')[0].value = '';
		}
	}
}

//on change of part BTTI refund
function onChngBTTIRefund() {
	var typeHP = document.getElementsByName('partBTTI.assetOutIndiaFlag')[0].value;
	if (typeHP == 'YES') {
		addErrorXHTML('',
		'Schedule FA is mandatory. Ensure all the details in Schedule FA are filled');
	}
}


//To set other gross
function setOtherGrossSource() {
	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var statusOrCompanyType = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

	var tab = document.getElementById('schduleOsinc');
	var rowCount = tab.rows.length -3;

	var allSectionArray = [ '5A1ai', '5A1aii', '5A1aiia', '5A1aiiaa',
	                        '5A1aiiab', '5A1aiiac', '5A1aiii', '5A1bA',  '5AC1ab',
	                        '5ACA1a', '5AD1i', '5AD1iP', '5BBA','5BBDA', '5BBC', '5BBF', '5BBG', '5AB1a','5Ea'
	                        ];

	if (status == 'RES' ){
		addAllOptions(allSectionArray, rowCount);
		var sectionArray = ['5A1ai', '5A1aii', '5A1aiia', '5A1aiiaa','5BBA','5AB1a','5BBA',
		                    '5A1aiiab', '5A1aiiac', '5A1aiii', '5A1bA',  '5AC1ab','5Ea' ];
		removeSectionOSe(sectionArray, rowCount);

	} else if (status == 'NRI') {
		addAllOptions(allSectionArray, rowCount);
		var sectionArray = ['5ACA1a','5BBDA', '5BBF'];
		removeSectionOSe(sectionArray, rowCount);
	}


	var tab1 = document.getElementById('schduleOsincPti');
	var rowCount1 = tab1.rows.length - 3;

	var allSectionArray1 = [ 'PTI_5A1ai', 'PTI_5A1aii', 'PTI_5A1aiia', 'PTI_5A1aiiaa','PTI_5AB1a',
	                         'PTI_5A1aiiab', 'PTI_5A1aiiac', 'PTI_5A1aiii', 'PTI_5A1bA',  'PTI_5AC1ab',
	                         'PTI_5ACA1a', 'PTI_5AD1i', 'PTI_5AD1iP','PTI_5BBA', 'PTI_5BBC', 'PTI_5BBDA', 'PTI_5BBF',
	                         'PTI_5BBG', 'PTI_5Ea' ];



	if (status == 'RES') {
		addAllOptionsPTI(allSectionArray1, rowCount1);
		var sectionArray1 = [ 'PTI_5A1ai', 'PTI_5A1aii', 'PTI_5A1aiia', 'PTI_5A1aiiaa',
		                      'PTI_5A1aiiab', 'PTI_5A1aiiac', 'PTI_5A1aiii', 'PTI_5A1bA', 'PTI_5AC1ab',
		                      'PTI_5BBA','PTI_5Ea' ];
		removeSectionPTI(sectionArray1, rowCount1);

	} else if (status == 'NRI') {
		addAllOptionsPTI(allSectionArray1, rowCount1);
		var sectionArray1 = ['PTI_5ACA1a','PTI_5BBDA', 'PTI_5BBF' ];
		removeSectionPTI(sectionArray1, rowCount1);
	}


}

//To set other sections newly added

//To set other gross
function setOtherGrossSourceOnChange() {
	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	var tab = document.getElementById('schduleOsinc');
	var rowCount = tab.rows.length -3;

	var allSectionArray = [ '5A1ai', '5A1aii', '5A1aiia', '5A1aiiaa',
	                        '5A1aiiab', '5A1aiiac', '5A1aiii', '5A1bA',  '5AC1ab',
	                        '5AD1i', '5AD1iP', '5BBA','5BBDA', '5BBC', '5BBF','5ACA1a', '5BBG', '5AB1a','5Ea'];

	if (status == 'RES') {
		addAllOptions(allSectionArray, rowCount);
		var sectionArray = [ '5A1ai', '5A1aii', '5A1aiia', '5A1aiiaa',
		                     '5A1aiiab', '5A1aiiac', '5A1aiii', '5A1bA',  '5AC1ab',
		                     '5BBA','5AB1a','5Ea'];
		removeSectionOSe(sectionArray, rowCount);

	} else if (status == 'NRI') {
		addAllOptions(allSectionArray, rowCount);
		var sectionArray = ['5ACA1a','5BBDA','5BBF'];
		removeSectionOSe(sectionArray, rowCount);

	}

	var tab1 = document.getElementById('schduleOsincPti');
	var rowCount1 = tab1.rows.length - 3;

	var allSectionArray1 = [ 'PTI_5A1ai', 'PTI_5A1aii', 'PTI_5A1aiia', 'PTI_5A1aiiaa','PTI_5AB1a',
	                         'PTI_5A1aiiab', 'PTI_5A1aiiac', 'PTI_5A1aiii', 'PTI_5A1bA',  'PTI_5AC1ab',
	                         'PTI_5AD1i', 'PTI_5AD1iP', 'PTI_5BBA', 'PTI_5BBC', 'PTI_5BBDA', 'PTI_5BBF',
	                         'PTI_5ACA1a','PTI_5BBG', 'PTI_5Ea' ];
	if (status == 'RES' ) {
		addAllOptionsPTI(allSectionArray1, rowCount1);
		var sectionArray1 = [ 'PTI_5A1ai', 'PTI_5A1aii', 'PTI_5A1aiia', 'PTI_5A1aiiaa',
		                      'PTI_5A1aiiab', 'PTI_5A1aiiac', 'PTI_5A1aiii', 'PTI_5A1bA',  'PTI_5AC1ab',
		                      'PTI_5BBA','PTI_5Ea','PTI_5AB1a'];
		removeSectionPTI(sectionArray1, rowCount1);
	} else if (status == 'NRI') {
		addAllOptionsPTI(allSectionArray1, rowCount1);
		var sectionArray1 = ['PTI_5ACA1a','PTI_5BBDA', 'PTI_5BBF' ];
		removeSectionPTI(sectionArray1, rowCount1);
	}



}

function setOtherGrossSourceOnChangeDTAA() {
	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;


	var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowCount = tab.rows.length - 2;

	var allSectionArray = [ '56i', '56','562iii','562x', '5A1ai', '5A1aii', '5A1aiia','5AB1a','5AC1ab',
	                        '5A1aiiaa', '5A1aiiab', '5A1aiiac', '5A1aiii', '5A1bA',
	                        '5AD1i', '5AD1iP', '5BBA','5Ea', '5BBG', '5BBDA',
	                        '5BBF', '5BBC', '5ACA1a', '5BB','PTI_5ACA1a','PTI_5A1ai','PTI_5A1aii','PTI_5AB1a','PTI_5A1aiia','PTI_5A1aiiaa','PTI_5A1aiiab','PTI_5A1aiiac','PTI_5A1aiii','PTI_5A1bA','PTI_5AC1ab','PTI_5AD1i','PTI_5AD1iP','PTI_5BBA','PTI_5Ea','PTI_5BBDA','PTI_5BBF','PTI_5BBC','PTI_5BBG'];

	if ((status == 'RES')) {
		addAllOptionsDTAA(allSectionArray, rowCount);
		var sectionArray = [ '5A1ai', '5A1aii', '5A1aiia', '5A1aiiaa',
		                     '5A1aiiac', '5A1aiiab', '5A1aiii', '5A1bA', 
		                     '5BBA','5Ea','5AB1a','5AC1ab','PTI_5A1ai', 'PTI_5A1aii', 'PTI_5A1aiia', 'PTI_5A1aiiaa','PTI_5A1aiiac', 'PTI_5A1aiiab', 'PTI_5A1aiii', 'PTI_5A1bA',  'PTI_5AC1ab','PTI_5Ea','PTI_5BBA','PTI_5AB1a'];
		removeSectionOnChangeDTAA(sectionArray, rowCount);

	} else if (status == 'NRI') {
		addAllOptionsDTAA(allSectionArray, rowCount);
		var sectionArray = [ '5BBDA', '5BBF', '5ACA1a','PTI_5BBDA', 'PTI_5BBF','PTI_5ACA1a' ];
		removeSectionOnChangeDTAA(sectionArray, rowCount);
	}


}

function removeSectionOnChangeDTAA(sectionArray, rowCount) {

	try {
		for (var i = 0; i < rowCount ; i++) {

			var selectsLength = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].options.length - 1 ;

			for (var k = selectsLength; k > 0; k--) {
				if (document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].options[k] != null
						&& sectionArray.indexOf(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].options[k].value) != -1) {

					console.log("true : "+document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].options[k].value);document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].remove(k);

				}
			}
		}
		//calcITR5();

	} catch (e) {
		alert('exception in removeSection' + e.stack);
	}
}

function setOtherGrossSourceOnChangeCGSTCG() {
	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	var tab = document.getElementById('scheduleStcgDtaa');
	var rowCount = tab.rows.length - 2;

	var allSectionArray = [ 'A1e','A2c' ,'A3e_111A', 'A3e_115AD', 'A4a', 'A4b',
	                        'A5e', 'A6g', 'A7','A8a','A8b','A8c'];

	if (status == 'RES') {
		addAllOptionsCGSTCG(allSectionArray, rowCount);
		var sectionArray = [ 'A4a', 'A4b', 'A5e'];
		removeSectionOnChangeCGSTCG(sectionArray, rowCount);
	}  else {
		addAllOptionsCGSTCG(allSectionArray, rowCount);
	}

}


function addAllOptionsCGSTCG(allSectionArray, rowCount) {
	for (var i = 0; i < rowCount; i++) {
		var srcDesc = document
		.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
				+ i + '].itemIncluded')[0];
		var selectedValue = srcDesc.value;
		removeAll(srcDesc);
		for (var k = 0; k < allSectionArray.length; k++) {
			var optn = document.createElement("option");
			optn.text = getSectionTextMap(allSectionArray[k]);
			optn.value = allSectionArray[k];
			srcDesc.options.add(optn);
		}
		srcDesc.value = selectedValue;
	}
}



function removeSectionOnChangeCGSTCG(sectionArray, rowCount) {
	try {
		for (var i = 0; i < rowCount; i++) {
			var selectsLength = document
			.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
					+ i + '].itemIncluded')[0].options.length - 1;
			for (var k = selectsLength; k > 0; k--) {
				if (document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].itemIncluded')[0].options[k] != null
								&& sectionArray
								.indexOf(document
										.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
												+ i + '].itemIncluded')[0].options[k].value) != -1) {

					document
					.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
							+ i + '].itemIncluded')[0].remove(k);

				}
			}
		}
		calcITR5();

	} catch (e) {
		alert('exception in removeSectionOnChangeCGSTCG' + e.stack);
	}
}


function setOtherGrossSourceOnChangeCGLTCG() {
	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var tab = document.getElementById('scheduleLtcgDtaa');

	var rowCount = tab.rows.length - 2;

	var allSectionArray = [ 'B1e', 'B2e', 'B3c', 'B4c' ,'B5','B6', 'B7c112(1)(c)','B7c115AB1b','B7c115AC','B7c115AD','B8','B9e','B10','B11a1','B11a2','B11b'];

	if (status == 'RES') {
		addAllOptionsCGLTCG(allSectionArray, rowCount);

		var sectionArray = [ 'B6','B7c112(1)(c)', 'B7c115AB1b', 'B7c115AC', 'B7c115AD','B8'];
		removeSectionOnChangeCGLTCG(sectionArray, rowCount);
	}  else {
		addAllOptionsCGLTCG(allSectionArray, rowCount);
	}

}

function addAllOptionsCGLTCG(allSectionArray, rowCount) {
	for (var i = 0; i < rowCount; i++) {
		var srcDesc = document
		.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
				+ i + '].itemIncluded')[0];
		var selectedValue = srcDesc.value;
		removeAll(srcDesc);
		for (var k = 0; k < allSectionArray.length; k++) {
			var optn = document.createElement("option");
			optn.text = getSectionTextMap(allSectionArray[k]);
			optn.value = allSectionArray[k];
			srcDesc.options.add(optn);
		}
		srcDesc.value = selectedValue;
	}
}





function removeSectionOnChangeCGLTCG(sectionArray, rowCount) {
	try {
		for (var i = 0; i < rowCount; i++) {
			var selectsLength = document
			.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
					+ i + '].itemIncluded')[0].options.length - 1;
			for (var k = selectsLength; k > 0; k--) {
				if (document
						.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
								+ i + '].itemIncluded')[0].options[k] != null
								&& sectionArray
								.indexOf(document
										.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
												+ i + '].itemIncluded')[0].options[k].value) != -1) {

					document
					.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
							+ i + '].itemIncluded')[0].remove(k);

				}
			}
		}
		//calcITR5();

	} catch (e) {
		alert('exception in removeSection' + e.stack);
	}
}
function addAllOptionsDTAA(allSectionArray, rowCount) {
	for (var i=0; i<rowCount;  i++) {
		var srcDesc = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0];
		var selectedValue = srcDesc.value;
		removeAll(srcDesc);
		for(var k=0; k<allSectionArray.length; k++) {
			var optn = document.createElement("option");
			optn.text = getSectionTextMap(allSectionArray[k]);
			optn.value = allSectionArray[k];
			srcDesc.options.add(optn);
		}
		srcDesc.value = selectedValue;
	}
}
//To add all options
function addAllOptions(allSectionArray, rowCount) {
	for (var i = 0; i < rowCount; i++) {
		var srcDesc = document
		.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
				+ i + '].sourceDescription')[0];
		var selectedValue = srcDesc.value;
		removeAll(srcDesc);

		for (var k = 0; k < allSectionArray.length; k++) {
			var optn = document.createElement("option");
			optn.text = getSectionTextMap(allSectionArray[k]);
			optn.value = allSectionArray[k];
			srcDesc.options.add(optn);
		}
		srcDesc.value = selectedValue;
	}
}
//To remove section
function removeSection(sectionArray, rowCount) {
	try {
		for (var i = 1; i < rowCount; i++) {
			var selectsLength = document
			.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
					+ i + '].sourceDescription')[0].options.length;
			for (var k = selectsLength; k > 0; k--) {
				if (document
						.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
								+ i + '].sourceDescription')[0].options[k] != null
								&& sectionArray
								.indexOf(document
										.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
												+ i + '].sourceDescription')[0].options[k].value) != -1) {
					document
					.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
							+ i + '].sourceDescription')[0].remove(k);
				}
			}
		}
	} catch (e) {
		alert(e.stack);
	}
}
//To remove Sections on change of status newly added
function removeSectionOSe(sectionArray, rowCount) {
	try {
		for (var i = 0; i < rowCount; i++) {
			var selectsLength = document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
					+ i + '].sourceDescription')[0].options.length;
			for (var k = selectsLength; k > 0; k--) {
				if (document
						.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
								+ i + '].sourceDescription')[0].options[k] != null
								&& sectionArray
								.indexOf(document
										.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
												+ i + '].sourceDescription')[0].options[k].value) != -1) {
					document
					.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['
							+ i + '].sourceDescription')[0].remove(k);
				}
			}
		}
	} catch (e) {
		alert(e.stack);
	}
}

function removeSectionOnChange(sectionArray, rowCount) {
	try {
alert("kkkkll");
		for (var i = 0; i < rowCount; i++) {
			var selectsLength = document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceDescription')[0].options.length;
			
			alert("pppp");
			for (var k = selectsLength; k > 0; k--) {
				if (document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceDescription')[0].options[k] != null
						&& sectionArray.indexOf(document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceDescription')[0].options[k].value) != -1) {
alert("mm");
					var NRI_value= document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceDescription')[0].value ;

					if (NRI_value=='5BBF' || NRI_value=='5BBDA'|| NRI_value == '5ACA1a')
					{
						document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceAmount')[0].value=0;
					}
					document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+ i + '].sourceDescription')[0].remove(k);

				}
			}
		}
		calcITR5();

	} catch (e) {
		alert('exception in removeSectionOnChange ' + e.stack);
	}
}


//To delete all options
function removeAll(selectbox) {

	for ( var i = selectbox.options.length - 1; i > 0; i--) {
		selectbox.removeChild(selectbox[i]);

	}
}

//To enable tables for NRI
function enableTableForNRI(element, value, tableId) {

	var flag = document.getElementsByName(element)[0].value;
	var tabId = "#" + tableId;

	$(tabId).find(':input').prop('disabled', true);
	$(tabId).find('.addbtn').prop('hidden', true);

	if (flag == value) {
		$(tabId).find('.addbtn').prop('hidden', false);
		$(tabId).find(':input').prop('disabled', false);
	} else {
		$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		deleteRowTable(tableId, 1, 1);
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find('.addbtn').prop('hidden', true);
	}
}

//To check dropdown
function checkDropdownSelectedin1d() {
	var table = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowCount = table.rows.length - 2;
	var itemIncluded = [];

	var tabl = document.getElementById('schduleOsinc');
	var rowCountTab1 = tabl.rows.length - 3;
	var tab2 = document.getElementById('schduleOsincPti');
	var rowCountTab2 = tab2.rows.length - 3;

	var sourceDescriptionMap = [];

	for(var i=0; i<rowCount; i++) {
		var section = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].itemIncluded')[0];
		if (section.value != '' && section.value != '56i' && section.value != '5BB' &&  section.value != '562iii' &&  section.value != '562x' && section.value != '56'
			&& itemIncluded.indexOf(section.value) == -1) {
			itemIncluded.push(section.value);
		}
	}

	for(var i=0; i<rowCountTab1; i++) {

		var sourceDescription = document.getElementsByName('scheduleOS.incomeChargableUnderSpc.othersGrossDtls['+i+'].sourceDescription')[0];

		if(sourceDescription.value != '') {
			sourceDescriptionMap.push(sourceDescription.value);
		}
	}
	for (var i = 0; i < rowCountTab2; i++) {
		var sourceDescription = document
		.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
				+ i + '].sourceDescription')[0];

		if (sourceDescription.value != '') {
			sourceDescriptionMap.push(sourceDescription.value);
		}

	}

	var index = 0;

	for(var i=0; i<itemIncluded.length; i++) {
		if (document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncluded')[0].value != '1'){

			if(sourceDescriptionMap.indexOf(itemIncluded[i]) == -1) {
				for(var k=0; k<rowCount; k++) {
					var section = document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+k+'].itemIncluded')[0];

					if(section.value != '' && section.value == itemIncluded[i] ) {

						index = k;
					}
				}
				addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+index+'].itemIncluded')[0]  ,'Please select this section in table 2d.',true);
				j.setFieldError('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+index+'].itemIncluded','Please select this section in table 2d.');
			}
		}
	}
}

//Validate Pure Schedule SI Tax.
function calculatePureSITax(){

	var rowCount1=countRowInTable('scheduleSI.splCodeRateTax','splRateInc');
	var sum = 0;
	var sumWithDtaa = 0;
	for(var i = 0; i < rowCount1; i++) {

		var section = document.getElementsByName('scheduleSI.splCodeRateTax[' + i +'].secCode')[0].value;

		if(section=='1A'||section=='21'||section=='22'||section=='2A'||section=='21ciii'||section=='5AC1c'||section=='5ACA1b'||section=='5ADii'||section=='5ADiii'||section=='5AD1biip'||section=='5Eb'||section=='5AB1b'||section=='5BBF_BP'||section=='5BBG_BP'||section=='PTI_LTCG20P'||section=='PTI_LTCG10P'|| section == 'PTI_LTCG10P112A'||section=='PTI_STCG15P'||section=='PTI_STCG30P'||section=='5ADiiiP'){
			sum = parseInt(sum) + parseInt(document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRateIncTax')[0].value);
		}

	}
	sumWithDtaa = sum;
	return parseInt(sumWithDtaa);

}

//Calculate Virtual Tax Payable on PartB-TI.
function calcVirtualTaxPayableOnTI(){
	try{
		var totInc = document.getElementsByName('partBTI.aggregateIncome')[0];
		var presInc44AD = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0];
		presInc44AD.value = coalesce(parseInt(presInc44AD.value,10));

		var resStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

		var virtualTotInc=parseInt('0',10);;
		if(resStatus=='RES' || resStatus=='NOR'){
			//virtualTotInc = eval(parseInt(totInc.value,10) - parseInt( presInc44AD.value ,10));
			virtualTotInc = eval(parseInt(totInc.value,10));//17-18
		}else{
			virtualTotInc = parseInt(totInc.value,10);
		}

		var virtualTaxPayable;

		var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

		if((taxPayer=='1') && (resStatus == 'RES' )){

			var temp = (eval(virtualTotInc)) * eval('0.30');

			virtualTaxPayable = Math.round(eval(temp));
		}

		surcharge = coalesce(parseInt(surcharge));

		virtualTaxPayable= parseInt(virtualTaxPayable) - parseInt(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].value) + parseInt(document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].value);

		var virtualEduCess= Math.round(eval(parseInt(virtualTaxPayable,10) + parseInt(surcharge))* eval('0.04'));
		var virtualTotalTaxWithEduCess = eval(parseInt(virtualTaxPayable)) + parseInt(surcharge) + eval(parseInt(virtualEduCess));

		var sec9091 = document.getElementsByName('partBTTI.computationOfTaxLiability.taxRelief.totTaxRelief')[0]; sec9091.value = coalesce(sec9091.value);
		var virtualBalTaxPayable = Math.round(eval(parseInt(virtualTotalTaxWithEduCess ,10)-parseInt(sec9091.value ,10)));


		if(virtualBalTaxPayable < eval('0')) {
			virtualBalTaxPayable = '0';
		}

		return parseInt(virtualBalTaxPayable);
	}catch(e){
		alert('Exception in calcVirtualTaxPayableOnTI = ' + e.stack);
	}
}

//Check if Marginal Relief Applicable.
function isMarginalRelfApplcblCheck(){
	var surcharge = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge')[0];
	var taxPybl = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxPayableOnTotInc')[0];
	if(parseInt(surcharge.value) > 0){
		if(parseInt(surcharge.value ) != parseInt(taxPybl.value* 0.15)){
			return true;
		}
	}
	return false;
}

function percentageShareMan(){
	var prevYrMemPartChange = document.getElementsByName('partAGEN2.prevYrMemPartChange')[0].value;
	var statusOrCompanyType = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatusOrCompanyType = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	var tabl = document.getElementById('partnerTableId');
	var rowCountTab1 = tabl.rows.length - 2;

	for ( var i = 0; i < rowCountTab1; i++) {
		var sharePercentage = document.getElementsByName('partAGEN2.prevYrMemPart.prevYrMemPartDtls['+ i + '].sharePercentage')[0].value;
		if((prevYrMemPartChange =='Y') && (statusOrCompanyType == '1'|| substatusOrCompanyType == '5') && (sharePercentage == '') ){
			j.setFieldError('partAGEN2.prevYrMemPart.prevYrMemPartDtls['+ i + '].sharePercentage','Please enter Percentage of share');
			addErrorXHTML(document.getElementsByName('partAGEN2.prevYrMemPart.prevYrMemPartDtls['+ i + '].sharePercentage')[0],'Please enter Percentage of share',true);

		}
	}


}

//To enable/disable tables based on the value
function enableTable(element, value, tableId){

	var flag =document.getElementsByName(element)[0].value;
	var tabId = "#"+tableId;

	$(tabId).find(':input').prop('disabled', true);
	$(tabId).find('.addbtn').prop('hidden', true);

	if(flag==value){
		$(tabId).find('.addbtn').prop('hidden', false);
		$(tabId).find(':input').prop('disabled', false);
	}else{
		$(tabId).find('[type=\"checkbox\"]').attr('checked','checked');
		if(tableId == 'partnerTableId') {
			deleteRowTable(tableId,1,1);
		}
		else {
			deleteRowTable(tableId,2,1);
		}
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find('.addbtn').prop('hidden', true);
	}
}

function enableTableWithOutCB(element, value, tableId){
	var flag =document.getElementsByName(element)[0].value;
	var tabId = "#"+tableId;
	if(flag == value){

		$(tabId).find(':input').prop('disabled', false);
		$(tabId).find('.addbtn').prop('hidden', false);
	}else{
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find('.addbtn').prop('hidden', true);
		$(tabId).find(':input').prop('value', '');
		if(tableId == 'stcg10pctTab') {
			deleteRowToCG('stcg10pctTab');
		}
	}
	calCGA7TotalSum();
	calCGPointB8Total();
}

/*function enable80GGAtables(){

	var tdsTable = document.getElementById('schedule80GGA');
	var noOfRows = tdsTable.rows.length;

	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

	for (var i = 0; i < (noOfRows - 4); i++) {

		if (status == '2' || status == '9') {

			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].revelantCause')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].revelantCause')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].nameOfDonee')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].nameOfDonee')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].address')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].address')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].city')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].city')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].state')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].state')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].pinCode')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].pinCode')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].panOfDonee')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].panOfDonee')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInCash')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInCash')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInOtherMode')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInOtherMode')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].totalDonation')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].totalDonation')[0].value = "";
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].eligibleAmount')[0].disabled = true;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].eligibleAmount')[0].value = "";
		}
		else {

			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].revelantCause')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].nameOfDonee')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].address')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].city')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].state')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].pinCode')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].panOfDonee')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInCash')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].donationInOtherMode')[0].disabled = false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].totalDonation')[0].disabled= false;
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].eligibleAmount')[0].disabled = false;

		}
	}
}*/




/*function enableNRItables(){
	 enableTableForNRI('partAGEN1.filingStatus.residentialStatus','NRI','scheduleStcgDtaa');
	 enableTableForNRI('partAGEN1.filingStatus.residentialStatus','NRI','scheduleLtcgDtaa');
	 enableTableForNRI('partAGEN1.filingStatus.residentialStatus','NRI','scheduleOsNriIncTaxDtaa');
	 enableTableWithOutCB('partAGEN1.filingStatus.residentialStatus','NRI','stcg10pctTab');
}
 */



//To calculate total Renumeration Paid/ Payable and poulate to 38 of PL
function calculateRemurationPaid(){
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var pl64iiiVal = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm')[0].value;
	var salRemuneration = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.salRemuneration')[0];
	var sum = parseInt('0' ,10);
	var amt =  parseInt('0' ,10);

	var tab1 = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var allInputTags = tab1.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("remunerationPaid$")) {
			sum = eval(parseInt(sum ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}

	var compareAmt = eval(parseInt(sum ,10) + coalesceSetRet('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm'));

	if(salRemuneration.value > compareAmt)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.salRemuneration',"Remuneration cannot exceed amount entered in Col 9 of point E of part A general.");
		addErrorXHTML(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.salRemuneration')[0],"Remuneration cannot exceed amount entered in Col 9 of point E of part A general.",true);
	}
}

function calculateRemurationPaid46(){
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var pl46Val = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.salRemuneration')[0].value;
	var salRemuneration1 = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm')[0].value;
	var sum = 0;



	var tab1 = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var noOfRows=tab1.rows.length;
	var amt = 0;
	for ( var i = 0; i < (noOfRows-4); i++) {
		amt = parseInt(amt) + parseInt(document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].remunerationPaid')[0].value);
	}
	sum = eval(parseInt(pl46Val,10) + parseInt(salRemuneration1,10));
	if(sum > amt)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm','Remuneration cannot exceed amount entered in Col 9 of point E of part A general.');
		addErrorXHTML(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.renumfirm')[0],'Remuneration cannot exceed amount entered in Col 9 of point E of part A general.',true);

	}

}

function disablepartbTI23FC() {
	var fiiFpiFlag = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.bussinessTrust')[0].value;
	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if (fiiFpiFlag == 'Y' && statusCompany == '14' && substatusCompany == '20') {
		document.getElementsByName("partBTI.invstUnder23FCor23FCA")[0].readOnly=false;
	} else {
		document.getElementsByName("partBTI.invstUnder23FCor23FCA")[0].readOnly=true;
		document.getElementsByName("partBTI.invstUnder23FCor23FCA")[0].value="";
		calculatePartBTI23FBC();
	}

}

function disablepartbTI23FB() {
	var fiiFpiFlag = document.getElementsByName("partAGEN1.filingStatus.returnFileSec.invstFund")[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	if (fiiFpiFlag == 'Y' && substatus==21) {
		document.getElementsByName("partBTI.invstUnder23FBor23FBA")[0].readOnly=false;
	} else {
		document.getElementsByName("partBTI.invstUnder23FBor23FBA")[0].readOnly=true;
		document.getElementsByName("partBTI.invstUnder23FBor23FBA")[0].value="";
		calculatePartBTI23FBC();
	}

}
function disableSebiRegNo() {
	var fiiFpiFlag = document.getElementsByName("partAGEN1.filingStatus.fiiFpiFlg")[0].value;

	if (fiiFpiFlag == 'Y') {
		document.getElementsByName("partAGEN1.filingStatus.sebiRegnNo")[0].disabled = false;
	} else {
		document.getElementsByName("partAGEN1.filingStatus.sebiRegnNo")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.sebiRegnNo")[0].value="";
	}

}
//Calculate a6 Total Sum.
function calCGA7TotalSum() {

	var tab1 = document.getElementById('scheduleStcgunUtilizedCapGain54');
	var noOfRows = tab1.rows.length;


	var sum = 0;
	for (var i = 0; i < (noOfRows - 3); i++) {
		var amt = document
		.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['
				+ i + '].amountUnUtilized')[0].value;
		sum = eval(parseInt(sum, 10) + parseInt(coalesce(amt), 10));
	}
	var total = eval(parseInt(sum, 10)
			+ parseInt(
					coalesce(document
							.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.amtDeemedStcg')[0].value),
							10));
	document
	.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.totAmtStcgUnderDtaa')[0].value = total;
}

//Calculate Point B8 Total.
function calCGPointB8Total() {

	var tab1 = document.getElementById('scheduleLtcgunUtilizedCapGain54');
	var noOfRows=tab1.rows.length;
	var sum = 0;
	for ( var i = 0; i < (noOfRows-3); i++) {
		var amt = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['+i+'].amountUnUtilized')[0].value;
		sum = eval(parseInt(sum,10) + parseInt(coalesce(amt),10));
	}
	var total = eval(parseInt(sum,10)
			+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54.amtDeemedLtcg')[0].value),10));
	document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')[0].value = total;
}

function populateRateOS()

{
	var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 2); i++) {

		var rateAsPerTreaty = parseFloat(document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].rateOfTax')[0].value);

		var rateAsPerITAct = parseFloat(document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].rateAsPerITAct')[0].value);

		if (rateAsPerTreaty > rateAsPerITAct) {
			document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ i + '].applicableRate')[0].value = rateAsPerITAct;
		}

		if (rateAsPerITAct > rateAsPerTreaty) {
			document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ i + '].applicableRate')[0].value = rateAsPerTreaty;
		}
		if (rateAsPerTreaty == rateAsPerITAct) {
			document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ i + '].applicableRate')[0].value = rateAsPerTreaty;
		}

	}

}


function populateRateSTCG()

{
	var tab = document.getElementById('scheduleStcgDtaa');
	var noOfRows = tab.rows.length;
	var residentialSatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	for (var i = 0; i < (noOfRows - 2); i++) {

		var rateAsPerTreaty = parseFloat(coalesce(document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].rateOfTreaty')[0].value));

		var rateAsPerITAct = parseFloat(coalesce(document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].rateAsPerItAct')[0].value));

		var trcFlag=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+i+'].taxResidCertFlag')[0].value;

		if(residentialSatus!='NRI')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].amntOfIncome')[0].value = document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].rateAsPerItAct')[0].value;

			} else {

				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].amntOfIncome')[0].value = document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].rateOfTreaty')[0].value;
			}
		}
		else if(residentialSatus=='NRI' && trcFlag=='Y')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].amntOfIncome')[0].value = document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].rateAsPerItAct')[0].value;

			} else {

				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
						+ i + '].amntOfIncome')[0].value = document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].rateOfTreaty')[0].value;
			}
		}
		else
		{
			document
			.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
					+ i + '].amntOfIncome')[0].value=''
		}
	}

}



function populateRateLTCG()

{
	var tab = document.getElementById('scheduleLtcgDtaa');
	var noOfRows = tab.rows.length;
	var residentialSatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	for (var i = 0; i < (noOfRows - 2); i++) {
		var rateAsPerTreaty = parseFloat(coalesce(document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].rateAsPerTreaty')[0].value));
		var rateAsPerITAct = parseFloat(coalesce(document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].rateAsPerItAct')[0].value));
		var trcFlag=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+i+'].taxResidCertFlag')[0].value;
		if(residentialSatus!='NRI')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].applicableRate')[0].value = document
						.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
								+ i + '].rateAsPerItAct')[0].value;
			} else {

				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].applicableRate')[0].value = document
						.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
								+ i + '].rateAsPerTreaty')[0].value;
			}
		}
		else if(residentialSatus=='NRI' && trcFlag=='Y')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].applicableRate')[0].value = document
						.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
								+ i + '].rateAsPerItAct')[0].value;
			} else {

				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
						+ i + '].applicableRate')[0].value = document
						.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
								+ i + '].rateAsPerTreaty')[0].value;
			}
		}
		else
		{
			document
			.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
					+ i + '].applicableRate')[0].value=''
		}
	}

}




function validateDTAAStcg(){

	var tab = document.getElementById('scheduleStcgDtaa');
	var rowCount = tab.rows.length - 2;

	var sum = 0;

	var totalStcg = eval(coalesceSetRet('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')
			+ coalesceSetRet('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.AmtStcgUnderDtaa8b'));
	var residentialStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var taxResidCertFlag = true;
	for (var i = 0; i < rowCount; i++) {
		sum = sum +parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
				+ i + '].amount')[0].value),10);
		/*+ document
						.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
								+ i + '].amount')[0].value;*/

		parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['
				+ i + '].amount')[0].value),10);
		if(residentialStatus == 'NRI' && document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].taxResidCertFlag')[0].value=='N' && taxResidCertFlag==true)
		{
			taxResidCertFlag = false;
		}
	}
	if(residentialStatus == 'NRI' && taxResidCertFlag && totalStcg != sum)
	{

		j.setFieldError('',
				'The amount of a+b should be equal to amount in STCG DTAA table');
		addErrorXHTML('',
				'The amount of a+b should be equal to amount in STCG DTAA table', true);

	
	}
	else
	{
		if (residentialStatus != 'NRI' && totalStcg != sum)
		{
			j.setFieldError('',
					'The amount of a+b should be equal to amount in STCG DTAA table');
			addErrorXHTML('',
					'The amount of a+b should be equal to amount in STCG DTAA table', true);

		}
	}
}



function validateDTAALtcg(){
	var tab = document.getElementById('scheduleLtcgDtaa');
	var rowCount = tab.rows.length - 2;

	var sum = 0;

	var totalStcg = eval(coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.totAmtLtcgUnderDtaa')
			+ coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.AmtLtcgUnderDtaa10b'));

	for (var i = 0; i < rowCount; i++) {
		sum = sum +parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['
				+ i + '].amount')[0].value),10);


	}

	if (totalStcg != sum)

	{
		j.setFieldError('',
		'The amount of B12a +B12b should be equal to amount in LTCG DTAA table');
		addErrorXHTML('',
				'The amount of B12a +B12b should be equal to amount in LTCG DTAA table', true);

	}
}

//Validate STCG Section Wise along with DTAA.
function validateSTCGSectionWiseDTAA() {
	var arr = {'A1e':0,'A2c':0,'A3e_111A':0,'A3e_115AD':0,'A4a':0,'A4b':0,'A5e':0,'A6g':0,'A7':0,'A8a':0,'A8b':0,'A8c':0};
	var tab = document.getElementById('scheduleStcgDtaa');
	var rowCount = tab.rows.length -2;
	for(var i=0; i<rowCount; i++) {
		var itemIncluded = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i +'].itemIncluded')[0].value;
		var amount = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i +'].amount')[0].value;
		if(itemIncluded == 'A1e') {
			arr['A1e'] = parseInt(arr['A1e'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A2c') {
			arr['A2c'] = parseInt(arr['A2c'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A4a') {
			arr['A4a'] = parseInt(arr['A4a'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A4b') {
			arr['A4b'] = parseInt(arr['A4b'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A5e') {
			arr['A5e'] = parseInt(arr['A5e'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A6g') {
			arr['A6g'] = parseInt(arr['A6g'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A3e_111A') {
			arr['A3e_111A'] = parseInt(arr['A3e_111A'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A3e_115AD') {
			arr['A3e_115AD'] = parseInt(arr['A3e_115AD'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A7') {
			arr['A7'] = parseInt(arr['A7'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A8a') {
			arr['A8a'] = parseInt(arr['A8a'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A8b') {
			arr['A8b'] = parseInt(arr['A8b'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'A8c') {
			arr['A8c'] = parseInt(arr['A8c'],10) +  parseInt(coalesce(amount),10);
		}

	}

	var table = document.getElementById('scheduleStcgDtaa');
	var rowCount = table.rows.length -2;

	var dtaaSection = [];

	for(var i=0; i<rowCount; i++) {
		var itemIncluded = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i +'].itemIncluded')[0].value;
		if(itemIncluded != '' && dtaaSection.indexOf(itemIncluded) == -1) {
			dtaaSection.push(itemIncluded);
		}
	}

	var table1 = document.getElementById('scheduleCGstcg2');
	var rowCount1 = table1.rows.length/10;

	var arrSection2 = [];
	var arrAmount2 = {'1A':0,'5AD1biip':0};

	var arrAmount2e = {
			'1A' : 0,
			'5AD1biip' : 0
	};



	for(var k=0; k<rowCount1; k++) {
		var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['+ k +'].section')[0].value;
		var amount = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['+ k +'].fullConsideration')[0].value;
		var capgainonAssets = document
		.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['
				+ k + '].capgainonAssets')[0].value;


		if(section != '' && arrSection2.indexOf(section) == -1) {
			arrSection2.push(section);
			arrAmount2[section] = amount;
			arrAmount2e[section] = capgainonAssets;

		}
	}

	var fullConsideration50C = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild.capgainonAssets')[0];
	if(dtaaSection.indexOf('A1e') != -1 && arr['A1e'] > 0 && fullConsideration50C.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild.capgainonAssets','A1(aiii) value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsideration50C,'A1(aiii) value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A1e') != -1 && parseInt(coalesce(arr['A1e']), 10)>parseInt(coalesce(fullConsideration50C.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild.capgainonAssets',
		'Amount of Income entered in DTAA table for Item no. A1e should not be more than A1e value.');
		addErrorXHTML(
				fullConsideration50C,
				'Amount of Income entered in DTAA table for Item no. A1e should not be more than A1e value.',
				true);
	}

	var fullConsideration = document.getElementsByName('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.cgSlumpSale')[0];
	if(dtaaSection.indexOf('A2c') != -1 && arr['A2c'] > 0 && fullConsideration.value == 0) {
		j.setFieldError('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.cgSlumpSale','A2a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsideration,'A2a value should not be zero as there is an entry in DTAA table.',true);
	}
	if (dtaaSection.indexOf('A2c') != -1 && parseInt(coalesce(arr['A2c']), 10)>parseInt(coalesce(fullConsideration.value), 10)) {
		j.setFieldError('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.cgSlumpSale',
		'Amount of Income entered in DTAA table for Item no. A2c should not be more than A2c value.');
		addErrorXHTML(fullConsideration,
				'Amount of Income entered in DTAA table for Item no. A2c should not be more than A2c value.',true);
	}
	if(dtaaSection.indexOf('A3e_111A') != -1 && arr['A3e_111A'] > 0 && (arrSection2.indexOf('1A') == -1 || arrAmount2['1A'] == 0)) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section','111A section in A3 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section')[0],'111A section in A3 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A3e_111A') != -1
			&& (arrSection2.indexOf('1A') != -1) && (parseInt(coalesce(arr['A3e_111A']), 10)>parseInt(coalesce(arrAmount2e['1A']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section',
		'Amount of Income entered in DTAA table for Item no. A3e_111A should not be more than A3e value for 111A section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section')[0],
				'Amount of Income entered in DTAA table for Item no. A3e_111A should not be more than A3e value for 111A section.',
				true);
	}



	if(dtaaSection.indexOf('A3e_115AD') != -1 && arr['A3e_115AD'] > 0 && (arrSection2.indexOf('5AD1biip') == -1 || arrAmount2['5AD1biip'] == 0)) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section','115AD(1)(b)(ii) section in A3 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section')[0],'115AD(1)(b)(ii) section in A3 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A3e_115AD') != -1
			&& (arrSection2.indexOf('5AD1biip') != -1) && (parseInt(coalesce(arr['A3e_115AD']), 10)>parseInt(coalesce(arrAmount2e['5AD1biip']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section',
		'Amount of Income entered in DTAA table for Item no. A3e_115AD should not be more than A3e value for 115AD section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section')[0],
				'Amount of Income entered in DTAA table for Item no. A3e_115AD should not be more than A3e value for 115AD section.',
				true);
	}



	var nRItaxSTTPaid = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid')[0];
	if(dtaaSection.indexOf('A4a') != -1 && arr['A4a'] > 0 && nRItaxSTTPaid.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid','A4a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(nRItaxSTTPaid,'A4a value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A4a') != -1 && parseInt(coalesce(arr['A4a']), 10)>parseInt(coalesce(nRItaxSTTPaid.value), 10) ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTPaid',
		'Amount of Income entered in DTAA table for Item no. A4a should not be more than A4a value.');
		addErrorXHTML(
				nRItaxSTTPaid,
				'Amount of Income entered in DTAA table for Item no. A4a should not be more than A4a value.',
				true);
	}


	var nRItaxSTTNotPaid = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid')[0];
	if(dtaaSection.indexOf('A4b') != -1 && arr['A4b'] > 0 && nRItaxSTTNotPaid.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid','A4b value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(nRItaxSTTNotPaid,'A4b value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A4b') != -1 && parseInt(coalesce(arr['A4b']), 10)>parseInt(coalesce(nRItaxSTTNotPaid.value), 10)  ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.nRITransacSec48Dtl.nRItaxSTTNotPaid',
		'Amount of Income entered in DTAA table for Item no. A4b should not be more than A4b value.');
		addErrorXHTML(
				nRItaxSTTNotPaid,
				'Amount of Income entered in DTAA table for Item no. A4b should not be more than A4b value.',
				true);
	}


	var fullConsideration = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0];
	var capgainonAssets = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.capgainonAssets')[0];

	if(dtaaSection.indexOf('A5e') != -1 && arr['A5e'] > 0 && fullConsideration.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration','A5a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsideration,'A5a value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A5e') != -1 && parseInt(coalesce(arr['A5e']), 10)>parseInt(coalesce(capgainonAssets.value), 10)  ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration',
		'Amount of Income entered in DTAA table for Item no. A5e should not be more than A5e value.');
		addErrorXHTML(
				fullConsideration,
				'Amount of Income entered in DTAA table for Item no. A5e should not be more than A5e value.',
				true);
	}


	var fullConsiderationA6g = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsideration')[0];

	var capgainonAssetsA5e = document
	.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.capgainonAssets')[0];

	if(dtaaSection.indexOf('A6g') != -1 && arr['A6g'] > 0 && fullConsiderationA6g.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsideration','A6a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationA6g,'A6a value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A6g') != -1 && parseInt(coalesce(arr['A6g']), 10)>parseInt(coalesce(capgainonAssetsA5e.value), 10)  ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsideration',
		'Amount of Income entered in DTAA table for Item no. A6g should not be more than A6g value.');
		addErrorXHTML(
				capgainonAssetsA5e,
				'Amount of Income entered in DTAA table for Item no. A6g should not be more than A6g value.',
				true);
	}


	var totAmtStcgUnderDtaa = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.totAmtStcgUnderDtaa')[0];
	if(dtaaSection.indexOf('A7') != -1 && arr['A7'] > 0 && totAmtStcgUnderDtaa.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.totAmtStcgUnderDtaa','A7 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa,'A7 value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A7') != -1 && parseInt(coalesce(arr['A7']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa.value), 10) ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54.totAmtStcgUnderDtaa',
		'Amount of Income entered in DTAA table for Item no. A7 should not be more than A7 value.');
		addErrorXHTML(
				totAmtStcgUnderDtaa,
				'Amount of Income entered in DTAA table for Item no. A7 should not be more than A7 value.',
				true);
	}


	var totAmtStcgUnderDtaa = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg15')[0];
	if(dtaaSection.indexOf('A8a') != -1 && arr['A8a'] > 0 && totAmtStcgUnderDtaa.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg15','A8a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa,'A8a value should not be zero as there is an entry in DTAA table.',true);
	}



	if (dtaaSection.indexOf('A8a') != -1 && parseInt(coalesce(arr['A8a']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa.value), 10) ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg15',
		'Amount of Income entered in DTAA table for Item no. A8a should not be more than A8a value.');
		addErrorXHTML(totAmtStcgUnderDtaa,'Amount of Income entered in DTAA table for Item no. A8a should not be more than A8a value.',
				true);
	}

	//A8b



	var totAmtStcgUnderDtaa8b = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg30')[0];
	if(dtaaSection.indexOf('A8b') != -1 && arr['A8b'] > 0 && totAmtStcgUnderDtaa8b.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg30','A8b value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa8b,'A8b value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('A8b') != -1 && parseInt(coalesce(arr['A8b']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa8b.value), 10)  ) {
		j.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcg30',
		'Amount of Income entered in DTAA table for Item no. A8b should not be more than A8b value.');
		addErrorXHTML(
				totAmtStcgUnderDtaa8b,
				'Amount of Income entered in DTAA table for Item no. A8b should not be more than A8b value.',
				true);
	}


	//A8c

	var totAmtStcgUnderDtaa8c = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcgAr')[0];
	if(dtaaSection.indexOf('A8c') != -1 && arr['A8c'] > 0 && totAmtStcgUnderDtaa8c.value == 0) {
		j.setFieldError('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcgAr','A8c value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa8c,'A8c value should not be zero as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('A8c') != -1 &&  parseInt(coalesce(arr['A8c']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa8c.value), 10)  ) {
		j
		.setFieldError(
				'scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.ptiStcgAr',
		'Amount of Income entered in DTAA table for Item no. A8c should not be more than A8c value.');
		addErrorXHTML(totAmtStcgUnderDtaa8c,'Amount of Income entered in DTAA table for Item no. A8c should not be more than A8c value.',
				true);
	}



}

//Validate LTCG Section-wise along with DTAA.
function validateLTCGSectionWiseDTAA() {
	var arr = {
			'B1e' : 0,
			'B2e' : 0,
			'B3c' : 0,
			'B4c' : 0,
			'B5' : 0,
			'B6' : 0,
			'B7c112(1)(c)' : 0,
			'B7c115AB1b' : 0,
			'B7c115AC' : 0,
			'B7c115AD' : 0,
			'B8' : 0,
			'B9e' : 0,
			'B10' : 0,
			'B11a1':0,
			'B11a2':0,
			'B11b' : 0
	};
	var tab = document.getElementById('scheduleLtcgDtaa');
	var rowCount = tab.rows.length -2;
	for(var i=0; i<rowCount; i++) {
		var itemIncluded = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i +'].itemIncluded')[0].value;
		var amount = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i +'].amount')[0].value;
		if(itemIncluded == 'B1e') {
			arr['B1e'] = parseInt(arr['B1e'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B2e') {
			arr['B2e'] = parseInt(arr['B2e'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B3c') {
			arr['B3c'] = parseInt(arr['B3c'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B4c') {
			arr['B4c'] = parseInt(arr['B4c'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B5') {
			arr['B5'] = parseInt(arr['B5'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B6') {
			arr['B6'] = parseInt(arr['B6'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B7c112(1)(c)') {
			arr['B7c112(1)(c)'] = parseInt(arr['B7c112(1)(c)'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B7c115AB1b') {
			arr['B7c115AB1b'] = parseInt(arr['B7c115AB1b'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B7c115AC') {
			arr['B7c115AC'] = parseInt(arr['B7c115AC'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B7c115AD') {
			arr['B7c115AD'] = parseInt(arr['B7c115AD'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B8') {
			arr['B8'] = parseInt(arr['B8'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B9e') {
			arr['B9e'] = parseInt(arr['B9e'],10) +  parseInt(coalesce(amount),10);
		} else if(itemIncluded == 'B10') {
			arr['B10'] = parseInt(arr['B10'],10) +  parseInt(coalesce(amount),10);
		}else if (itemIncluded == 'B11a1') {
			arr['B11a1'] = parseInt(arr['B11a1'], 10) + parseInt(coalesce(amount), 10);
		}else if (itemIncluded == 'B11a2') {
			arr['B11a2'] = parseInt(arr['B11a2'], 10)+ parseInt(coalesce(amount), 10);
		}else if (itemIncluded == 'B11b') {
			arr['B11b'] = parseInt(arr['B11b'], 10)	+ parseInt(coalesce(amount), 10);
		}
	}

	var table = document.getElementById('scheduleLtcgDtaa');
	var rowCount = table.rows.length -2;

	var dtaaSection = [];

	for(var i=0; i<rowCount; i++) {
		var itemIncluded = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i +'].itemIncluded')[0].value;
		if(itemIncluded != '' && dtaaSection.indexOf(itemIncluded) == -1) {
			dtaaSection.push(itemIncluded);
		}
	}

	var fullConsideration = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild[0].fullConsideration50C')[0];
	var capgainonAssets1e = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild[0].capgainonAssets')[0];

	if(dtaaSection.indexOf('B1e') != -1 && arr['B1e'] > 0  && fullConsideration.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild[0].fullConsideration50C','B1(aiii) value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsideration,'B1(aiii) value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B1e') != -1 && parseInt(coalesce(arr['B1e']), 10)>parseInt(coalesce(capgainonAssets1e.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.saleofLandBuild[0].capgainonAssets',
		'Amount of Income entered in DTAA table for Item no. B1e should not be more than B1e value.');
		addErrorXHTML(
				capgainonAssets1e,
				'Amount of Income entered in DTAA table for Item no. B1e should not be more than B1e value.',
				true);
	}

	if (dtaaSection.indexOf('B1e') != -1 && parseInt(coalesce(arr['B1e']), 10)>parseInt(coalesce(capgainonAssets1e.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.saleofLandBuild[0].capgainonAssets',
		'Amount of Income entered in DTAA table for Item no. B1e should not be more than B1e value.');
		addErrorXHTML(
				capgainonAssets1e,
				'Amount of Income entered in DTAA table for Item no. B1e should not be more than B1e value.',
				true);
	}


	var fullConsideration = document.getElementsByName('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.fullConsiderationB')[0];
	var capgainonAssets2e = document.getElementsByName('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.cgSlumpSaleB')[0];

	if(dtaaSection.indexOf('B2e') != -1 && arr['B2e'] > 0  && fullConsideration.value == 0) {
		j.setFieldError('scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.fullConsiderationB','B2a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsideration,'B2a value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B2e') != -1 && parseInt(coalesce(arr['B2e']), 10)>parseInt(coalesce(capgainonAssets2e.value), 10)) {
		j
		.setFieldError(
				'scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.fullConsiderationB',
		'Amount of Income entered in DTAA table for Item no. B2e should not be more than B2e value.');
		addErrorXHTML(
				capgainonAssets2e,
				'Amount of Income entered in DTAA table for Item no. B2e should not be more than B2e value.',
				true);
	}

	if (dtaaSection.indexOf('B2e') != -1 && parseInt(coalesce(arr['B2e']), 10)>parseInt(coalesce(capgainonAssets2e.value), 10)) {
		j
		.setFieldError(
				'scheduleCGFor4.shortTermCapGainFor4.capGainSlumpSale.fullConsiderationB',
		'Amount of Income entered in DTAA table for Item no. B2e should not be more than B2e value.');
		addErrorXHTML(
				capgainonAssets2e,
				'Amount of Income entered in DTAA table for Item no. B2e should not be more than B2e value.',
				true);
	}

	
	var fullConsiderationB3e = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.fullConsideration')[0];

	var capgainonAssets3c = document
	.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.balanceCG')[0];

	if(dtaaSection.indexOf('B3c') != -1 && arr['B3c'] > 0  && fullConsiderationB3e.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.fullConsideration','B3a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationB3e,'B3a value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B3c') != -1 && parseInt(coalesce(arr['B3c']), 10)>parseInt(coalesce(capgainonAssets3c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.fullConsideration',
		'Amount of Income entered in DTAA table for Item no. B3e should not be more than B3e value.');
		addErrorXHTML(
				capgainonAssets3c,
				'Amount of Income entered in DTAA table for Item no. B3e should not be more than B3e value.',
				true);
	}

	if (dtaaSection.indexOf('B3c') != -1 && parseInt(coalesce(arr['B3c']), 10)>parseInt(coalesce(capgainonAssets3c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.saleofBondsDebntr.fullConsideration',
		'Amount of Income entered in DTAA table for Item no. B3e should not be more than B3e value.');
		addErrorXHTML(
				capgainonAssets3c,
				'Amount of Income entered in DTAA table for Item no. B3e should not be more than B3e value.',
				true);
	}



	var fullConsiderationB4a = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].fullConsideration')[0];


	var capgainonAssets4c = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].balanceCG')[0];

	if(dtaaSection.indexOf('B4c') != -1 && arr['B4c'] > 0  && fullConsiderationB4a.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].fullConsideration','B4a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationB4a,'B4a value should not be zero as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B4c') != -1 && parseInt(coalesce(arr['B4c']), 10)>parseInt(coalesce(capgainonAssets4c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].fullConsideration',
		'Amount of Income entered in DTAA table for Item no. B4c should not be more than B4c value.');
		addErrorXHTML(
				capgainonAssets4c,
				'Amount of Income entered in DTAA table for Item no. B4c should not be more than B4c value.',
				true);
	}

	if (dtaaSection.indexOf('B4c') != -1 && parseInt(coalesce(arr['B4c']), 10)>parseInt(coalesce(capgainonAssets4c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.proviso112Applicable[0].fullConsideration',
		'Amount of Income entered in DTAA table for Item no. B4c should not be more than B4c value.');
		addErrorXHTML(
				capgainonAssets4c,
				'Amount of Income entered in DTAA table for Item no. B4c should not be more than B4c value.',
				true);
	}

	var capgainonAssets5c = document
	.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0];
	var fullConsiderationB5 =document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0];
	if(dtaaSection.indexOf('B5') != -1 && arr['B5'] > 0  && fullConsiderationB5.value == 0) {
		j.setFieldError('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain','B5 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationB5,'B5c value should not be zero as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B5') != -1 && parseInt(coalesce(arr['B5']), 10)>parseInt(coalesce(capgainonAssets5c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain',
		'Amount of Income entered in DTAA table for Item no. B5 should not be more than B5 value.');
		addErrorXHTML(
				capgainonAssets5c,
				'Amount of Income entered in DTAA table for Item no. B5 should not be more than B5 value.',
				true);
	}

	if (dtaaSection.indexOf('B5') != -1 && parseInt(coalesce(arr['B5']), 10)>parseInt(coalesce(capgainonAssets5c.value), 10)) {
		j
		.setFieldError(
				'scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain',
		'Amount of Income entered in DTAA table for Item no. B5 should not be more than B5 value.');
		addErrorXHTML(
				capgainonAssets5c,
				'Amount of Income entered in DTAA table for Item no. B5 should not be more than B5 value.',
				true);
	}


	var ltcgWithoutBenefit = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG')[0];
	if(dtaaSection.indexOf('B6') != -1 && arr['B6'] > 0 && ltcgWithoutBenefit.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG','B6 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(ltcgWithoutBenefit,'B6 value should not be zero as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B6') != -1 && parseInt(coalesce(arr['B6']), 10)>parseInt(coalesce(ltcgWithoutBenefit.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG',
		'Amount of Income entered in DTAA table for Item no. B6 should not be more than B6 value.');
		addErrorXHTML(
				ltcgWithoutBenefit,
				'Amount of Income entered in DTAA table for Item no. B6 should not be more than B6 value.',
				true);
	}

	if (dtaaSection.indexOf('B6') != -1 && parseInt(coalesce(arr['B6']), 10)>parseInt(coalesce(ltcgWithoutBenefit.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIProvisoSec48.BalanceCG',
		'Amount of Income entered in DTAA table for Item no. B6 should not be more than B6 value.');
		addErrorXHTML(
				ltcgWithoutBenefit,
				'Amount of Income entered in DTAA table for Item no. B6 should not be more than B6 value.',
				true);
	}

	var table2 = document.getElementById('stcg10pctTab');
	var rowCount2 = table2.rows.length/15;

	var arrSection1 = [];
	var arrAmount1 = {'21ciii':0,'5AB1b':0,'5AC1c':0,'5ADiii':0};
	var arrAmountB7 = {
			'21ciii' : 0,
			'5AC1c' : 0,
			'5ADiii' : 0
	};




	for(var a=0; a<=rowCount2; a++) {
		var sectionCode = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+a+'].sectionCode')[0].value;
		var amount = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+a+'].fullConsideration')[0].value;
		var capgainonAssets = document.getElementsByName('	')[0].value;


		if(sectionCode != '' && arrSection1.indexOf(sectionCode) == -1) {
			arrSection1.push(sectionCode);
			arrAmount1[sectionCode] = amount;
			arrAmountB7[sectionCode] = capgainonAssets;

		}
	}

	if(dtaaSection.indexOf('B7c112(1)(c)') != -1 && arr['B7c112(1)(c)'] > 0 && (arrSection1.indexOf('21ciii') == -1 || arrAmount1['21ciii'] == 0)) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode','21ciii section in B7 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],'21ciii section in B7 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B7c112(1)(c)') != -1
			&& (arrSection1.indexOf('21ciii') != -1) && (parseInt(coalesce(arr['B7c112(1)(c)']), 10)>parseInt(coalesce(arrAmountB7['21ciii']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode',
		'Amount of Income entered in DTAA table for Item no. B7c112(1)(c) should not be more than B7 value of 21ciii section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],
				'Amount of Income entered in DTAA table for Item no. B7c112(1)(c) should not be more than B7 value of 21ciii section.',
				true);
	}



	if(dtaaSection.indexOf('B7c115AB1b') != -1 && arr['B7c115AB1b'] > 0 && (arrSection1.indexOf('5AB1b') == -1 || arrAmount1['5AB1b'] == 0)) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode','5AB1b section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],'5AB1b section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B7c115AB1b') != -1
			&& (arrSection1.indexOf('5AB1b') != -1) && (parseInt(coalesce(arr['B7c115AB1b']), 10)>parseInt(coalesce(arrAmountB7['5AB1b']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode',
		'Amount of Income entered in DTAA table for Item no. B7c115AB1b should not be more than B7 value of 5AB1b section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],
				'Amount of Income entered in DTAA table for Item no. B7c115AB1b should not be more than B7 value of 5AB1b section.',
				true);
	}


	if(dtaaSection.indexOf('B7c115AC') != -1 && arr['B7c115AC'] > 0 && (arrSection1.indexOf('5AC1c') == -1 || arrAmount1['5AC1c'] == 0)) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode','5AC1c section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],'5AC1c section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B7c115AC') != -1 && (arrSection1.indexOf('5AC1c') != -1) && (parseInt(coalesce(arr['B7c115AC']), 10)>parseInt(coalesce(arrAmountB7['5AC1c']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode',
		'Amount of Income entered in DTAA table for Item no. B7c115AC should not be more than B7 value of 5AC1c section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],
				'Amount of Income entered in DTAA table for Item no. B7c115AC should not be more than B7 value of 5AC1c section.',
				true);
	}

	if(dtaaSection.indexOf('B7c115AD') != -1 && arr['B7c115AD'] > 0 && (arrSection1.indexOf('5ADiii') == -1 || arrAmount1['5ADiii'] == 0)) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode','5ADiii section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.');
		addErrorXHTML(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],'5ADiii section in B6 should be selected and amount should not be zero, as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B7c115AD') != -1
			&& (arrSection1.indexOf('5ADiii') != -1) && (parseInt(coalesce(arr['B7c115AD']), 10)>parseInt(coalesce(arrAmountB7['5ADiii']), 10))) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode',
		'Amount of Income entered in DTAA table for Item no. B7c115AD should not be more than B7 value of 5ADiii section.');
		addErrorXHTML(
				document
				.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115[0].sectionCode')[0],
				'Amount of Income entered in DTAA table for Item no. B7c115AD should not be more than B7 value of 5ADiii section.',
				true);
	}

	var fullConsiderationB7a = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration')[0];
	if(dtaaSection.indexOf('B7c') != -1 && arr['B7c'] > 0 && fullConsiderationB7a.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration','B7a value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationB7a,'B7a value should not be zero as there is an entry in DTAA table.',true);
	}


	var  ltcgAssestsB7= document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0];

	if (dtaaSection.indexOf('B8') != -1 && arr['B8'] > 0 && ltcgAssestsB7.value == 0) {
		j.setFieldError('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain',
		'B8 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(ltcgAssestsB7,'B8 value should not be zero as there is an entry in DTAA table.',true);
	}
	if (dtaaSection.indexOf('B8') != -1  && parseInt(coalesce(arr['B8']), 10)>parseInt(coalesce(ltcgAssestsB7.value), 10)) {
		j.setFieldError('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain',
		'Amount of Income entered in DTAA table for Item no. B8 should not be more than B8 value.');
		addErrorXHTML(ltcgAssestsB7,'Amount of Income entered in DTAA table for Item no. B8 should not be more than B8 value.',true);
	}



	var capgainonAssetsB9e = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.capgainonAssets')[0];
	if(dtaaSection.indexOf('B9e') != -1 && arr['B9e'] > 0 && capgainonAssetsB9e.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.capgainonAssets','B9e value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(capgainonAssetsB9e,'B9e value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B9e') != -1 && parseInt(coalesce(arr['B9e']), 10)>parseInt(coalesce(capgainonAssetsB9e.value), 10) ) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.capgainonAssets',
		'Amount of Income entered in DTAA table for Item no. B9e should not be more than B9e value.');
		addErrorXHTML(capgainonAssetsB9e,'Amount of Income entered in DTAA table for Item no. B9e should not be more than B9e value.',
				true);
	}

	var fullConsiderationB10 = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')[0];
	if(dtaaSection.indexOf('B10') != -1 && arr['B10'] > 0  && fullConsiderationB10.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa','B10 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(fullConsiderationB10,'B10 value should not be zero as there is an entry in DTAA table.',true);
	}

	if (dtaaSection.indexOf('B10') != -1  && parseInt(coalesce(arr['B10']), 10)>parseInt(coalesce(fullConsiderationB10.value), 10) ) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa',
		'Amount of Income entered in DTAA table for Item no. B10 should not be more than B10 value.');
		addErrorXHTML(
				fullConsiderationB10,
				'Amount of Income entered in DTAA table for Item no. B10 should not be more than B10 value.',
				true);
	}


	//B11a


	var totAmtStcgUnderDtaa = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10OthrUs112A')[0];
	if(dtaaSection.indexOf('B11a1') != -1 && arr['B11a1'] > 0 && totAmtStcgUnderDtaa.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10OthrUs112A','B11a1 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa,'B11a value should not be zero as there is an entry in DTAA table.',true);
	}


	if (dtaaSection.indexOf('B11a1') != -1  && parseInt(coalesce(arr['B11a1']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10OthrUs112A',
		'Amount of Income entered in DTAA table for Item no. B11a1 should not be more than B11a1 value.');
		addErrorXHTML(
				totAmtStcgUnderDtaa,
				'Amount of Income entered in DTAA table for Item no. B11a1 should not be more than B11a1 value.',
				true);
	}

	var ptiLtcg10 = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10')[0];

	if (dtaaSection.indexOf('B11a2') != -1 && arr['B11a2'] > 0
			&& ptiLtcg10.value == 0) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10',
		'B11a2 value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(
				ptiLtcg10,
				'B11a2 value should not be zero as there is an entry in DTAA table.',
				true);
	}
	if (dtaaSection.indexOf('B11a2') != -1 && parseInt(coalesce(arr['B11a2']), 10)>parseInt(coalesce(ptiLtcg10.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg10',
		'Amount of Income entered in DTAA table for Item no. B11a2 should not be more than B11a2 value.');
		addErrorXHTML(
				ptiLtcg10,
				'Amount of Income entered in DTAA table for Item no. B11a2 should not be more than B11a2 value.',
				true);
	}

	//B11b

	var totAmtStcgUnderDtaa = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg20')[0];
	if(dtaaSection.indexOf('B11b') != -1 && arr['B11b'] > 0 && totAmtStcgUnderDtaa.value == 0) {
		j.setFieldError('scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa','B11b value should not be zero as there is an entry in DTAA table.');
		addErrorXHTML(totAmtStcgUnderDtaa,'B11b value should not be zero as there is an entry in DTAA table.',true);
	}
	if (dtaaSection.indexOf('B11b') != -1 && parseInt(coalesce(arr['B11b']), 10)>parseInt(coalesce(totAmtStcgUnderDtaa.value), 10)) {
		j
		.setFieldError(
				'scheduleCGPost45.longTermCapGainPost45.stcgUnderDtaa.ptiLtcg20',
		'Amount of Income entered in DTAA table for Item no. B11b should not be more than B11b value.');
		addErrorXHTML(
				totAmtStcgUnderDtaa,
				'Amount of Income entered in DTAA table for Item no. B11b should not be more than B11b value.',
				true);
	}

}

function panValidation80G(tableId) {

	var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var verificationPAN = document.getElementsByName('verification.declaration.assesseeVerPAN')[0].value;
	var table = document.getElementById(tableId);
	var allInputTags = table.getElementsByTagName('input');
	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("doneePanNo$")) {
			if(allInputTags[i].value != '' && (allInputTags[i].value == pan || allInputTags[i].value == verificationPAN )){
				j.setFieldError(allInputTags[i].name,'Donee PAN cannot be same as assesse PAN or verification PAN in Schedule 80G');

			}
		}
	}
}

//To alert user
function alertItr5User() {

	var errText="";
	var i=1;
	var amountPayable = document.getElementsByName('partBTTI.taxPaid.balTaxPayable')[0].value;
	var fileSec = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var inchBPAlert=document.getElementsByName('itr5ScheduleBP.incChrgUnHdProftGain')[0].value;

	var checkForBPAlert = coalesceSetRet('partabs.fundSrc.totFundSrc')
	+ coalesceSetRet('partabs.noBooksOfAccBS.totSundryDbtAmt')
	+ coalesceSetRet('partabs.noBooksOfAccBS.totSundryCrdAmt')
	+ coalesceSetRet('partabs.noBooksOfAccBS.totStkInTradAmt')
	+ coalesceSetRet('partabs.noBooksOfAccBS.cashBalAmt');

	if(fileSec=='19'){
		errText+=(i++)+". To file return u/s 92CD, post login in e-Filing portal, go to 'e-File' --> 'Income Tax Return' and select the applicable AY, ITR and other options.\n\n";
	}
	if(fileSec=='20'){
		errText+=(i++)+". Sec 139 read with section 119(2)(b)- after condonation of delay should be filed after expiry of due date mentioned in 139(1)/139(4).\n\n";
	}
	/*if(fileSec=='18'){
		errText+=(i++)+". Please ensure that your Gross Total Income, Deductions  and Tax liabilities matches with the intimation issued by CPC u/s 143(1).\n\n";
	}*/
	if (checkForBPAlert == 0 && inchBPAlert > 250000){
		errText+=(i++)+". Please ensure that the relevant fields of Profit & Loss and Balance Sheet are filled, else Return of Income may be treated as defective u/s 139(9).\n";
	}
	main.generateMsgDialogWithOk(errText,"");
}

//To open Save file dialog
function popupWithOk()
{
	j.popup();
}

function verificationPanValidation(tableId){

	var verificationPAN = document.getElementsByName('verification.declaration.assesseeVerPAN')[0];
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	var flag = true;
	var table = document.getElementById(tableId);
	var allInputTags = table.getElementsByTagName('input');
	if(status=='1'||substatus=='15' ||substatus=='16' ||substatus=='17' ||substatus=='4'||substatus=='5'||substatus=='7'||substatus=='8'){
		for(var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("pan$")) {
				if(allInputTags[i].value == verificationPAN.value ){
					flag = false;
				}
			}
		}

		if(flag){
			j.setFieldError(verificationPAN.name,'PAN entered at Verification is not matching with the PAN entered at PARTNERS/MEMBERS/TRUST INFORMATION.Please ensure that the person authorized to verify the ITR is as per Section 140 of the Income Tax Act.');
		}
	}
}

//Calculate Total Income for Schedule ICDS.
function calcTotalICDS(){
	try{
		var totalNatEffect = document.getElementsByName('itrScheduleICDS.totNetEffect')[0];
		var totalNetAmtNegative = document.getElementsByName('itrScheduleICDS.totNetEffectN')[0];

		var	temp=eval( parseInt(coalesce(document.getElementsByName('itrScheduleICDS.accntPolicies')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.valInventories')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.constructionCon')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.revenueRecog')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.tangFixedAssets')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.foriegnExcRates')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.govGrants')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.securities')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.assets')[0].value),10) +
				parseInt(coalesce(document.getElementsByName('itrScheduleICDS.borrowingCosts')[0].value),10))
				if(parseInt(temp)>0){
					document.getElementsByName('itrScheduleICDS.totNetEffect')[0].value=''
						document.getElementsByName('itrScheduleICDS.totNetEffectN')[0].value=''
							document.getElementsByName('itrScheduleICDS.totNetEffect')[0].value=temp
				}
				else {
					document.getElementsByName('itrScheduleICDS.totNetEffect')[0].value=''
						document.getElementsByName('itrScheduleICDS.totNetEffectN')[0].value=''
							document.getElementsByName('itrScheduleICDS.totNetEffectN')[0].value=Math.abs(temp);
				}

		//populates to OI point 3a and 3b
		document.getElementsByName('partaoi.profDeviatDueAcctMeth')[0].value = parseInt(coalesce(totalNatEffect.value),10);
		document.getElementsByName('partaoi.decProfDeviatDueAcctMeth')[0].value = parseInt(coalesce(totalNetAmtNegative.value),10);

	}
	catch(e){
		alert(e.stack);
	}

}

//to add rows to table sch PTI
function addRowSchedPTIFor5(nocheck) {

	var mainTable = document.getElementById('schedulePTI').rows;
	var noOfRows = mainTable.length;

	var tobeInsertBefore = document.getElementById('schedulePTIAddRow');
	var flag = true;
	var checkFirst = true;
	var totRow = document.getElementById('schedulePTIFirst').cells[0].textContent;

	var iterate = eval(parseInt(totRow, 10));

	var indexValue = eval(((parseInt(noOfRows, 10) - 3) / 9) + 1);

	var isRowBlank = true;
	for ( var i = 0; i < 9; i++) {
		if (!checkRowBlank('schedulePTI', i, 0)) {
			isRowBlank = false;
			break;
		}
	}

	if (!isRowBlank || nocheck) {

		for ( var i = 1; i < mainTable.length; i++) {
			var cloneNode = mainTable[i].cloneNode(true);
			if (flag) {
				if (checkFirst) {
					iterate = eval(indexValue - 1);

					cloneNode.cells[0].innerHTML = indexValue;
					checkFirst = false;
				}

				// Numbering
				var inputTags = cloneNode.getElementsByTagName('input');
				for ( var a = 0; a < inputTags.length; a++) {
					inputTags[a].name = inputTags[a].name.replace('[0]', '['
							+ iterate + ']');

					inputTags[a].id = inputTags[a].name.replace(/([\.\[\]])/g,
					'_').replace(/(__)/g, '_');
					inputTags[a].value = '';
					var blurAttr = inputTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					inputTags[a].setAttribute('onblur', blurAttr
							+ 'j.blur(this,this.name,this.value);');
				}

				document.getElementById('schedulePTI').getElementsByTagName(
				'tr')[0].parentNode.insertBefore(cloneNode,
						tobeInsertBefore);
			}
			if (mainTable[i].id == 'schedulePTIEnd') {
				flag = false;
				break;
			}
		}
		if ($('#schedulePTIAddRow')[0].parentNode.children.length == 12) {
			$('#delPTIButtonId').prop('disabled', true);
		} else if ($('#schedulePTIAddRow')[0].parentNode.children.length > 12) {
			$('#delPTIButtonId').prop('disabled', false);
		}

	} else {
		addErrorXHTML(
				'',
		'Please fill in all the mandatory fields in the last row before adding another row.222222222222');
	}
	checkMaxLengthLimit();
}

//To delete row from PTI
function deleteRowPTI(tableId , noOfHeader , noOfFooter){
	try{
		var mytable = document.getElementById(tableId);
		var rowCount = mytable.rows.length;
		var itemCount = (rowCount - 3 )/ 9;
		noOfHeader = parseInt(noOfHeader , 10);
		var isChecked=false;
		var listOfCheckBox = mytable.getElementsByTagName('input');
		var totalChecked = 0;
		for(var z=0; z<listOfCheckBox.length; z++){
			if(listOfCheckBox[z].name.match(".chosenCheckBox$")){
				if(listOfCheckBox[z].checked==true){
					totalChecked = eval( parseInt(totalChecked,10) +1);
					isChecked=true;
				}
			}
		}
		if(!isChecked){
			addErrorXHTML('','Please select a checkbox for deleting row');
		}

		for(var j=1; j<=totalChecked ; j++){
			var totalNoOfInput = mytable.getElementsByTagName('input');

			for(var z=0; z<totalNoOfInput.length; z++){
				if(totalNoOfInput[z].name.match(".chosenCheckBox$")){

					var akhilIndex1 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf('[') ,10)+1);
					var akhilIndex2 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf(']') ,10));
					var rowNumber = totalNoOfInput[z].name.substring(akhilIndex1, akhilIndex2);
					rowNumber = parseInt(rowNumber ,10);

					var myCurrtable = document.getElementById(tableId);
					var rowCurrCount = myCurrtable.rows.length;


					if(totalNoOfInput[z].checked==true){
						if((rowNumber!=0) || (rowNumber==0 &&  parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/9)>1) ){
							rowNumber = eval(parseInt(rowNumber,10) * 9 + noOfHeader);
							for(var i=0;i<9;i++){
								mytable.deleteRow(rowNumber);
							}
							//To Do - reset the name of row for all input , textarea, select
							var newTrList = mytable.getElementsByTagName('tr');
							var newTrListLength = eval(parseInt(newTrList.length ,10)-noOfFooter);
							for( var q=rowNumber; q < newTrListLength ; q++ ){
								var p = parseInt((q-noOfHeader) /9) + noOfHeader;
								//set the serial number;
								if((q-noOfHeader)%9==0){
									if(noOfHeader==2){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-1,10);
									}else if(noOfHeader==1){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p,10);
									}else if(noOfHeader==3){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-2,10);
									}
								}
								var allInputTags = newTrList[q].getElementsByTagName('input');

								for(var zz=0; zz<allInputTags.length ; zz++ ){
									var index1= allInputTags[zz].name.lastIndexOf('[');
									var index2= allInputTags[zz].name.lastIndexOf(']');

									var str1 = allInputTags[zz].name.substring(0, index1);
									var str3 = allInputTags[zz].name.substring(index2 + 1, allInputTags[zz].name.length);

									allInputTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}

								var allTextAreaTags = newTrList[q].getElementsByTagName('textarea');

								for(var zz=0; zz<allTextAreaTags.length ; zz++ ){
									var index1= allTextAreaTags[zz].name.lastIndexOf('[');
									var index2= allTextAreaTags[zz].name.lastIndexOf(']');

									var str1 = allTextAreaTags[zz].name.substring(0, index1);
									var str3 = allTextAreaTags[zz].name.substring(index2 + 1, allTextAreaTags[zz].name.length);

									allTextAreaTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}
							}
							break;
						}else if((rowNumber==0)  && (parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/9)==1)){
							//Vacate the content if its first row

							for(var m=0; m<9; m++){
								var firstRow = mytable.getElementsByTagName('tr')[parseInt(noOfHeader) + m];

								var firstInputBox = firstRow.getElementsByTagName('input')[0];
								firstInputBox.checked = false;

								var allInputTags = firstRow.getElementsByTagName('input');
								for ( var i = 0; i < allInputTags.length; i++) {
									allInputTags[i].value = "";
								}
								var allSelectTags = firstRow.getElementsByTagName('select');
								for ( var i = 0; i < allSelectTags.length; i++) {
									var elem = allSelectTags[i];
									elem[0].selected = true;
								}
								var allTextAreaTags = firstRow.getElementsByTagName('textarea');
								for ( var i = 0; i < allTextAreaTags.length; i++) {
									allTextAreaTags[i].value = "";
								}
							}
						}
					}
				}
			}
		}
	}catch(e){
		alert('exception caught in =' +e.stack );
	}
}

function disablePartAoiPt6()
{
	if(document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value=='4'){
		document.getElementsByName('partaoi.amtDisallUs36.expGovtApprovedSugarPrice')[0].readOnly=false;
	}
	else{
		document.getElementsByName('partaoi.amtDisallUs36.expGovtApprovedSugarPrice')[0].readOnly=true;
	}
}

function surchargeEditable(){
	var splRateIncTax = eval(parseInt(coalesce(document
			.getElementsByName('scheduleSI.splCodeRateTax[13].splRateIncTax')[0].value))+parseInt(coalesce(document
					.getElementsByName('scheduleSI.splCodeRateTax[12].splRateIncTax')[0].value))+parseInt(coalesce(document
							.getElementsByName('scheduleSI.splCodeRateTax[11].splRateIncTax')[0].value)));

	/*var splRateIncTax1 = parseInt(coalesce(document.getElementsByName('scheduleSI.splCodeRateTax[0].splRateIncTax')[0].value));
	if(splRateIncTax>0||splRateIncTax1>0){
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = false;
	}else{
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = true;
	}*/

}

function clearOldSurchargeValue(){
	var surcharge = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0];
	if(surcharge.old!=undefined){
		surcharge.old = undefined;
	}
	if(surcharge.oldvalue!=undefined){
		surcharge.oldvalue = undefined;
	}
}

function returnZeroIfNegative(value){
	if (value < 0) {
		return 0;
	}else{
		return value;
	}
}


function NoneOrPostive(value){
	if (value > 0) {
		return value;
	}else{
		return '';
	}
}

function NoneOrVal(value){
	if (value > 0 || value < 0) {
		return value;
	}else{
		return '';
	}
}

function enable44AD()
{

	var resStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var statusType= document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;

	if (resStatus == 'RES' && statusType == '1')
	{
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0].disabled = false;
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA')[0].disabled = false;
	}else
	{
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0].value= '0';
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA')[0].value='0';
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44AD')[0].disabled = true;
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.deemedProfitBusUs.section44ADA')[0].disabled = true;
	}

}
function OSSubCal(){

	document
	.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls1.sourceAmount')[0].value = eval(parseInt(
			coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls7.sourceAmount'),
			10)
			+ parseInt(
					coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls2.sourceAmount'),
					10)
					+ parseInt(
							coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls3.sourceAmount'),
							10)
							+ parseInt(
									coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls4.sourceAmount'),
									10)
									+ parseInt(
											coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls5.sourceAmount'),
											10)
											+ parseInt(
													coalesceSetRet('scheduleOS.incOthThanOwnRaceHorse.othersGrossDtls6.sourceAmount'),
													10));
}

function OSSubCalInc() {

	document
	.getElementsByName('scheduleOS.incomeFromNature.underSec560.sourceAmount')[0].value = eval(parseInt(
			coalesceSetRet('scheduleOS.incomeFromNature.underSec561.sourceAmount'),
			10)
			+ parseInt(
					coalesceSetRet('scheduleOS.incomeFromNature.underSec562.sourceAmount'),
					10)
					+ parseInt(
							coalesceSetRet('scheduleOS.incomeFromNature.underSec563.sourceAmount'),
							10)
							+ parseInt(
									coalesceSetRet('scheduleOS.incomeFromNature.underSec564.sourceAmount'),
									10)
									+ parseInt(
											coalesceSetRet('scheduleOS.incomeFromNature.underSec565.sourceAmount'),
											10));

}


function surcharge201718(){
	document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surcharge25ofSI')[0].value = eval(
			parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBE'),10) * 0.60* 0.25);

	document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.totalSurcharge')[0].value = eval(
			parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.surcharge25ofSI'),10)+
			parseInt(coalesceSetRet('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F'),10));

}

function removeIncomeDtls1() {

	var status = document
	.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	if ( status == 'NRI' || status == 'RES' ) {
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0].value = 0;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0].value = 0;
		document
		.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0].value = 0;
	}

}

function clearFields(){

	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	if(taxPayer!='1' || resStatus == "NRI" ){

		document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0].value = 0;
	}
	if( resStatus == "NRI" ){

		document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0].value = 0;
	}

	document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBF')[0].value = 0;
	document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBG')[0].value = 0;

}

function checkRegistrationNoLength(RegNO) {
	if(RegNO.value=="00000000") {
		var regno = document.getElementsByName('partAGEN2.auditInfo.audFrmRegNo')[0];
		addErrorXHTML(regno,'Please enter valid Registration No. of the proprietorship/firm.',true);

	}
}


function statusPDTFields()
{
	var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
	var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;


	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var subtaxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;


	if(subtaxPayer == '13'){
		if((firstFlag=='Y' && secondFlag=='N') || (firstFlag=='N' && secondFlag=='N')){
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = true;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value = "";
		}else
		{
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = false;

		}
		var thirdFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value;
		if( (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='Y') || (firstFlag=='Y' && secondFlag=='Y' && thirdFlag=='N') || (firstFlag=='Y' && secondFlag=='N')
				|| (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='Y') || (firstFlag=='N' && secondFlag=='Y' && thirdFlag=='N')){

			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].disabled = true;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].disabled = true;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].disabled = true;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].disabled = true;

			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].value = "";
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].value = "";
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].value = "";
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].value = "";
		}else
		{
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].disabled = false;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].disabled = false;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].disabled = false;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].disabled = false;

		}
	}else{

		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = true;

		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBasic')[0].value = "";
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustReceivable')[0].value = "";
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustRelatives')[0].value = "";
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusProf')[0].value = "";
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value = "";
	}

}

function pdtSubFields()
{
	var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
	var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;
	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var subtaxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if(subtaxPayer == '13'){
		if((firstFlag=='Y' && secondFlag=='N') || (firstFlag=='N' && secondFlag=='N')){

			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = true;
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].value = "";
		}else
		{
			document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = false;

		}
	}else{
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustWill')[0].disabled = true;
	}
}

function pdtItr5NotReqd (){

	var firstFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0].value;
	var secondFlag = document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustBusInc')[0].value;
	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var subtaxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;


	if ( (subtaxPayer == '7') && firstFlag=='Y' && secondFlag=='N' ){

		j.setFieldError('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare','Under this scenario, filing of ITR 5 is not required. The share of income should be reflected in the personal return of income.');
		addErrorXHTML(document.getElementsByName('partAGEN2.partnerOrMemberInfo.pvtDiscretioneryTrustShare')[0],'Under this scenario, filing of ITR 5 is not required. The share of income should be reflected in the personal return of income.',true);
	}

}

function subStatus()
{

	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	var statusCompany1 = statusCompany.value;

	var sub = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0];
	var sub1 = sub.value;

	if(statusCompany1 == '1'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Partnership Firm','10');
		sub.options[2] = new Option('Limited Liability Partnership','5');

	}else if(statusCompany1 == '14'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Primary Agricultural Credit Society','15');
		sub.options[2] = new Option('Co-operative Bank other than a primary agricultural credit society or a primary co-operative agricultural and rural development bank','17');
		sub.options[3] = new Option('Primary Co-operative Agricultural and Rural Development bank','16');
		sub.options[4] = new Option('Society Registered under Societies Registration Act-1860 or any law corresponding to that state','11');
		sub.options[5] = new Option('Other Cooperative Society','4');
		sub.options[6] = new Option('Trust other than trust eligible to file return in ITR-7','13');
		sub.options[7] = new Option('Investment Fund','21');
		sub.options[8] = new Option('Business Trust','20');
		sub.options[9] = new Option('Any other AOP/BOI','8');
		 
	}else if(statusCompany1 == '9'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Estate of the deceased','12');
		sub.options[2] = new Option('Estate of the insolvent','18');
		sub.options[3] = new Option('Other AJP','19');

	}else{
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','');
	}

}

function setCountryForStateItr5(){


	try {

		var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
		var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

		if(state.value=='99' ){

			country.value = '';

		} else if(state.value==''){

			country.value = '';

		}else{

			country.value = "91";

		}

	} catch (e) {
	}
}


function checkPinOnStateChangeVer()
{
	var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	if ( state.value == "99" || country.value != "91")
	{
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].value="";
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].disabled=false;

	}
	else
	{
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value="";
	}

}

function checkPinOnCountryChangeVer()
{
	var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	var zipCode =document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value
	if (country.value == "91" || country.value== "-1"){
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value="";
	}
	else
	{
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].value="";
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].disabled=false;


	}

}

function setStateForCountryitr5(){

	var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	try{
		if(country.value=='91'){

			state.value = '';

		} else if(country.value!='91'){
			state.value = "99";

		}
	}catch (e) {
	}
}

function populateZipCodeVer(){

	var zipCodeCheck= document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0];
	var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];

	if(zipCodeCheck.checked==true && country.value !='91' && country.value !="" ){

		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value="XXXXXX";
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].readOnly=true;
		zipCodeCheck.value=true;

	}else{

		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value="";
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].readOnly=false;
		zipCodeCheck.value=false;
	}

}

function checkPinZipOnload()
{
	var state = document.getElementsByName('partAGEN1.orgFirmInfo.address.stateCode')[0];
	var country = document.getElementsByName('partAGEN1.orgFirmInfo.address.country')[0];
	var zipCode =document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value

	if (country.value == "91" || country.value== "-1"){
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].value="";

	}
	else
	{
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].disabled=false;

		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].disabled=true;
		document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode')[0].value="";
		if(zipCode=="XXXXXX"){

			document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].readOnly=true;
			document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=true;
		}else{

			document.getElementsByName('partAGEN1.orgFirmInfo.address.zipCode')[0].readOnly=false;
			document.getElementsByName('partAGEN1.orgFirmInfo.address.pinCode.pChosenCheckBox')[0].checked=false;
		}

	}

}

function priBankMandtry() {
	try{
		var bankDtlflag = document
		.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].value;
		var bankName = document
		.getElementsByName('itr.scheduleBA[0].bankName')[0].value;
		var ifscCode = document
		.getElementsByName('itr.scheduleBA[0].ifscCode')[0].value;
		var bankAcctNo = document.getElementsByName('itr.scheduleBA[0].accNo')[0].value;

		var countOfCheckBox = 0;
		var disbaledornot = true;


		var tab = document.getElementById('scheduleBAnk');
		var allInputTags = tab.getElementsByTagName('input');


		for (var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("useForRefund$")){
				if(allInputTags[i].checked==true&&allInputTags[i].disabled!=true){
					allInputTags[i].value=true;
					countOfCheckBox++;
				}else{
					if(allInputTags[i].disabled!=true){
						allInputTags[i].value=false;
					}else{
						disbaledornot = false;
						allInputTags[i].value="";
					}

				}
			}
		}

		if(countOfCheckBox==0 && disbaledornot== true){
			addErrorXHTML('',
			'Please select atleast one account in which you prefer to get your refund');
			j.setFieldError('itr.scheduleBA[0].useForRefund',
			'Please select atleast one account in which you prefer to get your refund');
		}

		if (bankDtlflag == 'N') {
			if (bankName != "" && (ifscCode == "" || bankAcctNo == "")) {

				addErrorXHTML('',
				'Please fill all the fields under Indian Bank Account details.');
				j
				.setFieldError('itr.refund.depositToBankAccount',
				'Please fill all the fields under Indian Bank Account details.');
			}

			if (ifscCode != "" && (bankName == "" || bankAcctNo == "")) {

				addErrorXHTML('',
				'Please fill all the fields under Indian Bank Account details.');
				j
				.setFieldError('itr.refund.depositToBankAccount',
				'Please fill all the fields under Indian Bank Account details.');
			}

			if (bankAcctNo != "" && (ifscCode == "" || bankName == "")) {

				addErrorXHTML('',
				'Please fill all the fields under Indian Bank Account details.');
				j
				.setFieldError('itr.refund.depositToBankAccount',
				'Please fill all the fields under Indian Bank Account details.');
			}

		}
	}catch(e){
		alert(e.stack);
	}
}
function calculateAggregateIncome(){


	var aggregateIncomeFirst=0;
	aggregateIncomeFirst=eval(
			parseInt(coalesceSetRet('partBTI.totalIncome'),10)
			- parseInt(coalesceSetRet('partBTI.incomeChargeableTotTax'),10)
	);
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	if(status=='14' || status == '9' ){
		if (parseInt(aggregateIncomeFirst, 10) > getExemption()) {
			document.getElementsByName('partBTI.aggregateIncome')[0].value = zeroOrMore(eval(
					parseInt(aggregateIncomeFirst,10)+
					parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'),10)));

		} else {
			document.getElementsByName('partBTI.aggregateIncome')[0].value = 0;
		}

	}else{

		document.getElementsByName('partBTI.aggregateIncome')[0].value = zeroOrMore(eval(
				parseInt(aggregateIncomeFirst,10)+
				parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'),10)));
	}
}

function calculateRebateAgriculture(){

	var rebateAgriculture = document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0];
	var exemption =  parseInt(getExemption(), 10);
	var agricultureIncome = parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'),10);
	if (agricultureIncome == 0){

		exemption = 0;
	}
	var netAgriIncome=0;
	var aggregateIncomeFirst=0;

	aggregateIncomeFirst=eval(
			parseInt(coalesceSetRet('partBTI.totalIncome'),10)
			- parseInt(coalesceSetRet('partBTI.incomeChargeableTotTax'),10)
	);

	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatusCompany = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if((status=='14' &&  (substatusCompany != '7' && substatusCompany != '13' && substatusCompany != '12')) || status == '9' ){

		if (parseInt(aggregateIncomeFirst, 10) > getExemption()) {
			var rebateCalc = calculateTaxPayableOnTotalInc(zeroOrMore( eval( parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'),10) + parseInt(exemption, 10))));
			rebateAgriculture.value=eval(rebateCalc);
		} else {
			document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].value = 0;
		}

	}else{
		setEditableFieldValue(rebateAgriculture,calculateTaxPayableOnTotalInc(zeroOrMore( eval( parseInt(coalesceSetRet('partBTI.netAgricultureIncomeOrOtherIncomeForRate'),10) + parseInt(exemption, 10)))));

	}

}

function subStatusOnLoad()
{

	var statusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	var statusCompany1 = statusCompany.value;

	var sub = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0];
	var sub1 = sub.value;

	if(statusCompany1 == '1'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Partnership Firm','10');
		sub.options[2] = new Option('Limited Liability Partnership','5');

	}else if(statusCompany1 == '14'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Primary Agricultural Credit Society','15');
		sub.options[2] = new Option('Co-operative Bank other than a primary agricultural credit society or a primary co-operative agricultural and rural development bank','17');
		sub.options[3] = new Option('Primary Co-operative Agricultural and Rural Development bank','16');
		sub.options[4] = new Option('Society Registered under Societies Registration Act-1860 or any law corresponding to that state','11');
		sub.options[5] = new Option('Other Cooperative Society','4');
		sub.options[6] = new Option('Trust other than trust eligible to file return in ITR-7','13');
		sub.options[7] = new Option('Investment Fund','21');
		sub.options[8] = new Option('Business Trust','20');
		sub.options[9] = new Option('Any other AOP/BOI','8');
		
	}else if(statusCompany1 == '9'){
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','-1');
		sub.options[1] = new Option('Estate of the deceased','12');
		sub.options[2] = new Option('Estate of the insolvent','18');
		sub.options[3] = new Option('Other AJP','19');

	}else{
		for(var i=0;sub.options.length > 0;i++){
			sub.options.remove(0);
		}
		sub.options[0] = new Option('Select','');
	}
	sub.value =sub1;
}

function enableBankDtls(){
	try{
		enableTableForNRI('itr.scheduleBA.bankDtlsFlag', 'Y', 'scheduleBAnk');

		var tab = document.getElementById('scheduleBAnk');
		var allInputTags = tab.getElementsByTagName('input');


		for (var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("useForRefund$")){
				if(allInputTags[i].disabled==true){
					allInputTags[i].checked=false;
				}
			}
		}

		enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].ibanSwiftCode');
		enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].bankName');
		enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].countryCode');
		enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].bankAccountNo');


	}catch(e){
		alert(e.stack);
	}


}

function enableBankDtlsOnload(){
	try{
		if(document.getElementsByName('itr.scheduleBA.foreignBankDtls[0].ibanSwiftCode')[0].value!="")
			document.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].value = 'N';
		enableTableForNRI('itr.scheduleBA.bankDtlsFlag', 'Y', 'scheduleBAnk');

		var tab = document.getElementById('scheduleBAnk');
		var allInputTags = tab.getElementsByTagName('input');


		for (var i = 0; i < allInputTags.length; i++) {
			if (allInputTags[i].name.match("useForRefund$")){
				if(allInputTags[i].disabled==true){
					allInputTags[i].checked=false;
				}
			}
		}
		if(document.getElementsByName('itr.scheduleBA.foreignBankDtls[0].ibanSwiftCode')[0].value==""){
			enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].ibanSwiftCode');
			enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].bankName');
			enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].countryCode');
			enableField('itr.scheduleBA.bankDtlsFlag','N','itr.scheduleBA.foreignBankDtls[0].bankAccountNo');
		}



	}catch(e){
		alert(e.stack);
	}


}

function enableGen2ForPDTAOT(){

	var substatusCompany = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var pan=document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var fourth;
	if(pan!=undefined && pan!=''){
		pan = pan.toUpperCase();
		fourth= pan.charAt(3);
	}

	if(substatusCompany==7 || substatusCompany==13){
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value = 'NO';
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].disabled = false;
	}else
	{
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value = '';
	}
}

function enableGen2ForPDTAOTOnLoad(){

	var substatusCompany = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var pan=document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var fourth;
	if(pan!=undefined && pan!=''){
		pan = pan.toUpperCase();
		fourth= pan.charAt(3);
	}

	if(substatusCompany==7 || substatusCompany==13){
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].value = 'NO';
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.partnerForeignCompFlg')[0].disabled = true;
		document.getElementsByName('partAGEN2.partnerOrMemberInfo.totIncFrmMemberOfAop')[0].disabled = false;
	}
}

function enableFieldsPDTAOT(){
	var substatusCompany = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

	if(substatusCompany==7 || substatusCompany==13 || substatusCompany==12  || substatusCompany==18 ){
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = false;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = false;
	}else{
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtNormalRatesOnAggrInc')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.taxAtSpecialRates')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.rebateAgriculture')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.taxPayableOnTI.surchargeOn2F')[0].readOnly = true;
		document.getElementsByName('partBTTI.computationOfTaxLiability.educationCess')[0].readOnly = true;
		surchargeEditable();
	}

}

function populateBankFlg()
{

	var residentialStatus  = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	if(residentialStatus == 'RES')
	{
		document.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].value = 'Y';
		document.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].disabled=true;
	}else
	{
		document.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].disabled=false;
	}

	enableBankDtlsOnload();
}



function setPartAGen2PinZipOnLoad(){

	var table = document.getElementById('partAGEN2PartnerOrMemberInfoTable');
	var rowCount = table.rows.length;
	var state ;
	var country ;

	for(var i=0 ;i<rowCount-4;i++){

		state = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.stateCode')[0].value;
		country = document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.country')[0].value;

		if(country == '91' ){
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.zipCode')[0].value='';
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.zipCode')[0].disabled=true;
		}else if(state =='99'){
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.pinCode')[0].value='';
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.pinCode')[0].disabled=true;
		}else{
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.zipCode')[0].value='';
			document.getElementsByName('partAGEN2.partnerOrMemberInfo['+i+'].addressDetail.zipCode')[0].disabled=true;
		}
	}

}

function setSchHPPinZipOnLoad(){

	var totHp=eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent)-1);

	var state ;
	var country ;

	for(var i=0 ;i<totHp;i++){

		state = document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.stateCode')[0].value;
		country = document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.country')[0].value;

		if(country == '91' ){
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.zipCode')[0].value='';
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.zipCode')[0].disabled=true;
		}else if(state =='99'){
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.pinCode')[0].value='';
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.pinCode')[0].disabled=true;
		}else{
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.zipCode')[0].value='';
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].addressDetail.zipCode')[0].disabled=true;
		}
	}

}

function calcTotalAmt(tableId){

	var tab1 = document.getElementById('schEIMinorChild');
	var noOfRows=tab1.rows.length;
	var sum = 0;
	var amt = 0;

	for ( var i = 0; i < (noOfRows-2); i++) {
		amt = document.getElementsByName('scheduleEI.othersInc['+i+'].othAmount')[0].value;
		sum = eval(parseInt(sum,10) + parseInt(coalesce(amt),10));

	}
	document.getElementsByName('scheduleEI.others')[0].value = parseInt(sum,10);
}

function validateAuditDtls() {

	var tab = document.getElementById('othSecDateTabId1');
	var allInputTags = tab.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("auditReportAct$") && allInputTags[i+1].name.match("auditReportSection$") && allInputTags[i+2].name.match("auditReportDate$")) {
			if(allInputTags[i+2].value!='' && (allInputTags[i].value=='' || allInputTags[i+1].value=='')){
				addError(allInputTags[i],'Please fill all the fields under Audit details.',true);
				j.setFieldError(allInputTags[i].name,'Please fill all the fields under Audit details.');
			}
		}
	}
}

function genWarningMsgForNRI() {

	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var bankDtlsFlg = document.getElementsByName('itr.scheduleBA.bankDtlsFlag')[0].value;
	if( resStatus == 'NRI' && bankDtlsFlg == 'N' ){
		addErrorXHTML('','Currently refund will be credited to a bank account located in India and not to a bank account located in a foreign country.');
		j.setFieldError('itr.scheduleBA.bankDtlsFlag','Currently refund will be credited to a bank account located in India and not to a bank account located in a foreign country.');
	}
}

function displayWarningOsSec115BBDA(elem){

	var secValue = elem.value;

	if(secValue=='5BBDA'){

		addErrorXHTML('','Please enter the amount, if Dividend income from domestic company exceeds Rs.10 lakh.');

	}


}

function validateOsBbdaLottery(){

	var taxon15BDA0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/6'),10)));
	var taxon15BDA1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/9'),10)+parseInt(taxon15BDA0,10)));
	var taxon15BDA2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/12'),10)+parseInt(taxon15BDA1,10)));
	var taxon15BDA3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/3'),10)+parseInt(taxon15BDA2,10)));
	var taxon15BDA4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto31/3'),10)));


	var totalBBDAtax = eval(parseInt(taxon15BDA3,10)+parseInt(taxon15BDA4,10));


	var taxonLottery0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/6'),10)));
	var taxonLottery1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/9'),10)+parseInt(taxonLottery0,10)));
	var taxonLottery2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/12'),10)+parseInt(taxonLottery1,10)));
	var taxonLottery3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/3'),10)+parseInt(taxonLottery2,10)));
	var taxonLottery4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto31/3'),10)));

	var totalLotteryTax = eval(parseInt(taxonLottery3,10)+parseInt(taxonLottery4,10));

	var BBDA=zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA'),10)));

	if(BBDA != totalBBDAtax){
		addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA')[0],'The total of all the quarter of Dividend Income u/s 115BBDA must be equal to the figures of 1fii of OS',true);
		j.setFieldError('scheduleOS.incChargblSplRateOS.winningFrmLotteries',"The total of all the quarter of Dividend Income u/s 115BBDA must be equal to the figures of 1fii of OS");
	}

	var lottery=zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.winningFrmLotteries'),10)));

	if(lottery != totalLotteryTax){
		addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.winningFrmLotteries')[0],'The total of all the quarter of Income from Lottery must be equal to the figures of 1fi of OS',true);
		j.setFieldError('scheduleOS.incChargblSplRateOS.winningFrmLotteries',"The total of all the quarter of Income from Lottery must be equal to the figures of 1fi of OS");
	}
}



function calculatedon100Total()
{
	var table = document.getElementById('ded100PerWithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].eligibleDonationTotal')[0].value  = eval(parseInt(coalesce(donationAmtCash.value,10)))
				+ eval(parseInt(coalesce(donationAmtOther.value,10)));

	}

	calculatedon100TotalCash();
	//calculatedon100Eligible();
	//calculateTotEligAmt();
	calculateTotal80G();

}
function calculatedon100TotalCash()
{
	var table = document.getElementById('ded100PerWithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));
	}

	document.getElementsByName('schedule80G.don100Percent.totDon100PercentCash')[0].value  = sumCash;
	document.getElementsByName('schedule80G.don100Percent.totDon100PercentOtherMode')[0].value  = sumOther;

	document.getElementsByName('schedule80G.don100Percent.totDon100Percent')[0].value
	= eval(parseInt(coalesce(sumCash,10)))
	+ eval(parseInt(coalesce(sumOther,10)));
}


function calculatedon100Eligible()
{
	var table = document.getElementById('ded100PerWithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		if(donationAmtCash.value <= 2000)
		{

			document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtCash.value,10)))
					+ eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

		else
		{
			document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

	}

	calculateTotEligAmt();


}


function calculateTotEligAmt()
{
	var table = document.getElementById('ded100PerWithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumelig=0;

	for (var i = 0; i < totRow; i++) {

		var eligibleDonationAmt = document.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].eligibleDonationAmt')[0];


		sumelig += eval(parseInt(coalesce(eligibleDonationAmt.value,10)));

	}

	document.getElementsByName('schedule80G.don100Percent.totEligibleDon100Percent')[0].value  = sumelig;

}


function calculatedon50Total()
{
	var table = document.getElementById('ded50WithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].eligibleDonationTotal')[0].value  = eval(parseInt(coalesce(donationAmtCash.value,10)))
				+ eval(parseInt(coalesce(donationAmtOther.value,10)));

	}

	calculatedon50TotalCash();
	//calculatedon50Eligible();
	//calculatedon50TotEligAmt();
	calculateTotal80G();

}


function calculatedon50TotalCash()
{
	var table = document.getElementById('ded50WithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));
	}

	document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentCash')[0].value  = sumCash;
	document.getElementsByName('schedule80G.don50PercentNoApprReqd.don50PercentOtherMode')[0].value  = sumOther;

	document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentNoApprReqd')[0].value
	= eval(parseInt(coalesce(sumCash,10)))
	+ eval(parseInt(coalesce(sumOther,10)));
}


function calculatedon50Eligible()
{
	var table = document.getElementById('ded50WithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		if(donationAmtCash.value <= 2000)
		{

			document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtCash.value,10)))
					+ eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

		else
		{
			document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

	}

	calculatedon50TotEligAmt();


}


function calculatedon50TotEligAmt()
{
	var table = document.getElementById('ded50WithoutQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumelig=0;

	for (var i = 0; i < totRow; i++) {

		var eligibleDonationAmt = document.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].eligibleDonationAmt')[0];


		sumelig += eval(parseInt(coalesce(eligibleDonationAmt.value,10)));

	}

	document.getElementsByName('schedule80G.don50PercentNoApprReqd.totEligibleDon50Percent')[0].value  = sumelig;

}

function calculatedon100ApprTotal()
{
	var table = document.getElementById('ded100Qual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].eligibleDonationTotal')[0].value  = eval(parseInt(coalesce(donationAmtCash.value,10)))
				+ eval(parseInt(coalesce(donationAmtOther.value,10)));

	}

	calculatedon100ApprTotalCash();
	//calculatedon100ApprEligible();
	//calculatedon100ApprTotEligAmt();
	calculateTotal80G();

}


function calculatedon100ApprTotalCash()
{
	var table = document.getElementById('ded100Qual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));
	}

	document.getElementsByName('schedule80G.totDon100PercentApprReqd.totDon100PercentApprReqdCash')[0].value  = sumCash;
	document.getElementsByName('schedule80G.totDon100PercentApprReqd.totDon100PercentApprReqdOtherMode')[0].value  = sumOther;

	document.getElementsByName('schedule80G.don100PercentApprReqd.totDon100PercentApprReqd')[0].value
	= eval(parseInt(coalesce(sumCash,10)))
	+ eval(parseInt(coalesce(sumOther,10)));
}


function calculatedon100ApprEligible()
{
	var table = document.getElementById('ded100Qual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		if(donationAmtCash.value <= 2000)
		{

			document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtCash.value,10)))
					+ eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

		else
		{
			document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

	}

	calculatedon100ApprTotEligAmt();


}


function calculatedon100ApprTotEligAmt()
{
	var table = document.getElementById('ded100Qual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumelig=0;

	for (var i = 0; i < totRow; i++) {

		var eligibleDonationAmt = document.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].eligibleDonationAmt')[0];


		sumelig += eval(parseInt(coalesce(eligibleDonationAmt.value,10)));

	}

	document.getElementsByName('schedule80G.don100PercentApprReqd.totEligibleDon100PercentApprReqd')[0].value  = sumelig;

}



function calculatedon50PercentApprTotal()
{
	var table = document.getElementById('ded50WithQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].eligibleDonationTotal')[0].value  = zeroOrMore(eval(parseInt(coalesce(donationAmtCash.value,10)))
						+ eval(parseInt(coalesce(donationAmtOther.value,10))));

	}

	calculatedon50PercentApprTotalCash();
	//calculatedon50PercentApprEligible();
	//calculatedon50PercentApprTotEligAmt();
	calculateTotal80G();

}


function calculatedon50PercentApprTotalCash()
{
	var table = document.getElementById('ded50WithQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));
	}

	document.getElementsByName('schedule80G.don50PercentApprReqd.totdon50PercentApprReqdCash')[0].value  = sumCash;
	document.getElementsByName('schedule80G.don50PercentApprReqd.totdon50PercentApprReqdOtherMode')[0].value  = sumOther;

	document.getElementsByName('schedule80G.don50PercentApprReqd.totDon50PercentApprReqd')[0].value
	= eval(parseInt(coalesce(sumCash,10)))
	+ eval(parseInt(coalesce(sumOther,10)));
}


function calculatedon50PercentApprEligible()
{
	var table = document.getElementById('ded50WithQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0];

		if(donationAmtCash.value <= 2000)
		{

			document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtCash.value,10)))
					+ eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

		else
		{
			document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
					+ '].eligibleDonationAmt')[0].value
					= eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

	}

	calculatedon50PercentApprTotEligAmt();


}


function calculatedon50PercentApprTotEligAmt()
{
	var table = document.getElementById('ded50WithQual');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumelig=0;

	for (var i = 0; i < totRow; i++) {

		var eligibleDonationAmt = document.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].eligibleDonationAmt')[0];


		sumelig += zeroOrMore(eval(parseInt(eligibleDonationAmt.value,10)));

	}

	document.getElementsByName('schedule80G.don50PercentApprReqd.totEligibleDon50PercentApprReqd')[0].value  = sumelig;

}

function calculateTotal80G()
{
	var totDon100Percent = document.getElementsByName('schedule80G.don100Percent.totDon100Percent')[0].value;
	var totEligibleDon100Percent = document.getElementsByName('schedule80G.don100Percent.totEligibleDon100Percent')[0].value
	var totDon50PercentNoApprReqd = document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentNoApprReqd')[0].value;
	var totEligibleDon50Percent = document.getElementsByName('schedule80G.don50PercentNoApprReqd.totEligibleDon50Percent')[0].value
	var totDon100PercentApprReqd = document.getElementsByName('schedule80G.don100PercentApprReqd.totDon100PercentApprReqd')[0].value;
	var totEligibleDon100PercentApprReqd = document.getElementsByName('schedule80G.don100PercentApprReqd.totEligibleDon100PercentApprReqd')[0].value
	var totDon50PercentApprReqd = document.getElementsByName('schedule80G.don50PercentApprReqd.totDon50PercentApprReqd')[0].value;
	var totEligibleDon50PercentApprReqd = document.getElementsByName('schedule80G.don50PercentApprReqd.totEligibleDon50PercentApprReqd')[0].value

	var totDon100PercentCash = document.getElementsByName('schedule80G.don100Percent.totDon100PercentCash')[0].value
	var totDon50PercentCash = document.getElementsByName('schedule80G.don50PercentNoApprReqd.totDon50PercentCash')[0].value
	var totDon100PercentApprReqdCash = document.getElementsByName('schedule80G.totDon100PercentApprReqd.totDon100PercentApprReqdCash')[0].value
	var totdon50PercentApprReqdCash = document.getElementsByName('schedule80G.don50PercentApprReqd.totdon50PercentApprReqdCash')[0].value

	var totDon100PercentOtherMode = document.getElementsByName('schedule80G.don100Percent.totDon100PercentOtherMode')[0].value
	var don50PercentOtherMode = document.getElementsByName('schedule80G.don50PercentNoApprReqd.don50PercentOtherMode')[0].value
	var totDon100PercentApprReqdOtherMode = document.getElementsByName('schedule80G.totDon100PercentApprReqd.totDon100PercentApprReqdOtherMode')[0].value
	var totdon50PercentApprReqdOtherMode = document.getElementsByName('schedule80G.don50PercentApprReqd.totdon50PercentApprReqdOtherMode')[0].value


	document.getElementsByName('schedule80G.totalDonationsUs80GCash')[0].value
	= zeroOrMore(eval(parseInt(coalesce(totDon100PercentCash,10)))
			+ eval(parseInt(coalesce(totDon50PercentCash,10)))
			+ eval(parseInt(coalesce(totDon100PercentApprReqdCash,10)))
			+ eval(parseInt(coalesce(totdon50PercentApprReqdCash,10))));


	document.getElementsByName('schedule80G.totalDonationsUs80GOtherMode')[0].value
	= zeroOrMore(eval(parseInt(coalesce(totDon100PercentOtherMode,10)))
			+ eval(parseInt(coalesce(don50PercentOtherMode,10)))
			+ eval(parseInt(coalesce(totDon100PercentApprReqdOtherMode,10)))
			+ eval(parseInt(coalesce(totdon50PercentApprReqdOtherMode,10))));





	document.getElementsByName('schedule80G.totalDonationsUs80G')[0].value
	= zeroOrMore(eval(parseInt(coalesce(totDon100Percent,10)))
			+ eval(parseInt(coalesce(totDon50PercentNoApprReqd,10)))
			+ eval(parseInt(coalesce(totDon100PercentApprReqd,10)))
			+ eval(parseInt(coalesce(totDon50PercentApprReqd,10))));

	document.getElementsByName('schedule80G.totalEligibleDonationsUs80G')[0].value
	= zeroOrMore(eval(parseInt(coalesce(totEligibleDon100Percent,10)))
			+ eval(parseInt(coalesce(totEligibleDon50Percent,10)))
			+ eval(parseInt(coalesce(totEligibleDon100PercentApprReqd,10)))
			+ eval(parseInt(coalesce(totEligibleDon50PercentApprReqd,10))));

}



function enableDirecComp(){

	var partnerInFirm = document.getElementsByName('partAGEN1.filingStatus.partnerInFirm')[0].value;

	if(partnerInFirm == "Y"){
		enableTable('partAGEN1.filingStatus.partnerInFirm',
				'Y', 'partnerInFirm');
	}else{
		var tabId = "#" + "partnerInFirm";
		$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		deleteRowTable('partnerInFirm', 1, 1);
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find('.addbtn').prop('hidden', true);
	}

	var unlistedShares = document.getElementsByName('partAGEN1.filingStatus.unlistedShares')[0].value;


	if(unlistedShares == "Y"){
		enableTable('partAGEN1.filingStatus.unlistedShares',
				'Y', 'UnlistedShares');
	}else{
		var tabId = "#" + "UnlistedShares";
		$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		deleteRowTable('UnlistedShares', 3, 1);
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find('.addbtn').prop('hidden', true);
	}

}


function validate80GTableAForCashAndOtherMode() {
	var tab = document.getElementById('ded100PerWithoutQual');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 4); i++) {
		var doneeName = document
		.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].doneeName')[0].value;

		var donationAmtCash = document
		.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtCash')[0].value;

		var donationAmtOther = document
		.getElementsByName('schedule80G.don100Percent.doneeDetail[' + i
				+ '].donationAmtOther')[0].value;

		if (doneeName != '') {
			if (donationAmtCash == '' && donationAmtOther == '') {
				addErrorXHTML(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table A');

				j
				.setFieldError(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table A ');

				return;
			}

		}
	}
}
function validate80GTableBForCashAndOtherMode() {
	var tab = document.getElementById('ded50WithoutQual');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 4); i++) {
		var doneeName = document
		.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].doneeName')[0].value;

		var donationAmtCash = document
		.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0].value;

		var donationAmtOther = document
		.getElementsByName('schedule80G.don50PercentNoApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0].value;

		if (doneeName != '') {
			if (donationAmtCash == '' && donationAmtOther == '') {
				addErrorXHTML(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table B');

				j
				.setFieldError(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table B ');

				return;
			}

		}
	}
}
function validate80GTableCForCashAndOtherMode() {
	var tab = document.getElementById('ded100Qual');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 4); i++) {
		var doneeName = document
		.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].doneeName')[0].value;

		var donationAmtCash = document
		.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0].value;

		var donationAmtOther = document
		.getElementsByName('schedule80G.don100PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0].value;

		if (doneeName != '') {
			if (donationAmtCash == '' && donationAmtOther == '') {
				addErrorXHTML(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table C');

				j
				.setFieldError(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table C ');

				return;
			}

		}
	}
}
function validate80GTableDForCashAndOtherMode() {
	var tab = document.getElementById('ded50WithQual');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 4); i++) {
		var doneeName = document
		.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].doneeName')[0].value;

		var donationAmtCash = document
		.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtCash')[0].value;

		var donationAmtOther = document
		.getElementsByName('schedule80G.don50PercentApprReqd.doneeDetail[' + i
				+ '].donationAmtOther')[0].value;

		if (doneeName != '') {
			if (donationAmtCash == '' && donationAmtOther == '') {
				addErrorXHTML(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table D');

				j
				.setFieldError(
						'',
				'Enter the amount of donation either in field Donation in cash or Donation in other mode in Table D ');

				return;
			}

		}
	}
}





/*Manufacturing*/


function calcManufacTotalA()
{
	var openingStockRawMaterial = document.getElementsByName('partama.openingInventory.openingStockRawMaterial')[0].value;
	var openingStockWip = document.getElementsByName('partama.openingInventory.openingStockWip')[0].value;

	document.getElementsByName('partama.openingInventory.openingStocktotalAiii')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStockRawMaterial,10)))
			+ eval(parseInt(coalesce(openingStockWip,10))));

	calculateOpeningStkTotal();

}

function calcManufacTotalD()
{
	var openingStockcarInward = document.getElementsByName('partama.openingInventory.openingStockcarInward')[0].value;
	var openingStockpowerandfuel = document.getElementsByName('partama.openingInventory.openingStockpowerandfuel')[0].value;
	var openingStockOtherDirectExpenses = document.getElementsByName('partama.openingInventory.openingStockOtherDirectExpenses')[0].value;

	document.getElementsByName('partama.openingInventory.openingStockdirectExpenses')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStockcarInward,10)))
			+ eval(parseInt(coalesce(openingStockpowerandfuel,10)))
			+ eval(parseInt(coalesce(openingStockOtherDirectExpenses,10))));

	calculateOpeningStkTotal();

}

function calcManufacTotalE()
{
	var openingStockindirectWages = document.getElementsByName('partama.openingInventory.openingStockindirectWages')[0].value;
	var openingStockfactoryRentandRates = document.getElementsByName('partama.openingInventory.openingStockfactoryRentandRates')[0].value;
	var openingStockFactoryInsurance = document.getElementsByName('partama.openingInventory.openingStockFactoryInsurance')[0].value;
	var openingStockfactoryFuelPower = document.getElementsByName('partama.openingInventory.openingStockfactoryFuelPower')[0].value;
	var openingStockfactoryGeneral = document.getElementsByName('partama.openingInventory.openingStockfactoryGeneral')[0].value;
	var openingStockdepOffactory = document.getElementsByName('partama.openingInventory.openingStockdepOffactory')[0].value;

	document.getElementsByName('partama.openingInventory.openingStocktotalE')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStockindirectWages,10)))
			+ eval(parseInt(coalesce(openingStockfactoryRentandRates,10)))
			+ eval(parseInt(coalesce(openingStockFactoryInsurance,10)))
			+ eval(parseInt(coalesce(openingStockfactoryFuelPower,10)))
			+ eval(parseInt(coalesce(openingStockfactoryGeneral,10)))
			+ eval(parseInt(coalesce(openingStockdepOffactory,10))));

	calculateOpeningStkTotal();

}


function calculateOpeningStkTotal()
{

	var openingStocktotalAiii  = document.getElementsByName('partama.openingInventory.openingStocktotalAiii')[0].value;
	var openingStockPurchase  = document.getElementsByName('partama.openingInventory.openingStockPurchase')[0].value;
	var openingStockdirectWages  = document.getElementsByName('partama.openingInventory.openingStockdirectWages')[0].value;
	var openingStockdirectExpenses  = document.getElementsByName('partama.openingInventory.openingStockdirectExpenses')[0].value;
	var openingStocktotalE  = document.getElementsByName('partama.openingInventory.openingStocktotalE')[0].value;

	document.getElementsByName('partama.openingInventory.openingStocktotalF')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStocktotalAiii,10)))
			+ eval(parseInt(coalesce(openingStockPurchase,10)))
			+ eval(parseInt(coalesce(openingStockdirectWages,10)))
			+ eval(parseInt(coalesce(openingStockdirectExpenses,10)))
			+ eval(parseInt(coalesce(openingStocktotalE,10))));

	calcManufacturingTotal();

}

function calcClosingStockTotal()
{

	var rawMaterial  = document.getElementsByName('partama.closingStock.rawMaterial')[0].value;
	var WorkinProgress  = document.getElementsByName('partama.closingStock.WorkinProgress')[0].value;

	document.getElementsByName('partama.closingStock.totalOf2')[0].value
	= zeroOrMore(eval(parseInt(coalesce(rawMaterial,10)))
			+ eval(parseInt(coalesce(WorkinProgress,10))));

	calcManufacturingTotal();

}


function calcManufacturingTotal()
{

	var openingStocktotalF  = document.getElementsByName('partama.openingInventory.openingStocktotalF')[0].value;
	var totalOf2  = document.getElementsByName('partama.closingStock.totalOf2')[0].value;

	document.getElementsByName('partama.closingStock.total1and2')[0].value
	= eval(parseInt(coalesce(openingStocktotalF,10)))
	- eval(parseInt(coalesce(totalOf2,10)));

	document.getElementsByName('partatr.revFromOperations.costOfGoodsFromMnf')[0].value   = document.getElementsByName('partama.closingStock.total1and2')[0].value;

	calculateManTrading();
}





function calcTotSchTradingRev(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('otherOperatingRevenue');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}

	document.getElementsByName('partatr.revFromOperations.otherOperatingRevTotal')[0].value = amtTotal;
	calcTradingTotalA();
}


function calcTotSchTradingExp(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('otherDirectExpenses');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}


	document.getElementsByName('partatr.revFromOperations.otherDirectExpencesTotal')[0].value = amtTotal;
	calcTradingTotal9();
}


function calcTradingTotalA()
{

	var openingStockRawMaterial  = document.getElementsByName('partatr.revFromOperations.openingStockRawMaterial')[0].value;
	var openingStockWip  = document.getElementsByName('partatr.revFromOperations.openingStockWip')[0].value;
	var otherOperatingRevTotal  = document.getElementsByName('partatr.revFromOperations.otherOperatingRevTotal')[0].value;

	document.getElementsByName('partatr.revFromOperations.openingStocktotalA')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStockRawMaterial,10)))
			+ eval(parseInt(coalesce(openingStockWip,10)))
			+ eval(parseInt(coalesce(otherOperatingRevTotal,10))));

	calcTradingTotalD();

}

function calculateTradingC()
{

	var unionExciseDuty  = document.getElementsByName('partatr.revFromOperations.unionExciseDuty')[0].value;
	var serviceTax  = document.getElementsByName('partatr.revFromOperations.serviceTax')[0].value;
	var vatSalesTax  = document.getElementsByName('partatr.revFromOperations.vatSalesTax')[0].value;
	var centralGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.centralGoodsServiceTax')[0].value;
	var stateGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.stateGoodsServiceTax')[0].value;
	var inteGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.inteGoodsServiceTax')[0].value;
	var unionGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.unionGoodsServiceTax')[0].value;
	var otherGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.otherGoodsServiceTax')[0].value;

	document.getElementsByName('partatr.revFromOperations.totalGoodsServiceTax')[0].value
	= zeroOrMore(eval(parseInt(coalesce(unionExciseDuty,10)))
			+ eval(parseInt(coalesce(serviceTax,10)))
			+ eval(parseInt(coalesce(vatSalesTax,10)))
			+ eval(parseInt(coalesce(centralGoodsServiceTax,10)))
			+ eval(parseInt(coalesce(stateGoodsServiceTax,10)))
			+ eval(parseInt(coalesce(inteGoodsServiceTax,10)))
			+ eval(parseInt(coalesce(unionGoodsServiceTax,10)))
			+ eval(parseInt(coalesce(otherGoodsServiceTax,10))));

	calcTradingTotalD();
}

function calculatePartBTI23FBC()
{

	var deduction10AA23  = document.getElementsByName('partBTI.deductionsUnder10Aor10AA')[0].value;
	var invstfund23FB  = parseInt(coalesceSetRet('partBTI.invstUnder23FBor23FBA'),10);
	var invstfund23FC  = parseInt(coalesceSetRet('partBTI.invstUnder23FCor23FCA'),10);


	document.getElementsByName('partBTI.incomeNtFormtotal')[0].value
	= zeroOrMore(eval(parseInt(coalesce(deduction10AA23,10)))
			+ eval(parseInt(coalesce(invstfund23FB,10)))
			+ eval(parseInt(coalesce(invstfund23FC,10))));

}


function calcTradingTotalD()
{


	var openingStocktotalA  = document.getElementsByName('partatr.revFromOperations.openingStocktotalA')[0].value;
	var grossReceiptsfromPro  = document.getElementsByName('partatr.revFromOperations.grossReceiptsfromPro')[0].value;
	var totalGoodsServiceTax  = document.getElementsByName('partatr.revFromOperations.totalGoodsServiceTax')[0].value;

	document.getElementsByName('partatr.revFromOperations.totalRevFormOperations')[0].value
	= zeroOrMore(eval(parseInt(coalesce(openingStocktotalA,10)))
			+ eval(parseInt(coalesce(grossReceiptsfromPro,10)))
			+ eval(parseInt(coalesce(totalGoodsServiceTax,10))));

	calcTradingTotal6();


}

function calcTradingTotal6()
{


	var totalRevFormOperations  = document.getElementsByName('partatr.revFromOperations.totalRevFormOperations')[0].value;
	var closingStock  = document.getElementsByName('partatr.revFromOperations.closingStock')[0].value;

	document.getElementsByName('partatr.revFromOperations.totalCreditsTradingAcc')[0].value
	= zeroOrMore(eval(parseInt(coalesce(totalRevFormOperations,10)))
			+ eval(parseInt(coalesce(closingStock,10))));

	calculateManTrading();

}


function calcTradingTotal9()
{

	var carriageInward  = document.getElementsByName('partatr.revFromOperations.carriageInward')[0].value;
	var powerAndFuel  = document.getElementsByName('partatr.revFromOperations.powerAndFuel')[0].value;
	var otherDirectExpencesTotal  = document.getElementsByName('partatr.revFromOperations.otherDirectExpencesTotal')[0].value;

	document.getElementsByName('partatr.revFromOperations.directExpenses')[0].value
	= zeroOrMore(eval(parseInt(coalesce(carriageInward,10)))
			+ eval(parseInt(coalesce(powerAndFuel,10)))
			+ eval(parseInt(coalesce(otherDirectExpencesTotal,10))));

	calculateManTrading();
}


function calcTradingTotal10()
{

	var sl10customDuty  = document.getElementsByName('partatr.revFromOperations.sl10customDuty')[0].value;
	var sl10counterveilingDuty  = document.getElementsByName('partatr.revFromOperations.sl10counterveilingDuty')[0].value;
	var sl10SplAddnDuty  = document.getElementsByName('partatr.revFromOperations.sl10SplAddnDuty')[0].value;
	var sl10unionExciseDuty  = document.getElementsByName('partatr.revFromOperations.sl10unionExciseDuty')[0].value;
	var sl10ServiceTax  = document.getElementsByName('partatr.revFromOperations.sl10ServiceTax')[0].value;
	var sl10VATSales  = document.getElementsByName('partatr.revFromOperations.sl10VATSales')[0].value;
	var sl10CentralTax  = document.getElementsByName('partatr.revFromOperations.sl10CentralTax')[0].value;
	var sl10StateTax  = document.getElementsByName('partatr.revFromOperations.sl10StateTax')[0].value;
	var sl10intTax  = document.getElementsByName('partatr.revFromOperations.sl10intTax')[0].value;
	var sl10unionTax  = document.getElementsByName('partatr.revFromOperations.sl10unionTax')[0].value;
	var sl10otherTax  = document.getElementsByName('partatr.revFromOperations.sl10otherTax')[0].value;

	document.getElementsByName('partatr.revFromOperations.sl10Total')[0].value
	= zeroOrMore(eval(parseInt(coalesce(sl10customDuty,10)))
			+ eval(parseInt(coalesce(sl10counterveilingDuty,10)))
			+ eval(parseInt(coalesce(sl10unionExciseDuty,10)))
			+ eval(parseInt(coalesce(sl10ServiceTax,10)))
			+ eval(parseInt(coalesce(sl10VATSales,10)))
			+ eval(parseInt(coalesce(sl10CentralTax,10)))
			+ eval(parseInt(coalesce(sl10StateTax,10)))
			+ eval(parseInt(coalesce(sl10intTax,10)))
			+ eval(parseInt(coalesce(sl10unionTax,10)))
			+ eval(parseInt(coalesce(sl10otherTax,10)))
			+ eval(parseInt(coalesce(sl10SplAddnDuty,10))));
	calculateManTrading();

}

function calculateManTrading()
{
	var totalCreditsTradingAcc  = document.getElementsByName('partatr.revFromOperations.totalCreditsTradingAcc')[0].value;
	var openingStockFinishedGoods  = document.getElementsByName('partatr.revFromOperations.openingStockFinishedGoods')[0].value;
	var purchases  = document.getElementsByName('partatr.revFromOperations.purchases')[0].value;
	var directExpenses  = document.getElementsByName('partatr.revFromOperations.directExpenses')[0].value;
	var sl10Total  = document.getElementsByName('partatr.revFromOperations.sl10Total')[0].value;
	var costOfGoodsFromMnf  = document.getElementsByName('partatr.revFromOperations.costOfGoodsFromMnf')[0].value;


	document.getElementsByName('partatr.revFromOperations.totalofMnfandTrading')[0].value
	= eval(parseInt(coalesce(totalCreditsTradingAcc,10)))
	- eval(parseInt(coalesce(openingStockFinishedGoods,10)))
	- eval(parseInt(coalesce(purchases,10)))
	- eval(parseInt(coalesce(directExpenses,10)))
	- eval(parseInt(coalesce(sl10Total,10)))
	- eval(parseInt(coalesce(costOfGoodsFromMnf,10)));

	document.getElementsByName('partapl.creditsToPL.grossPLTrading')[0].value
	= document.getElementsByName('partatr.revFromOperations.totalofMnfandTrading')[0].value;
}

//Calculate Total Income for Schedule IF
function calcTotSchIF(){
	var amtTotal = parseInt('0' ,10);
	var capTotal = parseInt('0' ,10);
	var tabl = document.getElementById('scheduleIF');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}else if(allInputTags[i].name.match("capitalBalance$")){
			capTotal = eval(parseInt(capTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}
	document.getElementsByName('scheduleIF.totalProfitShareAmt')[0].value = amtTotal;
	document.getElementsByName('scheduleIF.totalFirmCapBalOn31Mar')[0].value = capTotal;
	if(document.getElementsByName('scheduleIF.InforFirm[0].amount')[0].value=='')
		document.getElementsByName('scheduleIF.totalProfitShareAmt')[0].value = NoneOrVal(amtTotal);
	if(document.getElementsByName('scheduleIF.InforFirm[0].capitalBalance')[0].value=='')
		document.getElementsByName('scheduleIF.totalFirmCapBalOn31Mar')[0].value = NoneOrVal(capTotal);


}

function disableDpiitRegNo() {
	var fiiFpiFlag = document.getElementsByName("partAGEN1.filingStatus.dpiit")[0].value;

	if (fiiFpiFlag == 'Y') {
		document.getElementsByName("partAGEN1.filingStatus.dpiitRegnNo")[0].disabled = false;
	} else {
		document.getElementsByName("partAGEN1.filingStatus.dpiitRegnNo")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.dpiitRegnNo")[0].value="";
	}

}

function disableMinisRegNo() {
	var fiiFpiFlag = document.getElementsByName("partAGEN1.filingStatus.minist")[0].value;

	if (fiiFpiFlag == 'Y') {
		document.getElementsByName("partAGEN1.filingStatus.ministRegnNo")[0].disabled = false;
	} else {
		document.getElementsByName("partAGEN1.filingStatus.ministRegnNo")[0].disabled = true;
		document.getElementsByName("partAGEN1.filingStatus.ministRegnNo")[0].value="";
	}

}

function validate80GGA()
{
	var table = document.getElementById('schedule80GGA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInOtherMode')[0];
		if(document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].panOfDonee')[0].value!=''){

			if((donationAmtCash.value==''&&donationAmtOther.value=='') || (donationAmtCash.value==null && donationAmtOther.value==null)|| (donationAmtCash.value==0 && donationAmtOther.value==0) ){
				j.setFieldError(document.getElementsByName('schedule80GGA.scientificResearch[' + i + '].donationInCash')[0],'Enter the amount of donation either in field Donation in cash or Donation in other mode');
				addErrorXHTML(document.getElementsByName('')[0],'Enter the amount of donation either in field Donation in cash or Donation in other mode',true);

			}
		}

	}

}

function calculatedon80GGA()
{
	var table = document.getElementById('schedule80GGA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInOtherMode')[0];

		document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].totalDonation')[0].value  = eval(parseInt(coalesce(donationAmtCash.value,10)))
				+ eval(parseInt(coalesce(donationAmtOther.value,10)));

	}

	calculatedon80GGATotalCash();

}

function calculatedon80GGATotalCash()
{
	var table = document.getElementById('schedule80GGA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInOtherMode')[0];

		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));
	}

	document.getElementsByName('schedule80GGA.donationInCash')[0].value  = sumCash;
	document.getElementsByName('schedule80GGA.donationInOtherMode')[0].value  = sumOther;

	document.getElementsByName('schedule80GGA.totalDonationsUs80GGA')[0].value
	= eval(parseInt(coalesce(sumCash,10)))
	+ eval(parseInt(coalesce(sumOther,10)));
	calculatedon80GGAEligible();
}

function calculatedon80GGAEligible()
{
	var table = document.getElementById('schedule80GGA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumCash=0;
	var sumOther=0;


	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInCash')[0];

		var donationAmtOther = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].donationInOtherMode')[0];

		if(donationAmtCash.value <= 10000)
		{

			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].eligibleAmount')[0].value
					= eval(parseInt(coalesce(donationAmtCash.value,10)))
					+ eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

		else
		{
			document.getElementsByName('schedule80GGA.scientificResearch[' + i
					+ '].eligibleAmount')[0].value
					= eval(parseInt(coalesce(donationAmtOther.value,10)));
		}

	}

	calculate80GGAEligAmt();


}


function calculate80GGAEligAmt()
{
	var table = document.getElementById('schedule80GGA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	var sumelig=0;

	for (var i = 0; i < totRow; i++) {

		var eligibleDonationAmt = document.getElementsByName('schedule80GGA.scientificResearch[' + i
				+ '].eligibleAmount')[0];


		sumelig += eval(parseInt(coalesce(eligibleDonationAmt.value,10)));

	}

	document.getElementsByName('schedule80GGA.totalEligibleDonationsUs80GGA')[0].value  = sumelig;

}

function otherProperty(){
	var totHp = eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent) - 1);
	for (var i = 0; i < totHp; i++) {
		if(document.getElementsByName('scheduleHP.propertyDetails['+i+'].ownerOfProperty')[0].value=='OTH'){
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].otherOwnerOfProperty')[0].style.display='';
		}else{
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].otherOwnerOfProperty')[0].style.display='none';
			document.getElementsByName('scheduleHP.propertyDetails['+i+'].otherOwnerOfProperty')[0].value='';
		}
	}
}




function scheduleCGA5a(){


	document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullConsideration')[0].value =

		eval(coalesceSetRet("scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdOthUnqshr") +
				coalesceSetRet("scheduleCGPost45.shortTermCapGainPost45.nRISecur115AD.fullValueConsdSec50CA"));

}
function calcTotFullConTable()
{
	var tab = document.getElementById('stcg10pctTab');

	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows/16); i++) {


		if(parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdRecvUnqshr')[0].value),10)>parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fairMrktValueUnqshr')[0].value),10)
		){

			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdSec50CA')[0].value=
				parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdRecvUnqshr')[0].value),10);

		}
		else
		{


			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdSec50CA')[0].value=
				parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fairMrktValueUnqshr')[0].value),10);


		}

	}
}

function scheduleCGB6a()
{

	var tab = document.getElementById('stcg10pctTab');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows / 16); i++) {
		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullConsideration')[0].value
		= eval(coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdOthUnqshr') +
				coalesceSetRet('scheduleCGPost45.longTermCapGainPost45.nRIOnSec112and115['+ i +'].fullValueConsdSec50CA'));
	}

}

function scheduleCGB8a(){


	document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullConsideration')[0].value =

		eval(coalesceSetRet("scheduleCGPost45.longTermCapGainPost45.saleofAssetNA.deductSec48.fullValueConsdOthUnqshr") +
				coalesceSetRet("scheduleCGPost45.shortTermCapGainPost45.saleOnOtherAssets.fullConsidtnic"));

}

function removeSectionPTI(sectionArray, rowCount) {
	try {
		for (var i = 0; i < rowCount; i++) {
			var selectsLength = document
			.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
					+ i + '].sourceDescription')[0].options.length;
			for (var k = selectsLength; k > 0; k--) {
				if (document
						.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
								+ i + '].sourceDescription')[0].options[k] != null
								&& sectionArray
								.indexOf(document
										.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
												+ i + '].sourceDescription')[0].options[k].value) != -1) {
					document
					.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
							+ i + '].sourceDescription')[0].remove(k);
					console.log("PTIremove"+k);
				}
			}
		}
	} catch (e) {
		alert(e.stack);
	}
}
function addAllOptionsPTI(allSectionArray, rowCount) {
	for (var i = 0; i < rowCount; i++) {
		var srcDesc = document
		.getElementsByName('scheduleOS.schduleOsincPti.othersGrossDtls['
				+ i + '].sourceDescription')[0];
		var selectedValue = srcDesc.value;
		removeAll(srcDesc);
		for (var k = 0; k < allSectionArray.length; k++) {
			var optn = document.createElement("option");
			optn.text = getSectionTextMap(allSectionArray[k]);
			optn.value = allSectionArray[k];
			srcDesc.options.add(optn);
		}
		srcDesc.value = selectedValue;
	}
}


function validatePLafter61()
{
	//PL 61
	var grossReceipts61 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceipts61')[0].value);
	var grossReceiptsia = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia')[0].value);
	var anyOtherMode = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode')[0].value);
	var presumptive61iia = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia')[0].value);
	var presumptive61iib = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib')[0].value);

	if(grossReceipts61 > 20000000)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceipts61','It is mandatory to maintain books of accounts and have a tax audit under 44AB ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceipts61')[0],
				'It is mandatory to maintain books of accounts and have a tax audit under 44AB ',

				true);
	}

	if(grossReceiptsia < presumptive61iia)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia','62(ii)(a) can not be greater than 62(i)(a). ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia')[0],
				'62(ii)(a) can not be greater than 62(i)(a) ',
				true);
	}

	if(presumptive61iib > anyOtherMode)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib','61(ii)(b) can not be greater than 62(i)(b). ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib')[0],
				'62(ii)(b) can not be greater than 62(i)(b). ',
				true);
	}

	if(presumptive61iia < (grossReceiptsia * 0.06))
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia','If the income is less than 6% of 62(i)(a), it is mandatory to maintain books of accounts and have a tax audit under 44AB ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia')[0],
				'If the income is less than 6% of 62(i)(a), it is mandatory to maintain books of accounts and have a tax audit under 44AB ',
				true);
	}

	if(presumptive61iib < (anyOtherMode * 0.08))
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib','If the income is less than 8% of 62(i)(b), it is mandatory to maintain books of accounts and have a tax audit under 44AB. ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib')[0],
				'If the income is less than 8% of 62(i)(b), it is mandatory to maintain books of accounts and have a tax audit under 44AB. ',
				true);
	}

	//PL 62

	var grossReceipts62 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62')[0].value);
	var presumptive44ADA = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA')[0].value);
	var total4 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.totalOfClm4')[0].value);

	if(grossReceipts62 > 5000000)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62','If Gross Receipts are more than Rs.50 Lakh, it is mandatory to maintain books of accounts and have a tax audit under 44AB ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62')[0],
				'If Gross Receipts are more than Rs.50 Lakh, it is mandatory to maintain books of accounts and have a tax audit under 44AB ',
				true);
	}

	if(presumptive44ADA > grossReceipts62)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA','62(ii) should not be greater than 62(i). ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA')[0],
				'62(ii) should not be greater than 62(i) ',
				true);
	}

	if(presumptive44ADA < (grossReceipts62 * 0.5))
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA','If the income is less than 50% of 63(i), it is mandatory to maintain books of accounts and have a tax audit under 44AB. ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA')[0],
				'If the income is less than 50% of 63(i), it is mandatory to maintain books of accounts and have a tax audit under 44AB. ',
				true);
	}


	if(total4 > 120)
	{
		j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.totalOfClm4','Total of no. of months cannot exceed 120. ');
		addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg.totalOfClm4')[0],
				'Total of no. of months cannot exceed 120. ',
				true);
	}

	//PL 63


	var table = document.getElementById('presumtiveInc44AEReg');
	var rowCount = table.rows.length;
	var totRow = rowCount - 2;

	for (var i = 0; i < totRow; i++)
	{
		var field3 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].capacity')[0].value);
		var field4 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].noOfMonths')[0].value);
		var field5 = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].income')[0].value);

		if(field3<=12)
		{

			if(field5 < (field4 * 7500))
			{
				j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].income','It is mandatory to maintain books of accounts and have a tax audit under 44AB ');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].income')[0],
						'It is mandatory to maintain books of accounts and have a tax audit under 44AB ',
						true);
			}

		}
		else
		{
			if(field5 < (field3 * field4 * 1000))
			{
				j.setFieldError('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].income','It is mandatory to maintain books of accounts and have a tax audit under 44AB ');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AEReg[' + i + '].income')[0],
						'It is mandatory to maintain books of accounts and have a tax audit under 44AB ',
						true);
			}

		}
	}

	//PL 64

		var grossReceipts64ia = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ia')[0].value);
		var grossReceipts64ib = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ib')[0].value);
		var expenses = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.expenses')[0].value);

		var grossReceipts64iaProf = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ia')[0].value);
		var grossReceipts64ibProf = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ib')[0].value);
		var expensesProf = parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.expenses')[0].value);

		if(grossReceipts64ib > grossReceipts64ia)
		{
			j.setFieldError('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ib','Gross Profit cannot exceed the Gross Turnover/Gross Receipts  in schedule Profit and Loss A/c');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.grossReceipts64ib')[0],
				'Gross Profit cannot exceed the Gross Turnover/Gross Receipts  in schedule Profit and Loss A/c',
				true);
		}

		if((grossReceipts64ib ==0) && (expenses >0))
		{
			j.setFieldError('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.expenses','In order to claim Expenses,Gross Profit must be greater than zero in schedule Profit and Loss A/c');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngBuss.expenses')[0],
				'In order to claim Expenses,Gross Profit must be greater than zero in schedule Profit and Loss A/c',
				true);
		}

		if(grossReceipts64ibProf > grossReceipts64iaProf)
		{
			j.setFieldError('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ib','Gross Profit cannot exceed the Gross Turnover/Gross Receipts');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.grossReceipts64ib')[0],
				'Gross Profit cannot exceed the Gross Turnover/Gross Receipts ',
				true);
		}

		if(grossReceipts64ibProf ==0 && (expensesProf>0))
		{
			j.setFieldError('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.expenses','In order to claim Expenses,Gross Profit must be greater than zero');
				addErrorXHTML( document.getElementsByName('partapl.debitsToPL.debitPlAcnt.regularBookOfAccount.assessCarrngProf.expenses')[0],
				'In order to claim Expenses,Gross Profit must be greater than zero ',
				true);
		}


	}




function hideAddButton61() {
	var table = document.getElementById("presumtiveInc44AE");
	var rowCount = table.rows.length;
	var totRow = rowCount - 2;
	if (totRow == 3) {
		document.getElementById('addButton61').style.visibility = 'hidden';
	} else {
		document.getElementById('addButton61').style.visibility = 'visible';
	}

}
function hideAddButton62() {
	var table = document.getElementById("presumtiveInc44AD");
	var rowCount = table.rows.length;
	var totRow = rowCount - 2;

	if (totRow == 3) {
		document.getElementById('addButton62').style.visibility = 'hidden';
	} else {
		document.getElementById('addButton62').style.visibility = 'visible';
	}

}
function hideAddButton63() {

	var table = document.getElementById("presumtiveInc44ADA");
	var rowCount = table.rows.length;
	var totRow = rowCount - 2;

	if (totRow == 3) {
		document.getElementById('addButton63').style.visibility = 'hidden';
	} else {
		document.getElementById('addButton63').style.visibility = 'visible';
	}

}

function hideAddButtonIF() {

	var table1Rows = document.getElementById('scheduleIF').rows.length - 4;

	var numRows =document.getElementsByName('scheduleIF.numberFirm')[0].value;

	var tabl = document.getElementById('scheduleIF');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("nameOfFirm$")) {

			if(allInputTags[i].value!='' && (table1Rows != numRows)){

				j.setFieldError('scheduleIF.numberFirm','Number of firms in which you are partner should match with the number of rows in below table');
				addErrorXHTML( document.getElementsByName('scheduleIF.numberFirm')[0],
						'Number of firms in which you are partner should match with the number of rows in below table',
						true);
			}
		}

	}

	/*	if(numRows > 0 && (table1Rows != numRows)){

	j.setFieldError('scheduleIF.numberFirm','Number of firms in which you are partner should match with the number of rows in below table');
	addErrorXHTML( document.getElementsByName('scheduleIF.numberFirm')[0],
	'Number of firms in which you are partner should match with the number of rows in below table',
	true);
}*/

}


function validateOsBbdaLottery(){

	var taxon15BDA0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/6'),10)));
	var taxon15BDA1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/9'),10)+parseInt(taxon15BDA0,10)));
	var taxon15BDA2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/12'),10)+parseInt(taxon15BDA1,10)));
	var taxon15BDA3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/3'),10)+parseInt(taxon15BDA2,10)));
	var taxon15BDA4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto31/3'),10)));


	var totalBBDAtax = eval(parseInt(taxon15BDA3,10)+parseInt(taxon15BDA4,10));


	var taxonLottery0 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/6'),10)));
	var taxonLottery1 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/9'),10)+parseInt(taxonLottery0,10)));
	var taxonLottery2 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/12'),10)+parseInt(taxonLottery1,10)));
	var taxonLottery3 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/3'),10)+parseInt(taxonLottery2,10)));
	var taxonLottery4 = zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto31/3'),10)));

	var totalLotteryTax = eval(parseInt(taxonLottery3,10)+parseInt(taxonLottery4,10));

	var BBDA=zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA'),10)+parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.dividendIncome115BBDA_PTI'),10)));;


	if(BBDA<totalBBDAtax||BBDA>totalBBDAtax){
		addErrorXHTML(document.getElementsByName('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/6')[0],'The total of all the quarter of Dividend Income u/s 115BBDA must be equal to sum of 115BBDA and PTI-115BBDA of OS',true);
		j.setFieldError('scheduleOS.incFromOwnHorse.dividendIncome115BBDA.Upto15/6',"The total of all the quarter of Dividend Income u/s 115BBDA must be equal to sum of 115BBDA and PTI-115BBDA of OS");
	}

	var lottery=zeroOrMore(eval(parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.winningFrmLotteries'),10)+parseInt(coalesceSetRet('scheduleOS.incChargblSplRateOS.winningFrmLotteries_PTI'),10)));

	if(lottery<totalLotteryTax||lottery>totalLotteryTax){
		addErrorXHTML(document.getElementsByName('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/6')[0],'The total of all the quarter of Income from Lottery must be equal to  sum of 115BB and PTI-115BB Income of OS',true);
		j.setFieldError('scheduleOS.incFromOwnHorse.incomeFromLottery.Upto15/6',"The total of all the quarter Income by way of winnings from Lottery etc. must be equal to 2a of Schedule OS-DTAA 115BB respectively");
	}

}



function siDisable11(){
	try{
		var tableId = document.getElementById('scheduleSI');
		var mainTable = document.getElementById('scheduleSI').rows;
		var noOfRows = tableId.rows.length;
		var lastIndex = eval(parseInt(noOfRows, 10) - 2);

		var secCode;
		for(i=0;i<lastIndex;i++){
			secCode=document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].secCode')[0].value;
			if(secCode!='DTAASTCG'&&secCode!='DTAALTCG'&&secCode!='DTAAOS'){
				document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRatePercent')[0].readOnly=true;
				document.getElementsByName('scheduleSI.splCodeRateTax['+i+'].splRateIncTax')[0].readOnly=true;
			}
		}
	}catch(e){
		alert(e.stack);
	}

}






function validateSharePrice(value){
	var SharePriceName = value.name;
	var prefixValue = value.name.substring(0,value.name.lastIndexOf("."));
	if(coalesceSetRet(SharePriceName)>parseInt('0',10)){
		document.getElementsByName(prefixValue+'.costOfAcquisition')[0].value=parseInt('0',10);
	}
}



function validateSI(){
	if(coalesceSetRet('scheduleSI.splCodeRateTax[13].taxableInc')>parseInt('0',10)&&!coalesceSetRet('scheduleSI.splCodeRateTax[13].splRateIncTax')>parseInt('0',10)){
		j.setFieldError('scheduleSI.splCodeRateTax[13].splRateIncTax','Please enter Tax thereon');
		addErrorXHTML(document.getElementsByName('scheduleSI.splCodeRateTax[13].splRateIncTax')[0],'Please enter Tax thereon',true);
	}
	if(coalesceSetRet('scheduleSI.splCodeRateTax[12].taxableInc')>parseInt('0',10)&&!coalesceSetRet('scheduleSI.splCodeRateTax[12].splRateIncTax')>parseInt('0',10)){
		j.setFieldError('scheduleSI.splCodeRateTax[12].splRateIncTax','Please enter Tax thereon');
		addErrorXHTML(document.getElementsByName('scheduleSI.splCodeRateTax[12].splRateIncTax')[0],'Please enter Tax thereon',true);
	}
	if(coalesceSetRet('scheduleSI.splCodeRateTax[11].taxableInc')>parseInt('0',10)&&!coalesceSetRet('scheduleSI.splCodeRateTax[11].splRateIncTax')>parseInt('0',10)){
		j.setFieldError('scheduleSI.splCodeRateTax[11].splRateIncTax','Please enter Tax thereon');
		addErrorXHTML(document.getElementsByName('scheduleSI.splCodeRateTax[11].splRateIncTax')[0],'Please enter Tax thereon',true);
	}
}


function setSecRespOnSave(){
	var HiddenSec=document.getElementsByName('partAGEN1.filingStatus.secHidden')[0];
	var fileSec=document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var respSec=document.getElementsByName('partAGEN1.filingStatus.returnFileInResp')[0].value;
	if(fileSec=='11'||fileSec=='12'||fileSec=='17'||fileSec=='19'||fileSec=='20'){
		HiddenSec.value=fileSec;
	}else{
		HiddenSec.value=respSec;
	}
}


function validateSecHidden(){
	var HiddenSec=document.getElementsByName('partAGEN1.filingStatus.secHidden')[0];
	if(HiddenSec.value==''){
		j.setFieldError('partAGEN1.filingStatus.secHidden','Either Filed u/s or Filed in response to notice u/s must have to be selected');
		addErrorXHTML(HiddenSec,'Either Filed u/s or Filed in response to notice u/s must have to be selected',true);
	}
}



function setSecResp(){

	var HiddenSec=document.getElementsByName('partAGEN1.filingStatus.secHidden')[0].value;
	var fileSec=document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0];
	var respSec=document.getElementsByName('partAGEN1.filingStatus.returnFileInResp')[0];

	if(HiddenSec=='11'||HiddenSec=='12'||HiddenSec=='17'||HiddenSec=='19'||HiddenSec=='20'){
		fileSec.value=HiddenSec;
	}else if(HiddenSec=='13'||HiddenSec=='14'||HiddenSec=='15'||HiddenSec=='16'||HiddenSec=='18'){
		respSec.value=HiddenSec;
	}else{
		fileSec.value='11';
	}


}




function enableTextFieldOthEiOthNAt() {
	var tab = document.getElementById('scheduleEI1');
	var rowcount = tab.rows.length;
	for (var j = 0; j < rowcount - 2; j++) {

		var nature = document
		.getElementsByName('scheduleEI.schEiOthers['+j+'].incomeType')[0].value;

		if (nature == 'OTH') {
			document.getElementsByName('scheduleEI.schEiOthers['+j+'].othNatOfInc')[0].disabled = false;

		} else {
			document.getElementsByName('scheduleEI.schEiOthers['+j+'].othNatOfInc')[0].disabled = true;

			document.getElementsByName('scheduleEI.schEiOthers['+j+'].othNatOfInc')[0].value = '';
		}

	}
}



function validatePercentA1B1(){
	var table = document.getElementById('scheduleCGstcg1');
	var noOfRows = table.rows.length;
	var total =0.0;
	for (var i = 0; i <noOfRows/14; i++) {
		var tableId = 'scheduleCGstcg_ded'+(i+1);
		var shares = getPercentOfSharecg(tableId);
		if(parseFloat(shares.foreignPerc)> 100 ){
			j.setFieldError('','Total Percentage share cannot be more than 100%');
			addErrorXHTML(document.getElementsByName('')[0],'Total Percentage share cannot be more than 100%');
		}
		if(parseFloat(shares.foreignPerc)!= 100 && parseFloat(shares.foreignPerc)> 0){
			j.setFieldError('','Total Percentage share should be exactly 100%');
			addErrorXHTML(document.getElementsByName('')[0],'Total Percentage share should be exactly 100%');
		}

	}

	var table1 = document.getElementById('scheduleCGltcg1');
	var noOfRows1 = table1.rows.length;
	var total1 =0.0;
	for (var i = 0; i <noOfRows1/14; i++) {
		var tableId = 'scheduleCGltcg1_ded'+(i+1);
		var shares = getPercentOfSharecg(tableId);

		if(parseFloat(shares.foreignPerc)> 100 ){
			j.setFieldError('','Total Percentage share cannot be more than 100%');
			addErrorXHTML(document.getElementsByName('')[0],'Total Percentage share cannot be more than 100%');
		}

		if(parseFloat(shares.foreignPerc)!= 100 && parseFloat(shares.foreignPerc)> 0 ){
			j.setFieldError('','Total Percentage share shoule be exactly 100%');
			addErrorXHTML(document.getElementsByName('')[0],'Total Percentage share shoule be exactly 100%');
		}

	}

}


function getPercentOfSharecg(tableId){
	var tab = document.getElementById(tableId);
	var inputs = tab.getElementsByTagName('input');
	var foreignPerc = 0;

	for(var i =0; i < inputs.length; i++){
		if(inputs[i].name!=undefined && inputs[i].name.match('percentageShare$')){

			var index = inputs[i].name.substr(eval(inputs[i].name.indexOf("["))+1,1);
			foreignPerc = eval(foreignPerc + (mulFloatBy100(inputs[i].value)));

		}
	}
	return {'foreignPerc':foreignPerc/100};
}

function editableCFLFields() {
	var returnFileSec = document
	.getElementsByName('partAGEN1.filingStatus.secHidden')[0].value;

	if (returnFileSec == '12' || returnFileSec == '13' || returnFileSec == '20') {
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly = false;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly = false;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly = false;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly = false;
	} else {
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.hpLossCFTotal')[0].readOnly = true;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.stcgLossCFTotal')[0].readOnly = true;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.ltcgLossCFTotal')[0].readOnly = true;
		document
		.getElementsByName('scheduleCFL.currentAYloss.lossSummaryDetail.othSrcLossRaceHorseCF')[0].readOnly = true;
	}

}
function income115BBF_BP(){
	document.getElementsByName('partBTI.profBusGain.underSecBBF')[0].value=
		eval(parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBF'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.incRecCredPLOthHeads.underSec115BBG'),10)+
				parseInt(coalesceSetRet('itr5ScheduleBP.busSetoffCurYr.profitgainInc.incOfCurYrAfterSetOff'),10));

}

function validateBPforPoint38()
{
	var section7_38 = parseInt(document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7')[0].value);
	var section7A_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7A')[0];  section7A_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7A');
	var section7B_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B')[0];  section7B_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7B');
	var section7B1A_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B1A')[0];  section7B1A_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section7B1A');
	var section8_38 = document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section8')[0];  section8_38.value = coalesceSetRet('itr4ScheduleBP.businessIncOthThanSpec.section8');


	var section7 = parseInt(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7')[0].value);
	var section7a = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7a')[0];  section7a.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7a');
	var section7b1 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b1')[0];  section7b1.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b1');
	var section7b2 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b2')[0];  section7b2.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section7b2');
	var section8 = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section8')[0];  section8.value = coalesceSetRet('itr5ScheduleBP.businessIncOthThanSpec.underSecOther.section8');


	if(section7 < section7_38)
	{

		j.setFieldError('itr4ScheduleBP.businessIncOthThanSpec.section7','The amount shall not exceed amount shown at 4(c)(i)');
		addErrorXHTML( document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7')[0],
				'The amount shall not exceed amount shown at 4(c)(i) ',
				true);
	}



	if(section7A_38.value < (section7a.value * 0.35))
	{
		j.setFieldError('itr4ScheduleBP.businessIncOthThanSpec.section7A','The amount shall be minimum of 35 percent of amount shown at 4(c)(ii)');
		addErrorXHTML( document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7A')[0],
				'The amount shall be minimum of 35 percent of amount shown at 4(c)(ii) ',
				true);
	}

	if(section7B_38.value < (section7b1.value * 0.25))
	{
		j.setFieldError('itr4ScheduleBP.businessIncOthThanSpec.section7B','The amount shall be minimum of 25 percent of amount shown at 4(c)(iii)');
		addErrorXHTML( document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B')[0],
				'The amount shall be minimum of 25 percent of amount shown at 4(c)(iii) ',
				true);
	}

	if(section7B1A_38.value < (section7b2.value * 0.40))
	{
		j.setFieldError('itr4ScheduleBP.businessIncOthThanSpec.section7B1A','The amount shall be minimum of 40 percent of amount shown at 4(c)(iv)');
		addErrorXHTML( document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section7B1A')[0],
				'The amount shall be minimum of 40 percent of amount shown at 4(c)(iv) ',
				true);
	}

	if(section8_38.value < (section8.value * 0.40))
	{
		j.setFieldError('itr4ScheduleBP.businessIncOthThanSpec.section8','The amount shall be minimum of 40 percent of amount shown at 4(c)(v)');
		addErrorXHTML( document.getElementsByName('itr4ScheduleBP.businessIncOthThanSpec.section8')[0],
				'The amount shall be minimum of 40 percent of amount shown at 4(c)(v) ',
				true);
	}

}

function enablePLtables(){

	var tdsTable = document.getElementById('presumtiveInc44AD');
	var noOfRows = tdsTable.rows.length;
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	enableField('partAGEN1.filingStatus.residentialStatus','RES',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib'
	);

	enableField('partAGEN1.orgFirmInfo.statusOrCompanyType',['1'],
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib'
	);

	enableField('partAGEN1.orgFirmInfo.subStatus',['10'],
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.grossReceiptsia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.anyOtherMode',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iia',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive.presumptive61iib'
	);


	for (var i = 0; i < (noOfRows - 2); i++) {

		if (resStatus=='RES' && status == '1' && substatus == '10') {

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].nameOfBuss')[0].disabled = false;

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].bussCode')[0].disabled = false;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].description')[0].disabled = false;

		}
		else {

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].nameOfBuss')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].bussCode')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].description')[0].disabled = true;

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].nameOfBuss')[0].value = "";
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].bussCode')[0].value = "";
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[' + i
					+ '].description')[0].value = "";


		}
	}



}

function enablePL63tables(){

	var tdsTable = document.getElementById('presumtiveInc44AD');
	var noOfRows = tdsTable.rows.length;

	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var substatus = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	enableField('partAGEN1.filingStatus.residentialStatus','RES',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA'

	);

	enableField('partAGEN1.orgFirmInfo.statusOrCompanyType',['1'],
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA'

	);

	enableField('partAGEN1.orgFirmInfo.subStatus',['10'],
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.grossReceipts62',
			'partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA.presumptive44ADA'

	);


	for (var i = 0; i < (noOfRows - 2); i++) {

		if (resStatus=='RES' && status == '1' && substatus == '10') {

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].nameOfBuss')[0].disabled = false;



			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].bussCode')[0].disabled = false;



			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].description')[0].disabled = false;


		}
		else {

			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].nameOfBuss')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].bussCode')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].description')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].nameOfBuss')[0].value = "";
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].bussCode')[0].value = "";
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[' + i
					+ '].description')[0].value = "";

		}
	}



}

function othergener(){
	var partaoth = document.getElementById('othSecDateTabId1');

	var noOfRows = partaoth.rows.length;


	for (var i = 0; i < noOfRows-2; i++) {

		var nature = document.getElementsByName('partAGEN2.auditReportDetails[' + i + '].auditReportAct')[0].value;

		if (nature == '19') {
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportActOthers')[0].disabled = false;
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportActOthers')[0].readOnly = false;

		} else {
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportActOthers')[0].disabled = true;
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportActOthers')[0].readOnly = true;

			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportActOthers')[0].value = '';
		}

	}
}

function othergener1(){
	var partaoth = document.getElementById('othSecDateTabId1');

	var noOfRows = partaoth.rows.length;


	for (var i = 0; i < noOfRows-2; i++) {

		var natureothr = document.getElementsByName('partAGEN2.auditReportDetails[' + i + '].auditReportActOthers')[0].value;
		var nature = document.getElementsByName('partAGEN2.auditReportDetails[' + i + '].auditReportAct')[0].value;

		if (nature == '19' && (natureothr==null || natureothr=='')) {
			addErrorXHTML(
					'',
			'Please enter the description in audit report details.');

			j.setFieldError('partAGEN2.auditReportDetails['+i+'].auditReportActOthers',
			'Please enter the description in audit report details.');

			return;

		}

	}
}

//Function to check if Schedule FA is Mandatory.
function checkSchRAMandatory() {

	var table1 = checkRowBlank('scheduleRA', 3, 1);

	var section351IiamtDebPL = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Ii.deductUs35.amtDebPL')[0].value);
	var section351IiamtUs35Allowable = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Ii.deductUs35.amtUs35Allowable')[0].value);
	var section351IiaamtDebPL = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Iia.deductUs35.amtDebPL')[0].value);
	var section351IiaamtUs35Allowable = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Iia.deductUs35.amtUs35Allowable')[0].value);
	var section351IiiamtDebPL = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Iii.deductUs35.amtDebPL')[0].value);
	var section351IiiamtUs35Allowable = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section351Iii.deductUs35.amtUs35Allowable')[0].value);
	var section352AAamtDebPL = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section352AA.deductUs35.amtDebPL')[0].value);
	var section352AAamtUs35Allowable = parseInt(document.getElementsByName('scheduleESR.deductionUs35.section352AA.deductUs35.amtUs35Allowable')[0].value);


	if((section351IiamtDebPL >0) || (section351IiamtUs35Allowable >0) ||
			(section351IiaamtDebPL >0) || (section351IiaamtUs35Allowable >0) ||
			(section351IiiamtDebPL >0) || (section351IiiamtUs35Allowable >0) ||
			(section352AAamtDebPL >0) || (section352AAamtUs35Allowable >0)) {
		if(table1) {
			j.setFieldError('scheduleRA.doneeDetail[0].doneeName','Please enter value in Schedule RA.');
			addErrorXHTML('','Please enter value in Schedule RA.');
		}
	}

}


function validateNatureOfBusiness()
{
	var code=document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[0].code')[0].value;
	var code1=document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive[0].bussCode')[0].value;
	var code2=document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44ADA[0].bussCode')[0].value;
	var code3=document.getElementsByName('partapl.debitsToPL.debitPlAcnt.compPresumptive44AE[0].bussCode')[0].value;

	if( (code == '') && (code1 == '') && (code2 == '') && (code3 == '') )
	{
		addErrorXHTML('', 'Atleast one Business Code is mandatory either in Schedule Nature of Business or at Point-61 or 62 or 63 in Schedule Profit & Loss A/c');
		j.setFieldError('',"Atleast one Business Code is mandatory either in Schedule Nature of Business or at Point-61 or 62 or 63 in Schedule Profit & Loss A/c");
	}
}



function onStateChngPLOther() {

	var listOfTr = document.getElementById('badDebtPLOthers').getElementsByTagName(
	'tr');
	var noOfRows = eval(parseInt(listOfTr.length, 10) - 3);

	for (var i = 0; i < noOfRows; i++) {
		var state = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers['
				+ i + '].stateCode')[0];
		var country = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].country')[0];
		var pinCode = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].pinCode')[0];
		var zipCode = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].zipCode')[0];

		if (state.value != '99' && state.value != '') {
			if (country.value != '91') {
				zipCode.disabled = true;
				pinCode.disabled = false;
				country.value = '91';
				zipCode.value = "";

			}
		} else if (state.value == '99') {

			if (pinCode.value != null || pinCode.value != '') {
				zipCode.disabled = false;
				pinCode.disabled = true;
				pinCode.value = "";
				country.value = '';

			}
		}
	}
}

function onCountryChngPLOther() {
	var listOfTr = document.getElementById('badDebtPLOthers').getElementsByTagName(
	'tr');
	var noOfRows = eval(parseInt(listOfTr.length, 10) - 3);

	for (var i = 0; i < noOfRows; i++) {
		var state = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers['
				+ i + '].stateCode')[0];
		var country = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].country')[0];
		var pinCode = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].pinCode')[0];
		var zipCode = document
		.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].zipCode')[0];

		try {
			if (country.value == '91' && state.value == "99") {
				zipCode.disabled = true;
				pinCode.disabled = false;
				state.value = "";
				zipCode.value = "";

			} else if (country.value != '' && country.value != "91") {
				zipCode.disabled = false;
				pinCode.disabled = true;
				state.value = '99';
				pinCode.value = "";

			}

		} catch (e) {
		}
	}

}

function setSclPLZipCodeOnLoad()
{
	var table = document.getElementById('badDebtPLOthers');
	var rowCount = table.rows.length;
	var state;
	var country;

	for (var i = 0; i < rowCount - 3; i++) {

		state = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
				+ '].stateCode')[0].value;
		country = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers['
				+ i + '].country')[0].value;

		if (country == '91') {
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].zipCode')[0].value = '';
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].zipCode')[0].disabled = true;
		} else if (state == '99') {
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].pinCode')[0].value = '';
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].pinCode')[0].disabled = true;
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].zipCode')[0].disabled = false;
		} else {
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].zipCode')[0].value = '';
			document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers[' + i
					+ '].zipCode')[0].disabled = true;
		}
	}

}

function validateOSdropDown(){
	try{

		var tabl = document.getElementById('schduleOsinc');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'RES' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='5ACA1a'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section 115ACA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section 115ACA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}

function validateOSEAdropDown(){
	try{

		var tabl = document.getElementById('schduleOsinc');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'NRI' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='5Ea'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section 5EA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section 5EA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}

function validateOSPTI115dropDown(){
	try{

		var tabl = document.getElementById('schduleOsincPti');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'RES' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='PTI_5ACA1a'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section PTI 115ACA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section PTI 115ACA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}
function validateOSPTIEAdropDown(){
	try{

		var tabl = document.getElementById('schduleOsincPti');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'NRI' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='PTI_5Ea'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section PTI 5EA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section PTI 5EA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}

function validateOSDTAAPTIEAdropDown(){
	try{

		var tabl = document.getElementById('scheduleOsNriIncTaxDtaa');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'NRI' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='PTI_5Ea'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section PTI 5EA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section PTI 5EA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}
function validateOSDTAAEAdropDown(){
	try{

		var tabl = document.getElementById('scheduleOsNriIncTaxDtaa');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'NRI' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='5Ea'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section 5EA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section 5EA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}
function validateOSDTAA115dropDown(){
	try{

		var tabl = document.getElementById('scheduleOsNriIncTaxDtaa');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'RES' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='5ACA1a'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section 115ACA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section 115ACA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}
function validateOSDTAAPTI115dropDown(){
	try{

		var tabl = document.getElementById('scheduleOsNriIncTaxDtaa');
		var selectTags=tabl.getElementsByTagName('select');

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
		var substatusCompany=document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;

		if(residentialStatus == 'RES' && substatusCompany != '12'){
			for(var i = 0; i < selectTags.length; i++) {

				if(selectTags[i].name.match('sourceDescription$')){
					if(selectTags[i].value=='PTI_5ACA1a'){
						j.setFieldError('partAGEN1.orgFirmInfo.subStatus','Section PTI 115ACA can be selected for only Estate of Deceased');
						addErrorXHTML('','Section PTI 115ACA can be selected for only Estate of Deceased');
					}
				}
			}
		}
	}
	catch(e){
		alert(e.stack);
	}
}



function validatePriceShare(){
	try{
		var table = document.getElementById('UnlistedShares');
		var noOfRows = table.rows.length;
		for(var i=0;i<noOfRows-4;i++){
			var value = document.getElementsByName('partAGEN1.unlistedShares['+i+'].sharesAcquiredcostOfAcquisition')[0];
			var PriceShareName = value.name;
			var prefixValue = value.name.substring(0,value.name.lastIndexOf("."));
			var priceShareNameVal=parseInt(coalesce(document.getElementsByName(PriceShareName)[0].value));
			var issuePurcharseVal=parseInt(coalesce(document.getElementsByName(prefixValue+'.sharesAcquiredissuePurcharse')[0].value));
			if(priceShareNameVal>0&&issuePurcharseVal>0){
				j.setFieldError(document.getElementsByName(prefixValue+'.issuePurcharse')[0],'Please enter details of Issue Price & Purchase Price in separate Rows');
				addErrorXHTML('','Please enter details of Issue Price & Purchase Price in separate Rows',true);
			}
		}
	}catch(e){
		alert('error in func:validatePriceShare '+e.stack);
	}
}


function panValidation80GGA(tableId) {

	var pan = document.getElementsByName('partAGEN1.orgFirmInfo.panNumber')[0].value;
	var verificationPAN = document
	.getElementsByName('verification.declaration.assesseeVerPAN')[0].value;
	var table = document.getElementById(tableId);
	var allInputTags = table.getElementsByTagName('input');
	for (var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("panOfDonee$")) {
			if (allInputTags[i].value != ''
				&& (allInputTags[i].value == pan || allInputTags[i].value == verificationPAN)) {
				// addError(allInputTags[i],'Enter the PAN of the person to whom
				// the donation is made.',true);
				j
				.setFieldError(allInputTags[i].name,
				'Donee PAN cannot be same as assesse PAN or verification PAN');
			}
		}
	}
}


function validateSchRA()
{
	var table = document.getElementById('scheduleRA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('scheduleRA.doneeDetail[' + i+ '].donationAmtCash')[0];
		var donationAmtOther = document.getElementsByName('scheduleRA.doneeDetail[' + i+ '].donationAmtOther')[0];
		if(document.getElementsByName('scheduleRA.doneeDetail[' + i+ '].doneePanNo')[0].value!=''){

			if((donationAmtCash.value==''&&donationAmtOther.value=='') || (donationAmtCash.value==null && donationAmtOther.value==null)|| (donationAmtCash.value==0 && donationAmtOther.value==0) ){
				j.setFieldError(document.getElementsByName('scheduleRA.doneeDetail[' + i + '].donationAmtCash')[0],'Enter the amount of donation either in field Donation in cash or Donation in other mode');
				addErrorXHTML(document.getElementsByName('')[0],'Enter the amount of donation either in field Donation in cash or Donation in other mode',true);

			}
		}

	}

}

function calculateSchRA()
{
	var table = document.getElementById('scheduleRA');
	var rowCount = table.rows.length;
	var totRow = rowCount - 4;
	var sumCash=0;
	var sumOther=0;
	var sumElig=0;

	for (var i = 0; i < totRow; i++) {

		var donationAmtCash = document.getElementsByName('scheduleRA.doneeDetail[' + i
				+ '].donationAmtCash')[0];
		var donationAmtOther = document.getElementsByName('scheduleRA.doneeDetail[' + i
				+ '].donationAmtOther')[0];
		var eligibleDonationAmt = document.getElementsByName('scheduleRA.doneeDetail[' + i
				+ '].eligibleDonationAmt')[0];


		sumCash += eval(parseInt(coalesce(donationAmtCash.value,10)));

		sumOther += eval(parseInt(coalesce(donationAmtOther.value,10)));

		sumElig += eval(parseInt(coalesce(eligibleDonationAmt.value,10)));


		document.getElementsByName('scheduleRA.doneeDetail[' + i
				+ '].eligibleDonationTotal')[0].value  = eval(parseInt(coalesce(donationAmtCash.value,10)))
				+ eval(parseInt(coalesce(donationAmtOther.value,10)));

		document.getElementsByName('scheduleRA.totDon100Percent')[0].value = eval(parseInt(coalesce(sumCash,10)))
		+ eval(parseInt(coalesce(sumOther,10)));

	}

	document.getElementsByName('scheduleRA.totDon100PercentCash')[0].value = sumCash;
	document.getElementsByName('scheduleRA.totDon100PercentOtherMode')[0].value = sumOther;
	document.getElementsByName('scheduleRA.totEligibleDon100Percent')[0].value = sumElig;


}


function calculate112A(){
	try{

		var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
		if(residentialStatus == "NRI"){
			if(residentialStatus == "NRI")
				enableTable('partAGEN1.filingStatus.residentialStatus','NRI', 'Sch115Ad1');

		}else{
			var tabId = "#" + "Sch115Ad1";
			$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
			deleteRowTable('Sch115Ad1', 2, 2);
			$(tabId).find(':input').prop('disabled', true);
			$(tabId).find('.addbtn').prop('hidden', true);
		}
		if (document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value == 'NRI') {


		}else{

			document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0].readOnly=true;
			document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0].value='';

		}


		var ltcgAssestsB4=document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0];
		ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));

		/*if(document.getElementsByName('schedule115Ad1.bussinessTrust[0].iSINCode')[0].value==""){
			balanceOf4a.value =parseInt('0',10);
		}

		 */
		calcITR5();
	}catch(e){
		alert('calculate112A'+e);
	}
	calculate112A4();
}

function calculate112A4(){
	try{

		var ltcgAssestsB4=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0];
		ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));

		calcITR5();
	}catch(e){
		alert('calculate112A4'+e);
	}
}


function enable115AdP(){

	var residentialStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;


	if(residentialStatus == "NRI" ){
		enableTable('partAGEN1.filingStatus.residentialStatus','NRI', 'Sch115Ad1');
		clearFiels115AD();
	}else{
		var tabId = "#" + "Sch115Ad1";
		$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		deleteRowTable('Sch115Ad1', 2, 2);
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find(':input').prop('value',"");
		$(tabId).find('.addbtn').prop('hidden', true);
	}

}


function checkRepsentative(){
	try{
		var val =	document.getElementsByName('verification.declaration.capacity')[0];
		if(val.value=="RA"){
			document.getElementsByName('partAGEN1.filingStatus.asseseeRepFlg')[0].value='Y';
			document.getElementsByName('partAGEN1.filingStatus.asseseeRepFlg')[0].readOnly=true;
			document.getElementsByName('partAGEN1.filingStatus.asseseeRepFlg')[0].disabled=true;
		}else{
			document.getElementsByName('partAGEN1.filingStatus.asseseeRepFlg')[0].readOnly=false;
			document.getElementsByName('partAGEN1.filingStatus.asseseeRepFlg')[0].disabled=false;
		}


		enableField('partAGEN1.filingStatus.asseseeRepFlg', 'Y',
				'partAGEN1.filingStatus.assesseeRep.repName',
				'partAGEN1.filingStatus.assesseeRep.repcapac',
				'partAGEN1.filingStatus.assesseeRep.repAddress',
		'partAGEN1.filingStatus.assesseeRep.repPAN');
	}catch(e){
		alert(e.stack);
	}
}



function calcSch112A(){
	var tab = document.getElementById('Sch112A');
	var rowcount = parseInt(tab.rows.length)-4;
	var totaltotSaleValue = document.getElementsByName('schedule112A.bussinessTrust.totaltotSaleValue')[0];
	var totalCostAcqWithoutIndx = document.getElementsByName('schedule112A.bussinessTrust.totalCostAcqWithoutIndx')[0];
	var totalAcquisitionCost = document.getElementsByName('schedule112A.bussinessTrust.totalAcquisitionCost')[0];
	var totalLTCGBeforelowerB1B2 = document.getElementsByName('schedule112A.bussinessTrust.totalLTCGBeforelowerB1B2')[0];
	var totaltotFairMktValueCapAst = document.getElementsByName('schedule112A.bussinessTrust.totaltotFairMktValueCapAst')[0];

	var totalExpExclCnctTransfer = document.getElementsByName('schedule112A.bussinessTrust.totalExpExclCnctTransfer')[0];
	var totalTotalDeductions = document.getElementsByName('schedule112A.bussinessTrust.totalTotalDeductions')[0];
	var totalBalance = document.getElementsByName('schedule112A.bussinessTrust.totalBalance')[0];


	totaltotSaleValue.value =0;
	totalCostAcqWithoutIndx.value =0;
	totalAcquisitionCost.value =0;
	totalLTCGBeforelowerB1B2.value =0;
	totaltotFairMktValueCapAst.value =0;

	totalExpExclCnctTransfer.value =0;
	totalTotalDeductions.value =0;
	totalBalance.value =0;


	for(var i=0;i<rowcount;i++){
		var shareOnOrBefore = document.getElementsByName('schedule112A.bussinessTrust['+i+'].shareOnOrBefore')[0];
		
		var numSharesUnits = document.getElementsByName('schedule112A.bussinessTrust['+i+'].numSharesUnits')[0];
		var salePricePerShareUnit = document.getElementsByName('schedule112A.bussinessTrust['+i+'].salePricePerShareUnit')[0];
		var totSaleValue = document.getElementsByName('schedule112A.bussinessTrust['+i+'].totSaleValue')[0];

		//totSaleValue.value = parseFloat(eval(parseFloat(coalesce(numSharesUnits.value),2)*parseFloat(coalesce(salePricePerShareUnit.value),2)),2).toFixed(2);
		if(shareOnOrBefore.value == "BE" || shareOnOrBefore.value == ""){
			totSaleValue.value = parseFloat(eval(parseFloat(coalesce(numSharesUnits.value),4)*parseFloat(coalesce(salePricePerShareUnit.value),4)),4);
		
		}else{
			totSaleValue.value = parseFloat(eval(parseFloat(coalesce(totSaleValue.value),4)),4);
			//totSaleValue.value = parseFloat(totSaleValue.value,4).toFixed(4);
		}
		totSaleValue.value=Math.floor(totSaleValue.value);
		var costAcqWithoutIndx = document.getElementsByName('schedule112A.bussinessTrust['+i+'].costAcqWithoutIndx')[0];
		var acquisitionCost = document.getElementsByName('schedule112A.bussinessTrust['+i+'].acquisitionCost')[0];
		var lTCGBeforelowerB1B2 = document.getElementsByName('schedule112A.bussinessTrust['+i+'].lTCGBeforelowerB1B2')[0];
		var fairMktValuePerShareunit = document.getElementsByName('schedule112A.bussinessTrust['+i+'].fairMktValuePerShareunit')[0];
		var totFairMktValueCapAst = document.getElementsByName('schedule112A.bussinessTrust['+i+'].totFairMktValueCapAst')[0];

		totFairMktValueCapAst.value = parseFloat(eval(parseFloat(coalesce(fairMktValuePerShareunit.value),4)*parseFloat(coalesce(numSharesUnits.value),4)),4);
		totFairMktValueCapAst.value=Math.floor(totFairMktValueCapAst.value);
		if(parseFloat(totSaleValue.value)<parseFloat(totFairMktValueCapAst.value)){
			lTCGBeforelowerB1B2.value=parseFloat(totSaleValue.value,4);
		}else{
			lTCGBeforelowerB1B2.value=parseFloat(totFairMktValueCapAst.value,4);
		}
		
		lTCGBeforelowerB1B2.value=Math.floor(lTCGBeforelowerB1B2.value);
		if(parseFloat(acquisitionCost.value)>parseFloat(lTCGBeforelowerB1B2.value)){
			costAcqWithoutIndx.value =parseFloat(acquisitionCost.value,4);
		}else{
			costAcqWithoutIndx.value =parseFloat(lTCGBeforelowerB1B2.value,4);
		}
		costAcqWithoutIndx.value= Math.floor(costAcqWithoutIndx.value);
		
		var expExclCnctTransfer = document.getElementsByName('schedule112A.bussinessTrust['+i+'].expExclCnctTransfer')[0];
		var totalDeductions = document.getElementsByName('schedule112A.bussinessTrust['+i+'].totalDeductions')[0];

		totalDeductions.value = parseFloat(eval(parseFloat(costAcqWithoutIndx.value,4)+parseFloat(coalesce(expExclCnctTransfer.value),4)),4);
		
		totalDeductions.value=Math.floor(totalDeductions.value);
		var balance = document.getElementsByName('schedule112A.bussinessTrust['+i+'].balance')[0];
		balance.value = parseFloat(eval(parseFloat(totSaleValue.value,4) - parseFloat(totalDeductions.value,4)),4);
		balance.value=Math.floor(balance.value);
		
		totaltotSaleValue.value = parseFloat(parseFloat(totaltotSaleValue.value,4)+parseFloat(coalesce(totSaleValue.value),4),4);
		totalCostAcqWithoutIndx.value = parseFloat(parseFloat(totalCostAcqWithoutIndx.value,4)+parseFloat(coalesce(costAcqWithoutIndx.value),4),4);
		totalAcquisitionCost.value = parseFloat(parseFloat(totalAcquisitionCost.value,4)+parseFloat(coalesce(acquisitionCost.value),4),4);
		totalLTCGBeforelowerB1B2.value = parseFloat(parseFloat(totalLTCGBeforelowerB1B2.value,4)+parseFloat(coalesce(lTCGBeforelowerB1B2.value),4),4);
		totaltotFairMktValueCapAst.value = parseFloat(parseFloat(totaltotFairMktValueCapAst.value,4)+parseFloat(coalesce(totFairMktValueCapAst.value),4),4);
		totalExpExclCnctTransfer.value = parseFloat(parseFloat(totalExpExclCnctTransfer.value,4)+parseFloat(coalesce(expExclCnctTransfer.value),4),4);
		totalTotalDeductions.value = parseFloat(parseFloat(totalTotalDeductions.value,4)+parseFloat(coalesce(totalDeductions.value),4),4);
		totalBalance.value = parseFloat(parseFloat(totalBalance.value,4)+parseFloat(coalesce(balance.value),4),4);
	}
	
	totaltotSaleValue.value= Math.floor(totaltotSaleValue.value);
	totalCostAcqWithoutIndx.value=Math.floor(totalCostAcqWithoutIndx.value);
	totalAcquisitionCost.value=Math.floor(totalAcquisitionCost.value);
	totalLTCGBeforelowerB1B2.value= Math.floor(totalLTCGBeforelowerB1B2.value);
	totaltotFairMktValueCapAst.value=Math.floor(totaltotFairMktValueCapAst.value);
	totalExpExclCnctTransfer.value=Math.floor(totalExpExclCnctTransfer.value);
	totalTotalDeductions.value=Math.floor(totalTotalDeductions.value);
	totalBalance.value=Math.floor(totalBalance.value);
	if(document.getElementsByName('schedule112A.bussinessTrust[0].iSINCode')[0].value!=""){
		/*		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.total')[0].readOnly = false;
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0].readOnly = false;
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.costOfAquisitionWOIndex')[0].value=Math.round(coalesce(totalCostAcqWithoutIndx.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.costOfAquisition')[0].value=Math.round(coalesce(totalAcquisitionCost.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.longTermCap')[0].value=Math.round(coalesce(totalLTCGBeforelowerB1B2.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.fairMarketValue')[0].value=Math.round(coalesce(totaltotFairMktValueCapAst.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.fullValueConsideration')[0].value=Math.round(coalesce(totaltotSaleValue.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.costImprovWOIndex')[0].value=Math.round(coalesce(totalCostImprvWithoutIndx.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.expenditure')[0].value=Math.round(coalesce(totalExpExclCnctTransfer.value));
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.total')[0].value=Math.round(coalesce(totalTotalDeductions.value));*/
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0].value=Math.round(coalesce(totalBalance.value));
		/*		var balanceOf4a=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0];
		 */		var ltcgAssestsB4=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0];
		 /*var deductionUnder54F=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.deduction54F')[0];
		deductionUnder54F.value=NoneOrVal(coalesce(deductionUnder54F.value));*/
		 ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));
		 /*if(coalesce(balanceOf4a.value)<0){
			ltcgAssestsB4.value=NoneOrVal(parseInt(coalesce(balanceOf4a.value),10));
		}else{
			if(parseInt(coalesce(deductionUnder54F.value),10)>parseInt(coalesce(balanceOf4a.value),10)){
				ltcgAssestsB4.value=NoneOrVal(parseInt('0',10));
			}else{
				ltcgAssestsB4.value=NoneOrVal(parseInt(balanceOf4a.value,10)-parseInt(coalesce(deductionUnder54F.value),10));
			}
		}*/
	}

	/*	if(document.getElementsByName('schedule112A.bussinessTrust[0].iSINCode')[0].value==""){
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.total')[0].readOnly = true;
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0].readOnly = true;
	}

	 */
	calcITR5();
}


function calcSch115Ad1(){
	var tab = document.getElementById('Sch115Ad1');
	var rowcount = parseInt(tab.rows.length)-4;
	var totaltotSaleValue = document.getElementsByName('schedule115Ad1.bussinessTrust.totaltotSaleValue')[0];
	var totalCostAcqWithoutIndx = document.getElementsByName('schedule115Ad1.bussinessTrust.totalCostAcqWithoutIndx')[0];
	var totalAcquisitionCost = document.getElementsByName('schedule115Ad1.bussinessTrust.totalAcquisitionCost')[0];
	var totalLTCGBeforelowerB1B2 = document.getElementsByName('schedule115Ad1.bussinessTrust.totalLTCGBeforelowerB1B2')[0];
	var totaltotFairMktValueCapAst = document.getElementsByName('schedule115Ad1.bussinessTrust.totaltotFairMktValueCapAst')[0];

	var totalExpExclCnctTransfer = document.getElementsByName('schedule115Ad1.bussinessTrust.totalExpExclCnctTransfer')[0];
	var totalTotalDeductions = document.getElementsByName('schedule115Ad1.bussinessTrust.totalTotalDeductions')[0];
	var totalBalance = document.getElementsByName('schedule115Ad1.bussinessTrust.totalBalance')[0];

	totaltotSaleValue.value =0;
	totalCostAcqWithoutIndx.value =0;
	totalAcquisitionCost.value =0;
	totalLTCGBeforelowerB1B2.value =0;
	totaltotFairMktValueCapAst.value =0;

	totalExpExclCnctTransfer.value =0;
	totalTotalDeductions.value =0;
	totalBalance.value =0;


	for(var i=0;i<rowcount;i++){
		var shareOnOrBefore = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].shareOnOrBefore')[0];
		
		var numSharesUnits = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].numSharesUnits')[0];
		var salePricePerShareUnit = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].salePricePerShareUnit')[0];
		var totSaleValue = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totSaleValue')[0];

		//totSaleValue.value = parseFloat(eval(parseFloat(coalesce(numSharesUnits.value),2)*parseFloat(coalesce(salePricePerShareUnit.value),2)),2).toFixed(2);
		if(shareOnOrBefore.value == "BE" || shareOnOrBefore.value == ""){
			totSaleValue.value = parseFloat(eval(parseFloat(coalesce(numSharesUnits.value),4)*parseFloat(coalesce(salePricePerShareUnit.value),4)),4);
			
		}else{
			totSaleValue.value = parseFloat(eval(parseFloat(coalesce(totSaleValue.value),4)),4);
			//totSaleValue.value = parseFloat(totSaleValue.value,4).toFixed(4);
		}
		totSaleValue.value=Math.floor(totSaleValue.value);
		var costAcqWithoutIndx = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].costAcqWithoutIndx')[0];
		var acquisitionCost = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].acquisitionCost')[0];
		var lTCGBeforelowerB1B2 = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].lTCGBeforelowerB1B2')[0];
		var fairMktValuePerShareunit = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].fairMktValuePerShareunit')[0];
		var totFairMktValueCapAst = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totFairMktValueCapAst')[0];

		totFairMktValueCapAst.value = parseFloat(eval(parseFloat(coalesce(fairMktValuePerShareunit.value),4)*parseFloat(coalesce(numSharesUnits.value),4)),4);
		totFairMktValueCapAst.value=Math.floor(totFairMktValueCapAst.value);
		
		if(parseFloat(totSaleValue.value)<parseFloat(totFairMktValueCapAst.value)){
			lTCGBeforelowerB1B2.value=parseFloat(totSaleValue.value,4);
		}else{
			lTCGBeforelowerB1B2.value=parseFloat(totFairMktValueCapAst.value,4);
		}
		lTCGBeforelowerB1B2.value=Math.floor(lTCGBeforelowerB1B2.value);
		
		if(parseFloat(acquisitionCost.value)>parseFloat(lTCGBeforelowerB1B2.value)){
			costAcqWithoutIndx.value =parseFloat(acquisitionCost.value,4);
		}else{
			costAcqWithoutIndx.value =parseFloat(lTCGBeforelowerB1B2.value,4);
		}
		costAcqWithoutIndx.value=Math.floor(costAcqWithoutIndx.value);
		var expExclCnctTransfer = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].expExclCnctTransfer')[0];
		var totalDeductions = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totalDeductions')[0];

		totalDeductions.value = parseFloat(eval(parseFloat(costAcqWithoutIndx.value,4)+parseFloat(coalesce(expExclCnctTransfer.value),4)));
		totalDeductions.value= Math.floor(totalDeductions.value);
		var balance = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].balance')[0];
		balance.value = parseFloat(eval(parseFloat(totSaleValue.value,4) - parseFloat(totalDeductions.value,4)),4);
		balance.value=Math.floor(balance.value);
		
		totaltotSaleValue.value = parseFloat(parseFloat(totaltotSaleValue.value)+parseFloat(coalesce(totSaleValue.value)),4);
		totalCostAcqWithoutIndx.value = parseFloat(parseFloat(totalCostAcqWithoutIndx.value)+parseFloat(coalesce(costAcqWithoutIndx.value)),4);
		totalAcquisitionCost.value = parseFloat(parseFloat(totalAcquisitionCost.value)+parseFloat(coalesce(acquisitionCost.value)),4);
		totalLTCGBeforelowerB1B2.value = parseFloat(parseFloat(totalLTCGBeforelowerB1B2.value)+parseFloat(coalesce(lTCGBeforelowerB1B2.value)),4);
		totaltotFairMktValueCapAst.value = parseFloat(parseFloat(totaltotFairMktValueCapAst.value)+parseFloat(coalesce(totFairMktValueCapAst.value)),4);
		totalExpExclCnctTransfer.value = parseFloat(parseFloat(totalExpExclCnctTransfer.value)+parseFloat(coalesce(expExclCnctTransfer.value)),4);
		totalTotalDeductions.value = parseFloat(parseFloat(totalTotalDeductions.value)+parseFloat(coalesce(totalDeductions.value)),4);
		totalBalance.value = parseFloat(parseFloat(totalBalance.value)+parseFloat(coalesce(balance.value)),4);
		

	}
	totaltotSaleValue.value= Math.floor(totaltotSaleValue.value);
	totalCostAcqWithoutIndx.value=Math.floor(totalCostAcqWithoutIndx.value);
	totalAcquisitionCost.value=Math.floor(totalAcquisitionCost.value);
	totalLTCGBeforelowerB1B2.value= Math.floor(totalLTCGBeforelowerB1B2.value);
	totaltotFairMktValueCapAst.value=Math.floor(totaltotFairMktValueCapAst.value);
	totalExpExclCnctTransfer.value=Math.floor(totalExpExclCnctTransfer.value);
	totalTotalDeductions.value=Math.floor(totalTotalDeductions.value);
	totalBalance.value=Math.floor(totalBalance.value);



	if(document.getElementsByName('schedule115Ad1.bussinessTrust[0].iSINCode')[0].value!=""){
		document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0].value=Math.round(coalesce(totalBalance.value));

		var ltcgAssestsB4=document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0];
		ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));

	}

	//calcITR5();
}

function clearFiels112A(){
	if(document.getElementsByName('schedule112A.bussinessTrust[0].iSINCode')[0].value==""){
		var tabId = "#" + "Sch112A";
		$(tabId).find(':input').prop('value',"");
		/*	document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.total')[0].readOnly = false;
	document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0].readOnly = false;
	document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.total')[0].value="";
	document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0].value="";
	document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0].value="";*/
		document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0].value="";
	}
}

function clearFiels115AD(){
	try{
		if(document.getElementsByName('schedule115Ad1.bussinessTrust[0].iSINCode')[0].value==""){
			var tabId = "#" + "Sch115Ad1";
			$(tabId).find(':input').prop('value',"");
			document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0].value="";
		}
	}catch(e){
		alert(e);
	}
}


function importBaonLoad(){
	var tab = document.getElementById('scheduleBAnk');
	var allInputTags = tab.getElementsByTagName('input');


	for (var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("useForRefund$")){
			if(allInputTags[i].value=="true"){
				allInputTags[i].checked=true;
			}
		}
	}



}

function validateBPPL(){
	var netPLFromSpecBus = document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.netPLFromSpecBus')[0]; netPLFromSpecBus.value = coalesce(netPLFromSpecBus.value);
	if(eval(coalesce(parseInt(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.netIncome65')[0].value)))!=0){
		if(netPLFromSpecBus.value==0||netPLFromSpecBus.value==""){
			j.setFieldError('itr5ScheduleBP.businessIncOthThanSpec.netPLFromSpecBus','Please enter value in 2a of schedule BP');
			addErrorXHTML(netPLFromSpecBus ,'Please enter value in 2a of schedule BP',true);
		}
	}
}

function Cg112A(){
	var ltcgAssestsB4=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.ltcgCapGain')[0];
	/*	var balanceOf4a=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.balance')[0];
	 */	/*var deductionUnder54F=document.getElementsByName('scheduleCGFor5.shortTermCapGainFor5.saleofEquityLtcg.deduction54F')[0];
	deductionUnder54F.value=NoneOrVal(coalesce(deductionUnder54F.value));*/
	ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));

	/*	if(coalesce(balanceOf4a.value)<0){
		ltcgAssestsB4.value=(parseInt(coalesce(balanceOf4a.value),10));
	}else{
		if(parseInt(coalesce(deductionUnder54F.value),10)>parseInt(coalesce(balanceOf4a.value),10)){
			ltcgAssestsB4.value=(parseInt('0',10));
		}else{
			ltcgAssestsB4.value=(parseInt(balanceOf4a.value,10)-parseInt(coalesce(deductionUnder54F.value),10));
		}
	}*/

}
function Cg115Ad(){

	var ltcgAssestsB4=document.getElementsByName('scheduleCGFor8.shortTermCapGainFor8.saleofEquityLtcg.ltcgCapGain')[0];
	ltcgAssestsB4.value=NoneOrVal(coalesce(ltcgAssestsB4.value));
	//calcITR5();

}

function uncheckCheckBox(){
	var tab = document.getElementById('scheduleBAnk');
	var allInputTags = tab.getElementsByTagName('input');


	for (var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("useForRefund$")){
			if(allInputTags[i].checked==true&&allInputTags[i].value!="true"){
				allInputTags[i].checked=false;
			}
		}
	}
}


function uncheckCheckBoxOnclick(){
	var tab = document.getElementById('scheduleBAnk');
	var allInputTags = tab.getElementsByTagName('input');


	for (var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("useForRefund$")){
			if(allInputTags[i].checked==true){
				allInputTags[i].value="true";
			}
		}
	}
}

function validateOSPoint8()
{
	var receipts = parseInt(document.getElementsByName('scheduleOS.incFromOwnHorse.receipts')[0].value);
	var deductSec57 = parseInt(document.getElementsByName('scheduleOS.incFromOwnHorse.deductSec57')[0].value);

	if(deductSec57>0 && receipts<=0)
	{
		j.setFieldError('scheduleOS.incFromOwnHorse.deductSec57','Deduction u/s 57 at Point-8b shall be allowed only if Receipts at Point-8a are greater than Zero.');
		addErrorXHTML('scheduleOS.incFromOwnHorse.deductSec57','Deduction u/s 57 at Point-8b shall be allowed only if Receipts at Point-8a are greater than Zero.');

	}

}
function sysDateCompOfDOF()
{
	var date = document.getElementsByName('partAGEN1.filingStatus.origRetFiledDate')[0].value;
	var verficationDate=document.getElementsByName('verification.date')[0].value;
	if (date!=verficationDate && checkFirstDateBefore(verficationDate, date)) {

		j.setFieldError('partAGEN1.filingStatus.origRetFiledDate','In schedule Part A-General Date of filing of original return can not be more than system date.');
		addErrorXHTML( document.getElementsByName('partAGEN1.filingStatus.origRetFiledDate')[0],
				'In schedule Part A-General Date of filing of original return can not be more than system date.',	true);
	}
}
function sysDateCompOfResToNotice()
{
	var date = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.noticeDate')[0].value;
	if (date!=getCurrentDate() && checkFirstDateBefore(getCurrentDate(), date)) {
		j.setFieldError('partAGEN1.filingStatus.returnFileSec.noticeDate','In schedule Part A-General date of notice/order or date of advance pricing agreement can not be more than system date.');
		addErrorXHTML( document.getElementsByName('partAGEN1.filingStatus.returnFileSec.noticeDate')[0],
				'In schedule Part A-General date of notice/order or date of advance pricing agreement can not be more than system date.',	true);
	}
}

function enbaleSheduleTR()
{
	var tab = document.getElementById('scheduleTRMain');
	var status = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var allInputTags = tab.getElementsByTagName('input');
	var selectTags = tab.getElementsByTagName('select');
	for (var i = 0; i < selectTags.length; i++) {
		if (status=='NRI') {
			selectTags[i].disabled = true;
			selectTags[i].readOnly = true;
			selectTags[i].value = "";

		} else {
			selectTags[i].disabled = false;
			selectTags[i].readOnly = false;
		}
	}
	for (var i = 0; i < allInputTags.length; i++) {
		if (status=='NRI') {
			allInputTags[i].disabled = true;
			allInputTags[i].readOnly = true;
			allInputTags[i].value = "";
		} 
	}
}


function enableScheduleFSI()
{
	var tab = document.getElementById('scheduleFSI');
	var status = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var allInputTags = tab.getElementsByTagName('input');
	var selectTags = tab.getElementsByTagName('select');

	if (status=='NRI') {
		deleteRowFSI1('scheduleFSI',2,2);
		$('#addFsiButtonId').prop('disabled', true);
	}
	for (var i = 0; i < allInputTags.length; i++) {

		if (status=='NRI') {
			allInputTags[i].disabled = true;
			allInputTags[i].readOnly = true;
			allInputTags[i].value = "";

		} else {
			if(allInputTags[i].name.match("taxReliefinInd$")|| allInputTags[i].name.match("totalCountryWise.incFrmOutsideInd$") || allInputTags[i].name.match("totalCountryWise.taxPaidOutsideInd$")|| allInputTags[i].name.match("totalCountryWise.taxPayableinInd$")|| allInputTags[i].name.match("totalCountryWise.taxReliefinInd$"))
			{
				continue;
			}
			allInputTags[i].disabled = false;
			allInputTags[i].readOnly = false;
		}
	}
	for (var i = 0; i < selectTags.length; i++) {
		if (status=='NRI') {
			selectTags[i].disabled = true;
			selectTags[i].readOnly = true;
			selectTags[i].value = "";

		} else {
			selectTags[i].disabled = false;
			selectTags[i].readOnly = false;
		}
	}
}
function deleteRowFSI1(tableId , noOfHeader , noOfFooter){
	try{
		var mytable = document.getElementById(tableId);
		var rowCount = mytable.rows.length;
		var itemCount = (rowCount - 4 )/ 5;
		noOfHeader = parseInt(noOfHeader , 10);
		var isChecked=false;
		var listOfCheckBox = mytable.getElementsByTagName('input');
		var totalChecked = 0;
		for(var z=0; z<listOfCheckBox.length; z++){
			if(listOfCheckBox[z].name.match(".chosenCheckBox$")){
					totalChecked = eval( parseInt(totalChecked,10) +1);
			}
		}
		for(var j=1; j<=totalChecked ; j++){      // iterate for total number of checkboxes
			var totalNoOfInput = mytable.getElementsByTagName('input');

			for(var z=0; z<totalNoOfInput.length; z++){
				if(totalNoOfInput[z].name.match(".chosenCheckBox$")){		// if its a chosenCheckBox element

					var akhilIndex1 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf('[') ,10)+1);
					var akhilIndex2 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf(']') ,10));
					var rowNumber = totalNoOfInput[z].name.substring(akhilIndex1, akhilIndex2);
					rowNumber = parseInt(rowNumber ,10);

					var myCurrtable = document.getElementById(tableId);
					var rowCurrCount = myCurrtable.rows.length;


						if((rowNumber!=0) || (rowNumber==0 &&  parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/5)>1) ){
							rowNumber = eval(parseInt(rowNumber,10) * 5 + noOfHeader);
							for(var i=0;i<5;i++){
								mytable.deleteRow(rowNumber);
							}
							//To Do - reset the name of row for all input , textarea, select
							var newTrList = mytable.getElementsByTagName('tr');
							var newTrListLength = eval(parseInt(newTrList.length ,10)-noOfFooter);
							for( var q=rowNumber; q < newTrListLength ; q++ ){	//iterate over all rows from delete point to second last row
								var p = parseInt((q-noOfHeader) /5) + noOfHeader;
								//set the serial number;
								if((q-noOfHeader)%5==0){
									if(noOfHeader==2){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-1,10);
									}else if(noOfHeader==1){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p,10);
									}else if(noOfHeader==3){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-2,10);
									}
								}
								var allInputTags = newTrList[q].getElementsByTagName('input');

								for(var zz=0; zz<allInputTags.length ; zz++ ){
									var index1= allInputTags[zz].name.lastIndexOf('[');
									var index2= allInputTags[zz].name.lastIndexOf(']');

									var str1 = allInputTags[zz].name.substring(0, index1);
									var str3 = allInputTags[zz].name.substring(index2 + 1, allInputTags[zz].name.length);

									allInputTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}

								var allSelectTags = newTrList[q].getElementsByTagName('select');

								for(var zz=0; zz<allSelectTags.length ; zz++ ){
									var index1= allSelectTags[zz].name.lastIndexOf('[');
									var index2= allSelectTags[zz].name.lastIndexOf(']');

									var str1 = allSelectTags[zz].name.substring(0, index1);
									var str3 = allSelectTags[zz].name.substring(index2 + 1, allSelectTags[zz].name.length);

									allSelectTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}

								var allTextAreaTags = newTrList[q].getElementsByTagName('textarea');

								for(var zz=0; zz<allTextAreaTags.length ; zz++ ){
									var index1= allTextAreaTags[zz].name.lastIndexOf('[');
									var index2= allTextAreaTags[zz].name.lastIndexOf(']');

									var str1 = allTextAreaTags[zz].name.substring(0, index1);
									var str3 = allTextAreaTags[zz].name.substring(index2 + 1, allTextAreaTags[zz].name.length);

									allTextAreaTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}
							}
							break;
						}else if((rowNumber==0)  && (parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/5)==1)){
							//Vacate the content if its first row

							for(var m=0; m<5; m++){
								var firstRow = mytable.getElementsByTagName('tr')[parseInt(noOfHeader) + m];

								var firstInputBox = firstRow.getElementsByTagName('input')[0];
								firstInputBox.checked = false;

								var allInputTags = firstRow.getElementsByTagName('input');
								for ( var i = 0; i < allInputTags.length; i++) {
									allInputTags[i].value = "";
								}
								var allSelectTags = firstRow.getElementsByTagName('select');
								for ( var i = 0; i < allSelectTags.length; i++) {
									var elem = allSelectTags[i];
									elem[0].selected = true;
								}
								var allTextAreaTags = firstRow.getElementsByTagName('textarea');
								for ( var i = 0; i < allTextAreaTags.length; i++) {
									allTextAreaTags[i].value = "";
								}
							}
						}
				}
			}
		}
		//modifyRow(mytable);
	}catch(e){
		alert('exception caught in =' +e.stack );
	}
}



function enableDepreciation()
{
	var rentFromMachPlantBldgs = document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.rentFromMachPlantBldgs')[0].value;
	if(parseInt(coalesce(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.rentFromMachPlantBldgs')[0].value),10)>0)
	{
		document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.deductions.depreciation')[0].readOnly= false;
	}
	else
	{
		document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.deductions.depreciation')[0].readOnly= true;
		document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.deductions.depreciation')[0].value='';
	}
}


function enableTRCFlagOS()
{
	var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowcount = tab.rows.length;
	for (var j = 0; j <parseInt(rowcount-2); j++) {
		if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value == 'NRI')
		{
			document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+j+'].taxResidCertFlag')[0].disabled=false;
		}
		else
		{
			document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+j+'].taxResidCertFlag')[0].disabled=true;
			document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+j+'].taxResidCertFlag')[0].value='';
		}
	}
	populateRateOS();

}


function populateRateOS()

{
	var residentialSatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
	var noOfRows = tab.rows.length;

	for (var i = 0; i < (noOfRows - 2); i++) {

		var rateAsPerTreaty = parseFloat(document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].rateOfTax')[0].value);

		var rateAsPerITAct = parseFloat(document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].rateAsPerITAct')[0].value);
		var trcFlag=document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].taxResidCertFlag')[0].value;
		if(residentialSatus!='NRI')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerITAct;
			}

			if (rateAsPerITAct > rateAsPerTreaty) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerTreaty;
			}
			if (rateAsPerTreaty == rateAsPerITAct) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerTreaty;
			}
		}
		else if(residentialSatus=='NRI' && trcFlag=='Y')
		{
			if (rateAsPerTreaty > rateAsPerITAct) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerITAct;
			}

			if (rateAsPerITAct > rateAsPerTreaty) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerTreaty;
			}
			if (rateAsPerTreaty == rateAsPerITAct) {
				document
				.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
						+ i + '].applicableRate')[0].value = rateAsPerTreaty;
			}
		}
		else
		{
			document
			.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['
					+ i + '].applicableRate')[0].value=''
		}

	}

}


//to add rows to table sch PTI

function calculateSchedulePTI(elem)
{
	var index = parseInt(elem.name.substring(elem.name.indexOf("[") + 1, elem.name.indexOf("]")));

	var incFromHPamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromHP.amtOfIncm')[0];
	var incFromHPshareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromHP.shareOfLoss')[0];
	var incFromHPnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromHP.netIncome')[0];
	incFromHPnetIncome.value=eval(parseInt(coalesce(incFromHPamtOfIncm.value),10))-eval(parseInt(coalesce(incFromHPshareOfLoss.value),10));
	//document.getElementsByName('scheduleHP.passThroughIncome')[0].value=incFromHPnetIncome.value;



	var incFromCGShortTermtdsOnAmt111a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.tdsOnAmt111a')[0];
	var incFromCGShortTermtdsOnAmtOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.tdsOnAmtOthrs')[0];
	var incFromCGShortTermtdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.tdsOnAmt')[0];
	incFromCGShortTermtdsOnAmt.value=eval(parseInt(coalesce(incFromCGShortTermtdsOnAmt111a.value),10))+eval(parseInt(coalesce(incFromCGShortTermtdsOnAmtOthrs.value),10));

	var incFromCGShortTermamtOfIncm111a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.amtOfIncm111a')[0];
	var incFromCGShortTermshareOfLoss111a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.shareOfLoss111a')[0];
	var incFromCGShortTermnetIncome111a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.netIncome111a')[0];
	incFromCGShortTermnetIncome111a.value=eval(parseInt(coalesce(incFromCGShortTermamtOfIncm111a.value),10))-eval(parseInt(coalesce(incFromCGShortTermshareOfLoss111a.value),10));

	var incFromCGShortTermamtOfIncmOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.amtOfIncmOthrs')[0];
	var incFromCGShortTermshareOfLossOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.shareOfLossOthrs')[0];
	var incFromCGShortTermnetIncomeOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.netIncomeOthrs')[0];
	incFromCGShortTermnetIncomeOthrs.value=eval(parseInt(coalesce(incFromCGShortTermamtOfIncmOthrs.value),10))-eval(parseInt(coalesce(incFromCGShortTermshareOfLossOthrs.value),10));

	var incFromCGShortTermamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.amtOfIncm')[0];
	incFromCGShortTermamtOfIncm.value=eval(parseInt(coalesce(incFromCGShortTermamtOfIncm111a.value),10))+eval(parseInt(coalesce(incFromCGShortTermamtOfIncmOthrs.value),10));
	var incFromCGShortTermshareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.shareOfLoss')[0];
	incFromCGShortTermshareOfLoss.value=eval(parseInt(coalesce(incFromCGShortTermshareOfLoss111a.value),10))+eval(parseInt(coalesce(incFromCGShortTermshareOfLossOthrs.value),10));
	var incFromCGShortTermnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGShortTerm.netIncome')[0];
	incFromCGShortTermnetIncome.value=eval(parseInt(coalesce(incFromCGShortTermamtOfIncm.value),10))-eval(parseInt(coalesce(incFromCGShortTermshareOfLoss.value),10));

	var incFromCGLongTermtdsOnAmt112a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.tdsOnAmt112a')[0];
	var incFromCGLongTermtdsOnAmtOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.tdsOnAmtOthrs')[0];
	var incFromCGLongTermtdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.tdsOnAmt')[0];
	incFromCGLongTermtdsOnAmt.value=eval(parseInt(coalesce(incFromCGLongTermtdsOnAmt112a.value),10))+eval(parseInt(coalesce(incFromCGLongTermtdsOnAmtOthrs.value),10));

	var incFromCGLongTermamtOfIncm112a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.amtOfIncm112a')[0];
	var incFromCGLongTermshareOfLoss112a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.shareOfLoss112a')[0];
	var incFromCGLongTermnetIncome112a= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.netIncome112a')[0];
	incFromCGLongTermnetIncome112a.value=eval(parseInt(coalesce(incFromCGLongTermamtOfIncm112a.value),10))-eval(parseInt(coalesce(incFromCGLongTermshareOfLoss112a.value),10));

	var incFromCGLongTermamtOfIncmOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.amtOfIncmOthrs')[0];
	var incFromCGLongTermshareOfLossOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.shareOfLossOthrs')[0];
	var incFromCGLongTermnetIncomeOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.netIncomeOthrs')[0];
	incFromCGLongTermnetIncomeOthrs.value=eval(parseInt(coalesce(incFromCGLongTermamtOfIncmOthrs.value),10))-eval(parseInt(coalesce(incFromCGLongTermshareOfLossOthrs.value),10));

	var incFromCGLongTermamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.amtOfIncm')[0];
	incFromCGLongTermamtOfIncm.value=eval(parseInt(coalesce(incFromCGLongTermamtOfIncm112a.value),10))+eval(parseInt(coalesce(incFromCGLongTermamtOfIncmOthrs.value),10));
	var incFromCGLongTermshareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.shareOfLoss')[0];
	incFromCGLongTermshareOfLoss.value=eval(parseInt(coalesce(incFromCGLongTermshareOfLoss112a.value),10))+eval(parseInt(coalesce(incFromCGLongTermshareOfLossOthrs.value),10));
	var incFromCGLongTermnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromCGLongTerm.netIncome')[0];
	incFromCGLongTermnetIncome.value=eval(parseInt(coalesce(incFromCGLongTermamtOfIncm.value),10))-eval(parseInt(coalesce(incFromCGLongTermshareOfLoss.value),10));

	var incFromDividendtdsOnAmtDividend= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.tdsOnAmtDividend')[0];
	var incFromDividendtdsOnAmtOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.tdsOnAmtOthrs')[0];
	var incFromOStdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromOS.tdsOnAmt')[0];
	incFromOStdsOnAmt.value=eval(parseInt(coalesce(incFromDividendtdsOnAmtDividend.value),10))+eval(parseInt(coalesce(incFromDividendtdsOnAmtOthrs.value),10));

	var incFromDividendamtOfIncmDividend= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.amtOfIncmDividend')[0];
	//coalesceSetRet('schedulePTI.schedulePTI['+index+'].incFromDividend.shareOfLossDividend');
	var incFromDividendnetIncomeDiviend= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.netIncomeDividend')[0];
	incFromDividendnetIncomeDiviend.value=eval(parseInt(coalesce(incFromDividendamtOfIncmDividend.value),10));

	var incFromDividendamtOfIncmOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.amtOfIncmOthrs')[0];
	//coalesceSetRet('schedulePTI.schedulePTI['+index+'].incFromDividend.shareOfLossOthrs');
	var incFromDividendnetIncomeOthrs= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromDividend.netIncomeOthrs')[0];
	incFromDividendnetIncomeOthrs.value=eval(parseInt(coalesce(incFromDividendamtOfIncmOthrs.value),10));

	var incFromOSamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromOS.amtOfIncm')[0];
	incFromOSamtOfIncm.value=eval(parseInt(coalesce(incFromDividendamtOfIncmDividend.value),10))+eval(parseInt(coalesce(incFromDividendamtOfIncmOthrs.value),10));

	var incFromOSnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromOS.netIncome')[0];
	incFromOSnetIncome.value=eval(parseInt(coalesce(incFromOSamtOfIncm.value),10));

	var incFromExemptSec10_23FBBamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.amtOfIncm')[0];

	var incFromExemptSec10_23FBBnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.netIncome')[0];
	if(incFromExemptSec10_23FBBamtOfIncm.value!='')
	{
		incFromExemptSec10_23FBBnetIncome.value=eval(parseInt(coalesce(incFromExemptSec10_23FBBamtOfIncm.value),10));
	}
	else
	{
		incFromExemptSec10_23FBBnetIncome.value='';
	}

	var incFromExemptSec10_23FBB1amtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.amtOfIncm')[0];
	var incFromExemptSec10_23FBB1netIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.netIncome')[0];
	if(incFromExemptSec10_23FBB1amtOfIncm.value!='')
	{
		incFromExemptSec10_23FBB1netIncome.value=eval(parseInt(coalesce(incFromExemptSec10_23FBB1amtOfIncm.value),10));
	}
	else
	{
		incFromExemptSec10_23FBB1netIncome.value='';
	}
	var incFromExemptSec10_23FBB2amtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.amtOfIncm')[0];

	var incFromExemptSec10_23FBB2netIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.netIncome')[0];
	if(incFromExemptSec10_23FBB2amtOfIncm.value!='')
	{
		incFromExemptSec10_23FBB2netIncome.value=eval(parseInt(coalesce(incFromExemptSec10_23FBB2amtOfIncm.value),10));
	}
	else
	{
		incFromExemptSec10_23FBB2netIncome.value='';
	}

	var incFromExemptSec10_23FBBamtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.amtOfIncm')[0];
	var incFromExemptSec10_23FBB1amtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.amtOfIncm')[0];
	var incFromExemptSec10_23FBB2amtOfIncm= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.amtOfIncm')[0];
	var incFromExemptSec10_23FBBamtOfIncmTotal= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.amtOfIncmTotal')[0];
	incFromExemptSec10_23FBBamtOfIncmTotal.value=eval(parseInt(coalesce(incFromExemptSec10_23FBBamtOfIncm.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB1amtOfIncm.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB2amtOfIncm.value),10));

	/*var incFromExemptSec10_23FBBshareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.shareOfLoss')[0];
	var incFromExemptSec10_23FBB1shareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.shareOfLoss')[0];
	var incFromExemptSec10_23FBB2shareOfLoss= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.shareOfLoss')[0];
	var incFromExemptSec10_23FBBshareOfLossTotal= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.shareOfLossTotal')[0];
	incFromExemptSec10_23FBBshareOfLossTotal.value=eval(parseInt(coalesce(incFromExemptSec10_23FBBshareOfLoss.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB1shareOfLoss.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB2shareOfLoss.value),10));
	 */
	var incFromExemptSec10_23FBBnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.netIncome')[0];
	var incFromExemptSec10_23FBB1netIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.netIncome')[0];
	var incFromExemptSec10_23FBB2netIncome= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.netIncome')[0];
	var incFromExemptSec10_23FBBnetIncomeTotal= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.netIncomeTotal')[0];
	incFromExemptSec10_23FBBnetIncomeTotal.value=eval(parseInt(coalesce(incFromExemptSec10_23FBBnetIncome.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB1netIncome.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB2netIncome.value),10));

	var incFromExemptSec10_23FBBtdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.tdsOnAmt')[0];
	var incFromExemptSec10_23FBB1tdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB1.tdsOnAmt')[0];
	var incFromExemptSec10_23FBB2tdsOnAmt= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB2.tdsOnAmt')[0];
	var incFromExemptSec10_23FBBtdsOnAmtTotal= document.getElementsByName('schedulePTI.schedulePTI['+index+'].incFromExemptSec10_23FBB.tdsOnAmtTotal')[0];
	incFromExemptSec10_23FBBtdsOnAmtTotal.value=eval(parseInt(coalesce(incFromExemptSec10_23FBBtdsOnAmt.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB1tdsOnAmt.value),10))+eval(parseInt(coalesce(incFromExemptSec10_23FBB2tdsOnAmt.value),10));

}


function addRowSchedPTIFor3(nocheck) {

	var mainTable = document.getElementById('schedulePTI').rows;
	var noOfRows = mainTable.length;

	var tobeInsertBefore = document.getElementById('schedulePTIAddRow');
	var flag = true;
	var checkFirst = true;
	var totRow = document.getElementById('schedulePTIFirst').cells[0].textContent;

	var iterate = eval(parseInt(totRow, 10));

	var indexValue = eval(parseInt(((parseInt(noOfRows, 10) - 3) / 15) + 1));
	var isRowBlank = true;
	for ( var i = 0; i < 15; i++) {
		if (!checkRowBlank('schedulePTI', (3+i), 0)) {
			isRowBlank = false;
			break;
		}
	}
	if (!isRowBlank || nocheck) {

		for ( var i = 1; i < mainTable.length; i++) {
			var cloneNode = mainTable[i].cloneNode(true);
			if (flag) {
				if (checkFirst) {
					iterate = eval(indexValue - 1);

					cloneNode.cells[0].innerHTML = indexValue;
					checkFirst = false;
				}

				// Numbering
				var inputTags = cloneNode.getElementsByTagName('input');
				for ( var a = 0; a < inputTags.length; a++) {
					inputTags[a].name = inputTags[a].name.replace('[0]', '['
							+ iterate + ']');

					inputTags[a].id = inputTags[a].name.replace(/([\.\[\]])/g,
					'_').replace(/(__)/g, '_');
					inputTags[a].value = '';
					var blurAttr = inputTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					inputTags[a].setAttribute('onblur', blurAttr
							+ 'j.blur(this,this.name,this.value);');
				}
				var selectTags = cloneNode.getElementsByTagName('select');
				for (var a = 0; a < selectTags.length; a++) {
					selectTags[a].name = selectTags[a].name.replace('[0]', '['
							+ iterate + ']');
					selectTags[a].value = '';

					selectTags[a].id = selectTags[a].name.replace(
							/([\.\[\]])/g, '_').replace(/(__)/g, '_');

					var blurAttr = selectTags[a].getAttribute('onblur');
					if (blurAttr != null) {
						blurAttr = blurAttr + ";";
					} else {
						blurAttr = "";
					}
					selectTags[a].setAttribute('onblur', blurAttr
							+ 'j.blur(this,this.name,this.value);');
				}
				document.getElementById('schedulePTI').getElementsByTagName(
				'tr')[0].parentNode.insertBefore(cloneNode,
						tobeInsertBefore);
			}
			if (mainTable[i].id == 'schedulePTIEnd') {
				flag = false;
				break;
			}
		}
		if ($('#schedulePTIAddRow')[0].parentNode.children.length == 12) {
			$('#delPTIButtonId').prop('disabled', true);
		} else if ($('#schedulePTIAddRow')[0].parentNode.children.length > 12) {
			$('#delPTIButtonId').prop('disabled', false);
		}

	} else {
		addErrorXHTML(
				'',
		'Please fill in all the mandatory fields in the last row before adding another row.');
	}
	checkMaxLengthLimit();
}



function deleteRowPTI2(tableId , noOfHeader , noOfFooter){
	try{
		var mytable = document.getElementById(tableId);
		var rowCount = mytable.rows.length;
		var itemCount = (rowCount - 3 )/ 15;
		noOfHeader = parseInt(noOfHeader , 10);
		var isChecked=false;
		var listOfCheckBox = mytable.getElementsByTagName('input');
		var totalChecked = 0;
		for(var z=0; z<listOfCheckBox.length; z++){
			if(listOfCheckBox[z].name.match(".chosenCheckBox$")){
				if(listOfCheckBox[z].checked==true){
					totalChecked = eval( parseInt(totalChecked,10) +1);
					isChecked=true;
				}
			}
		}
		if(!isChecked){
			addErrorXHTML('','Please select a checkbox for deleting row');
		}

		for(var j=1; j<=totalChecked ; j++){
			var totalNoOfInput = mytable.getElementsByTagName('input');

			for(var z=0; z<totalNoOfInput.length; z++){
				if(totalNoOfInput[z].name.match(".chosenCheckBox$")){

					var akhilIndex1 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf('[') ,10)+1);
					var akhilIndex2 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf(']') ,10));
					var rowNumber = totalNoOfInput[z].name.substring(akhilIndex1, akhilIndex2);
					rowNumber = parseInt(rowNumber ,10);

					var myCurrtable = document.getElementById(tableId);
					var rowCurrCount = myCurrtable.rows.length;


					if(totalNoOfInput[z].checked==true){
						if((rowNumber!=0) || (rowNumber==0 &&  parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/9)>1) ){
							rowNumber = eval(parseInt(rowNumber,10) * 9 + noOfHeader);
							for(var i=0;i<15;i++){
								mytable.deleteRow(rowNumber);
							}
							//To Do - reset the name of row for all input , textarea, select
							var newTrList = mytable.getElementsByTagName('tr');
							var newTrListLength = eval(parseInt(newTrList.length ,10)-noOfFooter);
							for( var q=rowNumber; q < newTrListLength ; q++ ){
								var p = parseInt((q-noOfHeader) /9) + noOfHeader;
								//set the serial number;
								if((q-noOfHeader)%9==0){
									if(noOfHeader==2){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-1,10);
									}else if(noOfHeader==1){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p,10);
									}else if(noOfHeader==3){
										newTrList[q].getElementsByTagName('td')[0].innerHTML = parseInt(p-2,10);
									}
								}
								var allInputTags = newTrList[q].getElementsByTagName('input');

								for(var zz=0; zz<allInputTags.length ; zz++ ){
									var index1= allInputTags[zz].name.lastIndexOf('[');
									var index2= allInputTags[zz].name.lastIndexOf(']');

									var str1 = allInputTags[zz].name.substring(0, index1);
									var str3 = allInputTags[zz].name.substring(index2 + 1, allInputTags[zz].name.length);

									allInputTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}

								var allTextAreaTags = newTrList[q].getElementsByTagName('textarea');

								for(var zz=0; zz<allTextAreaTags.length ; zz++ ){
									var index1= allTextAreaTags[zz].name.lastIndexOf('[');
									var index2= allTextAreaTags[zz].name.lastIndexOf(']');

									var str1 = allTextAreaTags[zz].name.substring(0, index1);
									var str3 = allTextAreaTags[zz].name.substring(index2 + 1, allTextAreaTags[zz].name.length);

									allTextAreaTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
								}
							}
							break;
						}else if((rowNumber==0)  && (parseInt(eval(rowCurrCount-noOfHeader-noOfFooter)/9)==1)){
							//Vacate the content if its first row

							for(var m=0; m<15; m++){
								var firstRow = mytable.getElementsByTagName('tr')[parseInt(noOfHeader) + m];
								if(firstRow.getElementsByTagName('input').length > 0 ){

									var firstInputBox = firstRow.getElementsByTagName('input')[0];
									firstInputBox.checked = false;

									var allInputTags = firstRow.getElementsByTagName('input');
									for ( var i = 0; i < allInputTags.length; i++) {
										allInputTags[i].value = "";
									}
									var allSelectTags = firstRow.getElementsByTagName('select');
									for ( var i = 0; i < allSelectTags.length; i++) {
										var elem = allSelectTags[i];
										elem[0].selected = true;
									}
									var allTextAreaTags = firstRow.getElementsByTagName('textarea');
									for ( var i = 0; i < allTextAreaTags.length; i++) {
										allTextAreaTags[i].value = "";
									}
								}
							}
						}
					}
				}
			}
		}
	}catch(e){
		alert('exception caught in =' +e.stack );
	}
}




function calculateCFLTotalNormalPti()
{	
	
	var hpLossCFNormal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal7thyr.value=eval(parseInt(coalesce(hpLossCFNormal7thyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti7thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal7thyr.value;

	var stcgLossCFNormal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal7thyr.value=eval(parseInt(coalesce(stcgLossCFNormal7thyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti7thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal7thyr.value;

	var ltcgLossCFNormal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal7thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal7thyr.value=eval(parseInt(coalesce(ltcgLossCFNormal7thyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti7thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev7ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal7thyr.value;

	var hpLossCFNormal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal6thyr.value=eval(parseInt(coalesce(hpLossCFNormal6thyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti6thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal6thyr.value;

	var stcgLossCFNormal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal6thyr.value=eval(parseInt(coalesce(stcgLossCFNormal6thyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti6thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal6thyr.value;

	var ltcgLossCFNormal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal6thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal6thyr.value=eval(parseInt(coalesce(ltcgLossCFNormal6thyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti6thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev6ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal6thyr.value;

	var hpLossCFNormal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal5thyr.value=eval(parseInt(coalesce(hpLossCFNormal5thyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti5thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal5thyr.value;

	var stcgLossCFNormal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal5thyr.value=eval(parseInt(coalesce(stcgLossCFNormal5thyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti5thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal5thyr.value;

	var ltcgLossCFNormal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal5thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal5thyr.value=eval(parseInt(coalesce(ltcgLossCFNormal5thyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti5thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev5ThYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal5thyr.value;

	var hpLossCFNormal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal4thyr.value=eval(parseInt(coalesce(hpLossCFNormal4thyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti4thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal4thyr.value;

	
	var stcgLossCFNormal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal4thyr.value=eval(parseInt(coalesce(stcgLossCFNormal4thyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti4thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal4thyr.value;

	var ltcgLossCFNormal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal4thyr= document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal4thyr.value=eval(parseInt(coalesce(ltcgLossCFNormal4thyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti4thyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev4thYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal4thyr.value;

	var hpLossCFNormal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal3rdyr.value=eval(parseInt(coalesce(hpLossCFNormal3rdyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti3rdyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal3rdyr.value;

	var stcgLossCFNormal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal3rdyr.value=eval(parseInt(coalesce(stcgLossCFNormal3rdyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti3rdyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal3rdyr.value;

	var ltcgLossCFNormal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal3rdyr= document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal3rdyr.value=eval(parseInt(coalesce(ltcgLossCFNormal3rdyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti3rdyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev3rdYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal3rdyr.value;

	var hpLossCFNormal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPti2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotal2ndyr.value=eval(parseInt(coalesce(hpLossCFNormal2ndyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPti2ndyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotal2ndyr.value;

	var stcgLossCFNormal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPti2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotal2ndyr.value=eval(parseInt(coalesce(stcgLossCFNormal2ndyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPti2ndyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotal2ndyr.value;

	var ltcgLossCFNormal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPti2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotal2ndyr= document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotal2ndyr.value=eval(parseInt(coalesce(ltcgLossCFNormal2ndyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPti2ndyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrev2ndYearFromAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotal2ndyr.value;

	var hpLossCFNormalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPtiPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotalPrevyr.value=eval(parseInt(coalesce(hpLossCFNormalPrevyr.value), 10))+ eval(parseInt(coalesce(hpLossCFPtiPrevyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotalPrevyr.value;

	var stcgLossCFNormalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPtiPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotalPrevyr.value=eval(parseInt(coalesce(stcgLossCFNormalPrevyr.value), 10))+ eval(parseInt(coalesce(stcgLossCFPtiPrevyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotalPrevyr.value;

	var ltcgLossCFNormalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPtiPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotalPrevyr= document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotalPrevyr.value=eval(parseInt(coalesce(ltcgLossCFNormalPrevyr.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPtiPrevyr.value), 10));
	document.getElementsByName('scheduleCFL.lossCFFromPrevYrToAY.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotalPrevyr.value;


	var hpLossCFNormalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.hpLossCFNormal')[0];
	var hpLossCFPtiPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.hpLossCFPti')[0];
	var hpLossCFTotalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.hpLossCFTotal')[0];
	hpLossCFTotalPrevyr1819.value=eval(parseInt(coalesce(hpLossCFNormalPrevyr1819.value), 10))+ eval(parseInt(coalesce(hpLossCFPtiPrevyr1819.value), 10));
	document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.hpLossCFTotal')[0]=hpLossCFTotalPrevyr1819.value;

	var stcgLossCFNormalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.stcgLossCFNormal')[0];
	var stcgLossCFPtiPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.stcgLossCFPti')[0];
	var stcgLossCFTotalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.stcgLossCFTotal')[0];
	stcgLossCFTotalPrevyr1819.value=eval(parseInt(coalesce(stcgLossCFNormalPrevyr1819.value), 10))+ eval(parseInt(coalesce(stcgLossCFPtiPrevyr1819.value), 10));
	document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.stcgLossCFTotal')[0]=stcgLossCFTotalPrevyr1819.value;

	var ltcgLossCFNormalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.ltcgLossCFNormal')[0];
	var ltcgLossCFPtiPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.ltcgLossCFPti')[0];
	var ltcgLossCFTotalPrevyr1819= document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.ltcgLossCFTotal')[0];
	ltcgLossCFTotalPrevyr1819.value=eval(parseInt(coalesce(ltcgLossCFNormalPrevyr1819.value), 10))+ eval(parseInt(coalesce(ltcgLossCFPtiPrevyr1819.value), 10));
	document.getElementsByName('scheduleCFL.lossCFCurrentAssmntYear.carryFwdLossDetail.ltcgLossCFTotal')[0]=ltcgLossCFTotalPrevyr1819.value;

	
	
}

function calcSchTPSA(){

	coalesceSetRet('scheduleTPSA.amount');
	coalesceSetRet('scheduleTPSA.addlIncome');
	coalesceSetRet('scheduleTPSA.surcharge');
	coalesceSetRet('scheduleTPSA.healthEdu');
	coalesceSetRet('scheduleTPSA.total');
	coalesceSetRet('scheduleTPSA.taxesPaid');
	coalesceSetRet('scheduleTPSA.taxPayment.totalTaxPayments');
	coalesceSetRet('scheduleTPSA.taxpayable');

	var amount = document.getElementsByName('scheduleTPSA.amount')[0].value;
	var addlIncome = document.getElementsByName('scheduleTPSA.addlIncome')[0];
	addlIncome.value = Math.round(0.18 * parseInt(coalesce(amount), 10));

	var surcharge = document.getElementsByName('scheduleTPSA.surcharge')[0];
	surcharge.value = Math.round(0.12 * parseInt(coalesce(addlIncome.value), 10));

	var healthEdu = document.getElementsByName('scheduleTPSA.healthEdu')[0];
	healthEdu.value = Math.round(0.04 * (parseInt(coalesce(addlIncome.value), 10) + parseInt(coalesce(surcharge.value), 10)));

	var total = document.getElementsByName('scheduleTPSA.total')[0];
	total.value = parseInt(addlIncome.value,10) + parseInt(surcharge.value,10) + parseInt(healthEdu.value,10);
	//total.value = parseInt(coalesce(addlIncome.value), 10) + parseInt(coalesce(surcharge.value), 10)) + parseInt(coalesce(healthEdu.value), 10));

	var taxesPaid = document.getElementsByName('scheduleTPSA.taxesPaid')[0];
	taxesPaid.value = document.getElementsByName('scheduleTPSA.taxPayment.totalTaxPayments')[0].value;

	var taxpayable = document.getElementsByName('scheduleTPSA.taxpayable')[0];
	taxpayable.value = zeroOrMore(parseInt(total.value, 10) - parseInt(taxesPaid.value, 10));

}
function calculateScheduleDI()
{
	var scheduleviaFlag= document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.invsFlag')[0].value;
	if(scheduleviaFlag=='Y')
	{
		document.getElementsByName('scheduleDI.deductionUndChapVIA[0].deduction')[0].readOnly=false;
		document.getElementsByName('scheduleDI.deductionUndChapVIA[1].deduction')[0].readOnly=false;
		document.getElementsByName('scheduleDI.deductionUndChapVIA[2].deduction')[0].readOnly=false;

	}
	else
	{
		document.getElementsByName('scheduleDI.deductionUndChapVIA[0].deduction')[0].readOnly=true;
		document.getElementsByName('scheduleDI.deductionUndChapVIA[1].deduction')[0].readOnly=true;
		document.getElementsByName('scheduleDI.deductionUndChapVIA[2].deduction')[0].readOnly=true;
		document.getElementsByName('scheduleDI.deductionUndChapVIA[0].deduction')[0].value=parseInt('0', 10);
		document.getElementsByName('scheduleDI.deductionUndChapVIA[1].deduction')[0].value=parseInt('0', 10);
		document.getElementsByName('scheduleDI.deductionUndChapVIA[2].deduction')[0].value=parseInt('0', 10);
	}
	if(scheduleviaFlag=='Y')
	{
		var sec80G = document.getElementsByName('scheduleVIA.deductUndChapVIA.section80G')[0];
		var sec80GGA = document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGA')[0];
		var sec80GGC = document.getElementsByName('scheduleVIA.deductUndChapVIA.section80GGC')[0];

		if(eval(parseInt(coalesce(sec80G.value), 10))>0)
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[0].eligibleAmt')[0].value = eval(parseInt(coalesce(sec80G.value), 10));
		}
		else
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[0].eligibleAmt')[0].value=parseInt('0', 10);
		}

		if(eval(parseInt(coalesce(sec80GGA.value), 10))>0)
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[1].eligibleAmt')[0].value = eval(parseInt(coalesce(sec80GGA.value), 10));
		}
		else
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[1].eligibleAmt')[0].value=parseInt('0', 10);
		}
		if(eval(parseInt(coalesce(sec80GGC.value), 10))>0)
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[2].eligibleAmt')[0].value = eval(parseInt(coalesce(sec80GGC.value), 10));
		}
		else
		{
			document.getElementsByName('scheduleDI.deductionUndChapVIA[2].eligibleAmt')[0].value=parseInt('0', 10);
		}

	}
	else
	{
		document.getElementsByName('scheduleDI.deductionUndChapVIA[0].eligibleAmt')[0].value=parseInt('0', 10);
		document.getElementsByName('scheduleDI.deductionUndChapVIA[1].eligibleAmt')[0].value=parseInt('0', 10);
		document.getElementsByName('scheduleDI.deductionUndChapVIA[2].eligibleAmt')[0].value=parseInt('0', 10);

	}
	var eligibleAmt0 = document.getElementsByName('scheduleDI.deductionUndChapVIA[0].eligibleAmt')[0];
	var eligibleAmt1 = document.getElementsByName('scheduleDI.deductionUndChapVIA[1].eligibleAmt')[0];
	var eligibleAmt2 = document.getElementsByName('scheduleDI.deductionUndChapVIA[2].eligibleAmt')[0];

	var eligibleAmt80DedTotal = document.getElementsByName('scheduleDI.deductionUndChapVIA.eligibleAmt80DedTotal')[0];
	eligibleAmt80DedTotal.value = eval(parseInt(coalesce(eligibleAmt0.value), 10)
			+ parseInt(coalesce(eligibleAmt1.value), 10)
			+ parseInt(coalesce(eligibleAmt2.value), 10));
	document.getElementsByName('scheduleDI.deductionUndChapVIA.eligibleAmt80DedTotal')[0].value=eligibleAmt80DedTotal.value;

	var deduction0 = document.getElementsByName('scheduleDI.deductionUndChapVIA[0].deduction')[0];
	var deduction1 = document.getElementsByName('scheduleDI.deductionUndChapVIA[1].deduction')[0];
	var deduction2 = document.getElementsByName('scheduleDI.deductionUndChapVIA[2].deduction')[0];

	coalesceSetRet('scheduleDI.deductionUndChapVIA[0].deduction');
	coalesceSetRet('scheduleDI.deductionUndChapVIA[1].deduction');
	coalesceSetRet('scheduleDI.deductionUndChapVIA[2].deduction');

	if(eval(parseInt(coalesce(deduction0.value), 10))>eval(parseInt(coalesce(eligibleAmt0.value), 10)))
	{
		j.setFieldError('scheduleDI.deductionUndChapVIA[0].deduction','Deduction attributable to investment/expenditure made between 01.04.2020 to 31.07.2020 cannont exceed Eligible amount of deduction during FY 2019-20');
		addErrorXHTML(document.getElementsByName('scheduleDI.deductionUndChapVIA[0].deduction')[0],'Deduction attributable to investment/expenditure made between 01.04.2020 to 31.07.2020 cannont exceed Eligible amount of deduction during FY 2019-20',true);
		deduction0.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(deduction1.value), 10))>eval(parseInt(coalesce(eligibleAmt1.value), 10)))
	{
		j.setFieldError('scheduleDI.deductionUndChapVIA[1].deduction','Deduction attributable to investment/expenditure made between 01.04.2020 to 30.06.2020 cannont exceed Eligible amount of deduction during FY 2019-20');
		addErrorXHTML(document.getElementsByName('scheduleDI.deductionUndChapVIA[1].deduction')[0],'Deduction attributable to investment/expenditure made between 01.04.2020 to 31.07.2020 cannont exceed Eligible amount of deduction during FY 2019-20',true);
		deduction1.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(deduction2.value), 10))>eval(parseInt(coalesce(eligibleAmt2.value), 10)))
	{
		j.setFieldError('scheduleDI.deductionUndChapVIA[2].deduction','Deduction attributable to investment/expenditure made between 01.04.2020 to 30.06.2020 cannont exceed Eligible amount of deduction during FY 2019-20');
		addErrorXHTML(document.getElementsByName('scheduleDI.deductionUndChapVIA[2].deduction')[0],'Deduction attributable to investment/expenditure made between 01.04.2020 to 30.06.2020 cannont exceed Eligible amount of deduction during FY 2019-20',true);
		deduction2.value=parseInt('0', 10);
	}

	var deduction80Total = document.getElementsByName('scheduleDI.deductionUndChapVIA.deduction80Total')[0];
	deduction80Total.value = eval(parseInt(coalesce(deduction0.value), 10)
			+ parseInt(coalesce(deduction1.value), 10)
			+ parseInt(coalesce(deduction2.value), 10));
	document.getElementsByName('scheduleDI.deductionUndChapVIA.deduction80Total')[0].value=deduction80Total.value;

	var sec54DAmt=0;
	var sec54GAmt=0;
	var sec54GAAmt=0;

	var tableId = document.getElementById('scheduleLtcgunUtilizedCapGain54');
	var rowCount = tableId.rows.length;
	for (var i = 0; i < rowCount - 3; i++) {

		var subCat = document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['
				+ i + '].section')[0].value;
		if(subCat=='54D')
		{
			sec54DAmt=eval(parseInt(coalesce(sec54DAmt), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
		if(subCat=='54G')
		{
			sec54GAmt=eval(parseInt(coalesce(sec54GAmt), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
		if(subCat=='54GA')
		{
			sec54GAAmt=eval(parseInt(coalesce(sec54GAAmt), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
	}
	if(eval(parseInt(coalesce(sec54DAmt), 10))>0)
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[0].amtUtilizedOutOfLtcg')[0].value = eval(parseInt(coalesce(sec54DAmt), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[0].amtUtilizedOutOfLtcg')[0].value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(sec54GAmt), 10))>0)
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[1].amtUtilizedOutOfLtcg')[0].value = eval(parseInt(coalesce(sec54GAmt), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[1].amtUtilizedOutOfLtcg')[0].value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(sec54GAAmt), 10))>0)
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[2].amtUtilizedOutOfLtcg')[0].value = eval(parseInt(coalesce(sec54GAAmt), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.longTermCapitalGain[2].amtUtilizedOutOfLtcg')[0].value=parseInt('0', 10);
	}


	var amtUtilizedOutOfLtcg0 = document.getElementsByName('scheduleDI.longTermCapitalGain[0].amtUtilizedOutOfLtcg')[0];
	var amtUtilizedOutOfLtcg1 = document.getElementsByName('scheduleDI.longTermCapitalGain[1].amtUtilizedOutOfLtcg')[0];
	var amtUtilizedOutOfLtcg2 = document.getElementsByName('scheduleDI.longTermCapitalGain[2].amtUtilizedOutOfLtcg')[0];

	var amtUtilizedOutOfLtcgtotal = document.getElementsByName('scheduleDI.longTermCapitalGain.amtUtilizedOutOfLtcgtotal')[0];
	amtUtilizedOutOfLtcgtotal.value = eval(parseInt(coalesce(amtUtilizedOutOfLtcg0.value), 10)
			+ parseInt(coalesce(amtUtilizedOutOfLtcg1.value), 10)
			+ parseInt(coalesce(amtUtilizedOutOfLtcg2.value), 10));
	document.getElementsByName('scheduleDI.longTermCapitalGain.amtUtilizedOutOfLtcgtotal')[0].value=amtUtilizedOutOfLtcgtotal.value;

	var amtUtilized0 = document.getElementsByName('scheduleDI.longTermCapitalGain[0].amtUtilized')[0];
	var amtUtilized1 = document.getElementsByName('scheduleDI.longTermCapitalGain[1].amtUtilized')[0];
	var amtUtilized2 = document.getElementsByName('scheduleDI.longTermCapitalGain[2].amtUtilized')[0];
	coalesceSetRet('scheduleDI.longTermCapitalGain[0].amtUtilized');
	coalesceSetRet('scheduleDI.longTermCapitalGain[1].amtUtilized');
	coalesceSetRet('scheduleDI.longTermCapitalGain[2].amtUtilized');

	if(eval(parseInt(coalesce(amtUtilized0.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfLtcg0.value), 10)))
	{
		j.setFieldError('scheduleDI.longTermCapitalGain[0].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.longTermCapitalGain[0].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilized0.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(amtUtilized1.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfLtcg1.value), 10)))
	{
		j.setFieldError('scheduleDI.longTermCapitalGain[1].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.longTermCapitalGain[1].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilized1.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(amtUtilized2.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfLtcg2.value), 10)))
	{
		j.setFieldError('scheduleDI.longTermCapitalGain[2].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.longTermCapitalGain[2].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilized2.value=parseInt('0', 10);
	}

	var amtUtilizedLtcgTotal = document.getElementsByName('scheduleDI.longTermCapitalGain.amtUtilizedLtcgTotal')[0];
	amtUtilizedLtcgTotal.value = eval(parseInt(coalesce(amtUtilized0.value), 10)
			+ parseInt(coalesce(amtUtilized1.value), 10)
			+ parseInt(coalesce(amtUtilized2.value), 10));
	document.getElementsByName('scheduleDI.longTermCapitalGain.amtUtilizedLtcgTotal')[0].value=amtUtilizedLtcgTotal.value;



	var sec54DAmt1=0;
	var sec54GAmt1=0;
	var sec54GAAmt1=0;

	var tableId = document.getElementById('scheduleStcgunUtilizedCapGain54');
	var rowCount = tableId.rows.length;
	for (var i = 0; i < rowCount - 3; i++) {
		var subCat = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['
				+ i + '].section')[0].value;
		if(subCat=='54D')
		{
			sec54DAmt1=eval(parseInt(coalesce(sec54DAmt1), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
		if(subCat=='54G')
		{
			sec54GAmt1=eval(parseInt(coalesce(sec54GAmt1), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
		if(subCat=='54GA')
		{
			sec54GAAmt1=eval(parseInt(coalesce(sec54GAAmt1), 10)
					+ parseInt(coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.unUtilizedCapGain54['
							+ i + '].amountUtilized')[0].value), 10));
		}
	}
	if(eval(parseInt(coalesce(sec54DAmt1), 10))>0)
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[0].amtUtilizedOutOfStcg')[0].value = eval(parseInt(coalesce(sec54DAmt1), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[0].amtUtilizedOutOfStcg')[0].value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(sec54GAmt1), 10))>0)
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[1].amtUtilizedOutOfStcg')[0].value = eval(parseInt(coalesce(sec54GAmt1), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[1].amtUtilizedOutOfStcg')[0].value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(sec54GAAmt1), 10))>0)
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[2].amtUtilizedOutOfStcg')[0].value = eval(parseInt(coalesce(sec54GAAmt1), 10));
	}
	else
	{
		document.getElementsByName('scheduleDI.shortTermCapitalGain[2].amtUtilizedOutOfStcg')[0].value=parseInt('0', 10);
	}

	var amtUtilizedOutOfStcg0 = document.getElementsByName('scheduleDI.shortTermCapitalGain[0].amtUtilizedOutOfStcg')[0];
	var amtUtilizedOutOfStcg1 = document.getElementsByName('scheduleDI.shortTermCapitalGain[1].amtUtilizedOutOfStcg')[0];
	var amtUtilizedOutOfStcg2 = document.getElementsByName('scheduleDI.shortTermCapitalGain[2].amtUtilizedOutOfStcg')[0];

	var amtUtilizedOutOfStcgtotal = document.getElementsByName('scheduleDI.shortTermCapitalGain.amtUtilizedOutOfStcgtotal')[0];
	amtUtilizedOutOfStcgtotal.value = eval(parseInt(coalesce(amtUtilizedOutOfStcg0.value), 10)
			+ parseInt(coalesce(amtUtilizedOutOfStcg1.value), 10)
			+ parseInt(coalesce(amtUtilizedOutOfStcg2.value), 10));
	document.getElementsByName('scheduleDI.shortTermCapitalGain.amtUtilizedOutOfStcgtotal')[0].value=amtUtilizedOutOfStcgtotal.value;

	var amtUtilizedStcg0 = document.getElementsByName('scheduleDI.shortTermCapitalGain[0].amtUtilized')[0];
	var amtUtilizedStcg1 = document.getElementsByName('scheduleDI.shortTermCapitalGain[1].amtUtilized')[0];
	var amtUtilizedStcg2 = document.getElementsByName('scheduleDI.shortTermCapitalGain[2].amtUtilized')[0];
	coalesceSetRet('scheduleDI.shortTermCapitalGain[0].amtUtilized');
	coalesceSetRet('scheduleDI.shortTermCapitalGain[1].amtUtilized');
	coalesceSetRet('scheduleDI.shortTermCapitalGain[2].amtUtilized');

	if(eval(parseInt(coalesce(amtUtilizedStcg0.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfStcg0.value), 10)))
	{
		j.setFieldError('scheduleDI.shortTermCapitalGain[0].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.shortTermCapitalGain[0].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilizedStcg0.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(amtUtilizedStcg1.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfStcg1.value), 10)))
	{
		j.setFieldError('scheduleDI.shortTermCapitalGain[1].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.shortTermCapitalGain[1].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilizedStcg1.value=parseInt('0', 10);
	}
	if(eval(parseInt(coalesce(amtUtilizedStcg2.value), 10))>eval(parseInt(coalesce(amtUtilizedOutOfStcg2.value), 10)))
	{
		j.setFieldError('scheduleDI.shortTermCapitalGain[2].amtUtilized','Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account');
		addErrorXHTML(document.getElementsByName('scheduleDI.shortTermCapitalGain[2].amtUtilized')[0],'Amount utilised between 01.04.2020 to 30.09.2020 out of Col 2 cannont exceed Amount utilised out of Capital Gains account',true);
		amtUtilizedStcg2.value=parseInt('0', 10);
	}


	var amtUtilizedStcgTotal = document.getElementsByName('scheduleDI.shortTermCapitalGain.amtUtilizedStcgTotal')[0];
	amtUtilizedStcgTotal.value = eval(parseInt(coalesce(amtUtilizedStcg0.value), 10)
			+ parseInt(coalesce(amtUtilizedStcg1.value), 10)
			+ parseInt(coalesce(amtUtilizedStcg2.value), 10));
	document.getElementsByName('scheduleDI.shortTermCapitalGain.amtUtilizedStcgTotal')[0].value=amtUtilizedStcgTotal.value;


}


function calTotAmtTPSA(){


	var table=document.getElementById('scheduleTPSADtlsTbl');
	var noOfRows=table.rows.length;
	var indexValue=eval(((parseInt(noOfRows,10)-4)));
	var sum = 0;
	var totalTaxPayments= document.getElementsByName('scheduleTPSA.taxPayment.totalTaxPayments')[0];
	for(var i=0;i<indexValue;i++){

		var amount = document.getElementsByName('scheduleTPSA.taxPayment['+i+'].amt')[0].value;
		sum = eval(parseInt(coalesce(sum,10))) + eval(parseInt(coalesce(amount,10)));
	}

	totalTaxPayments.value =  eval(parseInt(coalesce(sum,10)));
	calcSchTPSA();
}




function calculatePercentageSharePrpty()
{
	var totHp = eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent) - 1);

	for (var i = 0; i < totHp; i++) {
		var tempName = 'scheduleHP.propertyDetails[' + i + '].propCoOwnedFlg';
		var val = document.getElementsByName(tempName)[0].value;
		var assessePercentShareProp = 100;
		if (val == 'YES') {
			var tab = document.getElementById('scheduleHP' + eval(parseInt(i) + 1));
			var rowcount = tab.rows.length;
			for (var j = 0; j <rowcount-2; j++) {
				assessePercentShareProp=eval(eval(coalesce(assessePercentShareProp))-
						eval(coalesce(document.getElementsByName('scheduleHP.propertyDetails[' + i
								+ '].coOwners[' + j + '].percentShareProperty')[0].value)));

			}
			document
			.getElementsByName('scheduleHP.propertyDetails[' + i
					+ '].asseseeShareProperty')[0].value=assessePercentShareProp.toFixed(2);
		}
	}
}


function selfOccupiedPrprtyCheck()
{
	var totHp = eval(parseInt(document.getElementById('scheduleHPLast').cells[0].textContent) - 1);
	var count=0;
	for (var i = 0; i < totHp; i++) {
		var tempName = 'scheduleHP.propertyDetails[' + i + '].ifLetOut';
		var val = document.getElementsByName(tempName)[0].value;
		if(val=='N')
		{
			count++;
		}
	}
	if(count>2)
	{
		j.setFieldError('','Self occupied property cannot be selected more than twice.');
		addErrorXHTML('','Self occupied property cannot be selected more than twice.',true);
	}
}



function intrstBorowdCheck()
{

	var tab = document.getElementById('scheduleHPMain');
	var selectTags = tab.getElementsByTagName('select');
	var sumIntrst=parseInt('0', 10);
	for (var i = 0; i < selectTags.length; i++) {
		var selfoccupiedFlag = false;
		if (selectTags[i].name.match("ifLetOut$")) {
			var index = parseInt(selectTags[i].name.substring(selectTags[i].name.indexOf("[") + 1, selectTags[i].name.indexOf("]")));
			if (selectTags[i].value == "N") {
				selfoccupiedFlag=true;
			}
		}
		if(selfoccupiedFlag)
		{
			var intOnBorwCap = document.getElementsByName('scheduleHP.propertyDetails['+index+'].rentdetails.intOnBorwCap')[0];
			sumIntrst=eval(parseInt(coalesce(sumIntrst),10)+parseInt(coalesce(intOnBorwCap.value),10));
			if(sumIntrst >200000)
			{
				j.setFieldError(document.getElementsByName('scheduleHP.propertyDetails['+index+'].rentdetails.intOnBorwCap')[0],
				'Interest cannot be more than Rs. 2,00,000 for category self-occupied in schedule HP.');
				addErrorXHTML('','Interest cannot be more than Rs. 2,00,000 for category self-occupied in schedule HP.',true);
			}
		}
	}
}


function validateSchCGSTCGAmt() {
	var tab = document.getElementById('scheduleStcgDtaa');
	var rowCount = tab.rows.length - 2;

	var residentialStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	if(residentialStatus == 'NRI')
	{
		var totalAmtNotTaxUsDTAAStcgSumNri = 0;
		var totAmtStcgUnderDtaaSumNri = 0;
		for (var i = 0; i < rowCount; i++) {
			if(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].taxResidCertFlag')[0].value=='Y' && 
					(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value=='' ||
							document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value==0))
			{
				totalAmtNotTaxUsDTAAStcgSumNri = parseInt(coalesce(totalAmtNotTaxUsDTAAStcgSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
			if(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].taxResidCertFlag')[0].value=='Y' && 
					(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value!='' &&
							document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value!=0))
			{
				totAmtStcgUnderDtaaSumNri = parseInt(coalesce(totAmtStcgUnderDtaaSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
		}


		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')[0].value=totalAmtNotTaxUsDTAAStcgSumNri;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.AmtStcgUnderDtaa8b')[0].value=totAmtStcgUnderDtaaSumNri;
	}
	else if(residentialStatus != 'NRI')
	{

		var totalAmtNotTaxUsDTAAStcgSumNri = 0;
		var totAmtStcgUnderDtaaSumNri = 0;
		for (var i = 0; i < rowCount; i++) {
			if(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value=='' ||
					document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value==0)
			{
				totalAmtNotTaxUsDTAAStcgSumNri = parseInt(coalesce(totalAmtNotTaxUsDTAAStcgSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amount')[0].value), 10);

			}
			if(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value!='' &&
					document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amntOfIncome')[0].value!=0)
			{
				totAmtStcgUnderDtaaSumNri = parseInt(coalesce(totAmtStcgUnderDtaaSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
		}
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.totAmtStcgUnderDtaa')[0].value=totalAmtNotTaxUsDTAAStcgSumNri;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa.AmtStcgUnderDtaa8b')[0].value=totAmtStcgUnderDtaaSumNri;		
	}
}


function validateSchCGLTCGAmt() {
	var tab = document.getElementById('scheduleLtcgDtaa');
	var rowCount = tab.rows.length - 2;

	var residentialStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	if(residentialStatus == 'NRI')
	{
		var totalAmtNotTaxUsDTAALtcgSumNri = 0;
		var totAmtLtcgUnderDtaaSumNri = 0;
		for (var i = 0; i < rowCount; i++) {
			if(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].taxResidCertFlag')[0].value=='Y' && 
					(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value=='' ||
							document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value==0))
			{
				totalAmtNotTaxUsDTAALtcgSumNri = parseInt(coalesce(totalAmtNotTaxUsDTAALtcgSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
			if(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].taxResidCertFlag')[0].value=='Y' && 
					(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value!='' &&
							document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value!=0))
			{
				totAmtLtcgUnderDtaaSumNri = parseInt(coalesce(totAmtLtcgUnderDtaaSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
		}


		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.totAmtLtcgUnderDtaa')[0].value=totalAmtNotTaxUsDTAALtcgSumNri;
		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.AmtLtcgUnderDtaa10b')[0].value=totAmtLtcgUnderDtaaSumNri;
	}
	else if(residentialStatus != 'NRI')
	{
		var totalAmtNotTaxUsDTAALtcgSumNri = 0;
		var totAmtLtcgUnderDtaaSumNri = 0;
		for (var i = 0; i < rowCount; i++) {
			if(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value=='' ||
					document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value==0)
			{
				totalAmtNotTaxUsDTAALtcgSumNri = parseInt(coalesce(totalAmtNotTaxUsDTAALtcgSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].amount')[0].value), 10);

			}
			if(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value!='' &&
					document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].applicableRate')[0].value!=0)
			{
				totAmtLtcgUnderDtaaSumNri = parseInt(coalesce(totAmtLtcgUnderDtaaSumNri),10)
				+ parseInt(
						coalesce(document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+ i + '].amount')[0].value), 10);
			}
		}
		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.totAmtLtcgUnderDtaa')[0].value=totalAmtNotTaxUsDTAALtcgSumNri;
		document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa.AmtLtcgUnderDtaa10b')[0].value=totAmtLtcgUnderDtaaSumNri;		
	}
}
function calculateFullVal50CStcg()
{
	var table = document.getElementById('scheduleCGstcg1');
	var noOfRows = table.rows.length;

	for (var i = 0; i <parseInt(noOfRows/13,10); i++) {
		var fullConsiderationSt=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+i+'].fullConsideration')[0];
		var propertyValuationSt=document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+i+'].propertyValuation')[0];
		if(eval(parseInt(coalesce(propertyValuationSt.value),10))<=Math.round((1.05 * eval(parseInt(
				coalesce(fullConsiderationSt.value), 10)))))
		{
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0].value=parseInt(
					coalesce(fullConsiderationSt.value), 10);
		}
		else
		{
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0].value=parseInt(
					coalesce(propertyValuationSt.value), 10);
		}
	}

}

function enableTRCFlagSTCG()
{
	var tab = document.getElementById('scheduleStcgDtaa');
	var rowcount = tab.rows.length;
	for (var j = 0; j <parseInt(rowcount-2); j++) {
		if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value == 'NRI')
		{
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+j+'].taxResidCertFlag')[0].disabled=false;
		}
		else
		{
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+j+'].taxResidCertFlag')[0].disabled=true;
			document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.stcgUnderDtaa['+j+'].taxResidCertFlag')[0].value='';
		}
	}
	populateRateSTCG();
	validateSchCGSTCGAmt();
}

function calculateFullVal50CLtcg()
{
	var table = document.getElementById('scheduleCGltcg1');
	var noOfRows = table.rows.length;

	for (var i = 0; i <parseInt(noOfRows/14); i++) {

		var fullConsiderationSt=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration')[0];
		var propertyValuationSt=document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].propertyValuation')[0];
		if(eval(parseInt(coalesce(propertyValuationSt.value),10))<=Math.round((1.05 * eval(parseInt(
				coalesce(fullConsiderationSt.value), 10)))))
		{
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0].value=parseInt(
					coalesce(fullConsiderationSt.value), 10);
		}
		else
		{
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.saleofLandBuild['+ i +'].fullConsideration50C')[0].value=parseInt(
					coalesce(propertyValuationSt.value), 10);
		}
	}

}
function enableTRCFlagLTCG()
{
	var tab = document.getElementById('scheduleLtcgDtaa');
	var rowcount = tab.rows.length;
	for (var j = 0; j <parseInt(rowcount-2); j++) {
		if(document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value == 'NRI')
		{
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+j+'].taxResidCertFlag')[0].disabled=false;
		}
		else
		{
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+j+'].taxResidCertFlag')[0].disabled=true;
			document.getElementsByName('scheduleCGPost45.longTermCapGainPost45.ltcgUnderDtaa['+j+'].taxResidCertFlag')[0].value='';
		}
	}
	populateRateLTCG();
	validateSchCGLTCGAmt();
}
function enableTPSA(){
	var schOIFlag = document.getElementsByName('partaoi.asseSub2ASec92EC')[0].value;
	if(schOIFlag == 'Y'){
		var tabId = "#" + "scheduleTPSA";
		//$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		$(tabId).find(':input').prop('disabled', false);

		$(tabId).find('.addbtn').prop('hidden', false);
	} else{
		var tabId = "#" + "scheduleTPSA";
		//$(tabId).find('[type=\"checkbox\"]').attr('checked', 'checked');
		$(tabId).find(':input').prop('disabled', true);
		$(tabId).find(':input').prop('value', '');
		$(tabId).find('.addbtn').prop('hidden', true);
	}
}



function validateScheduleVIA()
{

	var sec80G = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80G')[0];


	var sec80GGA = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGA')[0];

	var sec80GGC = document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80GGC')[0];
	var total=eval(parseInt(coalesce(sec80G.value), 10)
			+ parseInt(coalesce(sec80GGA.value), 10)
			+ parseInt(coalesce(sec80GGC.value), 10));
	if(total>0 && document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.invsFlag')[0].value=='')
	{
		j.setFieldError('scheduleVIA.usrDeductUndChapVIA.invsFlag','Please select drop down in field Whether, you have made any investment/ deposit/ payments between 01.04.2020 to 31.07.2020 for the purpose of claiming any deduction under Part B of Chapter VIA?');
		addErrorXHTML(document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.invsFlag')[0],'Please select drop down in field Whether, you have made any investment/ deposit/ payments between 01.04.2020 to 31.07.2020 for the purpose of claiming any deduction under Part B of Chapter VIA?',true);
	}
}

function disableSch80(){


	var tab1 = document.getElementById('page30');
	var status = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	var allInputTags1 = tab1.getElementsByTagName('input');

	for (var i = 0; i < allInputTags1.length; i++) {
		if (status=='12') {
			allInputTags1[i].disabled = true;

			$(tab1).find('.addbtn').prop('hidden', true);
		}else{
			allInputTags1[i].disabled = false;
			$(tab1).find('.addbtn').prop('hidden', false);
		}
	}





} 



function getExemption_SI(){
	var age	= calcAgeCommon(document.getElementsByName('partAGEN1.orgFirmInfo.dateOFFormOrIncorp')[0]);
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0]; //RES
	var taxPayer = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0];
	if(taxPayer.value=='I' && age > 59 && age < 80 && (resStatus.value=='RES')){
		return 300000;
	}else if(taxPayer.value=='I' && age >= 80 && (resStatus.value=='RES')){
		return 500000;
	}else if( (taxPayer.value=='I' || taxPayer.value=='H') && (resStatus.value=='RES')){
		return 250000;
	}else{
		return 0;
	}
}




function schVIApartCgreyOff(){
	var status = document.getElementsByName('partAGEN1.filingStatus.returnFileSec.incomeTaxSec')[0].value;
	if (status=='12'){
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAB')[0].readOnly=true;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IBA')[0].readOnly=true;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJA')[0].readOnly=true;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJAA')[0].readOnly=true;

		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].value='';
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80LA')[0].value='';
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].readOnly=true;

		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].value='';
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80LA1A')[0].value='';
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].readOnly=true;

		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IA')[0].value=0;
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IA')[0].value=0;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAB')[0].value='';
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IAB')[0].value=0;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IB')[0].value=0;
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IB')[0].value=0;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IC')[0].value=0;
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80IC')[0].value=0;

		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJA')[0].value='';
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJA')[0].value=0;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJAA')[0].value='';
		document.getElementsByName('scheduleVIA.deductUndChapVIA.section80JJAA')[0].value=0;
		/*	
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.totalDeductionPartc')[0].value=0;
		document.getElementsByName('scheduleVIA.deductUndChapVIA.totalDeductionPartc')[0].value=0;*/
	}else{
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80IAB')[0].readOnly=false;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJA')[0].readOnly=false;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80JJAA')[0].readOnly=false;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA')[0].readOnly = false;
		document.getElementsByName('scheduleVIA.usrDeductUndChapVIA.section80LA1A')[0].readOnly = false;
	}
	caclDedSchVIA();
}


function calcTotSchPL47i(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('badDebtPL');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}
	var badDebtAmtDtlsTotal = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls.total')[0];
	badDebtAmtDtlsTotal.value = coalesce(badDebtAmtDtlsTotal.value);
	badDebtAmtDtlsTotal.value =parseInt(amtTotal,10) ;
}


function calcTotSchPL47ii(){
	var amtTotal = parseInt('0' ,10);
	var tabl = document.getElementById('badDebtPLOthers');
	var allInputTags = tabl.getElementsByTagName('input');

	for(var i = 0; i < allInputTags.length; i++) {
		if (allInputTags[i].name.match("amount$")) {
			amtTotal = eval(parseInt(amtTotal ,10) + parseInt(isNVL(allInputTags[i].value) ,10));
		}
	}


	document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtlsOthers.total')[0].value = amtTotal;

}


function validateSchBPA5(){

	var amtSchBPA5=document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.totExempIncPL')[0];
	var schEIfield1=document.getElementsByName('scheduleEI.interestInc')[0];
	var schEIfield2=document.getElementsByName('scheduleEI.dividendInc')[0];
	var schEIfield3i=document.getElementsByName('scheduleEI.grossAgriReceipt7B8')[0];
	var schEIfield4=document.getElementsByName('scheduleEI.others')[0];
	var schEIfield5=document.getElementsByName('scheduleEI.incChrgblAsPerDTAA')[0];
	var schEIfield6=document.getElementsByName('scheduleEI.incNotChrgblToTax')[0];

	var sumTotalEI = parseInt(coalesce(schEIfield1.value),10)+
	parseInt(coalesce(schEIfield2.value),10)+
	parseInt(coalesce(schEIfield3i.value),10)+
	parseInt(coalesce(schEIfield4.value),10)+
	parseInt(coalesce(schEIfield5.value),10)+
	parseInt(coalesce(schEIfield6.value),10);

	if(amtSchBPA5.value > sumTotalEI){
		j.setFieldError('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.totExempIncPL','In schedule BP Amount of exempt income reduced from Profits and Gains of Business and Profession does not tally with income offered in schedule EI.');
		addErrorXHTML(document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.incCredPL.totExempIncPL')[0],'In schedule BP Amount of exempt income reduced from Profits and Gains of Business and Profession does not tally with income offered in schedule EI.',true);
	}


}



function mandCol5orCol6(){
	var mainTab = document.getElementById('scheduleTCS');
	var mainTabRows = mainTab.rows.length;
	for (var i = 0; i < mainTabRows - 5; i++) {
		var amtbfTCS = document.getElementsByName('scheduleTCS.tcs[' + i + '].amountBF')[0].value;
		var totTCS = document.getElementsByName('scheduleTCS.tcs[' + i + '].totalTCS')[0].value ;
		if (amtbfTCS =='' && totTCS ==''){
			addErrorXHTML(document.getElementsByName('scheduleTCS.tcs[' + i + '].totalTCS')[0],'Please enter in col(5) or col (6) in Sch TCS',true);
			j.setFieldError('scheduleTCS.tcs[' + i + '].totalTCS','Please enter in col(5) or col (6) in Sch TCS');
		}
	}
}



function deleteRowTableSchDI(tableId , noOfHeader , noOfFooter){
	try{
		var mytable = document.getElementById(tableId);
		var rowCount = mytable.rows.length;
		noOfHeader = parseInt(noOfHeader , 10);
		var isChecked=false;
		var listOfCheckBox = mytable.getElementsByTagName('input');
		var totalChecked = 0;
		for(var z=0; z<listOfCheckBox.length; z++){
			if(listOfCheckBox[z].name.match(".chosenCheckBox$")){

				totalChecked = eval( parseInt(totalChecked,10) +1);
				isChecked=true;
			}
		}
		for(var j=1; j<=totalChecked ; j++){      // iterate for total number of checkboxes
			var totalNoOfInput = mytable.getElementsByTagName('input');

			for(var z=0; z<totalNoOfInput.length; z++){
				if(totalNoOfInput[z].name.match(".chosenCheckBox$")){		// if its a chosenCheckBox element

					var akhilIndex1 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf('[') ,10)+1);
					var akhilIndex2 = eval(parseInt(totalNoOfInput[z].name.lastIndexOf(']') ,10));
					var rowNumber = totalNoOfInput[z].name.substring(akhilIndex1, akhilIndex2);
					rowNumber = parseInt(rowNumber ,10);

					var myCurrtable = document.getElementById(tableId);
					var rowCurrCount = myCurrtable.rows.length;



					if((rowNumber!=0) || (rowNumber==0 &&  eval(rowCurrCount-noOfHeader-noOfFooter)>1) ){
						rowNumber = eval(parseInt(rowNumber,10) + noOfHeader);
						mytable.deleteRow(rowNumber);

						//To Do - reset the name of row for all input , textarea, select
						var newTrList = mytable.getElementsByTagName('tr');
						var newTrListLength = eval(parseInt(newTrList.length ,10)-noOfFooter);

						for( var p=rowNumber; p < newTrListLength ; p++ ){	//iterate over all rows from delete point to second last row
							//set the serial number;

							if(noOfHeader==2){
								newTrList[p].getElementsByTagName('td')[0].innerHTML = parseInt(p-1,10);
							}else if(noOfHeader==1){
								newTrList[p].getElementsByTagName('td')[0].innerHTML = parseInt(p,10);
							}else if(noOfHeader==3){
								newTrList[p].getElementsByTagName('td')[0].innerHTML = parseInt(p-2,10);
							}else if(noOfHeader==0){
								newTrList[p].getElementsByTagName('td')[0].innerHTML = parseInt(p+1,10);
							}

							if(rowNumber >= 1 && tableId=="scheduleBA"){
								newTrList[p].getElementsByTagName('td')[0].innerHTML = parseInt(p+1,10);
							}

							var allInputTags = newTrList[p].getElementsByTagName('input');

							for(var zz=0; zz<allInputTags.length ; zz++ ){
								var index1= allInputTags[zz].name.lastIndexOf('[');
								var index2= allInputTags[zz].name.lastIndexOf(']');

								var str1 = allInputTags[zz].name.substring(0, index1);
								var str3 = allInputTags[zz].name.substring(index2 + 1, allInputTags[zz].name.length);

								allInputTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
							}

							var allSelectTags = newTrList[p].getElementsByTagName('select');

							for(var zz=0; zz<allSelectTags.length ; zz++ ){
								var index1= allSelectTags[zz].name.lastIndexOf('[');
								var index2= allSelectTags[zz].name.lastIndexOf(']');

								var str1 = allSelectTags[zz].name.substring(0, index1);
								var str3 = allSelectTags[zz].name.substring(index2 + 1, allSelectTags[zz].name.length);

								allSelectTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
							}

							var allTextAreaTags = newTrList[p].getElementsByTagName('textarea');

							for(var zz=0; zz<allTextAreaTags.length ; zz++ ){
								var index1= allTextAreaTags[zz].name.lastIndexOf('[');
								var index2= allTextAreaTags[zz].name.lastIndexOf(']');

								var str1 = allTextAreaTags[zz].name.substring(0, index1);
								var str3 = allTextAreaTags[zz].name.substring(index2 + 1, allTextAreaTags[zz].name.length);

								allTextAreaTags[zz].name = str1+'[' +eval(parseInt(p,10)-noOfHeader) +']'+str3;
							}
						}
						break;
					}else if((rowNumber==0)  && (eval(rowCurrCount-noOfHeader-noOfFooter)==1)){
						//Vacate the content if its first row

						var firstRow = mytable.getElementsByTagName('tr')[noOfHeader];

						var firstInputBox = firstRow.getElementsByTagName('input')[0];
						firstInputBox.checked = false;

						var allInputTags = firstRow.getElementsByTagName('input');
						for ( var i = 0; i < allInputTags.length; i++) {
							allInputTags[i].value = "";
						}
						var allSelectTags = firstRow.getElementsByTagName('select');
						for ( var i = 0; i < allSelectTags.length; i++) {
							var elem = allSelectTags[i];
							elem[0].selected = true;
						}
						var allTextAreaTags = firstRow.getElementsByTagName('textarea');
						for ( var i = 0; i < allTextAreaTags.length; i++) {
							allTextAreaTags[i].value = "";
						}
					}
				}
			}
		}
		//modifyRow(mytable);
	}catch(e){
		alert('exception caught in =' +e.stack );
	}
}
function populateDI() {
	var date=[];
	var dropdowns = [];
	var table = document.getElementById('scheduleDI10AA');
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-2;i++){
		date[i]=document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].DateSEZAct')[0].value;
		dropdowns[i]=document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].DeductionUs10AAFlg')[0].value;

	}
	deleteRowTableSchDI('scheduleDI10AA',1,1);
	var table1 = document.getElementById('taxDed10AAId');
	var rowCount1 = table1.rows.length;
	for(var i=0;i<rowCount1-4;i++){
		if(document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].value!='')
		{
			if(i==0)
			{
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].UndrtakAsPrSchedule10AA')[0].value = 'Undertaking No '+ eval(parseInt(i, 10) + 1 );
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].AmountDedSchedule10AA')[0].value = document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].value;
			}
			else
			{
				addRowToTableNoCheck('scheduleDI10AA',2,1);
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].UndrtakAsPrSchedule10AA')[0].value = 'Undertaking No '+ eval(parseInt(i, 10) + 1 );
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].AmountDedSchedule10AA')[0].value = document.getElementsByName('schedule10AA.deductSEZ.dedUs10Detail['+i+'].dedFromUndertaking')[0].value;
			}
			if(date[i]!=undefined && dropdowns[i]!=undefined)
			{
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].DateSEZAct')[0].value=date[i];
				document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].DeductionUs10AAFlg')[0].value=dropdowns[i];
			}
		}
	}
}

function checkSchDIpartB(elem){

	var indexString = elem.name;
	var index = indexString.substring(
			indexString.lastIndexOf("[") + 1, 
			indexString.lastIndexOf("]")
	);
	var checked = document.getElementsByName(indexString)[0].checked; 

	var table10AA = document.getElementById('scheduleDI10AA');
	document.getElementsByName('scheduleDI.deductionUnd10AA['+index+'].chosenCheckBox')[0].checked = checked;
}

function updateUndertaking(){

	var table = document.getElementById('scheduleDI10AA');
	var rowCount = table.rows.length;
	for(var i=0;i<rowCount-2;i++){
		if(document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].AmountDedSchedule10AA')[0].value !='' ){

			document.getElementsByName('scheduleDI.deductionUnd10AA['+i+'].UndrtakAsPrSchedule10AA')[0].value = 'Undertaking No '+ eval(parseInt(i, 10) + 1 );

		}



	}

}


function schCgA3greyOff(){
	var status = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].section')[0].value;



	if((status=='RES')&& section =='5AD1biip')
	{
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].fullConsideration')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48aquisitCost')[0].readOnly=true;
		
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48improveCost')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48expOnTrans')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48totalDedn')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].balanceCG')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].lossSec94of7Or94of8')[0].readOnly=true;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].capgainonAssets')[0].readOnly=true;


		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].fullConsideration')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48aquisitCost')[0].value=0;

		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48improveCost')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48expOnTrans')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48totalDedn')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].balanceCG')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].lossSec94of7Or94of8')[0].value=0;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].capgainonAssets')[0].value=0;


	}else{
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].fullConsideration')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48aquisitCost')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48improveCost')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48expOnTrans')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].deductSec48totalDedn')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].balanceCG')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].lossSec94of7Or94of8')[0].readOnly=false;
		document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT[0].capgainonAssets')[0].readOnly=false;



	}

}


function validatePanOrAadhaarPL47(){

	var tab = document.getElementById('badDebtPL');
	var rowCount = tab.rows.length - 2;
	for(var i=0;i<rowCount;i++){
		var aadhaarNum = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls['+i+'].aadhaarNum')[0].value;
		var panNum = document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls['+i+'].pan')[0].value;

		if(aadhaarNum == '' && panNum ==''){

			j.setFieldError('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls['+i+'].pan','Please enter a PAN/ Aadhaar in schedule Profit and Loss A/c.');
			addErrorXHTML(document.getElementsByName('partapl.debitsToPL.debitPlAcnt.badDebtDtls.badDebtAmtDtls['+i+'].pan')[0],'Please enter a PAN/ Aadhaar in schedule Profit and Loss A/c.',true);
		}

	}

}


function addRowSchPLpt63i(){
	var tab = document.getElementById('presumtiveInc44AEReg');
	var rowCount = tab.rows.length - 2;
	if (rowCount == 10) {
		document.getElementById('addButton63i').style.visibility = 'hidden';
	} else {
		document.getElementById('addButton63i').style.visibility = 'visible';
	}

}

function schBPDep321I()
{
	var tab = document.getElementById('natOfBustTradeTableId');
	var noOfRows = tab.rows.length;

	var count = 0;
	for (var i = 0; i < (noOfRows - 2); i++) {
		count++;
		var code = document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[' + i + '].code')[0].value;
		if ((code == '05001') || (code == '06008')) {
			document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].readOnly = false;
			break;
		} 
		else {
			document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].value = '0';
			document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].readOnly = true;
			//enablePt12ii();
		}
	}
}
function enablePt12ii(){
	var tab = document.getElementById('natOfBustTradeTableId');
	var noOfRows = tab.rows.length;
	var flag = true;
	if(noOfRows==5){
		var codeA = document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[0].code')[0].value;
		var codeB = document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[1].code')[0].value;
		var codeC = document.getElementsByName('partAGEN2.natOfBus.natureOfBusiness[2].code')[0].value;
		if((codeA==codeB)||(codeB==codeC)||(codeC==codeA)){
			flag=false;
		}
	}	
	if(flag== true && noOfRows==5 ){
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].readOnly = false;
	}else{
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].value = '';
		document.getElementsByName('itr5ScheduleBP.businessIncOthThanSpec.depreciationAllowITAct32.depreciationAllowUs321I')[0].readOnly = true;
		schBPDep321I();
	}
}

function enableAuditDtlsA2(){

	var incomeOnlyUS44 = document.getElementsByName('partAGEN2.incomeOnlyUS44')[0];
	var incomeExc1cr = document.getElementsByName('partAGEN2.incomeExc1cr')[0];
	var payNtExcd5PerAmt = document.getElementsByName('partAGEN2.payNtExcd5PerAmt')[0];
	var payPrevYrNotExcd5PerPmt = document.getElementsByName('partAGEN2.payPrevYrNotExcd5PerPmt')[0];


	if( incomeOnlyUS44.value =='Y' ){
		incomeExc1cr.disabled = true;
		incomeExc1cr.value = '';
		payNtExcd5PerAmt.disabled = true;
		payNtExcd5PerAmt.value = '';
		payPrevYrNotExcd5PerPmt.disabled = true;
		payPrevYrNotExcd5PerPmt.value = '';
	}else if(incomeOnlyUS44.value == 'N'){
		incomeExc1cr.disabled = false;
		if( incomeExc1cr.value =='Y' ){
			payNtExcd5PerAmt.disabled = false;
			payPrevYrNotExcd5PerPmt.disabled = false;
		}else{
			payNtExcd5PerAmt.disabled = true;
			payNtExcd5PerAmt.value = '';
			payPrevYrNotExcd5PerPmt.disabled = true;
			payPrevYrNotExcd5PerPmt.value = '';
		}
	}	
}



function schAmtcgreyOff(){
	var status = document.getElementsByName('partAGEN1.orgFirmInfo.statusOrCompanyType')[0].value;
	var section = document.getElementsByName('partAGEN1.orgFirmInfo.subStatus')[0].value;



	if((status=='1')&& section =='5')
	{

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].assYr')[0].readOnly=false;

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditFwd')[0].readOnly=false;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0].readOnly=false;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditUtilized')[0].readOnly=false;



	}else{

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].assYr')[0].readOnly=true;

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditFwd')[0].readOnly=true;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0].readOnly=true;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditUtilized')[0].readOnly=true;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditBalBroughtFwd')[0].readOnly=true;
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].balAmtCreditCarryFwd')[0].readOnly=true;



		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].assYr')[0].value='2012-13';

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditFwd')[0].value='';

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditSetOfEy')[0].value='';
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditUtilized')[0].value='';
		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].amtCreditBalBroughtFwd')[0].value='';

		document.getElementsByName('scheduleAMTC.scheduleAMTCUtil[0].balAmtCreditCarryFwd')[0].value='';



	}

}



function enableStcgMutualFund()
{
	var residentialStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var table1 = document.getElementById('scheduleCGstcg2');
	var rowCount1 = table1.rows.length / 10;
	if(residentialStatus=='RES')
	{
		for (var k = 0; k < rowCount1; k++) {
			var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['
					+ k + '].section')[0];
			for (var i = 0; section.length > 0; i++) {
				section.options.remove(0);
			}
			var option1 = document.createElement("option");
			option1.text = "Select";
			option1.value = "";
			var option2 = document.createElement("option");
			option2.text = "(i) 111A [for others]";
			option2.value = "1A";
			section.add(option1);
			section.add(option2);
		}
	}
	else
	{

		for (var k = 0; k < rowCount1; k++) {
			var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['
					+ k + '].section')[0];
			for (var i = 0; section.length > 0; i++) {
				section.options.remove(0);
			}
			var option1 = document.createElement("option");
			option1.text = "Select";
			option1.value = "";
			var option2 = document.createElement("option");
			option2.text = "(i) 111A [for others]";
			option2.value = "1A";
			var option3 = document.createElement("option");
			option3.text = "(ii) 115AD(1)(b)(ii)[proviso for Foreign Institutional Investors]";
			option3.value = "5AD1biip";
			section.add(option1);
			section.add(option2);
			section.add(option3);
		}
	}
}


function enableStcgMutualFundOnload()
{
	var residentialStatus=document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;
	var table1 = document.getElementById('scheduleCGstcg2');
	var rowCount1 = table1.rows.length / 10;
	if(residentialStatus=='RES')
	{
		for (var k = 0; k < rowCount1; k++) {
			var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['
					+ k + '].section')[0];
			var selectedValue=section.value;
			for (var i = 0; section.length > 0; i++) {
				section.options.remove(0);
			}
			var option1 = document.createElement("option");
			option1.text = "Select";
			option1.value = "";
			var option2 = document.createElement("option");
			option2.text = "(i) 111A [for others]";
			option2.value = "1A";
			section.add(option1);
			section.add(option2);
			section.value=selectedValue;
		}
	}
	else
	{

		for (var k = 0; k < rowCount1; k++) {
			var section = document.getElementsByName('scheduleCGPost45.shortTermCapGainPost45.equityMFonSTT['
					+ k + '].section')[0];
			var selectedValue=section.value;
			for (var i = 0; section.length > 0; i++) {
				section.options.remove(0);
			}
			var option1 = document.createElement("option");
			option1.text = "Select";
			option1.value = "";
			var option2 = document.createElement("option");
			option2.text = "(i) 111A [for others]";
			option2.value = "1A";
			var option3 = document.createElement("option");
			option3.text = "(ii) 115AD(1)(b)(ii)[proviso for Foreign Institutional Investors]";
			option3.value = "5AD1biip";
			section.add(option1);
			section.add(option2);
			section.add(option3);
			section.value=selectedValue;
		}
	}
}




function auditEnableDia(){
	var auditdi = document.getElementsByName('partAGEN2.liableSec92Eflg')[0];
	var auditdia = document.getElementsByName('partAGEN2.liableSec92Eflg.accAuditedUs92Eflg')[0];
	var audidiaDate = document.getElementsByName('partAGEN2.sec92Edate')[0];

	if(auditdi.value == 'Y'){
		auditdia.disabled = false;
		if(auditdia.value == 'Y' ){
			audidiaDate.disabled = false;
		}else{
			audidiaDate.disabled = true;
			audidiaDate.value = '';
		}
	}else{
		auditdia.disabled = true;
		auditdia.value = '';
		audidiaDate.disabled = true;
		audidiaDate.value = '';
	}

}



function populateHP_PTI(){
	var mainTable = document.getElementById('schedulePTI').rows;
	var noOfRows = mainTable.length;
	var amount = 0;
	var indexValue = eval(parseInt(((parseInt(noOfRows, 10) - 3) / 15) + 1));
	for ( var i = 0; i < indexValue-1; i++) {
		if(document.getElementsByName('schedulePTI.schedulePTI['+i+'].incFromHP.netIncome')[0].value!=""){
			var incFromHPnetIncome= document.getElementsByName('schedulePTI.schedulePTI['+i+'].incFromHP.netIncome')[0].value;
			amount= parseInt(coalesce(amount), 10)+ parseInt(coalesce(incFromHPnetIncome),10);
			document.getElementsByName('scheduleHP.passThroughIncome')[0].value=amount;
		}
	}
	scheduleHPCalcFor5();
}

function validateSchOSDTAA()
{
	var tab = document.getElementById('scheduleOsNriIncTaxDtaa');
	var rowcount = tab.rows.length;
	var amt1b =parseInt(document.getElementsByName('scheduleOS.incOthThanOwnRaceHorse.interestGross')[0].value,10);
	for (var i = 0; i <parseInt(rowcount-2); i++) {
		if(amt1b <0 && document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].itemIncludedIn')[0].value == '1b')
		{
			document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+i+'].itemIncludedIn')[0].value='';
			addErrorXHTML(document.getElementsByName('scheduleOS.incChargblSplRateOS.nriIncTaxDtaa['+ i + '].itemIncludedIn')[0],
					'Please select a valid drop down',
					true);
		}
	}
}


function schPL48(){

	var pl44 = document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.netPLFrmSpecifiedBus')[0];
	if(pl44.value==0){
		document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD')[0].readOnly=true;
	}else{
		document.getElementsByName('itr5ScheduleBP.specifiedBusinessInc.deductionUs35AD')[0].readOnly=false;
	}
}


function checkFor80PFiledValue(){
	if( getAmt('schedule80P.deductUndChap80P.bankCreditFacilties') >
		getAmt('schedule80P.usrDeductUndSec80P.bankCreditFacilties')  ){
		j.setFieldError('schedule80P.deductUndChap80P.bankCreditFacilties','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.bankCreditFacilties')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
	}
		if( getAmt('schedule80P.deductUndChap80P.cottageIndustry') >
		getAmt('schedule80P.usrDeductUndSec80P.cottageIndustry')  ){
		j.setFieldError('schedule80P.deductUndChap80P.cottageIndustry','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.cottageIndustry')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.marketingOfAgricture') >
		getAmt('schedule80P.usrDeductUndSec80P.marketingOfAgricture')  ){
		j.setFieldError('schedule80P.deductUndChap80P.marketingOfAgricture','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.marketingOfAgricture')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.pruchaseOfAgricuture') >
		getAmt('schedule80P.usrDeductUndSec80P.pruchaseOfAgricuture')  ){
		j.setFieldError('schedule80P.deductUndChap80P.pruchaseOfAgricuture','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.pruchaseOfAgricuture')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.processingOfAgriculture') >
		getAmt('schedule80P.usrDeductUndSec80P.processingOfAgriculture')  ){
		j.setFieldError('schedule80P.deductUndChap80P.processingOfAgriculture','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.processingOfAgriculture')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.collectiveDisposal') >
		getAmt('schedule80P.usrDeductUndSec80P.collectiveDisposal')  ){
		j.setFieldError('schedule80P.deductUndChap80P.collectiveDisposal','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.collectiveDisposal')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.fishingActivities') >
		getAmt('schedule80P.usrDeductUndSec80P.fishingActivities')  ){
		j.setFieldError('schedule80P.deductUndChap80P.fishingActivities','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.fishingActivities')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}

		if( getAmt('schedule80P.deductUndChap80P.primaryCooperative') >
		getAmt('schedule80P.usrDeductUndSec80P.primaryCooperative')  ){
		j.setFieldError('schedule80P.deductUndChap80P.primaryCooperative','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.primaryCooperative')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.cosumerCooperative') >
		getAmt('schedule80P.usrDeductUndSec80P.cosumerCooperative')  ){
		j.setFieldError('schedule80P.deductUndChap80P.cosumerCooperative','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.cosumerCooperative')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.cooperativeSociety') >
		getAmt('schedule80P.usrDeductUndSec80P.cooperativeSociety')  ){
		j.setFieldError('schedule80P.deductUndChap80P.cooperativeSociety','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.cooperativeSociety')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.interestFromInvestment') >
		getAmt('schedule80P.usrDeductUndSec80P.interestFromInvestment')  ){
		j.setFieldError('schedule80P.deductUndChap80P.interestFromInvestment','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.interestFromInvestment')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.incomeFromLetting') >
		getAmt('schedule80P.usrDeductUndSec80P.incomeFromLetting')  ){
		j.setFieldError('schedule80P.deductUndChap80P.incomeFromLetting','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.incomeFromLetting')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		if( getAmt('schedule80P.deductUndChap80P.others') >
		getAmt('schedule80P.usrDeductUndSec80P.others')  ){
		j.setFieldError('schedule80P.deductUndChap80P.others','Amount eligible for deduction cannot exceed value at income column');
		addErrorXHTML( document.getElementsByName('schedule80P.deductUndChap80P.others')[0],
				'Amount eligible for deduction cannot exceed value at income column',
				true);
		
	}
		
		
}



function checkSchEIxmlblock()
{
	var resStatus = document.getElementsByName('partAGEN1.filingStatus.residentialStatus')[0].value;

	var divIncome = parseInt(coalesce(document.getElementsByName('scheduleEI.dividendInc')[0].value));

	if( (resStatus == 'RES') && divIncome > 1000000)
		{
		j.setFieldError('scheduleEI.dividendInc','Dividend income from domestic company should not be entered more than Rs. 10 lakh in schedule EI.');
 		addErrorXHTML(document.getElementsByName('scheduleEI.dividendInc')[0],'Dividend income from domestic company should not be entered more than Rs. 10 lakh in schedule EI.',true);
		}

}


function cflFieldxiii(){
	
	//Balance available of Total of earlier year b/f (xi-xii)
		

		
		var BFLossestotalEarlierYrsHP = document
				.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.hpLossCFTotal')[0];
		BFLossestotalEarlierYrsHP.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.hpLossCFTotal')
				- coalesceSetRet('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.hpLossCFTotal'));

		var BFLossestotalEarlierYrsBUSS = document
				.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.busLossOthThanSpecLossCF')[0];
		BFLossestotalEarlierYrsBUSS.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.busLossOthThanSpecLossCF'));

		var BFLossestotalEarlierYrsSpec = document
		.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.lossFrmSpecBusCF')[0];
		BFLossestotalEarlierYrsSpec.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecBusCF'));

		var BFLossestotalEarlierYrsSpecice = document
		.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.lossFrmSpecifiedBusCF')[0];
		BFLossestotalEarlierYrsSpecice.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmSpecifiedBusCF'));

		var BFLossestotalEarlierYrsIns = document
		.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.lossFrmInsuCF')[0];
		BFLossestotalEarlierYrsIns.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.lossFrmInsuCF'));

		
		var BFLossestotalEarlierYrsSTCG = document
				.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.stcgLossCFTotal')[0];
		BFLossestotalEarlierYrsSTCG.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.stcgLossCFTotal')
				- coalesceSetRet('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.stcgLossCFTotal'));

		var BFLossestotalEarlierYrsLTCG = document
				.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.ltcgLossCFTotal')[0];
		BFLossestotalEarlierYrsLTCG.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.ltcgLossCFTotal')
				- coalesceSetRet('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.ltcgLossCFTotal'));

		var BFLossestotalEarlierYrsOTHSRC = document
				.getElementsByName('scheduleCFL.BFLossestotalEarlierYrs.balanceSummaryDetail.othSrcLossRaceHorseCF')[0];
		BFLossestotalEarlierYrsOTHSRC.value = zeroOrMore(coalesceSetRet('scheduleCFL.totalOfBFLossesEarlierYrs.lossSummaryDetail.othSrcLossRaceHorseCF')
				- coalesceSetRet('scheduleCFL.BFLossesEarlierYrs.lossUnitHolder.othSrcLossRaceHorseCF'));
	}


function enableGrossAmtTDS1()
{
	var tdsTable = document.getElementById('scheduleTDS2');
	var noOfRows = tdsTable.rows.length;

	for (var i = 0; i < (noOfRows - 6); i++) {
		if(document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].headOfIncome')[0].value=='NA')
		{
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].readOnly=true;
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].value='';
		}
		else
		{
			document.getElementsByName('scheduleTDS2.tdSonOthThanSal['+i+'].grossAmount')[0].readOnly=false;
		}
	}
}

function enableAuditDetailsLiable()
{
	var tdsTable = document.getElementById('othSecDateTabId');
	var noOfRows = tdsTable.rows.length;
	for (var i = 0; i < (noOfRows - 2); i++) {
		if(document.getElementsByName('partAGEN2.auditDetails['+i+'].furOthAudReportFlg')[0].value=='Y')
		{
			document.getElementsByName('partAGEN2.auditDetails['+i+'].dateOfAudit')[0].readOnly=false;
		}
		else
		{
			document.getElementsByName('partAGEN2.auditDetails['+i+'].dateOfAudit')[0].readOnly=true;
			document.getElementsByName('partAGEN2.auditDetails['+i+'].dateOfAudit')[0].value='';
		}
	}
}
function enableAuditReportDetails()
{
	var tdsTable = document.getElementById('othSecDateTabId1');
	var noOfRows = tdsTable.rows.length;
	for (var i = 0; i < (noOfRows - 2); i++) {
		if(document.getElementsByName('partAGEN2.auditReportDetails['+i+'].audUSActFlg')[0].value=='Y')
		{
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportDate')[0].readOnly=false;
		}
		else
		{
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportDate')[0].readOnly=true;
			document.getElementsByName('partAGEN2.auditReportDetails['+i+'].auditReportDate')[0].value='';
		}
	}
}
function disableScheduleFor(elementId){
	var tab = document.getElementById(elementId);
	var rowcount = tab.rows.length;
	for(var i=0; i<rowcount;i++){
		var shareonOrBefore = document.getElementsByName('schedule112A.bussinessTrust['+i+'].shareOnOrBefore')[0];
		if(shareonOrBefore){
		    if (shareonOrBefore.value== "AE") {
		    	document.getElementsByName('schedule112A.bussinessTrust['+i+'].iSINCode')[0].disabled = true;
		    	document.getElementsByName('schedule112A.bussinessTrust['+i+'].shareUnitName')[0].disabled = true;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].numSharesUnits')[0].disabled = true;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].salePricePerShareUnit')[0].disabled = true;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].fairMktValuePerShareunit')[0].disabled = true;
				
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].totSaleValue')[0].readOnly=false;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].totSaleValue')[0].disabled=false;
				
		    }else{
		    	document.getElementsByName('schedule112A.bussinessTrust['+i+'].iSINCode')[0].disabled = false;
		    	document.getElementsByName('schedule112A.bussinessTrust['+i+'].shareUnitName')[0].disabled = false;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].numSharesUnits')[0].disabled = false;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].salePricePerShareUnit')[0].disabled = false;
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].fairMktValuePerShareunit')[0].disabled = false;
				
				document.getElementsByName('schedule112A.bussinessTrust['+i+'].totSaleValue')[0].disabled=true;
		    }	
		}
	}
}

function disableScheduleFor115AD(elementId){
	var tab = document.getElementById(elementId);
	var rowcount = tab.rows.length;
	for(var i=0; i<rowcount;i++){
		var shareonOrBefore = document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].shareOnOrBefore')[0];
		if(shareonOrBefore){
	    if (shareonOrBefore.value == "AE") {
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].iSINCode')[0].disabled = true;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].shareUnitName')[0].disabled = true;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].numSharesUnits')[0].disabled = true;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].salePricePerShareUnit')[0].disabled = true;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].fairMktValuePerShareunit')[0].disabled= true;
			
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totSaleValue')[0].readOnly=false;
			document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totSaleValue')[0].disabled=false;
			
	    }else{
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].iSINCode')[0].disabled = false;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].shareUnitName')[0].disabled = false;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].numSharesUnits')[0].disabled = false;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].salePricePerShareUnit')[0].disabled = false;
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].fairMktValuePerShareunit')[0].disabled= false;
	    	
	    	document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totSaleValue')[0].disabled=true;
	    }
		}
	}
}

function disableFieldsBasedOnShare(index){
	var tab = document.getElementById('Sch112A');
	var rowcount = tab.rows.length;
	//for(var i=0; i<rowcount;i++){
	index= index-2;
		var shareonOrBefore = document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareOnOrBefore')[0];
	    if (shareonOrBefore.value == "AE") {
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].readOnly = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].readOnly = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].readOnly = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].readOnly = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].readOnly= true;
		
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].disabled = true;
    	document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].disabled = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].disabled = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].disabled = true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].disabled = true;
		
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].value = 'INNOTREQUIRD';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].value = 'CONSOLIDATED';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].value = 0;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].value = 0;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].value = 0;
		
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].disabled=false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].readOnly=false;
	} else {
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].readOnly = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].readOnly = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].readOnly = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].readOnly = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].readOnly= false;
		
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].disabled = false;
    	document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].disabled = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].disabled = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].disabled = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].disabled = false;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].readOnly=true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].disabled=true;
		
		if(document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].value == 'INNOTREQUIRD'){
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].iSINCode')[0].value = '';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].shareUnitName')[0].value ='';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].numSharesUnits')[0].value ='';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].salePricePerShareUnit')[0].value ='';
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].value ='';

		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].disabled=true;
		document.getElementsByName('schedule112A.bussinessTrust['+index+'].totSaleValue')[0].readOnly=true;
		
		}
	}
	//}
}
function disableFieldsBasedOnShare115Ad1(index){

	var tab = document.getElementById('Sch115Ad1');
	var rowcount = tab.rows.length;
	//for(var i=0;i<rowcount;i++){
	index= index-2;
	var shareOnOrBef= document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareOnOrBefore')[0];
    if(shareOnOrBef.value == "AE") {
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].readOnly = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].readOnly = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].readOnly = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].readOnly = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].readOnly= true;
	
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].disabled = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].disabled = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].disabled = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].disabled = true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].disabled= true;
	
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].value = 'INNOTREQUIRD';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].value = 'CONSOLIDATED';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].value = 0;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].value = 0;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].value =0;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].disabled=false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].readOnly=false;
} else {
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].readOnly = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].readOnly = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].readOnly = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].readOnly = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].readOnly= false;
	
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].disabled = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].disabled = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].disabled = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].disabled = false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].disabled= false;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].disabled=true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].readOnly=true;
	
	if(document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].value == 'INNOTREQUIRD'){
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].iSINCode')[0].value ='';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].shareUnitName')[0].value ='';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].numSharesUnits')[0].value ='';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].salePricePerShareUnit')[0].value ='';
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].fairMktValuePerShareunit')[0].value ='';

	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].disabled=true;
	document.getElementsByName('schedule115Ad1.bussinessTrust['+index+'].totSaleValue')[0].readOnly=true;
	//document.getElementsByName('schedule115Ad1.bussinessTrust['+i+'].totSaleValue')[0].value='';
	}

}
//}
}


