if (typeof SESSIONURL == 'undefined')
{
	SESSIONURL = '';
}
if (typeof vbphrase == 'undefined')
{
	vbphrase = new Array();
}
var vB_Editor = new Array();
var ignorequotechars = false;
var pagenavcounter = 0;
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac    = (userAgent.indexOf('mac') != -1);
var is_regexp = (window.RegExp) ? true : false;
var AJAX_Compatible = false;
var pointer_cursor = (is_ie ? 'hand' : 'pointer');
function array_pop(a)
{
	if (typeof a != 'object' || !a.length)
	{
		return null;
	}
	else
	{
		var response = a[a.length - 1];
		a.length--;
		return response;
	}
}
function array_push(a, value)
{
	a[a.length] = value;
	return a.length;
}
function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}
function fetch_tags(parentobj, tag)
{
	if (typeof parentobj.getElementsByTagName != 'undefined')
	{
		return parentobj.getElementsByTagName(tag);
	}
	else if (parentobj.all && parentobj.all.tags)
	{
		return parentobj.all.tags(tag);
	}
	else
	{
		return null;
	}
}
function do_an_e(eventobj)
{
	if (!eventobj || is_ie)
	{
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	}
	else
	{
		eventobj.stopPropagation();
		eventobj.preventDefault();
		return eventobj;
	}
}
function e_by_gum(eventobj)
{
	if (!eventobj || is_ie)
	{
		window.event.cancelBubble = true;
		return window.event;
	}
	else
	{
		if (eventobj.target.type == 'submit')
		{
			eventobj.target.form.submit();
		}
		eventobj.stopPropagation();
		return eventobj;
	}
}
function vbmenu_register(controlid, noimage, datefield)
{
	if (typeof vBmenu == 'object')
	{
		vBmenu.register(controlid, noimage);
	}
}
function vBulletin_init()
{
	if (is_webtv)
	{
		return false;
	}
	var imgs = fetch_tags(document, 'img');
	for (var i = 0; i < imgs.length; i++)
	{
		if (!imgs[i].title && imgs[i].alt != '')
		{
			imgs[i].title = imgs[i].alt;
		}
	}
	if (typeof vBmenu == 'object')
	{
		if (window.attachEvent && !is_saf)
		{
			document.attachEvent('onclick', vbmenu_hide);
			window.attachEvent('onresize', vbmenu_hide);
		}
		else if (document.addEventListener && !is_saf)
		{
			document.addEventListener('click', vbmenu_hide, false);
			window.addEventListener('resize', vbmenu_hide, false);
		}
		else
		{
			window.onclick = vbmenu_hide;
			window.onresize = vbmenu_hide;
		}
		var pagenavs = fetch_tags(document, 'td');
		for (var n = 0; n < pagenavs.length; n++)
		{
			if (pagenavs[n].hasChildNodes() && pagenavs[n].firstChild.name && pagenavs[n].firstChild.name.indexOf('PageNav') != -1)
			{
				var addr = pagenavs[n].title;
				pagenavs[n].title = '';
				pagenavs[n].innerHTML = '';
				pagenavs[n].id = 'pagenav.' + n;
				var pn = vBmenu.register(pagenavs[n].id);
				if (is_saf)
				{
					pn.controlobj._onclick = pn.controlobj.onclick;
					pn.controlobj.onclick = vBpagenav.prototype.controlobj_onclick;
				}
			}
		}
		if (typeof addr != 'undefined')
		{
			fetch_object('pagenav_form').addr = addr;
			fetch_object('pagenav_form').gotopage = vBpagenav.prototype.form_gotopage;
			fetch_object('pagenav_ibtn').onclick = vBpagenav.prototype.ibtn_onclick;
			fetch_object('pagenav_itxt').onkeypress = vBpagenav.prototype.itxt_onkeypress;
		}
		vBmenu.activate(true);
	}
	return true;
}

function vB_Popup_Handler()
{
	this.open_steps = 10;
	this.open_fade = false;
	this.active = false;
	this.menus = new Array();
	this.activemenu = null;
	this.hidden_selects = new Array();
}
vB_Popup_Handler.prototype.activate = function(active)
{
	this.active = active;
}
vB_Popup_Handler.prototype.register = function(controlkey, noimage)
{
	this.menus[controlkey] = new vB_Popup_Menu(controlkey, noimage);

	return this.menus[controlkey];
}
vB_Popup_Handler.prototype.hide = function()
{
	document.getElementById("singinid").src="/global-images/nw-sign_in.gif";
	if (this.activemenu != null)
	{
		this.menus[this.activemenu].hide();
	}
}
vBmenu = new vB_Popup_Handler();
function vbmenu_hide(e)
{
	if (e && e.button && e.button != 1 && e.type == 'click')
	{
		return true;
	}
	else
	{
		vBmenu.hide();
	}
}
function vB_Popup_Menu(controlkey, noimage)
{
	this.controlkey = controlkey;
	this.menuname = this.controlkey.split('.')[0] + '_menu';
	this.init_control(noimage);
	if (fetch_object(this.menuname))
	{
		this.init_menu();
	}
	this.slide_open = (is_opera ? false : true);
	this.open_steps = vBmenu.open_steps;
}
vB_Popup_Menu.prototype.init_control = function(noimage)
{
	this.controlobj = fetch_object(this.controlkey);
	this.controlobj.state = false;
	if (this.controlobj.firstChild && (this.controlobj.firstChild.tagName == 'TEXTAREA' || this.controlobj.firstChild.tagName == 'INPUT'))
	{
	}
	else
	{
		if (!noimage && !(is_mac && is_ie))
		{
			var space = document.createTextNode(' ');
			this.controlobj.appendChild(space);
			var img = document.createElement('img');			
		
		}
		this.controlobj.unselectable = true;
		if (!noimage)
		{
			this.controlobj.style.cursor = pointer_cursor;
		}
		this.controlobj.onclick = vB_Popup_Events.prototype.controlobj_onclick;
		this.controlobj.onmouseover = vB_Popup_Events.prototype.controlobj_onmouseover;
		this.controlobj.onmouseout = vB_Popup_Events.prototype.controlobj_onmouseout;
	}
}
vB_Popup_Menu.prototype.init_menu = function()
{
	this.menuobj = fetch_object(this.menuname);
	if (this.menuobj && !this.menuobj.initialized)
	{
		this.menuobj.initialized = true;
		this.menuobj.onclick = e_by_gum;
		this.menuobj.style.position = 'absolute';
		this.menuobj.style.zIndex = 50;
		if (is_ie && !is_mac)
		{
		}
		this.init_menu_contents();
	}
}
vB_Popup_Menu.prototype.init_menu_contents = function()
{
	var tds = fetch_tags(this.menuobj, 'td');
	for (var i = 0; i < tds.length; i++)
	{
		if (tds[i].className == 'vbmenu_option')
		{
			if (tds[i].title && tds[i].title == 'nohilite')
			{
				tds[i].title = '';
			}
			else
			{
				tds[i].controlkey = this.controlkey;
				tds[i].onmouseover = vB_Popup_Events.prototype.menuoption_onmouseover;
				tds[i].onmouseout = vB_Popup_Events.prototype.menuoption_onmouseout;
				if (typeof tds[i].onclick == 'function')
				{
					tds[i].ofunc = tds[i].onclick;
					tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_function;
				}
				else
				{
					tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_link;
				}
				if (!is_saf && !is_kon)
				{
					try
					{
						links = fetch_tags(tds[i], 'a');
						for (var j = 0; j < links.length; j++)
						{
							if (typeof links[j].onclick  == 'undefined')
							{
								links[j].onclick = e_by_gum;
							}
						}
					}
					catch(e)
					{
					}
				}
			}
		}
	}
}
vB_Popup_Menu.prototype.show = function(obj, instant)
{
	if (!vBmenu.active)
	{
		return false;
	}
	else if (!this.menuobj)
	{
		this.init_menu();			
	}
	if (!this.menuobj)
	{	
		return false;
	}
	if (vBmenu.activemenu != null)
	{	
		vBmenu.menus[vBmenu.activemenu].hide();
	}	
	vBmenu.activemenu = this.controlkey;
	this.menuobj.style.display = '';	
	if (vBmenu.slide_open)
	{
		this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';		
	}	
	this.pos = this.fetch_offset(obj);
	this.leftpx = this.pos['left'];
	this.toppx = this.pos['top'] + obj.offsetHeight;	
	if ((this.leftpx + this.menuobj.offsetWidth) >= document.body.clientWidth && (this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth) > 0)
	{
		this.leftpx = this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth;
		this.direction = 'right';
	}
	else
	{
		this.direction = 'left'
	}	
	this.menuobj.style.left = this.leftpx + 'px';
	this.menuobj.style.top  = this.toppx + 'px';
	if (!instant && this.slide_open)
	{
		this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps);
		this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps);
		this.slide((this.direction == 'left' ? 0 : this.menuobj.offsetWidth), 0, 0);
	}
	else if (this.menuobj.style.clip && vBmenu.slide_open)
	{
		this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
	}	
	this.handle_overlaps(true);	
	if (this.controlobj.editorid)
	{
		this.controlobj.state = true;		
		vB_Editor[this.controlobj.editorid].menu_context(this.controlobj, 'mousedown');
	}	
}
vB_Popup_Menu.prototype.hide = function(e)
{
	if (e && e.button && e.button != 1)
	{
		return true;
	}
	this.stop_slide();
	this.menuobj.style.display = 'none';
	this.handle_overlaps(false);
	if (this.controlobj.editorid)
	{
		this.controlobj.state = false;
		vB_Editor[this.controlobj.editorid].menu_context(this.controlobj, 'mouseout');
	}
	vBmenu.activemenu = null;
}
vB_Popup_Menu.prototype.hover = function(obj)
{
	if (vBmenu.activemenu != null)
	{
		if (vBmenu.menus[vBmenu.activemenu].controlkey != this.id)
		{
			this.show(obj, true);
		}
	}
}
vB_Popup_Menu.prototype.choose = function(e, obj)
{
	var links = fetch_tags(obj, 'a');
	if (links[0])
	{
		if (is_ie)
		{
			links[0].click();
			window.event.cancelBubble = true;
		}
		else
		{
			if (e.shiftKey)
			{
				window.open(links[0].href);
				e.stopPropagation();
				e.preventDefault();
			}
			else
			{
				window.location = links[0].href;
				e.stopPropagation();
				e.preventDefault();
			}
		}
		this.hide();
	}
}

vB_Popup_Menu.prototype.slide = function(clipX, clipY, opacity)
{
	if (this.direction == 'left' && (clipX < this.menuobj.offsetWidth || clipY < this.menuobj.offsetHeight))
	{
		if (vBmenu.open_fade && is_ie)
		{
			opacity += 10;
			this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
		}
		clipX += this.intervalX;
		clipY += this.intervalY;
		this.menuobj.style.clip = "rect(auto, " + clipX + "px, " + clipY + "px, auto)";
		this.slidetimer = setTimeout("vBmenu.menus[vBmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
	}
	else if (this.direction == 'right' && (clipX > 0 || clipY < this.menuobj.offsetHeight))
	{
		if (vBmenu.open_fade && is_ie)
		{
			opacity += 10;
			menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
		}
		clipX -= this.intervalX;
		clipY += this.intervalY;
		this.menuobj.style.clip = "rect(auto, " + this.menuobj.offsetWidth + "px, " + clipY + "px, " + clipX + "px)";
		this.slidetimer = setTimeout("vBmenu.menus[vBmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
	}
	else
	{
		this.stop_slide();
	}
}
vB_Popup_Menu.prototype.stop_slide = function()
{
	clearTimeout(this.slidetimer);

	this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';

	if (vBmenu.open_fade && is_ie)
	{
		this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = 100;
	}
}
vB_Popup_Menu.prototype.fetch_offset = function(obj)
{
	var left_offset = obj.offsetLeft;
	var top_offset = obj.offsetTop;
	while ((obj = obj.offsetParent) != null)
	{
		left_offset += obj.offsetLeft;
		top_offset += obj.offsetTop;
	}
	return { 'left' : left_offset, 'top' : top_offset };
}
vB_Popup_Menu.prototype.overlaps = function(obj, m)
{
	var s = new Array();
	var pos = this.fetch_offset(obj);
	s['L'] = pos['left'];
	s['T'] = pos['top'];
	s['R'] = s['L'] + obj.offsetWidth;
	s['B'] = s['T'] + obj.offsetHeight;
	if (s['L'] > m['R'] || s['R'] < m['L'] || s['T'] > m['B'] || s['B'] < m['T'])
	{
		return false;
	}
	return true;
}
vB_Popup_Menu.prototype.handle_overlaps = function(dohide)
{
	if (is_ie)
	{
		var selects = fetch_tags(document, 'select');
		if (dohide)
		{
			var menuarea = new Array(); menuarea = {
				'L' : this.leftpx,
				'R' : this.leftpx + this.menuobj.offsetWidth,
				'T' : this.toppx,
				'B' : this.toppx + this.menuobj.offsetHeight
			};
			for (var i = 0; i < selects.length; i++)
			{
				if (this.overlaps(selects[i], menuarea))
				{
					var hide = true;
					var s = selects[i];
					while (s = s.parentNode)
					{
						if (s.className == 'vbmenu_popup')
						{
							hide = false;
							break;
						}
					}
					if (hide)
					{
						selects[i].style.visibility = 'hidden';
						array_push(vBmenu.hidden_selects, i);
					}
				}
			}
		}
		else
		{
			while (true)
			{
				var i = array_pop(vBmenu.hidden_selects);
				if (typeof i == 'undefined' || i == null)
				{
					break;
				}
				else
				{
					selects[i].style.visibility = 'visible';
				}
			}
		}
	}
}
function vB_Popup_Events()
{
}
vB_Popup_Events.prototype.controlobj_onclick = function(e)
{
	do_an_e(e);
	if (vBmenu.activemenu == null || vBmenu.menus[vBmenu.activemenu].controlkey != this.id)
	{		
		vBmenu.menus[this.id].show(this);
		document.getElementById("singinid").src="/global-images/nw-cbol-pannel_top.gif";
	}
	else
	{
		document.getElementById("singinid").src="/global-images/nw-sign_in.gif";
		vBmenu.menus[this.id].hide();
	}
};
vB_Popup_Events.prototype.controlobj_onmouseover = function(e)
{
	do_an_e(e);	
	vBmenu.menus[this.id].hover(this);

};
vB_Popup_Events.prototype.controlobj_onmouseout = function(e)
{
	if(document.getElementById('threadrating_menu').style.display=="none")
	{

	}
	else
	{
		
	}
};
vB_Popup_Events.prototype.menuoption_onclick_function = function(e)
{
	this.ofunc(e);
	vBmenu.menus[this.controlkey].hide();
};
vB_Popup_Events.prototype.menuoption_onclick_link = function(e)
{
	vBmenu.menus[this.controlkey].choose(e, this);
};
vB_Popup_Events.prototype.menuoption_onmouseover = function(e)
{
	this.className = 'vbmenu_hilite';
};
vB_Popup_Events.prototype.menuoption_onmouseout = function(e)
{
	this.className = 'vbmenu_option';	
};