function account() {
	var moneyPattern = /^\d*(\.\d{1,2})?\b$/;
	var errorMesg = "";
	var b1 = document.getElementById("b1").value;
	var b2 = document.getElementById("b2").value;
	var b4 = document.getElementById("b4").value;
	var b1Val = 0.0;
	var b2Val = 0.0;
	var b4Val = 0.0;
	var subtotal = 0.0;
	var accountBalance = 0.0;

	if( b1.match(moneyPattern) || b1.length == 0) {
		b1Val = parseFloat(b1);
	}
	else {
		errorMesg += "Step B1 is not in the correct numeric notation.\n";
	}
	
	if( b2.match(moneyPattern) || b2.length == 0) {
		b2Val = parseFloat(b2);
	}
	else {
		errorMesg += "Step B2 is not in the correct numeric notation.\n";
	}

	if( b4.match(moneyPattern) || b4.length == 0) {
		b4Val = parseFloat(b4);
	}
	else {
		errorMesg += "Step B4 is not in the correct numeric notation.\n";
	}

	if( isNaN(b1Val) ) {
		b1Val = 0.0;
	}
	if( isNaN(b2Val) ) {
		b2Val = 0.0;
	}
	if( isNaN(b4Val) ) {
		b4Val = 0.0;
	}

	var b3 = document.getElementById("b3");
	var padding = 17 - subtotal.toString().length;
	if( errorMesg.length > 0 ) {
		errorMesg += "Here are few examples of correct decimal notations:\n\n";
		errorMesg += "3\n";
		errorMesg += "3.2\n";
		errorMesg += "3.25\n";
		alert(errorMesg);
		subtotal = "<font color=\"red\">Invalid Input!!!</font>";
		accountBalance = "<font color=\"red\">Invalid Input!!!</font>";
	}
	else {
		subtotal = b1Val + b2Val;
		subtotal = subtotal.toFixed(2);
		accountBalance = subtotal - b4Val;
		accountBalance = accountBalance.toFixed(2);
	}
	b3.innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"> <tr> <td width=\"30\" align=\"left\">&nbsp;&nbsp;3. $</td> <td width=\"100\" align=\"right\">" + subtotal + "&nbsp;&nbsp;</td> </tr> </table>";
	var b5 = document.getElementById("b5");
	b5.innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"> <tr> <td width=\"30\" align=\"left\">&nbsp;&nbsp;5. $</td> <td width=\"100\" align=\"right\">" + accountBalance + "&nbsp;&nbsp;</td> </tr> </table>";
}

function dividend() {
	var moneyPattern = /^\d*(\.\d{1,2})?\b$/;
	var errorMesg = "";
	var c6 = document.getElementById("c6").value;
	var c7 = document.getElementById("c7").value;
	var c8 = document.getElementById("c8").value;
	var c6Val = 0.0;
	var c7Val = 0.0;
	var c8Val = 0.0;
	var bookBalance = 0.0;

	if( c6.match(moneyPattern) || c6.length == 0) {
		c6Val = parseFloat(c6);
	}
	else {
		errorMesg += "Step c6 is not in the correct numeric notation.\n";
	}
	
	if( c7.match(moneyPattern) || c7.length == 0) {
		c7Val = parseFloat(c7);
	}
	else {
		errorMesg += "Step c7 is not in the correct numeric notation.\n";
	}

	if( c8.match(moneyPattern) || c8.length == 0) {
		c8Val = parseFloat(c8);
	}
	else {
		errorMesg += "Step c8 is not in the correct numeric notation.\n";
	}

	if( isNaN(c6Val) ) {
		c6Val = 0.0;
	}
	if( isNaN(c7Val) ) {
		c7Val = 0.0;
	}
	if( isNaN(c8Val) ) {
		c8Val = 0.0;
	}
	if( errorMesg.length > 0 ) {
		errorMesg += "Here are few examples of correct decimal notations:\n\n";
		errorMesg += "3\n";
		errorMesg += "3.2\n";
		errorMesg += "3.25\n";
		alert(errorMesg);
		bookBalance = "<font color=\"red\">Invalid Input!!!</font>";
	}
	else {
		bookBalance = c6Val + c7Val - c8Val;
		bookBalance = bookBalance.toFixed(2);
	}

	var c9 = document.getElementById("c9");
	var padding = 17 - bookBalance.toString().length;
	c9.innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"> <tr> <td width=\"30\" align=\"left\">&nbsp;&nbsp;9. $</td> <td width=\"100\" align=\"right\">" + bookBalance + "&nbsp;&nbsp;</td> </tr> </table>";
}

function addupAmounts(){
    var totalAmount=document.getElementById("totalAmount");
    var moneyPattern = /^\d*(\.\d{1,2})?\b$/;
    var total=0.0;
    for(var i=0;i<36;i++){
        var obj=document.getElementById("a"+i);
        var amount=obj.value;
        if(amount.length!=0 && !amount.match(moneyPattern)){
            obj.style.color="red";
            totalAmount.value="invalid input!!!";
            totalAmount.style.color="red";
            alert("invalid input!!!");
            return;
        } else {
            obj.style.color="black";
        }
        var amountVal=parseFloat(amount);
        if(isNaN(amountVal)) amountVal=0.0;
        total+=amountVal;
    }
    totalAmount.value=total.toFixed(2);
    totalAmount.style.color="black";
}