//	COMPULSORY
//	url = page to open with variables
//	w = width of popup
//	h = height of popup

//	OPTIONAL
//	tit (title) = text in titlebar
//	txt (text) = text under picture
//	sbar (scrollb)= hide scrollbars = 0, show scrollbars = 1


function imgPopup(url,w,h,tit,txt,sbar) {

	var wmax = 700;
	var hmax = 540;

	var x = 0;
	var y = 0;

	var title = "";
	if (arguments.length > 3) { title = tit; }

	var text = "";
	if (arguments.length > 4) { text = txt; }

	var scrollb = "0";
	if ((arguments.length > 5) || (w > wmax) || (h > hmax)) { 
		scrollb = "1";
		w += 18;
	}


	if (text > "") {
		h = h + 24 + 80 * (text.length / w);
	}

	if (w > wmax) { w = wmax; }
	if (h > hmax) { h = hmax; }

	if (document.all || document.layers) {
		x = (screen.availWidth - w) / 2;
		y = (screen.availHeight - h) / 3;
		if (x < 0) { x = (screen.availWidth - w) }
		if (y < 0) { y = 0 }	
	}

	var urls =	"../common/img-popup.asp?";
	urls +=	"w=" + w;
	urls +=	"&h=" + h;
	urls +=	"&photo=" + url;
	urls +=	"&title=" + title;
	urls +=	"&text=" + text;

	var posi =	"width=" + w + ",";
	posi +=	"height=" + h + ",";
	posi +=	"top=" + y + ",";
	posi +=	"left=" + x + ",";

	var opts = 	"scrollbars=" + scrollb + ",";
	opts +=	"resizable=0,";
	opts +=	"copyhistory=0,";
	opts +=	"directories=0,";
	opts +=	"location=0,";
	opts +=	"menubar=0,";
	opts +=	"status=0,";
	opts +=	"toolbar=0";

	popupWin = window.open(urls,'win',posi + opts);
}
