/*
	Document dimensions.
*/
// page width and height
document.getWidth= function() {
	return document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth;
}

document.getHeight= function() {
	return document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight
}

// offset left and top
document.getOffsetLeft = function() {
	return self.pageXOffset || document.body.scrollleft || document.documentElement.scrollLeft;
}

document.getOffsetTop = function() {
	return self.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
}

// get/set cookies
document.setCookie = function(name, value, expiry) {
	document.cookie = name + "=" + escape(value) + (expiry ? "; expires=" + expiry : "");
}

document.getCookie = function (name) {
	if (document.cookie.length > 0) {
		var s = document.cookie.indexOf(name + "=")
		if (s != -1) {
			s += name.length + 1
			var e = document.cookie.indexOf(";", s)
			if (e == -1)
				e = document.cookie.length;
			return unescape(document.cookie.substring(s, e));
		}
	}
	return "";
}

// Define document.getElementById for Internet Explorer 4. 
if (!document.getElementById) {
	document.getElementById = function (id) { 
		// Just return the corresponding index of all. 
		return document.all[id];
	};
}

// Internet Exploere/Safari compatibility
if (!document.getSelection) {
	document.getSelection = function() {
		return window.getSelection ?
			window.getSelection() :
			document.selection.createRange().text;
	};
}

// Ensure that document.body exists.
if (!document.body && window.attachEvent) {
    window.attachEvent("onload", function() {
    	if (document.body)
    		return;
        document.body = document.getElementsByTagName("body")[0];
    });
}