function openGallery(prod_id, dirs)
{
	dirs = dirs.split('|');
	if (!dirs) {return false;}
	var width = (dirs.length <= 1) ? 350 : 400;
	var height = (dirs.length <= 1) ? 350 : 494;
	var classSuffix = (dirs.length <= 1) ? 310 : 360;
	var nw = window.open('','pic','resizable=no,scrollbars=no,width=' + width + ',height=' + height + ',toolbar=no');
	nw.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
	nw.document.write("<html>\n");
	nw.document.write("<head>\n");
	nw.document.write("<title>Natúrsziget Webáruház</title>\n");
	nw.document.write("<link rel=\"stylesheet\" href=\"./common/media/css/picviewer.css\" />\n");
	nw.document.write("<script type=\"text/javascript\">function showPic(pic_id) {for (var i = 1; i <= " + dirs.length + "; i++) {if (i != pic_id) {document.getElementById(i).style.display = 'none';} else {setIfExists(i, document.getElementById(i).src.substr(0, document.getElementById(i).src.length - 5) + 'X.jpg'); document.getElementById(i).style.display = 'block';}}}</script>\n");
	nw.document.write("<script type=\"text/javascript\">function getPicId() {for (var i = 1; i <= " + dirs.length + "; i++) {if (document.getElementById(i).style.display == 'block') {return i}}}</script>\n");
	nw.document.write("<script type=\"text/javascript\">function forward(pic_id) {if (pic_id < " + dirs.length + ") {showPic(pic_id + 1);} else {showPic(1);}}</script>\n");
	nw.document.write("<script type=\"text/javascript\">function backward(pic_id) {if (pic_id > 1) {showPic(pic_id - 1);} else {showPic(" + dirs.length + ");}}</script>\n");
	nw.document.write("<script type=\"text/javascript\">function setIfExists(id, src) {var img = new Image(); img.onload = function () {document.getElementById(id).src = src;}; img.onerror = function () {document.getElementById(id).src = src.substr(0, scr.length - 5) + \"L.jpg\";}; img.src = src;}</script>\n");
	nw.document.write("</head>\n");
	nw.document.write("<body>\n");
	nw.document.write("<div class=\"nagykepkeret" + classSuffix + "\"><div class=\"nagykep" + classSuffix + "\">\n");
	if (dirs.length > 1)
	{
		nw.document.write("<a href=\"javascript:void(0);\" class=\"left\" onclick=\"backward(getPicId());\"></a>\n");
		nw.document.write("<a href=\"javascript:void(0);\" class=\"right\" onclick=\"forward(getPicId());\"></a>\n");
	}
	nw.document.write("<table><tr><td class=\"image\">");
	for (x in dirs) {
		if (Number(x) != 0) {var suffix = '_' + String(Number(x) + 1); var display = 'none';}
		else {var suffix = ''; var display = 'block';}
		dir = dirs[x].split(':');		
		if (!dir[1]) {dir[1] = '';}
		nw.document.write("<img src=\"http://www.natursziget.com/common/media/images/products/" + dir[0] + "/" + prod_id + dir[1] + "_L.jpg\" class=\"nagykep\" id=\"" + (Number(x) + 1) + "\" alt=\"\" title=\"\" style=\"display: " + display + "\" />");
	}
	nw.document.write("</td></tr></table>\n");
	nw.document.write("</div></div>\n");
	nw.document.write("<script type=\"text/javascript\">setIfExists(1, document.getElementById('1').src.substr(0, document.getElementById('1').src.length - 5) + 'X.jpg');</script>");
	if (dirs.length > 1)
	{
		nw.document.write("<div class=\"nagykepkeret" + classSuffix + "\"><div class=\"kiskepek" + classSuffix + "\">\n");
		nw.document.write("<table><tr>\n");
		for (x in dirs) {
			if (Number(x) != 0) {var suffix = '_' + String(Number(x) + 1);}
			else {var suffix = '';}
			dir = dirs[x].split(':');	
			if (!dir[1]) {dir[1] = '';}
			nw.document.write("<td><img src=\"http://www.natursziget.com/common/media/images/products/" + dir[0] + "/" + prod_id + dir[1] + "_M.jpg\" class=\"kiskep\" alt=\"\" title=\"\" onclick=\"showPic(" + (Number(x) + 1) + ");\" /></td>");
		}
		nw.document.write("</tr></table>\n");
		nw.document.write("</div></div>\n");
	}
	nw.document.write("</body>\n");
	nw.document.write("</html>\n");
}
