// JavaScript Document

/** Populate the Keyword default into the search box (this will cause browsers w/o javascript to get a value by default **/
$(document).ready(function() {
	try{document.getElementById("txtSearch").value = "Keyword";}catch(e){}
});

/** Toggles the Keyword preview text in the textbox **/
function checkForDefaultSearchValue(txtBox, isSelected)
{
	if(isSelected)
	{
		if(txtBox.value == "Keyword")
			txtBox.value = "";
	}
	else
	{
		if(txtBox.value == "")
			txtBox.value = "Keyword";
	}
}

/** Calls the anchor child element's href link **/
function callMenuItemLink(liElement)
{
	if(liElement.firstChild.nodeName == "a")
		document.location = liElement.firstChild.href;
	
	// iphone / non-mouse systems, show menu on click
	hoverMenuItem(liElement, true);
}

/** Shows or hides a submenu if available **/
function hoverMenuItem(liElement, isOver)
{
	// Find the UL sub menu (if applicable)
	var ulElements = liElement.getElementsByTagName("ul");
	
	// If we have a sub-menu
	if(ulElements.length > 0)
	{
		// Display or hide it
		var subMenu = ulElements[0];
		
		if(isOver)
			subMenu.style.left = "215px";
		else
			subMenu.style.left = "-9999px";
	}
}

/** Opens an anchor element in a new window **/
function newWindow(anchor)
{
	window.open(anchor.href, '_blank');
	return false;
}

/** pretty form stuff **/
$(document).ready(function() {
	
	/* Add bg addition on focus */
	$("fieldset input").focus(function() {
		var $this = $(this);
		$this.parent().addClass("field-active");
	});
	
	/* Add bg subtraction on blur */
	$("fieldset input").blur(function() {
		var $this = $(this);
		$this.parent().removeClass("field-active");
	});
	
	/* Add bg addition on focus */
	$("fieldset textarea").focus(function() {
		var $this = $(this);
		$this.parent().addClass("field-active");
	});
	
	/* Add bg subtraction on blur */
	$("fieldset textarea").blur(function() {
		var $this = $(this);
		$this.parent().removeClass("field-active");
	});
	
});


