function validateLogin(f)
{
	if (f.un.value == '')
	{
		showError('Please entert your Username to log in.', f.un);
		return false;
	}
	
	if (f.pw.value == '')
	{
		showError('Please enter your Password to log in.', f.pw);
		return false;
	}
	
	return true;
}

function validateAddCountry(f)
{
	if (f.cty_name.value == '')
	{
		showError('Please enter the name of the Country to create it', f.cty_name);
		return false;
	}
	
	return true;
}

function validateAddDomain(f)
{
	if (f.dmn_name.value == '')
	{
		showError('Please enter the name of the Domain to create it', f.dmn_name);
		return false;
	}
	
	if (f.dmn_prefix.value == '')
	{
		showError('Please enter the prefix of the Domain to create it', f.dmn_prefix);
		return false;
	}
	
	if (f.dmn_title.value == '')
	{
		showError('Please enter the title of the Domain to create it', f.dmn_title);
		return false;
	}
	
	return true;
}

function validateAddState(f)
{
	if (f.sta_name.value == '')
	{
		showError('Please enter the name of the State to create it', f.sta_name);
		return false;
	}
	
	return true;
}

function validateAddRegion(f)
{
	if (f.rgn_name.value == '')
	{
		showError('Please enter the name of the Region to create it', f.rgn_name);
		return false;
	}
	
	return true;
}

function validateResume(f)
{
	if (f.jbs_firstname.value == '')
	{
		showError('Please enter your first name to continue', f.jbs_firstname);
		return false;
	}
	
	if (f.jbs_lastname.value == '')
	{
		showError('Please enter your last name to continue', f.jbs_lastname);
		return false;
	}

	if (f.jbs_phone.value == '' && f.jbs_mobile.value == '')
	{
		showError('Please enter a contact phone number to continue', f.jbs_phone);
		return false;
	}
	
	if (f.jbs_email.value == '')
	{
		showError('Please enter your email address to continue', f.jbs_email);
		return false;
	}
	
	if (f.ofc_id.selectedIndex == 0)
	{
		showError('Please select at least one (1) office to continue', f.ofc_id);
		return false;
	}
	
	if (f.rsm_resume.value == '')
	{
		showError('Please attach your electronic resume to continue', f.rsm_resume);
		return false;
	}
	
	if (f.rsm_resume.value != "")
	{
		var fn = f.rsm_resume.value;
		var fe = getfileextension(fn).toLowerCase();
		
		if (fe == ".doc" || fe == ".docx" || fe == ".pdf")
		{
			
		}
		else
		{
			alert(fe);
			
			showError('Please attach only Word (.doc, .docx) or PDF (.pdf) resumes to continue', f.rsm_resume);
			return false;
		}
	}
	
	return true;
}

function getfileextension(inputVal)
{ 
	var filename = inputVal;
	if (filename.length == 0) return "";
	
	var dot = filename.lastIndexOf(".");
	if (dot == -1) return "";
	
	var extension = filename.substr(dot,filename.length);
	
	return extension;
}

function validateFeedback(f)
{
	if (f.Name.value == '')
	{
		showError('Please fill in your Name to continue', f.Name);
		return false;
	}
	
	if (f.Phone.value == '')
	{
		showError('Please fill in your Phone number to continue', f.Phone);
		return false;
	}
	
	if (f.Email.value == '')
	{
		showError('Please fill in your Email Address to continue', f.Email);
		return false;
	}
	
	return true;
}

function validateAddClient(f)
{
	for (i=0; i != f.length; i++)
	{
		if (f[i].type == 'text' && f[i].value == '')
		{
			showError('Please fill in all the boxes to continue', f[i]);
			return false;
		}
	}
	
	if (f.cln_pword.value != f.cln_pword_c.value)
	{
		showError('Your Password Confirmation is different to your Password.\nPlease re-enter to verify the Password.', f.cln_pword_c);
		f.cln_pword_c.select();
		return false;
	}
	
	return true;
}

function validatePlaceJob(f)
{
	for (i=0; i != f.length; i++)
	{
		if (f[i].type == 'text' && f[i].value == '')
		{
			showError('Please fill in all the boxes to continue. Use NA where Not Applicable', f[i]);
			return false;
		}
	}
	
	return true;
}

function validatePlaceNursingJob(f)
{
	for (i=0; i != f.length; i++)
	{
		if (f[i].type == 'text' && f[i].value == '')
		{
			showError('Please fill in all the boxes to continue', f[i]);
			return false;
		}
	}
	
	return true;
}

function validateRFI(f)
{
	for (i=0; i != f.length; i++)
	{
		if ((f[i].type == 'text' || f[i].type == 'textarea') && f[i].value == '')
		{
			showError('Please fill in all the boxes to continue', f[i]);
			return false;
		}
	}
	
	return true;
}

function validateAddBusiness(f)
{
	for (i=0; i != f.length; i++)
	{
		if ((f[i].type == 'text' || f[i].type == 'textarea') && f[i].name != 'bsn_web' && f[i].name != 'bsn_email' && f[i].value == '')
		{
			showError('Please fill in all the boxes to continue.\nUse NA if no information is available or applicable.', f[i]);
			return false;
		}
	}
	
	if (f.bsn_email.value != '' && (f.bsn_email.value.indexOf('@') == -1 || f.bsn_email.value.indexOf('.') == -1))
	{
		showError('Please ensure the email address is correct.', f.bsn_email);
		return false;
	}
	
	if (f.bsn_web.value == 'http://')
	{
		showError('Please enter the full web address or delete the http:// part if there is no address', f.bsn_web);
		return false;
	}
	
	return true;
}

function showError(msg, ctrl)
{
	window.alert(msg);
	ctrl.focus();
}