	function trim(str, chars) {
		return ltrim(rtrim(str, chars), chars);
	}
 
	function ltrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
 
	function rtrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	function isNumeric(str) {
		return /^\d+$/.test(str);
	}
	function calcComm(what){
		//Shorten DOM call
		switch(what){
			case "comm":
				var v = document.getElementById("salePrice").value;
				var w = "c";
				break;
			case "home":
				var v = document.getElementById("takeHome").value;
				var w = "h";
				break;
		}
		//Check for blank box
		if(trim(v) != ""){
			//Check for number
			if(isNumeric(v) && v > 0){
				v = parseInt(v);
				//Calculate
				if(v <251){
					switch(w){
						case "c":
							var c = v * .1;
							var rt = "10%";
							break;
						case "h":
							var th = v / .9;
							if(th > 250){
								th = v / .91;
							}
							if((th - v) < 5){
								th = v + 5;
							}
							break;
					}
				}
				else if(v < 501){
					switch(w){
						case "c":
							var c = v * .09;
							var rt = "9%";
							break;
						case "h":
							var th = v / .91;
							if(th > 500){
								th = v / .92;
							}
							break;
					}
				}
				else if(v < 1501){
					switch(w){
						case "c":
							var c = v * .08;
							var rt = "8%";
							break;
						case "h":
							var th = v / .92;
							if(th > 1500){
								th = v / .93;
							}
							break;
					}
				}
				else{
					switch(w){
						case "c":
							var c = v * .07;
							var rt = "7%";
							break;
						case "h":
							var th = v / .93;
							if((th - v) > 500){
								th = v + 500;
							}
							break;
					}
				}
				switch(w){
					case "c":
						c = Math.round(c * 100)/100;
						if(c <= 5){c = 5;rt = "Minimum";}
						if(c >= 500){c = 500;rt = "Maximum";}
						var r = v - c;
						if(Math.floor(v) == v){v = v+".00";}else{if(Math.floor(v*10) == v*10){v = v+"0";}}
						if(Math.floor(c) == c){c = c+".00";}else{if(Math.floor(c*10) == c*10){c = c+"0";}}
						if(Math.floor(r) == r){r = r+".00";}else{if(Math.floor(r*10) == r*10){r = r+"0";}}
						
						//Alert the results
						alert("Selling Price: $"+v+"\n\nCommission Taken Out: $"+c+" ("+rt+")\n\nYou will receive: $"+r+"*\n\n*This does NOT include any No Sale fees or Title fees that may apply");
						break;
					case "h":
						th = Math.ceil(th)+".00";
						alert("The item will need to sell for at least: $"+th+"*\n\n*This does NOT include any No Sale fees or Title fees that may apply");
						break;
				}
			}
			else{
				alert("The value you entered is invalid. You must enter a number with no decimal points or commas. Please Try Again.");
			}
		}
		else{
			alert("You did not enter anything into the box. Try again.");
		}
	}