function efs_validate_find_name()
{
	var decision = true;
	var error_text = "Please enter name of at least 3 characters.";
	var find_name = document.findPlayerName.NAME.value;
	
	var name_array = new Array();


	if (find_name.length < 3)
	{
		decision = false;
	}
	else
	{
		name_array = find_name.split(" ");
	
		if (name_array.length == 0)
		{
			decision = false;
		}
		else
		{

			// name?l? namel other
			//
			var ctr=0;
			var trimmed_name = "";
			while ( (ctr < name_array.length) && (ctr < 2) )
			{
				trimmed_name = trim(name_array[ctr])
		
				if (trimmed_name.length < 3)
				{
					decision = false;
				}
				
				ctr+=1;
			}
		}

	}

	
	if (decision == true)
	{
		document.findPlayerName.submit();
	}
	else
	{
		alert(error_text);
	}
}

function efs_validate_find_name2(formName)
{
	var decision = true;
	var error_text = "Please enter name of at least 3 characters.";
	var find_name = document.forms[formName].NAME.value;
	
	var name_array = new Array();


	if (find_name.length < 3)
	{
		decision = false;
	}
	else
	{
		name_array = find_name.split(" ");
	
		if (name_array.length == 0)
		{
			decision = false;
		}
		else
		{

			// name?l? namel other
			//
			var ctr=0;
			var trimmed_name = "";
			while ( (ctr < name_array.length) && (ctr < 2) )
			{
				trimmed_name = trim(name_array[ctr])
		
				if (trimmed_name.length < 3)
				{
					decision = false;
				}
				
				ctr+=1;
			}
		}

	}

	
	if (decision == true)
	{
		document.forms[formName].submit();
	}
	else
	{
		alert(error_text);
	}
}

function trim(inputString) {

   if (typeof inputString != "string") { return inputString; }

   var retValue = inputString;
   var ch = retValue.substring(0, 1);

   while (ch == " ") { 
      // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }

   ch = retValue.substring(retValue.length-1, retValue.length);

   while (ch == " ") { 
      // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }

   while (retValue.indexOf("  ") != -1) { 
      // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }

   return retValue; 
} 

function efs_validate_find_type()
{
	var decision = true;
	var error_text = "";
	
	// only allow Draft sort for Rookie find type
	var find_rookie_type 	=document.findPlayerType.ROOKIE_TYPE.value;
	var find_rookie_sort 	=document.findPlayerType.ROOKIE_SORT.value;
	var find_type_selection =document.findPlayerType.PPOS.options[document.findPlayerType.PPOS.selectedIndex].value;
	var find_sort_selection =document.findPlayerType.SORD.options[document.findPlayerType.SORD.selectedIndex].value;
	
	if ( ( find_rookie_sort == find_sort_selection ) && (find_rookie_type != find_type_selection) )
	{
		error_text = "Draft Position sort only allowed for Find Player by Type - Rookies.";
		decision = false;
	}

	if (decision == true)
	{
		document.findPlayerType.submit();
	}
	else
	{
		alert(error_text);
	}	
}

