function clearfield(){
	if (document.SearchBox.criteria.value == "Keyword or Ref No")
	document.SearchBox.criteria.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 SubmitForm(form) {	
	var string = "";	
	//if (!ValidateUserName(form.criteria.value,1))
		//string = string + "- Please enter a valid value for your Keywords..\n- Please user numbers, letters and (_ or -) only.\n";
	if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitAdv(form) {	
	var string = "";	
	if (!ValidateKeywordText(form.Keywords.value))
		string = string + "- Please enter a valid value for your Keywords..\n- Please user letters and spaces only.\n";
	if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitApp(form) {	
	var string = "";	
	if (!ValidateUserName(form.Name.value,1))
		string = string + "- Please enter a valid value for your name use numbers, letters and (_ or -) only.\n";
	if (!isEmail(form.Email.value))
		string = string + "- Please enter a valid email address.\n";
	if (!isEmail(form.Email2.value))
		string = string + "- Please confirm your valid email address.\n";
	if (form.Email.value!= form.Email2.value)
		string = string + "- Your Email addresses do not match.\n";	
	if (!ValidatePhone(form.Telephone.value,6))
		string = string + "- Please enter a valid telephone number, use a minimum of 6 numbers,spaces,() and _ or - only.\n";		
	if (form.Telephone2.value!="")
			{
		if (!ValidatePhone(form.Telephone2.value,6))
				string = string + "- Please enter a valid alternate telephone number using a minimum of 6 numbers,spaces,() and _ or - only.\n";
		}	
if (string != "")
	{
		alert(string);
		return false;
	} 
	else
		return true;
}
function SubmitEmail(form) {	
	var string = "";	
	if (!ValidateUserName(form.Name.value,1))
		string = string + "- Please enter a valid value for your name use numbers, letters and (_ or -) only.\n";
	if (!isEmail(form.Email.value))
		string = string + "- Please enter a valid email address.\n";
	if (!isEmail(form.Email2.value))
		string = string + "- Please enter a valid email address to Send To.\n";
	if (!ValidateText(form.validation_text.value,1))
		string = string + "- Please complete the validation box, use letters only.\n";		
	if (form.comments.value!="")
			{
		if (!ValidateUserName(form.comments.value,1))
				string = string + "- Please enter valid Comments using numbers, letters, spaces,()?&_-+,.;:*/• only.\n";
		}		
if (string != "")
	{
		alert(string);
		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 ValidateUserName(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 == ';'
				// or enter or line feed
				|| strCurrentChar.charCodeAt(0) == 13 || strCurrentChar.charCodeAt(0) == 10 || strCurrentChar.charCodeAt(0) == 9 
				// Bullet
				|| strCurrentChar.charCodeAt(0) == 8226 || strCurrentChar.charCodeAt(0) == 8211 || strCurrentChar.charCodeAt(0) == 39
			   );  
			  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 ValidatePhone(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error4="";
		
		// 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')
				// or if dash or underscore
				|| strCurrentChar == '-' || strCurrentChar == '_'
				// or if brackets
				|| strCurrentChar == '(' || strCurrentChar == ')'
				// or if space
				|| strCurrentChar == ' '
			   );
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error4 = "illegal";

		}
		
		if ((strUserName.length < csize)) error4="toosmall";
		
		if (error4 != "")
	{
		return false;
	} 
	else
		return true;	
	}
function ValidateKeywordText(strUserName,csize)
	{
		// Get the value of the UserName text box
		var strCurrentChar;
		
		// This variable will determine if our string is valid
		var error5="";
		
		// 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 space
				|| strCurrentChar == ' '
			   );
			   
			   // We have a valid string... do nothing.
			  else
			   // We have an invalid string, set the flag
			   error5 = "illegal";

		}
		
		if ((strUserName.length < csize)) error5="toosmall";
		
		if (error5 != "")
	{
		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 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')
			   );
			   
			   // 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;	
	}
