
function debug(obj) {
	var flasher = document.createElement('div');
	document.getElementsByTagName('body')[0].appendChild(flasher);

	flasher.style.display = 'block';
	flasher.style.top = '0';
	flasher.style.left = '0';
	flasher.style.position = 'absolute';
	flasher.style.background = '#fff';
	flasher.style.color = '#000';
	flasher.style.border = '1px solid #c00';
	flasher.style.width = '800px';

	for (var prop in obj) {
		flasher.appendChild(document.createTextNode(prop));
		flasher.appendChild(document.createElement('br'));
	}
}

/**
 * add Event Listener
 */
function addEvent(eventtype, callfunction) {
	if (window.addEventListener) {
		window.addEventListener(eventType, callfunction, false);
		return true;
	} else if (window.attachEvent) {
		var returnvalue = window.attachEvent("on" + eventType, callfunction);
		return returnvalue;
	} else {
		return false;
	}
}

/**
 * Redirect to URL
 */
function redirect(url) {
	if (url)
		document.location = url;
	return false;
}



/**
 * ToolTip stuff
 *
 * @link http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/
 */
var tooltip = function() {
	var id = 'tooltipbox';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 8;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return {
		show:function(v, w) {
			if (tt == null) {
				tt= document.createElement('div');
				t = document.createElement('div');
				c = document.createElement('div');
				b = document.createElement('div');
				tt.setAttribute('id', id);
				t.setAttribute('id', id + '-top');
				c.setAttribute('id', id + '-content');
				b.setAttribute('id', id + '-bottom');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity	= 0;
				tt.style.filter		= 'alpha(opacity=0)';
				document.onmousemove= this.pos;
			}

			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';

			if (!w && ie) {
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if (tt.offsetWidth > maxw) {
				tt.style.width = maxw + 'px';
			}

			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function() { tooltip.fade(1); }, timer);
		},
		pos:function(e) {
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d) {
			var a = alpha;
			if ((a != endalpha && d == 1) || (a != 0 && d == -1)) {
				var i = speed;
				if (endalpha - a < speed && d == 1) {
					i = endalpha - a;
				}else if (alpha < speed && d == -1) {
					i = a;
				}

				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			} else {
				clearInterval(tt.timer);
				if(d == -1) {
					tt.style.display = 'none';
				}
			}
		},
		hide:function() {
			clearInterval(tt.timer);
			tt.timer = setInterval(function() { tooltip.fade(-1); }, timer);
		}
	};
}();
