function fillHidden($field) {
	document.forms["inquiry2"].elements[$field.name].value = document.forms["inquiry1"].elements[$field.name].value;
}

function numbersOnly($str) {
	$s = $str.replace(/\D/g,"");
	return $s;
}

function checkEmail($f) {
// optional 2nd argument: "quiet" suppresses alert messages	
	$str = $f.value;
	filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
	if (!filter.test($str) && $str.length > 0) {
		if (arguments[1]!="quiet") {
			errorBubble("<b>Sorry!</b><br />There appears to be a problem with your email address.");
		}
		return false;
	} else {
		return true;
	}
}

function checkPhone($f) {
// optional 2nd argument: "quiet" suppresses alert messages
	$str = $f.value;
	$s = "";
	if ($str.length>0) {
		// remove all non-numbers
		$s = numbersOnly($str);
		if ($s.length != 10) {
			if (arguments[1]!="quiet") {
				errorBubble("<b>Sorry!</b><br />There appears to be a problem with your Phone Number.");
			}
		}
		$str = "(" + $s.substr(0,3) + ") " + $s.substr(3,3) + "-" + $s.substr(6);
	}
	return $str;
}

function proper($str) {
	return $str.substr(0,1).toUpperCase() + $str.substr(1).toLowerCase();
}
	
function checkForm(f) {
	errorFlag = false;
	message = "<b>Sorry!</b><br />There appears to be a problem with your form submission.<br /><br />";
// name
	if (f.elements["name"].value.length < 3) {
		errorFlag = true;
		message += " - Please enter your name.<br />";
	}
		
// Check for valid email syntax
	if (!checkEmail(f.elements["email"],"quiet") || f.elements["email"].value.length < 1) {
		errorFlag = true;
		message += " - Please enter a valid email address.<br />";
	}
	
// Check phone # for valid characters
	temp = checkPhone(f.elements["phone"],"quiet");
	if (temp.length < 14) {
		message += " - Please enter your 10 digit phone number.<br />";
		errorFlag = true;
	}
	
// description
	if (f.elements["description"].value.length < 10) {
		errorFlag = true;
		message += " - Please provide your project details.<br />";
	}
	
// Final routine	
	if (errorFlag) {
		errorBubble(message);
		return false;
	} else {
		return true;
	}
}

function errorBubble($message) {
	$bubble = document.getElementById("errorBubble");
	$bubble.innerHTML = $message;
// get offsetLeft & Top
	$e = document.getElementById("left_cont");
	$h = $e.offsetHeight;
	$t = 0;
	$l = 0;
	while ($e != null){
		$l += $e.offsetLeft;
		$t += $e.offsetTop;
		$e = $e.offsetParent;
	}
	$bubble.style.left = $l + "px";
	$bubble.style.top = ($t + $h + 10) + "px";
	show("errorBubble");
}
