//this code is for a popup image swatch
var winPhoto2;
function makeNewWindow2(path,title)
{
	path = 'assets/images/hickeyfreeman/swatches/' + porder_code + '_' + path + '_lg.jpg';
	
	winPhoto2 = window.open("","AltView","height=300,width=300,status=0,scrollbars=0,location=0");
	winPhoto2.document.open();
	winPhoto2.document.write('<html>');
	winPhoto2.document.write('    <head>');
	winPhoto2.document.write('        <title>');
	winPhoto2.document.write(title);
	winPhoto2.document.write('        </title>');
	winPhoto2.document.write('			<link rel="stylesheet" type="text/css" href="assets/images/hickeyfreeman/includes/hickeyfreeman.css">');
	winPhoto2.document.write('<script lang=javascript>');
	winPhoto2.document.write('var largeimage = new Image();');
	winPhoto2.document.write('largeimage.src = "' + path + '"');
	winPhoto2.document.write('</script>');
	winPhoto2.document.write('    </head>');
	winPhoto2.document.write('    <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" background="assets/images/hickeyfreeman/main_bg2.gif">');

	winPhoto2.document.write('    <table border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#FFFFFF">');
	winPhoto2.document.write('      <tr>');
	winPhoto2.document.write('        <td align="left"><a href="default.asp?s_id=1" onclick="return(visitargs(\'default.asp\',\'\',\'URL\'));"><img src="assets/images/hickeyfreeman/header_logo.jpg" border="0" height="48" width="260"></a><br></td>');
	winPhoto2.document.write('      </tr>');
	winPhoto2.document.write('      <tr>');
	winPhoto2.document.write('        <td align="center" class="dept_products_in"><strong>'+title+'</strong><br><br><img align=center src="' + path + '" onLoad="window.resizeTo(largeimage.width+100,largeimage.height+200);" ></td>');
	winPhoto2.document.write('      </tr>');
	winPhoto2.document.write('      <tr>');
	winPhoto2.document.write('        <td align="left"><a href="javascript:window.close();" class="footer">Close window</a><br></td>');
	winPhoto2.document.write('      </tr>');
	winPhoto2.document.write('     </table>	');
	
	winPhoto2.document.write('    </body>');
	winPhoto2.document.write('</html>');
	winPhoto2.document.close();
	winPhoto2.focus();
	return false;
}

function draw_image_2(){
	 if (product_image[1].scr=="PRODUCT" && product_image[1].image!="" ) { 
		if (product_image[1].image_show=="TARGET REG" || product_image[1].image_show=="TARGET" ){
			if (product_image[1].image_show=="TARGET REG"){
				if (user_guid==""){
					document.write("<A HREF=\"shopper_lookup.asp?target=" + product_image[1].target + "&\" onClick=return(visitargs('shopper_lookup.asp',\"target=" + product_image[1].target + "&\")); target=\"_top\" >");
				}else {
					document.write("<A HREF=\"" + product_image[1].target + "\" onClick=return(visitargs('" + product_image[1].target + "')); target=\"_top\" >");
				}
			}else {
				document.write("<a HREF=\"" + product_image[1].target + "\" target=\"_top\">");
			}
			document.write("<img name=\"mainimg\" id=\"mainimg\" ALIGN =" + product_image[1].align + " "); 
			//if (product_image[1].width==""){document.write("WIDTH = 358 ");}
			document.write(" BORDER=0  VSPACE=0 width=315 HSPACE=0 ALT=\"" + product_image[1].alt_text + "\" ");         
			document.write(" SRC=\"assets/product_images/" + product_image[1].image +"\"></a>");
		}else{
			document.write("<img name=\"mainimg\" id=\"mainimg\" ALIGN =\"" + product_image[1].align + "\" "); 
			//if (product_image[1].width==""){document.write("WIDTH = 358 ");}
			document.write(" BORDER=0  VSPACE=0 width=315 HSPACE=0 ALT=\"" + product_image[1].alt_text + "\" ");         
			document.write(" SRC=\"assets/product_images/" + product_image[1].image +"\">");
		}  		
	}
	else{
		//document.write("<img src=\"assets/product_images/product.gif\">");
	}
}

function imgOn(imgName) {
        document.getElementById("mainimg").src="assets/images/hickeyfreeman/swatches/" + porder_code + "_" + imgName + "_lg.jpg";
}

function display_thumbnails() {
	var array_largeimage;
	if (typeof info_attributes!="undefined" && info_attributes != "") {
		var thumbnails_array = info_attributes.split(",");
		//info_attributes="";
		var image_array;
		if (thumbnails_array.length >= 1) {
			//the number below changes the number of columns for the swatches
			var columns=3;
			var atn;
			atn=0;
			var myImage;
			var counter=1;
			document.write("<br>Available In:");
			document.write("<br><table border=0><tr><td><div align=center width=100%><table border=0><tr>");
			var colorAttrFlag = false;
			for (var attrIter=0;attrIter<attr_label.length;attrIter++) {
				if (attr_label[attrIter].toLowerCase() == "color") {
					colorAttrFlag = true;
				}
			}
			if (colorAttrFlag) {
				for (atn=0; atn<thumbnails_array.length; atn++) {
					if (thumbnails_array[atn]!="") {
						image_array = thumbnails_array[atn].split(":");
						//strip out any divs or ps
						image_array[1] = image_array[1].replace(/<div>|<\/div>|<p>|<\/p>/ig,"");
						image_array[0] = image_array[0].replace(/<div>|<\/div>|<p>|<\/p>/ig,"");
						//is this swatch available for retail?
						var colorName = image_array[0].toLowerCase().replace(/ /g, "");
						for (var pvIter=0;pvIter<product_var.length;pvIter++) {
							if (colorName==product_var[pvIter].attr_value2.toLowerCase() && product_var[pvIter].vvendor_code!="w") {
								document.write("<td align=center><table border=0><tr><td align=center><A HREF=\"default.asp?s_id=1&\" onClick=\"return(makeNewWindow2('"+image_array[1]+"','"+image_array[0]+"'));\" ><img NAME=\""+image_array[1]+"\" id=\""+image_array[1]+"\" src=\"assets/images/hickeyfreeman/swatches/" + porder_code + "_" + image_array[1] + "_sm.jpg\" WIDTH=60 border=1></A>");
								document.write("<br>"+image_array[0].replace("_"," ")+"</td></tr></table></td>");
								if (counter==columns){document.write("</tr><tr>");counter=0}
								break;
							}
						}
					}
					counter = counter+1;
				}
			} else {
				var arrColor = info_attributes.split(":");
				var strColor = arrColor[0].toLowerCase();
				document.write("<td align=center><table border=0><tr><td align=center>");
				document.write("<a href=\"default.asp?s_id=1&\" onClick=\"return(makeNewWindow2('"+strColor+"','"+arrColor[1]+"'));\" ><img NAME=\""+arrColor[1]+"\" id=\""+arrColor[1]+"\" src=\"assets/images/hickeyfreeman/swatches/" + porder_code + "_" + strColor + "_sm.jpg\" WIDTH=60 border=1></A>");
				document.write("<br>"+arrColor[1].replace("_"," ")+"</td></tr></table></td>");
			}
			document.write("</tr></table></div></td></tr></table>");
		}
	}
} //end display_thumbnails