var FD = new Object();

function FD_Texts(texts) {
	if (texts) this.set(texts);
}
FD_Texts.prototype.set = function(texts) {
	for (var key in texts) {
		this[key] = texts[key];
	}
}
FD_Texts.prototype.get = function(key, alt) {
	return unescape((this[key] ? this[key] : (alt ? alt : '')));
}
FD_Texts.prototype.create = function(sub, texts) {
	if (this[sub]) this[sub].set(texts);
	else this[sub] = new FD_Texts(texts);
}

try {
	if (top.FD && typeof top.FD.Texts != 'undefined')
		FD.Texts = top.FD.Texts;
	else if (top.opener && typeof top.opener.top.FD != 'undefined' && typeof top.opener.top.FD.Texts != 'undefined')
		FD.Texts = top.opener.top.FD.Texts;
	else
		throw "Create your own Texts object!";
} catch (e) {
	FD.Texts = new FD_Texts();
}

FD.Security = new Object();

function FDBrowser() {
	this.Name = navigator.appName; this.Version = navigator.appVersion; this.VersionNr = parseInt(this.Version);

	this.win = navigator.userAgent.search('Windows') > 0;
	this.linux = navigator.userAgent.search('Linux') > 0;
	this.mac = navigator.userAgent.search('Macintosh') > 0 || navigator.userAgent.search('Mac_') > 0;

	this.opera = (navigator.userAgent.search('Opera') > 0);
	this.gecko = (navigator.userAgent.search('Gecko/') > 0);
	this.ns = (navigator.userAgent.search('Netscape') > 0);
	this.ns4 = false; this.ns6 = false; this.ns7 = false; this.ns8 = false;
	if (this.ns) {
		this.VersionNr = parseFloat(navigator.userAgent.match(/Netscape(\d)?\/(.*)/)[2]);
		this.ns4 = (parseInt(this.Version) == 4);
		this.ns6 = (navigator.userAgent.search('Netscape6') > 0); //parseInt( this.Version ) >= 5 );
		this.ns7 = (navigator.userAgent.search('Netscape/7') > 0);
		this.ns8 = (navigator.userAgent.search('Netscape/8') > 0);
	}

	this.ie = (this.Name == "Microsoft Internet Explorer"); this.ie4 = false; this.ie5 = false; this.ie6 = false; this.ie7 = false;
	if (this.ie) {
		this.VersionNr = parseFloat(this.Version.match(/MSIE (\d+.\d+)/)[1]);
		this.ie4 = (this.Version.search('MSIE 4') > 0);
		this.ie5 = (this.Version.search('MSIE 5') > 0);
		this.ie6 = (this.Version.search('MSIE 6') > 0);
		this.ie7 = (this.Version.search('MSIE 7') > 0);
	}

	this.safari = (this.mac && navigator.userAgent.search('Safari') > 0);
	if (this.safari)
		this.VersionNr = parseFloat(this.Version.match(/Safari\/(\d+.\d+)/)[1]);
	this.camino = (navigator.userAgent.search('Camino') > 0);
	if (this.camino)
		this.VersionNr = parseFloat(navigator.userAgent.match(/Camino\/(.*)/)[1]);


	this.W3C = document.getElementById ? true : false;

	this.isComp = function(npLvl) {
		var lComp = false;
		if (npLvl > 0) {
			lComp = this.gecko && (!this.ns || this.VersionNr >= 7);
			if (!lComp && this.win) lComp = (this.ie && this.VersionNr >= 5.5);
		}
		return lComp;
	}
}

var Browser = FD.Browser = new FDBrowser();

FD.Script = new Object();
FD.Script.loadFile = function(filePath, onload, check_version) {

	if (check_version) filePath += '?' + this.getVersion(check_version);
	// Dynamically load the file (it can be a CSS or a JS)
	var e = document.createElement("script");
	e.type = "text/javascript";

	// Add the new object to the HEAD.
	document.getElementsByTagName("head")[0].appendChild(e);

	// Start downloading it.
	// Gecko fires the "onload" event and IE fires "onreadystatechange"
	if (onload) {
		e.onload = onload;
		if (FD.Browser.ie) {
			e.onreadystatechange = function() {
				if (this.readyState == 'complete') this.tmr = setTimeout(this.onload, 1000);
				if (this.readyState == 'loaded') {
					if (this.tmr > 0) clearTimeout(this.tmr);
					this.onload();
				}
			};
		}
	}
	e.src = filePath;
}
FD.Script.getVersion = function(scriptname) {
	var scripts = document.getElementsByTagName("script"), version = '';
	for (var i = 0; i < scripts.length; i++) {
		if (scripts[i].src.search(scriptname) > -1) {
			var match = /\?(.*)?/.exec(scripts[i].src);
			if (match) version = match[1];
			return version;
		}
	}
	return version;
}

/* This function/object checks for Internet Security software */
FD.Security.checkIS = function(opWND) {

	var obj = { IS: false, Continue: true };

	opWND = (typeof opWND == 'object' ? opWND : window);
	var cOnError = new String(opWND.onerror), cOpen = new String(opWND.open);
	if (opWND.onerror && cOnError.search('native') <= -1 && cOnError.search('fdOnError') <= -1) {
		obj.IS = true;
		opWND.onerror = null;
	}
	if (opWND.open && ((!FD.Browser.safari && cOpen.search('native') <= -1) || (FD.Browser.safari && cOpen != '[function]'))) {
		obj.IS = true;
		if (opWND.SymRealWinOpen)
			opWND.open = opWND.SymRealWinOpen;
		else
			obj.Continue = false;
	}

	return obj;
}
var oIS = FD.Security.checkIS();

Object.is = function(vpEl, cpTest) {
	return (vpEl != null && (typeof vpEl == 'object' || typeof vpEl == 'function') && (typeof cpTest == 'undefined' || (eval('typeof vpEl.' + cpTest) != 'undefined' && eval('typeof vpEl.' + cpTest) != 'unknown')));
};

function setStatus(cpStatus, opWnd) {
	opWnd = top;
	opWnd.status = ((typeof cpStatus == 'string' && cpStatus != '') ? cpStatus : '');
	return true;
}

function getElement(doc, vel) {
	var el = null;
	if (Object.is(vel)) return vel;
	if (!Object.is(doc)) return el;

	if (Browser.W3C) {
		if (typeof doc.getElementsByName == 'function') {
			el = doc.getElementsByName(vel);
		}
		if (!Object.is(el) || el.length == 0) {
			el = (typeof doc.getElementById == 'function' ? doc.getElementById(vel) : null);
		} else if (el.length == 1) {
			el = el[0];
		}
	}

	if (Object.is(el)) return el;

	if (typeof doc.forms != 'undefined' && doc.forms.length > 0)
		el = doc.forms[0].elements[vel];

	if (Object.is(el)) return el;
	if (Browser.ie) el = doc.all[vel];
	return el;
}

function getLocationVars(cpLocation) {
	// de pagina en de parameters scheiden
	var aLocation = cpLocation.split('?'), cBookmark = '';
	// de parameters scheiden
	if (aLocation.length > 1) {
		var nBM = aLocation[1].search('#');
		if (nBM >= 0) {
			cBookmark = aLocation[1].substr(nBM);
			aLocation[1] = aLocation[1].substr(0, nBM);
		}
		aLocation[1] = aLocation[1].split('&');
	} else
		aLocation[1] = new Array();

	// de parameters en de waarden scheiden
	var i = 0;
	for (i = 0; i < aLocation[1].length; i++) {
		aLocation[1][i] = aLocation[1][i].split('=');
		if (typeof aLocation[1][i][0] == 'undefined') aLocation[1][i][0] = '';
		if (typeof aLocation[1][i][1] == 'undefined') aLocation[1][i][1] = '';
	}
	if (cBookmark.length > 0)
		aLocation[1][i] = new Array(cBookmark);

	return aLocation;
}
function getLocationVar(location, qvar) {
	var loc = getLocationVars(location);
	var i = arraySearch(loc[1], qvar, 0, 2);
	if (i > -1) return loc[1][i][1];
	return '';
}

function setLocationVars(cpLocation, apVars, lpNoBookmark) {
	// de pagina en de parameters scheiden
	var aLocation = getLocationVars(cpLocation), cBookmark = '';

	// zoeken en vervangen/toevoegen van de meegegeven parameter/waarde array
	if (apVars) {
		var nIndex, i;
		for (i = 0; i < apVars.length; i = i + 2) {
			nIndex = arraySearch(aLocation[1], apVars[i], 0)
			nIndex = (nIndex > -1) ? nIndex : aLocation[1].length;
			aLocation[1][nIndex] = new Array(apVars[i], apVars[i + 1]);
		}
	}

	// de locatiestring weer opbouwen
	cpLocation = aLocation[0] + '?';
	for (i = 0; i < aLocation[1].length; i++) {
		if (aLocation[1][i][0].charAt(0) != '#')
			cpLocation = cpLocation + ((i > 0) ? '&' : '') +
				aLocation[1][i][0] + ((aLocation[1][i][0].length > 0) ? '=' : '') + aLocation[1][i][1];
		else
			cBookmark = aLocation[1][i][0];
	}

	return (cpLocation + (!lpNoBookmark ? cBookmark : ''));
}

function getCookies(cpCookies) {
	var aCookies = cpCookies.split('; ');

	// de cookies en waarden scheiden
	var i = 0;
	for (i = 0; i < aCookies.length; i++) {
		aCookies[i] = aCookies[i].split('=');
		if (aCookies[i][0] == 'undefined') aCookies[i][0] = '';
		if (aCookies[i][1] == 'undefined' || typeof aCookies[i][1] == 'undefined')
			aCookies[i][1] = '';
		else {
			aCookies[i][1] = decodeURIComponent(aCookies[i][1]);
		}
	}
	return aCookies;
}

function getCookie(cpCookies, cpCookie) {
	var aCookies = getCookies(cpCookies);
	var nIndex = arraySearch(aCookies, cpCookie, 0);
	if (nIndex >= 0)
		return aCookies[nIndex][1];
	else
		return false;
}

function arraySearch(apArray, vpSearchFor, npColumn, npColumns) {
	if (apArray.length == 0) return -1;
	npColumn = (typeof npColumn == 'undefined') ? 0 : npColumn;
	npColumns = (typeof npColumns == 'undefined') ? 1 : npColumns;
	var i = 0, l2d = (Object.is(apArray[0]) && typeof apArray[0][0] != 'undefined');
	if (l2d) {
		for (i = 0; i < apArray.length; i++) {
			if ((typeof apArray[i][npColumn] == 'string' && apArray[i][npColumn].toUpperCase() == vpSearchFor.toUpperCase()) || apArray[i][npColumn] == vpSearchFor)
				return i;
		}
	} else {
		for (i = npColumn; i < apArray.length; i = i + npColumns) {
			if ((typeof apArray[i] == 'string' && apArray[i].toUpperCase() == vpSearchFor.toUpperCase()) || apArray[i] == vpSearchFor)
				return i;
		}
	}
	return -1;
}

function OpenWindow(opWindow, cpPage, npWidth, npHeight, cpScroll, cpStatus, cpToolbar, cpName, opParentProp, lpDialog, vpArg) {
	var lParent = (typeof opParentProp == 'object'), cScroll = (cpScroll ? cpScroll : 'yes');
	var cStatus = (cpStatus ? cpStatus : 'yes'), cToolbar = (cpToolbar ? cpToolbar : 'no');
	var nAvailWidth = 0, nAvailHeight = 0, oDim = new getWindowDim(window, true);
	nAvailWidth = oDim.availWidth; //window.screen.availWidth;
	nAvailHeight = oDim.availHeight; //window.screen.availHeight;
	var nWidth = 0, nHeight = 0, nTop = 0, nLeft = 0;
	npWidth = (typeof npWidth == 'undefined' ? 0 : (npWidth > nAvailWidth ? nAvailWidth : npWidth));
	npHeight = (typeof npHeight == 'undefined' ? 0 : ((npHeight + 32) >= nAvailHeight ? nAvailHeight - 50 : npHeight));

	nWidth = Math.max(nWidth, npWidth);
	nHeight = Math.max(nHeight, npHeight);

	if (!lParent || (nLeft + nWidth > nAvailWidth))
		nLeft = (nAvailWidth / 2) - ((nWidth + (cScroll == 'yes' ? 8 : 0)) / 2);
	if (!lParent || (nTop + nHeight > nAvailHeight))
		nTop = (nAvailHeight / 2) - (nHeight / 2) - 25;
	if (nTop < 0) nTop = 0;
	var oFromWindow = ((Object.is(opWindow)) ? opWindow : window), oWindow = null, vReturn;
	oWindow = oFromWindow.open(cpPage, (cpName ? cpName : ''), 'toolbar=' + cToolbar + ',directories=no,menubar=no,status=' + cStatus + ',resizable=yes,scrollbars=' + cScroll + ',top=' + nTop + ',left=' + nLeft + ',width=' + nWidth + ',height=' + nHeight);

	return (lpDialog ? vReturn : (Object.is(oWindow, 'document') ? oWindow : null));
}

function getWindowDim(opWnd, lpCreated) {
	if (!lpCreated) return (new getWindowDim(opWnd, true));

	this.outerWidth = 0, this.outerHeight = 0, this.clientWidth = 0, this.clientHeight = 0, this.scrolTop = 0, this.scrolLeft = 0;
	this.Top = 0, this.Left = 0, this.availWidth = opWnd.screen.availWidth, this.availHeight = opWnd.screen.availHeight;
	with (this) {
		if (Browser.gecko) {
			availHeight = availHeight - 56;
			Top = opWnd.screenY;
			Left = opWnd.screenX;
			outerWidth = opWnd.outerWidth;
			outerHeight = opWnd.outerHeight + 2;
			clientWidth = opWnd.innerWidth;
			clientHeight = opWnd.innerHeight;
			scrolTop = opWnd.pageYOffset;
			scrolLeft = opWnd.pageXOffset;
		} else if (Browser.ie) {
			availHeight = availHeight - 60;
			Top = opWnd.screenTop;
			Left = opWnd.screenLeft;
			if (opWnd.document.body) {
				outerWidth = opWnd.document.body.offsetWidth + 6; // -6 voor de scrollbar
				outerHeight = opWnd.document.body.offsetHeight;
				clientWidth = opWnd.document.body.clientWidth;
				clientHeight = opWnd.document.body.clientHeight;
				scrolTop = opWnd.document.body.scrollTop;
				scrolLeft = opWnd.document.body.scrollLeft;
			}
		}
	}
}

function layerWrite(opDoc, vpEl, cpHTML) {
	var oEl = getElement(opDoc, vpEl);
	if (!Object.is(oEl)) return;
	if (typeof oEl[0] == 'object') {
		for (var i = 0; i < oEl.length; i++)
			layerWrite(null, oEl[i], cpHTML);
	} else {
		if (this.Browser.ns4 && Object.is(oEl, 'write')) {
			oEl.document.write(cpHTML);
			oEl.document.close();
		}
		if ((this.Browser.ie || this.Browser.W3C) && Object.is(oEl, 'innerHTML'))
			oEl.innerHTML = cpHTML;
	}
}

function preloadImage(cpImage, apArray) {
	var oImg = new Image();
	oImg.src = cpImage;
	if (typeof (apArray) == 'undefined')
		if (typeof (window.preloadImg) == 'undefined')
		window.preloadImg = new Array(oImg);
	else
		window.preloadImg[window.preloadImg.length] = oImg;
	else
		apArray[apArray.length] = oImg;
	return oImg;
}

function URLDecode(cpString) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	var cDecoded = "", i = 0;
	while (i < cpString.length) {
		var ch = cpString.charAt(i);
		if (ch == "+") {
			cDecoded += " ";
			i++;
		} else if (ch == "%" && cpString.charAt(i + 1) != "%") {
			cDecoded += unescape(cpString.substr(i, 3));
			i += 3;
		} else {
			cDecoded += ch;
			i++;
		}
	} // while
	if (i < cpString.length) {
		cDecoded += cpString.substr(i, cpString.length - i);
	}

	return unescape(cDecoded);
}
if (typeof decodeURIComponent == 'undefined') var decodeURIComponent = URLDecode;

function URLEncode(cpString, cpSAFECHARS, lpUrl) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" + 				// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()" + (cpSAFECHARS || ''); // RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var cEncoded = "";
	for (var i = 0; i < cpString.length; i++) {
		var ch = cpString.charAt(i);
		if (ch == " ") {
			cEncoded += (lpUrl ? "%20" : "+"); 			// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			cEncoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			cEncoded += "%";
			cEncoded += HEX.charAt((charCode >> 4) & 0xF);
			cEncoded += HEX.charAt(charCode & 0xF);
		}
	} // for

	return cEncoded;
}
if (typeof encodeURIComponent == 'undefined') var encodeURIComponent = URLEncode;