function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}



function resetFields(whichform)
{
	for (var i=0; i<whichform.elements.length; i++)
	{
		var element = whichform.elements[i];
		if (element.type == 'submit') continue;
		if (!element.defaultValue) continue;
		element.onfocus = function()
		{
			if (this.value == this.defaultValue)
			{
				this.value = '';
			}
		}
		element.onblur = function()
		{
			if (this.value == '')
			{
				this.value = this.defaultValue;
			}
		}
	}
}



function prepareForms()
{
	for (var i=0; i<document.forms.length; i++)
	{
		var thisform = document.forms[i];
		resetFields(thisform);
		
		thisform.onsubmit = function()
		{
			return prepareSearchTerm(this);
		}
	}
}



function prepareSearchTerm()
{
	var search_term = document.getElementById('txt_site_search').value;
	var new_search_term = search_term + '*';
	document.getElementById('txt_site_search').value = new_search_term;
	return true;
}



Event.observe(window, 'load', function()
{
	// ADD HOVER BEHAVIOR TO TABLE ROWS IN IE6 AND BELOW
	if (!window.XMLHttpRequest)
	{
		$$('table tr').each( function(e)
		{
			Event.observe(e, 'mouseover', function()
			{
				Element.addClassName(e, 'hover');
			});
			Event.observe(e, 'mouseout', function()
			{
				Element.removeClassName(e, 'hover');
			});
		});
	}
	
	// CHECK FOR IE/WIN
	/*if(window.ActiveXObject)
	{
		if($('content').lastChild && $('content').lastChild.nodeName == 'TABLE' && $('content').lastChild.className.indexOf('downloads_list') != 1)
		{
			$('content').setStyle
			({
				paddingBottom: 0,
				borderBottom: 0
			});
		}
	}
	else
	{
		if($('content').lastChild.previousSibling && $('content').lastChild.previousSibling.nodeName == 'TABLE' && $('content').lastChild.previousSibling.className.indexOf('downloads_list') != 1)
		{
			$('content').setStyle
			({
				paddingBottom: 0,
				borderBottom: 0
			});
		}
	}*/
	
	// ENABLE FORM INTERACTION
	prepareForms();
});
