﻿//* Google Search Functions *//

//Trims spaces
function trim(string)
{
	return string.replace(/^\s+|\s+$/g,"");
}

function validateGoogleSearch(googleSearchBoxId)
{
	searchBox = document.getElementById(googleSearchBoxId);
	if (trim(searchBox.value) == getDefaultGoogleSearchText() || trim(searchBox.value) == "")
	{
		alert("Please enter a search term.");
		return false;
	}
	else
	{
		return true;
	}
	
	//Temporarily disable Google Search:
	//arguments.IsValid = false;
	//Remove after testing
}

function clearGoogleSearchText(googleSearchBoxId)
{
	searchBox = document.getElementById(googleSearchBoxId);
	if (trim(searchBox.value) == getDefaultGoogleSearchText())
	{
		searchBox.value = "";
	}
}

function resetGoogleSearchText(googleSearchBoxId)
{
	searchBox = document.getElementById(googleSearchBoxId);
	if (trim(searchBox.value) == "")
	{
		searchBox.value = getDefaultGoogleSearchText();
	}
}

function googleSearchButtonOver(googleSearchButtonId)
{
	setBackgroundColor(googleSearchButtonId, "#C1D4E3");
}

function googleSearchButtonOut(googleSearchButtonId)
{
	setBackgroundColor(googleSearchButtonId, "#A3ADB8");
}

function getDefaultGoogleSearchText()
{
	if (defaultGoogleSearchText == null)
	{
		return "Search";
	}
	else
	{
		return defaultGoogleSearchText;
	}
}