var useServersideForm = true;
function validatePage()
{
	return useServersideForm;
}

function placeFocus()
{
	if (document.forms.length > 0)
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++)
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s"))
			{
				document.forms[0].elements[i].focus();
				break;
         }
      }
   }
}

function search(url, box)
{
	//var queryString = window.location.search.substr(1);

	var form = document.forms[0];
	var field = document.getElementById(box);
	if (field != null)
	{
		text = getSearchEncoded(field.value);
	}
	else
	{
		text = getSearchEncoded(form.TopSearch.value);
	}

	if(url.indexOf("?") >= 0)
	{
		result = "&s=" + text;
	}
	else
	{
		result = "?s=" + text;
	}

	location.href = url + result;
}

function tsearch(evt, url, box)
{	
	if (evt && (evt.keyCode == 13 || evt.which == 13))
	{
		search(url, box);
		return false;
	}
	else
	{
		return true;
	}
}

function jump(url, jump)
{
	var form = document.forms[0];
	text = getSearchEncoded(form.Search.value);
	offset = parseInt(parseFloat(form.Offset.value)) + jump;
	
	if(url.indexOf("?") >= 0)
	{
		result = "&s=" + text;
	}
	else
	{
		result = "?s=" + text;
	}

	if (offset > 0)
	{
		result += "&o=" + offset;
	}

	location.href = url + result;
}

function getSearchEncoded(search)
{
	return encodeURI(search);
}

function Export()
{
	window.open(location.href + '&export=true')
}

function EditOpen(url)
{
	window.open(url)
}

if (window.onload)
{
	cached_onload = window.onload;
	window.onload = new Function(				
		"new_onload",
		"placeFocus();" +			
		"cached_onload();" +
		""
	);
}
else
{
	window.onload = placeFocus;
}

