/* Author: Jason Gennaro
	Oct. 18, 2010
	
	This script adds some default text to the search box, then
	removes the text once the user clicks on the field.  Adds it back once 
	user clicks off the field
	
	contains function within an object
	to ensure that it does not conflict with
	other javascript
*/

var SearchBoxInput = 
	{
		init: function()
			{
			//empty variable to contain EN or FR text once path is determined. 
			var searchBoxText = "";
			//grabs the file path
			var getLanguageFromPath = location.pathname;	
			//splits the file path into an array
			var checkLanguageFromPath = getLanguageFromPath.split("/");
			//checks to see if the file path contains english, adds EN text to variable, else adds FR text
			if (checkLanguageFromPath[1] == "english")
				{
					searchBoxText = "Search...";
				}		
			else 
				{
					searchBoxText = "Recherche...";
				}
			
			//assigns search box text to the input field, makes it grey	
			$("#searchBox").attr("value", searchBoxText).css({color:'grey'});
			
			//when the user clicks/tabs on the box, if the variable text is there, it remove it and changes
			//the text color to black to make typed text more clear
			$("#searchBox").focus(function()
					{
					$(this).css({color:'black'});
					if($(this).attr("value") == searchBoxText) $(this).attr("value", "");
					}
				);

			//when the user moves away from the input field, the color is switch back to grey
			//if there is nothing is the field (no user input) then variable added back							
			$("#searchBox").blur(function() 
					{
					$(this).css({color:'grey'});
					if($(this).attr("value") == "") $(this).attr("value", searchBoxText);
					}	
				);
			
			}
	};

$(document).ready(function(){SearchBoxInput.init();});

