// opener.js

function getmagePopupWinName()
{
	return 'ImagePopup';
}

function getImagePopupWinDefaultFeatures()
{
	return 'resizable=yes,scrollbars=yes';
}

function showImagePopup(a_itemid, a_name, a_imageurl, a_alt, a_height, a_width, a_winHeight, a_winWidth)
{
	// show one image in a popup
	var strURL = 'showimage.asp';
	var strFeatures = getImagePopupWinDefaultFeatures();

	if (a_itemid || a_name || a_imageurl || a_alt || a_height || a_width)
	{
		strURL += '?';	// begin query string
		if (a_itemid)
		{
			strURL += 'itemid=' + a_itemid;
		}
		if (a_name)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'name=' + escape(a_name);
		}
		if (a_imageurl)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'url=' + a_imageurl;
		}
		if (a_alt)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'alt=' + escape(a_alt);
		}
		if (a_height)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'h=' + a_height;

			if (!a_winHeight)
			{
				a_winHeight = new Number(a_height) + 80;
			}
		}
		if (a_width)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'w=' + a_width;

			if (!a_winHeight)
			{
				a_winHeight = new Number(a_width) + 20;
			}
		}
	}
	if (a_winHeight)
	{
		strFeatures += ',height=' + a_winHeight;
	}
	if (a_winHeight)
	{
		strFeatures += ',width=' + a_winWidth;
	}

	var win = window.open(strURL, getmagePopupWinName(), strFeatures);
	win.focus();
}

function showItemImagePopup(a_itemid, a_name, a_winHeight, a_winWidth, a_fname, a_bShowAddCart)
{
	// shows multiple images for the same itemid in a popup
	var strURL = 'showitemimage.asp';
	var strFeatures = getImagePopupWinDefaultFeatures();

	if (a_itemid || a_name)
	{
		strURL += '?';	// begin query string
		if (a_itemid)
		{
			strURL += 'itemid=' + a_itemid;
		}
		if (a_name)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'name=' + escape(a_name);
		}
		if (a_fname)
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'fname=' + escape(a_fname);
		}
		if (typeof(a_bShowAddCart) != 'undefined')
		{
			if (strURL.charAt(strURL.length - 1) != '?')
			{
				strURL += '&';
			}
			strURL += 'showaddcart=' + escape(a_bShowAddCart);
		}
	}
	if (a_winHeight)
	{
		strFeatures += ',height=' + a_winHeight;
	}
	if (a_winHeight)
	{
		strFeatures += ',width=' + a_winWidth;
	}

	var win = window.open(strURL, getmagePopupWinName(), strFeatures);
	win.focus();
}