//==========================================================================
// Function: validateContactForm(this)
// Description : Validates email form to make sure required fields entered
// usage: <form action="/cgi-bin/dbform.cgi" method="POST" onsubmit="return checkform(this);">
// note: June 30, 2001
// Author: Ivan Svetic - D.J.'s Micro-Info Inc. (www.deejays.com)


function checkform ( form )
{
 	

if (form.location[0].selected) {
        alert( "JOB LOCATION is a required field.  Please select a Job Location from the drop down list." );
        form.location.focus();
        return false ;
  }  
  
if (form.job_title.value == "" || form.job_title.value == null) {
        alert( "JOB TITLE is a required field.  Please re-submit the form including the Job Title." );
        form.job_title.focus();
        return false ;
    } 

if (form.organization_name.value == "" || form.organization_name.value == null) {
        alert( "ORGANIZATION NAME is a required field.  Please re-submit the form including the Organization Name." );
        form.organization_name.focus();
        return false ;
    } 
    
if (form.start_date.value == "" || form.start_date.value == null) {
        alert( "JOB START DATE is a required field.  Please re-submit the form including the Job Start Date." );
        form.start_date.focus();
        return false ;
    } 
    
 if (form.job_type[0].selected) {
        alert( "JOB TYPE is a required field.  Please select a Job Type from the drop down list." );
        form.job_type.focus();
        return false ;
  }    
    
        
if (form.job_overview.value == "" || form.job_overview.value == null) {
        alert( "JOB OVERVIEW is a required field.  Please re-submit the form including the Job Overview." );
        form.job_overview.focus();
        return false ;
    }
  
    
if (form.application_details.value == "" || form.application_details.value == null) {
        alert( "PLEASE DETAIL HOW APPLICANTS SHOULD APPLY is a required field.  Please re-submit the form including this information." );
        form.application_details.focus();
        return false ;
    }
        

	if (form.contact_name.value == "" || form.contact_name.value == null) {
        alert( "CONTACT NAME is a required field.  Please re-submit the form including your Contact Name." );
        form.contact_name.focus();
        return false ;
    }


	if (form.contact_phone.value == "" || form.contact_phone.value == null) {
        alert( "CONTACT PHONE is a required field.  Please re-submit the form including your Phone Number." );
        form.contact_phone.focus();
        return false ;
    }
	
	if (form.contact_email.value == "" || form.contact_email.value == null) {
        alert( "CONTACT EMAIL is a required field.  Please re-submit the form including your Email address." );
        form.contact_email.focus();
        return false ;
    }
	
	// test if valid email address, must have @ and .
	var checkEmail = "@.";
	var checkStr = form.contact_email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
		{
			if (ch == checkEmail.charAt(j) && ch == "@")
				EmailAt = true;
			if (ch == checkEmail.charAt(j) && ch == ".")
				EmailPeriod = true;
	  		if (EmailAt && EmailPeriod)
				break;
	  		if (j == checkEmail.length)
				break;
		}
	
	// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
		EmailValid = true
		break;
	}
	}

	if (!EmailValid)
	{
		alert("The \"email\" field must contain an \"@\" and a \".\".");
		form.contact_email.focus();
		return false;
	}		
	
	 
	return true ;
}

//===========================================================================
