/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 1.0.2
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2000-2008 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

/**
* Handle Firebug calls when Firebug is not available (getfirebug.com)
*/
if (!window.console || !console.firebug)
{
	window.console = {};
	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
	for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
}

if (typeof(vBulletin) == "object" && typeof(vBulletin.register_control) != "function")
{
	vBulletin.init = function()
	{
		this.events.systemInit.fire();
		console.info("System Init Fired");
	}

	vBulletin.register_control = function(controltype, element)
	{
		var args = new Array();
		for (var i = 1; i < arguments.length; i++)
		{
			args.push(arguments[i]);
		}
		if (!this.elements[controltype])
		{
			console.info("Creating array vBulletin.elements[\"%s\"]", controltype);
			this.elements[controltype] = new Array();
		}
		if (controltype == "vB_DatePicker")
		{
			args = new Array();
			args.push(YAHOO.util.Dom.get(arguments[1]));
			args.push(arguments[3] + "," + arguments[2]);
		}
		var x = this.elements[controltype].push(args);
		vBulletin.console("vBulletin.elements[\"%s\"][%d] = %s", controltype, x-1, args.join(", "));
	}
}

if (vB_Popup_Menu)
{
	// apply a new fetch_offset function to deal with issue 22186
	var orig_fetch_offset_func = vB_Popup_Menu.prototype.fetch_offset;
	vB_Popup_Menu.prototype.fetch_offset = function(obj)
	{
		if (obj.getBoundingClientRect)
		{
			// better, more accurate function for IE
			var rect = obj.getBoundingClientRect();

			var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
			var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);

			if (document.documentElement.dir == 'rtl')
			{
				// IE returns a positive scrollLeft, but we need a negative value to actually do proper calculations.
				// This actually flips the scolloing to be relative to the distance scrolled from the default.
				scrollLeft = scrollLeft + document.documentElement.clientWidth - document.documentElement.scrollWidth;
			}

			return { 'left' : rect.left + scrollLeft, 'top' : rect.top + scrollTop };
		}

		return orig_fetch_offset_func(obj);
	}
}

/*======================================================================*\
|| ####################################################################
|| # Downloaded: 15:50, Fri Apr 11th 2008
|| # RCS: $Revision: 17794 $
|| ####################################################################
\*======================================================================*/