/* numbers only */
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
	return true;
}

/* numbers and dots only */
function isFloatKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode == 46) return true; //exception voor punt
	if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
	return true;
}

/* clear textfield */
function clearfield(el, defaultvalue) {
	if(el.value == defaultvalue) el.value = '';
	el.focus();
}

/* versnelde innerHTML funcie */
function replaceHtml(el, html) {
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	var newEl = document.createElement(oldEl.nodeName);
	newEl.id = oldEl.id;
	newEl.className = oldEl.className;
	newEl.innerHTML = html;
	oldEl.parentNode.replaceChild(newEl, oldEl);
	return newEl;
};

/* resize to fit */
function resizeImgOO(el, widthcontainer, heightcontainer, parent) { 
	function imgRatio() { 
		return (el.height / el.width); 
	} 
	function holderRatio() { 
		return (heightcontainer / widthcontainerh); 
	} 
	function fitToContainer() { 
		if(imgRatio>holderRatio)  { 
			if(el.height > heightcontainer) {
				el.height = heightcontainer; 
			}
			if(el.width > widthcontainer) {
				el.width = el.width*(widthcontainer/el.width);
				el.height = el.height*(widthcontainer/el.width);
			}
		} 
		else  { 
			if(el.height > widthcontainer) {
				el.width = widthcontainer;	
			}
			if(el.height > heightcontainer) {
				el.width = el.width*(heightcontainer/el.width);
				el.height = el.height*(heightcontainer/el.width);
			}
		} 
		parent.width = el.width;
	}
	this.imgRatio = imgRatio; 
	this.holderRatio = holderRatio; 
	this.resize = fitToContainer; 
}
