function updateamount() {
	document.form.sum1.value = (document.form.invoiceamount.value -0);
	document.form.sum2.value = (document.form.invoiceamount.value -0);
}
function updatesum() {
	document.form.sum.value = (document.form.sum1.value -0) - (document.form.sum2.value -0) + (document.form.sum3.value -0) - (document.form.sum4.value -0);
}
function checkform(){
	if(document.form.sum.value = (document.form.sum1.value -0) - (document.form.sum2.value -0) + (document.form.sum3.value -0) - (document.form.sum4.value -0)!=0){
	
		alert('Transaction does not balance.');

		
		
		return false;
	}
	

	else if(
		
	(document.form.account1.options[form.account1.selectedIndex].value == "0") && ((document.form.sum1.value -0)>0) ||
	(document.form.account2.options[form.account2.selectedIndex].value == "0") && ((document.form.sum2.value -0)>0) ||
	(document.form.account3.options[form.account3.selectedIndex].value == "0") && ((document.form.sum3.value -0)>0) ||
	(document.form.account4.options[form.account4.selectedIndex].value == "0") && ((document.form.sum4.value -0)>0)
	
	 ){
	
		alert('Account not selected');

		
		
		return false;
	}


	return true;
}

function updatetransaction(id) {
	
	if(id==1){

		// Dr Cash 17 Cr Trade Creditors 21
		var accountList1 = document.getElementById("account1");
		var curListOption1 = document.getElementById("c1id17");
		curListOption1.selected = true;


		var accountList2 = document.getElementById("account2");
		var curListOption2 = document.getElementById("c2id21");
		curListOption2.selected = true;

	}else if(id==2){

		// Dr Trade Creditors 21 Cr Cash 17 
		var accountList1 = document.getElementById("account1");
		var curListOption1 = document.getElementById("c1id21");
		curListOption1.selected = true;


		var accountList2 = document.getElementById("account2");
		var curListOption2 = document.getElementById("c2id17");
		curListOption2.selected = true;


	}

}