function clearKeyword(inputElement)
{
	if (inputElement.value=="Etsi tiedostoja..." || inputElement.value=="Kirjoita hakusana...")
	{
		inputElement.value = "";
	}	
}

function executeSearch()
{
	if(!$('searchIcon').prototip) // Create the tip if it does not exist
	{
		new Tip('searchIcon', ' \
		Hakuohjeita<br/> \
		<ul> \
			<li>Varmista, että kaikki sanat ovat kirjoitettu oikein.</li> \
			<li>Hakusanat voi kirjoittaa pienin tai suurin kirjaimin.</li> \
			<li>Kokeile eri hakusanoja.</li> \
			<li>Haku lyötää myös osittaisia sanoja.</li> \
			<li>Älä käytä erikoismerkkejä.</li> \
		</ul>',
		{
			title: 'Unohdit kirjoittaa hakusanan...',
			style: 'esseet',
			stem: {
				position: 'topLeft',
				height: 12,
				width: 15
			},
			showOn: 'false',
			hideOn: { element: 'closeButton', event: 'click' },
			hook: { tip: 'topLeft', mouse: false },
			offset: { x: 28, y: 42 }
		});
	}

	if ($('qsearch').value=="Etsi tiedostoja..." || $('qsearch').value=="" || containsIllegalChars($('qsearch').value)) // Show the tip on error
	{
		$('searchIcon').prototip.show();
		$('quick-search').qsearch.focus();
	}
	else
	{
		$('quick-search').submit();
	}
}

function checkform()
{
	var hakusana = $('searchForm').hakusana.value;

	if (containsIllegalChars(hakusana) || hakusana=="" || hakusana=="Kirjoita hakusana...")
	{
		new Tip('searchForm', ' \
		Hakuohjeita<br/> \
		<ul> \
			<li>Varmista, että kaikki sanat ovat kirjoitettu oikein.</li> \
			<li>Hakusanat voi kirjoittaa pienin tai suurin kirjaimin.</li> \
			<li>Kokeile eri hakusanoja.</li> \
			<li>Haku lyötää myös osittaisia sanoja.</li> \
			<li>Älä käytä erikoismerkkejä.</li> \
		</ul>',
		{
			title: 'Virheellinen hakukysely...',
			style: 'esseet',
			stem: {
				position: 'bottomLeft',
				height: 12,
				width: 15
			},
			showOn: 'false',
			hideOn: { element: 'closeButton', event: 'click' },
			hook: { tip: 'bottomLeft', mouse: false },
			offset: { x: 90, y: 30 }
		});

		$('searchForm').prototip.show();

		return false;
	}
}

function containsIllegalChars(str)
{
	var filter=/[*|<>{}]/;
	if (filter.test(str)) 
	{
		return true;
	}
	else
	{
		return false;
	}
}