function validContactUs()
{
	var ayReqFields = new Array();
	ayReqFields[0] = "company";
	ayReqFields[1] = "first";
	ayReqFields[2] = "last";
	ayReqFields[3] = "jobtitle";
	ayReqFields[4] = "state";
	ayReqFields[5] = "zip";
	ayReqFields[6] = "country";
	ayReqFields[7] = "phone";
	ayReqFields[8] = "email";
	

	if(requireFields(ayReqFields, 8))
		document.frmContact.submit();
}

function validLogin()
{
	var ayReqFields = new Array();
	ayReqFields[0] = "email";
	ayReqFields[1] = "password";

	if(requireFields(ayReqFields, 0))
		document.frmLogin.submit();
}

function requireFields(ayFields, nEmailFieldIndex)
{
	if(ayFields==null || !isArray(ayFields)){
		alert("Error in requireFields():\nayFields parameter is null or not an array");
		return false;
	}
	
	rS = /\s/g;
	rE = /[\w\-.]+@[a-zA-Z0-9]{1}[\w\-.]+\.[a-zA-Z]{2,3}/i;
	var oField = null;
	var cField = null;

	//check each field make sure it is not empty
	for(var i = 0; i < ayFields.length; i++)
	{
		cField = "";
		oField = document.getElementById(ayFields[i]);
		if(oField != null) cField = oField.value;

		if(cField.replace(rS, "") == ""){
			alert("All fields marked with an asterisk are required.");
			//alert("All fields marked with an asterisk are required.\nPlease fill in the \"" + ayFields[i] + "\" field.");
			return false;
		}
	}

	//if needed, check one of the fields for valid email address format
	if(nEmailFieldIndex != null && isNumber(nEmailFieldIndex) && nEmailFieldIndex < ayFields.length)
	{
		var oEmail = document.getElementById(ayFields[nEmailFieldIndex]);
		if(oEmail != null){
			var cEmail = oEmail.value;
			cEmail = cEmail.replace(rS, "")
			if(rE.test(cEmail)==false){
				alert("You typed in an invalid email address. Please check it and try again.");
				return false;
			}
		}
	}

	return true;
}

function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
    return typeof a == 'boolean';
}

function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}

function isFunction(a) {
    return typeof a == 'function';
}

function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 
