function $(id)
{
	return document.getElementById(id);
}

function addToCart()
{
		var rbl = document.getElementsByName('radio-prijs');
		var rb = '';
		for(i=0;i<rbl.length;i++)
		{
			rb = rbl[i];
			
			if(rb.checked)
			{
				window.location = '/winkelmandje/toevoegen/' + rb.value + '/';
				return;
			}
		}
}

function cl(strUrl)
{
	window.location = strUrl;
}

function ow(strUrl)
{
	window.open(strUrl);
	return false;
}

function submitFormZoek(e)
{
	document.getElementById('event').value = e;	
	document.getElementById('frmZoek').submit();
	
	return false;
}

function toggleNav(id)
{
	var llm = document.getElementById('llm' + id);
	var tllm = document.getElementById('tllm' + id);
	
	if(llm.style.display=='')
	{
		llm.style.display = 'block';
		tllm.innerHTML = 'Minder';
		tllm.style.backgroundImage = "url('/img/arrow-up.gif')";
	} else {
		llm.style.display = '';
		tllm.innerHTML = 'Meer';
		tllm.style.backgroundImage = "url('/img/arrow-down.gif')";
	}
	
	return false;
}

function toggleZoek()
{
	var bz = $('blockzoek');
	
	if(bz.style.display == '')
	{
		bz.style.display = 'block';
	} else {
		bz.style.display = '';
	}
}

function zoekBlur()
{
	$('resultaat').style.display = '';
}

function zoekKeyUp(oArg)
{
	var phZoek = $('phZoek');
	var zoek = $('tbZoek');
	
	if(typeof(oArg)=='undefined')
	{
		var zoek = $('tbZoek');
		var zoekterm = zoek.value;
		
		if(zoekterm.length<3)
		{
			if(phZoek!=null)
			{
				phZoek.parentNode.removeChild(phZoek);
			}
			return;
		}
				
		var url = '/ajax/zoekAjax.php';
	    var arg = 'zoekterm=' + zoekterm;
	    httpRequest('POST',url,true,zoekKeyUp,arg);		
	} else {		
		var txt = oArg.xmlhttp.responseText;
		
		if(txt!='')
		{
			var json = eval('(' + txt + ')');
			var resultaten = json.resultaten;
			
			var strHTML = ''
			var id = '';
			var waarde = '';
			var soort = '';
			var url = '';
			
			for(i=0;i<resultaten.length;i++)
			{
				id = resultaten[i].id;
				soort = resultaten[i].soort;
				waarde = resultaten[i].waarde;
				
				if(soort=='wijn')
				{
					url = '/product/' + id + '/';
				} else {
					url = '/productdatabase/' + id + '/';
				}
				
				strHTML += "<a href='" + url + "'>" + resultaten[i].waarde + '<br/><span>' + resultaten[i].soort + '</span></a>';
			}	
		} else {
			strHTML = 'geen resultaten';
		}
		
		if(phZoek!=null)
		{
			phZoek.parentNode.removeChild(phZoek);
		}
		
		phZoek = document.createElement("div");
		phZoek.id = 'phZoek';
		phZoek.style.left = zoek.offsetLeft + 'px';
		phZoek.style.top = zoek.offsetTop + zoek.offsetHeight + 5 + 'px';
		phZoek.innerHTML = strHTML;
		
		
		$('blockzoek').appendChild(phZoek);
		if(phZoek.offsetHeight>300)
		{
			phZoek.style.height = '300px';
		}
	}
}
	