Page = function() {
	if (!this.hasSupport()) return;
	this.menu = new Navigation("primary-navigation");
	this.collapsers = new Collapsers();	
}

Page.prototype.destroy = function() {
	if(!this.hasSupport()) return;
	this.menu.destroy();
	if(this.collapsers) this.collapsers.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; 
	}
}


// Dynamic classname handling for objects
addClass = function(obj, cName) { 
	if (obj) {
		removeClass(obj,cName); 
		return obj.className += (obj.className.length > 0 ? " " : "") + cName; 
	}
}
removeClass = function(obj, cName) {
	if (obj) {
		return obj.className = obj.className.replace(new RegExp("^" + cName+"\\b\\s*|\\s*\\b" + cName+"\\b",'g'),''); 
	}
}

// Function to fetch objects by classname
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" : "");
}

getCookie = function(name){
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

// Functions to calculate the position of objects
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 the browser to display correctly
tickle = function(){
	addClass(document.getElementsByTagName("body")[0], "tickle");
}

// Function to add event listeners
addEvent = function(obj, evType, fn, ieonly) { 
	if (obj.addEventListener && !ieonly){ /* Mozilla & others */
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ /* IE */
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}
