
function popup(url, name, width, height) {

    var screenWidth = screen.availWidth;
    var screenHeight = screen.availHeight;
    var halfScreenWidth = screenWidth / 2;
    var halfScreenHeight = screenHeight / 2;


    var xPos = 0;
    if (screenWidth == null) {
        xPos = 50;
    } else if (width > screenWidth) {
        width = screenWidth - 20;
        xPos = 5;
    } else {
        xPos = halfScreenWidth - ( width / 2 );
    }

    var yPos = 0;
    if (screenHeight == null) {
        yPos = 50;
    } else if (height > screenHeight) {
        height = screenHeight - 40;
        yPos = 5;
    } else {
        yPos = halfScreenHeight - ( height / 2 );
    }

    var tempWin = window.open(url, name, 'width=' + width + ',height=' + height + ', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no,left=' + xPos + ',top=' + yPos);
    tempWin.focus();
}

