/*

js/ambrose.js

29-JUL-2009	DNK

*/

function initContactUs()
{
	document.getElementById("submit").onclick = validateContactUs;
}

function validateContactUs()
{
	var f = document.forms["contact_form"];
	var c, s;
	if ((s = (c = f.Name).value.trim()) == "")
		return warn(c, "Please enter your name.");
	if ((s = (c = f.Email).value.trim()) == "")
		return warn(c, "Please enter your email address.");
	if ((s = (c = f.Phone).value.trim()) == "")
		return warn(c, "Please enter your contact number.");
	f.submit();
	return false;
}

function warn(c, msg)
{
	alert(msg);
	if (typeof(c) == "object")
	{
		if (c.focus + "" != "undefined") c.focus();
		if (c.select + "" != "undefined") c.select();
	}
	return false;
}

String.prototype.trim = function() { return this.replace(/^\s+(.*?)\s+$/, "$1"); }

