function change_buttons(state)
{
	var obj= window.document.getElementById('b_overlay');
	
		
	if(state == 1)
	{
		obj.style.visibility = 'visible';
		changeStyle(state);
	}
	
	if(state == 0)
	{
		obj.style.visibility = 'hidden';
		changeStyle(state);
	}
}

function changeStyle(state)
{
	if(state == 1)
	{
		document.body.style.height ="100%";
		document.body.style.margin = "0";
		
		if(navigator.appName == "Microsoft Internet Explorer"){
			body.style.backgroundColor="#222222"; <!-- IE only -->
		}
		else {
			document.body.style.backgroundColor="#222222";
		}
	}
	
	if(state == 0)
	{
		document.body.style.height ="100%";
		document.body.style.margin = "0";
			
		if(navigator.appName == "Microsoft Internet Explorer"){
			document.body.style.backgroundColor="#666666"; <!-- IE only -->
		}
		else {
			document.body.style.backgroundColor="#666666";
		}
	}
}


function keyPressHandler(e) {
	var kC  = (window.event) ?    // MSIE or Firefox?
			 event.keyCode : e.keyCode;
	var Esc = (window.event) ?   
			27 : e.DOM_VK_ESCAPE // MSIE : Firefox
	
	if(kC==Esc)
	{
		var the_action = getElementsByAttribute(document.getElementById("formulier"), "input", "type", "submit");
		var aantal = the_action.length -1;
		the_action[aantal].click();
		alert("De wijzigingen zijn geannuleerd");
		change_buttons(0);
	}
}

function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\s)" + strAttributeValue + "(\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}
