function getBounds(element)
{
  var left = element.offsetLeft;
  var top = element.offsetTop;
  for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
  {
    left += parent.offsetLeft;
    top += parent.offsetTop;
  }
  return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

function my_getcookie( name )
{
        cname = ipb_var_cookieid + name + '=';
        cpos  = document.cookie.indexOf( cname );

        if ( cpos != -1 )
        {
                cstart = cpos + cname.length;
                cend   = document.cookie.indexOf(";", cstart);

                if (cend == -1)
                {
                        cend = document.cookie.length;
                }

                return unescape( document.cookie.substring(cstart, cend) );
        }

        return null;
}

function my_setcookie( name, value, sticky )
{
        expire = "";
        domain = "";
        path   = "/";

        if ( sticky )
        {
                expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
        }

        if ( ipb_var_cookie_domain != "" )
        {
                domain = '; domain=' + ipb_var_cookie_domain;
        }

        if ( ipb_var_cookie_path != "" )
        {
                path = ipb_var_cookie_path;
        }

        document.cookie = ipb_var_cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';
}

function buddy_pop()
{
ipb_var_base_url = ipb_var_base_url.replace( '&amp;', '&' );
window.open( ipb_var_base_url + 'act=buddy','BrowserBuddy','width=250,height=500,resizable=yes,scrollbars=yes');

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

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

        msg = ipb_lang_tpl_q1 + " " + pages;

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

        show_page = 1;

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

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

        userPage = prompt( msg, show_page );

        if ( userPage > 0  )
        {
                if ( userPage < 1 )     {    userPage = 1;  }
                if ( userPage > pages ) { userPage = pages; }
                if ( userPage == 1 )    {     start = 0;    }
                else { start = (userPage - 1) * per_page; }

                window.location = url_bit + "&st=" + start;
        }
}
function ShowHide(id1, id2)
{
        if (id1 != '') toggleview(id1);
        if (id2 != '') toggleview(id2);
}

function expMenu(id) {
          var itm = null;
          if (document.getElementById) {
                itm = document.getElementById(id);
          } else if (document.all){
                itm = document.all[id];
          } else if (document.layers){
                itm = document.layers[id];
          }

          if (!itm) {
           // do nothing
          }
          else if (itm.style) {
                if (itm.style.display == "none") { itm.style.display = ""; }
                else { itm.style.display = "none"; }
          }
          else { itm.visibility = "show"; }
        }
function my_getbyid(id)
{
        itm = null;

        if (document.getElementById)
        {
                itm = document.getElementById(id);
        }
        else if (document.all)
        {
                itm = document.all[id];
        }
        else if (document.layers)
        {
                itm = document.layers[id];
        }

        return itm;
}
function toggleview(id)
{
        if ( ! id ) return;

        if ( itm = my_getbyid(id) )
        {
                if (itm.style.display == "none")
                {
                        my_show_div(itm);
                }
                else
                {
                        my_hide_div(itm);
                }
        }
}
function my_hide_div(itm)
{
        if ( ! itm ) return;

        itm.style.display = "none";
}
function my_show_div(itm)
{
        if ( ! itm ) return;

        itm.style.display = "";
}
function togglecategory( fid, add )
{
        saved = new Array();
        clean = new Array();
        if ( tmp = my_getcookie('collapseprefs') )
        {
                saved = tmp.split(",");
        }
        for( i = 0 ; i < saved.length; i++ )
        {
                if ( saved[i] != fid && saved[i] != "" )
                {
                        clean[clean.length] = saved[i];
                }
        }
        if ( add )
        {
                clean[ clean.length ] = fid;
                my_show_div( my_getbyid( 'fc_'+fid  ) );
                my_hide_div( my_getbyid( 'fo_'+fid  ) );
        }
        else
        {
                my_show_div( my_getbyid( 'fo_'+fid  ) );
                my_hide_div( my_getbyid( 'fc_'+fid  ) );
        }

        my_setcookie( 'collapseprefs', clean.join(','), 1 );
}
function locationjump(url)
{
        window.location = ipb_var_base_url + url;
}
function PopUp(url, name, width,height,center,resize,scroll,posleft,postop)
{
        showx = "";
        showy = "";

        if (posleft != 0) { X = posleft }
        if (postop  != 0) { Y = postop  }

        if (!scroll) { scroll = 1 }
        if (!resize) { resize = 1 }

        if ((parseInt (navigator.appVersion) >= 4 ) && (center))
        {
                X = (screen.width  - width ) / 2;
                Y = (screen.height - height) / 2;
        }

        if ( X > 0 )
        {
                showx = ',left='+X;
        }

        if ( Y > 0 )
        {
                showy = ',top='+Y;
        }

        if (scroll != 0) { scroll = 1 }

        var Win = window.open( url, name, 'width='+width+',height='+height+ showx + showy + ',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}
var loadedurls={};
function crel(url)
{
 if (!loadedurls[url])
 {
 var t=document.createElement('script');
   t.type='text/javascript';
   t.src=url;
   var d=document.getElementById('appendajax');
   d.appendChild(t);
 }
}

function crelcss(url)
{
 if (!loadedurls[url])
 {
   var t=document.createElement('link');
   t.type='text/css';
   t.rel='stylesheet';
   t.href=url;
   var d=document.getElementById('appendajax');
   d.appendChild(t);
 }
}

function ajax_request (query_string, script)
{ if (!script) script="ajax.php";
  //setTimeout("",1000);
 
 try
 {
   var http = get_http();
   http.open('POST', ipb_var_home_url+script+'?__=' +Math.random(), true);
   http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   http.send(query_string);
   http.onreadystatechange = function() {
   if (http.readyState == 4)
     if (http.responseText)
      ajax_ev(http.responseText);
   }
 }  catch (e)
 {if (query_string.length<2000)crel(ipb_var_home_url+script+'?'+query_string+"&__=" +Math.random());}
}
function get_http(){
    var xmlhttp;
    if (!xmlhttp && typeof (XMLHttpRequest) != undefined) {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
           try {
           xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
           }
           catch (E) {
            xmlhttp = false;
            }
        }
    }
    return xmlhttp;
}
function ajax_ev(a){eval(a);}
function encodeurl ( url ){return escape(url).replace(/\+/g, "%2B");}


function std_window_resize( box, pix ){var cur_height = parseInt( box.rows ) ? parseInt( box.rows ) : 20;var new_height = cur_height + pix;if ( new_height > 0 ){box.rows = new_height;
        }

        return false;
}
function lang_build_string(){if ( ! arguments.length || ! arguments ){return;}var string = arguments[0];for( var i = 1 ; i < arguments.length ; i++ ){var match  = new RegExp('<%' + i + '>', 'gi');string = string.replace( match, arguments[i] );}return string;}
var pm_ref_height=200;
var pm_ref_width=550;
var pm_ref_time=300000;
var lastdocomm=0;
function pm_resize (h,w)
{ var d=document.getElementById('root');
  d.style.height=h+'px';
  d.style.width=w+'px';
  document.getElementById('handle').style.width=(w-8)+'px';
  document.getElementById('pm_cont').style.height=(h-20)+'px';
}
function pm_refresh(mid){if(_get_time_now()-pm_ref_lastload>=pm_ref_time && _get_time_now()-pm_page_load>=pm_ref_time) ajax_request('act=check_pm&mid='+mid+'&loaded='+pm_ref_loaded_modules+'&lastload='+pm_ref_lastload+'&nextdiv='+pm_ref_next_div+'&last_id='+pm_ref_last_id+'&md='+pm_ref_md, "pmcheck.php");}



 

