var $j = jQuery.noConflict();
function isFloat(val) {
	if(!val || (typeof val != "string" || val.constructor != String)) {
		return(false);
	}
	var isNumber = !isNaN(new Number(val));
	if(isNumber) {
		if(val.indexOf('.') != -1) {
		return(true);
	} else {
		return(false);
	}
	} else {
	return(false);
	}
}

function calculateArea(){
		
		if( ($('width_ft').value.search(/\S/) == -1) ){ 
			$('width_ft').className = 'error';
			$('width_ft').focus();
			return false;
		}else $('width_ft').className = 'textbox';
		
		if($('width_ft').value < 3){
			$('width_ft').value = '';
			alert("Please enter minimum dimension of 3 ft");
			$('width_ft').focus();
			return false;
		}
		
		if( ($('length_ft').value.search(/\S/) == -1) ){ 
			$('length_ft').className = 'error';
			$('length_ft').focus();
			return false;
		}else $('length_ft').className = 'textbox';
		
		if($('length_ft').value < 3){
			$('length_ft').value = '';
			alert("Please enter minimum dimension of 3 ft");
			$('length_ft').focus();
			return false;
		}
		
		var width_ft  = parseInt($('width_ft').value);
		if($('width_in').value.search(/\S/) != -1)
			width_ft = width_ft + parseInt($('width_in').value)/12;
			
		var length_ft = parseInt($('length_ft').value);
		if($('length_in').value.search(/\S/) != -1)
			length_ft = length_ft + parseInt($('length_in').value)/12;
			
		var ft = width_ft*length_ft;
		ft = ft.toString();
		if(isFloat(ft)){ 
		  ft = parseFloat(ft);
		  ft = ft.toFixed(2);
		}
		var yd = ft/9;
		yd = yd.toString();
		if(isFloat(yd)){ 
		  yd = parseFloat(yd);
		  yd = yd.toFixed(2);
		}
		
		$('area').innerHTML = '<div style="font-size:14px; "><div>Floor Area : '+ yd +' yd<sup>2</sup></div><div style="padding-left:80px;">( '+ ft +' ft<sup>2</sup> )</div></div>';
	
	return false;
}