/**
 * 
 */
function checkMandatory() {
    
    // local variable to store the error messages
    var errorString = "";
    
    // check company
    if(window.document.requestForm.company.value == "") {
        errorString += "Please fill in your company name.\n";
    }
    
    // check last name
    if(window.document.requestForm.lastName.value == "") {
        errorString += "Please fill in your last name.\n";
    } else if(window.document.requestForm.lastName.value != "") {
		var lastNameRE = new RegExp(/^[a-zA-Z]+$/);		
		if(!(lastNameRE.test(window.document.requestForm.lastName.value))) {
			errorString += "Please enter a valid last name [A-Z / a-z].\n";
		}
	}
    
    // check first name
    if(window.document.requestForm.firstName.value == "") {
        errorString += "Please fill in your first name.\n";
    } else if(window.document.requestForm.firstName.value != "") {
		var firstNameRE = new RegExp(/^[a-zA-Z .\']+$/);		
		if(!(firstNameRE.test(window.document.requestForm.firstName.value))) {
			errorString += "Please enter a valid first name [A-Z / a-z].\n";
		}
	}
    
    // check address
    if(window.document.requestForm.address.value == "") {
        errorString += "Please fill in your address.\n";
    }
    
    // check city
    if(window.document.requestForm.city.value == "") {
        errorString += "Please fill in your city.\n";
    } else if(window.document.requestForm.city.value != "") {
		var cityRE = new RegExp(/^[a-zA-Z]+$/);
		if(!(cityRE.test(window.document.requestForm.city.value))) {
			errorString += "Please enter a valid city [A-Z / a-z].\n";
		}
	}
	
	// check province/state
	if(document.requestForm.province.value == "") {
		errorString += "Please fill in your province/state.\n";
	}
    
    // check for postal/zip code
    if(window.document.requestForm.postalCode.value == "") {
        errorString += "Please fill in your postal/zip code.\n";
    }
    
	// check country
	if(window.document.requestForm.country.value == "") {
	    errorString += "Please fill in your country.\n";
	} else if(window.document.requestForm.country.value != "") {
        var countryRE = new RegExp(/^[a-zA-Z ]+$/);
        if(!(countryRE.test(window.document.requestForm.country.value))) {
            errorString += "Please enter a valid country [A-Z / a-z].\n";
        }
	}
	
	// check email address
	if(window.document.requestForm.email.value == "") {
	    errorString += "Please fill in your email address.\n";
	} else if(window.document.requestForm.email.value != ""){
		var
			setemail = window.document.requestForm.email.value,
			testemail = /^([\w-]+\.)*?[\w-]+@[\w-]+\.([\w-]+\.)*?[\w]+$/;
		if(!(setemail.match(testemail))) {
			errorString += "Please enter a valid email address [username@domain.com].\n"
		}
	}
	
    // check phone number
    if(window.document.requestForm.phone.value == "") {
        errorString += "Please fill in your phone number.\n"
    } else if(window.document.requestForm.phone.value != "") {
        var phoneRE = new RegExp(/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/);
    }

    
    // generate the loop if error occur and popup the error window
    for (i = 0; i < errorString.length; i++) {
        if (errorString == "") {
            return true;
        } else {
            errorString = "Warring!  We found the following omissions in your form: \n\n" + errorString;
            alert(errorString);
            return false;
        }
    }
}

