function searchItems()
{
	var form = document.getElementById('search');
	form.submit();
}

function setOrder(order)
{
	var orderbox = document.getElementById('cur_order');
	
	orderbox.value = order;
}

function filterItemList()
{
	var brand = document.getElementById('brandfilter');
	var price = document.getElementById('pricefilter');
	var cat = document.getElementById('cur_cat');
	var order = document.getElementById('cur_order');
	
	var searchstring = 'http://webshop.babsboomer.nl/shop.php?type=categorie&cat='+cat.value;
	if(brand.value != '' && brand.value != '_DEFAULT_')
	{
		searchstring += '&filter[b]='+brand.value;
	}
	if(price.value != '' && price.value != '_DEFAULT_')
	{
		searchstring += '&filter[p]='+price.value;
	}
	if(order.value != '')
	{
		searchstring += '&filter[order]='+order.value;
	}
	window.location = searchstring;	
}

function resetFilter()
{
	var cat = document.getElementById('cur_cat');
	location.href = 'http://webshop.babsboomer.nl/shop/categorie/'+cat.value+'/';
}

function addToCart(url,itemid,amount)
{
	//var select = document.getElementById('size').value;
	var selectvar = document.getElementById('size');
	var selectedindex = selectvar.selectedIndex;
	var valuevar = selectvar.options[selectedindex].value;
	
	if(itemid && amount)
	{
		location.href=url+"/cart.php?id="+itemid+"&amount="+amount+"&size="+valuevar;
	}
	else
	{
		return false;
	}
}

function displayProductOptions(id)
{
	var div = document.getElementById(id);
	
	if(div.style.display == 'block')
	{
		div.style.display = 'none';
	}
	else
	{
		div.style.display = 'block';
	}
}

function searchWebshop()
{
	var product_naam	= document.getElementById('product_naam').value;
	var category		= document.getElementById('category').value;
	var brand			= document.getElementById('brand').value;
	var product_price	= document.getElementById('product_price').value;
	var update 			= document.getElementById('search_result');
	var url				= 'action=result';
	
	if (product_naam == '' && (category != '_DEFAULT_' || brand != '_DEFAULT_' || product_price != '_DEFAULT_'))
	{
		url += '&search[product]=';
		if(category != '_DEFAULT_')
		{
			url += '&search[category]='+category;
		}
		
		if(brand != '_DEFAULT_')
		{
			url += '&search[brand]='+brand;
		}
	
		if(product_price != '_DEFAULT_')
		{
			url += '&search[price]='+product_price;
		}
		
		location.search = url;	
	}
	else if(product_naam != '')
	{
		url += '&search[product]='+product_naam;
		
		if(category != '_DEFAULT_')
		{
			url += '&search[category]='+category;
		}
		
		if(brand != '_DEFAULT_')
		{
			url += '&search[brand]='+brand;
		}
	
		if(product_price != '_DEFAULT_')
		{
			url += '&search[price]='+product_price;
		}
		
		location.search = url;	
	}
	else
	{
		update.innerHTML   = '';
		update.innerHTML  += '<p>Er is geen zoekterm ingevuld</p>';
	}
	
}

function popMeUp(url)
{
	var width  = 400;
	var height = 500;
	
 day = new Date();
 id = day.getTime();
 var Left = (screen.width - width) / 2;
 var Top = (screen.height - height) / 2;
 eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = "+Left+",top = "+Top+"');");
 }
