function lib_isIE5() {
	var nver = navigator.appVersion;
	var npos = nver.indexOf("MSIE");
	if (npos == -1) return false;
	var nvno = parseInt(nver.charAt(npos + 5));
	if (nvno < 5) return false;
	return true;
}
	var isIE5 = lib_isIE5();

function lib_obj(obj) {
	this.evnt = document.getElementById(obj);
	this.css = this.evnt.style;
	this.ref = document;
	this.x = parseInt(this.css.left) || this.css.pixelLeft || this.evnt.offsetLeft || 0;
	this.y = parseInt(this.css.top) || this.css.pixelTop || this.evnt.offsetTop || 0;
	this.w = this.evnt.offsetWidth || this.css.clip.width || this.ref.width || this.css.pixelWidth || 0;
	this.h = this.evnt.offsetHeight || this.css.clip.height || this.ref.height || this.css.pixelHeight || 0;
	this.c = 0;
	if (this.css.clip) {
		this.c = this.css.clip;
		this.c = this.c.slice(5, this.c.length - 1);
		this.c = this.c.split(' ');
		for (var i=0; i<4; i++) {
			this.c[i] = parseInt(this.c[i]);
		}
	}
	this.ct = this.css.clip.top || this.c[0] || 0;
	this.cr = this.css.clip.right || this.c[1] || this.w || 0;
	this.cb = this.css.clip.bottom || this.c[2] || this.h || 0;
	this.cl = this.css.clip.left || this.c[3] || 0;
	this.obj = obj + "Object";
	eval(this.obj + "=this");
	return this;
}

lib_obj.prototype.moveIt = function(x, y) {
	this.x = x;
	this.y = y;
	this.css.left = x;
	this.css.top = y;
}

lib_obj.prototype.moveBy = function(x, y) {
	this.css.left = this.x += x;
	this.css.top = this.y += y;
}

lib_obj.prototype.showIt = function() {
	this.css.visibility = "visible";
}

lib_obj.prototype.hideIt = function() {
	this.css.visibility = "hidden";
}

lib_obj.prototype.bg = function(color) {
	this.css.backgroundColor = color;
}

lib_obj.prototype.writeIt = function(text) {
	this.evnt.innerHTML = text;
}

lib_obj.prototype.clipTo = function(t, r, b, l, setwidth) {
	this.ct = t;
	this.cr = r;
	this.cb = b;
	this.cl = l;
	if (t < 0) t = 0;
	if (r < 0) r = 0;
	if (b < 0) b = 0;
	if (l < 0) l = 0;
	this.css.clip = "rect(" + t + "," + r + "," + b + "," + l + ")";
	if (setwidth) {
		this.css.pixelWidth = this.css.width = r;
		this.css.pixelHeight = this.css.height = b;
	}
}

lib_obj.prototype.clipBy = function(t, r, b, l, setwidth) {
	this.clipTo(this.ct + t, this.cr + r, this.cb + b, this.cl + l, setwidth);
}

lib_obj.prototype.clipIt = function(t, r, b, l, step, fn, wh) {
	var tstep = Math.max(Math.max(Math.abs((t - this.ct) / step), Math.abs((r - this.cr) / step)), Math.max(Math.abs((b - this.cb) / step), Math.abs((l - this.cl) / step)));
	if (!this.clipactive) {
		this.clipactive = true;
		if (!wh) wh = 0;
		if (!fn) fn = 0;
		this.clip(t, r, b, l, (t - this.ct) / tstep, (r - this.cr) / tstep, (b - this.cb) / tstep, (l - this.cl) / tstep, tstep, 0, fn, wh);
	}
}

lib_obj.prototype.clip = function(t, r, b, l, ts, rs, bs, ls, tstep, astep, fn, wh) {
	if (astep < tstep) {
		if (wh) eval(wh);
		astep++;
		this.clipBy(ts, rs, bs, ls, 1);
		setTimeout(this.obj + ".clip(" + t + "," + r + "," + b + "," + l + "," + ts + "," + rs + "," + bs + "," + ls + "," + tstep + "," + astep + ",'" + fn + "','" + wh + "')", 50);
	} else {
		this.clipactive = false;
		this.clipTo(t, r, b, l, 1);
		if (fn) eval(fn);
	}
}

lib_obj.prototype.slideIt = function(endx, endy, inc, speed, fn, wh) {
	if (!this.slideactive) {
		var distx = endx - this.x;
		var disty = endy - this.y;
		var num = Math.sqrt(Math.pow(distx, 2) + Math.pow(disty, 2)) / inc;
		var dx = distx / num;
		var dy = disty / num;
		this.slideactive = 1;
		if (!wh) wh = 0;
		if (!fn) fn = 0;
		this.slide(dx, dy, endx, endy, speed, fn, wh);
	}
}

lib_obj.prototype.slide = function(dx, dy, endx, endy, speed, fn, wh) {
	if (this.slideactive && (Math.floor(Math.abs(dx)) < Math.floor(Math.abs(endx - this.x)) || Math.floor(Math.abs(dy)) < Math.floor(Math.abs(endy - this.y)))) {
		this.moveBy(dx, dy);
		if (wh) eval(wh);
		setTimeout(this.obj + ".slide(" + dx + "," + dy + "," + endx + "," + endy + "," + speed + ",'" + fn + "','" + wh + "')", speed);
	} else {
		this.slideactive = 0;
		this.moveIt(endx, endy);
		if (fn) eval(fn);
	}
}

lib_obj.prototype.circleIt = function(rad, ainc, a, enda, xc, yc, speed, fn) {
	if (Math.abs(ainc) < Math.abs(enda - a)) {
		a += ainc;
		var x = xc + rad * Math.cos(a * Math.PI / 180);
		var y = yc - rad * Math.sin(a * Math.PI / 180);
		this.moveIt(x, y);
		setTimeout(this.obj + ".circleIt(" + rad + "," + ainc + "," + a + "," + enda + "," + xc + "," + yc + "," + speed + ",'" + fn + "')", speed);
	} else if (fn && fn != "undefined") eval(fn);
}

function lib_doc_size() {
	this.x2 = parseInt(document.body.clientWidth);
	this.y2 = parseInt(document.body.clientHeight);
	this.x50 = parseInt(this.x2 / 2);
	this.y50 = parseInt(this.y2 / 2);
	return this;
}

	var dd_is_active = 0;
	var dd_obj = 0;
	var dd_mobj = 0;

function lib_dd() {
	dd_is_active = 1;
	document.onmousemove = lib_dd_move;
	document.onmousedown = lib_dd_down;
	document.onmouseup = lib_dd_up;
}

lib_obj.prototype.dragdrop = function(obj) {
	if (!dd_is_active) lib_dd();
	this.evnt.onmouseover = new Function("lib_dd_over(" + this.obj + ")");
	this.evnt.onmouseout = new Function("dd_mobj = 0");
	if (obj) this.ddobj = obj;
}

lib_obj.prototype.nodragdrop = function() {
	this.evnt.onmouseover = "";
	this.evnt.onmouseout = "";
	dd_obj = 0;
	dd_mobj = 0;
}

function lib_dd_over(obj) {
	dd_mobj = obj;
}

function lib_dd_up(e) {
	dd_obj = 0;
}

function lib_dd_down(e) {
	if (dd_mobj) {
		x = event.x || event.clientX;
		y = event.y || event.clientY;
		dd_obj = dd_mobj;
		dd_obj.clX = x - dd_obj.x;
		dd_obj.clY = y - dd_obj.y;
	}
}

function lib_dd_move(e, y, rresize) {
	x = event.x || event.clientX;
	y = event.y || event.clientY;
	if (dd_obj) {
		nx = x - dd_obj.clX;
		ny = y - dd_obj.clY;
		if (dd_obj.ddobj) {
			dd_obj.ddobj.moveIt(nx, ny);
		} else {
			dd_obj.moveIt(nx, ny);
		}
	}
	return false;
}

