
function openWindow(url, title, x, y, width, height)
{
    var parentLeft, parentTop, parentWidth, parentHeight;

    // If X and Y position are both 0, center in the parent
    if (x == 0 && y == 0)
    {
        // Sigh...
        if (window.screenLeft)
        {
            parentLeft = window.screenLeft;
            parentTop = window.screenTop;
        }
        else
        if (window.screenX)
        {
            parentLeft = window.screenX;
            parentTop = window.screenY;
        }
    
        if (window.outerWidth)
        {
            parentWidth = window.outerWidth;
            parentHeight = window.outerHeight;
        }
        else
        if (document.documentElement)
        {
            parentWidth = document.documentElement.offsetWidth;
            parentHeight = document.documentElement.offsetHeight;
        }
        else
        if (document.body && document.body.offsetWidth)
        {
            parentWidth = document.body.offsetWidth
            parentHeight = document.body.offsetHeight;
        }

        // Sigh... *Some* browsers will not support any of these...
        if (parentLeft && parentTop && parentWidth && parentHeight)
        {
            x = parentLeft + (parentWidth - width) / 2;
            y = parentTop + (parentHeight - height) / 2;
        }
        else
        {
            x = 50;
            y = 50;
        }
    }
    
    
// alert('at ' + x + ', ' + y);
    
    // Handle Netscape (screenX, screenY) and IE (left, top) values for X and Y
    features = 'left=' + x + ',top=' + y + ',screenX=' + x + ',screenY=' + y;
    features += ',width=' + width + ',height=' + height;
    features += ',directories=no,menubar=no,toolbar=no';
    features += ',status,resizable,scrollbars';
    
    win = window.open(url, title, features, true);
    
    // As setting size/pos in the feature string usually doesn't work
    win.moveTo(x, y);
    win.resizeTo(width, height);
	
	// Necessary?
	if (parseInt(navigator.appVersion) >= 4)
	{
	    win.window.focus();
	}
}

function new_location_popup(url)
{
    openWindow(url, 'add_location', 0, 0, 500, 600);
}

function edit_location_popup(url)
{
    openWindow(url, 'edit_location', 0, 0, 500, 600);
}

function add_item_note_popup(url)
{
    openWindow(url, 'add_item_note', 0, 0, 555, 425);
}

function show_item_note_popup(url)
{
    openWindow(url, 'show_item_note', 0, 0, 555, 425);
}

function packing_list_note_popup(url)
{
    openWindow(url, 'packing_list_note', 0, 0, 555, 450);
}

function print_form_popup(url)
{
    openWindow(url, 'print_form', 0, 0, 800, 750);
}

function reassign_order_popup(url)
{
    openWindow(url, 'reassign_order', 0, 0, 555, 600);
}

function show_order_outsource_info_popup(url)
{
    openWindow(url, 'order_outsource_info', 0, 0, 555, 500);
}

function proof_history_popup(url)
{
    openWindow(url, 'proof_history', 0, 0, 555, 500);
}

function email_proof_popup(url)
{
    openWindow(url, 'email_proof', 0, 0, 560, 520);
}

function share_customer_popup(url)
{
    openWindow(url, 'share_customer', 0, 0, 555, 500);
}

/*
** Customer side
*/

function show_file_upload_popup(url)
{
    openWindow(url, 'file_upload', 0, 0, 585, 520);
}

function approve_proof_popup(url)
{
    // openWindow(url, 'approve_proof', 0, 0, 585, 520);
    
    openWindow(url, 'approve_proof', 0, 0, 900, 670);
}

