var leftPos=0;
var topPos=0;
var width=0;
var height=0;

function calculateCenterPos() {
 saw = screen.availWidth; sah = screen.availHeight; sw = screen.Width; sh = screen.Height;
 if(!document.layers) {ch = document.body.clientHeight;cw = document.body.clientWidth; }
 else  {ch = window.innerHeight;cw = window.innerWidth;}
 if(!saw || !sah) {leftPos=100;topPos=100}
 else {
    leftPos = Math.ceil((saw - width) / 2 );
    topPos = Math.ceil((sah - height) / 2 );
    }
}

function openCenteredPopup(url,name,type) {
    switch(type) {
        case 'window':
            width=800;
            height=600;
            break;
        default:
            width=800;
            height=600;
    }
    calculateCenterPos()
    switch(type) {
        case 'window':
            options = 'width='+width+
                      ',height='+height+
                      ',top='+topPos+
                      ',left='+leftPos+
                      ',toolbar=0,location=0,fullscreen=0'+
                      'directories=0,status=0,menubar=0,resizable=0,scrollbars=1';
            break;
        default:
            options='';
    }
  newwin=window.open(url,name,options);
  newwin.focus();
}

function writetxt(txt)
{
	var elm = document.getElementById('writer');
	elm.ineerHTML = txt;
}
