$(document).ready(function() {
		$("#answer").empty();
		$("#calculator").submit(function(){
			calculateVolume();
			return false;
		})
	});
	
	function calculateVolume(){
		$("#answer").html("<div style='color:#cc001b;text-align:center'><img src='images/ajax-loader.gif' />&nbsp;&nbsp;&nbsp;Calculating......</div>");
		$("#calculate").attr("disabled","disabled");
		//length
		var length=eval($("#length").val());
		if(isNaN(length) || length<1){
			alert("Please input the Length");
			$("#length").focus();
			$("#answer").empty();
			$("#calculate").removeAttr("disabled");
			return;
		}
		//width
		var width=eval($("#width").val());
		if(isNaN(width) || width<1){
			alert("Please input the Width");
			$("#width").focus();
			$("#answer").empty();
			$("#calculate").removeAttr("disabled");
			return;
		}
		//depth
		var depth=eval($("#depth").val());
		if(isNaN(depth) || depth<1){
			alert("Please input the Depth");
			$("#depth").focus();
			$("#answer").empty();
			$("#calculate").removeAttr("disabled");
			return;
		}
		setTimeout(function(){
			$("#calculate").removeAttr("disabled");
			var answer=Math.round((((depth*$("#depthunits").val()) * (width*$("#widthunits").val()) * (length*$("#lengthunits").val())) *10) /10) + ""
			$("#answer").html("<div style='color:#cc001b;text-align:center;font-size:13px'>Calculated Volume:<b> "+answer+"m<sup>3<sup></b></div>");
			$('#calc_answer').val(""+answer+"");
		},500)	
	}


