	function confirmLink(msg)
	{
	    confirmCheck = confirm(msg);
	    if (confirmCheck)
	        return true;
		 else
	        return false;
	}

	function openWindow(url, name, w, h)
	{
//	   w += 32;
//		h += 96;
		w += 32;
		h += 96;
		
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h) / 2;
		var win = window.open(url, name,
			'width=' + w + ', height=' + h + ', ' +
			'left=' + wleft + ', top=' + wtop + ', ' +
			'location=no, menubar=no, ' +
			'status=yes, toolbar=no, scrollbars=no, resizable=no');

		// Just in case width and height are ignored
		win.resizeTo(w, h);
		// Just in case left and top are ignored
		win.moveTo(wleft, wtop);
		win.focus();
	}

	function openCenteredWindow(url, name, w, h)
	{
		w += 32;
		h += 96;
		
		wleft = (screen.width - w) / 2;
		wtop = (screen.height - h) / 2;
		var win = window.open(url, name,
			'width=' + w + ', height=' + h + ', ' +
			'left=' + wleft + ', top=' + wtop + ', ' +
			'location=no, menubar=no, ' +
			'status=yes, toolbar=no, scrollbars=yes, resizable=yes');

		// Just in case width and height are ignored
		win.resizeTo(w, h);
		// Just in case left and top are ignored
		win.moveTo(wleft, wtop);
		win.focus();
	}

	function SetImage(newImg, newBigLink, newBigLinkButton, imgId)
	{
		var elem = document.getElementById("bigimg");
		if (elem != null)
			elem.src = String(newImg);
			
		if (newBigLink != null)
		{
			var bigLink = document.getElementById(newBigLink);
			if (bigLink != null)
			{
				var lnkText = 'show_image.php?id=' + imgId;
				bigLink.onclick=function(){openWindow(lnkText, 'item', 450, 450); return false;}
			}
		}

		if (newBigLinkButton != null)
		{
			var bigLinkButton = document.getElementById(newBigLinkButton);
			if (bigLinkButton != null)
			{
				var lnkText = 'show_image.php?id=' + imgId;
				bigLinkButton.onclick=function(){openWindow(lnkText, 'item', 450, 450); return false;}
			}
		}

		return false;
	}

	function resizeImage(img, wMax, hMax, bMargin)
	{
		if (img == null)
			return false;

		var wt = wMax;
		var ht = hMax;
		var aspect = 1.0;

		var pic = new Image;
		pic.src = String(img.src);

		wt = pic.width;
		ht = pic.height;

		if ((wt <= 0) || (ht <= 0))
			return true;

		aspect = wt/ht;
		ht = hMax;
		wt = ht * aspect;

		if (wt > wMax)
		{
			wt = wMax;
			ht = wt * aspect;
		}

		if (wt > ht)
		{
			aspect = ht/wt;
			wt = wMax;
			ht = wt * aspect;

			if (ht > hMax)
			{
				ht = hMax;
				wt = ht * aspect;
			}
		}

		if (bw.ns4)
		{
			img.offsetWidth = wt;
			img.offsetHeight = ht;

			img.width = wt;
			img.height = ht;
		}
		else
		{
			img.width = wt;
			img.height = ht;
		}

		if (bMargin == true)
		{
			xMargin = (wMax - wt)/2;
			yMargin = (hMax - ht)/2;
			img.style.margin = (yMargin+1) +"px " + xMargin +"px " + yMargin +"px " + xMargin +"px";

//			alert(xMargin + " " + yMargin);
		}

		return true;
	}
