window.addEvent('domready', function() {
    var showButton = $('browse_button');
    var hideButton = $('browse_hide_button');
    var popup = $('browse_window');
    if (!showButton || !hideButton || !popup) { return; }
    popup.set('tween', { duration: 'short' });
    showButton.set('tween', { duration: 'short' });

    showButton.onclick = function() {
        popup.fade('hide');
        popup.fade('in');
        showButton.fade('out');
    };

    hideButton.onclick = function() {
        popup.fade('out');
        showButton.fade('in');
    };
});

//testing:

function test_opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame 
    var speed = Math.round(millisec / 100);
    var timer = 0;

    var s = document.getElementById(id).style;

    if (opacStart == 0 && opacEnd == 100) {
        changeOpac(0, id);
        s.setAttribute('background-color', '#fff');
        s.visibility = 'visible';
    }
    
    //determine the direction for the blending, if start and end are the same nothing happens 
    if (opacStart > opacEnd) {
        for (i = opacStart; i >= opacEnd; i--) {
            setTimeout("test_changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
        setTimeout("test_hide('" + id + "')", (timer * speed));
    } else if (opacStart < opacEnd) {
        for (i = opacStart; i <= opacEnd; i++) {
            setTimeout("test_changeOpac(" + i + ",'" + id + "')", (timer * speed));
            timer++;
        }
        setTimeout("test_showit('" + id + "')", (timer * speed));
    }
}

function test_hide(id) {
    document.getElementById(id).style.visibility = 'hidden';
}

function test_show(id) {
    var x= document.getElementById(id).style;
    x.removeAttribute('filter');
    x.visibility = 'visible';
}

//change the opacity for different browsers 
function test_changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 