
function convertMeasurement()
{
	var METERS_SQ_TO_FEET_SQ = 10.7639104167097;
	var ACRES_TO_FEET_SQ = 43560;
	var HECTARES_TO_FEET_SQ = 107639.104167097;
	
	var units = document.getElementById("units_measurement").value;
	var old_units = units;
	if(units != "" && IsNumeric(units))
	{
		var convert_to = document.getElementById("convert_to_m").value;
		var convert_from = document.getElementById("convert_from_m").value;
				
		switch(convert_from)
		{
			case "feet_sq":
				convert_from = "square feet";
				break;
			case "meters_sq":
				units = units * METERS_SQ_TO_FEET_SQ;
				convert_from = "square meters";
				break;
			case "acres": 
				units = units * ACRES_TO_FEET_SQ;
				break;
			case "hectares":
				units = units * HECTARES_TO_FEET_SQ;
				break;
		}
		
		/*Now everything is in feet^2, convert to unit of measurement we want to convert to: */
		switch(convert_to)
		{
			case "feet_sq":
				convert_to = "square feet";
				break;
			case "meters_sq":
				units = units * (1 / METERS_SQ_TO_FEET_SQ);
				convert_to = "square meters";
				break;
			case "acres": 
				units  = units *(1 / ACRES_TO_FEET_SQ );
				break;
			case "hectares":
				units  = units * (1 / HECTARES_TO_FEET_SQ);
				break;
			
		}
			
		document.getElementById("conversion_results_m").innerHTML = "<br />" + old_units + " " + convert_from + " = " + Math.round(units*100)/100 + " " + convert_to;
	}
	else
	{
		alert("Please enter the units (Numerical values only, no special characters or spaces) of the measurement you wish to convert.");	
	}
}

function convertCurrency()
{
	var units = document.getElementById("units_currency").value;
	if(units != "" && IsNumeric(units))
	{	
		var from_option = document.getElementById("convert_from_c");
		var to_option = document.getElementById("convert_to_c");

		/* Get the conversion rates */
		var convert_from = from_option.value;
		var convert_to = to_option.value;
		
		/* Convert into US Dollars first
		 * (Apply from conversion)
		 */
		var from_value_in_usd = units * convert_from;
		/* Then convert from US Dollars to whatever 
		 * (apply to conversion)
		 */
		var to_value = from_value_in_usd / convert_to;
		
		/* Round the value to 2 decimals */
		to_value = Math.round(to_value * 100) / 100
		
		/* Labels are the english name of the currency */
		var message = "<br />" + units + " " + from_option.options[from_option.selectedIndex].label + " = " + to_value + " " + to_option.options[to_option.selectedIndex].label;
		document.getElementById("conversion_results_c").innerHTML = message;
	}
	else
	{
		alert("Please enter the amount of money (Numerical values only, no special characters or spaces) you wish to convert.");	
	}
}