
function checkEmail(email) {
	if (email.length>0)
	{
		var flag = true;
		if (email.indexOf('@')==-1) flag=false;
		if (email.indexOf('.')==-1) flag=false;
		if (email.length<6) flag=false;
		if (flag) {
			return true;
		} else {
			return false;
		}
	}
	return false;
}


function SubmitIt(type) {
	var f = document.form1;
	with (f)
	{
		if (firstname.value.length<1) {alert("Please enter your first name"); return false;}
		if (lastname.value.length<1)  {alert("Please enter your last name"); return false;}

		if (type=='full') { if (dob.value.length<1)  {alert("Please enter your date of birth"); return false;} }

		if (!checkEmail(email.value))  {
			alert("Your email address appears to be incorrectly entered. If\nyou do not have an email address of your own, please enter\n\"no_email@miningemployment.com.au\" in the email field.");
			return false;
		}

		if (type=='full') { if (phone1.value.length<1)  {alert("Please enter a contact phone number"); return false;} }

		// Checking Resume
		if (resume.value.length > 0)
		{
			var theContent		= document.form1.resume.value;
			var LastSlash	 	= theContent.lastIndexOf("\\");
			theContent			= theContent.substring(LastSlash+1,theContent.length);
			var LastDot 		= theContent.lastIndexOf(".");
			var theExtention	= theContent.substring(LastDot+1,theContent.length);
			
			theExtention		= theExtention.toLowerCase();

			if ((theExtention != "txt") && (theExtention != "doc") && (theExtention != "rtf") && (theExtention != "docx"))
			{
				alert("Please only upload files of type .txt, .doc, .docx or .rtf");
				return false;
			}
		}
	}
	return true;
}

function SubmitVacancy(f)
{
	with (f)
	{
		if (org.value.length<1) {alert("Please enter your company name"); return false;}
		if (salutation.value.length<1) {alert("Please enter your title"); return false;}
		if (firstname.value.length<1) {alert("Please enter your first name"); return false;}
		if (lastname.value.length<1)  {alert("Please enter your last name"); return false;}
		if (position.value.length<1)  {alert("Please enter your position"); return false;}

		if (!checkEmail(email.value))  {
			alert("Your email address appears to be incorrectly entered.");
			return false;
		}

		if (phone1.value.length<1)			{alert("Please enter a contact phone number"); return false;}
		if (suburb.value.length<1)			{alert("Please enter your company address"); return false;}
		if (postcode.value.length<1)		{alert("Please enter your company postcode"); return false;}
		if (state.value.length<1)			{alert("Please enter your company state"); return false;}
		if (vacancy_title.value.length<1)	{alert("Please enter the position you wish to advertise"); return false;}
		if (location.value.length<1)  		{alert("Please enter the location of the vacancy"); return false;}
		if (desc.value.length<1)			{alert("Please enter the job description"); return false;}
		if (resume.value.length > 0) document.Form1.attach.value = 'yes';

	if (verificationCode) {
		if (verificationCode.value.length<1) {alert("Please enter the verification code.");return false;}
	}
	}
	return true;
}


function submitMail(f)
{
	with (f)
	{
		if (fname.value.length<1) {alert("Please enter your first name"); return false;}
		if (lname.value.length<1)  {alert("Please enter your last name"); return false;}
		if (email.value.length>0)  {
			if (!checkEmail(email.value))  {
				alert("Your email address appears to be incorrectly entered.");
				return false;
			}
		}
	}
	return true;
}
