Page = function() {
	if (!this.hasSupport()) return;
	this.menu = new Navigation("primary-navigation");
	this.customSubmits = new Submits();
	this.tabbedItems = new TabbedItems();
	this.collapsers = new Collapsers();	
	this.skipLinks = new SkipLinks("skip");
}

Page.prototype.destroy = function() {
	if(!this.hasSupport()) return;
	this.menu.destroy();
	if(this.tabbedItems) this.tabbedItems.destroy();
	if(this.collapsers) this.skipLinks.destroy();
	if(this.skipLinks) this.skipLinks.destroy();
}

Page.prototype.hasSupport = function(){
	// block MSIE5.0x/Win, MSIE5.x/Mac
	var ua = navigator.userAgent;
	if((ua.indexOf("MSIE 5.0") != -1 && ua.indexOf("Windows") != -1) || (ua.indexOf("MSIE 5.2") != -1 && ua.indexOf("Mac") != -1) || !document.getElementsByTagName || !document.getElementById) return false; else return true;
}

addClass = function(obj, cName) { 
	removeClass(obj,cName); 
	return obj.className += (obj.className.length > 0 ? " " : "") + cName; 
}

removeClass = function(obj, cName) {
	return obj.className = obj.className.replace(new RegExp("^" + cName+"\\b\\s*|\\s*\\b" + cName+"\\b",'g'),''); 
}

getElementsByClassName = function(cName, baseElement) {
	var results = new Array;
	var objs = document.getElementsByTagName("*").length > 0 ? baseElement.getElementsByTagName("*") : baseElement.all;
	if(!objs) objs = baseElement.all;
	for(var i = 0; i < objs.length; i++){
		if(objs[i].className.match(cName)) results[results.length] = objs[i]
	}
	return results;
}

Object.prototype.method = function(method) {
	var context = this;
	return function(){
		method.apply(context, arguments);
	}
}

setCookie = function(name, value, expires, path, domain, secure){
	document.cookie = name + "=" + escape(value) + 
		((expires) ? ";expires=" + expires.toGMTString() : "") + 
		((path) ? ";path=" + path : "") + 
		((domain) ? ";domain=" + domain : "") + 
		((secure) ? ";secure" : "");
}

calculateLeft = function(object) {
	if (object) return object.offsetLeft + calculateLeft(object.offsetParent); 
	else return 0;
}

calculateTop = function(object) {
	if (object) return object.offsetTop + calculateTop(object.offsetParent); 
	else return 0;
}

tickle = function(){
	addClass(document.getElementsByTagName("body")[0], "tickle");
}
