//window.onload = scale;
//window.onresize = scale;

function scale()
{
	var div = document.getElementById("placeholder2");
	var oBd = document.getElementById("bvCmtBody");
	if(div != null && oBd!=null)
	{
		div.style.height = String((oBd.offsetHeight - 69) - 167) + "px";
	}
}

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 fCorrectNumber(c)
{
	var re = /[^\d]/g;
	c = c.replace(re,'');

	re = /^(010|0111|0113|0114|0115|0117|0118|013|015|0161|0162|0164|0165|0166|0167|0168|0172|0174|0180|0181|0182|0183|0184|0186|0187|020|0222|0223|0224|0226|0227|0228|0229|023|024|0251|0252|0255|026|0294|0297|0299|030|0313|0314|0315|0316|0317|0318|0320|0321|033|0341|0342|0343|0344|0345|0346|0347|0348|035|036|038|040|0411|0412|0413|0416|0418|043|045|046|0475|0478|0481|0485|0486|0487|0488|0492|0493|0495|0497|0499|050|0511|0512|0513|0514|0515|0516|0517|0518|0519|0521|0522|0523|0524|0525|0527|0528|0529|053|0541|0543|0544|0545|0546|0547|0548|055|0561|0562|0566|0570|0571|0572|0573|0575|0577|0578|058|0591|0592|0593|0594|0595|0596|0597|0598|0599|06|070|071|072|073|074|075|076|077|078|079)/;

	c = c.replace(re,'($1)');
	return c;
}

function fCorrectCase(c)
{
	return c.substr(0,1).toUpperCase() + c.substr(1).toLowerCase();
}

function initOrderButton()
{
	var loBtn = document.getElementById("cmd_OrderNow");
	if(loBtn != null)
	{
		history.go(1);

		loBtn.onclick = function()
		{
			this.value= "Order wordt verwerkt...";
			this.onclick = function()
			{
				return false;
			}
		}
	}
}

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 initTopMenu()
{
	var oM = $("#topmenu");
	if(oM != null)
	{
		oM.data("menus",  $("td.topmenubaritem"));
		oM.data("menus").data("menubar", oM);

		
		oM.mouseleave(
			function()
			{
				window.clearTimeout( oM.data("timer") );
				oM.data("timer", window.setTimeout("closeAllTopMenusBut('xx')",500));
			}
		);
	
		$("td.topmenubaritem", oM).mouseenter(
			function()
			{
				window.clearTimeout( oM.data("timer") );
				oM.data("timer", window.setTimeout("openMenu('" + this.id + "')",100));				
			}
		);
	}

}

function openMenu(id)
{
	closeAllTopMenusBut(id);
	$('#' + id).addClass('topmenubaritemactive');
}

function closeAllTopMenusBut(id)
{
	$("#topmenu td.topmenubaritem:not(#" + id + ")").removeClass('topmenubaritemactive');
}

