window.onload = function()
{
	initOrderButton();
	fDescweb();
}


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 fRecalcBasket()
{
	try{document.getElementById('RecalcBasket').click();}catch(e){}
}


function fDescweb()
{
	var o = document.getElementById('descweb');
	if(!o)
		return;

	var h = o.clientHeight > 0 ? o.clientHeight : o.offsetHeight;

	if(h > 700)
	{
		var oMore = document.getElementById('artdescmore');
		if(!oMore)
			return;

		o.className = "artdesclimit";
		oMore.style.display = 'block';
	}
}

function fDescwebShowHide(tiMode)
{
	var o = document.getElementById('descweb');
	var oMore = document.getElementById('artdescmore');
	var oLess = document.getElementById('artdescless');
	if(!o || !oMore || !oLess)
		return;

	if(tiMode)
	{
		o.className = "artdesclimit";
		oMore.style.display =  'block';
		oLess.style.display = 'none';
	}
	else
	{
		o.className = "artdesc";
		oMore.style.display = 'none';
		oLess.style.display =  'block';
	}
}

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 filterpanel(id)
{
	var element = document.getElementById(id);
	if(element == null)
	{
		return;
	}

	element.fp_init = function()
	{
		var trs = element.getElementsByTagName("div");
		element.filterrow = trs[1];
	}

	element.pf_onmouseover= function(e)
	{
		if(this.timer != 0)
			window.clearTimeout(this.timer);

		this.fp_show();
	}

	element.pf_onmouseout = function(e)
	{
		if(this.timer != 0)
			window.clearTimeout(this.timer);

		this.timer = window.setTimeout("document.getElementById('"+element.id+"').fp_hide()", this.timeout);
	}

	element.fp_show = function()
	{
		if(document.all)
		{
			this.filterrow.style.overflow = "visible";
		}
		else
		{
			this.filterrow.style.overflow = "visible";
		}
	}	

	element.fp_hide = function()
	{
		this.filterrow.style.overflow = "hidden";
	}	

	element.onclick = function()
	{
		if (!e) var e = window.event;
		if(this.pf_onmouseover != null)
			this.pf_onmouseover(e);
	}
	element.onmouseover = function()
	{
		if (!e) var e = window.event;
		if(this.pf_onmouseover != null)
		{
			if(this.timer != 0)
				window.clearTimeout(this.timer);

		}
	}
	element.onmouseout = function()
	{
		if (!e) var e = window.event;
		if(this.pf_onmouseout != null)
			this.pf_onmouseout(e);
	}

	element.timeout = 500;
	element.timer = 0;
	element.filterrow = null;

	element.fp_init();	
}

function showArtdetailImg(newSrc)
{
	var img = document.getElementById("artdetailsimg").getElementsByTagName("img")[0];
	if( img && newSrc)
	{
		//if(newSrc.indexOf("/") > -1)
		//	newSrc = newSrc.substr(newSrc.lastIndexOf("/") + 1);
		var oldSrc = img.src.substr(0, img.src.lastIndexOf("/") + 1 );
document.title = newSrc;
		img.src = newSrc;
	}
}

function fadeBasket(bSHow)
{
	if($(headerbasketlines ))
	{

	}
}

function checkBasketStock()
{
	var list = document.getElementsByTagName('input');
	var lineno, stock, qty;
	var count = 0;
	for(var i=0; i<list.length; i++) {
		if(list[i].name.substring(0,9) == 'txtStock_') {
			lineno = list[i].name.substring(9);

			qty = document.getElementById('txt_BasketCount_'+lineno);
			stock = list[i];

			if(qty == null)
				continue;

			if(parseInt(qty.value,10) > parseInt(stock.value,10)) {
				qty.value = stock.value;
				count++;
			}
		}
	}
	if(count > 0)
		alert('I.v.m. strekkende voorraad is het bestelaantal van 1 of meerdere artikelen aangepast');
}




/**
 * Stuff for article property filters
 */

function fAddNamedPropFilter(tcPropID,tcValID) {
	if(tcValID == "") {
		fRemoveNamedPropFilter(tcPropID,tcValID);
		return;
	}
	
	var url = window.location.href;
	url = url.replace(/\?alstart=\d+&?/ig,'?');
	url = url.replace(/&alstart=\d+&?/ig,'&'); 
	lcRE = tcPropID.replace(/[^a-z0-9]/ig,'(.+?)')+'=([^&]*)&?';
	var re = new RegExp(lcRE,'g');
	url = url.replace(re,'');
	url = url + (url.indexOf('?') >= 0?'&':'?')+encodeURIComponent(tcPropID)+'='+encodeURIComponent(tcValID);
	url = url + (url.indexOf('?') >= 0?'&':'?')+'alstart=0';
	url = url.replace(/\?&/g,'?');
	url = url.replace(/&+/g,'&'); 
	window.location.href = url;
}

function fRemoveNamedPropFilter(tcPropID,tcValID) {
	var url = window.location.href;
	url = url.replace(/\?alstart=\d+&?/ig,'?');
	url = url.replace(/&alstart=\d+&?/ig,'&'); 
	var lcRE;
	if(tcValID == "")
		lcRE = tcPropID.replace(/[^a-z0-9]/ig,'(.+?)')+'=([^&]*)&?';
	else
		lcRE = tcPropID.replace(/[^a-z0-9]/ig,'(.+?)')+'='+tcValID.replace(/[^a-z0-9]/ig,'(.+?)');
	var re = new RegExp(lcRE,'g');
	url = url.replace(re,'');
	url = url + (url.indexOf('?') >= 0?'&':'?')+'alstart=0';
	url = url.replace(/\?&/g,'?');
	url = url.replace(/&+/g,'&');
	url = url.replace(/(\?|&)$/g,'');
	window.location.href = url;
}

/**
 * END - Stuff for article property filters
 */
