// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function showHideClicker(id) {
	$(id).style.display = $(id).style.display == "none" ? "block" : "none";
	return false;
}
function changeCSSClass(obj, from, to) {
	$(obj).removeClassName(from);
	$(obj).addClassName(to);
}
Number.prototype.toFixed=function(x) {
	var temp=this;
	temp=Math.round(temp*Math.pow(10,x))/Math.pow(10,x);
	return temp;
}
digitalValidator = function(obj) {
	var only_digits_pattern = /^\-{0,1}[0-9.]*$/;
	//if (obj) {
	try {
		if (obj.value && only_digits_pattern.test(obj.value)) {
			changeCSSClass(obj, "not-valid", "valid");
			return true;
		} else {
			changeCSSClass(obj, "valid", "not-valid");
			return false;
		}
	}
	catch(ex) {
		return false;
	}
	//}
}
check_range = function(obj, min, max) {
	if (digitalValidator(obj) && (parseFloat(obj.value) >= min && parseFloat(obj.value) <= max)) {
		changeCSSClass(obj, "not-valid", "valid");
		return true;
	} else {
		changeCSSClass(obj, "valid", "not-valid");
		return false;
	}
}