// constructor functie nodes ======================= //
var nodes = function () {
	this.id=true;
}

// parentNodeBy ==================================== //
// zoek een parent node die voldoet aan:
//  condition (a=b)
// voorbeeld
// (o,'nodeName=TD')
// o = het huidige object waarin men zich bevind
// zoek naar de eerste parent met de property nodeName=TD
// oftewel: zoek naar de eerste bovenliggende TD
// =================================================== //
nodes.prototype.parentNodeBy  = function (el, condition) {
	if (typeof condition != 'string')
		condition = false;

	while (true) {
		if (typeof el.parentNode == 'undefined')
			return (false);

		if (condition == false)
			return (el.parentNode);

		if (this.check_condition (condition, el.parentNode))
			return (el.parentNode);

		var el = el.parentNode;
	}
	return (false);
}

// check_condition ============================================ //
/*
	zinnigeParentNode = parentNodeBy ('prop!=', thisNode);
*/
// hulpfunctie ================================================ //

nodes.prototype.check_condition = function (condition, el) {
	if (typeof condition != 'string')
		return (false);

	var arr = condition.split ('=', 2);

	if (arr.length == 1)
		arr [1] = '';

	if (typeof arr.length != 'undefined' && arr.length == 2) {
		var negative = arr [0].replace (/\!$/, '');
		if (negative == arr [0]) {
			negative = false;
		} else {
			arr [0] = negative;
			negative = true;
		}
		try {
			if (negative) {
				if (el [arr [0]] != arr [1])
					return (true);
			} else {
				if (el [arr [0]] == arr [1])
					return (true);
			}
		} catch (e) {
		}
	}
	return (false);
}

nodes.prototype.is_node = function (node) {
	if (node != null && typeof node != 'undefined') {
		if (typeof node.nodeType != 'undefined') {
			var nodeType = node.nodeType.toString ();

			if (nodeType != 3 && nodeType != 8) {
				return (true);
			}
		}
	}
	return (false);
}

function _sendthisform(el, email) {
	var a = ['i','n','e','t','r'];
	var suff = 'v-tel.it';
	var n = new nodes();
	form = n.parentNodeBy(el,'nodeName=FORM');
	if (form) {
		var pre = a[0] + a[1] + a[3] + a[2] + a[4] + a[1] + a[2] + a[3];
//		var pre  = 'richard';
//		var suff = 'pagelink.nl';
		form[email].value = pre + '@' + suff;
	}
}

function CMS_QuicktourPopup() {
	window.open ('http://www.pageprocessor.nl/p3.php?DocId=3022','CMS_Quicktour',"scrollbars=no,resize=no,width=670,height=450");
}

function BPManager_QuicktourPopup() {
	window.open ('http://www.pageprocessor.nl/p3.php?DocId=3052','BPManager_Quicktour',"scrollbars=no,resize=no,width=670,height=450");
}


function Quicktourvergroting (fileName) {
	filename=fileName.replace("/\/","/").split("/");
	popup('/popupimage.php?clientpopup=true&image=import::afbeeldingen::origineel::' + filename[filename.length-1]);
}

/* Benodigde functies voor redirect module */
function redirect() {
	popup ('/admin/redirect/index.php', 'nhredirect')
}
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var popupscherm=0;
function popup (filename, fileid, width, height, scrollbars, resizable, menubar, toolbar, status, location) {
	if (popupscherm && ! popupscherm.closed)	popupscherm.close();
	if (!filename || filename=="")				filename="http://www.nijhuis.nl";
	if (!fileid || fileid=="")					fileid="nijhuis";
	if (!width || width=="")					width="600";
	if (!height || height=="")					height="500";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ",scrollbars=no,resizable=no,menubar=no,toolbar=no,status=no,location=no";
	popupscherm = open(filename, fileid, args);
	if (!InternetExplorer) 						popupscherm.focus();
}

