	/*****************************************************************************
	**		 __      __  ____     ____     __  __  ________   ________      	**
	**		/\ \  __/\ \/\  _`\  /\  _`\  /\ \/\ \/\_____  \ /\_____  \    		**
	**		\ \ \/\ \ \ \ \ \L\ \\ \ \L\ \\ \ \ \ \/____//'/'\/____//'/'   		**
	**		 \ \ \ \ \ \ \ \  _ <'\ \  _ <'\ \ \ \ \   //'/'      //'/'    		**
	**		  \ \ \_/ \_\ \ \ \L\ \\ \ \L\ \\ \ \_\ \ //'/'___   //'/'___  		**
	**		   \ `\___x___/\ \____/ \ \____/ \ \_____\/\_______\ /\_______\		**
	**			'\/__//__/  \/___/   \/___/   \/_____/\/_______/ \/_______/		**
	**																			**
	**	This site created by Drew Loomer for the West Bloomfield Township 		**
	**	Public Library Youth Department.  										**
	**	Completed on 9-14-2009													**
	**	loomerdr@wblib.org														**
	**	Sorry about the lame ASCII art - it was just too tempting...			**
	**																			**
	**	This page contains the javascript for the about us page.  That is a 	**
	**	function to remove the default value of an input like "Your Name" when	**
	**	a user clicks that box.  If they click off without entering, our other	**
	**	function will re-populate the box with its default text.				**
	**																			**
	*****************************************************************************/
	
	
	//Clear the default value if it's still there, and make the text black.
	function removeValue(input, text)
	{
		if (input.value == text)
		{
			input.value = "";
			input.style.color = "#000000";
		}
	}
	
	
	
	//Replace the default value if necessary, and make the text gray.
	function replaceValue(input, text)
	{
		if (input.value == "")
		{
			input.value = text;	
			input.style.color = "#aaaaaa";
		}
	}
	
	
	
	//Check for valid Email Address
	function emailCheck()
	{
		//Get the value from HTML form
		var emailInput = document.getElementById("yourEmail").value;


		//regular Expression to check for email characters
		var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;


		//Illegal Email Characters
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;


		//Is the field blank?
		if (emailInput == "" || emailInput == "Your Email")
		{
			document.getElementById("askError").innerHTML = "- &nbsp; Your Email is blank!";			
			return false;
		}
		//Is the email valid?
		else if (!emailFilter.test(emailInput))
		{
			document.getElementById("askError").innerHTML = "- &nbsp; Your Email is invalid!";			
			return false;
		}
		//Are there illegal characters?
		else if (emailInput.match(illegalChars))
		{
			document.getElementById("askError").innerHTML = "- &nbsp; Your Email is invalid!";			
			return false;
		}
		else
		{
			document.getElementById("askError").innerHTML = "";			
		}

		
		return true;
	}
	
	
	
	
	//Check for a blank input (side note: Blank Check == best movie of all time?)
	function blankCheck(input)
	{
		//Get the value from HTML form
		var inputName = document.getElementById(input);
		
		
		//Get the printable name - break apart the name at the first upper case and capitalize the first word.
		var pos = inputName.id.search(/[A-Z]/);
		var printFirst = inputName.id.slice(0, pos);
		printFirst = printFirst.slice(0,1).toUpperCase() + printFirst.slice(1);
		var printSecond = inputName.id.slice(pos); 
		var printName = printFirst + " " + printSecond;

		
		//Is the field blank or still its default value?
		if (inputName.value == "" || inputName.value == printName)
		{
			document.getElementById("askError").innerHTML = "- &nbsp; " + printName + " is blank!";	
			return false;
		}
		else
		{
			document.getElementById("askError").innerHTML = "";	
		}

		
		return true;
	}
	
	
	
	
	
	//Check for a blank recaptcha
	function recaptchaCheck()
	{
		//Get the value from HTML form
		var recap = document.contact.recaptcha_response_field.value;

		
		//Is the field blank or still its default value?
		if (!recap)
		{
			document.getElementById("askError").innerHTML = "- &nbsp; Validation input is blank!";	
			return false;
		}
		else
		{
			document.getElementById("askError").innerHTML = "";	
		}

		
		return true;
	}
	
	
	
	
	//Call all of the form checks
	function formChecks()
	{
		if (blankCheck('yourName') == false)
			return false;
		else if (emailCheck() == false)
			return false;
		else if (blankCheck('yourMessage') == false)
			return false;
		else if (recaptchaCheck() == false)
			return false;
		else
			return true;
	}
