/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +--------------------------------------------------------+
// | Internet Explorer 5.5 & Firefox 1.0                    |
// +--------------------------------------------------------+
// | Copyright (c) 2005 Song Hyo-Jin                        |
// +--------------------------------------------------------+
// | License : GPL (current new version)                    |
// +--------------------------------------------------------+
// | Author : Song Hyo-Jin <crosser at hanmail dot net>     |
// |                                  (MSN Messengerable)   |
// +--------------------------------------------------------+
//
// $Id: popup.js, v 1.0.0 2006/02/04 18:13:13 crosser Exp $
//
// Image Popup & Auto Scroll

function autoscroll_popup(u, w, h)
{
	var screenw, screenh, lmargin, tmargin;
	screenw = parseInt(screen.availWidth);
	screenh = parseInt(screen.availHeight);

	if(w > screenw) {
		w = screenw;
	}
	if(h > screenh) {
		h = screenh;
	}

	if(screenw > w) {
		lmargin = Math.ceil((screenw - w) / 2);
	} else {
		lmargin = 0;
	}
	if(screenh > h) {
		tmargin = Math.ceil((screenh - h) / 2);
	} else {
		tmargin = 0;
	}

	window.open("/popup.html?u=" + u + "&w=" + w + "&h=" + h, "_blank", "width=300,height=400,left=" + lmargin + ",top=" + tmargin);
}

function getParentNode(tag, pName) {
	var ntag = tag.parentNode;
	while(ntag.tagName != pName) {
		ntag = ntag.parentNode;
	}
	return ntag;
}
