//initialization function, called after all elements of DOM are written
Event.observe(window, "load", function() {


	$('searchTerm').onfocus = function() {
		// if already cleared, do nothing
		if (this._cleared) return

		// when this code is executed, "this" keyword will in fact be the field itself
		this.clear()
		this._cleared = true
	}		

	$('searchTerm').onkeypress = function(e) {
		// fetch event object
		var keynum;

		if(window.event) // IE
		{
			keynum = window.event.keyCode;
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which;
		}

/*		if (keynum == Event.KEY_RETURN) {	// enter key pressed
			submitForm('search');
		}
*/		
		$('search-button').observe('click', doSearch);

	}	
});


	// this function replaces the method of submitting the form. it's a workaround with the bug in Safari (Mac)
	// that includes the coordinates of the mouse-click in the query when images are used as submit buttons
	function doSearch() {
		var query = $('searchTerm').getValue();  
		location.href = "/?page=search&q=" + query;
		return false;
		
	}