// KPnl Zoekfunctie
var defaulttext = "Zoeken...";

function clickclear(thisfield) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
thisfield.style.color = '#000000';
thisfield.style.fontStyle = 'normal';
}

function clickrecall(thisfield) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
thisfield.style.color = '#bbbbbb';
thisfield.style.fontStyle = 'italic';
}
}

document.write('<form method="get" target="_self" action="http://www.kappersproducten.nl/include/engine.asp" onSubmit =" return doSearch()\" name="Search_Keyword">');

document.write('<input type="hidden" name="SQL" value=" ">');
document.write('<input type="hidden" name="Action" value="Search">');
document.write('<input type="hidden" name="Page" value="search.htm">');
document.write('<input type="hidden" name="Mode" value="0">');
document.write('<input type="hidden" name="Index" value="">');
document.write('<input type="hidden" name="Move" value="">');
document.write('<input type="hidden" name="Feature" value="">');

document.write('<select name="SQL"  class="hor-menu_zoeken-cat">');
document.write('<option selected value=" ">Alle categorieën</option>');
document.write('<option value="Catalog_Table.ProductIndex = 4">Benodigdheden</option>');
document.write('<option value="Catalog_Table.ProductIndex = 2">Borstels</option>');
document.write('<option value="Catalog_Table.ProductIndex = 9">Droogkappen</option>');
document.write('<option value="Catalog_Table.ProductIndex = 18">Extensions</option>');
document.write('<option value="Catalog_Table.ProductIndex = 6">Föhns</option>');
document.write('<option value="Catalog_Table.ProductIndex = 7">Haarproducten</option>');
document.write('<option value="Catalog_Table.ProductIndex = 1">Kammen</option>');
document.write('<option value="Catalog_Table.ProductIndex = 8">Manicure/Pedicure</option>');
document.write('<option value="Catalog_Table.ProductIndex = 10">Meubilair</option>');
document.write('<option value="Catalog_Table.ProductIndex = 15">Nekmessen</option>');
document.write('<option value="Catalog_Table.ProductIndex = 5">Oefenmateriaal</option>');
document.write('<option value="Catalog_Table.ProductIndex = 11">Scharen</option>');
document.write('<option value="Catalog_Table.ProductIndex = 12">Stijltangen</option>');
document.write('<option value="Catalog_Table.ProductIndex = 3">Tondeuses</option>');
document.write('</select>');

document.write('<input type="text" maxlength="64" name="Keywords" class="hor-menu_zoeken-input" onclick="clickclear(this)" onblur="clickrecall(this)">');
document.write('<input type="image" src="http://www.kappersproducten.nl/Assets/images/zoeken_button.gif" name="Search_Button" height="18" width="66" style="position: relative; top: 4px" /></form>');
<!-- document.write('<input name="Search_Button" type="submit" value="Zoek !" id="header_zoeken_button"></form>'); -->

function doSearch()
{
	if (document.Search_Keyword && document.Search_Keyword.Keywords)
	{
		var	keyword = document.Search_Keyword.Keywords.value;
		setcookie("Keywords", keyword, 1);
		var index = 0, i = 0;
		if (document.Search_Keyword.SQL && document.Search_Keyword.SQL[0])
		{
			for (i = 1; i < document.Search_Keyword.SQL.length; i++)
			{
				if (document.Search_Keyword.SQL[i].type.indexOf('select') >= 0)
				{
					index = document.Search_Keyword.SQL[i].selectedIndex;
					setcookie("SQL_" + i, index, 1);
				}
			}
		}
		document.Search_Keyword.onsubmit = null;
		var sTarget = document.Search_Keyword.target;
		sTarget = sTarget.toLowerCase();
		submitform('Search_Keyword','');
		if (!sTarget.length || sTarget == '_self') return false;
	}
}

function getSearch()
{
	if (!window.getcookie) return;
	if (document.Search_Keyword && document.Search_Keyword.Keywords)
	{
		var keyword = getcookie("Keywords");
		if (keyword.length) document.Search_Keyword.Keywords.value = keyword;
		var index = 0, i = 0;
		if (document.Search_Keyword.SQL && document.Search_Keyword.SQL[0])
		{
			for (i = 1; i < document.Search_Keyword.SQL.length; i++)
			{
				if (document.Search_Keyword.SQL[i].type.indexOf('input') >= 0)
				{
					index =  getcookie("SQL_" + i);
					if (index.length && !isNaN(parseInt(index)))
					document.Search_Keyword.SQL[i].selectedIndex = parseInt(index);
				}
			}
		}
	}
}

getSearch();

function clearDefault(ctrl, sDef)
{
	if (ctrl.value == sDef)
		ctrl.value = '';
	else
		ctrl.select();
}

autoSearch();
function autoSearch()
{
var i, sQuery = "";
var curPage = "" + window.location;
	if (curPage.indexOf('?') > 0)
	{
		sQuery = curPage.substring(curPage.indexOf('?'), curPage.length);
		sQuery = sQuery.toLowerCase();
	}
	if (sQuery.length && ((i = sQuery.indexOf('keywords=')) >= 0))
	{
		sQuery = sQuery.substring( i + 'keywords='.length, sQuery.length);
		if (sQuery.length && ((i = sQuery.indexOf('&')) >= 0)) sQuery = sQuery.substring(0, i);
		if (sQuery.length && ((i = sQuery.indexOf('#')) >= 0)) sQuery = sQuery.substring(0, i);
		if (sQuery.length)
		{
			sQuery = unescape(sQuery);
			sQuery = sQuery.replace(/\+/g, ' ');
			document.Search_Keyword.Keywords.value = sQuery;
			doSearch();
		}
	}
}