// ==================================================
// global vars
// ==================================================

var regURL = new RegExp(/^(http\:\/\/)([a-z0-9\-]+\.){1,2}([a-z0-9\-])/);

var bbmx = bbmy = 0; 			// global mousepos vars voor oa. Help Mouseover
var mmchecktel, mmcheckid;

var mmevent 	= 0;			// pas als mmevent op 1 staat zullen de mouse-coords worden uitgelezen
var mmaway		= 0;			// pas als mmaway op 8 staat gaat helptext weer weg
var mymx, mymy;					// waar deze nou voor zijn... vergeten!

// window resizer vars (animeert het resizen van een window)
var rray 		= new Array(0.02, 0.05, 0.1, 0.2, 0.5, 0.8, 0.9, 0.94, 0.97, 0.98, 0.99, 1);
var rtel 		= 0;
var rzid;

// browser detect
var is_mac		= navigator.platform.indexOf("Mac") != -1;
var is_win		= navigator.platform=="Win32";
var is_safari 	= navigator.userAgent.indexOf("Safari") != -1;
var is_opera 	= navigator.userAgent.indexOf("Opera") > -1;
var is_ie 		= navigator.userAgent.indexOf("MSIE") > 1 && !is_opera; //(navigator.userAgent.indexOf ("IE") != -1);
var is_mozilla	= navigator.userAgent.indexOf("Mozilla/5.") == 0 && !is_opera;
var is_gecko 	= /gecko/i.test(navigator.userAgent);
//var is_ie    	= /MSIE/.test(navigator.userAgent);

// document afmetingen
var DBW, DBH;

// ==================================================
// misc functions
// ==================================================

function setDocsize(debug) {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		DBW = window.innerWidth;
		DBH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		DBW = document.documentElement.clientWidth;
		DBH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		DBW = document.body.clientWidth;
		DBH = document.body.clientHeight;
	}

	if (debug) top.document.title = 'document width: ' + DBW + ' x ' + DBH;
}

function centerElement(elid, xoff, yoff) {
	var dw = is_safari ? document.clientWidth : document.body.clientWidth;
	var dh = is_safari ? document.clientHeight : document.body.clientHeight;
	var ew = getElement(elid).offsetWidth;
	var eh = getElement(elid).offsetHeight;

	getElement(elid).style.left = (Math.round((dw-ew)/2)+xoff) + "px";
	getElement(elid).style.top  = (Math.round((dh-eh)/2)+yoff) + "px";
}

function rnd(bot, top) {
	tmp = top - bot;
	tmp = Math.random() * tmp;
	return bot + tmp;
}

function ctime() {
	t 	= new Date();
	t2 	= t.getYear().toString()
		+ t.getMonth().toString()
		+ t.getDate().toString()
		+ t.getHours().toString()
		+ t.getMinutes().toString()
		+ t.getSeconds().toString();
	return t2;
}

// ==================================================

function getElement(el) {
	return document.getElementById(el);
}

// ==================================================

// php-compatible url-encode (alle non-alphanumerieke tekens behalve de .)
// NB: escape() zou ook kunnen, echter deze functie werkt beter dan escape()
function urlenc(str) {
	var ret = "";
//alert('ok');
	for (i=0; i < str.length; i++) {
		c = (str.substr(i,1));	// neem 1 char vd string
		// indien char geen alfanumeriek of . teken is
		if (c.search(/[^0-9a-zA-Z\.]/g) != -1) {
			// neem ascii-code van char en converteer naar hexadecimaal en maak die string uppercase
			ret += "%" + c.charCodeAt(0).toString(16).toUpperCase();
		} else {
			ret += c;
		}
	}
	return ret;
}

function getxoff() {
	if (is_safari) 	return window.pageXOffset;
	if (is_ie) 		return document.body.scrollLeft;
}

function getyoff() {
	if (is_safari) 	return window.pageYOffset;
	if (is_ie) 		return document.body.scrollTop;
}

function setxoff(xoff) {
	if (is_safari) 	window.pageXOffset = xoff;
	if (is_ie) 		document.body.scrollLeft = xoff;
}

function setyoff(yoff) {
	if (is_safari) 	window.pageYOffset = yoff;
	if (is_ie) 		document.body.scrollTop = yoff;
}

function trim(s) {
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}
	return s;
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function isUrl(s) {
	// werkt niet: /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	// werkt niet: /https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?/;
	var regexp = /^(ftp|http|https):\/\/([0-9a-z\-]{2,})\.([0-9a-z\-]{2,})(.{0,})$/i;
	return regexp.test(s);
}

// cookie stuff
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie= name + "=" + escape(value.toString()) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

// alternatief: plaats object adhv positie huidige object
// NB: extra feature die kijkt of element buiten beeld valt, zoja plaats dan in beeld
function showLayerRelative(srcObj, dstObj, dstXOff, dstYOff, forceShow) {
	if (dstObj.style.visibility == 'visible' && !forceShow) {
		dstObj.style.visibility = 'hidden';
	} else {
		var objBody = document.body;
		var ow = dstObj.offsetWidth;
		var oh = dstObj.offsetHeight;
		var ox = obj_curleft(srcObj)+dstXOff;
		var oy = obj_curtop(srcObj)+dstYOff;

		if (oy+oh > objBody.clientHeight+objBody.scrollTop) {
			oy = obj_curtop(srcObj)-oh+srcObj.offsetHeight-dstYOff;
		}

		if (ox+ow > objBody.clientWidth+objBody.scrollLeft) {
			ox = obj_curleft(srcObj)-ow+srcObj.offsetWidth-dstXOff;
		}

		dstObj.style.left = ox+'px';
		dstObj.style.top  = oy+'px';
		dstObj.style.visibility = 'visible';
	}
}

// ==============================================
// maak een kleur bijv. "#f08050" lichter of donkerder in factor (0.5 = donkerder, 1.5 = lichter)
// ==============================================

function colbrightness(srcCol, factor) {
	tmpR = Math.max(0, Math.min(255, Math.round(hexdec(srcCol.substr(1,2)) * factor)));
	tmpG = Math.max(0, Math.min(255, Math.round(hexdec(srcCol.substr(3,2)) * factor)));
	tmpB = Math.max(0, Math.min(255, Math.round(hexdec(srcCol.substr(5,2)) * factor)));
	return "#" + toHex(tmpR) + toHex(tmpG) + toHex(tmpB);
}

function colmix(colA, colB, balance) {
	if (colA.match(/^(rgb)/i)) {
		colA = colA.replace(/[^0-9,]/g, '').split(',');
	} else {
		colA = new Array(hexdec(colA.substr(1,2)), hexdec(colA.substr(3,2)), hexdec(colA.substr(5,2)));
	}

	if (colB.match(/^(rgb)/i)) {
		colB = colB.replace(/[^0-9,]/g, '').split(',');
	} else {
		colB = new Array(hexdec(colB.substr(1,2)), hexdec(colB.substr(3,2)), hexdec(colB.substr(5,2)));
	}

	var tmpR = Math.round( colA[0] * (1-balance) + colB[0] * balance);
	var tmpG = Math.round( colA[1] * (1-balance) + colB[1] * balance);
	var tmpB = Math.round( colA[2] * (1-balance) + colB[2] * balance);
	return "#" + toHex(tmpR) + toHex(tmpG) + toHex(tmpB);
}

// ==============================================
// decimaal naar hexadecimaal conversie
// ==============================================

var hexval = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');

function toHex(i) {
	runningTotal = '';
	quotient = hexQuotient(i);
	remainder = eval(i + '-(' + quotient + '* 16)');
	runningTotal = hexval[remainder] + runningTotal;
	while( quotient >= 16) {
		savedQuotient = hexQuotient(quotient);
		remainder = eval(quotient + '-(' + savedQuotient + '* 16)');
		runningTotal = hexval[remainder] + runningTotal;
		quotient = savedQuotient;
	}
	return hexval[quotient] + runningTotal ;
}

function hexQuotient(i) {
	return Math.floor(eval(i +'/ 16'));
}

function valClip(val, lo, hi) {
	val = parseInt(val,10);
	val = isNaN(val) ? 0 : val;
	return Math.max(lo, Math.min(hi, parseInt(val, 10)));
}

function hexdec(i) {
  i = parseInt(i.toUpperCase(),16);
  return (isNaN(i) ? 0 : i);
}

function str2int(str) {
	if (typeof(str)=="string") {
		val = parseInt(str.replace(/[^0-9\-]/gi, ''),10);
		return isNaN(val) ? 0 : val;
	} else {
		return str;
	}
}

// test of waarde in array zit
// JS 26-jul-09: case-insensitive gemaakt
function inArray(arr, val) {
	for (var i=0; i<arr.length; i++) {
		if (arr[i].toString().toLowerCase() == val.toString().toLowerCase()) return true;
	}
	return false;
}

// zoek waarde in array en retourneer index
// JS 26-jul-09: case-insensitive gemaakt
function arrval2idx(arr, val, notfound) {
	for (var i=0; i<arr.length; i++) {
		if (arr[i].toLowerCase() == val.toLowerCase()) return i;
	}
	return notfound;
}

// zoek een waarde in de selbox lijst en retourneer diens index of 0 indien niet gevonden
function selboxval2idx(selobj, val) {
	for (var i=0; i<selobj.options.length; i++) {
		if (selobj.options[i].value == val) {
			return i;
		}
	}
	return 0;
}

// zoek in selectbox een waarde op en selecteer deze
function selboxset(selobj, val, noWarnings) {
	for (var i=0; i<selobj.options.length; i++) {
		if (selobj.options[i].value == val) {
			selobj.selectedIndex = i;
			return i;
		}
	}
	if (noWarnings != 1) {
		alert("Warning: selectbox '"+selobj.name+"' could not be set to option with value '" + val + "'.\n\nSource: "+location.href);
	}
	return 0;
}

// zoek in selectbox een label (text) op en selecteer deze
function selboxsetbylabel(selobj, val) {
	for (i=0; i<selobj.options.length; i++) {
		if (selobj.options[i].text.toLowerCase() == val.toLowerCase()) {
			selobj.selectedIndex = i;
			return i;
		}
	}
	return 0;
}

// valideer tijdveld in formaat HH:MM bijv. 23:12
function chktime(obj) {
	v = obj.value.replace(/[^0-9]/gi, "");
	if (isNaN(v) || v.length == 0) {
		obj.value = "12:00";
	}
	v = "0000" + v;
	v = v.substr(v.length-4,4);
	h = "00" + Math.min(23, parseInt(v.substr(0,2),10)).toString();
	m = "00" + Math.min(59, parseInt(v.substr(2,2),10)).toString();

	obj.value = h.substr(h.length-2,2) + ":" + m.substr(m.length-2,2);
}

function objDisplay(objid) {
	t = getElement(objid).style.display;
	if (t == 'none') {
		getElement(objid).style.display = "block";
		t = 1;
	} else {
		getElement(objid).style.display = "none";
		t = 0;
	}
	return t;
}

// -------------------------------------------------------

function format_seconds(seconds) {
	m = "00" + Math.floor(seconds/60).toString();
	s = "00" + (seconds % 60).toString();
	return m.substr(m.length-2,2) + ":" + s.substr(s.length-2,2);
}

// vervang de ct-parameter in een url-string
function url_refresh(str) {
	ctbeg = str.indexOf("ct=");
	if (ctbeg != -1) {
		ctend = str.indexOf("&", ctbeg);
		if (ctend != -1) {
			return str.substr(0,ctbeg) + "ct=" + ctime() + str.substr(ctend);
		} else {
			return str.substr(0,ctbeg) + "ct=" + ctime();
		}
	} else {
		return str + (str.indexOf("?") == -1 ? "?" : "&") + "ct=" + ctime();
	}
	//return str.indexOf("ct=");
}

function human2unix(y,m,d,h,i,s) {
	d = new Date(Date.UTC(y,m-1,d,h,i,s));
	return d.getTime() / 1000.0;
}

function unix2human(timestamp, arrMonthNames, addTime) {
	var t  = new Date(timestamp * 1000);
	var t2 =
		+ t.getDate().toString() + " "
		+ arrMonthNames[t.getMonth()] + " "
		+ t.getYear().toString();

	if (addTime) {
		t2 += " " + t.getHours().toString() + ':' + t.getMinutes().toString();
	}

	return t2;
}

function unixstamp() {
	d = new Date();
	return d.getTime() / 1000.0;
}

// retourneer true indien needle in array haystack voorkomt, anders false
function in_array(needle, haystack) {
	if (!haystack.length) return false;
	for (var q=0; q<haystack.length; q++) if (needle == haystack[q]) return true;
	return false;
}

// retourneer absolute top en left corner van relatief object
// handig voor positioneren absolute layers bij bijv. een input-object of span
function obj_curtop(obj) {
	actb_toreturn = 0;
	while(obj){
		actb_toreturn += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return actb_toreturn;
}

function obj_curleft(obj) {
	actb_toreturn = 0;
	while(obj){
		actb_toreturn += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return actb_toreturn;
}

// ------------------------------------------------------------
// loop door object en diens parentNodes (numlevels) heen om een property te vinden
// bijv. handig om breedte te vinden: obj_getstyle(getElement('object'), 'width', 2)
// ------------------------------------------------------------

function obj_getstyle(obj, prop, numlevels) {
	for(var i=0; i<numlevels; i++) {
		var meas = str2int(eval("obj.style."+prop));
		if(meas) {
			return meas;
			break;
		}
		obj = obj.parentNode;
	}
	return false;
}

// ------------------------------------------------------------
// muis-coordinaten
// bron: http://javascript.about.com/library/blmousepos.htm
// ------------------------------------------------------------

function mouseX(evt) {
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)
	   return evt.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	else return null;
}
function mouseY(evt) {
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)
	   return evt.clientY + (document.documentElement.scrollTop ?
	   document.documentElement.scrollTop :
	   document.body.scrollTop);
	else return null;
}

// ------------------------------------------------------------
// enable | disable fields in form
// ------------------------------------------------------------

function disable_fields(formname, mode) {
	f = eval("document."+formname);
	// loop door alle fields in form
	for (i = 0; i < f.elements.length; i++) {
		f.elements[i].disabled = mode;
	}
}

// ------------------------------------------------------------
// verwijder object en diens childs
// ------------------------------------------------------------

function obj_remove(obj) {
	// indien er kindjes in dit object zitten, verwijder die dan eerst
	if (obj.childNodes.length) {
		for (var i = 0; i < obj.childNodes.length; i++) {
			obj_remove(obj.childNodes[i]);
		}
	}
	// verwijder vervolgens het object zelf
	obj.parentNode.removeChild(obj);
}

// ------------------------------------------------------------
// geef basisnaam zonder pad terug
// ------------------------------------------------------------

function basename(filename) {
	return filename.replace(/^.+[\\\\\\/]/g, '');
}

function urlbase(url) {
	if (url == false) url = location.href;

	// http://127.0.0.0.1/bla/bla/bla/mediaman_settings.php?bla=1&b=3 -> mediaman_settings.php
	var urlpart = url.match(/^(http|https)\:\/\/.+\/(.+)$/);
	if (urlpart) url = urlpart[2];

	urlpart = url.match(/^([^\?]+)\?(.+)$/);
	if (urlpart) url = urlpart[1];

	return url;
}

// ------------------------------------------------------------
// zoek node (bijv. TEXTAREA) en retourneer object indien gevonden
// ------------------------------------------------------------

function findNode(obj, findNodeName, lvl) {
	if (lvl>20) {
		alert('Too many recursions: '+lvl);
		return;
	}
	if (obj.nodeType == 1 && obj.nodeName == findNodeName) {
		return obj;
	} else if (obj.nodeType == 1 && obj.childNodes.length) {
		for(var c=0; c<obj.childNodes.length; c++) {
			var objChild = findNode(obj.childNodes[c], findNodeName, lvl+1);
			if (objChild) return objChild;
		}
	} else {
		return false;
	}
}

// ------------------------------------------------------------
// zoek node op className en retourneer object indien gevonden
// ------------------------------------------------------------

function findNodeByClassName(obj, findClassName, lvl) {
	if (lvl>20) {
		alert('Too many recursions: '+lvl);
		return;
	}
	if (obj.nodeType == 1 && obj.className == findClassName) {
		return obj;
	} else if (obj.nodeType == 1 && obj.childNodes.length) {
		var objChild;
		for(var c=0; c<obj.childNodes.length; c++) {
			objChild = findNodeByClassName(obj.childNodes[c], findClassName, lvl+1);
			if (objChild) return objChild;
		}
	} else {
		return false;
	}
}

// ----------------------------------------------------------------
// zoek node via een regular expression op de id
// vb:	regExp = /^(ypos)[0-9]+$/gi
//		findNodeByRegExp(getElement('content'+imgCntId), regExp, 0)
// ----------------------------------------------------------------

function findNodeByRegExp(obj, regExp, lvl) {
	if (lvl>20) {
		alert('Too many recursions: '+lvl);
		return;
	}
	if (obj.nodeType == 1 && obj.id.length && regExp.test(obj.id)) {
		return obj;
	} else if (obj.nodeType == 1 && obj.childNodes.length) {
		for(var c=0; c<obj.childNodes.length; c++) {
			var objChild = findNodeByRegExp(obj.childNodes[c], regExp, lvl+1);
			if (objChild) return objChild;
		}
	} else {
		return false;
	}
}

// ----------------------------------------------------------------
// shift(): Removes the first element from an array and returns it
// usage: 	arrayObj.shift()
// ----------------------------------------------------------------

if(!Array.prototype.shift) {
	Array.prototype.shift = function(){
		firstElement = this[0];
		this.reverse();
		this.length = Math.max(this.length-1,0);
		this.reverse();
		return firstElement;
	}
}

// ----------------------------------------------------------------
// unshift():	Returns an array with specified elements inserted at the beginning
// usage: 		arrayObj.unshift([item1[, item2 [, . . . [, itemN]]]])
// ----------------------------------------------------------------

if(!Array.prototype.unshift) {
	Array.prototype.unshift = function(){
		this.reverse();
			for(var i=arguments.length-1; i>=0; i--) {
				this[this.length] = arguments[i];
			}
		this.reverse();
		return this.length;
	}
}

function toggleRadio(formName, fieldName) {
	var r = eval('document.'+formName+'.'+fieldName);
	r.checked = r.checked ? false : true;
	return r.checked;
}

function getRadioChecked(objRadio) {
	if (objRadio.length) {
		for(var i=0; i<objRadio.length; i++) {
			if (objRadio[i].checked) {
				return objRadio[i].value;
				break;
			}
		}
	}
	return false;
}

// make percentage, degrees or integer of a value
function validateinput(input, mode, minval, maxval) {
	if (mode == "percentage") {
		return Math.max(minval, Math.min(maxval, str2int(input))).toString() + "%";
	} else if (mode == "degrees") {
		return (str2int(input) % 360).toString() + "°";
	} else if (mode == "integer") {
		return Math.max(minval, Math.min(maxval, str2int(input)));
	} else if (mode == "float") {
		input = parseFloat(input.replace(/^0-9\-\./gi, ""));
		if (isNaN(input)) input = 0;
		return Math.max(minval, Math.min(maxval, input));
	}
}

// increase / decrease value of input
function incdecinput(formname, inputname, incvalue, mode, minval, maxval) {
	obj = eval("document."+formname+"."+inputname);
	obj.value = validateinput(
		str2int(obj.value)+incvalue,
		mode,
		minval,
		maxval
	);
}

// check of window.opener bestaat en nog open is (retourneert true | false)
function checkOpener() {
	if (typeof(window.opener) == 'undefined' || window.opener.closed) {
		return false;
	} else {
		return true;
	}
}

// probeer een stukje code. indien dit een javascript error geeft, vang deze af
// vb: if (checkOpener()) tryCode('window.opener.focus()', 0)
function tryCode(code, showErrors) {
	try {
		eval(code);
	}
	catch(err) {
		if (showErrors) alert('Error: ' + err.description);
	}
}

// retourneer event bij een onclick ofzo, IE en FireFox compatible
// aanroep: getEvent(event)
// vb: onkeypress="if (getEvent(event).keyCode == 13) buildsearch(0);"
function getEvent(e) {
	if (!e) var e = window.event;
	return e;
	//if (e.keyCode) code = e.keyCode;
	//else if (e.which) code = e.which;
}

// voer een link uit van een <a href=''> element: geef ID van het object op en de link wordt uitgevoerd
function execLink(aObjectId) {
	var link = getElement(aObjectId).href;
	var isJS = link.match(/^(javascript\:)(.+)$/i);

	if (isJS) {
		// linkje is javascript-code!
		link = isJS[2];
		var isVoid = link.match(/^(void\()(.+)(\))$/i);
		if (isVoid) link = isVoid[2];

		// All characters encoded with the %xx hexadecimal form are replaced by their ASCII character set equivalents.
		link = unescape(link);

		eval(link);
	} else {
		location.href = link;
	}
	//alert(link);
}

// stel transparantie van item in
function setOpacity(obj, percentOpacity) {
	if(typeof(obj.style.filter)=='string') { obj.style.filter='alpha(opacity:'+percentOpacity+')'; }
	if(typeof(obj.style.KHTMLOpacity)=='string') { obj.style.KHTMLOpacity=percentOpacity/100; }
	if(typeof(obj.style.MozOpacity)=='string') { obj.style.MozOpacity=percentOpacity/100; }
	if(typeof(obj.style.opacity)=='string') { obj.style.opacity=percentOpacity/100; }
}

// indien nodig, scroll naar item in beeld
function scrollObjectIntoView(obj) {

	// check Y-positie
	var topOfObject = obj.style.top.length ? str2int(obj.style.top) : obj_curtop(obj);
	var bottomOfObject = topOfObject + obj.offsetHeight;
	var bottomOfVisibleArea = document.body.clientHeight + getyoff();

	//alert(obj.style.top + ' / ' + bottomOfObject + ' : ' + bottomOfVisibleArea);

	if (bottomOfObject > bottomOfVisibleArea) {
		obj.scrollIntoView(false);
	}
}

// retourneer rechter-onderkant van een element (als kommagescheiden string)
function bottomRight(id) {
	var obj = getElement(id);

	// object niet gevonden?
	if (obj == null) {
		setDocsize();
		return (window.screenLeft + Math.round(DBW/2)) + ',' + (window.screenTop);
	}

	var rgt = obj_curleft(obj) + obj.offsetWidth + window.screenLeft;
	var bot = obj_curtop(obj) + obj.offsetHeight + window.screenTop;
	return rgt+','+bot;
}

// maak van alle woorden in een string de eerste letter een Hoofdletter
function ucwords(str) {
	var arrWords = str.split(' ');
	for (var i=0; i<arrWords.length; i++) {
		arrWords[i] = arrWords[i].substr(0,1).toUpperCase() + arrWords[i].substr(1,arrWords[i].length-1);
		//alert(arrWords[i]);
	}
	return arrWords.join(' ');
}

function clipText(str, treshold, abbr) {
	if (str.length>treshold) {
		if (!abbr) abbr = '...';
		str = str.substr(0,treshold) + abbr;
	}
	return str;
}

// converteer "dd-mm-yyyy" naar unix-versie
function date2unix(dat) {
	dat = dat.replace(/[^0-9]/gi, "");
	if (dat.length != 8) return false;
	y = dat.substr(4,4);
	m = dat.substr(2,2);
	d = dat.substr(0,2);
	return human2unix(y,m,d,0,0,0);
}

//

function addEvent2( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent2( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}

function getElementsByClassName(classname, node) {

	//alert(classname);

	if (!node) {
		node = document.getElementsByTagName('body')[0];
	}

	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName('*');

	for (var i = 0, j = els.length; i < j; i++) {
		if ( re.test(els[i].className) ) {
			a.push(els[i]);
		}
	}

	return a;
}


function getElementsByRegExpId(p_regexp, p_element, p_tagName) {
	p_element = p_element === undefined ? document : p_element;
	p_tagName = p_tagName === undefined ? '*' : p_tagName;
	var v_return = [];
	var v_inc = 0;
	for(var v_i = 0, v_il = p_element.getElementsByTagName(p_tagName).length; v_i < v_il; v_i++) {
		if(p_element.getElementsByTagName(p_tagName).item(v_i).id && p_element.getElementsByTagName(p_tagName).item(v_i).id.match(p_regexp)) {
			v_return[v_inc] = p_element.getElementsByTagName(p_tagName).item(v_i);
			v_inc++;
		}
	}
	return v_return;
}


