
// IE8 bug:	Mootools' Element.prototype.getElementById clashes with Adobe Flash's ExternalInterface.addCallback
// Trigger:	load page and close tab or window, an alert will appear
// Solution:	delete Element.prototype.getElementById
delete Element.prototype.getElementById;



if (bw.ie && bw.v<=7) {
	new Asset.css('/libs/css/centercenter.ie.css' , {media:'screen'});

	if (bw.v<7) {
		new Asset.css('/libs/js/iepngfix/iepngfix.css');
		new Asset.javascript('/libs/js/iepngfix/iepngfix_tilebg.js');
	}
}

window.addEvent('domready' , function() {
	// hidden button to switch between HTML and FLash
	__('body').adopt(new Element('div' , {
		styles: {
			position:	'absolute',
			background:	'#fff',
			width:		10,
			height:		10,
			left:		0,
			right:		0
		},
		events: {
			click: function() {Cookie.set('html' , Cookie.get('html')==0 ? 1:0); document.location.reload()}
		}
	}));

	// print site.swf or restyle #site for HTML content
	window.uid = new Date().getTime();
	if (!Cookie.get('html') || Cookie.get('html')=='0') {
		// make and insert SWF-object
/*
var flashvars	= {};
var params	= {};
var attributes	= {id:'flObj' , name:'flObj'};
swfobject.embedSWF('/site.swf?cache='+uid , 'site' , '780' , '550' , '7' , '/libs/js/swfobject/expressinstall.swf' , flashvars , params , attributes);
*/

		var so = new SWFObject('/site.swf?cache='+uid , 'flObj' , '780' , '550' , '7' , '#fff');
		so.useExpressInstall('/libs/js/swfobject/expressinstall.swf');
		so.addParam('salign'	, 'lt');
		so.addParam('wmode'	, 'opaque');
		so.addVariable('uid'	, uid);
		so.addVariable('pids'	, pids);
		so.write('site');
	}
	else {
		_('site').setStyles({width:700 , height:525});

		// open links to /_pops/... in internal popup
		__('a[href^=/_pops]').addEvent('click' , function(e) {
			var page	= this.href.match(/_pops\/(\w+)/)[1];
			popUp(this.href , pops[page].height , pops[page].width , pops[page].title);
			new Event(e).stop();
		});
	}

	// unhide #site
	_('site').setStyle('display' , 'block');
});

// js2flash('flObj' , {getPage:'contact'})
function js2flash(flObj , vrs) {(navigator.appName.match("Microsoft")?window:document)[flObj].js2flash(vrs)}

// handle multibox from hidden link
window.addEvent('domready' , function() {
	var hiddenlink = new Element('a' , {id:'hiddenmb1' , 'class':'hiddenmb'});
	__('body').adopt(hiddenlink);

	var hiddenmb = new MultiBox('hiddenmb' , {
		descClassName:	false, //'multiBoxDesc',
		useOverlay:	true,
		showControls:	false,
		overlayColor:	'#d8d8d8',
		openFromLink:	false,
		path:		'/libs/js/mootools/MultiBox/multibox/files/'
	});

	window.popUp	= function(href , height , width , title) {
		hiddenlink.setProperties({
			href:		href,
			title:		title || '',
			rel:		'width:' + width + ',height:' + height
		});
		hiddenmb.open(hiddenlink);
	}
});

window.addEvent('domready' , function() {
	// open popUp if 1) hash var is provided and 2) hash var exists in pops object
	var hash;
	if ((hash=document.location.hash) && hash.match(/^#?(.+)/)) {
		hash	= RegExp.$1;

		if	(hash.match(/^(\w+)/) && pops[RegExp.$1])		window.popUp('/_pops/' + hash + '.htm?lang=' + lang , pops[RegExp.$1].height , pops[RegExp.$1].width , pops[RegExp.$1].title)
		else if	(hash.match(/^(http.*actueel.*$)/))			window.popUp(RegExp.$1 , pops.actueel.height , pops.actueel.width , pops.actueel.title)

		// erase hash
		document.location.href='#';
	}
});
