//------------------------------------------
// 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      = 'system/blank.gif';
var img_tick       = 'system/aff_tick.gif';
var img_cross      = 'system/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');
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 dashboard_id  = 0;
var dashboard_key = '';
var dashFade    = '';

//==========================================
// Multi Page jumps
//==========================================

function multi_page_jump( url_bit, total_posts, per_page )
{
        pages = 1;
        cur_st = ipb_var_st;
        cur_page  = 1;

        if ( total_posts % per_page == 0 )
        {
                pages = total_posts / per_page;
        }
        else
        {
                pages = Math.ceil( total_posts / per_page );
        }

        msg = "Please enter a page number to jump to between 1 and" + " " + pages;

        if ( cur_st > 0 )
        {
                cur_page = cur_st / per_page; cur_page = cur_page -1;
        }

        show_page = 1;

        if ( cur_page < pages )
        {
                show_page = cur_page + 1;
        }

        if ( cur_page >= pages )
        {
                show_page = cur_page - 1;
        }
         else
         {
                 show_page = cur_page + 1;
         }

        userPage = prompt( msg, show_page );

        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;
        }
}

/*-------------------------------------------------------------------------*/
// Toggle Divs
/*-------------------------------------------------------------------------*/

function toggle(id) 
{ 
	thediv = document.getElementById(id); 

	if( !thediv ) 
	{ 
		return; 
    } 
    else 
    { 
		if( thediv.style.display == 'none' ) 
		{ 
			thediv.style.display = ''; 
		} 
		else 
		{ 
			thediv.style.display = 'none'; 
		} 
	} 
}

/*-------------------------------------------------------------------------*/
// INIT Post GD Image
/*-------------------------------------------------------------------------*/

function init_gd_image()
{
	var reg_img = document.getElementById('gd-antispam');
	
	try
	{
		reg_img.style.cursor = 'pointer';
	}
	catch(e)
	{
		reg_img.style.cursor = 'hand';
	};
	
	reg_img._ready  = 1;
	
	reg_img.onclick = do_change_img;
};

function do_change_img()
{
	var rc 	    = '';
	var act	    = 'captcha';
	var code    = 'showimage';
	var reg_img = document.getElementById('gd-antispam');
	
	var qparts  = reg_img.src.split("?");
	
	if ( ! reg_img._ready )
	{
		return false;
	}
	
	if ( qparts.length > 1 ) 
	{
		var qvars = qparts[1].split("&");

		for ( var i=0; (i < qvars.length); i++ ) 
		{
			var qparts = qvars[i].split("=");
			
			if ( qparts[0] == 'captcha_unique_id' )
			{
				rc = qparts[1];
			};
			
			if ( qparts[0] == 'act' )
			{
				act = qparts[1];
			};
			
			if ( qparts[0] == 'do' )
			{
				code = qparts[1];
			};
		};
	};
	
	var url = ipb_var_script_url_no_module + 'module=ajax&section=captcha&do=change-gd-img&img=' + rc + '&secure_key=' + ipb_md5_check;
	
	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------
		
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			// Could do a little loading graphic here?
			return;
		}
		
		//----------------------------------
		// INIT
		//----------------------------------
		
		var html = xmlobj.xmlhandler.responseText;
		
		reg_img.src = ipb_var_script_url_no_module + '&module=global&section=captcha&do='+code+'&captcha_unique_id='+html;
		
		var reg_field  	= document.getElementById('captcha_unique_id');
		reg_field.value = html;
		
		reg_img._ready = 1;
	};
	
	//----------------------------------
	// LOAD XML
	//----------------------------------
	
	reg_img._ready = 0;
	
	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	xmlobj.process( url );
}
		
/*-------------------------------------------------------------------------*/
// The form has changed...
/*-------------------------------------------------------------------------*/

init_sidebar_menu_click = function( event )
{
	//-------------------------------
	// INIT
	//-------------------------------
	
	var _tabs = new Array( 'menu', 'bookmarks', 'search' );
	var tabid = ipsclass.get_id_from_text( this.id );
	
	//-------------------------------
	// Store cookie
	//-------------------------------
	
	ipsclass.my_setcookie( 'ips-global-menu-sidebar', tabid, 1 );
	
	//-------------------------------
	// Got it?
	//-------------------------------
	
	for ( var i in _tabs )
	{
		if ( _tabs[i] == tabid )
		{
			document.getElementById( 'sidebar-' + _tabs[i] ).style.display = 'block';
			document.getElementById( 'sidebar-tab-' + _tabs[i] ).className = 'tabon';
		}
		else
		{
			document.getElementById( 'sidebar-' + _tabs[i] ).style.display = 'none';
			document.getElementById( 'sidebar-tab-' + _tabs[i] ).className = 'taboff';
		}
	}
	
	// Stop scrolling to top of the page...
	ipsclass.cancel_bubble( event );
	
	return false;
};

//==========================================
// Update Nexus Mini Dashboard
//==========================================
function update_mini_dashboard( id, key )
{
	// Set IDS
	if ( id && key )
	{
		dashboard_id  = id;
		dashboard_key = key;
	}
	else
	{
		return false;
	}

	// Ajax: Get Invoice list
	if( use_enhanced_js && ipb_var_base_url )
	{
		var url = ipb_var_base_url + '&appcomponent=core&module=ajax&secure_key=' + ipb_md5_check + '&section=dashboard_ajax&do=update-mini-dashboard&id=' + dashboard_id + '&key=' + dashboard_key;

		do_request_function = function()
		{
			// Ignore unless we're ready to go
			if( ! xmlobj.readystate_ready_and_ok() )
			{
				return;
			}

			if ( xmlobj.xmlhandler.responseText == 'logout' )
			{
				document.location = document.location;
			}
			else
			{
				document.getElementById( 'mini-dashboard' ).innerHTML = xmlobj.xmlhandler.responseText;
			}
		}

		// Load XML
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url );
	}

 	self.setTimeout( 'update_mini_dashboard(0,0)', 30000 );
}

//==========================================
// Gets the page height
//==========================================

function _get_page_height()
{

	if(is_ns || is_moz || is_ns4)
	{
		//return pageYOffset + innerHeight;
		return innerHeight;
	}
	else
	{

		//var ignoreme = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;

		if(document.documentElement && ( document.documentElement.clientHeight ))
		{
			var ignoremetoo = document.documentElement.clientHeight;
		}
		else
		{
			var ignoremetoo = document.body.clientHeight;
		}

		return ignoremetoo - 40;
	}

}

/*-------------------------------------------------------------------------*/
// Get top position of object
/*-------------------------------------------------------------------------*/

function _get_obj_toppos(obj)
{
        var top = obj.offsetTop;

        while( (obj = obj.offsetParent) != null )
        {
                top += obj.offsetTop;
        }

        return top;
}

/*-------------------------------------------------------------------------*/
// Display in-line messages...
/*-------------------------------------------------------------------------*/

function show_inline_messages()
{
	var _string  = window.location.toString();
	var _msg_box = null;
	
	if ( _string.indexOf( '?___msg=' ) != -1 || _string.indexOf( ';___msg=' ) != -1 || _string.indexOf( '&___msg=' ) != -1 )
	{
		// Is this a frame? Move it to the parent...
		try
		{
			if ( parent.document.getElementById( 'ipd-msg-text' ) )
			{
				_msg_box = parent.document.getElementById( 'ipd-msg-text' );
			}
			else
			{
				_msg_box = document.getElementById( 'ipd-msg-text' );
			}
		}
		catch( error )
		{
			alert( error );
		}
		
		var message = _string.replace( /^.*[\?;&]___msg=(.+?)(&.*$|$)/, "$1" );
		message     = unescape( message );
		
		if ( message_pop_up_lang[ message ] )
		{
			try
			{
				_msg_box.innerHTML = message_pop_up_lang[ message ];

				centerdiv         = new center_div();
				centerdiv.divname = 'ipd-msg-wrapper';
				centerdiv.move_div();
				
				setTimeout("hide_inline_messages_instant()",2000);
			}
			catch( anerror)
			{
				alert( message_pop_up_lang[ message ] );
			}
		}
	}
};

function show_inline_messages_instant( msg )
{
	_msg_box 		   = document.getElementById( 'ipd-msg-text' );
	_msg_box.innerHTML = message_pop_up_lang[ msg ];

	centerdiv          = new center_div();
	centerdiv.divname  = 'ipd-msg-wrapper';
	centerdiv.move_div();
	
	setTimeout("hide_inline_messages_instant()",2000);
};

function hide_inline_messages_instant()
{
	try
	{
		document.getElementById( 'ipd-msg-wrapper' ).style.display = 'none';
		parent.document.getElementById( 'ipd-msg-wrapper' ).style.display = 'none';
	}
	catch(acold)
	{
	}
};

//==========================================
// 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;
}

//==========================================
// 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 = "";
}

//==========================================
// Toggle misc divs
//==========================================

function toggle_divs( fid, add )
{
        saved = new Array();
        clean = new Array();

        //-----------------------------------
        // 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  ) );
        }

        return false;
}

/*-------------------------------------------------------------------------*/
// Fix IE PNG images
/*-------------------------------------------------------------------------*/

function ie_fix_png()
{
	if ( is_ie )
	{
		document.onreadystatechange = ie_fix_png_do;
	}
}

function ie_fix_png_do()
{
	if ( document.readyState == 'complete' )
	{
		var pos     = navigator.userAgent.indexOf("MSIE ");
		var version = navigator.userAgent.substring(pos + 5);
		var blanky  = ipb_skin_url + "/blank.gif";
	
		if (pos == -1)
		{
			return false;
		}
	
		if ( ! ((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)) && (navigator.platform == ("Win32")) )
		{
			return;
		}
	
		var images = document.getElementsByTagName( 'IMG' );
		var _len   = images.length;
	
		if ( _len )
		{
			for ( var i = 0 ; i < _len ; i++ )
			{
				if ( images[i].src.match( /\.png$/ ) )
				{
					var element = images[i];
					var _width  = 0;
					var _height = 0;
					var _src    = 0;
				
					if ( ! element.style.width )
					{
						_width = element.width;
					}

					if ( ! element.style.height )
					{
						_height = element.height;
					}
				
					_src        = element.src;
					element.src = blanky;

					if ( _width )
					{
						element.style.width  = _width+"px";
					}
					if ( _height )
					{
						element.style.height = _height+"px";
					}

					element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + _src + "',sizingMethod='scale')";
				}
			}
		}
	}
}


/*-------------------------------------------------------------------------*/
// Add onload event
/*-------------------------------------------------------------------------*/

function add_onload_event( func )
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
	{
    	window.onload = func;
  	}
  	else
  	{
    	window.onload = function()
		{
      		if ( oldonload )
      		{
        		oldonload();
      		};

      		func();
    	};
  	}
}

/*-------------------------------------------------------------------------*/
// Add onclick event
/*-------------------------------------------------------------------------*/

function add_onclick_event( func )
{
	var oldonclick = window.onclick;

	if (typeof window.onclick != 'function')
	{
    	window.onclick = func;
  	}
  	else
  	{
    	window.onclick = function()
		{
      		if ( oldonclick )
      		{
        		oldonclick();
      		};

      		func();
    	};
  	}
}

/*-------------------------------------------------------------------------*/
// Add shadow to an ID
/*-------------------------------------------------------------------------*/

function add_shadow( wrapname, divname )
{
	var divobj  = document.getElementById( divname );
	var wrapobj = document.getElementById( wrapname );
	
	//----------------------------------
	// Transform the DIV
	//----------------------------------
	
	if ( is_ie )
	{
		wrapobj.className      = 'shadow-ie';
		wrapobj.style.width    = divobj.offsetWidth  + 4 + 'px';
		wrapobj.style.height   = divobj.offsetHeight + 4 + 'px';
	}
	else
	{
		wrapobj.className      = 'shadow-moz';
		wrapobj.style.width    = divobj.offsetWidth  + 0 + 'px';
		wrapobj.style.height   = divobj.offsetHeight + 0 + 'px';
	}
}

/*-------------------------------------------------------------------------*/
// 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_script_url + '&module=xmlout&do=dst-autocorrection&xml=1&md5check=' + ipb_md5_check;
	
	if ( Math.abs( thisoffset + dstoffset ) == 1 )
	{
		try
		{
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/

			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------

				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					return;
				}

				//----------------------------------
				// INIT
				//----------------------------------

				var html = xmlobj.xmlhandler.responseText;
			
				if ( html == 'error' )
				{
					//window.location = url.replace( '&xml=1', '&xml=0');
				}
			};

			//----------------------------------
			// LOAD XML
			//----------------------------------

			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url );
			dstset = 1;
		}
		catch(e)
		{
			dstset = 0;
		}
		
		//----------------------------------
		// No fancy?
		//----------------------------------
		
		if ( dstset == 0 )
		{
			//window.location = url;
		}
	}
}

/*-------------------------------------------------------------------------*/
// Write Calendar popup
/*-------------------------------------------------------------------------*/

function show_calendar( fieldid )
{
	formfield = document.getElementById( fieldid );
	
	cal = new calendar_us( formfield );
	cal.year_scroll = true;
	cal.time_comp   = false;
	cal.popup();
}

/*-------------------------------------------------------------------------*/
// Generate new iframe include
/*-------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------*/
// Generate new iframe include
/*-------------------------------------------------------------------------*/

function iframe_include()
{
	this.iframe_id			   = null;
	this.iframe_obj            = null;
	this.iframe_add_to_div     = null;
	this.iframe_add_to_div_obj = null;
	this.iframe_main_wrapper   = null;
	this.iframe_classname      = 'GBL-component-iframe';
	this.ok_to_go              = 1;
	this.iframe_height         = 300;
	this.ajax                  = '';
};

iframe_include.prototype.init = function()
{
	try
	{
		this.iframe_add_to_div_obj = document.getElementById( this.iframe_add_to_div );
	}
	catch( error )
	{
		this.ok_to_go = 0;
	}
};

iframe_include.prototype.include = function( url )
{
	//-----------------------------------------
	// Check
	//-----------------------------------------
	
	if ( ! this.ok_to_go )
	{ 
		return false;
	}
	
	//-----------------------------------------
	// INIT
	//-----------------------------------------
	
	var iheight = parseInt( this.iframe_add_to_div_obj.style.height );
	var iwidth  = this.iframe_add_to_div_obj.style.width;
	
	//-----------------------------------------
	// Generate iFrame box
	//-----------------------------------------
	
	if ( this.iframe_obj )
	{
		this.iframe_add_to_div_obj.removeChild( this.iframe_obj );
	}
	
	this.iframe_obj = document.createElement( 'IFRAME' );
	
	this.iframe_obj.src	               = url;
	this.iframe_obj.id                 = this.iframe_id + '-id';
	this.iframe_obj.name			   = this.iframe_id + '-name';
	this.iframe_obj.scrolling          = 'no';
	this.iframe_obj.frameBorder        = 'no';
	this.iframe_obj.border             = '0';
	this.iframe_obj.className          = this.iframe_classname;
	this.iframe_obj.style.width        = iwidth  ? iwidth  : '100%';
	this.iframe_obj.style.height       = iheight ? iheight - 5 + 'px' : this.iframe_height + 'px';
	this.iframe_obj.style.overflow     = 'hidden';
	this.iframe_obj.style.padding      = '0px';
	this.iframe_obj.style.margin       = '0px';
	
	// Fix up padding
	this.iframe_add_to_div_obj.style.padding = '0px';
	this.iframe_add_to_div_obj.style.margin  = '0px';
	
	// Add environmentals..
	this.iframe_obj.iframe_loaded      = 0;
	this.iframe_obj.iframe_init        = 0;
	this.iframe_obj._this              = this;
	
	// Attach iFrame inside our DIV
	this.iframe_add_to_div_obj.style.overflow = '';
	this.iframe_add_to_div_obj.appendChild( this.iframe_obj );
	
	// Add handler
	if ( is_ie )
	{
		this.iframe_obj.allowTransparency  = true;
		this.iframe_obj.onreadystatechange = this.iframe_on_load_ie;
	}
	else
	{
		this.iframe_obj.onload = this.iframe_onload;
	}
};

/**
* Each time the window is loaded, close
* any open messages
*/
iframe_include.prototype.iframe_onload = function( e )
{
	//-----------------------------------------
	// First load?
	//-----------------------------------------
	
	//window.frames[ this.id ].document
	
	var _document= this._this.iframe_obj.contentDocument;
	
	if ( is_safari )
	{
		_document = window.frames[ this.id ].document;
	}
	
	if ( ! this.iframe_init )
	{
		this.iframe_init   = 1;
		this.iframe_loaded = 1;
		
		_document.onmousedown = menu_action_close;
	}
	else
	{
		this.iframe_loaded = 1;
		_document.onmousedown = menu_action_close;
	}
	
	//-----------------------------------------
	// Attempt to fix up padding issues
	//-----------------------------------------
	
	try
	{
		_document.getElementsByTagName( 'body' )[0].style.padding = '0px';
		_document.getElementsByTagName( 'body' )[0].style.margin  = '0px';
	}
	catch(error)
	{
	}
	
	//-----------------------------------------
	// Resize... 
	//-----------------------------------------
	
	var _new_height = parseInt( _document.getElementById( this._this.iframe_main_wrapper ).offsetHeight );
	
	if ( _new_height > 0 )
	{
		if ( is_safari )
		{
			_new_height += 3;
		}
		
		this._this.iframe_obj.style.height            = _new_height + "px";
		this._this.iframe_add_to_div_obj.style.height = _new_height + "px";
	}
	
	//-----------------------------------------
	// Fix up style sheets
	//-----------------------------------------
	
	var style      = document.getElementsByTagName( 'style' );
	var _new_style = '';
	
	for( i in style )
	{
		_new_style += "\n" + style[i].innerHTML;
	}
	
	try
	{
		_document.getElementsByTagName( 'style' )[0].innerHTML = _new_style;
	}
	catch(error)
	{
	}
};

/**
* IE only calls onload once... So subsequent loads
* don't do anything.. hence the readystate change
*/
iframe_include.prototype.iframe_on_load_ie = function( e )
{
	//-----------------------------------------
	// First load?
	//-----------------------------------------
	
	if ( this.readyState == 'complete' )
	{
		var _document = '';
		
		if ( this._this.iframe_obj.contentWindow )
		{
			_document = this._this.iframe_obj.contentWindow.document;
		}
		else if ( this._this.iframe_obj.document )
		{
			_document = this._this.iframe_obj.document;
		}
		else
		{
			_document = window.frames[ this.id ].document;
		}
		
		if ( ! this.iframe_init )
		{
			this.iframe_init   = 1;
			this.iframe_loaded = 1;
			_document.onmousedown = menu_action_close;
		}
		else
		{
			this.iframe_loaded = 1;
			_document.onmousedown = menu_action_close;
		}
		
		//-----------------------------------------
		// Fix up style sheets
		//-----------------------------------------
		
		var style      = document.getElementsByTagName( 'style' );
		var _new_style = '';

		for( i in style )
		{
			if ( style[i].innerHTML )
			{
				_new_style += "\n" + style[i].innerHTML;
			}
		}
		
		var _urls = _new_style.match( /@import\s+?url\(\s+?['"](.+?)['"]\s+?\);/ig );
		
		if ( _urls && _urls.length )
		{
			for( i = 0 ; i <= _urls.length ; i++ )
			{
				if ( typeof( _urls[i] ) != 'undefined' )
				{
					_urls[i] = _urls[i].replace( /@import\s+?url\(\s+?['"](.+?)['"]\s+?\);/ig, "$1" );
				
					if ( typeof( _urls[i] ) != 'undefined' )
					{
						_document.createStyleSheet( _urls[i] );
					}
				}
			}
		}
		
		//-----------------------------------------
		// Attempt to fix up padding issues
		//-----------------------------------------

		try
		{
			_document.getElementsByTagName( 'body' )[0].style.padding = '0px';
			_document.getElementsByTagName( 'body' )[0].style.margin  = '0px';
		}
		catch(error)
		{
		}
		
		//-----------------------------------------
		// Resize... 
		//-----------------------------------------

		var _new_height = parseInt( _document.getElementById( this._this.iframe_main_wrapper ).offsetHeight );
		var _new_width  = parseInt( _document.getElementById( this._this.iframe_main_wrapper ).offsetWidth );
		
		if ( _new_height > 0 )
		{
			this._this.iframe_obj.style.height            = _new_height + "px";
			this._this.iframe_add_to_div_obj.style.height = _new_height + "px";
		}
		
		if ( _new_width > 0 )
		{
			this._this.iframe_obj.style.width            = _new_width + "px";
			this._this.iframe_add_to_div_obj.style.width = _new_width + "px";
		}
	}
};

/*-------------------------------------------------------------------------*/
// Get cache file
/*-------------------------------------------------------------------------*/

function get_cached_html()
{
	this.url 		   = "";
	this.div_to_add_id = "";
	this.xmlobj        = new ajax_request();
	
	this.load = function()
	{
		//-----------------------------------------
		// Main function
		//-----------------------------------------
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------

			if ( ! _this.xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				return;
			}

			//----------------------------------
			// INIT
			//----------------------------------

			var html = _this.xmlobj.xmlhandler.responseText;
			
			//-----------------------------------------
			// Fix up form urls
			//-----------------------------------------
			
			if ( match = html.match( /<form(.+?)action=[\"'](.+?)[\"'](.+?)?>/i ) )
			{
				var _url     = match[2];
				var _join    = _url.match( /\?/ ) ? '&' : '?';
				var _from    = window.location.toString();
				
				_url += _join + '__from=' + escape( _from );
				
				html = html.replace( /<form(.+?)action=[\"'](.+?)[\"'](.+?)?>/i, "<form$1action='" + _url + "'$3>" );
			}
			try
			{
				document.getElementById( _this.div_to_add_id ).innerHTML = html;
				_this.xmlobj.execute_javascript( html );
			}
			catch(err)
			{
			}
		};
		
		var _this   = this;
		this.xmlobj.onreadystatechange( do_request_function );
		this.xmlobj.process( this.url );
	};
};

/*-------------------------------------------------------------------------*/
// Show Polls
/*-------------------------------------------------------------------------*/

function show_poll()
{
	this.poll_ids         = {};
	this.poll_id          = 0;
	this.poll_text        = 'poll-image-bar_';
	this.show_results     = 0;
};

show_poll.prototype.new_poll = function( wrapper_div_name )
{
	this.poll_ids         = {};
	
	//-----------------------------------------
	// Really not showing the poll?
	//-----------------------------------------
	
	if ( ! this.show_results )
	{
		var _test = ipsclass.my_getcookie( 'poll-' + this.poll_id + '-voted' );
		
		if ( _test )
		{
			this.show_results = 1;
		}
	}
};

show_poll.prototype.reorder_poll = function( question_id )
{
	if ( this.show_results )
	{
		var _main_wrap = document.getElementById( 'poll-results-mainwrap-' + this.poll_id + '_' + question_id );
		var _rows      = new Array();
		var _lookfor   = 'poll-results-main-' + this.poll_id + '_' + question_id;
		
		//-----------------------------------------
		// Get all child divs
		//-----------------------------------------
		
		var divs = document.getElementsByTagName('DIV');

		//----------------------------------
		// Sort through and grab links
		//----------------------------------

		for ( var i = 0 ; i < divs.length ; i++ )
		{
			try
			{
				if ( ! divs[i].id )
				{
					continue;
				}
			}
			catch(error)
			{
				continue;
			}

			var divid   = divs[i].id;
			var divname = ipsclass.get_name_from_text( divid );
			var divnum  = ipsclass.get_id_from_text( divid );
			
			if ( divname == _lookfor )
			{
				_rows[ divnum ] = divs[i].innerHTML;
			}
		}
		
		if ( this.poll_order[ question_id ].length )
		{
			_main_wrap.innerHTML = '';
			
			for ( var i = 0 ; i < this.poll_order[ question_id ].length ; i++ )
			{
				_main_wrap.innerHTML += "\n" + _rows[ this.poll_order[ question_id ][i] ];
			}
		}
	}
};

show_poll.prototype.display_poll = function()
{
	for( var i in this.poll_ids )
	{
		var _id      = i;
		var _percent = parseInt( this.poll_ids[i] );
		
		if ( _id )
		{
			try
			{
				//-----------------------------------------
				// Sort out what we're showing...
				//-----------------------------------------

				if ( this.show_results )
				{
					document.getElementById( 'poll-no-results-row-' + _id ).style.display = 'none';
					document.getElementById( 'poll-results-row-'    + _id ).style.display = '';
				}
				else
				{
					document.getElementById( 'poll-no-results-row-' + _id ).style.display = '';
					document.getElementById( 'poll-results-row-'    + _id ).style.display = 'none';
				}
			}
			catch(error)
			{
				alert(error);
			}
			
			if ( this.show_results )
			{
				document.getElementById( 'poll-no-results-'     + this.poll_id ).style.display = 'none';
				document.getElementById( 'poll-results-'        + this.poll_id ).style.display = '';
			}
			else
			{
				document.getElementById( 'poll-no-results-'     + this.poll_id ).style.display = '';
				document.getElementById( 'poll-results-'        + this.poll_id ).style.display = 'none';
			}
			
		}
	}
};

/*-------------------------------------------------------------------------*/
// Center a div on the screen
/*-------------------------------------------------------------------------*/

function center_div()
{
	this.divname    = '';
	this.divobj     = '';
	this.parentname = '';
	this._document  = document;
	this._window    = window;
}

/*-------------------------------------------------------------------------*/
// Main run function
/*-------------------------------------------------------------------------*/

center_div.prototype.move_div = function()
{
	try
	{
		if ( parent.document.getElementById( this.divname ) )
		{
			this._document = parent.document;
			this._window   = parent.window;
		}
	}
	catch(e)
	{
		return;
	}
	
	this.divobj = this._document.getElementById( this.divname );
	
	//----------------------------------
	// Figure width and height
	//----------------------------------
	
	var my_width  = 0;
	var my_height = 0;
	
	if ( typeof( this._window.innerWidth ) == 'number' )
	{
		//----------------------------------
		// Non IE
		//----------------------------------
	  
		my_width  = this._window.innerWidth;
		my_height = this._window.innerHeight;
	}
	else if ( this._document.documentElement && ( this._document.documentElement.clientWidth || this._document.documentElement.clientHeight ) )
	{
		//----------------------------------
		// IE 6+
		//----------------------------------
		
		my_width  = this._document.documentElement.clientWidth;
		my_height = this._document.documentElement.clientHeight;
	}
	else if ( this._document.body && ( this._document.body.clientWidth || this._document.body.clientHeight ) )
	{
		//----------------------------------
		// Old IE
		//----------------------------------
		
		my_width  = this._document.body.clientWidth;
		my_height = this._document.body.clientHeight;
	}
	
	//----------------------------------
	// Show (but behind the zIndex...
	//----------------------------------
	
	this.divobj.style.position = 'absolute';
	this.divobj.style.display  = 'block';
	this.divobj.style.zIndex   = -1;
	
	//----------------------------------
	// 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();
	
	//-----------------------------------------
	// Set up
	//-----------------------------------------
	
	var _top  = 0;
	var _left = 0;
	
	//-----------------------------------------
	// Bump 'em if we have a parent div set
	//-----------------------------------------
	
	if ( this.parentname )
	{
		var _div = document.getElementById( this.parentname );
		
		var _top  = parseInt( _div.cumulativeOffset().top );
		var _left = parseInt( _div.cumulativeOffset().left );
		
		if ( scrolly > _top )
		{
			_top = 0;
		}
	}
	
	//----------------------------------
	// Finalize...
	//----------------------------------
	
	var setX = ( ( my_width  - ( _left / 2 ) ) - divwidth  ) / 2 + _left;
	var setY = ( ( my_height - ( _top  / 2 ) ) - divheight ) / 2 + scrolly + _top;
	
	setX = ( setX < 0 ) ? 0 : setX;
	setY = ( setY < 0 ) ? 0 : setY;
	
	this.divobj.style.left = setX + "px";
	this.divobj.style.top  = setY + "px";
	
	//----------------------------------
	// Show for real...
	//----------------------------------
	
	this.divobj.style.zIndex = 99;
};

/*-------------------------------------------------------------------------*/
// 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 ( this._document.documentElement && this._document.documentElement.scrollTop )
	{
		scrollY = this._document.documentElement.scrollTop;
	}
	else if ( this._document.body && this._document.body.scrollTop )
	{
		scrollY = this._document.body.scrollTop;
	}
	else if ( this._window.pageYOffset )
	{
		scrollY = this._window.pageYOffset;
	}
	else if ( this._window.scrollY )
	{
		scrollY = this._window.scrollY;
	}
	
	return scrollY;
};
