//
// KEI-KUN.NET JavaScript Code
// (c) Kimmo Hernborg 2002.
// kimmo@kei-kun.net
//


// Open a Popup for edit functions

function dopop(dest) {
    if(dest != "") {
        sw = screen.availWidth;
        sh = screen.availHeight;
        
        //ww = 800; wh = 790;
        //pw = 300; ph = 790;
        pw = 300; ph = sh;
        ww = sw - pw; wh = sh;
        
        wl = 0; //((sw-ww)/2)-(pw/2);
        wt = 0; //(sh-wh)/2;
        pl = wl+ww; pt = wt;
        
        self.moveTo(wl, wt);
        self.resizeTo(ww, wh);
        
        if(dest.indexOf("?")!=-1) {
            dest = dest + "&winheight="+(ph-120);
        } else {
            dest = dest + "?winheight="+(ph-120);
        }

        editwin = open(dest, "editwin", "left="+pl+", top="+pt+", screenX="+pl+", screenY="+pt+", width="+pw+", height="+ph+", resizable=yes");
        
        editwin.moveTo(pl, pt);
        editwin.resizeTo(pw, ph);
        editwin.focus();
    }
}

function hilitefirst() {
    for(i=0;i<document.forms.length;i++) {
        for(j=0;j<document.forms[i].elements.length;j++) {
            if(document.forms[i].elements[j].type=="text") {
                document.forms[i].elements[j].focus();
                return true;
            }
        }
    }
    return false;
}



function poppic(pic, width, height, myautoresize)
{
    myleft = (screen.width / 2) - (width / 2);
    mytop = (screen.height / 2) - (height / 2);
    features = "width=" +width+ ", height=" +height+ ", left=" +myleft+ ", screenX=" +myleft+ ", top=" +mytop+ ", screenY=" +mytop+ ", directories=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=no, toolbar=no";
    thewin = window.open("", "picture", features);
    thewin.document.open("text/html");
    thewin.document.myautoresize = myautoresize;
    thewin.document.write(
        '<HTML>\n' +
        '<HEAD><TITLE>'+pic+'</TITLE></HEAD>\n' +
        '<BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>\n\n' +
        '<A href="javascript:self.close()">\n'+
        '\t<IMG src="'+pic+'" border=0 alt="" onLoad="if(self.document.myautoresize) self.resizeTo((self.document.images[0].width+12), (self.document.images[0].height+30))">\n</A>\n\n' +
        '</BODY>\n</HTML>'
    );
    thewin.document.close();
    thewin.focus();
}


