/* JavaScript functions for common tasks ------------------------------------*/
// force the page to load in the top frame
if (self != top)
{
	top.location= self.location;
}

// register common handlers
function _registerCommonHandlers()
{
	if (document.getElementById)
	{
		// title element
		var e= document.getElementById("title");

		if (e)
		{
			e.style.cursor= "pointer";
			e.title= "To the Shopsonic homepage";
			e.onclick= titleClickHander;
		}

		// search form
		var f= document.getElementById("searchForm");

		if (f)
		{
			f.onsubmit= new Function("e", "return validateSearch()");
		}
	}
}

// register the common handlers at page load
if (window.loader) window.loader.add(_registerCommonHandlers);


// the click handler
function titleClickHander()
{
	var exitOK= true;

	if (window.isWizard && window.confirmCancel)
	{
		exitOK= window.confirmCancel();
	}

	if (exitOK)
	{
		document.location= "/";
	}
}


// confirm logout requests
function confirmLogout(iname)
{
	return confirm("You are currently logged in as " + iname + ".\n\nAre you sure you wish to log out?");
}


// confirm that the user has entered search terms
// when they submit the search form
function validateSearch()
{
	if (document.getElementById)
	{
		var terms= document.getElementById("searchTerms");

		if (terms && terms.value == "")
		{
			alert("Please enter a search term or terms.");
			return false;
		}
	}

	return true;
}



