var min = 0;
var max = 1000;
var cur = 0;
var step = 3;
var imgs = new Array( "g0", "g1", "g2", "g3", "g4" );
var st_event = "function onmouseover(event) {\n";
var e_event = "\n}";
var sTipHeader = new Array();
var sTipBody = [];

function reset_images()
{
    sTipHeader.length = 0; 
    sTipBody.length = 0; 
    for( i = 0; i < reset_images.arguments.length; i += 5 )
    {
        x = i/5;
        img = document.getElementById( imgs[x] );
        lnk = document.getElementById( "a" + imgs[x] );
        tip = document.getElementById( imgs[x] + "tip" );
        if( img )
        {
            img.src = "phpBB3/images/thumbnails/" + reset_images.arguments[i] + ".jpg";
            lnk.href = "phpBB3/viewtopic.php?t=" + reset_images.arguments[i];
            if( tip )
            {
                sTipHeader[x] = "Author: " + reset_images.arguments[i+1];
                sTipBody[x] = "Forum: " + reset_images.arguments[i+2] + "<br>" +
                                "Title: " + reset_images.arguments[i+3] + "<br>" +
                                "Date: " + reset_images.arguments[i+4];
            }
        }
    }


    if( cur <= min )
        enable_click( "leftclick", false );
    else
        enable_click( "leftclick", true );

    if( cur > ( max - step ))
        enable_click( "rightclick", false );
    else
        enable_click( "rightclick", true );
}

function update_thumb_ids(val)
{
    if( val )
        cur += step * val;
//    xajax_get_next_thumb_ids( cur, step );
}

function enable_click( val, toggle )
{
    obj = document.getElementById( val );
    if( obj )
    {
        obj.disabled = !toggle;
    }
}

function toggle_body( id )
{
    obj = document.getElementById( id );
    obj_img = document.getElementById( id + "_img" );
    if( obj )
    {
        if( obj.style.display == "" )
        {
            obj.style.display = "none";
            obj_img.src = "frontpage/j_arrow_left.png";
        }
        else
        {
            obj.style.display = "";
            obj_img.src = "frontpage/j_arrow_down.png";
        }
    }
}


function ShowTip()
{
    var args = ShowTip.arguments;
    var hdr = document.getElementById( "tip_hdr" );
    var bdy = document.getElementById( "tip_bdy" );
    var tooltip = document.getElementById( "tooltip" );
    if( args[0] < 0 )
    {
        if( hdr && args[1] )
            hdr.innerHTML = args[1];
        if( bdy && args[2] )
            bdy.innerHTML = args[2];
    }
    else
    {
        if( hdr )
            hdr.innerHTML = sTipHeader[args[0]];
        if( bdy )
            bdy.innerHTML = sTipBody[args[0]];
    }

    tooltip.style.zIndex = 100;
    tip_visible = true;
}

function HideTip()
{
    tip = document.getElementById( "tooltip" );
    if( tip )
        tip.style.visibility = "hidden";
    tip_visible = false;
}

if( typeof document.attachEvent != 'undefined' ) 
{
    document.attachEvent( 'onmousemove', getMouseXY );
}
else 
{
    document.addEventListener( 'mousemove', getMouseXY, false );
}


var IE = document.all?true:false;
var curX = 0, oldX = 0;
var curY = 0, oldY = 0;
var tip_visible = false;

function getMouseXY( e )
{
    if( !tip_visible )
        return;

    if( IE )
    { // grab the x-y pos.s if browser is IE
        curX = event.clientX + document.body.scrollLeft;
        curY = event.clientY + document.body.scrollTop;
    }
    else 
    {  // grab the x-y pos.s if browser is NS
        curX = e.pageX;
        curY = e.pageY;
    }  
    if( curX < 0 ) curX = 0;
    if( curY < 0 ) curY = 0;  

    if( oldX != curX || oldY != curY )
    {
        tip = document.getElementById( "tooltip" );
        if( tip )
        {
            tip.style.visibility = "hidden";
            tip.style.left = ( curX + 5 ) + "px";
            tip.style.top = ( curY + 5 ) + "px";
            tip.style.visibility = "visible";
        }
        oldX = curX;
        oldY = curY;
    }

    return true;
}
