/**
* Inferno Mini Profile Hover v1.1.2
* Created By Zer0 T0lerance
* Copyright Inferno Technologies 2008
* All rights reserved
* * * * * * * * * * * * * * * * * * 
*/

_profile_hover = function()
{
	var self = this;

	this.init = function()
	{
		if (typeof(YAHOO) != "undefined")
		{
			YAHOO.util.Event.on(document, "click", self.kill_hover);
		}
		else if (window.attachEvent && !is_saf)
		{
			document.attachEvent('onclick', self.kill_hover);
		}
		else if (document.addEventListener && !is_saf)
		{
			document.addEventListener('click', self.kill_hover, false);
		}
		else
		{
			window.onclick = self.kill_hover;
		}

		this.check_links();
	}

	this.check_links = function()
	{
		links = fetch_tags(document.body, 'a');

		for (var l = 0; l < links.length; l++)
		{
			if ((userid = this.is_member_link(links[l])) !== false)
			{
				this.append_profile_hover(links[l], userid);
			}
		}
	}

	this.is_member_link = function(chklink)
	{
		if (chklink.href.match(/^http:\/\/www\.nextgenboards\.com\/vb\/members\/(\d+)/))
		{
			return RegExp.$1;
		}

		return false;
	}

	this.append_profile_hover = function(link, userid)
	{
		if (!link.onmouseover)
		{
			link.onmouseover = function(){ProfileHover.init_hover(this, userid);}
			link.onmouseout = function(){ProfileHover.clear_hover();}
		}
	}

	this.clear_hover = function()
	{
		clearTimeout(self.request_timer);
	}

	this.kill_hover = function()
	{
		if (fetch_object('inferno_profile_hover'))
		{
			fetch_object('inferno_profile_hover').parentNode.removeChild(fetch_object('inferno_profile_hover'));
		}

		self.active = false;
		self.request_userid = 0;
	}

	this.init_hover = function(link, userid)
	{
		if (self.active && userid == self.request_userid)
		{
			return false;
		}

		this.kill_hover();

		self.request_from = link;
		self.request_userid = userid;
		self.request_timer = setTimeout("ProfileHover.do_hover();", 300);
		self.active = true;
	}

	this.do_hover = function()
	{
		this.ajax = new vB_AJAX_Handler(true);
		this.ajax.onreadystatechange(self.prep_hover);
		this.ajax.send('ajax.php', 'do=memberpop&u=' + this.request_userid);
	}

	this.prep_hover = function()
	{
		if (self.ajax.handler.readyState == 4 && self.ajax.handler.status == 200 && self.ajax.handler.responseText != '')
		{
			self.show_hover(self.ajax.handler.responseText);
		}
	}

	this.show_hover = function(HTML)
	{
		if (!this.active)
		{
			return false;
		}

		offset = vB_Popup_Menu.prototype.fetch_offset(this.request_from);
		div = document.createElement('div');

		div.id = 'inferno_profile_hover';
		div.align = 'left';
		div.innerHTML = HTML;
		div.style.position = 'absolute';
		div.style.top = (offset['top'] + this.request_from.offsetHeight) + 'px';
		div.style.left = offset['left'] + 'px';

		document.body.appendChild(div);

		while (offset['left'] + fetch_object('inferno_profile_hover').offsetWidth >= (document.body.clientWidth))
		{
			offset['left']--;

			fetch_object('inferno_profile_hover').style.left = offset['left'] + 'px'
		}

		return false; // The boing effect is far from ready...

		actualwidth	= fetch_object('inferno_profile_hover').offsetWidth;
		actualheight	= fetch_object('inferno_profile_hover').offsetHeight;

		fetch_object('inferno_profile_hover').style.overflow = 'hidden';
		fetch_object('inferno_profile_hover').style.width = '1px';
		fetch_object('inferno_profile_hover').style.height = '1px';

		fetch_object('inferno_profile_hover').className = 'vbmenu_popup';

		boingw = new _boing('boingw', 'inferno_profile_hover', 1, actualwidth, 'width', '');
		boingh = new _boing('boingh', 'inferno_profile_hover', 1, actualheight, 'height', '');

		boingw.boing();
		boingh.boing();
	}
}

/**
* - - - - - - - - - - - - - -
* Boing Model v0.1
* Created By Zero Tolerance
* Copyright 2008 Inferno Technologies, All Rights Reserved
* * * * * * * * * * * * * *
*/

_boing = function(_callback, _id, _start, _end, _what, _trigger)
{
	var me = this;

	this.callback	= _callback;
	this.id		= _id;
	this.current	= _start;
	this.start	= _start;
	this.end	= _end;
	this.what	= _what;
	this.trigger	= _trigger;
	this.speed	= 20;
	this.retention	= 0;
	this.decay	= 10;

	this.get_object = function()
	{
		return document.getElementById(this.id);
	}

	this.boing = function()
	{
		if (this.start > this.end)
		{
			this.direction = 'down';

			this.boing_down();
		}
		else
		{
			this.direction = 'up';

			this.boing_up();
		}
	}

	this.boing_down = function()
	{
		obj = this.get_object();

		if (this.current < this.end)
		{
			this.retention += 4;
		}
		else if (this.retention > 0)
		{
			this.retention--;
		}

		speed = this.speed - this.retention;

		if (speed == 0)
		{
			this.direction = 'up';
			this.decay += 2;
		}

		this.current = (this.current - speed);

		if (this.decay == 20)
		{
			this.set_style_property(obj, this.what, this.end + 'px');

			eval(this.trigger);

			return false;
		}

		this.set_style_property(obj, this.what, this.current + 'px');

		if (this.direction == 'up')
		{
			setTimeout(this.callback + ".boing_up()", 20 * (this.decay / 10));
		}
		else
		{
			setTimeout(this.callback + ".boing_down()", 20 * (this.decay / 10));
		}
	}

	this.set_style_property = function(obj, what, value)
	{
		eval("obj.style." + what + " = value;");
	}

	this.boing_up = function()
	{
		obj = this.get_object();

		if (this.current > this.end)
		{
			this.retention += 4;
		}
		else if (this.retention > 0)
		{
			this.retention--;
		}

		speed = this.speed - this.retention;

		if (speed == 0)
		{
			this.direction = 'down';
			this.decay += 2;
		}

		this.current = (this.current + speed);

		if (this.decay == 20)
		{
			this.set_style_property(obj, this.what, this.end + 'px');

			eval(this.trigger);

			return false;
		}

		this.set_style_property(obj, this.what, this.current + 'px');

		if (this.direction == 'up')
		{
			setTimeout(this.callback + ".boing_up()", 20 * (this.decay / 10));
		}
		else
		{
			setTimeout(this.callback + ".boing_down()", 20 * (this.decay / 10));
		}
	}
}

ProfileHover = new _profile_hover;
ProfileHover.init();