// Helper functions for various bits of UI
function showChanged(ctl) {
    var form = document.forms['linkto'];
    var show = form.elements['fromid'].value;

    setControl(form.elements[ctl],
      (weight[show] == undefined) ? 0 : weight[show]);
}

function setControl(c, v) {
    //alert(c.length);
    if (c.type == undefined) {
        for (var i = 0; i < c.length; i++) {
            c[i].checked = (c[i].value == v);
        }
    } else {
        c.value = v;
    }
}

function popSizedViewer(url, width, height) {
	if (width > screen.width - 64) {
	    width = screen.width - 64;
	}
	if (height > screen.height - 96) {
	    height = screen.height - 96;
	}
    agent = navigator.userAgent;
    windowName = "_blank";
    params = "status=0,toolbar=0,location=0,directories=0,menubar=0,resizable=1";
    if (agent.indexOf("MSIE") != -1) {
		params += ",scrollbars=1"
        params += ",screenX=" + window.screenX + 40;
        params += ",screenY=" + window.screenY + 40;
        width  += 24;
        height += 16;
    } else {
		params += ",scrollbars=1"
    }
    params += ",width=" + width + ",height=" + height;

    // Work round bug in Mac and Unix versions of Netscape 2.0
    win = window.open(url, windowName, params);
    if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) {
            win = window.open(url, windowName, params);
    }

    if (!win.opener) {
            win.opener = window;
    }
}
