var fm_id           ='sliding';     // melyik divrol van szo?
var content_x       = 980;          //oldal szelessege
var content_margin  = 242;          //oldal margo
var target_y        = 189;          //minimalis magassag

var target_x  = 980;
var has_inner, has_element, fm_id, floating_menu, fm_shift_x, fm_shift_y, fm_next_x, fm_next_y;
var goodbrowser = (navigator.appName.indexOf("Microsoft")== -1) ? true : false;


window.onload = function()
{
	  xajax_showBasket();
    for (i=0;i<queue.length;i++) {
        eval(queue[i]);
    }
    //document.getElementById(fm_id).style.position = 'absolute';
    winW          = goodbrowser ? (window.innerWidth - 8) : document.body.offsetWidth + 6;
    target_x      = ((winW/2) + (content_x/2)) - content_margin;
    has_inner     = typeof(window.innerWidth) == 'number';
    has_element   = document.documentElement && document.documentElement.clientWidth;
    floating_menu = document.getElementById ? document.getElementById(fm_id) : document.all ? document.all[fm_id] : document.layers[fm_id];

    compute_shifts();

    if (document.layers) {
        fm_next_x = 0;
        fm_next_y = 0;
    } else {
        fm_next_x = fm_shift_x + target_x;
        fm_next_y = fm_shift_y + target_y;
        move_menu();
    }

    float_menu();
}
window.onresize = function ()
{
    winW     = goodbrowser ? (window.innerWidth - 8) : document.body.offsetWidth + 6;
    target_x = ((winW/2) + (content_x/2)) - content_margin;
    target_x = Math.ceil(target_x);
}

function move_menu() {
    if (document.layers) {
        floating_menu.left = target_x + 'px';
        floating_menu.top = fm_next_y + 'px';
    } else {
        floating_menu.style.left = target_x + 'px';
        floating_menu.style.top = fm_next_y + 'px';
    }
}

function compute_shifts() {

    fm_shift_x = has_inner ? pageXOffset : has_element ? document.documentElement.scrollLeft : document.body.scrollLeft;
    if (target_x < 0)
        fm_shift_x += has_inner
            ? window.innerWidth
            : has_element
              ? document.documentElement.clientWidth
              : document.body.clientWidth;

    fm_shift_y = has_inner ? pageYOffset : has_element ? document.documentElement.scrollTop : document.body.scrollTop;

    if (target_y < 0)
        fm_shift_y += has_inner
            ? window.innerHeight
            : has_element
              ? document.documentElement.clientHeight
              : document.body.clientHeight;
}

function float_menu() {

    var step_x, step_y;

    compute_shifts();

    step_x = (fm_shift_x + target_x - fm_next_x) * .07;

    if (Math.abs(step_x) < .5)
    {
        step_x = fm_shift_x + target_x - fm_next_x;
    }
    if (fm_shift_y > target_y || fm_next_y > target_y+5)
    {
        step_y = (fm_shift_y - fm_next_y) * .07;

        if (Math.abs(step_y) < .1)
        {
            step_y = fm_shift_y - fm_next_y;
        }
    }

    if (Math.abs(step_x) > 0 || Math.abs(step_y) > 0)
    {
        fm_next_x += step_x;
        fm_next_y += step_y;
        move_menu();
    }

    setTimeout('float_menu()', 20);
}
