var win;

if (self.name == "") {
    self.name = "main";
}

function popup(url, width, height) {
    width += 40;
    height += 40;

    var features = 'width=' + width + ',height=' + height + ',left=10,top=10,' +
        'scrollbars=yes,resizable=yes,location=no,directories=no,status=no,menubar=no';

    win = open(url, 'popup', features);
    setTimeout('win.focus();', 250);
}

function picture(name, width, height) {
    var features = 'width=' + width + ',height=' + height + ',left=10,top=10';

    win = window.open('party.php', 'popup', features);

    win.document.open();
    win.document.write('<html><head><title>Popup</title></head>');
    win.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
    win.document.write('<img src="pictures/' + name + '" width="' + width + '" height="' + height + '" onClick="self.close()">');
    win.document.write('</body>');
    win.document.write('</html>');
    win.document.close();

    win.focus();
    setTimeout('win.focus();', 250);
}

function focus_control() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var elem = document.forms[0].elements[i];

        if (elem.type == "text") {
            elem.focus();
            elem.select();
            break;
        } else if (elem.type == "select-one" || elem.type == "textarea") {
            elem.focus();
            break;
        }
    }
}
