// Written by Ahmad Azarinurazie (aien@pixl8.co.uk).
// Created on January 15th. 2009
// Updated on March 15th 2009 to use class name style to preserve variables name

if (typeof(AEqualHeight) == 'undefined') {

	AEqualHeight = {
		init: function() {
			var aElement = [];
			var i = 0;
			var oTallest = null;
			
			// Push all element obj passed in arguments into an array
			for (i=0; i<arguments.length; i++) 
				if (arguments[i] && document.getElementById(arguments[i])) aElement.push(document.getElementById(arguments[i]));
			
			for (i=0; i<aElement.length; i++) {
				if (oTallest == null || AEqualHeight.getHeight(oTallest) < AEqualHeight.getHeight(aElement[i])) oTallest = aElement[i];
			}
			
			for (i=0; i<aElement.length; i++) {
				AEqualHeight.setHeight(aElement[i], oTallest);
			}
		},
		
		getHeight: function(obj) {
			return obj.offsetHeight;
		},
		
		setHeight: function(obj1, obj2) {
			// This website use 1em = 12px
			var iHeight = AEqualHeight.getHeight(obj2)/12;
			
			// This is specifically written for IIA as the column-2-1-1 is inside column column-2-1
			if (obj1.id == "column-2-1-1") iHeight -= 5;
			
			if (navigator.userAgent.toLowerCase().indexOf("msie 6") > -1) obj1.style.height = iHeight + "em";
			else obj1.style.minHeight = iHeight + "em";
		}
	}

}

if (typeof(AEvent) == 'undefined') {
	AEvent = {
		add: function(obj, type, fn) {
			if (obj.addEventListener) obj.addEventListener( type, fn, false );
			else if (obj.attachEvent) {
				obj["e"+type+fn] = fn;
				obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
				obj.attachEvent( "on"+type, obj[type+fn] );
			}
		}
	}
}

AEvent.add(window, "load", function(){ AEqualHeight.init("column-2-1", "column-2-2", "column-2-1-1"); } );
