window.onload = function()
{
	initOrderButton();
	initCountFields();
}

function pop(url, width, height)
{
	window.open(url,'','width='+width+', height='+height+', menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no', false);
}

function poppage(url, width, height)
{
	window.open(url,'','width='+width+', height='+height+', menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes', false);
}

function initOrderButton()
{
	var loBtn = document.getElementById("cmd_OrderNow");
	if(loBtn != null)
	{
		loBtn.onclick = function()
		{
			this.value= "Order wordt verwerkt...";
			this.onclick = function()
			{
				return false;
			}
		}
	}
}

function showWebgroups(cFilter, cCluster)
{
	if(window.location.href.toLowerCase().indexOf("default.asp?") > 1)
	{
		var cHref = window.location.href;
		cHref = cHref.replace(/webgroupfilter\=[0-9,-]+\&?/gi,"");
		cHref = cHref.replace(/artdetail\=[^\&]+\&?/gi, "");
		cHref = cHref.replace(/clusterfilter\=[^\&]+\&?/gi, "");
		cHref = cHref.replace("?","?alstart=&webgroupfilter="+cFilter+"&");
		window.location.href = cHref;
	}
	else
	{
		window.location.href = "/default.asp?alstart=0&webgroupfilter="+cFilter;
	}
}

function initCountFields()
{
	var loFields = document.getElementsByTagName("input");
	for(var i=0; i<loFields.length; i++)
	{
		loF = loFields.item(i);
		if(loF.name.indexOf("txtCount_")== 0 || loF.name.indexOf("txt_BasketCount_")== 0 )
		{
			loF.onchange = function()
			{
				roundFieldValue(this);
			}
		}
	}
}

function roundFieldValue(oF)
{
                var val = oF.value;
                val = parseInt(val,10);
                if(isNaN(val) || val < 0)
                               val = 0;
                val = Math.round(val);
                oF.value = val;
}
