Вход Регистрация
Файл: public/js/ipb.js
Строк: 4071
<?php
//************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ipb.js - Global code                            */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                        */
/************************************************/

/* ===================================================================================================== */
/* IPB3 JS Debugging */

var Debug = {
    
write: function( text ){
        if( 
jsDebug && !Object.isUndefined(window.console) ){
            
console.logtext );
        }
        
/*else if( jsDebug )
        {
            if( !$('_inline_debugging') ){
                var _inline_debug =  new Element('div', { id: '_inline_debugging' }).setStyle('background: rgba(0,0,0,0.7); color: #fff; padding: 10px; width: 97%; height: 150px; position: absolute; bottom: 0; overflow: auto; z-index: 50000').show();
                
                if( !Object.isUndefined( $$('body')[0] ) ){
                    $$('body')[0].insert( _inline_debug );
                }
            }
            
            try {
                $('_inline_debugging').innerHTML += "<br />" + text;
            } catch(err){}
        }*/
    
},
    
dir: function( values ){
        if( 
jsDebug && !Object.isUndefined(window.console) && ! Prototype.Browser.IE && ! Prototype.Browser.Opera ){
            
console.dirvalues );
        }
    },
    
error: function( text ){
        if( 
jsDebug && !Object.isUndefined(window.console) ){
            
console.errortext );
        }
    },
    
warn: function( text ){
        if( 
jsDebug && !Object.isUndefined(window.console) ){
            
console.warntext );
        }
    },
    
info: function( text ){
        if( 
jsDebug && !Object.isUndefined(window.console) ){
            
console.infotext );
        }
    }
};

/* Set up version specifics */
Prototype.Browser.IE6 Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
Prototype.Browser.IE7 Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
Prototype.Browser.IE8 Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 8;
Prototype.Browser.IE9 Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 9;

/* Add in stuff prototype does not include */
Prototype.Browser.Chrome Prototype.Browser.WebKit && ( navigator.userAgent.indexOf('Chrome/') > -);

/* ===================================================================================================== */
/* OVERWRITE getOffsetParent TO FIX TD ISSUE */

function isBody(element) {
  return 
element.nodeName.toUpperCase() === 'BODY';
}

function 
isHtml(element) {
  return 
element.nodeName.toUpperCase() === 'HTML';
}

function 
isDocument(element) {
  return 
element.nodeType === Node.DOCUMENT_NODE;
}

function 
isDetached(element) {
  return 
element !== document.body &&
   !
Element.descendantOf(elementdocument.body);
}

Element.Methods.getOffsetParent = function(element) {
    
element = $(element);
    
    if (
isDocument(element) || isDetached(element) || isBody(element) || isHtml(element))
    return $(
document.body);
    
    if( 
Prototype.Browser.IE ){
        if (
element.offsetParent && element.offsetParent != document.body && Element.getStyleelement.offsetParent'position' ) != 'static') return $(element.offsetParent);
        if (
element == document.body) return $(element);
    } else {    
        var 
isInline = (Element.getStyle(element'display') === 'inline');
        if (!
isInline && element.offsetParent && Element.getStyle(element.offsetParent,'position') != 'static') return $(element.offsetParent);
    }

    while ((
element element.parentNode) && element !== document.body) {
        if (
Element.getStyle(element'position') !== 'static') {
            return 
isHtml(element) ? $(document.body) : $(element);
        }
    }

    return $(
document.body);
}

/*Event.observe( window, 'load', function(e){
    Element.Methods.getOffsetParent = function( element ){
        //alert( "Using overloaded getOffsetParent" );
        if (element.offsetParent && element.offsetParent != document.body) return $(element.offsetParent);
        if (element == document.body) return $(element);

        while ((element = element.parentNode) && element != document.body)
          if (Element.getStyle(element, 'position') != 'static')
            return $(element);

        return $(document.body);
    };
});

function _getOffsetParent( element )
{
    //alert( "Using overloaded getOffsetParent" );
    if (element.offsetParent && element.offsetParent != document.body) return $(element.offsetParent);
    if (element == document.body) return $(element);

    while ((element = element.parentNode) && element != document.body )
      if (Element.getStyle(element, 'position') != 'static')
        return $(element);

    return $(document.body);
}*/

/* ===================================================================================================== */
/* MAIN ROUTINE */

window.IPBoard = Class.create({
    
namePops: [],
    
topicPops: [],
    
vars: [],
    
lang: [],
    
templates: [],
    
editors$A(),
    
initDonefalse,
    
    
initialize: function()
    {
        
Debug.write("IPB js is loading...");
        
        
document.observe("dom:loaded", function(){
            
            
this.Cookie.init();
            
// Show a little loading graphic
            
Ajax.Responders.register({
              
onLoading: function( handler ) {
                if( !
Object.isUndefinedhandler['options']['hideLoader'] ) && handler['options']['hideLoader'] != false ){
                    return;
                }
                
                if( !$(
'ajax_loading') ){
                    if( !
ipb.templates['ajax_loading'] ){ return; }
                    $(
'ipboard_body').insertipb.templates['ajax_loading'] );
                }
                
                var 
effect = new Effect.Appear( $('ajax_loading'), { duration0.2 } );
              },
              
onComplete: function() {
            
                if( !$(
'ajax_loading') || !$('ajax_loading').visible() ){ return; }
                var 
effect = new Effect.Fade( $('ajax_loading'), { duration0.2 } );
                
                if ( ! 
Object.isUndefinedipb.hoverCard ) ){
                    
ipb.hoverCardRegister.postAjaxInit();
                }
                
                
/* General links to functions */
                
$$("[data-clicklaunch]").invoke('clickLaunch');
              },
              
onSuccess: function() {
                if ( ! 
Object.isUndefinedipb.hoverCard ) ){
                    
ipb.hoverCardRegister.postAjaxInit();
                }
              },
              
onFailure: function( )
              {
                 if( !$(
'ajax_loading') || !$('ajax_loading').visible() ){ return; }
                 var 
effect = new Effect.Fade( $('ajax_loading'), { duration0.2 } );
                  
                 if ( ! 
Object.isUndefinedipb.global ) )
                 {
                     
ipb.global.showInlineNotificationipb.lang['ajax_failure'] );
                 }
                  
              },
              
onException: function( texception )
              {
                  if( !$(
'ajax_loading') || !$('ajax_loading').visible() ){ return; }
                  var 
effect = new Effect.Fade( $('ajax_loading'), { duration0.2 } );
                  
                  
Debug.errorexception );
                  
                  if ( ! 
Object.isUndefinedipb.global ) )
                  {
                      
//ipb.global.showInlineNotification( ipb.lang['ajax_failure'] );
                  
}
              }
            });
            
            
// Initialize our delegation manager
            
ipb.delegate.initialize();            
            
ipb.initDone true;
            
        }.
bind(this));
    },
    
    
positionCenter: function( elemdir )
    {
        if( !$(
elem) ){ return; }
        
elem_s = $(elem).getDimensions();
        
window_s document.viewport.getDimensions();
        
window_offsets document.viewport.getScrollOffsets();

        
center = {     left: ((window_s['width'] - elem_s['width']) / 2),
                     
top: ((window_s['height'] - elem_s['height']) / 2)
                };
        
        if( 
typeof(dir) == 'undefined' || ( dir != 'h' && dir != 'v' ) )
        {
            $(
elem).setStyle('top: ' center['top'] + 'px; left: ' center['left'] + 'px');
        }
        else if( 
dir == 'h' )
        {
            $(
elem).setStyle('left: ' center['left'] + 'px');
        }
        else if( 
dir == 'v' )
        {
            $(
elem).setStyle('top: ' center['top'] + 'px');
        }
        
        $(
elem).setStyle('position: fixed');
    },
    
showModal: function()
    {
        if( !$(
'ipb_modal') )
        {
            
this.createModal();
        }
        
this.modal.show();
    },
    
hideModal: function()
    {
        if( !$(
'ipb_modal') ){ return; }
        
this.modal.hide();        
    },
    
createModal: function()
    {
        
this.modal = new Element('div', { id'ipb_modal' } ).hide().addClassName('modal');
        
this.modal.setStyle("width: 100%; height: 100%; position: fixed; top: 0px; left: 0px; overflow: hidden; z-index: 1000; opacity: 0.2");
        $(
'ipboard_body').insert({bottomthis.modal});
    },
    
editorInsert: function( contenteditorid )
    {
        
// If no editor id supplied, lets use the first one
        
if( !editorid )    {
            var 
editor ipb.textEditor.getEditor();
        } else {
            var 
editor ipb.textEditor.getEditor(editorid);
        }
        
        if( 
Object.isUndefinededitor ) )
        {
            
/* Get current */
            
var editor ipb.textEditor.getEditor();
        }
        
        
editor.insertcontent );
    }
});

/* ===================================================================================================== */
/* IPB3 Delegation manager */
/* Simple class that allows us to specify css selectors and an associated function to run */
/* when an appropriate element is clicked */

IPBoard.prototype.delegate = {
    
store$A(),
    
    
initialize: function()
    {
        
document.observe('click', function(e){

            if( 
Event.isLeftClick(e) || Prototype.Browser.IE || ipb.vars['is_touch'] ) // IE doesnt provide isLeftClick info for click event, touch devices either
            
{
                var 
elem null;
                var 
handler null;
            
                var 
target ipb.delegate.store.find( function(item){
                    
elem e.findElementitem['selector'] );
                    if( 
elem ){
                        
handler item;
                        return 
true;
                    } else {
                        return 
false;
                    }
                });
            
                if( !
Object.isUndefinedtarget ) )
                {                
                    if( 
handler )
                    {
                        
Debug.write("Firing callback for selector " handler['selector'] );
                        
handler['callback']( eelemhandler['params'] );
                    }
                }
            }
        });
    },
    
    
register: function( selectorcallbackparams )
    {
        
ipb.delegate.store.push( { selectorselectorcallbackcallbackparamsparams } );
    }
};

/* ===================================================================================================== */
/* IPB3 Cookies */

/* Meow */
IPBoard.prototype.Cookie = {
    
store: [],
    
initDonefalse,
    
    
set: function( namevaluesticky )
    {
        var 
expires '';
        var 
path '/';
        var 
domain '';
        
        if( !
name )
        {
            return;
        }
        
        if( 
sticky )
        {    
            if( 
sticky == )
            {
                
expires "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
            }
            else if( 
sticky == -// Delete
            
{
                
expires "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
            }
            else if( 
sticky.length 10 )
            {
                
expires "; expires=" sticky;
            }
        }
        if( 
ipb.vars['cookie_domain'] )
        {
            
domain "; domain=" ipb.vars['cookie_domain'];
        }
        if( 
ipb.vars['cookie_path'] )
        {
            
path ipb.vars['cookie_path'];
        }
        
        
document.cookie ipb.vars['cookie_id'] + name "=" escapevalue ) + "; path=" path expires domain ';';
        
        
ipb.Cookie.storename ] = value;
        
        
Debug.write"Set cookie: " ipb.vars['cookie_id'] + name "=" value "; path=" path expires domain ';' );
    },
    
get: function( name )
    {
        
/* Init done yet? */
        
if ( ipb.Cookie.initDone !== true )
        {
            
ipb.Cookie.init();
        }
        
        if( 
ipb.Cookie.storename ] )
        {
            return 
ipb.Cookie.storename ];
        }
        
        return 
'';
    },
    
doDelete: function( name )
    {
        
Debug.write("Deleting cookie " name);
        
ipb.Cookie.setname'', -);
    },
    
init: function()
    {
        
// Already init?
        
if ( ipb.Cookie.initDone )
        {
            return 
true;
        }
        
        
// Init cookies by pulling in document.cookie
        
skip = ['session_id''ipb_admin_session_id''member_id''pass_hash'];
        
cookies $Hdocument.cookie.replace(" "'').toQueryParams(";") );
    
        if( 
cookies )
        {
            
cookies.each( function(cookie){
                
cookie[0] = cookie[0].strip();
                
                if( 
ipb.vars['cookie_id'] != '' )
                {
                    if( !
cookie[0].startsWithipb.vars['cookie_id'] ) )
                    {
                        return;
                    }
                    else
                    {
                        
cookie[0] = cookie[0].replaceipb.vars['cookie_id'], '' );
                    }
                }
                
                if( 
skipcookie[0] ] )
                {
                    return;
                }
                else
                {
                    
ipb.Cookie.storecookie[0] ] = unescapecookie[1] || '' );
                    
Debug.write"Loaded cookie: " cookie[0] + " = " cookie[1] );
                }                
            });
        }
        
        
ipb.Cookie.initDone true;    
    }
};

/* ===================================================================================================== */
/* Form validation */

IPBoard.prototype.validate = {
    
// Checks theres actually a value
    
isFilled: function( elem )
    {
        if( !$( 
elem ) ){ return null; }
        return !
$F(elem).blank();
    },
    
isNumeric: function( elem )
    {
        if( !$( 
elem ) ){ return null; }
        return 
$F(elem).match( /^[d]+?$/ );
    },
    
isMatching: function( elem1elem2 )
    {
        if( !$( 
elem1 ) || !$( elem2 ) ){ return null; }
        return 
$F(elem1) == $F(elem2);
    },
    
email: function( elem )
    {
        if( !$( 
elem ) ){ return null; }
        if( 
$Felem ).match( /^.+@.+..{2,4}$/ ) ){
            return 
true;
        } else {
            return 
false;
        }
    }
};

/* ===================================================================================================== */
/* AUTOCOMPLETE */

IPBoard.prototype.Autocomplete = Class.create( {
    
    
initialize: function(idoptions)
    {
        
this.id = $( id ).id;
        
this.timer null;
        
this.last_string '';
        
this.internal_cache $H();
        
this.pointer 0;
        
this.items $A();
        
this.observing true;
        
this.objHasFocus null;
        
this.options Object.extend({
            
min_chars3,
            
multiboxfalse,
            
global_cachefalse,
            
goToUrlfalse,
            
classname'ipb_autocomplete',
            
templates:     { 
                            
wrap: new Template("<ul id='#{id}'></ul>"),
                            
item: new Template("<li id='#{id}' data-url='#{url}'>#{itemvalue}</li>")
                        }
        }, 
arguments[1] || {});
        
        
//-----------------------------------------
        
        
if( !$( this.id ) ){
            
Debug.error("Invalid textbox ID");
            return 
false;
        }
        
        
this.obj = $( this.id );
        
        if( !
this.options.url )
        {
            
Debug.error("No URL specified for autocomplete");
            return 
false;
        }
        
        $( 
this.obj ).writeAttribute('autocomplete''off');
        
        
this.buildList();
        
        
// Observe keypress
        
$( this.obj ).observe('focus'this.timerEventFocus.bindAsEventListenerthis ) );
        $( 
this.obj ).observe('blur'this.timerEventBlur.bindAsEventListenerthis ) );
        $( 
this.obj ).observe('keypress'this.eventKeypress.bindAsEventListenerthis ) );
    },
    
    
eventKeypress: function(e)
    {    
        if( ![ 
Event.KEY_TABEvent.KEY_UPEvent.KEY_DOWNEvent.KEY_LEFTEvent.KEY_RIGHTEvent.KEY_RETURN ].include( e.keyCode ) ){
            return; 
// Not interested in anything else
        
}
        
        
// & and up key are both keycode 38. So if we're holding shift, ignore this
        
console.loge.shiftKey );
        if ( 
e.shiftKey === true ) {
            return;
        }
        
        if( $( 
this.list ).visible() )
        {
            switch( 
e.keyCode )
            {
                case 
Event.KEY_TAB:
                case 
Event.KEY_RETURN:
                    
this.selectCurrentItem(e);
                break;
                case 
Event.KEY_UP:
                case 
Event.KEY_LEFT:
                    
this.selectPreviousItem(e);
                break;
                case 
Event.KEY_DOWN:
                case 
Event.KEY_RIGHT:
                    
this.selectNextItem(e);
                break;
            }
            
            
Event.stop(e);
        }
    },
    
    
// MOUSE & KEYBOARD EVENT
    
selectCurrentItem: function(e)
    {
        var 
current = $( this.list ).down('.active');
        
this.unselectAll();
        
        if( !
Object.isUndefinedcurrent ) )
        {
            var 
itemid = $( current ).id.replacethis.id '_ac_item_''');
            if( !
itemid ){ return; }
            
            
// Go to URL?
            
if( this.options.goToUrl && $( current ).readAttribute('data-url') )
            {
                
window.location = $( current ).readAttribute('data-url');
                return 
false;
            }

            
// Get value
            
var value this.itemsitemid ]
                .
replace('&amp;''&')
                .
replace( /&#39;/g, "'" )
                
.replace( /&gt;/g'>' )
                .
replace( /&lt;/g'<' )
                .
replace( /&#33;/g, '!' );

            
if( this.options.multibox )
            {
                
// some logic to get current name
                
if( $Fthis.obj ).indexOf(',') !== -)
                {
                    var 
pieces $Fthis.obj ).split(',');
                    
piecespieces.length ] = '';

                    $( 
this.obj ).value pieces.join(',') + ' ';
                }
                else
                {
                    $( 
this.obj ).value '';
                    $( 
this.obj ).focus();
                }
                
                $( 
this.obj ).value $Fthis.obj ) + value ', ';
            }
            else
            {
                $( 
this.obj ).value value;
                
                var 
effect = new Effect.Fade( $(this.list), { duration0.3 } );
                
//this.observing = false;
            
}    
        }
        
        $( 
this.obj ).focus();
        
        
/* Stop cursor jumping back when adding input */
        
if ( Prototype.Browser.IE )
        {
            if ( $( 
this.obj ).createTextRange )
            {
                var 
= $( this.obj ).createTextRange();
                
r.moveStart("character", $( this.obj ).value.length);
                
r.select();
            }
        }
    },
    
    
// MOUSE EVENT
    
selectThisItem: function(e)
    {
        
this.unselectAll();
        
        var 
items = $( this.list ).immediateDescendants();
        var 
elem Event.element(e);
        
        
// Find the element
        
while( !items.include( elem ) )
        {
            
elem elem.up();
        }
        
        $( 
elem ).addClassName('active');
    },
    
    
// KEYBOARD EVENT
    
selectPreviousItem: function(e)
    {
        var 
current = $( this.list ).down('.active');
        
this.unselectAll();
        
        if( 
Object.isUndefinedcurrent ) )
        {
            
this.selectFirstItem();
        }
        else
        {
            var 
prev = $( current ).previous();
            
            if( 
prev ){
                $( 
prev ).addClassName('active');
            }
            else
            {
                
this.selectLastItem();
            }
        }
    },
    
    
// KEYBOARD EVENT
    
selectNextItem: function(e)
    {
        
// Get the current item
        
var current = $( this.list ).down('.active');
        
this.unselectAll();
        
        if( 
Object.isUndefinedcurrent ) ){
            
this.selectFirstItem();
        }
        else
        {
            var 
next = $( current ).next();
            
            if( 
next ){
                $( 
next ).addClassName('active');
            }
            else
            {
                
this.selectFirstItem();
            }
        }
    },
    
    
// INTERNAL CALL
    
selectFirstItem: function()
    {
        if( !$( 
this.list ).visible() ){ return; }
        
this.unselectAll();
        
        $( 
this.list ).firstDescendant().addClassName('active');
    },
    
    
// INTERNAL CALL
    
selectLastItem: function()
    {
        if( !$( 
this.list ).visible() ){ return; }
        
this.unselectAll();
        
        var 
= $( this.list ).immediateDescendants();
        var 
dd.length -];
        
        if( 
)
        {
            $( 
).addClassName('active');
        }
    },
    
    
unselectAll: function()
    {
        $( 
this.list ).childElements().invoke('removeClassName''active');
    },
    
    
// Ze goggles are blurry!
    
timerEventBlur: function(e)
    { 
        
window.clearTimeoutthis.timer );
        
this.eventBlur.bind(this).delay0.6);
    },
    
    
// Phew, ze goggles are focussed again
    
timerEventFocus: function(e)
    {
        
this.timer this.eventFocus.bind(this).delay(0.4e);
    },
    
    
eventBlur: function(e)
    {
        
this.objHasFocus false;
        
        if( $( 
this.list ).visible() )
        {
            var 
effect = new Effect.Fade( $(this.list), { duration0.3 } );
        }
    },
    
    
eventFocus: function(e)
    {
        if( !
this.observing ){ Debug.write("Not observing keypress"); return; }
        
this.objHasFocus true;
        
        
// Keep loop going
        
this.timer this.eventFocus.bind(this).delay(0.6e);
        
        var 
curValue this.getCurrentName();
        if( 
curValue == this.last_string ){ return; }
        
        if( 
curValue.length this.options.min_chars ){
            
// Hide list if necessary
            
if( $( this.list ).visible() )
            {
                var 
effect = new Effect.Fade( $( this.list ), { duration0.3afterFinish: function(){ $( this.list ).update(); }.bind(this) } );
            }
            
            return;
        }
        
        
this.last_string curValue;
        
        
// Cached?
        
json this.cacheReadcurValue );
        
        if( 
json == false ){
            
// No results yet, get them
            
var request = new Ajax.Requestthis.options.url encodeURIComponentcurValue ),
                                {
                                    
method'get',
                                    
evalJSON'force',
                                    
onSuccess: function(t)
                                    {
                                        if( 
Object.isUndefinedt.responseJSON ) )
                                        {
                                            
// Well, this is bad.
                                            
Debug.error("Invalid response returned from the server");
                                            return;
                                        }
                                        
                                        if( 
t.responseJSON['error'] )
                                        {
                                            switch( 
t.responseJSON['error'] )
                                            {
                                                case 
'requestTooShort':
                                                    
Debug.warn("Server said request was too short, skipping...");
                                                break;
                                                default:
                                                    
Debug.error("Server returned an error: " t.responseJSON['error']);
                                                break;
                                            }
                                            
                                            return 
false;
                                        }
                                        
                                        if( 
t.responseText != "[]" )
                                        {
                                        
                                            
// Seems to be OK!
                                            
this.cacheWritecurValuet.responseJSON );
                                            
this.updateAndShowt.responseJSON );
                                        }
                                    }.
bindthis )
                                }
                            );
        }
        else
        {
            
this.updateAndShowjson );
        }
        
        
//Debug.write( curValue );
    
},
    
    
updateAndShow: function( json )
    {
        if( !
json ){ return; }
        
        
this.updateListjson );

        if( !$( 
this.list ).visible() && this.objHasFocus )
        {
            
Debug.write("Showing");
            var 
effect = new Effect.Appear( $( this.list ), { duration0.3afterFinish: function(){ this.selectFirstItem(); }.bind(this) } );
        }
    },
    
    
cacheRead: function( value )
    {
        if( 
this.options.global_cache != false )
        {
            if( !
Object.isUndefinedthis.options.global_cache.getvalue ) ) ){
                
Debug.write("Read from global cache");
                return 
this.options.global_cache.getvalue );
            }
        }
        else
        {
            if( !
Object.isUndefinedthis.internal_cache.getvalue ) ) ){
                
Debug.write("Read from internal cache");
                return 
this.internal_cache.getvalue );
            }
        }
        
        return 
false;
    },
    
    
cacheWrite: function( keyvalue )
    {
        if( 
this.options.global_cache !== false ){
            
this.options.global_cache.setkeyvalue );
        } else {
            
this.internal_cache.setkeyvalue );
        }
        
        return 
true;
    },
    
    
getCurrentName: function()
    {
        if( 
this.options.multibox )
        {
            
// some logic to get current name
            
if( $Fthis.obj ).indexOf(',') === -){
                return 
$Fthis.obj ).strip();
            }
            else
            {
                var 
pieces $Fthis.obj ).split(',');
                var 
lastPiece piecespieces.length ];
                
                return 
lastPiece.strip();
            }
        }
        else
        {
            return 
$Fthis.obj ).strip();
        }
    },
    
    
buildList: function()
    {
        if( $( 
this.id '_ac' ) )
        {
            return;
        }
        
        var 
finalPos = {};
        
        
// Position menu to keep it on screen
        
var sourcePos = $( this.id ).viewportOffset();
        var 
sourceDim = $( this.id ).getDimensions();
        var 
delta = [0,0];
        var 
parent null;
        var 
screenScroll document.viewport.getScrollOffsets();

        var 
ul this.options.templates.wrap.evaluate({ idthis.id '_ac' });
        
        
/* In a modal pop up? */
        
var test = $( this.id ).up('.popupWrapper');
        
        if ( ! 
Object.isUndefinedtest ) && test.getStyle('position') == 'fixed' )
        {
            $(
this.id).up().insert( {bottomul} );
            
            
parent = $( this.id ).getOffsetParent();
            
delta = [ parseIntparent.getStyle('left') / ), parseIntparent.getStyle('top') / ) ];
            
            
finalPos['left'] = delta[0];
            
finalPos['top'] = delta[1] + screenScroll.top;
                    
            
/* Make it appear over */
            
$( this.id '_ac' ).setStyle( { 'zIndex'10002 } );
        }
        else
        {
            $$(
'body')[0].insert( {bottomul} );
            
            if ( 
Element.getStyle( $( this.id ), 'position') == 'absolute')
            {
                
parent = $( this.id ).getOffsetParent();
                
delta = [ parseIntparent.getStyle('left') ), parseIntparent.getStyle('top') ) ];
            }
    
            
finalPos['left'] = sourcePos[0] - delta[0];
            
finalPos['top'] = sourcePos[1] - delta[1] + screenScroll.top;
        }
        
        
// Now try and keep it on screen
        
finalPos['top'] = finalPos['top'] + sourceDim.height;
        
        $( 
this.id '_ac' ).setStyle('position: absolute; top: ' finalPos['top'] + 'px; left: ' finalPos['left'] + 'px;').hide();
        
        
        
this.list = $( this.id '_ac' );
    },
    
    
updateList: function( json )
    {    
        if( !
json || !$( this.list ) ){ return; }
    
        var 
newitems ='';
        
this.items $A();
        
        
json $Hjson );
        
        
json.each( function( item )
            {        
                var 
li this.options.templates.item.evaluate({ idthis.id '_ac_item_' item.key,
                                                                 
itemiditem.key,
                                                                 
itemvalueitem.value['showas'] || item.value['name'],
                                                                 
imgitem.value['img'] || '',
                                                                
img_witem.value['img_w'] || '',
                                                                
img_hitem.value['img_h'] || '',
                                                                
urlitem.value['url'] || ''
                                                            
});
                
this.itemsitem.key ] = item.value['name'];
    
                
newitems newitems li;
            }.
bind(this)
        );
        
        $( 
this.list ).updatenewitems );
        $( 
this.list ).immediateDescendants().each( function(elem){
            $( 
elem ).observe('mouseover'this.selectThisItem.bindAsEventListener(this));
            $( 
elem ).observe('click'this.selectCurrentItem.bindAsEventListener(this));
            $( 
elem ).setStyle('cursor: pointer');
        }.
bind(this));
        
        if( $( 
this.list ).visible() )
        {
            
this.selectFirstItem();
        }
    }
});

/* ===================================================================================================== */
/* Extended objects */

// Extend RegExp with escape
Object.extendRegExp, { 
    
escape: function(text)
    {
        if (!
arguments.callee.sRE)
        {
               var 
specials = [ '/''.''*''+''?''|''('')''['']''{''}''\', '$' ];
               //arguments.callee.sRE = new RegExp( '
(\' + specials.join('|\') + ')' ); // IMPORTANT: dont use g flag
               arguments.callee.sRE = new RegExp( '
(\' + specials.join('|\') + ')', 'g' );
        }
        return text.replace(arguments.callee.sRE, '
\$1');
    }
});

// Extend String with URL UTF-8 escape
String.prototype.encodeUrl = function()
{
        text = this;
        var regcheck = text.match(/[x90-xFF]/g);
        
        if ( regcheck )
        {
            for (var i = 0; i < regcheck.length; i++)
            {
                //text = text.replace(regcheck[i], '
%u00' + (regcheck[i].charCodeAt(0) & 0xFF).toString(16).toUpperCase());
            }
        }
    
        return escape(text).replace(/+/g, "%2B").replace(/%20/g, '
+').replace(/*/g, '%2A').replace(///g, '%2F').replace(/@/g, '%40');
};

// Extend String with URL UTF-8 escape - duplicated so it can be changed from above
String.prototype.encodeParam = function()
{
        text = this;
        var regcheck = text.match(/[x90-xFF]/g);

        if ( regcheck )
        {
            for (var i = 0; i < regcheck.length; i++)
            {
                //text = text.replace(regcheck[i], '
%u00' + (regcheck[i].charCodeAt(0) & 0xFF).toString(16).toUpperCase());
            }
        }
        
        /* Return just text as it is then encoded by prototype lib */
        return escape(text).replace(/+/g, "%2B");
};


// Extend Date object with a function to check for DST
Date.prototype.getDST = function()
{
    var beginning    = new Date( "January 1, 2008" );
    var middle        = new Date( "July 1, 2008" );
    var difference    = middle.getTimezoneOffset() - beginning.getTimezoneOffset();
    var offset        = this.getTimezoneOffset() - beginning.getTimezoneOffset();
    
    if( difference != 0 )
    {
        /* Hemisphere check */
        if ( difference < 0 )
        {
            /* Northern */
            return (difference == offset) ? 1 : 0;
        }
        else
        {
            /* Southern */
            return (difference != offset) ? 1 : 0;
        }
    }
    else
    {
        return 0;
    }
};

/* ==================================================================================================== */
/* IPB3 JS Loader */

var Loader = {
    require: function( name )
    {
        document.write("<script type='
text/javascript' src='" + name + ".js'></script>");
    },
    boot: function()
    {
        $A( document.getElementsByTagName("script") ).findAll(
            function(s)
            {
                  return (s.src && s.src.match(/ipb.js(?.*)?$/));
            }
        ).each( 
            function(s) {
                  var path = s.src.replace(/ipb.js(?.*)?$/,'');
                  var includes = s.src.match(/?.*load=([a-zA-Z0-9_,]*)/);
                if( ! Object.isUndefined(includes) && includes != null && includes[1] )
                {
                    includes[1].split('
,').each(
                        function(include)
                        {
                            if( include )
                            {
                                Loader.require( path + "ips." + include );
                            }
                        }
                    );
                }
            }
        );
    }
};
var callback = { 
    afterOpen: function( popup ){
        try {
            $( '
pj_' + $(elem).identify() + '_input').activate();
        }
        catch(err){ }
    }
};

/* ==================================================================================================== */
/* ELEMENT EXTENSIONS (tooltips, authorpane etc.) */

Element.addMethods( {
    
    defaultize: function( element, lang )
    {
        if( ipb.global._supportsPlaceholder == null ){
            ipb.global._supportsPlaceholder = (function(){
                var i = document.createElement('
input');
                return '
placeholder' in i;
            })();
        }
    
        if( ipb.global._supportsPlaceholder ){
            if( $F( element ) == lang || $F( element ).empty() ){
                $(element).removeClassName('
inactive').writeAttribute('placeholder', lang).value = '';
            }
        } else {
            if( $F( element ) == lang || $F( element ).empty() ){
                $(element).addClassName('
inactive').value = lang;
            }
        
            $(element).observe('
focus', function(e){
                if( $(element).hasClassName('
inactive') && ( $F(element) == '' || $F(element) == lang ) ){
                    $(element).removeClassName('
inactive').value = '';
                } else {
                    $(element).removeClassName('
inactive');
                }
            }).
            observe('
blur', function(e){
                if( $F(element).empty() ){
                    $(element).addClassName('
inactive').value = lang;
                }
            });
            
            // Try and find a form around the element
            var form = $( element ).up('
form');
            if( !Object.isUndefined( form ) ){
                $( form ).observe('
submit', function(e){
                    if( $(element).hasClassName('
inactive') ){
                        $(element).value = '';
                    }
                });
            }
        }    
    },
    
    clickLaunch: function( element )
    {
        var _callback = $( element ).readAttribute("data-clicklaunch");
        var _scope    = '
global';
        
        try {
            var _try = $( element ).readAttribute("data-scope");
            _scope = ( _try ) ? _try.replace("ipb.", '') : _scope;
        } catch(e) { };
        
        if( $(element).retrieve('
clickevent') ){
            try {
                 $(element).retrieve('
clickevent').stop();
            } catch(err){ };
        }
        
        var click = $(element).on( '
click', function(e) {
                                                Event.stop(e);
                                                ipb[_scope][_callback]( element, e);
                                            } );
        $(element).store('
clickevent', click);
    },
    
    confirmAction: function( element )
    {
        var _text     = $( element ).readAttribute("data-confirmaction");
        var _ok       = '';
        
        if ( element.tagName == '
FORM' )
        {
            _ok = "$('" + element.id +"').submit()";
        }
        else
        {
            _ok =  '
window.location='' element.readAttribute'href' ) + ''';
        }
    
        if ( ! _text || _text == '
true' )
        {
            _text = ipb.lang['
gbl_confirm_desc'];
        }
        
        var _options = { type: '
pane',
                         modal: true,
                         /* Inline JS makes it easier even if it is uglier */
                          initial: '
<div><h3>' + ipb.lang['gbl_confirm_text'] + '</h3><div class="ipsPad ipsForm_center"><p>' + _text + '</p><br /><span onclick="ipb.global.popups['conact'].hide()" class="clickable ipsButton_secondary important">' + ipb.lang['gbl_confirm_cancel'] + '</span> &nbsp; <span onclick="' + _ok + '" class="clickable ipsButton_secondary">' + ipb.lang['gbl_confirm_ok'] + '</span></div>',
                          hideAtStart: false,
                         w: '
300px',
                          h: 150 };
        
        if ( element.tagName == '
FORM' )
        {
            /* Fire immediately */
            if ( ! Object.isUndefined( ipb.global.popups['
conact'] ) )
            {
                ipb.global.popups['
conact'].kill();
            }
            
            ipb.global.popups['
conact'] = new ipb.Popup( 'confirm', _options  );
        }
        else 
        {
            $(element).on( '
click', function(e)
            {
                Event.stop(e);
                
                if ( ! Object.isUndefined( ipb.global.popups['
conact'] ) )
                {
                    ipb.global.popups['
conact'].kill();
                }
                
                ipb.global.popups['
conact'] = new ipb.Popup( 'confirm', _options );
            
            } );
        }
    },
    
    tooltip: function( element, options ){
        
        options = Object.extend( {
            template: new Template("<div class='
ipsTooltip' id='#{id}' style='display: none'><div class='ipsTooltip_inner'>#{content}</div></div>"),
            
position'auto',
            
content: $( element ).readAttribute("data-tooltip"),
            
animatetrue,
            
overrideBrowsertrue,
            
delay0.4
        
}, options);
        
        var 
show = function(e){
            if( 
options.delay && !options._still_going ){
                return; 
// Action has been cancelled
            
}
            
            
// Don't show if empty. Bug #36247 Tooltips
            
if( ! options.content ){
                return;
            }        
            
            var 
id = $(element).identify();

            if( !$( 
id '_tooltip' ) ){
                $( 
document.body ).insert({ 'bottom'options.template.evaluate({ 'id'id '_tooltip''content'options.content }) } );
            }

            if( 
options.overrideBrowser && $(element).hasAttribute('title') ){
                $(
element).writeAttribute("data-title", $(element).readAttribute('title')).writeAttribute("title"false);
            }

            var 
tooltip = $(id '_tooltip').setStyle({position'absolute'});
            
            
// Add word wrap for calculations
            //$(tooltip).setStyle('white-space: nowrap');
            
            
var layout = $(element).getLayout();
            var 
position = $(element).cumulativeOffset();
            var 
dims = $( id '_tooltip' ).getDimensions();
            var 
docDim = $( document.body ).getLayout();
            
            
// Detect best position for tooltip
            
if( options.position == 'auto' ){
                if( 
position.left + (layout.get('padding-box-width')/2) - (dims.width/2) < ){
                    
options.position 'right';
                } else if( 
position.left + (dims.width/2) > docDim.get('width') ){
                    
options.position 'left';
                } else {
                    
options.position 'top';
                }                
            }
            
            
Debug.writedims );
            
            
// And now position
            
switch( options.position ){
                case 
'top':
                    $(
tooltip).setStyle( { top: (position.top dims.height 1) + 'px'left: (position.left + (layout.get('padding-box-width')/2) - (dims.width/2)) + 'px' } ).addClassName('top');
                break;
                case 
'bottom':
                    $(
tooltip).setStyle( { top: (position.top layout.get('padding-box-height') + 1) + 'px'left: (position.left + (layout.get('padding-box-width')/2) - (dims.width/2)) + 'px' } ).addClassName('bottom');
                break;
                case 
'left':
                    $(
tooltip).setStyle( { top: (position.top - (layout.get('padding-box-height') / 2)) + 'px'left: (position.left dims.width -  3) + 'px' }).addClassName('left');
                break;
                case 
'right':
                    $(
tooltip).setStyle( { top: (position.top - (layout.get('padding-box-height') / 2)) + 'px'left: (position.left layout.get('padding-box-width') - 3) + 'px' }).addClassName('right');
                break;
            }
            
            
// Remove word wrap
            //$(tooltip).setStyle('white-space: normal');

            
if( options.animate ){
                new 
Effect.Appear( $(tooltip), { duration0.3queue'end' } );
            } else {
                $(
tooltip).show();
            }
        },
        
hide = function(e){
            var 
id = $(element).identify();
            if( !$(
id '_tooltip') ){ return; }
            
            if( 
options.animate ){
                new 
Effect.Fade( $(id '_tooltip'), { duration0.2queue'end' });
            } else {
                $(
id '_tooltip').hide();
            }
        };
        
        $( 
element ).observe("mouseenter", function(e){
            if( 
options.delay ){
                
options._still_going true;
                
show.delayoptions.delay);
            } else {
                
show(e);
            }
        }).
        
observe("click", function(e){
            
options._still_going false;
            
hide();
        }).
        
observe("mouseleave", function(e)
        {
            
options._still_going false;
            
hide();                
        });    
    }
});

/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.global.js - Global functionality            */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                        */
/************************************************/

var _global window.IPBoard;

_global.prototype.global = {
    
searchTimer: [],
    
searchLastQuery'',
    
rssItems: [],
    
reputation: {},
    
popups: {},
    
ac_cache$H(),
    
pageJumps$H(),
    
pageJumpMenus$H(),
    
boardMarkers$H(),
    
searchResults$H(),
    
tidPopOpen0,
    
activeTab'forums',
    
userCardsnull,
    
inlineNotification: { timers: [] },
    
_supportsPlaceholdernull,
    
    
/*------------------------------*/
    /* Constructor                     */
    
init: function()
    {
        
Debug.write("Initializing ips.global.js");
        
        
document.observe("dom:loaded", function(){
            
ipb.global.initEvents();
        });
    },
    
initEvents: function()
    {
        
// Delegate our user popup links/warn logs
        
ipb.delegate.register(".warn_link"ipb.global.displayWarnLogs);
        
ipb.delegate.register(".mini_friend_toggle"ipb.global.toggleFriend);
        
ipb.delegate.register(".__topic_preview"ipb.global.topicPreview);
        
ipb.delegate.register('.bbc_spoiler_show'ipb.global.toggleSpoiler);
        
ipb.delegate.register('a[rel~="external"]'ipb.global.openNewWindow );
        
ipb.delegate.register('._repLikeMore'ipb.global.repLikeMore);
        
ipb.delegate.register('a[rel~="quickNavigation"]'ipb.global.openQuickNavigation );
        
        if( $(
'sign_in') && !$('sign_in').hasClassName('no_ajax') ){
            $(
'sign_in').on('click'ipb.global.inlineSignin);
        }
        
        if( $(
'rss_feed') ){
            
ipb.global.buildRSSmenu();
        }
        
        if ( ! 
Object.isUndefinedipb.vars['notificationData'] ) )
        {
            new 
ipb.Popup'navigation_popup', { type'modal',
                                                  
initialipb.templates['notificationTemplate'].evaluateipb.vars['notificationData'] ),
                                                  
hideAtStartfalse,
                                                 
w'600px',
                                                  
h250} );
        }
        
        
/* This is needed for RTL - the generic anchoring isn't working on RTL for some reason */
        
if( $('backtotop') ){
            $(
'backtotop').observe"click", function(e){ Event.stop(e); window.scroll0); } );
        }
        
        
ipb.global.buildPageJumps();        
        
ipb.global.initUserCards();
        
        
/* Got an inline notification? */
        
if ( ! Object.isUndefinedipb.templates['inlineMsg'] ) && ipb.templates['inlineMsg'] != '' ){
            
ipb.global.showInlineNotificationipb.templates['inlineMsg'] );
        }
        
        
// Contextual search
        
if( $('search-box') ){
            
ipb.global.contextualSearch();
        }
        
        
// Global menus
        
if( $('user_link') ){
            new 
ipb.Menu( $('user_link'), $('user_link_menucontent') );
        }
        
        if( $(
'new_skin') ){
            new 
ipb.Menu( $('new_skin'), $('new_skin_menucontent') );
        }

        if( $(
'new_language') ){
            new 
ipb.Menu( $('new_language'), $('new_language_menucontent') );
        }

        if( $(
'mark_all_read') ){
            new 
ipb.Menu( $('mark_all_read'), $('mark_all_read_menucontent') );
        }
        
        
// Tooltips
        
$$("[data-tooltip]").invoke('tooltip');
        
        
// General click handlers
        
$$("[data-clicklaunch]").invoke('clickLaunch');
        
        
// Confirm action used in delete, etc
        
$$("[data-confirmaction]").invoke('confirmAction');
         
        
// Status updates
        
if( $('statusUpdateGlobal') ){
            $(
'statusUpdateGlobal').defaultizeipb.lang['global_status_update'] );
            
            $(
'statusSubmitGlobal').observe'click'ipb.global.statusUpdated );
        }
        
        
/* Attachments wrapped in URL @link http://community.invisionpower.com/tracker/issue-37113-linking-image-attachments-does-not-work/ */
        
$$('a.resized_img').each( function( elem )
        {
            if ( $(
elem).previous('a.bbc_url') )
            {
                var 
test = $(elem).previous('a.bbc_url');
                
                if ( ! 
test.innerHTML.length )
                {
                    $(
elem).writeAttribute'href'test.href );
                    $(
elem).writeAttribute'rel',  test.rel );
                    
                    
/* Remove empty href */
                    
test.remove();
                }
            }
        } );
        
        
/* Tag show more */
        
if ( ! Object.isUndefinedipb.hoverCard ) && ipb.vars['is_touch'] === false )
        {
            var 
ajaxUrl ipb.vars['base_url'] + "app=core&module=ajax&section=tags&do=getTagsAsPopUp&md5check="+ipb.vars['secure_hash'];
            
            
ipb.hoverCardRegister.initialize'tagsPopUp', { 'w''500px''delay'750'position''auto''ajaxUrl'ajaxUrl'getId'true'setIdParam''key' } );
        }
    },
    
    
/* Lightbox has been disabled */
    
lightBoxIsOff: function()
    {
        $$(
'span[rel*="lightbox"]').each( function( elem )
        {
            if ( ! $(
elem).down('a') )
            {
                $(
elem).down('img').on'click', function(eel) { window.open(el.src) } );
            }
        } );
    },
    
    
/* Stores default values of status share checkboxes */
    
saveSocialShareDefaults: function( elem)
    {
        var 
services = {};
        
        
/* Gather elements */
        
$$('._share_x_').each( function(elem){
            
serviceselem.id.replace(/share_x_/, '' ) ] = ( elem.checked ) ? 0;
        } );
        
        new 
Ajax.Requestipb.vars['base_url'] + "app=core&section=sharelinks&module=ajax&do=savePostPrefs&md5check=" ipb.vars['secure_hash'],
                {
                    
method'post',
                    
evalJSON'force',
                    
parametersservices,
                    
onSuccess: function(t)
                    {
                        if ( 
Object.isUndefinedt.responseJSON ) )
                        {
                            
alertipb.lang['action_failed'] );
                            return;
                        }
                        
                        if ( ! 
Object.isUndefinedt.responseJSON['error'] ) )
                        {
                            
alertt.responseJSON['error'] );
                        }
                        else
                        {
                            
/* Nothing to do */
                        
}
                    }
                });
    },
    
    
/*!! statusUpdated */
    /* Updates a status where ever you are on the page. Differs from the ipb.status version slightly */
    
statusUpdated: function(e)
    {
        
Event.stop(e);
        
        if ( $(
'statusUpdateGlobal' ).value.length || $('statusUpdateGlobal').value == ipb.lang['prof_update_default'] )
        {
            return 
false;
        }
        
        
// Bug #34650: Commented this out so that board index updates
        // use the ajax function defined below instead of the main status function
        /* Main status library loaded? */
        /*if ( ! Object.isUndefined( ipb.status ) )
        {
            return ipb.status.updateSubmit( e, 'statusUpdateGlobal' );
        }*/
        
        
var su_Twitter  = $('su_TwitterGlobal') && $('su_TwitterGlobal').checked 1  0;
        var 
su_Facebook = $('su_FacebookGlobal') && $('su_FacebookGlobal').checked 0;
        
        new 
Ajax.Requestipb.vars['base_url'] + "app=members&section=status&module=ajax&do=new&md5check=" ipb.vars['secure_hash'] + "&skin_group=boards&return=json&smallSpace=1",
                        {
                            
method'post',
                            
evalJSON'force',
                            
parameters: {
                                
content: $('statusUpdateGlobal' ).value.encodeParam(),
                                
su_Twittersu_Twitter,
                                
su_Facebooksu_Facebook
                            
},
                            
onSuccess: function(t)
                            {
                                if( 
Object.isUndefinedt.responseJSON ) )
                                {
                                    
alertipb.lang['action_failed'] );
                                    return;
                                }
                                
                                if ( 
t.responseJSON['error'] )
                                {
                                    
alertt.responseJSON['error'] );
                                }
                                else
                                {
                                    try {
                                        if ( $(
'status_wrapper') )
                                        {
                                            var 
memberId 0;
                                            
                                            try
                                            {
                                                
memberId = $('status_wrapper').readAttribute('data-member');
                                            }
                                            catch(
err){ }
                                            
                                            if ( ! 
memberId || ( memberId == ipb.vars['member_id'] ) )
                                            {
                                                $(
'status_wrapper').innerHTML t.responseJSON['html'] + $('status_wrapper').innerHTML;
                                                
                                                
/* Showing latest only? */
                                                
if ( ipb.status.myLatest )
                                                {
                                                    if ( $(
'statusWrap-' ipb.status.myLatest ) )
                                                    {
                                                        $(
'statusWrap-' ipb.status.myLatest ).hide();
                                                    }
                                                }
                                            }
                                        }
                                        
                                        
ipb.menus.closeAll(e,true);
                                        
ipb.global.showInlineNotificationipb.lang['status_updated'] );
                                        
                                    }
                                    catch(
err)
                                    {
                                        
Debug.error'Logging error: ' err );
                                    }
                                }
                            }
                        });
    },
    
    
/**
     * Changes the user's skin
     */
    
changeSkin: function(elemente)
    {
        
Debug.direlement );
        var 
skinId = $(element).readAttribute'data-skinid');
        
        var 
url ipb.vars['base_url'] + 'app=core&module=ajax&section=skin&do=change&skinId=' skinId '&secure_key=' ipb.vars['secure_hash'];
        
Debug.writeurl );
        new 
Ajax.Request(    url,
                            {
                                
method'get',
                                
onSuccess: function(t)
                                {
                                    
/*
                                     * Get an error?
                                     */
                                    
if( t.responseJSON['status'] == 'ok' )
                                    {
                                        
window.location window.location;
                                        
window.location.reload(true);
                                    }
                                    else
                                    {
                                        
ipb.global.errorDialogueipb.lang['ajax_failure'] );
                                    }
                                }
                            }
                        );
        
        
        
Event.stop(e);
        return 
false;
    },
    
    
/**
     * Displays the inbox drop down in header
     */
    
getInboxList: function(elemente)
    {
        
/*
         * Only run AJAX call once.  Cache and use the cache for subsequent requests.
         */
        
if ( Object.isUndefinedipb.global.popups['inbox'] ) )
        {
            
ipb.global.popups['inbox'] = true;
            
ipb.menus.closeAll(e);
            
            $(
element).identify();
            
            
/* Create pop-up wrapper */
            
$(element).addClassName('ipbmenu');
            
            $(
'ipboard_body').insertipb.templates['header_menu'].evaluate( { id'user_inbox_link_menucontent' } ) );
            
            $(
'user_inbox_link_menucontent').setStyle('width: 300px').update"<div class='ipsPad ipsForm_center'><img src='" ipb.vars['loading_img'] + "' /></div>" );
            
            var 
_newMenu = new ipb.Menu( $(element), $( "user_inbox_link_menucontent" ) );
            
_newMenu.doOpen();            
            
            var 
url ipb.vars['base_url'] + 'app=members&module=ajax&section=messenger&do=getInboxDropDown';
            
Debug.writeurl );
            new 
Ajax.Request(    url,
                                {
                                    
method'post',
                                    
evalJSON'force',
                                    
hideLoadertrue,
                                    
parameters: {
                                        
secure_key:     ipb.vars['secure_hash']
                                    },
                                    
onSuccess: function(t)
                                    {
                                        
/*
                                         * Get an error?
                                         */
                                        
if( t.responseJSON['error'] )
                                        {
                                            if ( 
t.responseJSON['__board_offline__'] )
                                            {
                                                
ipb.global.errorDialogueipb.lang['board_offline'] );
                                                
ipb.menus.closeAll(e);
                                            }
                                        }
                                        else
                                        {                                        
                                            $(
'user_inbox_link_menucontent').updatet.responseJSON['html'] );
                                            
                                            
/* Clear counter */
                                            
try
                                            {
                                                $(
element).down('.ipsHasNotifications').fade( { afterFinish: function() { $(element).down('.ipsHasNotifications').show().addClassName('ipsHasNotifications_blank'); } } );
                                            } catch( 
acold ) { }
                                        }
                                    }
                                }
                            );
        }
        
        
Event.stop(e);
        return 
false;
    },
    
    
/**
     * Displays the notifications drop down in header
     */
    
getNotificationsList: function(elemente)
    {
        
Event.stop(e);
        
        
/*
         * Only run AJAX call once.  Cache and use the cache for subsequent requests.
         */
        
if ( Object.isUndefinedipb.global.popups['notification'] ) )
        {
            
ipb.global.popups['notification'] = true;
            
            
ipb.menus.closeAll(e);
            
            $(
element).identify();
            
            
/* Create pop-up wrapper */
            
$(element).addClassName('ipbmenu');
            
            $(
'ipboard_body').insertipb.templates['header_menu'].evaluate( { id'user_notifications_link_menucontent' } ) );
            
            $(
'user_notifications_link_menucontent').setStyle('width: 300px').update"<div class='ipsPad ipsForm_center'><img src='" ipb.vars['loading_img'] + "' /></div>" );
            
            var 
_newMenu = new ipb.Menu( $(element), $( "user_notifications_link_menucontent" ) );
            
_newMenu.doOpen();
            
            var 
url ipb.vars['base_url'] + 'app=core&module=ajax&section=notifications&do=getlatest';
            
Debug.writeurl );
            
            new 
Ajax.Request(    url,
                                {
                                    
method'post',
                                    
evalJSON'force',
                                    
hideLoadertrue,
                                    
parameters: {
                                        
secure_key:     ipb.vars['secure_hash']
                                    },
                                    
onSuccess: function(t)
                                    {
                                        
/*
                                         * Get an error?
                                         */
                                        
if( t.responseJSON['error'] )
                                        {
                                            if ( 
t.responseJSON['__board_offline__'] )
                                            {
                                                
ipb.global.errorDialogueipb.lang['board_offline'] );
                                                
ipb.menus.closeAll(e);
                                            }
                                        }
                                        else
                                        {                                        
                                            $(
'user_notifications_link_menucontent').updatet.responseJSON['html'] );
                                            
                                            
/* Clear counter */
                                            
try
                                            {
                                                $(
element).down('.ipsHasNotifications').fade( { afterFinish: function() { $(element).down('.ipsHasNotifications').show().addClassName('ipsHasNotifications_blank'); } } );
                                            } catch( 
acold ) { }
                                        }
                                    }
                                }
                            );
        }
        
        
        return 
false;
    },

    
    
openQuickNavigation: function( )
    {
        
Event.stop(e);
        
        if( 
ipb.global.popups['quickNav'] ){
            
ipb.global.popups['quickNav'].show();
        } else {
            var 
url ipb.vars['base_url'] + "app=core&module=ajax&section=navigation&secure_key=" ipb.vars['secure_hash'] + "&inapp=" ipb.vars['active_app'];
            
ipb.global.popups['quickNav'] = new ipb.Popup'navigation_popup', { type'modal',
                                                 
ajaxURLurl,
                                                 
hideAtStartfalse,
                                                 
w'600px',
                                                 
h460 } );

        
            
/* delegate */
            
ipb.delegate.register('a[rel~="ipsQuickNav"]'ipb.global.quickNavTabClick );
        }
        
        return 
false;
    },
    
    
launchPhotoEditor: function( elem)
    {
        
Event.stop(e);
        
        if ( ! 
Object.isUndefinedipb.global.popups['photoEditor'] ) )
        {
            
ipb.global.popups['photoEditor'].kill();
        }
        
        var 
url ipb.vars['base_url'] + "&app=members&module=ajax&section=photo&do=show&secure_key=" ipb.vars['secure_hash'];        
        
ipb.global.popups['photoEditor'] = new ipb.Popup'photo_popup', {  type'pane',
                                                                                 
modaltrue,
                                                                                 
ajaxURLurl,
                                                                                 
hideAtStartfalse,
                                                                                 
evalJs'force',
                                                                                 
w'750px',
                                                                                 
h500
                                                                                  
} );
        return 
false;
    },
    
    
quickNavTabClick: function( eelem )
    {
        
Event.stop(e);
        
app elem.readAttribute'data-app' );
        
        var 
url ipb.vars['base_url'] + "app=core&module=ajax&section=navigation&secure_key=" ipb.vars['secure_hash'] + "&do=panel&inapp=" app;
        
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                {
                    
method'get',
                    
evalJSON'force',
                    
hideLoadertrue,
                    
onSuccess: function(t)
                    {
                        $(
'ipsNav_content').updatet.responseText );
                        
                        $$(
'a[rel~="ipsQuickNav"]').each( function(link)
                        {
                            
link.up('li').removeClassName('active');
                            var 
_app link.readAttribute'data-app' );
                            
                            if ( 
_app == app )
                            {
                                
link.up('li').addClassName('active');
                            }
                        } );
                    }
                });
        
        return 
false;
    },
    
    
    
ajaxPagination: function( elementurl )
    {
        new 
Ajax.Request(    url.replace(/&amp;/g'&'),
                            {
                                
method'get',
                                
evalJSON'force',
                                
hideLoadertrue,
                                
onSuccess: function(t)
                                {
                                    $(
element).updatet.responseText );
                                }
                            });

        return 
false;
    },
    
    
inlineSignin: function( )
    {
        if( 
ipb.vars['is_touch'] ){ // Just go to normal form for touch devices
            
return;
        }
        
        
/* If we don't have the template bit.. */
        
if ( ! $('inline_login_form') )
        {
            return;
        }
        
        
Event.stop(e);

        if( 
ipb.global.loginRedirect )
        {
            
window.location ipb.global.loginRedirect;
            return;
        }
        
        new 
ipb.Popup'sign_in_popup', {    type'pane',
                                            
initial: $('inline_login_form').show(),
                                            
hideAtStartfalse,
                                            
hideClosefalse,
                                            
deferfalse,
                                            
modaltrue,
                                            
w'600px' },
                                        {
                                            
afterShow: function(pop){
                                                try {
                                                    $(
'ips_username').focus();
                                                } catch(
err){}
                                            }
                                        });
    },
    
    
forumMarkRead: function(eleme)
    {
        
Event.stop(e);
        
        var 
id = $(elem).readAttribute("data-fid");
        
        if( !
id ){ return; }
        
        var 
url    ipb.vars['base_url'] + '&app=forums&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=forums&do=markRead&fid=' id;
    
        
// Send AJAX request
        
new Ajax.Request(     url,
                             {
                                
method'get',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseText == 'no_forum' || t.responseText == 'no_permission' ){
                                        
alertipb.lang['mark_read_forum'] );
                                        return;
                                    }
                                    
                                    
/* Remove elements */
                                    
$$('.__topic').each( function( topic )
                                    {
                                        if ( $(
topic).hasClassName('unread') )
                                        {
                                            var 
tid = $(topic).readAttribute("data-tid");
                                            
                                            if ( 
tid )
                                            {
                                                
ipb.global.topicRemoveUnreadElementstid );
                                            }
                                        }
                                    } );
                                }
                            });
        
    },
    
    
topicMarkRead: function(eleme)
    {
        
Event.stop(e);
        
        var 
id = $(elem).readAttribute("data-tid");
        
        if( !
id ){ return; }
        
        var 
row    = $('trow_'+id);
        var 
url    ipb.vars['base_url'] + '&app=forums&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=topics&do=markRead&tid=' id;
    
        
// Send AJAX request
        
new Ajax.Request(     url,
                             {
                                
method'get',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    if( 
t.responseText == 'no_topic' || t.responseText == 'no_permission' ){
                                        
alertipb.lang['mark_read_topic'] );
                                        return;
                                    }
                                    
                                    
/* Remove mark as read link */
                                    
$(elem).remove();
                                    
                                    
/* Close preview */
                                    
ipb.global.topicPreview(erow.down('.__topic_preview') );
                                    
                                    
/* Remove elements */
                                    
ipb.global.topicRemoveUnreadElementsid );
                                }
                            });
        
    },
    
    
topicRemoveUnreadElements: function( tid )
    {
        $(
'trow_' tid).removeClassName('unread').down('.col_f_icon').select('a img').invoke('remove');
    },
    
    
topicPreview: function(eelem)
    {                
        
Event.stop(e);
        
        var 
toggle = $(elem).down(".expander");
        var 
row = $(elem).up(".__topic");
        var 
id = $(row).readAttribute("data-tid");
        
        if( !
id ){ return; }
        
        
// Stop multiple loads
        
if( $(row).readAttribute('loadingPreview') == 'yes' ){
            return; 
// Just be patient!
        
}        
        $( 
row ).writeAttribute('loadingPreview''yes');
        
        if( $(
"topic_preview_" id) )
        {
            if( $(
"topic_preview_wrap_" id).visible() )
            { 
                new 
Effect.BlindUp( $("topic_preview_wrap_" id), { duration0.3afterFinish: function(){ $('topic_preview_' id).hide(); } } );
                
row.removeClassName('highlighted');
                $( 
toggle ).addClassName('closed').removeClassName('loading').removeClassName('open').writeAttribute('title'ipb.lang['open_tpreview']);
            }
            else
            {
                $(
'topic_preview_' id).show();
                new 
Effect.BlindDown( $("topic_preview_wrap_" id), { duration0.3 } );
                
row.addClassName('highlighted');
                $( 
toggle ).addClassName('open').removeClassName('loading').removeClassName('closed').writeAttribute('title'ipb.lang['close_tpreview']);
            }
            
            $(
row).writeAttribute('loadingPreview''no');
        }
        else
        {
            var 
url    ipb.vars['base_url'] + '&app=forums&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=topics&do=preview&tid=' id;
            if ( 
ipb.global.searchResultsid ] ){
                
url += '&pid=' ipb.global.searchResultsid ]['pid'] + '&searchTerm=' ipb.global.searchResultsid ]['searchterm'];
            }
            
            $( 
toggle ).addClassName('loading').removeClassName('closed').removeClassName('open');
            
            
// Send AJAX request
            
new Ajax.Request(     url,
                                 {
                                    
method'get',
                                    
evalJSON'force',
                                    
onSuccess: function(t)
                                    {
                                        if( 
t.responseText == 'no_topic' || t.responseText == 'no_permission' ){
                                            
alertipb.lang['no_permission_preview'] );
                                            $( 
toggle ).addClassName('open').removeClassName('loading').removeClassName('closed').writeAttribute('title'ipb.lang['close_tpreview']);

                                            $(
row).writeAttribute('loadingPreview''no');
                                            return;
                                        }
                                        
                                        if( 
row.tagName == "TR" )
                                        {
                                            var 
count row.childElements().size();
                                            var 
newrow = new Element('tr', { 'class''preview''id''topic_preview_' id });
                                            var 
newcell = new Element('td', { 'colspan'count } );
                                            var 
wrap = new Element('div', { 'id''topic_preview_wrap_' id }).hide().update( new Element('div' ) );
                                            
                                            
// Put all the bits inside each other
                                            
row.insert( { afternewrow.insertnewcell.insertwrap ) ) } );
                                        }
                                        else
                                        {
                                            var 
wrap = new Element('div', { 'id''topic_preview_wrap_' id }).hide().update( new Element('div') );
                                            
row.insert( { afterwrap } );
                                        }                                        
                                        
                                        
// Insert content
                                        
wrap.updatet.responseText ).relativize();
                                        
// display it
                                        
new Effect.BlindDownwrap, { duration0.3 } );
                                        
// Update row & elem
                                        
row.addClassName('highlighted');
                                        $( 
toggle ).addClassName('open').removeClassName('loading').removeClassName('closed').writeAttribute('title'ipb.lang['close_tpreview']);
                                        
                                        $(
row).writeAttribute('loadingPreview''no');
                                    }
                                });
        }
    },
    
    
// Set up the main menu
    
activateMainMenu: function()
    {
        if( $(
"nav_other_apps") && $("community_app_menu") ){
            
/* Image is 0 width inside hidden div, so we have to compensate manually...hardcoded for our useropts image 17px + 3px margin */
            /* Note that we are grabbing width of more menu tab, instead of 'margin-box-width' which accounts for margin.  Cannot grab this
                value while the tab is hidden and we don't want to loop a second time unnecessarily to readjust after showing the menu */
            
var start totalW = $("nav_other_apps").getWidth() + 20
            var 
menuWidth = $("community_app_menu").getWidth();

            
/* Add up the widths of any menu items we won't be moving to the more menu */
            
$("community_app_menu").select("li.skip_moremenu").each( function(elem){
                
totalW += $(elem).measure('margin-box-width');
            });

            $(
"community_app_menu").select("li:not(#nav_other_apps,.submenu_li)").each( function(elem){
                
/* These tabs should not be moved to the more menu */
                
if( $(elem).hasClassName('skip_moremenu') )
                {
                    return;
                }

                
totalW += $(elem).measure('margin-box-width');

                if( 
totalW >= menuWidth )
                {
                    if( !$(
"more_apps_menucontent") ){
                        $$(
"body")[0].insert("<div id='more_apps_menucontent' class='submenu_container clearfix boxShadow'><div class='left'><ul class='submenu_links' id='more_apps_menucontentul'></ul></div></div>");
                    }

                    $(
elem).addClassName('submenu_li').removeClassName('left');
                    
                    $(
"more_apps_menucontentul").insertelem ); // Move item to menu
                
}
            });
            
            
// Do we have an app menu?
            
if( $("more_apps_menucontent" ) )
            {
                $(
"nav_other_apps").show();
                new 
ipb.Menu( $('more_apps'), $('more_apps_menucontent') );
            }
            
            
Debug.writemenuWidth );
        }
    },
    
    
/**
     * Init user cards
     */
    
initUserCards: function()
    {
        
/* User cards */
        
if ( ! Object.isUndefinedipb.hoverCard ) && ipb.vars['is_touch'] === false && ipb.vars['member_group']['g_mem_info'] == )
        {
            var 
ajaxUrl ipb.vars['base_url'] + '&app=members&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=card';
            if ( 
ipb.topic !== undefined && ipb.topic.forum_id !== undefined )
            {
                
ajaxUrl += "&f=" ipb.topic.forum_id;
            }
            
            
ipb.hoverCardRegister.initialize'member', { 'w''500px''delay'750'position''auto''ajaxUrl'ajaxUrl'getId'true'setIdParam''mid' } );
        }
    },
    
    
/**
     * Display an inline notification
     * 
     */
    
showInlineNotification: function( contentoptions )
    {
        
/* Fix options */
        
options                      = ( Object.isUndefinedoptions ) ) ? {} : options;
        
options.showClose           = ( Object.isUndefinedoptions.manualClose ) ) ? false options.showClose;
        
options.neverClose           = ( Object.isUndefinedoptions.neverClose ) )  ? false options.neverClose;
        
options.displayForSeconds = ( Object.isUndefinedoptions.displayForSeconds ) ) ? options.displayForSeconds;
        
        
/* Already one open? */
        
if ( $('ipsGlobalNotification' ) )
        {
            var 
span = $('ipsGlobalNotification').down('span');
            
            
/* fade out current content and fade in new */
            
new Effect.Fadespan, { duration0.8afterFinish:
                function() {
                    
span.replace( new Element'span' ).updatecontent ) );
                    new 
Effect.Appear( $('ipsGlobalNotification').down('span'), { duration0.8 } );
                }
            } );
        }
        else
        {
            if( $(
'ipbwrapper') )
            {
                
/* Front end */
                
$('ipbwrapper').insert( new Element('div', { id'ipsGlobalNotification' } ).updateipb.templates['global_notify'].evaluate( { 'message'content } ) ) );
            }
            else
            {
                
/* ACP */
                
$('ipboard_body').insert( new Element('div', { id'ipsGlobalNotification' } ).updateipb.templates['global_notify'].evaluate( { 'message'content'close'ipb.templates['global_notify_close'] } ) ) );
            }
            
            
/* Add in content */            
            
new Effect.Appear'ipsGlobalNotification', { duration1.5 } );
            
            if ( 
options.showClose )
            {
                $(
'ipsGlobalNotification').insert( new Element'div', { id'ipsGlobalNotification_close' } ) );
                $(
'ipsGlobalNotification_close').observe('click'ipb.global.closeInlineNotification );
            }
            else if( $(
'ipsGlobalNotification_close') )
            {
                $(
'ipsGlobalNotification_close').observe('click'ipb.global.closeInlineNotification );
            }
        }
        
        
/* Listen on any a hrefs */
        
$('ipsGlobalNotification').on('click''span a'ipb.global.closeInlineNotification);
        
        
/* Close */
        
if ( options.neverClose !== true )
        {
            try    {
                
clearTimeoutipb.global.inlineNotification['timers']['close'] );
            }
            catch(
e) {}
            
            
ipb.global.inlineNotification['timers']['close'] = setTimeoutipb.global.closeInlineNotificationoptions.displayForSeconds 1000 );
        }
    },
    
    
/**
     * Closes a notification
     */
    
closeInlineNotification: function()
    {
        if ( $(
'ipsGlobalNotification_close') ){
            $(
'ipsGlobalNotification_close').stopObserving('click');
        }
        
        try {
            
clearTimeoutipb.global.inlineNotification['timers']['close'] );
        }
        catch(
e) {}
        
        new 
Effect.Fade'ipsGlobalNotification', { duration1.0 } );
        
setTimeout( function() { $('ipsGlobalNotification').remove(); }, 2000 );
    },
    
    
/**
     * Show an error dialogue
     * @param string
     * @returns Nothing
     */
    
errorDialogue: function( text )
    {
        
errContent "<h3>" ipb.lang['error_occured'] + "</h3><div class='row2 ipsPad ipsForm_center'><p>" text "</p></div>";
        
        new 
ipb.Popup'generic__errorDialogue', {  type'pane',
                                                    
initialerrContent,
                                                    
stemtrue,
                                                    
hideAtStartfalse,
                                                    
hideClosefalse,
                                                    
deferfalse,
                                                    
warningfalse,
                                                    
w400 } );
    },
    
    
/**
     * Show an OK dialogue
     * @param string
     * @returns Nothing
     */
    
okDialogue: function( text )
    {
        
okContent "<h3>" ipb.lang['success'] + "</h3><div class='row2 ipsPad ipsForm_center'><p>" text "</p></div>";
        
        new 
ipb.Popup'generic__okDialogue', {  type'pane',
                                                 
initialokContent,
                                                 
stemtrue,
                                                 
hideAtStartfalse,
                                                 
hideClosefalse,
                                                 
deferfalse,
                                                 
w400 } );
    },
    
    
contextualSearch: function()
    {
        if( !$(
'search_options') && !$('search_options_menucontent') ){ return; }
        
        if ( ! $(
'main_search') )
        {
            return;
        }
        
        $(
'main_search').defaultizeipb.lang['search_default_value'] );
        
        
// This removes the text for IE7
        
$('search').select('.submit_input').find( function(elem){ $(elem).value ''; } );
        
        var 
update = function( noSelect )
        {
            var 
checked = $('search_options_menucontent').select('input').find( function(elem){ return $(elem).checked; } );
            if( 
Object.isUndefinedchecked ) ){ 
                
checked = $('search_options_menucontent').select('input:first')[0];
                if( !
checked ){ return; }
                
checked.checked true;
            }
            $(
'search_options').show().update( $( checked ).up('label').readAttribute('title') || '' );
            
            
// Put cursor in search box
            
if( noSelect != true ){
                $(
'main_search').focus();
            }
            
            return 
true;
        };
        
update(true);
        
        $(
'search_options_menucontent').select('input').invoke('observe''click'update);
    },

    
fetchTid: function( )
    {
        var 
elem Event.element(e);
        
elem.identify();
        
        if( !
elem.hasClassName('__topic') )
        {
            
elem elem.up('.__topic');
        }

        var 
id   elem.id;
        
        if ( !
id || ! $(id) )
        {
            return 
0;
        }
        
        var 
m    = $(id).className.match('__tid([0-9]+)');
        var 
tid  m[1];
        
        return 
tid;
    },

    
displayWarnLogs: function( eelem )
    {        
        
mid elem.id.match('warn_link_([0-9a-z]+)_([0-9]+)')[2];
        if( 
Object.isUndefined(mid) ){ return; }
        
        if( 
parseInt(mid) == ){
            return 
false;
        }
        
        
Event.stop(e);
        
        var 
_url         ipb.vars['base_url'] + '&app=core&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=warn&do=view&mid=' mid;
        
warnLogs = new ipb.Popup'warnLogs', {type'pane'modalfalsew'500px'h500ajaxURL_urlhideAtStartfalseclose'.cancel' } );
        
    },
    
    
/* ------------------------------ */
    /**
     * Toggle mini friend button
     * 
     * @param    {event}        e        The event
     * @param    {int}        id        Member id
    */
    
toggleFriend: function(eelem)
    {
        
Event.stop(e);
        
        
// Get ID of friend
        
var id = $( elem ).id.match('friend_(.*)_([0-9]+)');
        if( 
Object.isUndefinedid[2] ) ){ return; }
        
        var 
isFriend = ( $(elem).hasClassName('is_friend') ) ? 0;
        var 
urlBit = ( isFriend ) ? 'remove' 'add';
        
        var 
url ipb.vars['base_url'] + "app=members&section=friends&module=ajax&do=" urlBit "&member_id=" id[2] + "&md5check=" ipb.vars['secure_hash'];
        
        
// Send
        
new Ajax.Request(     url,
                             {
                                
method'get',
                                
onSuccess: function(t)
                                {
                                    switch( 
t.responseText )
                                    {
                                        case 
'pp_friend_timeflood':
                                            
alertipb.lang['cannot_readd_friend'] );
                                            
Event.stop(e);
                                            break;
                                        case 
"pp_friend_already":
                                            
alertipb.lang['friend_already'] );
                                            
Event.stop(e);
                                            break;
                                        case 
"error":
                                            return 
true;
                                            break;
                                        default:
                                            
                                            var 
newIcon = ( isFriend ) ? ipb.templates['m_add_friend'].evaluate({ idid[2]}) : ipb.templates['m_rem_friend'].evaluate({ idid[2] });
                                             
                                            
// Find all friend links for this user
                                            
var friends = $$('.mini_friend_toggle').each( function( fr ){
                                                if( $(
fr).id.endsWith('_' id[2] ) )
                                                {
                                                    if ( 
isFriend ) {
                                                        $(
fr).removeClassName('is_friend').addClassName('is_not_friend').updatenewIcon );
                                                    } else {
                                                        $(
fr).removeClassName('is_not_friend').addClassName('is_friend').updatenewIcon );
                                                    }
                                                }                                            
                                            });
                                            
                                            new 
Effect.Highlight( $( elem ), { startcoloripb.vars['highlight_color'] } );
                                            
                                            
// Fire an event so we can update if necessary
                                            
document.fire('ipb:friendRemoved', { friendIDid[2] } );
                                            
Event.stop(e);
                                        break;
                                    }
                                }
                            }
                        );
    },
    
    
/**
    * MATT
    * Toggle spammer
    */
    
toggleFlagSpammer: function( memberIdflagStatus )
    {
        if ( 
flagStatus == true )
        {
            if( 
confirmipb.lang['set_as_spammer'] ) )
            {
                var 
tid    0;
                var 
fid    0;
                var 
sid    0;
                
                if( 
typeof(ipb.topic) != 'undefined' )
                {
                    
tid ipb.topic.topic_id;
                    
fid ipb.topic.forum_id;
                    
sid ipb.topic.start_id;
                }

                
window.location ipb.vars['base_url'] + 'app=core&module=modcp&do=setAsSpammer&member_id=' memberId '&t=' tid '&f=' fid '&st=' sid '&auth_key=' ipb.vars['secure_hash'];
                return 
false;
            }
            else
            {
                return 
false;
            }
        }
        else
        {
            
alertipb.lang['is_spammer'] );
            return 
false;
        }
    },
    
    
/* ------------------------------ */
    /**
     * Toggle spoiler
     * 
     * @param    {event}        e        The event
    */
    
toggleSpoiler: function(ebutton)
    {
        
Event.stop(e);
        
        var 
returnvalue = $(button).up('.bbc_spoiler').down('.bbc_spoiler_wrapper').down('.bbc_spoiler_content').toggle();
        
        if( 
returnvalue.visible() ){
            $(
button).value ipb.lang['spoiler_hide'];
        } else {
            $(
button).value ipb.lang['spoiler_show'];
        }
    },

    
/* ------------------------------ */
    /**
     * Builds the popup menu for RSS feeds
    */
    
buildRSSmenu: function()
    {
        
// Get all link tags
        
$$('link').each( function(link)
        {
            if( 
link.readAttribute('type') == "application/rss+xml" )
            {
                
ipb.global.rssItems.pushipb.templates['rss_item'].evaluate( { urllink.readAttribute('href'), titlelink.readAttribute('title') } ) );
            }
        });
        
        if( 
ipb.global.rssItems.length )
        {
            
rssmenu ipb.templates['rss_shell'].evaluate( { itemsipb.global.rssItems.join("n") } );
            $( 
'rss_feed' ).insert( { afterrssmenu } );
            new 
ipb.Menu( $( 'rss_feed' ), $( 'rss_menu' ) );
        }
        else
        {
            $(
'rss_feed').hide();
        }
    },
    
    
/* ------------------------------ */
    /**
     * Reputation Popup Balloon
     */
    
repPopUp: function( erepIdrepApprepType )
    {
        if( 
ipb.global.popups['rep_' repId] ){
            
ipb.global.popups['rep_' repId].kill();
        }
        
        var 
_url ipb.vars['base_url'] + '&app=core&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=reputation&do=view&repApp=' repApp '&repType=' repType '&repId=' repId;
        
ipb.global.popups['rep_' repId] = new ipb.Popup('rep_' repId, {
                                                                
type'balloon',
                                                                
stemtrue,
                                                                
attach: { targeteposition'auto' },
                                                                
hideAtStartfalse,
                                                                
ajaxURL_url,
                                                                
w'300px',
                                                                
h400
                                                            
});
    },
    
    
/* ------------------------------ */
    /**
     * Hides the PM notification box
     * 
     * @param    {event}        e        The event
    */
    
closePMpopup: function(e)
    {
        if( $(
'pm_notification') )
        {
            new 
Effect.Parallel([
                new 
Effect.Fade( $('pm_notification') ),
                new 
Effect.BlindUp( $('pm_notification') )
            ], { 
duration0.5 } );
        }
        
        
Event.stop(e);
    },
    
    
/* ------------------------------ */
    /**
     * Mark a PM read from popup
     * 
     * @param    {event}        e        The event
    */
    
markReadPMpopup: function(e)
    {
        if( $(
'pm_notification') )
        {
            var 
elem     Event.findElement(e'a');
            var 
href    elem.href.replace( /&amp;/g'&' ) + '&ajax=1';
            
            
//Debug.write( 'Mark as read: ' + href );
            
            
new Ajax.Requesthref "&md5check=" ipb.vars['secure_hash'],
                            {
                                
method'get',
                                
evalJSON'force',
                                
onSuccess: function(t){}
                            });
            
            new 
Effect.Parallel([
                new 
Effect.Fade( $('pm_notification') ),
                new 
Effect.BlindUp( $('pm_notification') )
            ], { 
duration0.5 } );
        }
        
        
Event.stop(e);
        return 
false;
    },
    
    
/* ------------------------------ */
    /**
     * Initializes GD image
     *
    */
    
initGD: function()
    {
        $(
'gd-antispam').observe('click'ipb.global.generateNewImage);
        
        if( $(
'gd-image-link') )
        {
            $(
'gd-image-link').observe('click'ipb.global.generateNewImage );
        }
    },

    
/* ------------------------------ */
    /**
     * Simulate clicking the image
     *
     * @param    {element}    elem    The GD image element
    */
    
generateImageExternally: function( elem )
    {
        if( !$(
elem) ){ return; }
        
        $(
elem).observe('click'ipb.global.generateNewImage);
    },    
    
    
/* ------------------------------ */
    /**
     * Click event for generating new GD image
     * 
     * @param    {event}        e    The event
    */
    
generateNewImage: function(e)
    {
        
img    = $('gd-antispam');
        
        
Event.stop(e);

        
oldSrc img.src.toQueryParams();
        
oldSrc $HoldSrc ).toObject();
        
        if( !
oldSrc['captcha_unique_id'] ){    Debug.error("No captcha ID found"); }
        
        
// Get new image
        
new Ajax.Request
            
ipb.vars['base_url'] + "app=core&module=global&section=captcha&do=refresh&captcha_unique_id=" oldSrc['captcha_unique_id'] + '&secure_key=' ipb.vars['secure_hash'],
            {
                
method'get',
                
onSuccess: function(t)
                {
                    
//Change src
                    
oldSrc['captcha_unique_id'] = t.responseText;
                    
img.writeAttribute( { srcipb.vars['base_url'] + $HoldSrc ).toQueryString() } );
                    $(
'regid').value t.responseText;
                }
            }
        );
    },
    
    
/* ------------------------------ */
    /**
     * Registers a reputation toggle on the page
     * 
     * @param    {int}        id        The element that wraps rep
     * @param    {string}    url        The URL to ping
     * @param    {int}        rating    The current rep rating
    */
    
registerReputation: function( idurlrating )
    {
        if( !$( 
id ) ){ return; }
                
        
// Find rep up
        
var rep_up         = $( id ).down('.rep_up');
        var 
rep_down       = $( id ).down('.rep_down');
        
        var 
domLikeStripId = ( $(url.domLikeStripId) ) ? $(url.domLikeStripId) : false;
    
        var 
sendUrl ipb.vars['base_url'] + '&app=core&module=ajax&section=reputation&do=add_rating&app_rate=' url.app '&type=' url.type '&type_id=' url.typeid '&secure_key=' ipb.vars['secure_hash'];        
        
        if( $( 
rep_up ) ){
            $( 
rep_up ).observe'click'ipb.global.repRate.bindAsEventListener(this1id) );
        }
        
        if( $( 
rep_down ) ){
            $( 
rep_down ).observe'click'ipb.global.repRate.bindAsEventListener(this, -1id) );
        }
        
        
ipb.global.reputationid ] = { obj: $( id ), domLikeStripIddomLikeStripIdurlurlsendUrlsendUrlcurrentRatingrating || };
        
Debug.write"Registered reputation" );
    },
    
    
/* ------------------------------ */
    /**
     * Does a reputation rating action
     * 
     * @param    {event}        e        The event
    */
    
repRate: function( )
    {
        
Event.stop(e);
        var 
type $A(arguments)[1];
        var 
id $A(arguments)[2];
        var 
value = ( type == ) ? : -1;
        
        if( !
ipb.global.reputationid ] ){
            return;
        } else {
            var 
rep ipb.global.reputationid ];
        }

        
Debug.writerep.sendUrl '&rating=' value );
        
        
// Send ping
        
new Ajax.Requestrep.sendUrl '&rating=' value,
                        {
                            
method'get',
                            
onSuccess: function( )
                            {
                                if( 
t.responseJSON['status'] == 'ok' )
                                {
                                    try {                                    
                                        
// It worked! Hide the rep buttons
                                        
rep.obj.down('.rep_up').up('li').hide();
                                        
rep.obj.down('.rep_down').up('li').hide();
                                        
                                        
/* Can we see some, though? */
                                        
if ( t.responseJSON['canRepUp'] === true )
                                        {
                                            
rep.obj.down('.rep_up').up('li').show();
                                        }
                                        
                                        if ( 
t.responseJSON['canRepDown']  === true )
                                        {
                                            
rep.obj.down('.rep_down').up('li').show();
                                        }                                        
                                    } catch(
err) { Debug.errorerr ); }
                                    
                                    
// Update the figure
                                    
var rep_display rep.obj.down('.rep_show');
                                    if( 
rep_display )
                                    {                                        
                                        [
'positive''negative''zero'].each(function(c){ rep_display.removeClassName(c); });
                                        
                                        var 
newValue parseIntt.responseJSON['rating'] );
                                        
                                        if( 
newValue )
                                        {
                                            
rep_display.addClassName('positive');
                                        }
                                        else if( 
newValue )
                                        {
                                            
rep_display.addClassName('negative');
                                        }
                                        else
                                        {
                                            
rep_display.addClassName('zero');
                                        }
                                        
                                        
rep_display.updatenewValue );
                                    }
                                    
                                    
/* Got a like strip */
                                    
if ( $(rep.domLikeStripId.id) )
                                    {
                                        if ( 
t.responseJSON['likeData'].formatted !== false )
                                        {
                                            $(
rep.domLikeStripId.id).updatet.responseJSON['likeData'].formatted ).show();
                                        }
                                        else
                                        {
                                            $(
rep.domLikeStripId.id).update'' ).hide();
                                        }
                                    }
                                }
                                else
                                {
                                    if( 
t.responseJSON['error'] == 'nopermission' || t.responseJSON['error'] == 'no_permission' )
                                    {
                                        
ipb.global.errorDialogueipb.lang['no_permission'] );
                                    }
                                    else
                                    {
                                        
ipb.global.errorDialoguet.responseJSON['error'] );
                                    }
                                }
                            }
                        });
    
     },
    
     
/**
     * Fetch 'more'pop-up
     */
    
repLikeMore: function(eelem)
    {
        
Event.stop(e);
        
        try
        {
            var 
id   elem.readAttribute('data-id');
            var 
app  elem.readAttribute('data-app');
            var 
type elem.readAttribute('data-type');
        }
        catch( 
)
        {
            
Debug.error(e);
        }
        
        if ( ! 
Object.isUndefinedipb.global.popups['likeMore'] ) )
        {
            
ipb.global.popups['likeMore'].kill();
        }
        
        var 
popid 'setfave_' id;
        var 
_url  ipb.vars['base_url'] + '&app=core&module=ajax&section=reputation&do=more&secure_key=' ipb.vars['secure_hash'] + '&f_app=' app '&f_type=' type '&f_id=' id;
        
Debug.write_url );
        
        
/* easy one this... */
        
ipb.global.popups['likeMore'] = new ipb.Popuppopid, { type'pane',
                                                                
ajaxURL_url,
                                                                
stemfalse,
                                                                
hideAtStartfalse,
                                                                
h500,
                                                                
w'450px' });        
    },

    
/* ------------------------------ */
    /**
     * Utility function for converting bytes
     * 
     * @param    {int}        size    The value in bytes to convert
     * @return    {string}            The converted string, with unit
    */
    
convertSize: function(size)
    {
        var 
kb 1024;
        var 
mb 1024 1024;
        var 
gb 1024 1024 1024;
        
        if( 
size kb ){ return size " B"; }
        if( 
size mb ){ return ( size kb ).toFixed) + " KB"; }
        if( 
size gb ){ return ( size mb ).toFixed) + " MB"; }
        
        return ( 
size gb ).toFixed) + " GB";
    },

    
/* ------------------------------ */
    /**
     * Registers a page jump toggle
     * 
     * @param    {int}    source        ID of this jump
     * @param    {hash}    options        Options for this jump
    */
    
registerPageJump: function( sourceoptions )
    {
        if( !
source || !options ){
            return;
        }
        
        
ipb.global.pageJumpssource ] = options;    
    },
    
    
/* ------------------------------ */
    /**
     * Builds a page jump control
    */
    
buildPageJumps: function()
    {
        $$(
'.pagejump').each( function(elem){
            
// Find the pj ID
            
var classes = $( elem ).className.match(/pj([0-9]+)/);
            
            if( 
Object.isUndefinedclasses ) || !classes || !classes[1] ){
                return;
            }
            
            $( 
elem ).identify();
            
            
// Doth a popup exist?
            //Debug.write( "This wrapper has been created! " + classes[1]  );
            
var temp ipb.templates['page_jump'].evaluate( { id'pj_' + $(elem).identify() } );
            $$(
'body')[0].inserttemp );
            
            $(
'pj_' + $(elem).identify() + '_submit').observe('click'ipb.global.pageJump.bindAsEventListenerthis, $(elem).identify() ) );
            
            
// So it submits on enter
            
$('pj_' + $(elem).identify() + '_input').observe('keypress', function(e){
                if( 
e.which == Event.KEY_RETURN )
                {
                    
ipb.global.pageJumpe, $(elem).identify() );
                }
            });
            
            var 
wrap = $( 'pj_' + $(elem).identify() + '_wrap' ).addClassName('pj' classes[1]).writeAttribute('jumpid'classes[1] );
            
            var 
callback = { 
                
afterOpen: function( popup ){
                    try {
                        $( 
'pj_' + $(elem).identify() + '_input').activate();
                    }
                    catch(
err){ }
                }
             };
            
            
ipb.global.pageJumpMenusclasses[1] ] = new ipb.Menu( $( elem ), $( wrap ), { stopClosetrue }, callback );
        });
    },
    
    
/* ------------------------------ */
    /**
     * Executes a page jump
     * 
     * @param    {event}        e        The event
     * @param    {element}    elem    The page jump element
    */
    
pageJump: function( eelem )
    {
        if( !$( 
elem ) || !$( 'pj_' + $(elem).id '_input' ) ){ return; }
        
        var 
value $F'pj_' + $(elem).id '_input' );
        var 
jumpid = $( 'pj_' + $(elem).id '_wrap' ).readAttribute'jumpid' );
        
        if( 
value.blank() ){
            try {
                
ipb.global.pageJumpMenussource ].doClose();
            } catch(
err) { }
        }
        else
        {
            
value parseIntvalue );
        }
        
        
// Work out page number 
        
var options ipb.global.pageJumpsjumpid ];
        if( !
options ){ Debug.diripb.global.pageJumps ); Debug.writejumpid ); return; }
        
        var 
pageNum = ( ( value ) * options.perPage );
        
Debug.writepageNum );
        
        if( 
pageNum ){
            
pageNum 0;
        }
        
/*else if( pageNum > options.totalPages ){
            pageNum = options.totalPages;
        }*/
        
        
if( ipb.vars['seo_enabled'] ){
            
// Bug #33897
            // Pagination broken in search results due to use of query string, so here we'll check
            // whether QS's are used with regex, and use old style pagination if that's the case.
            
if( options.url.charAtoptions.url.length ) == '=' || options.url.match(/(&|&amp;)[dw]+=/gi) ){
                
// Bug #31029
                // SEO URLs ending with = don't work. Use non-seo urls in this case.
                
var url options.url '&amp;' options.stKey '=' pageNum;
            } else {
                if( 
document.location.toString().matchipb.vars['seo_params']['start'] ) && document.location.toString().matchipb.vars['seo_params']['end'] ) ){
                    if ( 
options.url.matchipb.vars['seo_params']['varBlock'] ) )
                    {
                        var 
url options.url ipb.vars['seo_params']['varSep'] + options.stKey ipb.vars['seo_params']['varSep'] + pageNum;
                    }
                    else
                    {
                        var 
url options.url ipb.vars['seo_params']['varBlock'] + options.stKey ipb.vars['seo_params']['varSep'] + pageNum;
                    }
                } else {
                    var 
url options.url ipb.vars['seo_params']['varBlock'] + options.stKey ipb.vars['seo_params']['varSep'] + pageNum;
                }
            }
        } else {
            var 
url options.url '&amp;' options.stKey '=' pageNum;
        }

        if( 
options.anchor )
        {
            
url url options.anchor;
        }
    
        
url url.replace(/&amp;/g'&');
        
// Without a negative lookbehind, http:// gets replaced with http:/ when we replace // with /
        // @see http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
        
url url.replace(/(http:|https:)?///g, function($0, $1) { return $1 ? $0 : '/'; } );
        
        
document.location url;
        
        return;
    },
    
    
/* ------------------------------ */
    /**
     * Open the link in a new window
     * 
     * @param    {event}        e        The event
     * @param    {boolean}    force    Force new window regardless of host?
    */
    
openNewWindow: function(elinkforce)
    {        
        var 
ourHost    document.location.host;
        var 
newHost link.host;
        
        if( 
Prototype.Browser.IE )
        {
            
newHost    newHost.replace( /^(.+?):(d+)$/, '$1' );
        }

        
/**
         * Open a new window, if link is to a different host
         */
        
if( ourHost != newHost || force )
        {
            
window.open(link.href);
            
Event.stop(e);
            return 
false;
        }
        else
        {
            return 
true;
        }
    },
    
    
/* ------------------------------ */
    /**
     * Registers an ajax marker
     * 
     * @param    {string}    id        ID of the wrapper element
     * @param    {string}    key        Key of the current marker status (e.g. f_unread)
     * @param    {string}    url        URL to ping
    */
    
registerMarker: function( idkeyurl )
    {
        if( !$(
id) || key.blank() || url.blank() ){ return; }
        
Debug.write"Marker INIT: " id );
        $( 
id ).observe('click'ipb.global.sendMarker.bindAsEventListenerthisidkeyurl ) );
    },
    
    
/* ------------------------------ */
    /**
     * Sends a marker read request
     * 
     * @param    {event}        e        The event
     * @param    {string}    id        ID of containing element
     * @param    {string}    key        Key of current marker
     * @param    {string}    url        URL to ping
    */
    
sendMarker: function( eidkeyurl )
    {
        
Event.stop(e);
        
        new 
Ajax.Requesturl "&secure_key=" ipb.vars['secure_hash'], 
                            {
                                
method'get',
                                
evalJSON'force',
                                
onSuccess: function(t)
                                {
                                    if( 
Object.isUndefinedt.responseJSON ) )
                                    {
                                        
Debug.error("Invalid server response");
                                        return 
false;
                                    }
                                    
                                    if( 
t.responseJSON['error'] )
                                    {
                                        
Debug.errort.responseJSON['error'] );
                                        return 
false;
                                    }
                                    
                                    if ( $(
id '_tooltip') ){
                                        $(
id '_tooltip').hide();
                                    }
                                    
                                    $( 
id ).up('tr').removeClassName('unread');
                                    
                                    
// Update icon
                                    
$( id ).replaceunreadIcon );
                                    
                                    
// Update subforum icons
                                    
var _intId    id.replace( /forum_img_/, '' );
                                    
                                    if( $(
"subforums_" _intId ) )
                                    {
                                        $$(
"#subforums_" _intId " li" ).each( function(elem) {
                                            $(
elem).removeClassName('unread');
                                        });
                                    }
                                }
                            });
    },
    
    
registerCheckAll: function( idclassname )
    {
        if( !$( 
id ) ){ return; }
        
        $( 
id ).observe('click'ipb.global.checkAll.bindAsEventListenerthisclassname ) );
        
        $$(
'.' classname ).each( function(elem){
            $( 
elem ).observe('click'ipb.global.checkOne.bindAsEventListenerthisid ) );
        });
    },
    
    
checkAll: function( eclassname )
    {
        
Debug.write('checkAll');
        var 
elem Event.element(e);
        
        
// Get all checkboxes
        
var checkboxes = $$('.' classname);
        
        if( 
elem.checked ){
            
checkboxes.each( function(check){
                
check.checked true;
            });
        } else {
            
checkboxes.each( function(check){
                
check.checked false;
            });
        }            
    },
    
    
checkOne: function(eid)
    {
        var 
elem Event.element(e);
        
        if( $( 
id ).checked && elem.checked == false )
        {
            $( 
id ).checked false;
        }        
    },
    
    
updateReportStatus: function(ereportIDnoautonoimg )
    {
        
Event.stop(e);
        
        var 
url ipb.vars['base_url'] + "app=core&amp;module=ajax&amp;section=reports&amp;do=change_status&secure_key=" ipb.vars['secure_hash'] + "&amp;status=3&amp;id=" parseIntreportID ) + "&amp;noimg=" parseIntnoimg ) + "&amp;noauto=" parseIntnoauto );
        
        
// Do request, see what we get
        
new Ajax.Requesturl.replace(/&amp;/g'&'),
                            {
                                
method'post',
                                
evalJSON'force',
                                
onSuccess: function( )
                                {
                                    if( 
Object.isUndefinedt.responseJSON ) )
                                    {
                                        
alertipb.lang['action_failed'] );
                                        return;
                                    }
                                    
                                    try {
                                        $(
'rstat-' reportID).updatet.responseJSON['img'] );
                                        
ipb.menus.closeAll);
                                    } catch(
err) {
                                        
Debug.errorerr );
                                    }
                                }
                            });
    },
    
    
getTotalOffset: function(elemtopleft)
    {
        if( $( 
elem ).getOffsetParent() != document.body )
        {
            
Debug.write"Checking " + $(elem).id );
            var 
extra = $(elem).positionedOffset();
            
top += extra['top'];
            
left += extra['left'];
            
            return 
ipb.global.getTotalOffset( $( elem ).getOffsetParent(), topleft );
        }
        else
        {
            
Debug.write("OK Finished!");
            return { 
toptopleftleft };
        }
    },
    
    
// Checks a server response from an ajax request for 'nopermission'
    
checkPermission: function( text )
    {
        if( 
text == "nopermission" || text == 'no_permission' )
        {
            
alertipb.lang['no_permission'] );
            return 
false;
        }
        
        return 
true;
    },
    
    
/**
     * Check for entry keypress
     */
    
checkForEnter: function(ecallback)
    {
        if( ![ 
Event.KEY_RETURN ].include( e.keyCode ) ){
            return; 
// Not interested in anything else
        
}
        
        if ( 
callback )
        {
            switch( 
e.keyCode )
            {
                case 
Event.KEY_RETURN:
                    
callback(e);
                break;
            }
            
            
Event.stop(e);
        }    
    },

    
/**
     * Check for DST
     */
    
checkDST: function()
    {
        var 
memberHasDst    ipb.vars['dst_in_use'];
        var 
dstInEffect        = new Date().getDST();

        if( 
memberHasDst dstInEffect != )
        {
            var 
url ipb.vars['base_url'] + 'app=members&module=ajax&section=dst&md5check='+ipb.vars['secure_hash'];
            
            new 
Ajax.Request(    url,
                                {
                                    
method'get',
                                    
onSuccess: function(t)
                                    {
                                        
// We don't need to do anything about this..
                                        
return true;
                                    }
                                }
                            );
        }
    }
};

/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.menu.js - Me n you class    <3                */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                         */
/************************************************/

/* ipb.menus is a menu manager; ipb.Menu is a menu object */

var _menu window.IPBoard;
_menu.prototype.menus = {
    
registered$H(),
    
closeCallBackfalse,
    
    
init: function()
    {
        
Debug.write("Initializing ips.menu.js");
        
document.observe("dom:loaded", function(){
            
ipb.menus.initEvents();
        });
    },
    
    
initEvents: function()
    {  
        
// Set document event
        
Event.observedocument'click'ipb.menus.docCloseAll );
        
        
// Auto-find menus
        
$$('.ipbmenu').each( function(menu){
            
id menu.identify();
            if( $( 
id "_menucontent" ) )
            { 
                new 
ipb.Menumenu, $( id "_menucontent" ) );
            }
        });
    },
    
    
register: function( sourceobj )
    {
        
ipb.menus.registered.setsourceobj );
    },
    
    
registerCloseCallBack: function( callBack )
    {
        
ipb.menus.closeCallBack callBack;
    },
    
    
docCloseAll: function( )
    {
        
ipb.menus.closeAll);
    },
    
    
/*!! Close all menus (forceClose ignores clicked in menu area check) */
    
closeAll: function( exceptforceClose )
    {
        
ipb.menus.registered.each( function(menuforce){
        
            if( 
typeofexcept ) == 'undefined' || ( except && menu.key != except ) )
            {
                try{
                    if( 
forceClose || ( !(except.target && $(except.target).descendantOfmenu.value.target )) && except != menu.key ) ){
                        
menu.value.doClose();
                    }
                } catch(
err) {
                    
// Assume this menu gone byebye
                
}
            }
        });
        
        
/* Could make this an array and chain events */
        
if ( Object.isFunctionipb.menus.closeCallBack ) )
        {
            
ipb.menus.closeCallBack();
        }
    }    
};

_menu.prototype.Menu = Class.create({
    
initialize: function( sourcetargetoptionscallbacks ){
        if( !$( 
source ) || !$( target ) ){ return; }
        if( !$( 
source ).id ){
            $( 
source ).identify();
        }
        
this.id = $( source ).id '_menu';
        
this.source = $( source );
        
this.target = $( target );
        
this.callbacks callbacks || {};
        
        
this.options Object.extend( {
            
eventType'click',
            
closeOnMouseoutfalse,
            
stopClosetrue,
            
offsetX0,
            
offsetY0
        
}, arguments[2] || {});
        
        
// Set up events
        
$( source ).observe'click'this.eventClick.bindAsEventListenerthis ) );
        $( 
source ).observe'mouseover'this.eventOver.bindAsEventListenerthis ) );
        $( 
target ).observe'click'this.targetClick.bindAsEventListenerthis ) );

        
/* Close on mouse out too? */
        
if( this.options['closeOnMouseout'] !== false )
        {
            $( 
this.options['closeOnMouseout'] ).observe'mouseleave'this.mouseOutClose.bindAsEventListenerthis ) );
        }
        
        
/* Have an alt? */
        
if ( $( $( source ).id '_alt' ) )
        {
            $( $( 
source ).id '_alt' ).observe'click'this.eventClick.bindAsEventListenerthis, $( $( source ).id '_alt' ) ) );
            $( $( 
source ).id '_alt' ).observe'mouseover'this.eventOver.bindAsEventListenerthis ) );
        }
        
        
// Set up target
        
$( this.target ).setStyle'position: absolute;' ).hide().setStyle( { zIndex9999 } );
        $( 
this.target ).descendants().each( function( elem ){
            $( 
elem ).setStyle( { zIndex10000 } );
        });
        
        
ipb.menus.register( $( source ).idthis ); 
        
        if( 
Object.isFunctionthis.callbacks['afterInit'] ) )
        {
            
this.callbacks['afterInit']( this );
        }
    },
    
    
doOpen: function(elem)
    {
        
Debug.write("Menu open");
        var 
pos = {};
        
        var 
_source = ( this.options.positionSource ) ? this.options.positionSource this.source;
    
        if ( ! 
Object.isUndefinedelem ) )
        {
            var 
_source elem;
        }
        
        
// This is the positioned offset of the source element
        
var sourcePos        = $( _source ).positionedOffset();
        
        
// Cumulative offset (actual position on the page, e.g. if you scrolled down it could be higher than max resolution height)
        
var _sourcePos        = $( _source ).cumulativeOffset();
        
        
// Cumulative offset of your scrolling (how much you have scrolled)
        
var _offset            = $( _source ).cumulativeScrollOffset();
        
        
// Real source position: Actual position on page, minus scroll offset (provides position on page within viewport)
        
var realSourcePos    = { top_sourcePos.top _offset.topleft_sourcePos.left _offset.left };
        
        
// Dimensions of source object
        
var sourceDim        = $( _source ).getDimensions();
        
        
// Viewport dimensions (e.g. 1280x1024)
        
var screenDim        document.viewport.getDimensions();
        
        
// Target dimensions
        
var menuDim            = { width: $( this.target ).measure('border-box-width'), height: $(this.target).measure('border-box-height') };
        
        var 
isFixed = $( _source ).ancestors().find( function(el){ return el.getStyle('position') == 'fixed'; } );
        
        
/* RTL bug fixes */
        
if( isRTL )
        {
            if( 
sourcePos.top )
            {
                
sourcePos.top    realSourcePos.top;
            }
            
            
// Really really hacky RTL bug fix... :(
            
if( $(_source).id == 'user_link' )
            {
                
//alert(sourcePos.left);
                
sourcePos.left sourcePos.left - ( parseInt($(_source).getStyle('padding-left').replace( /px/, '' )) + parseInt($(_source).getStyle('margin-left').replace( /px/, '' )) );
                
//alert(sourcePos.left);
            
}
        }
        
        
// Some logging    
        
Debug.write"realSourcePos: " realSourcePos.top " x " realSourcePos.left );
        
Debug.write"sourcePos: " sourcePos.top " x " sourcePos.left );
        
Debug.write"scrollOffset: " _offset.top " x " _offset.left );
        
Debug.write"_sourcePos: " _sourcePos.top " x " _sourcePos.left );
        
Debug.write"sourceDim: " sourceDim.width " x " sourceDim.height);
        
Debug.write"menuDim: " menuDim.height );
        
Debug.write"screenDim: " screenDim.height );
        
Debug.write"manual ofset: " this.options.offsetX " x " this.options.offsetY );

        
// Ok, if it's a relative parent, do one thing, else be normal
        // Getting fed up of this feature and IE bugs
        
_a _source.getOffsetParent();
        
_b this.target.getOffsetParent();
        
        
Debug.write("_a is " _a );
        
Debug.write("_b is " _b );
        
        if( 
isFixed )
        {
            $( 
this.target ).setStyle('position: fixed');
            
            if( ( 
_sourcePos.left menuDim.width ) > screenDim.width ){
                
diff menuDim.width sourceDim.width;
                
pos.left _sourcePos.left diff this.options.offsetX;
            } else {
                
pos.left = (_sourcePos.left) + this.options.offsetX;
            }
            
            if( ( 
_sourcePos.top menuDim.height ) > screenDim.height ){
                
pos.top _sourcePos.top menuDim.height this.options.offsetY;
            } else {
                
pos.top _sourcePos.top sourceDim.height this.options.offsetY;
            }
            
            
            $( 
this.target ).setStyle'top: ' + (pos.top-1) + 'px; left: ' pos.left 'px;' );
        }
        else
        {
            if( 
_a != _b )
            {
                
// Left
                
if( ( realSourcePos.left menuDim.width ) > screenDim.width ){
                    
diff menuDim.width sourceDim.width;
                    
pos.left _sourcePos.left diff this.options.offsetX;
                } else {
                    if( 
Prototype.Browser.IE7 ){
                        
pos.left = (_sourcePos.left) + this.options.offsetX;
                    } else {
                        
pos.left = (_sourcePos.left) + this.options.offsetX;
                    }
                }
            
                
// Top
                /* If there's no space to open downwards, open upwards *unless*
                /* it would go off the top of the screen (i.e. < 0px ) Bug #18270 */
                
if( 
                    ( ( ( 
realSourcePos.top sourceDim.height ) + menuDim.height ) > screenDim.height ) &&
                    ( 
_sourcePos.top menuDim.height this.options.offsetY ) > )
                {
                    
pos.top _sourcePos.top menuDim.height this.options.offsetY;
                } else {
                    
pos.top _sourcePos.top sourceDim.height this.options.offsetY;
                }
            }
            else
            {
                
Debug.write("MENU: source offset EQUALS target offset");
            
                
// Left
                
if( ( realSourcePos.left menuDim.width ) > screenDim.width ){
                    
diff menuDim.width sourceDim.width;
                    
pos.left sourcePos.left diff this.options.offsetX;
                } else {
                    
pos.left sourcePos.left this.options.offsetX;
                }
            
                
// Top
                /* If there's no space to open downwards, open upwards *unless*
                /* it would go off the top of the screen (i.e. < 0px ) Bug #18270 */
                
if( 
                    ( ( ( 
realSourcePos.top sourceDim.height ) + menuDim.height ) > screenDim.height ) &&
                    ( 
_sourcePos.top menuDim.height this.options.offsetY ) > )
                {
                    
pos.top sourcePos.top menuDim.height this.options.offsetY;
                } else {
                    
pos.top sourcePos.top sourceDim.height this.options.offsetY;
                }
            }
            
            $( 
this.target ).setStyle'top: ' + (pos.top-1) + 'px; left: ' pos.left 'px;' );
        }
        
        $( 
this.source ).addClassName('menu_active'); // Set active class on the source
        
        // Now set pos
        
Debug.write("Menu position: " pos.top " x " pos.left );
        
        
        
// If we have any fixed ancestors, then fix the menu too
        /*if( isFixed ){
            $( this.target ).setStyle('position: fixed');
        }*/
        
        // And show
        
new Effect.Appear( $( this.target ), { duration0.2afterFinish: function(e){
                if( 
Object.isFunctionthis.callbacks['afterOpen'] ) )
                {
                    
this.callbacks['afterOpen']( this );
                }
        }.
bind(this) } );
        
        
// Set key event so we can close on ESC
        
Event.observedocument'keypress'this.checkKeyPress.bindAsEventListenerthis ) );        
    },
    
    
checkKeyPress: function( )
    {
        
//Debug.write( e );
        
        
if( e.keyCode == Event.KEY_ESC )
        {
            
this.doClose();
        }        
    },

    
mouseOutClose: function()
    {
        
this.doClose();
    },

    
doClose: function()
    {
        new 
Effect.Fade( $( this.target ), { duration0.3afterFinish: function(e){
                if( 
Object.isFunctionthis.callbacks['afterClose'] ) )
                {
                    
this.callbacks['afterClose']( this );
                }
         }.
bindthis ) } );
        
        
//Debug.write( "Closing " + $( this.source ).id );
        
this.source.removeClassName('menu_active');
    },
    
    
targetClick: function(e)
    {
        if( !
this.options.stopClose ){
            
this.doClose();
        }
        
        
/*try
        {
            var elem = Event.findElement(e);
            
            if ( elem.hasClassName('_noCloseMenuUponClick') )
            {
                Event.stop(e);
            }
        }
        catch(e) { }
        
        if( ( this.options.stopClose && !$(elem).match("input") || $(elem).match("input") ) ){
            //if( $(e.target).match("[type=checkbox]")){
            //    Debug.write( $(e.target).checked );
            //    $(e.target).checked = true;
            //}
            Event.stop(e);
        }*/
    
},
    
    
eventClick: function(eelem)
    {
        if( 
this.options['eventType'] == 'click' )
        {
            
Event.stop(e);
            
            if( $( 
this.target ).visible() ){
                
                if( 
Object.isFunctionthis.callbacks['beforeClose'] ) )
                {
                    
this.callbacks['beforeClose']( this );
                }
                
                
this.doClose();
            } else {
                
ipb.menus.closeAll( $(this.source).id );
                
                if( 
Object.isFunctionthis.callbacks['beforeOpen'] ) )
                {
                    
this.callbacks['beforeOpen']( this );
                }
                
                
this.doOpen(elem);
            }
        }
    },
    
    
eventOver: function()
    {
        if( 
this.options['eventType'] == 'mouseover' )
        {
            if( !$( 
this.target ).visible() ){
                
                
ipb.menus.closeAll( $(this.source).id );
                
                if( 
Object.isFunctionthis.callbacks['beforeOpen'] ) )
                {
                    
this.callbacks['beforeOpen']( this );
                }
                
                
this.doOpen();
            }
        }
    }
});


/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.popup.js - Popup creator                    */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                        */
/************************************************/

/**
 * Full list of options:
 * 
 * type:             balloon, pane
 * modal:             true/false
 * w:                 width
 * h:                 height
 * classname:         classname to be applied to wrapper
 * initial:         initial content
 * ajaxURL:         If supplied, will ping URL for content and update popup
 * close:             element that will close popup (wont work with balloon)
 * attach:             { target, event, mouse, offset }
 * hideAtStart:     Hide after creation (allows showing at a later time)
 * stem:             true/false
 * delay:             { show, hide }
 */
_popup window.IPBoard;
_popup.prototype.Popup = Class.create({
        
    
initialize: function( idoptionscallbacks )
    {
        
/* Set up properties */
        
this.id                '';
        
this.wrapper        null;
        
this.inner            null;
        
this.stem            null;
        
this.options        = {};
        
this.timer            = [];
        
this.ready            false;
        
this.visible        false;
        
this._startup        null;
        
this.hideAfterSetup    false;
        
this.eventPairs        = {    'mouseover':     'mouseout',
                                
'mousedown':     'mouseup'
                              
};
        
this._tmpEvent         null;
        
        
/* Now run */
        
this.id id;
        
this.options Object.extend({
            
type:                 'pane',
            
w:                     '500px',
            
modal:                 false,
            
modalOpacity:         0.4,
            
hideAtStart:         true,
            
delay:                 { show0hide},
            
defer:                 false,
            
hideClose:             false,
            
black:                false,
            
warning:            false,
            
evalJs:                true,
            
closeContents:         ipb.templates['close_popup']        
        }, 
arguments[1] || {});
        
        
this.callbacks callbacks || {};
        
        
// Are we deferring the load?
        
if( this.options.defer && $( this.options.attach.target ) )
        {
            
this._defer this.init.bindAsEventListenerthis );
            $( 
this.options.attach.target ).observethis.options.attach.eventthis._defer );
            
            if( 
this.eventPairsthis.options.attach.event ] )
            {
                
this._startup = function(e){ this.hideAfterSetup truethis.hide(); }.bindAsEventListenerthis );
                $( 
this.options.attach.target ).observethis.eventPairsthis.options.attach.event ], this._startup  );
            }
        }
        else
        {
            
this.init();
        }
    },
    
    
init: function()
    {
        try {
            
Event.stopObserving( $( this.options.attach.target ), this.options.attach.eventthis._defer );
            
            if ( $(
this.options.attach.target) )
            {
                var 
toff = $( this.options.attach.target ).positionedOffset();
                var 
menu = $(this.options.attach.target).up('.ipbmenu_content');
                
                if ( 
toff.top == && toff.left == || $(menu) )
                {
                    
/* make it a centered box */
                    
this.options.type 'modal';
                    
this.options.attach = {};
                }
            }
            
        } catch(
err) { }
        
        
        
this.wrapper = new Element('div', { 'id'this.id '_popup' } ).setStyle('z-index: 10001').hide().addClassName('popupWrapper');
        
        
this.inner = new Element('div', { 'id'this.id '_inner' } ).addClassName('popupInner');
        
        if ( 
this.options.black )
        {
            
this.inner.addClassName('black_mode');
        }
        
        if ( 
this.options.warning )
        {
            
this.inner.addClassName('warning_mode');
        }
        
        if( 
this.options.){ this.inner.setStyle'width: ' this.options.); }
        
        
this.wrapper.insertthis.inner );
        
        if( 
this.options.hideClose != true )
        {
            
this.closeLink = new Element('div', { 'id'this.id '_close' } ).addClassName('popupClose').addClassName('clickable');
            
this.closeLink.updatethis.options.closeContents );
            
this.closeLink.observe('click'this.hide.bindAsEventListenerthis ) );
            
this.wrapper.insertthis.closeLink );
            
            if ( 
this.options.black || this.options.warning )
            {
                
this.closeLink.addClassName('light_close_button');
            }
        }
        
        $$(
'body')[0].insertthis.wrapper );
    
        if( 
this.options.classname ){ this.wrapper.addClassNamethis.options.classname ); }
        
        if( 
this.options.initial ){
            
this.updatethis.options.initial );
        }
        
        
// Callback
        
if( Object.isFunctionthis.callbacks['beforeAjax'] ) )
        {
            
this.callbacks['beforeAjax']( this );
        }
        
        
// If we are updating with ajax, handle the show there
        
if( this.options.ajaxURL ){
            
this.updateAjax();
            
setTimeoutthis.continueInit.bind(this), 80 );
        } else {
            
this.ready true;
            
this.continueInit();
        }
    },
    
    
continueInit: function()
    {
        if( !
this.ready )
        {
            
setTimeoutthis.continueInit.bind(this), 80 );
            return;
        }
        
        
/* Ensure pop-up isn't larger than viewport */
        
if( this.inner.select(".fixed_inner").size() )
        {
            
Debug.write("Found fixed_inner");
            
this.inner.select(".fixed_inner")[0].setStyle'height: ' this.options.'px; max-height: ' this.options.'px; overflow: auto' );
        }
        else
        {
            var 
_vph document.viewport.getDimensions().height 25;
            
this.options.= ( this.options.&& _vph this.options.) ? this.options._vph;
            
this.inner.setStyle'max-height: ' this.options.'px' );
        }
        
        
//Debug.write("Continuing...");
        // What are we making?
        
if( this.options.type == 'balloon' ){
            
this.setUpBalloon();
        } else {
            
this.setUpPane();
        }
        
        
// Set up close event
        
try {
            if( 
this.options.close ){
                
closeElem = $( this.wrapper ).selectthis.options.close )[0];
                
                if( 
Object.isElementcloseElem ) )
                {
                    $( 
closeElem ).observe'click'this.hide.bindAsEventListenerthis ) );
                }
            }
        } catch( 
err ) {
            
Debug.writeerr );
        }
        
        
// Callback
        
if( Object.isFunctionthis.callbacks['afterInit'] ) )
        {
            
this.callbacks['afterInit']( this );
        }
        
        if( !
this.options.hideAtStart && !this.hideAfterSetup )
        {
            
this.show();
        }
        if( 
this.hideAfterSetup && this._startup )
        {    
            
Event.stopObserving( $( this.options.attach.target ), this.eventPairsthis.options.attach.event ], this._startup );
        }
    },
    
    
updateAjax: function()
    {
        
Debug.writethis.options.ajaxURL );
        new 
Ajax.Requestthis.options.ajaxURL,
                        {
                            
method'get',
                            
evalJSthis.options.evalJs,
                            
onSuccess: function(t)
                            {
                                if ( 
t.responseText != 'error' )
                                { 
                                    try
                                    {
                                        if ( ! 
Object.isUndefinedt.responseJSON ) && ! Object.isUndefinedt.responseJSON['error'] ) )
                                        {
                                            if ( 
t.responseJSON['__board_offline__'] )
                                            {
                                                
ipb.global.errorDialogueipb.lang['board_offline'] );
                                                
ipb.menus.closeAll(e);
                                            }
                                            else
                                            {
                                                
ipb.global.errorDialoguet.responseJSON['error'] );
                                            }
                                            
                                            return 
false;
                                        }
                                    } catch(
e){}
                                    
                                    if ( 
t.responseText == 'nopermission' )
                                    {
                                        
ipb.global.errorDialogueipb.lang['no_permission'] );
                                        return;
                                    }
                                    
                                    
/* Check for log out */
                                    
if ( t.responseText.match"__session__expired__log__out__" ) )
                                    {
                                        
this.update('');
                                        
alertipb.lang['session_timed_out'] );
                                        return 
false;
                                    }
                                    
                                    
Debug.write"AJAX done!" );
                                    
this.updatet.responseText );
                                    
this.ready true;
                                    
                                    
// Callback
                                    
if( Object.isFunctionthis.callbacks['afterAjax'] ) )
                                    {
                                        
this.callbacks['afterAjax']( thist.responseText );
                                    }
                                }
                                else
                                {
                                    
Debug.writet.responseText );
                                    return;
                                }
                            }.
bind(this)
                        });
    },
    
    
show: function(e)
    { 
        if( 
){ Event.stop(e); }
        
        if( 
this.timer['show'] ){
            
clearTimeoutthis.timer['show'] );
        }
        
        if( 
this.options.delay.show != ){
        
            
this.timer['show'] = setTimeoutthis._show.bindthis ), this.options.delay.show );
        } else {
            
this._show(); // Just show it
        
}
    },
    
    
hide: function(e)
    {
        if( 
){ Event.stop(e); }
        if( 
this.document_event ){
            
Event.stopObservingdocument'click'this.document_event );
        }
        
        if( 
this.timer['hide'] ){
            
clearTimeoutthis.timer['hide'] );
        }
                
        if( 
this.options.delay.hide != ){
            
this.timer['hide'] = setTimeoutthis._hide.bindthis ), this.options.delay.hide );
        } else {
            
this._hide(); // Just hide it
        
}
    },
    
    
/* remove wrapper and kill timeouts */
    
kill: function()
    {
        if( 
this.timer['hide'] ){
            
clearTimeoutthis.timer['hide'] );
        }
        
        if( 
this.timer['show'] ){
            
clearTimeoutthis.timer['show'] );
        }
        
        if( $( 
this.wrapper ) )
        {
            $( 
this.wrapper ).remove();
        }
    },
    
    
_show: function()
    {
        
this.visible true;
        
        
/* Experimental */
        
try
        {
            if ( 
this.options.warning )
            {
                
_wrap this.inner.down('h3').next('div');
                
                if ( 
_wrap )
                {
                    if ( ! 
_wrap.className.match( /moderated/ ) )
                    {
                        
_wrap.addClassName('moderated');
                    }
                }
            }
        } catch(
e){}
        
        if( 
this.options.modal == false ){
            new 
Effect.Appear( $( this.wrapper ), { duration0.3afterFinish: function(){
                if( 
Object.isFunctionthis.callbacks['afterShow'] ) )
                {
                    
this.callbacks['afterShow']( this );
                }
            }.
bind(this) } );
            
this.document_event this.handleDocumentClick.bindAsEventListener(this);
            
this.setDocumentEvent();
        } else {
            new 
Effect.Appear( $('document_modal'), { duration0.3tothis.options.modalOpacityafterFinish: function(){
                new 
Effect.Appear( $( this.wrapper ), { duration0.4afterFinish: function(){
                    if( 
Object.isFunctionthis.callbacks['afterShow'] ) )
                    {
                        
this.callbacks['afterShow']( this );
                    }
                 }.
bind(this) } );
            }.
bind(this) });
        }
    },
    
    
_hide: function()
    {
        
this.visible false;
        
        if( 
this._tmpEvent != null )
        {
            
Event.stopObserving( $( this.wrapper ), 'mouseout'this._tmpEvent );
            
this._tmpEvent null;
        }
                        
        if( 
this.options.modal == false ){
            new 
Effect.Fade( $( this.wrapper ), { duration0.3afterFinish: function(){
                if( 
Object.isFunctionthis.callbacks['afterHide'] ) )
                {
                    
this.callbacks['afterHide']( this );
                }
            }.
bind(this) } );
        } else {
            new 
Effect.Fade( $( this.wrapper ), { duration0.3afterFinish: function(){
                new 
Effect.Fade( $('document_modal'), { duration0.2afterFinish: function(){
                    if( 
Object.isFunctionthis.callbacks['afterHide'] ) )
                    {
                        
this.callbacks['afterHide']( this );
                    }
                }.
bind(this) } );
            }.
bind(this) });
        }
    },
    
    
setDocumentEvent: function()
    {        
        if( !
ipb.vars['is_touch'] ){
            
Event.observedocument'click'this.document_event );
            return;
        }
        
        
// Touch event
        
Event.observedocument'touchstart'this.document_event );
    },
    
    
handleDocumentClick: function(e)
    {
        
Debug.write'document click: ' Event.element(e).id);
        
        if( !
Event.element(e).descendantOfthis.wrapper ) && ( this.options.attach && ( Event.element(e).id != this.options.attach.target.id ) ) )
        {
            
this.hide(e);
        }
    },
    
    
update: function( contentevalScript )
    {
        if( 
Object.isElementcontent ) ){
            
this.inner.insert( { bottomcontent } );
        } else {
            
this.inner.updatecontent );
        }
        
        
// Should this popup eval scripts? Default is YES
        
if( Object.isUndefinedevalScript ) || evalScript != false ){
            
this.inner.innerHTML.evalScripts();
        }
    },
    
    
setUpBalloon: function()
    {
        
// Are we attaching?
        
if( this.options.attach )
        {
            var 
attach this.options.attach;
            
            if( 
attach.target && $( attach.target ) )
            {                
                if( 
this.options.stem == true )
                {
                    
this.createStem();
                }
                
                
// Get position
                
if( !attach.position ){ attach.position 'auto'; }
                
                if( 
isRTL )
                {
                    if( 
Object.isUndefinedattach.offset ) ){ attach.offset = { top0right}; }
                    if( 
Object.isUndefinedattach.offset.top ) ){ attach.offset.top 0; }
                    if( 
Object.isUndefinedattach.offset.left ) ){ attach.offset.right 0; }else{ attach.offset.right attach.offset.left; }
                }
                else
                {
                    if( 
Object.isUndefinedattach.offset ) ){ attach.offset = { top0left}; }
                    if( 
Object.isUndefinedattach.offset.top ) ){ attach.offset.top 0; }
                    if( 
Object.isUndefinedattach.offset.left ) ){ attach.offset.left 0; }
                }
                
                if( 
attach.position == 'auto' )
                {
                    
Debug.write("Popup: auto-positioning");
                    var 
screendims         document.viewport.getDimensions();
                    var 
screenscroll     document.viewport.getScrollOffsets();
                    var 
toff            = $( attach.target ).viewportOffset();
                    var 
wrapSize         = $( this.wrapper ).getDimensions();
                    var 
delta             = [0,0];
                    
                    if (
Element.getStyle( $( attach.target ), 'position') == 'absolute')
                    {
                        var 
parent attach.target.getOffsetParent();
                        
delta parent.viewportOffset();
                    }
                
                    if( 
isRTL )
                    {
                        
toff['right'] = screendims.width - ( toff[0] - delta[0] );
                    }
                    else
                    {
                        
toff['left'] = toff[0] - delta[0];
                    }
                    
toff['top'] = toff[1] - delta[1] + screenscroll.top;

                    
//Debug.write( toff['left'] + "    " + toff['top'] );
                    // Need to figure out if it will be off-screen
                    
var start     'top';
                    
                    if( 
isRTL ){
                        var 
end     'right';
                    } else {
                        var 
end     'left';
                    }

                    
//Debug.write( "Target offset top: " + toff.top + ", wrapSize Height: " + wrapSize.height + ", screenscroll top: " + screenscroll.top);
                    
if( ( toff.top wrapSize.height attach.offset.top ) < ( screenscroll.top ) ){
                        var 
start 'bottom';
                    }
                    
                    if( 
isRTL )
                    {
                        if( ( 
toff.right wrapSize.width attach.offset.right ) < ( screendims.width screenscroll.left ) ){
                            var 
end 'left';
                        }
                    }
                    else
                    {
                        if( ( 
toff.left wrapSize.width attach.offset.left ) > ( screendims.width screenscroll.left ) ){
                            var 
end 'right';
                        }
                    }

                    
finalPos this.positionstart end, { target: $( attach.target ), content: $( this.wrapper ), offsetattach.offset } );
                    
                    if( 
this.options.stem == true )
                    {
                        
finalPos this.positionStemstart endfinalPos );
                    }
                }
                else
                {
                    
Debug.write("Popup: manual positioning");
                    
                    
finalPos this.positionattach.position, { target: $( attach.target ), content: $( this.wrapper ), offsetattach.offset } );
                    
                    if( 
this.options.stem == true )
                    {
                        
finalPos this.positionStemattach.positionfinalPos );
                    }
                }
                
                
// Add mouse events
                
if( !Object.isUndefinedattach.event ) ){
                    $( 
attach.target ).observeattach.eventthis.show.bindAsEventListenerthis ) );
                    
                    if( 
attach.event != 'click' && !Object.isUndefinedthis.eventPairsattach.event ] ) ){
                        $( 
attach.target ).observethis.eventPairsattach.event ], this.hide.bindAsEventListenerthis ) );
                    }
                        
                    $( 
this.wrapper ).observe'mouseover'this.wrapperEvent.bindAsEventListenerthis ) );                    
                }                
            }
        }
        
        if( 
isRTL )
        {
            
Debug.write("Popup: Right: " finalPos.right "; Top: " finalPos.top);
            $( 
this.wrapper ).setStyle'top: ' finalPos.top 'px; right: ' finalPos.right 'px; position: absolute;' );
        }
        else
        {
            
Debug.write("Popup: Left: " finalPos.left "; Top: " finalPos.top);
            $( 
this.wrapper ).setStyle'top: ' finalPos.top 'px; left: ' finalPos.left 'px; position: absolute;' );
        }
    },
    
    
wrapperEvent: function(e)
    {
        if( 
this.timer['hide'] )
        {
            
// Cancel event now
            
clearTimeoutthis.timer['hide'] );
            
this.timer['hide'] = null;
            
            if( 
this.options.attach.event && this.options.attach.event == 'mouseover' )
            {
                
// Set new event to account for mouseout of the popup,
                // but only if we don't already have one - otherwise we get
                // expontentially more event calls. Bad.
                
if( this._tmpEvent == null ){
                    
this._tmpEvent this.hide.bindAsEventListenerthis );
                    $( 
this.wrapper ).observe('mouseout'this._tmpEvent );
                }
            }
        }
    },
    
    
positionStem: function( posfinalPos )
    {
        var 
stemSize = { height16width31 };
        var 
wrapStyle = {};
        var 
stemStyle = {};
        
        switch( 
pos.toLowerCase() )
        {
            case 
'topleft':
                
wrapStyle = { marginBottomstemSize.height 'px' };
                
                if( 
isRTL )
                {
                    
stemStyle = { bottom: -(stemSize.height) + 'px'right'5px' };
                    
finalPos.right finalPos.right 15;
                }
                else
                {
                    
stemStyle = { bottom: -(stemSize.height) + 'px'left'5px' };
                    
finalPos.left finalPos.left 15;
                }
                break;
            case 
'topright':
                
wrapStyle = { marginBottomstemSize.height 'px' };

                if( 
isRTL )
                {
                    
stemStyle = { bottom: -(stemSize.height) + 'px'left'5px' };
                    
finalPos.right finalPos.right 15;
                }
                else
                {
                    
stemStyle = { bottom: -(stemSize.height) + 'px'right'5px' };
                    
finalPos.left finalPos.left 15;
                }
                break;
            case 
'bottomleft':
                
wrapStyle = { marginTopstemSize.height 'px' };

                if( 
isRTL )
                {
                    
stemStyle = { top: -(stemSize.height) + 'px'right'5px' };
                    
finalPos.right finalPos.right 15;
                }
                else
                {
                    
stemStyle = { top: -(stemSize.height) + 'px'left'5px' };
                    
finalPos.left finalPos.left 15;
                }
                break;
            case 
'bottomright':
                
wrapStyle = { marginTopstemSize.height 'px' };

                if( 
isRTL )
                {
                    
stemStyle = { top: -(stemSize.height) + 'px'left'5px' };
                    
finalPos.right finalPos.right 15;
                }
                else
                {
                    
stemStyle = { top: -(stemSize.height) + 'px'right'5px' };
                    
finalPos.left finalPos.left 15;
                }
                break;
        }

        $( 
this.wrapper ).setStylewrapStyle );
        $( 
this.stem ).setStylestemStyle ).setStyle('z-index: 6000').addClassNamepos.toLowerCase() );
        
        return 
finalPos;
    },
    
    
position: function( pos)
    {
        
finalPos = {};
        
        
v.target.identify();
        
        var 
toff            = $( v.target.id ).viewportOffset();
        var 
tsize             = $( v.target.id ).getDimensions();
        var 
wrapSize         = $( v.content ).getDimensions();
        var 
screenscroll     document.viewport.getScrollOffsets();
        var 
offset             v.offset;
        var 
delta            = [0,0];
        
        if (
Element.getStyle( $( v.target.id ), 'position') == 'absolute')
        {
            var 
parent = $( v.target.id ).getOffsetParent();
            
delta    parent.viewportOffset();
            
            
/* That above doesn't help */
            
delta = [0,0];
        
        }
        
        if( 
isRTL )
        {
            
toff['right'] = document.viewport.getDimensions().width - ( toff[0] - delta[0] );
        }
        else
        {
            
toff['left'] = toff[0] - delta[0];
        }
        
        
toff['top'] = toff['top'] - delta[1] + screenscroll.top;
                
        switch( 
pos.toLowerCase() )
        {
            case 
'topleft':
                
finalPos.top = ( toff.top wrapSize.height - ( tsize.height ) ) - offset.top;
                
                if( 
isRTL )
                {
                    
finalPos.right toff.right offset.right;
                }
                else
                {
                    
finalPos.left toff.left offset.left;
                }
                break;
            case 
'topright':            
                 
finalPos.top = ( toff.top wrapSize.height - ( tsize.height ) ) - offset.top;
                 
                 if( 
isRTL )
                 {
                     
finalPos.right = ( toff.right - ( wrapSize.width tsize.width ) ) - offset.right;
                 }
                 else
                 {
                    
finalPos.left = ( toff.left - ( wrapSize.width tsize.width ) ) - offset.left;
                }
                break;
            case 
'bottomleft':
                
finalPos.top = ( toff.top tsize.height ) + offset.top;
                
                if( 
isRTL )
                {
                    
finalPos.right toff.right offset.right;
                }
                else
                {
                    
finalPos.left toff.left offset.left;
                }
                break;
            case 
'bottomright':
                
finalPos.top = ( toff.top tsize.height ) + offset.top;
                
                if( 
isRTL )
                {
                    
finalPos.right = ( toff.right - ( wrapSize.width tsize.width ) ) - offset.right;
                }
                else
                {
                    
finalPos.left = ( toff.left - ( wrapSize.width tsize.width ) ) - offset.left;
                }
                break;
        }
    
        return 
finalPos;
    },
    
    
createStem: function()
    {
        
this.stem = new Element('div', { idthis.id '_stem' } ).update('&nbsp;').addClassName('stem');
        
this.wrapper.insert( { topthis.stem } );
    },
    
    
setUpPane: function()
    {
        
// Does the document have a modal blackout?
        
if( !$('document_modal') ){
            
this.createDocumentModal();
        }
        
        
this.positionPane();    
    },
    
    
positionPane: function()
    {
        
// Position it in the middle
        
var elem_s = $( this.wrapper ).getDimensions();
        var 
window_s document.viewport.getDimensions();
        var 
window_offsets document.viewport.getScrollOffsets();

        if( 
ipb.vars['is_touch'] ){
            
// #35826: On some skins, webkit will handle the document viewport sizes incorrectly.
            // To try and protect against this, we'll use the actual screen size for these
            // calculations.
            
window_s = { widthwindow.innerWidthheightwindow.innerHeight };
        }
        
        if( 
isRTL )
        {
            var 
center = {     right: ((window_s['width'] - elem_s['width']) / 2),
                             
top: (((window_s['height'] - elem_s['height']) / 2)/2)
                        };
                        
            if( 
center.top 10 ){ center.top 10; }
                        
            $( 
this.wrapper ).setStyle('top: ' center['top'] + 'px; right: ' center['right'] + 'px; position: fixed;');

        }
        else
        {
            var 
center = {     left: ((window_s['width'] - elem_s['width']) / 2),
                             
top: (((window_s['height'] - elem_s['height']) / 2)/2)
                        };

            if( 
center.top 10 ){ center.top 10; }
                        
            $( 
this.wrapper ).setStyle('top: ' center['top'] + 'px; left: ' center['left'] + 'px; position: fixed;');
        }
    },
            
    
createDocumentModal: function()
    {
        var 
pageLayout = $( document.body ).getLayout();
        var 
pageSize = { widthpageLayout.get('width'), heightpageLayout.get('margin-box-height') };
        var 
viewSize document.viewport.getDimensions();
        
        var 
dims = [];
        
        
Debug.dirpageSize );
        
Debug.dirviewSize );
        
        if( 
viewSize['height'] < pageSize['height'] ){
            
dims['height'] = pageSize['height'];
        } else {
            
dims['height'] = viewSize['height'];
        }
        
        if( 
viewSize['width'] < pageSize['width'] ){
            
dims['width'] = pageSize['width'];
        } else {
            
dims['width'] = viewSize['width'];
        }
        
        var 
modal = new Element'div', { 'id''document_modal' } ).addClassName('modal').hide();
        
        if( 
isRTL ){
            
modal.setStyle('width: ' dims['width'] + 'px; height: ' dims['height'] + 'px; position: fixed; top: 0px; right: 0px; z-index: 10000;');
        } else {
            
modal.setStyle('width: ' dims['width'] + 'px; height: ' dims['height'] + 'px; position: fixed; top: 0px; left: 0px; z-index: 10000;');
        }
        
        $$(
'body')[0].insertmodal );
    },
    
    
getObj: function()
    {
        return $( 
this.wrapper );
    }
});

/************************************************/
/* IPB3 Javascript                                */
/* -------------------------------------------- */
/* ips.ticker.js - Popup creator                */
/* (c) IPS, Inc 2008                            */
/* -------------------------------------------- */
/* Author: Rikki Tissier                        */
/************************************************/
_ticker window.IPBoard;
_ticker.prototype.Ticker = Class.create({        
    
initialize: function( rootoptionscallbacks )
    {
        if( !$(
root) ){
            return;
        }
        
this.root = $(root);
        
this.options Object.extend({
            
duration4,
            
select"li"
        
}, options || {});
        
        
this.items = $( root ).selectthis.options.select );
        if( !
this.items.length ){ return; }
        
        
// Hide all items except first
        
this.items.invoke('hide').first().show();
        
        
// Start timer
        
this.timer this.nextItem.bindthis ).delaythis.options.duration );
        
        
// Pause event
        
$( this.root ).observe('mouseenter'this.pauseTicker.bindAsEventListenerthis ) );
        $( 
this.root ).observe('mouseleave'this.unpauseTicker.bindAsEventListenerthis ) );
    },
    
pauseTicker: function(e)
    {
        
clearTimeoutthis.timer );
    },
    
unpauseTicker: function(e)
    {
        
this.timer this.nextItem.bind(this).delaythis.options.duration );
    },
    
nextItem: function()
    {
        
// Find current item
        
var cur this.items.find( function(elem){
            return 
elem.visible();
        });

        var 
next = $( cur ).nextthis.options.select );

        if( 
Object.isUndefinednext ) ){
            
next this.items.first();
        }

        
// Fade current
        
new Effect.Fade( $( cur ), { duration0.4queue'end'afterFinish: function(){
            new 
Effect.Appear( $( next ), { duration0.8queue'end' } );
        } } );

        
// Reset timer
        
this.timer this.nextItem.bindthis ).delaythis.options.duration );
    }
});

function 
warningPopupelemid )
{
    var 
_url ipb.vars['base_url'] + '&app=members&module=ajax&secure_key=' ipb.vars['secure_hash'] + '&section=warnings&id=' id;
    new 
ipb.Popup'warning' id, {
        
type'balloon',
        
stemtrue,
        
attach: { targetelemposition'auto' },
        
hideAtStartfalse,
        
ajaxURL_url,
        
w'600px',
        
h800
    
});
}

ipb = new IPBoard;
ipb.global.init();
ipb.menus.init();
?>
Онлайн: 1
Реклама