window.onload = function()
{
	initOrderButton();
}

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 initButtons()
{
	var loBtns = null;
	try {
		loBtns = document.getElementsByTagName("input");
	} catch(e) {
	}

	if(loBtns == null)
		return;

	var loBtn;
	for(var i=0; i<loBtns.length; i++) {
		loBtn = loBtns.item(i);
		switch(loBtn.className) {
			case "inputbutton":
			case "customerbutton":
			case "artlstaddtobasket":
			case "artlstaddtofavorites":
				loBtn.onmouseover = function(){this.className+='MO'};
				loBtn.onmouseout = function(){this.className=this.className.replace(/MO$/g,'')};
				break;
		}
	}
}

function initOrderButton()
{
	var loBtn = document.getElementById("cmd_OrderNow");
	if(loBtn != null)
	{
		loBtn.onclick = function()
		{
			this.value= "Order wordt verwerkt...";
			this.onclick = function()
			{
				return false;
			}
		}
	}
}



var iBoxMin = 80;
var iGrow = 15;


function initwebgroupbox(box)
{
	if (box.scrollHeight) // all but Explorer Mac
	{
		box.maxheight = box.scrollHeight;
		box.minheight = box.scrollHeight;
	}
	else 
	{
		box.maxheight = box.offsetHeight;
		box.minheight = box.offsetHeight;
	}
	if(box.minheight > 100)
		box.minheight = iBoxMin ;

	box.iheight = box.minheight;
	
}

function togglewebgroupbox(button, tcBoxId)
{
	if(button.value == "meer")
	{
		initGrowWebgroupbox(document.getElementById(tcBoxId), iGrow);
		button.value = "minder";
	}
	else
	{
		initGrowWebgroupbox(document.getElementById(tcBoxId), 0 - iGrow);
		button.value = "meer";
	}
}

function initGrowWebgroupbox(box, tiGrow)
{
	if(box.className != 'webgroupbox')
		return;
	if(! box.maxheight)
		initwebgroupbox(box);

	clearBoxTimer(box);
	box.igrow = tiGrow;
	box.iInterval = window.setInterval("growWebgroupbox(document.getElementById('"+box.id+"'))", 10);
}


function clearBoxTimer(box)
{
	if(box.iInterval)
	{
		if(box.iInterval > 0)
		{
			window.clearInterval(box.iInterval)
		}
	}
}


function growWebgroupbox(box)
{
	var iNewheight = box.iheight + box.igrow;

	if(box.igrow < 0 && iNewheight <  box.minheight )
	{
		clearBoxTimer(box)
		return;
	}

	if(box.igrow > 0 && iNewheight >  box.maxheight + iGrow )
	{
		clearBoxTimer(box)
		return;	
	}

	box.style.height = String(iNewheight ) + "px";
	box.iheight = iNewheight ;
}

function getHttpRequest()
{
	var xmlhttp;

	if (window.XMLHttpRequest) 
	{         
		// code for IE7+, Firefox, Chrome, Opera, Safari         
		xmlhttp=new XMLHttpRequest();     
	} 
	else 
	{         
		// code for IE6, IE5         
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");     
	} 
	return xmlhttp;
}
