var lm = {
	cx: 0,
	cy: 0,
	X: 0,
	Y: 0,
	CX: 0,
	CY: 0,
	FO: 7, // FOCO
	RS: .04, // VELOCIDADE
	RC: 1,
	
	/** evento no movimento do mouse */
	mousemove: function(e) {
		if (window.event) {
			e = window.event;
		}
		lm.xm = (e.x || e.clientX) - lm.nx + (lm.nw * .5);
		lm.ym = (e.y || e.clientY) - lm.ny + (lm.nh * .5);
	},
	
	/** evento que redimensiona a tela */
	resize: function() {
		lm.nx = pxLeft(lm.scr);
		lm.ny = pxTop(lm.scr);
		lm.nw = lm.scr.offsetWidth;
		lm.nh = lm.scr.offsetHeight;
	},
	
	/** loop principal */
	run: function() {
		lm.cx += (lm.xm - lm.cx) * (lm.RS * 2 * lm.RC);
		lm.cy += (lm.ym - lm.cy) * (lm.RS * 2 * lm.RC);
		lm.CX += (lm.X - lm.CX) * (lm.RS * lm.RC);
		lm.CY += (lm.Y - lm.CY) * (lm.RS * lm.RC);
		/** movimento da tela */
		for (var i = 0; i < lm.N; i++) {
			var o = lm.spa[i];
			o.style.left = px(o.m + lm.nw * .5 + (o.X - lm.cx * .5 - lm.CX) * o.d);
			o.style.top = px(o.m + lm.nh * .5 + (o.Y - lm.cy * .5 - lm.CY) * o.d);
		}
		setTimeout(lm.run, 16);
		
	},
	/** inicia */
	start: function(container) {
		this.scr = id(container);
		this.ref = {};
		this.spa = [];
		var k = 0;
		var r = this.scr.childNodes;
		for (var i = 0, n = r.length; i < n; i++) {
			var o = r[i];
			if (o.id) {
				var X = o.offsetLeft;
				var Y = o.offsetTop;
				this.ref[o.id] = {};
				this.ref[o.id].X = X;
				this.ref[o.id].Y = Y;
				this.ref[o.id].W = o.offsetWidth;
				this.ref[o.id].H = o.offsetHeight;
				o.style.position = 'static';
				var c = o.getElementsByTagName('*');
				for (var j = 0, m = c.length; j < m; j++) {
					if (c[j].className.indexOf('lm') >= 0) {
						var s = this.spa[k] = c[j];
						s.Z = s.style.zIndex;
						s.d = Math.min(lm.FO, lm.FO / (lm.FO + 1 - s.Z));
						s.X = X + s.offsetLeft;
						s.Y = Y + s.offsetTop;
						s.W = s.offsetWidth * ((!s.style.width || s.style.width.indexOf('px') > 0) ? 1 : s.d);
						s.H = s.offsetHeight * ((!s.style.height || s.style.width.indexOf('px') > 0) ? 1 : s.d);
						s.style.width = px(s.W);
						s.style.height = px(s.H);
						
						/** links */
						if (s.onclick) {
							s.style.cursor = 'pointer';
							s.style.zIndex = 100;
							s.onmouseover = function() {
								this.m = 2;
								lm.RC = .5;
							}
							s.onmouveout = function() {
								this.m = 0;
								lm.RC = 1;
							}
						}
						/** navegação */
						s.goto = function(o, ret) {
							lm.RC = 1;
							if (!ret) {
								id(o).O = this.oid; 
							}
							id(o).style.visibility = 'visible';
							lm.X = lm.ref[o].X - .5 * (lm.nw - lm.ref[o].W);
							lm.Y = lm.ref[o].Y - .5 * (lm.nh - lm.ref[o].H);
						}
						s.ret = function() {
							this.goto(this.p.O, true);
						}
						s.hide = function() {
							setTimeout('id("' + this.oid + '").style.visibility = "hidden";', 500);
						}
						s.oid = o.id;
						s.p = o;
						s.m = 0;
						k++;
					}
				} // fim do for (var j = 0, m = c.length; j < m; j++)
			}
		} // fim do for (var i = 0; n = r.length; i < n; i++)
		this.N = this.spa.length;
		/** aciona eventos do mouse */
		addEvent(window, 'resize', this.resize);
		addEvent(window.document, 'mousemove', this.mousemove);
		/** inicia */
		this.resize();
		this.xm = this.nw;
		this.ym = this.nh;
		this.scr.style.visibility = 'visible';
		this.run();
	}
}
onload = function startFuncoes() {
	setTimeout("lm.start('geral')", 500);
}