﻿var eXPorter = {
	addListener: function(el, type, fn) {
		if (typeof el.addEventListener === 'function') {
			eXPorter.addListener = function(el, type, fn) {
				el.addEventListener(type, fn, false);
			};
		} 
		else if (typeof el.attachEvent === 'function') {
			eXPorter.addListener = function(el, type, fn) {
				el.attachEvent('on' + type, fn);
			};
		} 
		else {
			eXPorter.addListener = function(el, type, fn)  {
				el['on' + type] = fn;
			};
		}
	
		eXPorter.addListener(el, type, fn);
	},
	
	getDocHeight: function() {
		try {
		    var D = document;
		    return Math.max(
		        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
		        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
		        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
		    );
		}
		catch (ex) {
			//perhaps an uncompatible browser
		}
	},
		
	onLoad: function() {
		if (parent.eXPorterModule && typeof parent.eXPorterModule.resizeIframe == 'function') {
			parent.eXPorterModule.resizeIframe(eXPorter.getDocHeight());
		}
	}
};

eXPorter.addListener(window, 'load', eXPorter.onLoad);

