var swatches = ({});
var storename = 'yhst-37254555466313';

function swatchPopup(swatchID, numCols, winWidth, winHeight) {
	var cols = numCols || 3;
	var winWidth = winWidth || 400;
	var winHeight = winHeight || 400;
	if (swatches[swatchID]) {
		var swatch = swatches[swatchID];
		var win = window.open('', 'swatches', 'width=' + winWidth + ',height=' + winHeight + ',status=0,resizeable=1,scrollbars=1');
		win.document.write('<link type="text/css" href="/lib/' + storename + '/swatch-popup.css" rel="stylesheet" />');
		win.document.write("<script type='text/javascript'>function resizeSwatches() { var obj = document.getElementById('" + swatchID + "'); if (obj) try { if (obj.offsetHeight + 100 < screen.height) window.innerHeight = obj.offsetHeight + 40; } catch (err) {} } function selectSwatch(i) { var obj = window.opener.document.getElementById('option" + swatchID + "'); if (obj) obj.value = i; } window.onload = resizeSwatches;</script>");
		win.document.write('<table id="' + swatchID + '" border="0" cellpadding="0" cellspacing="0">\n');
		for (var i = 0, j = swatch.length / cols; i < j; i++) {
			win.document.write('\t<tr class="image">\n');
			for (var k = i * cols, l = (i * cols) + cols; k < l; k++) {
				win.document.write('\t\t<td width="' + 100 / cols + '%">');
				if (swatch[k] && swatch[k][2] !== "")
					win.document.write('<a href="javascript:selectSwatch(\'' + swatch[k][0] + '\');"><img src="' + swatch[k][2] + '" /></a>');
				win.document.write('</td>\n');
			}
			win.document.write('</tr>\n\t<tr class="name">\n');
			for (var k = i * cols, l = (i * cols) + cols; k < l; k++) {
				win.document.write('\t\t<td>');
		       		if (swatch[k]) win.document.write('<a href="javascript:selectSwatch(\'' + swatch[k][0] + '\');">' + swatch[k][1] + '</a>');
				win.document.write('</td>\n');
			}
			win.document.write('\t</tr>\n');
		}
		win.document.write('</table>\n');
		win.document.close();
	}
}

