function clearfield(){
	if (document.SearchBox.criteria.value == "Keywords")
	document.SearchBox.criteria.value = "";
}
function clearfieldrg(){
	//if (document.ResetPass.criteria.value == "Keywords")
	document.ResetPass.randompass.value = "";
}
function clearfieldnu(){
	//if (document.ResetPass.criteria.value == "Keywords")
	document.useradd.PID.value = "";
}
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
function open_window2(url,width,height){mywin=window.open(url,"popup",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + width + ',height=' + height);
mywin.focus();
}
function SubmitJob(form) {	
	var string = "";	
	if (!ValidateText(form.J_Title.value,1))
		string = string + "- Please enter a valid value for the Job Title use numbers, letters and (_ or -) only.\n";
	if (!ValidateNumber(form.J_Ref.value,4))
		string = string + "- Please enter a Job Reference, at least 4 characters.\n";	
	if (!ValidateMoney(form.Salary_Top.value,1))
		string = string + "- Please enter a valid Top Salary, 0-9 or period and at least 1 character.\n";	
	if (!ValidateMoney(form.Salary_Bottom.value,1))
		string = string + "- Please enter a valid Bottom Salary, 0-9 or period and at least 1 character.\n";		
	if (!ValidateText(form.Location.value,1))
		string = string + "- Please enter a valid Location.\n";
	if (form.Description.value=="")
				string = string + "- Please enter a valid Description.\n";
	if (form.Contact.value=="")
				string = string + "- Please select a valid Contact.\n";
	if (form.SAS_Category.value=="")
				string = string + "- Please select a valid Recruitment Type.\n";
	if (!ValidateTextArea(form.Category.value,1))
				string = string + "- Please select or enter a valid Sector/Category using numbers, letters, spaces,()?&_-+,.;:*/• only.\n";
	if (form.Sub_Category.value!="")
			{
		if (!ValidateTextArea(form.Sub_Category.value,1))
				string = string + "- Please select or enter a valid Sub Category using numbers, letters, spaces,()?&_-+,.;:*/• only.\n";
		}	
	if (form.Salary_Comments.value!="")
			{
		if (!ValidateTextArea(form.Salary_Comments.value,1))
				string = string + "- Please enter a valid Salary Comment using numbers, letters, spaces,()?&_-+,.;:*/• only.\n";
		}	
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitTM(form) {	
	var string = "";	
	if (!ValidateText(form.Name.value,1))
		string = string + "- Please enter a valid value for the Name use numbers, letters and (_ or -) only.\n";
	if (!ValidateNumber(form.Ranking.value,1))
		string = string + "- Please enter a valid Ranking, numbers only.\n";	
	if (!ValidateTextArea(form.Description.value,1))
				string = string + "- Please enter valid Description using numbers, letters, spaces,()?&_-+,.;:*/•£' only.\n";
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitCat(form) {	
	var string = "";	
	if (!ValidateAlpha(form.Category.value,1))
		string = string + "- Please enter a valid value for the Category, at least one character using letters A-Z and a-z only.\n";
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitPass(form) {	
	var string = "";	 
	if (form.randompass.value=="")
		{
		if (!ValidateText(form.newpass.value,6))
		string = string + "- Please enter a valid value for the Password, a minimum of 6 characters using numbers, letters only.\n";
		}
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitUser(form) {	
	var string = "";	
	if (!ValidateAlpha(form.UID.value,3))
		string = string + "- Please enter a valid value for the User ID use between 3-10 letters only.\n";
	if (!ValidateText(form.Name.value,1))
		string = string + "- Please enter a valid Name.\n";
	if (!ValidateText(form.PID.value,3))
		string = string + "- Please enter a valid value for the Password, between 3-10 characters using numbers, letters only.\n";
	if (!isEmail(form.email.value))
		string = string + "- Please enter a valid email address.\n";
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function ValidateTextArea(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error3="";

		// Step through the UserName one character at a time...
		for (var iLoop=0; iLoop < strUserName.length; iLoop++)
		{
			// Check to see if the current character is valid
			strCurrentChar = strUserName.substring(iLoop,iLoop+1);
			
			if (
				// if A-Z...
				(strCurrentChar >= 'A' && strCurrentChar <= 'Z')
				// or if a-z...
				|| (strCurrentChar >= 'a' && strCurrentChar <= 'z')
				// or if 0-9...
				|| (strCurrentChar >= '0' && strCurrentChar <= '9')
				// or if dash or underscore
				|| strCurrentChar == '-' || strCurrentChar == '_' || strCurrentChar == '!' || strCurrentChar == '&'
				// or other misc
				|| strCurrentChar == ' ' || strCurrentChar == '(' || strCurrentChar == ')' || strCurrentChar == '.'
				|| strCurrentChar == ',' || strCurrentChar == '*' || strCurrentChar == '/' || strCurrentChar == ':'
				|| strCurrentChar == ';' || strCurrentChar == '/' || strCurrentChar == '?' 
				// or enter or line feed or £
				|| strCurrentChar.charCodeAt(0) == 13 || strCurrentChar.charCodeAt(0) == 10 || strCurrentChar.charCodeAt(0)==163
				// Bullet or alt - or '
				|| strCurrentChar.charCodeAt(0) == 8226 || strCurrentChar.charCodeAt(0) == 8211 || strCurrentChar.charCodeAt(0) == 39
				// or Quotes or || ’
				|| strCurrentChar.charCodeAt(0) == 8220 || strCurrentChar.charCodeAt(0) == 8217 || strCurrentChar.charCodeAt(0) == 8216
				// or another bullet
				|| strCurrentChar.charCodeAt(0) == 183 
				);  
			  else
			   // We have an invalid string, set the flag
			   error3 = "illegal";

		}
		
		if ((strUserName.length < csize)) error3="toosmall";
		
		if (error3 != "")
	{
		return false;
	} 
	else
		return true;	
	}
function ValidateNumber(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error6="";
		
		// Step through the UserName one character at a time...
		for (var iLoop=0; iLoop < strUserName.length; iLoop++)
		{
			// Check to see if the current character is valid
			strCurrentChar = strUserName.substring(iLoop,iLoop+1);
			
			if (
				// or if 0-9...
				(strCurrentChar >= '0' && strCurrentChar <= '9')
			   );
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error6 = "illegal";

		}
		
		if ((strUserName.length < csize)) error6="toosmall";
		
		if (error6 != "")
	{
		return false;
	} 
	else
		return true;	
	}
function ValidateMoney(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error6="";
		
		// Step through the UserName one character at a time...
		for (var iLoop=0; iLoop < strUserName.length; iLoop++)
		{
			// Check to see if the current character is valid
			strCurrentChar = strUserName.substring(iLoop,iLoop+1);
			
			if (
				// or if 0-9...
				(strCurrentChar >= '0' && strCurrentChar <= '9') || strCurrentChar == '.'
			   );
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error6 = "illegal";

		}
		
		if ((strUserName.length < csize)) error6="toosmall";
		
		if (error6 != "")
	{
		return false;
	} 
	else
		return true;	
	}
function ValidateText(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error7="";
		
		// Step through the UserName one character at a time...
		for (var iLoop=0; iLoop < strUserName.length; iLoop++)
		{
			// Check to see if the current character is valid
			strCurrentChar = strUserName.substring(iLoop,iLoop+1);
			
			if (
				// if A-Z...
				(strCurrentChar >= 'A' && strCurrentChar <= 'Z')
				// or if a-z...
				|| (strCurrentChar >= 'a' && strCurrentChar <= 'z')
				// or space or &
				|| strCurrentChar == ' ' || strCurrentChar == '&'
				// or if dash or underscore
				|| strCurrentChar == '-' || strCurrentChar == '_' || strCurrentChar == '/'
				// or if 0-9...
				|| (strCurrentChar >= '0' && strCurrentChar <= '9')
			   );
			   
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error7 = "illegal";

		}
		
		if ((strUserName.length < csize)) error7="toosmall";
		
		if (error7 != "")
	{
		return false;
	} 
	else
		return true;	
	}
function isEmail (s)
{           
    var i = 1;
    var sLength = s.length;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (s.match(illegalChars)) return false;

    while ((i < sLength) && (s.charAt(i) != "@"))
    {
		i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    {
		i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}
function ValidateAlpha(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error17="";
		
		// Step through the UserName one character at a time...
		for (var iLoop=0; iLoop < strUserName.length; iLoop++)
		{
			// Check to see if the current character is valid
			strCurrentChar = strUserName.substring(iLoop,iLoop+1);
			
			if (
				// if A-Z...
				(strCurrentChar >= 'A' && strCurrentChar <= 'Z')
				// or if a-z...
				|| (strCurrentChar >= 'a' && strCurrentChar <= 'z')
				// or a space
				|| strCurrentChar == ' '
			   );
			   
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error17 = "illegal";

		}
		
		if ((strUserName.length < csize)) error17="toosmall";
		
		if (error17 != "")
	{
		return false;
	} 
	else
		return true;	
	}