//------------------------------------------
// Invision Power Board v2.0
// Global JS File
// (c) 2003 Invision Power Services, Inc.
//
// http://www.invisionboard.com
//------------------------------------------

//==========================================
// Set up
//==========================================

var input_red      = 'input-warn';
var input_green    = 'input-ok';
var input_ok_box   = 'input-ok-content';
var input_warn_box = 'input-warn-content';

var img_blank      = 'blank.gif';
var img_tick       = 'aff_tick.gif';
var img_cross      = 'aff_cross.gif';

// Sniffer based on http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var uagent    = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var is_opera  = (uagent.indexOf('opera') != -1);
var is_webtv  = (uagent.indexOf('webtv') != -1);
var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_moz    = ( (navigator.product == 'Gecko')  && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_kon    = (uagent.indexOf('konqueror') != -1);

var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers   = parseInt(navigator.appVersion);

var ipb_pages_shown = 0;
var ipb_pages_array = new Array();

/*-------------------------------------------------------------------------*/
// DST Auto correction
/*-------------------------------------------------------------------------*/

function global_dst_check( tzo, dst )
{
	var thisoffset = tzo + dst;
	var dstoffset  = new Date().getTimezoneOffset() / 60;
	var dstset     = 0;
	var url        = ipb_var_base_url + 'act=xmlout&do=dst-autocorrection&md5check=' + ipb_md5_check;
	
	if ( Math.abs( thisoffset + dstoffset ) == 1 )
	{
		try
		{
			//----------------------------------
			// Fancy first...
			//----------------------------------
			
			xml_dst_set( url + '&xml=1' );
			dstset = 1;
		}
		catch(e)
		{
			dstset = 0;
		}
		
		//----------------------------------
		// No fancy?
		//----------------------------------
		
		if ( dstset == 0 )
		{
			window.location = url;
		}
	}
}

/*-------------------------------------------------------------------------*/
// Get cookie
/*-------------------------------------------------------------------------*/

function my_getcookie( name )
{
	cname = ipb_var_cookieid + name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

/*-------------------------------------------------------------------------*/
// Set cookie
/*-------------------------------------------------------------------------*/

function my_setcookie( name, value, sticky )
{
	expire = "";
	domain = "";
	path   = "/";
	
	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}
	
	if ( ipb_var_cookie_domain != "" )
	{
		domain = '; domain=' + ipb_var_cookie_domain;
	}
	
	if ( ipb_var_cookie_path != "" )
	{
		path = ipb_var_cookie_path;
	}
	
	document.cookie = ipb_var_cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';
}

/*-------------------------------------------------------------------------*/
// Lang replace
/*-------------------------------------------------------------------------*/

function lang_build_string()
{
	if ( ! arguments.length || ! arguments )
	{
		return;
	}
	
	var string = arguments[0];
	
	for( var i = 1 ; i < arguments.length ; i++ )
	{
		var match  = new RegExp('<%' + i + '>', 'gi');
		string = string.replace( match, arguments[i] );
	}
	
	return string;
}

/*-------------------------------------------------------------------------*/
// Pop up MyAssistant window
/*-------------------------------------------------------------------------*/

function buddy_pop()
{
	var not_loaded_yet = 0;
	
	if ( use_enhanced_js )
	{
		try
		{
			xml_myassistant_init();
			not_loaded_yet = 1;
		}
		catch( e )
		{
			//alert(e);
			not_loaded_yet = 0;
		}
	}
	
	if ( ! not_loaded_yet )
	{
		ipb_var_base_url = ipb_var_base_url.replace( '&amp;', '&' );
		window.open( ipb_var_base_url + 'act=buddy','BrowserBuddy','width=250,height=500,resizable=yes,scrollbars=yes');
	}
}

/*-------------------------------------------------------------------------*/
// Multi Page jumps
/*-------------------------------------------------------------------------*/

function do_multi_page_jump( pages_id )
{
	var pages       = 1;
	var cur_st      = ipb_var_st;
	var cur_page    = 1;
	var total_posts = ipb_pages_array[ pages_id ][2];
	var per_page    = ipb_pages_array[ pages_id ][1];
	var url_bit     = ipb_pages_array[ pages_id ][0];
	var userPage    = parseInt( document.getElementById( 'st-'+pages_id ).value );
	
	//-----------------------------------
	// Fix up URL BIT
	//-----------------------------------
	
	url_bit = url_bit.replace( new RegExp( "&amp;", "g" ) , '&' );
	
	//-----------------------------------
	// Work out pages
	//-----------------------------------
	
	if ( total_posts % per_page == 0 )
	{
		pages = total_posts / per_page;
	}
	else
	{
		pages = Math.ceil( total_posts / per_page );
	}
	
	if ( cur_st > 0 )
	{
		cur_page = cur_st / per_page; cur_page = cur_page -1;
	}

	if ( userPage > 0  )
	{
		if ( userPage < 1 )     {    userPage = 1;  }
		if ( userPage > pages ) { userPage = pages; }
		if ( userPage == 1 )    {     start = 0;    }
		else { start = (userPage - 1) * per_page; }
		
		window.location = url_bit + "&st=" + start;
		return false;
	}
}

/*-------------------------------------------------------------------------*/
// Hide / Unhide menu elements
/*-------------------------------------------------------------------------*/

function pages_st_focus( pages_id )
{
	document.getElementById( 'st-'+pages_id ).focus();
}

/*-------------------------------------------------------------------------*/
// Hide / Unhide menu elements
/*-------------------------------------------------------------------------*/

function ShowHide(id1, id2)
{
	if (id1 != '') toggleview(id1);
	if (id2 != '') toggleview(id2);
}
	
/*-------------------------------------------------------------------------*/
// Get element by id
/*-------------------------------------------------------------------------*/

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}

/*-------------------------------------------------------------------------*/
// Show/hide toggle
/*-------------------------------------------------------------------------*/

function toggleview(id)
{
	if ( ! id ) return;
	
	if ( itm = my_getbyid(id) )
	{
		if (itm.style.display == "none")
		{
			my_show_div(itm);
		}
		else
		{
			my_hide_div(itm);
		}
	}
}

/*-------------------------------------------------------------------------*/
// Set DIV ID to hide
/*-------------------------------------------------------------------------*/

function my_hide_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}

/*-------------------------------------------------------------------------*/
// Set DIV ID to show
/*-------------------------------------------------------------------------*/

function my_show_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "";
}

/*-------------------------------------------------------------------------*/
// Change cell colour
/*-------------------------------------------------------------------------*/

function change_cell_color( id, cl )
{
	itm = my_getbyid(id);
	
	if ( itm )
	{
		itm.className = cl;
	}
}

/*-------------------------------------------------------------------------*/
// Toggle category
/*-------------------------------------------------------------------------*/

function togglecategory( fid, add )
{
	saved = new Array();
	clean = new Array();

	//-----------------------------------
	// Get any saved info
	//-----------------------------------
	
	if ( tmp = my_getcookie('collapseprefs') )
	{
		saved = tmp.split(",");
	}
	
	//-----------------------------------
	// Remove bit if exists
	//-----------------------------------
	
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != fid && saved[i] != "" )
		{
			clean[clean.length] = saved[i];
		}
	}
	
	//-----------------------------------
	// Add?
	//-----------------------------------
	
	if ( add )
	{
		clean[ clean.length ] = fid;
		my_show_div( my_getbyid( 'fc_'+fid  ) );
		my_hide_div( my_getbyid( 'fo_'+fid  ) );
	}
	else
	{
		my_show_div( my_getbyid( 'fo_'+fid  ) );
		my_hide_div( my_getbyid( 'fc_'+fid  ) );
	}
	
	my_setcookie( 'collapseprefs', clean.join(','), 1 );
}

/*-------------------------------------------------------------------------*/
// locationjump
/*-------------------------------------------------------------------------*/

function locationjump(url)
{
	window.location = ipb_var_base_url + url;
}

/*-------------------------------------------------------------------------*/
// CHOOSE SKIN
/*-------------------------------------------------------------------------*/

function chooseskin(obj)
{
	choosebox = obj.options[obj.selectedIndex].value;
	extravars = '';
	
	if ( choosebox != -1 && ! isNaN( choosebox ) )
	{
		if ( document.skinselectorbox.skinurlbits.value )
		{
			extravars = '&' + document.skinselectorbox.skinurlbits.value;
			
			//----------------------------------
			// Strip out old skin change stuff
			// setskin=1&skinid=2
			//----------------------------------
			
			extravars = extravars.replace( /setskin=\d{1,}/g, ''  );
			extravars = extravars.replace( /skinid=\d{1,}/g , ''  );
			extravars = extravars.replace( /&{1,}/g         , '&' );
			extravars = extravars.replace( /s=&/g           , ''  );
		}
		
		locationjump( 'setskin=1&skinid=' + choosebox + extravars );
	}
}

/*-------------------------------------------------------------------------*/
// CHOOSE LANG
/*-------------------------------------------------------------------------*/

function chooselang(obj)
{
	choosebox = obj.options[obj.selectedIndex].value;
	extravars = '';
	
	if ( document.langselectorbox.langurlbits.value )
	{
		extravars = '&' + document.langselectorbox.langurlbits.value;

		//----------------------------------
		// Strip out old skin change stuff
		// setskin=1&skinid=2
		//----------------------------------
			
		extravars = extravars.replace( /setlanguage=\d{1,}/g, ''  );
		extravars = extravars.replace( /cal_id=&/g, ''  );
		extravars = extravars.replace( /langid=\w{1,}/g , ''  );
		extravars = extravars.replace( /&{1,}/g         , '&' );
		extravars = extravars.replace( /s=&/g           , ''  );
	}
	
	locationjump( 'setlanguage=1&langid=' + choosebox + extravars );
}

/*-------------------------------------------------------------------------*/
// pop up window
/*-------------------------------------------------------------------------*/

function PopUp(url, name, width,height,center,resize,scroll,posleft,postop)
{
	showx = "";
	showy = "";
	
	if (posleft != 0) { X = posleft }
	if (postop  != 0) { Y = postop  }
	
	if (!scroll) { scroll = 1 }
	if (!resize) { resize = 1 }
	
	if ((parseInt (navigator.appVersion) >= 4 ) && (center))
	{
		X = (screen.width  - width ) / 2;
		Y = (screen.height - height) / 2;
	}
	
	if ( X > 0 )
	{
		showx = ',left='+X;
	}
	
	if ( Y > 0 )
	{
		showy = ',top='+Y;
	}
	
	if (scroll != 0) { scroll = 1 }
	
	var Win = window.open( url, name, 'width='+width+',height='+height+ showx + showy + ',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}

/*-------------------------------------------------------------------------*/
// Array: Get stack size
/*-------------------------------------------------------------------------*/

function stacksize(thearray)
{
	for (i = 0 ; i < thearray.length; i++ )
	{
		if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') )
		{
			return i;
		}
	}
	
	return thearray.length;
}

/*-------------------------------------------------------------------------*/
// Array: Push stack
/*-------------------------------------------------------------------------*/

function pushstack(thearray, newval)
{
	arraysize = stacksize(thearray);
	thearray[arraysize] = newval;
}

/*-------------------------------------------------------------------------*/
// Array: Pop stack
/*-------------------------------------------------------------------------*/

function popstack(thearray)
{
	arraysize = stacksize(thearray);
	theval = thearray[arraysize - 1];
	delete thearray[arraysize - 1];
	return theval;
}

/*-------------------------------------------------------------------------*/
// Converts "safe" innerHTML back to normal template
/*-------------------------------------------------------------------------*/

function innerhtml_template_to_html( t )
{
	t = t.replace( /&lt;%(\d+?)&gt;/ig, "<%$1>" );
	t = t.replace( /%3C%(\d+?)%3E/ig  , "<%$1>" );
	return t;
}

/*-------------------------------------------------------------------------*/
// Global freeze events
/*-------------------------------------------------------------------------*/

function global_cancel_bubble(obj, extra)
{
	if ( ! obj || is_ie)
	{
		if ( extra )
		{
			window.event.returnValue = false;
		}
		
		window.event.cancelBubble = true;
		
		return window.event;
	}
	else
	{
		obj.stopPropagation();
		
		if ( extra )
		{
			obj.preventDefault();
		}
		
		return obj;
	}
}

/*-------------------------------------------------------------------------*/
// Get left posititon of object
/*-------------------------------------------------------------------------*/

function _get_obj_leftpos(obj)
{
	var left = obj.offsetLeft;
	
	while( (obj = obj.offsetParent) != null )
	{
		left += obj.offsetLeft;
	}
	
	return left;
}

/*-------------------------------------------------------------------------*/
// Get top position of object
/*-------------------------------------------------------------------------*/

function _get_obj_toppos(obj)
{
	var top = obj.offsetTop;
	
	while( (obj = obj.offsetParent) != null )
	{
		top += obj.offsetTop;
	}
	
	return top;
}

/*-------------------------------------------------------------------------*/
// Center a div on the screen
/*-------------------------------------------------------------------------*/

function center_div()
{
	this.divname = '';
	this.divobj  = '';
}

/*-------------------------------------------------------------------------*/
// Main run function
/*-------------------------------------------------------------------------*/

center_div.prototype.move_div = function()
{
	try
	{
		this.divobj = document.getElementById( this.divname );
	}
	catch(e)
	{
		return;
	}
	
	//----------------------------------
	// Figure width and height
	//----------------------------------
	
	var my_width  = 0;
	var my_height = 0;
	
	if ( typeof( window.innerWidth ) == 'number' )
	{
		//----------------------------------
		// Non IE
		//----------------------------------
	  
		my_width  = window.innerWidth;
		my_height = window.innerHeight;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//----------------------------------
		// IE 6+
		//----------------------------------
		
		my_width  = document.documentElement.clientWidth;
		my_height = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//----------------------------------
		// Old IE
		//----------------------------------
		
		my_width  = document.body.clientWidth;
		my_height = document.body.clientHeight;
	}
	
	//----------------------------------
	// Show...
	//----------------------------------
	
	this.divobj.style.position = 'absolute';
	this.divobj.style.display  = 'block';
	this.divobj.style.zIndex   = 99;
	
	//----------------------------------
	// Get div height && width
	//----------------------------------
	
	var divheight = parseInt( this.divobj.style.Height );
	var divwidth  = parseInt( this.divobj.style.Width );
	
	divheight = divheight ? divheight : 200;
	divwidth  = divwidth  ? divwidth  : 400;
	
	//----------------------------------
	// Get current scroll offset
	//----------------------------------
	
	var scrolly = this.getYscroll();
	
	//----------------------------------
	// Finalize...
	//----------------------------------
	
	var setX = ( my_width  - divwidth  ) / 2;
	var setY = ( my_height - divheight ) / 2 + scrolly;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	
	this.divobj.style.left = setX + "px";
	this.divobj.style.top  = setY + "px";
}

/*-------------------------------------------------------------------------*/
// Hide div
/*-------------------------------------------------------------------------*/

center_div.prototype.hide_div = function()
{
	try
	{
		if ( ! this.divobj )
		{
			return;
		}
		else
		{
			this.divobj.style.display  = 'none';
		}
	}
	catch(e)
	{
		return;
	}
}

/*-------------------------------------------------------------------------*/
// Get YScroll
/*-------------------------------------------------------------------------*/

center_div.prototype.getYscroll = function()
{
	var scrollY = 0;
	
	if ( document.documentElement && document.documentElement.scrollTop )
	{
		scrollY = document.documentElement.scrollTop;
	}
	else if ( document.body && document.body.scrollTop )
	{
		scrollY = document.body.scrollTop;
	}
	else if ( window.pageYOffset )
	{
		scrollY = window.pageYOffset;
	}
	else if ( window.scrollY )
	{
		scrollY = window.scrollY;
	}
	
	return scrollY;
}





/*-------------------------------------------------------------------------*/
// IPS BASIC MENU CLASS
// (c) 2005 Invision Power Services, Inc
// ASSUMES "ips_global.js" has been loaded
/*-------------------------------------------------------------------------*/

var menu_registered = new Array();
var menu_openfuncs  = new Array();
var menu_built      = new Array();
var menu_open_menus = new Hash();
var menu_cur_open   = false;

/*-------------------------------------------------------------------------*/
// menu_do_global_init: Initiate all registered menus in HTML
/*-------------------------------------------------------------------------*/

function menu_do_global_init()
{
	if ( menu_registered.length > 0 )
	{
		for( var i=0;i<menu_registered.length;i++ )
		{
			menu_init( menu_registered[i] );
		}
		
		//----------------------------------
		// Close all menus on click
		//----------------------------------
		
		document.onclick = menu_action_close;
	}
}

/*-------------------------------------------------------------------------*/
// menu_init: Initiate a single menu
/*-------------------------------------------------------------------------*/

function menu_init(cid)
{
	var mid  = _menu_get_base_name(cid) + "_menu";
	var mobj = my_getbyid(mid);

	if ( document.getElementsByTagName && mobj )
	{
		//----------------------------------
		// Control object (link / img, etc)
		//----------------------------------
		
		var cobj = my_getbyid(cid);
		
		// Change cursor to show link
		try
		{
			cobj.style.cursor = "pointer";
		}
		catch(e)
		{
			cobj.style.cursor = "hand";
		}
	
		cobj.unselectable = true;
		cobj.onclick      = _event_menu_click;
		cobj.onmouseover  = _event_menu_mouseover;
		
		//----------------------------------
		// Save CPU - already init?
		//----------------------------------
		
		if ( typeof( menu_built[mid]) != "undefined" )
		{
			return;
		}
		
		//----------------------------------
		// Pop-up menu obj (hidden div)
		//----------------------------------
		
		var pobj = my_getbyid(mid);
		
		// Set up style defaults
		pobj.style.display  = "none";
		pobj.style.position = "absolute";
		pobj.style.left     = "0px";
		pobj.style.top      = "0px";
		pobj.onclick        = _cancel_bubble;
		pobj.zIndex         = 1000;
		
		menu_built[mid] = true;
	}
}

/*-------------------------------------------------------------------------*/
// Register menu control ID (add to array)
/*-------------------------------------------------------------------------*/

function menu_register(cid, callback)
{
	if ( document.getElementsByTagName )
	{
		var cobj = my_getbyid(cid);
		
		if (cobj)
		{			
			menu_registered[menu_registered.length] = cid;
			
			if ( callback )
			{
				menu_openfuncs[ cobj ] = callback;
			}
			
			return true;
		}
	}
	
	return false;
}

/*-------------------------------------------------------------------------*/
// ACTION: If registered control ID clicked, open menu
/*-------------------------------------------------------------------------*/

function menu_action_open(e)
{
	var openmenu = menu_cur_open;
	var negpad   = true;
	
	//----------------------------------
	// Close current menu(s)
	//----------------------------------
	
	menu_action_close();
	
	//----------------------------------
	// Save CPU - cur open clicked?
	//----------------------------------
	
	if ( openmenu == e.id )
	{
		return false;
	}
	
	//----------------------------------
	// Get ID of menu DIV to show
	//----------------------------------
	
	var mid         = _menu_get_base_name(e.id) + "_menu";	
	var mobj        = my_getbyid(mid);
	var left_px     = _get_obj_leftpos(e);
	var top_px      = _get_obj_toppos(e) + e.offsetHeight;
	var callbackobj = my_getbyid( e.id );
	var ifid        = e.id;
	
	menu_open_menus.set(e.id,true);
	menu_cur_open         = e.id;
	
	//----------------------------------
	// Show menu DIV
	//----------------------------------
	
	mobj.style.display = "";
	
	//----------------------------------
	// Try and keep it on screen
	//----------------------------------
	
	var width = parseInt( mobj.style.width ) ? parseInt( mobj.style.width ) : mobj.offsetWidth;
	
	if ( (left_px + width) >= document.body.clientWidth )
	{
		left_px = left_px + e.offsetWidth - width;
		negpad  = false;
	}
	
	//----------------------------------
	// IE needs a tweak...
	//----------------------------------
	
	if ( is_ie )
	{
		left_px += ( negpad ) ? -2 : 2;
	}
	
	//----------------------------------
	// Finalize menu position
	//----------------------------------
	
	mobj.style.left   = left_px + "px";
	mobj.style.top    = top_px  + "px";
	mobj.style.zIndex = 100;
	
	//----------------------------------
	// Run a custom function?
	//----------------------------------
	
	if ( menu_openfuncs[ callbackobj ] )
	{ 
		eval( menu_openfuncs[ callbackobj ] );
	}
	
	//----------------------------------
	// Workaround for IE bug which shows
	// select boxes and other windows GUI
	// over divs. SHOW IFRAME
	//----------------------------------
	
	if ( is_ie )
	{
		try
		{
			if ( ! document.getElementById( 'if_' + e.id ) )
			{ 
				var iframeobj = document.createElement('iframe');
				
				iframeobj.src = 'javascript;';
				iframeobj.id  = 'if_' + e.id;
				
				document.getElementsByTagName('body').appendChild( iframeobj );
			}
			else
			{
				var iframeobj = document.getElementById( 'if_' + e.id );
			}
			
			iframeobj.scrolling      = 'no';
			iframeobj.frameborder    = 'no';
			iframeobj.className      = 'iframeshim';
			iframeobj.style.position = 'absolute';
				
			iframeobj.style.width   = parseInt(mobj.offsetWidth)  + 'px';
			iframeobj.style.height  = parseInt(mobj.offsetHeight) + 'px';
			iframeobj.style.top     = mobj.style.top;
			iframeobj.style.left    = mobj.style.left;
			iframeobj.style.zIndex  = 99;
			iframeobj.style.display = "block";
    		
    	}
    	catch(e)
    	{
    		//alert(e); // Oh dear, someones stolen the iframe
    	}
	}
	
	//----------------------------------
	// Work around for safari which doesnt
	// allow a hrefs top be clickable in
	// a pop up div
	//----------------------------------
	
	if ( is_safari )
	{
		try
		{
			mlinks = mobj.getElementsByTagName('a');
			
			for ( var i = 0 ; i <= mlinks.length ; i++ )
			{
				//----------------------------------
				// Ignore non links and links that end with #
				// As safari likes to do that with href='#' links
				//----------------------------------
				
				if ( mlinks[i].href && ( mlinks[i].href.indexOf( '#', 0 ) != (mlinks[i].href.length - 1) ) )
				{
					mlinks[i].onmousedown = _safari_onclick_handler;
					mlinks[i].id          = 'saf-link-' + mid + i;
				}
			}
		}
		catch( e )
		{
			//alert( e );
		}
	}
	
	return false;
}

/*-------------------------------------------------------------------------*/
// Safari: bug fix
/*-------------------------------------------------------------------------*/

function _safari_onclick_handler()
{
	if ( this.id )
	{
		window.location = document.getElementById( this.id ).href;
	}
}


/*-------------------------------------------------------------------------*/
// ACTION: Close all open menus
/*-------------------------------------------------------------------------*/

function menu_action_close()
{
	if ( menu_cur_open )
	{	
		menu_open_menus.each(function(pair) {
			my_getbyid(_menu_get_base_name(pair.key) + "_menu").style.display = "none";
			
			//----------------------------------
			// Workaround for IE bug which shows
			// select boxes and other windows GUI
			// over divs. Hide IFRAME
			//----------------------------------
			
			if ( is_ie )
			{
				try
				{
					document.getElementById( 'if_' + pair.key ).style.display = "none";
				}
				catch(e)
				{
					//alert(e);// Oh dear, someones stolen the iframe
				}
			}
	
			menu_open_menus.set(pair.key,false);
		});
	}
	
	menu_cur_open = false;
}

/*-------------------------------------------------------------------------*/
// ACTION: If menu open and hover over another cid, close cur open new
/*-------------------------------------------------------------------------*/

function menu_action_hover(e)
{
	menu_open_menus.each(function(pair) {
		if (menu_open_menus[pair.key] == true && pair.key != e.id)
		{
			menu_action_open(e);
			return;
		}
	});
}

/*-------------------------------------------------------------------------*/
// Prevent browser bubblin'
/*-------------------------------------------------------------------------*/

function _cancel_bubble(obj, extra)
{
	if ( ! obj || is_ie)
	{
		if ( extra )
		{
			window.event.returnValue = false;
		}
		
		window.event.cancelBubble = true;
		
		return window.event;
	}
	else
	{
		if (obj.target.type == 'submit')
		{
			obj.target.form.submit();
		}
		
		obj.stopPropagation();
		
		if ( extra )
		{
			obj.preventDefault();
		}
		
		return obj;
	}
}

/*-------------------------------------------------------------------------*/
// EVENT : Mouse over menu
/*-------------------------------------------------------------------------*/

function _event_menu_mouseover(e)
{
	e = _cancel_bubble(e, true);
	menu_action_hover(this);
}

/*-------------------------------------------------------------------------*/
// EVENT: Menu click
/*-------------------------------------------------------------------------*/

function _event_menu_click(e)
{
	e = _cancel_bubble(e, true);
	menu_action_open(this);
}

/*-------------------------------------------------------------------------*/
// Get menu basename
/*-------------------------------------------------------------------------*/

function _menu_get_base_name(cid)
{
	var endpos = cid.indexOf(".");
	
	if (endpos != -1)
	{
		return cid.substr(0, endpos);
	}
	else
	{
		return cid;
	}
}

/*-------------------------------------------------------------------------*/
// Get left posititon of object
/*-------------------------------------------------------------------------*/

function _get_obj_leftpos(obj)
{
	var left = obj.offsetLeft;
	
	while( (obj = obj.offsetParent) != null )
	{
		left += obj.offsetLeft;
	}
	
	return left;
}

/*-------------------------------------------------------------------------*/
// Get top position of object
/*-------------------------------------------------------------------------*/

function _get_obj_toppos(obj)
{
	var top = obj.offsetTop;
	
	while( (obj = obj.offsetParent) != null )
	{
		top += obj.offsetTop;
	}
	
	return top;
}


//------------------------------------------------------------------------------
// IPS XML HTTP REQUEST 
//------------------------------------------------------------------------------
// Supports Safari, Mozilla 1.3+ (Firefox, etc) and IE 5.5+
// (c) 2005 Invision Power Services, Inc.
// http://www.invisionpower.com
//------------------------------------------------------------------------------

try
{
	if ( ! use_charset )
	{
		var use_charset = '';
	}
}
catch( e ) { }

/*--------------------------------------------*/
// New object
/*--------------------------------------------*/

function ajax_request()
{
	this.isIE               = false;
	this.allow_use          = use_enhanced_js ? true : false;
	this.xmlhandler         = null;
	this.error_string       = '';
	this.nocache			= true;
	this.do_request_functon = function() {}
	this.loading_fired		= 0;
	this.centerdiv          = null;
}

/*--------------------------------------------*/
// Initiate
/*--------------------------------------------*/

ajax_request.prototype.xml_init = function()
{
	try
	{
		//------------------------------------------------
		// Moz, Safari, Opera
		//------------------------------------------------
		
		this.xmlhandler = new XMLHttpRequest();
		this.ie        = false;
		this.allow_use = true;
		return true;
	}
	catch(e)
	{
		try
		{
			//------------------------------------------------
			// IE
			//------------------------------------------------
			
			this.xmlhandler = new ActiveXObject('Microsoft.XMLHTTP');
			this.ie        = true;
			this.allow_use = true;
			return true;
		}
		catch(e)
		{
			this.ie        = true;
			this.allow_use = false;
			return false;
		}
	}
}

/*--------------------------------------------*/
// Actually send data
/*--------------------------------------------*/

ajax_request.prototype.process = function( url, type, post )
{
	//------------------------------------------------
	// The 'post' variable needs to be in the following format:
	//
	// var=content&var2=content&var3=content
	//
	// All values need to be escaped with encodeURIComponent();
	//------------------------------------------------
	
	type = type == "POST" ? "POST" : "GET";
	
	//------------------------------------------------
	// Use nocache where possible...
	//------------------------------------------------
	
	if ( this.nocache == true  && type == 'GET' )
	{
		url = this.nocache_url( url );
	}
	
	//------------------------------------------------
	// Make sure we're initialized
	//------------------------------------------------
	
	if ( ! this.xmlhandler )
	{
		this.xml_init();
	}
	
	//------------------------------------------------
	// Only go when ready
	//------------------------------------------------
	
	if ( ! this.readystate_not_ready() )
	{
		this.xmlhandler.open(type, url, true);
		
		if ( type == "GET" )
		{
			this.xmlhandler.send(null);
		}
		else
		{
			if ( typeof( this.xmlhandler.setRequestHeader ) != "undefined" )
			{
				this.xmlhandler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=' + use_charset);
			}
			this.xmlhandler.send( post );
		}
		
		if ( this.xmlhandler.readyState == 4 && this.xmlhandler.status == 200 )
		{
			return true;
		}
	}
	
	return false;
}

/*--------------------------------------------*/
// retrieve text of an XML document element, including
// elements using namespaces
/*--------------------------------------------*/

ajax_request.prototype.get_element_text_ns = function(prefix, local, parentElem, index)
{
    var result = "";
    
    if ( prefix && this.isIE )
    {
        //-------------------------------
        // IE
        //-------------------------------
        
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    }
    else
    {
        //-------------------------------
        // Safari, Gecko
        //-------------------------------
        
        result = parentElem.getElementsByTagName(local)[index];
    }
    
    if ( result )
    {
        if (result.childNodes.length > 1)
        {
            return result.childNodes[1].nodeValue;
        }
        else
        {
            return result.firstChild.nodeValue;    		
        }
    }
    else
    {
        return "n/a";
    }
}

/*--------------------------------------------*/
// Make sure URL is not cached
/*--------------------------------------------*/

ajax_request.prototype.nocache_url = function (url)
{
	var sep    = ( -1 < url.indexOf("?") ) ? "&" : "?";
	var mydate = new Date();
	var newurl = url + sep + "__=" + mydate.getTime();
	return newurl;
}

/*--------------------------------------------*/
// Takes an array of:
// array[ field ] = value
// and returns a nice encoded POST string
/*--------------------------------------------*/

ajax_request.prototype.format_for_post = function( arrayfields )
{
	var str = '';
	
	try
	{
		for (var i = 0; i < arrayfields.length; i++)
		{
			str += i + '=' + this.encodeurl(arrayfields[i]) + '&';
		}
	}
	catch(e)
	{
	}
	
	return str;
}

/*--------------------------------------------*/
// Hand roll encode URL to UTF-8
/*--------------------------------------------*/

ajax_request.prototype.encodeurl = function( url )
{
	//-------------------------------
	// Ensure we have a string
	//-------------------------------
	
	url = url.toString();

	var regcheck = url.match(/[\x90-\xFF]/g);
	
	if ( regcheck )
	{
		for (var i = 0; i < i.length; i++)
		{
			url = url.replace(regcheck[i], '%u00' + (regcheck[i].charCodeAt(0) & 0xFF).toString(16).toUpperCase());
		}
	}

	return escape(url).replace(/\+/g, "%2B");
}


/*--------------------------------------------*/
// Check to ensure ready state-ness
/*--------------------------------------------*/

ajax_request.prototype.readystate_not_ready = function()
{
	return ( this.xmlhandler.readyState && ( this.xmlhandler.readyState < 4 ) );
}

/*--------------------------------------------*/
// Check to ensure ready state-ness
/*--------------------------------------------*/

ajax_request.prototype.readystate_ready_and_ok = function()
{
	return ( this.xmlhandler.readyState == 4 && this.xmlhandler.status == 200 ) ? true : false;
}

/*--------------------------------------------*/
// Onready state change event handler
/*--------------------------------------------*/

ajax_request.prototype.onreadystatechange = function( event )
{
	//------------------------------------------------
	// Make sure we're initialized
	//------------------------------------------------
	
	if ( ! this.xmlhandler )
	{
		this.xml_init();
	}
	
	//------------------------------------------------
	// Make sure its a function event
	//------------------------------------------------
	
	if ( typeof(event) == 'function' )
	{
		this.xmlhandler.onreadystatechange = event;
	}
}

/*--------------------------------------------*/
// Show loading layer
/*--------------------------------------------*/

ajax_request.prototype.show_loading = function( message )
{
	if ( ! this.loading_fired )
	{
		this.loading_fired = 1;
		
		//------------------------------------------------
		// Change text?
		//------------------------------------------------
		
		if ( message )
		{
			document.getElementById( 'loading-layer-text' ).innerHTML = message;
		}
		
		this.centerdiv         = new center_div();
		this.centerdiv.divname = 'loading-layer';
		//Commented this out because was causing error. Seems to work. Too lazy to find out why it was here in the first place.
		//this.centerdiv.move_div();
	}
	
	return;
}

/*--------------------------------------------*/
// Hide loading layer
/*--------------------------------------------*/

ajax_request.prototype.hide_loading = function()
{
	try
	{
		if ( this.centerdiv && this.centerdiv.divobj )
		{
			this.centerdiv.hide_div();
		}
	}
	catch(e)
	{
	}
	
	this.loading_fired = 0;
	
	return;
}

/*--------------------------------------------*/
// IPB thinks we can use fancy JS, lets see...
/*--------------------------------------------*/

if ( use_enhanced_js )
{
	use_enhanced_js = ajax_request.prototype.xml_init() ? 1 : 0;
}


/*-------------------------------------------------------------------------*/
// IPS BASIC MENU CLASS (EXTENSION: BUILD SIMPLE MENU)
// (c) 2005 Invision Power Services, Inc
// Assumes that "ips_menu.js" has been loaded
/*-------------------------------------------------------------------------*/

//----------------------------------
// INIT some CSS classes
//----------------------------------

var css_mainwrap     = 'popupmenu';
var css_menusep      = 'popupmenu-item';
var css_menusep_last = 'popupmenu-item-last';

//----------------------------------
// INIT some images
//----------------------------------

var img_item   = "<img src='" + ipb_var_image_url + "/menu_item.gif' border='0' alt='V' style='vertical-align:middle' />";
var img_action = "<img src='" + ipb_var_image_url + "/menu_item2.gif' border='0' alt='V' />";

/*-------------------------------------------------------------------------*/
// Return formed image
/*-------------------------------------------------------------------------*/

function make_image( img )
{
	return "<img src='" + ipb_var_image_url + "/" + img + "' border='0' alt='-' class='ipd' />";
}

/*-------------------------------------------------------------------------*/
// menu_build_menu
// cid: ID of opener object (img, div, etc)
// menuinput: Array of menu entries | Variable of menu HTML
// complexmenu: Treat as HTML stream if true, else treat as array of HTML
/*-------------------------------------------------------------------------*/

function menu_build_menu(cid, menuinput, complexmenu)
{
	var html = "\n<div class='" + css_mainwrap + "' id='" + cid + "_menu' style='display:none;z-index:100'>\n";
	
	if ( ! complexmenu )
	{
		len = parseInt(menuinput.length);
		
		if ( len > 0 )
		{
			for(var i=0;i<menuinput.length;i++)
			{
				t = parseInt(i) + 1;
				
				thisclass = ( t == len ) ? css_menusep_last : css_menusep;
				
				if ( menuinput[i].match( /^--NODIV--/ ) )
				{
					html += menuinput[i].replace( /^--NODIV--/, '' );
				}
				else
				{
					html += "<div class='" + thisclass + "'>\n" + menuinput[i] + "\n</div>\n";
				}
			}
		}
	}
	else
	{
		html += menuinput;
	}
	
	html += "\n</div>\n";
	
	//----------------------------------
	// Workaround for IE bug which shows
	// select boxes and other windows GUI
	// over divs. Write iframe
	//----------------------------------
	
	if ( is_ie )
	{
		html += "\n"+'<iframe id="if_' + cid + '" src="' + ipb_var_image_url + '/iframe.html" scrolling="no" frameborder="1" style="position:absolute;top:0px;left:0px;display:none;"></iframe>'+"\n";
	}
	
	//----------------------------------
	// Write the html
	//----------------------------------
	
	if ( html != '' )
	{
		document.open();
		document.writeln( html );
		document.close();
	}
	
	//----------------------------------
	// Register and init
	//----------------------------------
	
	menu_register( cid );
}



