$(document).ready ( function() {
							 
	// check for calculate button click
	$('#calculate').click ( function() {
	
		var linearSquareMetreCost = 37.00;
		var wallDepth = 0; // mm
		var wallWidth = 0; //
		var price = 0.00; 
		var unit = $('#unit').val();
		var drops = 0;
		var lin = 0;
		var vat_rate = 17.5;
		var vat = 0.00;
		
		// get the depth and width
		wallDepth = $('#depth').val();
		wallWidth = $('#width').val();

		if ( wallDepth != '' && wallWidth != '' ) {
			
			wallDepth = parseFloat ( wallDepth );
			wallWidth = parseFloat ( wallWidth );
			
			if ( unit != 'mm' ) {
			
			
				// check for feet
				if ( unit == 'ft' ) {
				
					// convert the feet to mm
					// feet * 304.8
					wallDepth = wallDepth * 304.8;
					wallWidth = wallWidth * 304.8;
					
					
				}
				
				if ( unit == 'me' ) {
					
					wallDepth = wallDepth * 1000;
					wallWidth = wallWidth * 1000;
					
				}
			}
			
			// work out the number of drops
			drops =  Math.ceil( wallWidth / 600 );
			
		
		
			// work out how many linear square metres
			lin = ( wallDepth + drops * 100 ) * ( drops * 600 ) / 1000000;
		
			// work out final price
			price = parseFloat ( linearSquareMetreCost * lin );
			
			// work out vat
			vat = ( price * vat_rate ) / 100;
			
			// sho price
			$('#price').html ( price.toFixed ( 2 ) );
			$('#vat').html ( vat.toFixed ( 2 ) );
			
		} else {
				
				alert ( "Please complete the wall width and depth" );
				
		}
	
	});
							 
							 
});