
/* This set of functions simulates :hover for submit buttons in IE. To use, apply onmouseover and onomouseout attributes
	to the input element and then define the CSS for "thatelement".hover-off and "thatelement".hover-on.

	-----------

	For example:

	<style type="text/css">
		.hover-off
		{
			background-color: #00FF00;
			color:            #000000;
		}
		.hover-on {
			background-color: #000000;
			color:            #00FF00;
		}
	</style>

   <input type="submit" class="hover-off" onmouseover="hoverOn(this);" onmouseout="hoverOff(this);" />

	-----------

	From here:
	http://phd.netcomp.monash.edu.au/RobertMarkBram/javaScript/examples/ieHoverFix/default.asp */

function hoverOff(hoverElement)
{
	hoverElement.className = "image-based submit-button hover-off";
}

function hoverOn(hoverElement)
{
	hoverElement.className = "image-based submit-button hover-on";
}




function initialize()
{
	// This auto deletes the default text "search the blog" when the user focuses the field
	setOnFocusOnBlur();

	// This applies form validation
	setOnSubmit();

	// Add the default text to the input element
	///	 (if it's not there already)
	document.getElementById("s").onblur();
}

function setOnFocusOnBlur()
{
	// Get the query field (the quoted value below must match the ID on the input field)
	inputField = document.getElementById("s");
	inputField.onfocus = deleteDefaultText;
	inputField.onblur = applyDefaultText;
}

// This deletes the default text from the form field
function deleteDefaultText()
{
	inputField = this;
	if (inputField.value == "search the blog") inputField.value = "";
}

// This reapplies the default text to the form field
function applyDefaultText()
{
	inputField = this;
	if (inputField.value == "") inputField.value = "search the blog";
}

// This applies the onSubmit handler to the form
function setOnSubmit()
{
	// The quoted value below must match the ID on the <form>
	formElement = document.getElementById("s");
	formElement.onsubmit = validateForm;
}

// This ensures that the search field is set to neither "search the blog" nor "" (the empty string)
function validateForm()
{
	// Get the query field (the quoted value below must match the ID on the input field
	inputField = document.getElementById("s");

	// If the field is blank or set to "search the blog" (the default), fail the validation
	if ( (inputField.value == "search the blog") || (inputField.value == "") )
	{
		alert("Please enter a search term.");
		inputField.focus(); // Give focus to the form field
		return false;
	}

	// If it got this far, the form must be fine.
	return true;
}


/* If the line below were uncommented, the textfield in the search area
   would be set to automatically have the text "search the blog"
  (until someone clicked on it, at which point, it woudl auto-clear) */

// window.onload = initialize;