var Event = {
	add: function(obj,type,fn) {
		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]);
		} else
		obj.addEventListener(type,fn,false);
	},
	remove: function(obj,type,fn) {
		if (obj.detachEvent) {
			obj.detachEvent('on'+type,obj[type+fn]);
			obj[type+fn] = null;
		} else
		obj.removeEventListener(type,fn,false);
	}
}

function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/,"");
}

function addClassName(el,className) {
	removeClassName(el,className);
	el.className = (el.className + " " + className).trim();
}

function removeClassName(el,className) {
	el.className = el.className.replace(className,"").trim();
}

function getStyle(el, styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function windowSize() {
	var size = {};		
	if (window.innerWidth) // all except Explorer
	{
		size.w = window.innerWidth;
		size.h = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) // Explorer 6 Strict Mode
	{
		size.w = document.documentElement.clientWidth;
		size.h = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		size.w = document.body.clientWidth;
		size.h = document.body.clientHeight;
	}
	return size;
}

var BoxHeights = {
	maxh: 0,
	boxes: Array(),
	num: 0,
	
	equalise: function() {
		this.num = arguments.length;
		for (var i=0;i<this.num;i++) if (!$(arguments[i])) return;
		this.boxes = arguments;
		this.maxheight();
		for (var i=0;i<this.num;i++) $(arguments[i]).style.height = this.maxh+"px";
	},

	maxheight: function() {
		var heights = new Array();
		for (var i=0;i<this.num;i++) {
			if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
				heights.push($(this.boxes[i]).scrollHeight);
			} else {
				heights.push($(this.boxes[i]).offsetHeight);
			}
		}
		heights.sort(this.sortNumeric);
		this.maxh = heights[this.num-1];
	},

	sortNumeric: function(f,s) {
		return f-s;
	}
}

Event.add(window, "load", function() {
	SetHeight();
});

function SetHeight()
{
if(!$("flash")){
	var size = windowSize();
	var header = $("header").scrollHeight;
	var footer = $("footer").scrollHeight;
	var diff = size.h - header - footer - 63;
	if(diff > $("content").scrollHeight && diff > $("subnav").scrollHeight){
		$("content").style.height = diff+"px";
		$("subnav").style.height = diff+"px"; 
	}
	else {
		var h = Math.max($("content").scrollHeight, $("subnav").scrollHeight);
		$("content").style.height = h+"px";
		$("subnav").style.height = h+"px";
	}
	}
}

//Event.add(window, "load", function() { BoxHeights.equalise('subnav', 'content'); });