function show(e)
{
    if (typeof e != 'object') {
        e = ID(e);
    }
    e.style.visibility = 'visible';
}

function hide(e)
{
    if (typeof e != 'object') {
        e = ID(e);
    }
    e.style.visibility = 'hidden';
}

function display(e, display)
{
    if (typeof e != 'object') {
        e = ID(e);
    }
    e.style.display = display ? display : (e.display ? e.display : 'block');
}

function collapse(e)
{
    if (typeof e != 'object') {
        e = ID(e);
    }
    e.display = e.style.display;
    e.style.display = 'none';
}

function toggle(e)
{
    if (e.offsetWidth > 0) {
        collapse(e);
    } else {
        display(e);
    }
}

function remove(object, effect)
{
    if (object && object.parentNode) {
        switch (effect) {
        default:
        case 'simple':
            object.parentNode.removeChild(object);
            break;
        case 'vanish':
            setTimeout(function() {remove_vanish(object, 100, 1, 0.1)}, 100);
            break;
        case 'blink':
            setTimeout(function() {remove_blink(object, 100, 0, 3)}, 100);
            break;
        }
    }
}

function remove_vanish(object, delay, opacity, step)
{
    if (opacity > 0) {
        if (is_browser_ie()) {
            object.style.filter = 'Alpha(Opacity="' + (opacity * 100) + '")';
        } else {
            object.style.opacity = opacity;
        }
        setTimeout(function() {remove_vanish(object, delay, opacity - step, step)}, delay);
    } else {
        object.parentNode.removeChild(object);
    }
}

function remove_blink(object, delay, counter, number)
{
    if (counter < number * 2) {
        object.style.visibility = counter % 2 ? 'hidden' : 'visible';
        setTimeout(function() {remove_blink(object, delay, ++ counter, number)}, delay);
    } else {
        object.parentNode.removeChild(object);
    }
}


function emerge(object, effect)
{
    switch (effect) {
    default:
    case 'simple':
        //do nothing :)
        break;
    case 'appear':
        setTimeout(function() {emerge_appear(object, 100, 0, 0.1)}, 100);
        break;
    case 'blink':
        setTimeout(function() {emerge_blink(object, 100, 0, 3)}, 100);
        break;
    }
}

function emerge_appear(object, delay, opacity, step)
{
    if (opacity < 1) {
        if (is_browser_ie()) {
            object.style.filter = 'Alpha(Opacity="' + (opacity * 100) + '")';
        } else {
            object.style.opacity = opacity;
        }
        setTimeout(function() {emerge_appear(object, delay, opacity + step, step)}, delay);
    }
}

function emerge_blink(object, delay, counter, number)
{
    if (counter < number * 2) {
        object.style.visibility = counter % 2 ? 'visible' : 'hidden';
        setTimeout(function() {emerge_blink(object, delay, ++ counter, number)}, delay);
    }
}

function move(e, x, y, step_x, step_y, finalize)
{
    if (!step_x || !step_y) {
        return false;
    }

    var cur_x = parseInt(e.style.left);
    var cur_y = parseInt(e.style.top);

    var moved_x = false;
    if (Math.abs(cur_x - x) >= step_x) {
        e.style.left = (cur_x + Math.sign(x - cur_x) * step_x) + 'px';
        moved_x = true;
    } else {
        e.style.left = x + 'px';
    }

    var moved_y = false;
    if (Math.abs(cur_y - y) >= step_y) {
        e.style.top = (cur_y + Math.sign(y - cur_y) * step_y) + 'px';
        moved_y = true;
    } else {
        e.style.top = y + 'px';
    }

    if (moved_x || moved_y) {
        setTimeout(function() {move(e, x, y, step_x, step_y, finalize)}, 0);
    } else {
        if (finalize) {
            finalize.call(e);
        }
    }
}