jQuery(document).ready(function () {
	
		jQuery(".calculateForm").bind("change", function() {calculate(); });
		jQuery(".resetForm").click(function() { location.reload(true) });

});


function calculate() {




jQuery("p.buttonheading a").attr('onclick', '#');
jQuery("p.buttonheading a").attr('href', 'javascript:window.print()');
//alert ("changePrintButton 1");

var overallTotal = 0;
var EveryRoomSubTotal = 0;

var decimalPlace = 1; /* 100 for 2 decimal place. 1000 for 3 decimal place.*/


				jQuery("table#EveryRoom input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
						if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					
					//alert(currentValue);
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					//alert(currentValue);
					
					EveryRoomSubTotal = (EveryRoomSubTotal + parseInt(currentValue) );
					

					
				});

overallTotal = EveryRoomSubTotal;
//EveryRoomSubTotal = '$' + EveryRoomSubTotal	;		
document.getElementById('erSubT').value = EveryRoomSubTotal;

var MasterBedroomSubTotal = 0;

				jQuery("table#MasterBedroom input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					
					
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					MasterBedroomSubTotal = (MasterBedroomSubTotal + parseInt(currentValue) );
				});


overallTotal = overallTotal + MasterBedroomSubTotal;
//MasterBedroomSubTotal = '$' + MasterBedroomSubTotal;			
document.getElementById('mbSubT').value = MasterBedroomSubTotal;

var Bedroom2SubTotal = 0;

				jQuery("table#Bedroom2 input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					Bedroom2SubTotal = (Bedroom2SubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + Bedroom2SubTotal;
//Bedroom2SubTotal = '$' + Bedroom2SubTotal;			
document.getElementById('b2SubT').value = Bedroom2SubTotal;

var Bedroom3SubTotal = 0;

				jQuery("table#Bedroom3 input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					Bedroom3SubTotal = (Bedroom3SubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + Bedroom3SubTotal;
//Bedroom3SubTotal = '$' + Bedroom3SubTotal;			
document.getElementById('b3SubT').value = Bedroom3SubTotal;

var Bedroom4SubTotal = 0;

				jQuery("table#Bedroom4 input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					Bedroom4SubTotal = (Bedroom4SubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + Bedroom4SubTotal;
//Bedroom4SubTotal = '$' + Bedroom4SubTotal;			
document.getElementById('b4SubT').value = Bedroom4SubTotal;

var Bedroom5SubTotal = 0;

				jQuery("table#Bedroom5 input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					Bedroom5SubTotal = (Bedroom5SubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + Bedroom5SubTotal;
//Bedroom5SubTotal = '$' + Bedroom5SubTotal;			
document.getElementById('b5SubT').value = Bedroom5SubTotal;

var StudyRoomSubTotal = 0;

				jQuery("table#StudyRoom input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					StudyRoomSubTotal = (StudyRoomSubTotal + parseInt(currentValue) );
				});


overallTotal = overallTotal + StudyRoomSubTotal;
//StudyRoomSubTotal = '$' + StudyRoomSubTotal;			
document.getElementById('srSubT').value = StudyRoomSubTotal;

var BathroomsSubTotal = 0;

				jQuery("table#Bathrooms input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					BathroomsSubTotal = (BathroomsSubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + BathroomsSubTotal;
//BathroomsSubTotal = '$' + BathroomsSubTotal			
document.getElementById('brSubT').value = BathroomsSubTotal;

var LaundrySubTotal = 0;

				jQuery("table#Laundry input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					LaundrySubTotal = (LaundrySubTotal + parseInt(currentValue) );
				});


overallTotal = overallTotal + LaundrySubTotal;
//LaundrySubTotal = '$' + LaundrySubTotal;			
document.getElementById('lauSubT').value = LaundrySubTotal;

var LoungeRoomSubTotal = 0;

				jQuery("table#LoungeRoom input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					LoungeRoomSubTotal = (LoungeRoomSubTotal + parseInt(currentValue) );
				});


overallTotal = overallTotal + LoungeRoomSubTotal;
//LoungeRoomSubTotal = '$' + LoungeRoomSubTotal			
document.getElementById('louSubT').value = LoungeRoomSubTotal;

var KitchenSubTotal = 0;

				jQuery("table#Kitchen input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					KitchenSubTotal = (KitchenSubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + KitchenSubTotal;
//KitchenSubTotal = '$' + KitchenSubTotal			
document.getElementById('kitSubT').value = KitchenSubTotal;

var DiningRoomSubTotal = 0;

				jQuery("table#DiningRoom input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					DiningRoomSubTotal = (DiningRoomSubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + DiningRoomSubTotal;
//DiningRoomSubTotal = '$' + DiningRoomSubTotal			
document.getElementById('dinSubT').value = DiningRoomSubTotal;

var GarageSubTotal = 0;

				jQuery("table#Garage input.calculateForm").each(function(){
					
				
					var currentValue = jQuery(this).val();
					if (currentValue == "") {
							currentValue = "0";
						}
					currentValue = currentValue.replace(/[^0-9\.]/g, '');
					currentValue =  Math.round(currentValue * decimalPlace) / decimalPlace;
					
					
					GarageSubTotal = (GarageSubTotal + parseInt(currentValue) );
				});

overallTotal = overallTotal + GarageSubTotal;
//GarageSubTotal = '$' + GarageSubTotal			
document.getElementById('garSubT').value = GarageSubTotal;


//overallTotal = '$' + overallTotal	
document.getElementById('overallTotal').value = overallTotal;


}

