function showMessageBox(o) {
	var opt = Ext.apply({
    	id: 'currentMessageBox',
		width: 400,
		height: 150,
		hideAction: 'close',
		icon: "",
        buttons: [{text: Ext.MessageBox.buttonText.ok, handler: function() {Ext.getCmp('currentMessageBox').close();}}]
	}, o);
	if(opt.icon != "") {
		opt.html = '<table style="width:100%; height:100%;"><tr><td><img src="'+opt.icon+'" style="padding-right: 10px;"/></td><td style="vertical-align:middle;">'+ opt.html +'</td></tr></table>';
	} else {
		opt.html = '<table style="width:100%; height:100%;"><tr><td style="vertical-align:middle;">'+ opt.html +'</td></tr></table>';
	}
	var win = new Ext.Window(opt);
	win.show();
	return win;
}

function toggleOptions(callback) {
    if(currentOptionState) {
        document.getElementById('rightMenu').style['display'] = 'none';
        document.getElementById('toggleButton').innerHTML = 'Show options';
    } else {
        document.getElementById('rightMenu').style['display'] = '';
        document.getElementById('toggleButton').innerHTML = 'Hide options';
    }
    currentOptionState = !currentOptionState;
    document.cookie = 'currentOptionState='+(currentOptionState?1:0)+'';
    callback(currentOptionState);
}

var helpWindow = null;

function showHelp(helpid) {
	    
        // create the window on the first click and reuse on subsequent clicks
        if(!helpWindow){
            helpWindow = new Ext.Window({                
                layout:'fit',
                width:500,
                height:300,
                closeAction:'hide',
                plain: true,
                bodyStyle:'background-color:#ffffff;',
                buttons: [{
                    text: 'Close',
                    handler: function(){
                        helpWindow.hide();
                    }
                }]
            });
        }
        helpWindow.show();
        helpWindow.center();
        helpWindow.load('/modules/help/get.help.php?id=' + helpid);
}     
function getPageLocation() {
  return document.location.href;
}   
function keepAlive(o) {
	Ext.Ajax.request({
		url: '/keepalive.php',
		method: 'GET',
		keepAlive: o,
		callback: function(o,s,r) {
			if(o.keepAlive != undefined) {
				if(o.callback != undefined) {
					o.callback(r);
				}
			}
			Ext.defer(keepAlive, 60000);
		}
	});
}
