window.onload = function()
{
	if(document.getElementById('txtDefaultPaymentMethod'))
	{
		fPaymentManager(document.getElementById('txtDefaultPaymentMethod').value);	
	}
	initCountToMax();

	var obj = document.getElementById("custx_address1");
	if(obj != null)
	{
		obj .onchange=function(){fCheckAddress(this)};
	}
}
function fCheckAddress(o)
{
	if(o.value != "")
	{
		lOk = false;
		if(o.value.search(/\s\d/) > 3)
		{
			lOk = true;
		}
		if(! lOk)
		{
			o.style.backgroundColor= "FFCC99";
			alert("Heeft u uw huisnummer juist ingevuld?")
		}
		else
		{
			o.style.backgroundColor= "#FFFFFF";
		}
	}
}
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 fPaymentManager(cName)
{
	payments = new Array("rembours","bill","ideal","payfirst");
	for(var i=0; i<payments.length; i++)
	{
		div = document.getElementById('Payment_' + payments[i]);
		if(div != null)
		{
			if(cName == payments[i])
			{
				div.style.display = 'block'
			}
			else
			{
				div.style.display = 'none'
			}
		}
	}
	return;
}

function initCountToMax()
{
	a = document.getElementsByTagName("input");
	for(var i=0; i<a.length; i++)
	{
		b=a[i];
		c = b.name;
		d = Math.max(c.indexOf("txt_BasketCount_"), c.indexOf("txtCount_"));
		if(d == 0 && b.type=="text")
		{
			b.onchange = CountToMax;
			b.onkeyup = CountToMax;
		}
	}

}
function CountToMax()
{
	var newvalue = "";
	var oldvalue = this.value;
	if(oldvalue == "")
		return;

	oldvalue = oldvalue.replace(/\,/g,".");


	if(isNaN(oldvalue ))
	{
		newvalue= 1;
	}
	else
	{
		newvalue= Math.ceil(oldvalue);
	}

	if(newvalue != this.value)
	{
		this.style.borderColor = "#fa7701";
	}
	else
	{
		this.style.borderColor = "";
	}

	this.value = newvalue;

}

function showWebgroups(cFilter, cPage)
{

	lcHref = "/default.asp?pageid="+ cPage+"&webgroupfilter=" + cFilter ;

	window.location.href = lcHref ;
}

function fShowClusters(tcWebgroupfilter,tcClusterfilter,tcPageID)
{
	if(typeof tcWebgroupfilter == undefined)
		return;
	if(typeof tcClusterfilter == undefined)
		return;
	if(typeof tcClusterfilter == undefined)
		return;

	var lcHref = '/default.asp?pageid='+tcPageID+'&docid=33';
	lcHref += '&webgroupfilter='+tcWebgroupfilter;
	lcHref += '&clusterfilter='+tcClusterfilter;

	window.location.href = lcHref;
}

