/* -- Check the information being passed to the php -- */
function checkRequired ()
{
	var f = document.form1;
	var errorStr = "";
	var missingObj = new Array();
	var count = 0;
	
	if (isEmpty(f.name.value))
	{
		errorStr += "\n - Name";
		missingObj[count++] = f.name;
	}
	if (isEmpty(f.email.value))
	{
		errorStr += "\n - Email Address";
		missingObj[count++] = f.email;
	} 
	else if ( !isValidEmail(f.email.value))
	{
		errorStr += "\n - Invalid Email Format";
		missingObj[count++] = f.email;
	}
	if(isEmpty(f.textfield.value))
	{
		errorStr += "\n - Comments";
		missingObj[count++] = f.textfield;
	}
    if(errorStr !="")
	{
		alert("The following required data are missing:\n" + errorStr);
		//missingObj[0].focus();
		return false;
    } else {
		return true;
	}
}


function isEmpty(str)
{
    for(var intLoop=0; intLoop<str.length; intLoop++)
      if(str.charAt(intLoop)!=" ")
        return false;
    return true;
}

function isValidEmail(myEmail)
{
	if (myEmail.match(/\w+((-\w+)|(\.\w+)|(_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/) )
		return true;
	else
		return false;
} 


function employmentCheck ()
{
	var f = document.employment;
	var errorStr = "";
	var missingObj = new Array();
	var count = 0;
	
	if (isEmpty(f.name.value))
	{
		errorStr += "\n - Name";
		missingObj[count++] = f.name;
	}
	if (isEmpty(f.email.value))
	{
		errorStr += "\n - Email Address";
		missingObj[count++] = f.email;
	} 
	else if ( !isValidEmail(f.email.value))
	{
		errorStr += "\n - Invalid Email Format";
		missingObj[count++] = f.email;
	}
	if (isEmpty(f.phone.value))
	{
		errorStr += "\n - Phone Number";
		missingObj[count++] = f.phone;
	}
	else if (isNaN(f.phone.value.substr(0, 10)) || ((f.phone.value).length < 10))
    {
		errorStr += "\n - Invalid Phone Format";
		missingObj[count++] = f.phone;
	}
    if(errorStr !="")
	{
		alert("The following required data are missing:\n" + errorStr);
		//missingObj[0].focus();
		return false;
    } else {
		return true;
	}
}


	
	