var polixjsurl = 'https://www.polixonline.nl/klanten/';
//var polixjsurl = 'http://doha.perrit.net/klanten/';
//var polixjsurl = 'http://localhost/klanten/';

var polixjsargs = '?RubriekID=1995&usesessionurls=false';

/* deze argumenten zijn nodig; begin en eindkomma zijn ook nodig */
var polixjsNeededArgs=",polixid,";

try {
	var polixjs = document.getElementById ('polixjs');
} catch (e) {
	var polixjs = false;
}

if (polixjs !== false) {
	//alert(polixjsurl + polixjsargs);
	var polixjs_verzekering = polixjs.getAttribute ('verzekering');
		
	if (polixjs_verzekering !== null && polixjs_verzekering !== false)
		var polixjsargs = '?verzekering='+polixjs_verzekering+'&usesessionurls=true';

	var polixjs_collectief = polixjs.getAttribute ('collectief');
	if (polixjs_collectief === null)
		polixjs_collectief = false;
	else
		polixjsargs += '&collectief='+polixjs_collectief;

	try {
		var polixjslocation = window.top.document.location.toString ();
//		var polixjslocation = top.window.location.toString ();
	} catch (e) {
		var polixjslocation = document.location.toString ();
		//
	}

	var pp_params = false;
	for (var i=0; i< polixjs.attributes.length; i++) {
		var atr = polixjs.attributes[i];
		if (atr.nodeName.indexOf("PP_") === 0 || atr.nodeName.indexOf("pp_") === 0 || atr.nodeName.indexOf("EXT_") === 0 || atr.nodeName.indexOf("ext_") === 0){
			polixjsargs += '&'+atr.nodeName+'='+atr.nodeValue;
			pp_params = true;
		}
	}

	polixjslocation = unescape (polixjslocation);
	
	if (pp_params){
		var toplocation = polixjslocation;
		toplocation = toplocation.replace("file:///", "");
		polixjsargs += '&pp_loc='+escape (toplocation);
	}
	
	var _polixjsargs = '';

	polixjslocation = polixjslocation.split(/\&|\?/);

	var polixjssign = "?";

	if (typeof polixjslocation=='object') {
		for (var polixjsel = 1; polixjsel < polixjslocation.length; polixjsel++) {
			var polixjsloc2 = polixjslocation[polixjsel].split(/=/);

			var re = new RegExp (',' + polixjsloc2[0] + ',');

			if (re.test(polixjsNeededArgs)) {
				_polixjsargs += polixjssign + polixjsloc2[0] + '=' + polixjsloc2[1]
				polixjssign="&";
			}
		}
	}

	if (_polixjsargs!='')
		polixjsargs = _polixjsargs;
	else
		if (polixjs_collectief === false)
				polixjsargs = '';

	if (polixjsargs === '')
		alert ('FOUT: collectief onbekend');
	else {
		var polixjs_iframewidth = polixjs.getAttribute ('iframewidth');
		if (polixjs_iframewidth == null)
			polixjs_iframewidth = '100%';

		var polixjs_iframeheight = polixjs.getAttribute ('iframeheight');
		if (polixjs_iframeheight == null)
			polixjs_iframeheight = '100%';

		var polixjsiframe = document.createElement ('IFRAME');
		polixjsiframe.frameBorder = 0;

		polixjsiframe.setAttribute ('src', polixjsurl + polixjsargs);
		polixjsiframe.setAttribute ('width', polixjs_iframewidth);
		polixjsiframe.setAttribute ('height', polixjs_iframeheight);
		polixjsiframe.setAttribute ('position', 'absolute');
		polixjsiframe.setAttribute ('allowTransparency', true);

		if (document.body.onload)
			siteonload = document.body.onload;

		//maak loading div
		var loading = document.createElement('DIV')	
		loading.style.position = 'absolute';
		//loading.style.width = polixjs.parentNode.offsetWidth;
		//loading.style.height = polixjs.parentNode.offsetHeight;
		loading.style.width = polixjs_iframewidth;
		loading.style.height = polixjs_iframeheight;
		loading.style.color = '#000';
		loading.style.background = '#fff';
		loading.style.padding = '20px 0 0';
		loading.style.textAlign = 'center';
		loading.style.fontFamily = 'verdana';
		loading.style.fontSize = '11px';
		loading.style.zIndex = '99999';
		loading.innerHTML = '<br><br><strong>Polix wordt geladen</strong><br>Een moment geduld a.u.b...';
		
		//plaats loading div + polix iframe
		polixjs.parentNode.insertBefore (loading, polixjs);		
		polixjs.parentNode.insertBefore (polixjsiframe, polixjs);
				
		//verwijder loading div als polix geladen is
		polixjsiframe.onload = function() {
			loading.style.display = 'none';
			loadSiteonload();
			
		}
		
		//voer onload van de site nog eens uit om hoogtes etc goed te zetten
		function loadSiteonload() {
			if (typeof siteonload !== 'undefined')
				siteonload(); 
		}
	}
}
