//this code is for a popup image swatch
var winPhoto2;
function makeNewWindow2(path,title)
{
	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('<script lang=javascript>');
	winPhoto2.document.write('var largeimage = new Image();');
	winPhoto2.document.write('largeimage.src ="assets/images/swatches/' + path + '_lg.jpg"');
	winPhoto2.document.write('</script>');
	winPhoto2.document.write('    </head>');
	winPhoto2.document.write('    <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
	winPhoto2.document.write('    <center><font size=4><b>'+title+'</b></font></center><br>');
	winPhoto2.document.write('        <center><img align=center src="assets/images/swatches/' + path + '_lg.jpg" onLoad="window.resizeTo(largeimage.width+60,largeimage.height+100);" ></center>');
	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 =" + product_image[1].width + " ");}
			document.write(" BORDER=0  VSPACE=5  HSPACE=5 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 =" + product_image[1].width + " ");}
			document.write(" BORDER=0  VSPACE=5  HSPACE=5 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/swatches/" + imgName + "_lg.jpg";
}

function display_thumbnails()
{
	if (typeof U_Prod_Xlink[0]=="undefined")
	{
		var counter = 0;
		var droparray = new Array();
	
		for (x=0;x< product_var.length;x++)
		{
			var matched=false;
			//run thru the values already captured to see if we have a match
			for (y=0;y<droparray.length;y++)
			{
				if (droparray[y]==eval("product_var["+x+"].attr_value2"))
				{
					matched=true;
				}
			}
			//add the attr2 value to the array if it wasn't in there
			if (matched==false)
			{
				droparray[counter]=eval("product_var["+x+"].attr_value2");
				counter = counter + 1;
			}
		}
	
		var image_file;
		var image_name;
		if (droparray.length >= 1)
		{
			if (typeof droparray[0] != "undefined")
			{
				//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>");
				
				for (atn=0; atn<droparray.length; atn++)
				{
					if (typeof droparray[atn]!="undefined" && droparray[atn]!="")
					{
						//image_file = thumbnails_array[atn].split(":");
						image_file = droparray[atn].split(" ").join("_");
						image_name = droparray[atn];
						document.write("<td align=center><table border=0><tr><td align=center><A HREF=\"#\" onClick=\"return(makeNewWindow2('"+image_file+"','"+image_name+"'));\" ><img NAME=\""+image_file+"\" id=\""+image_file+"\" src=\"assets/images/swatches/"+ image_file + "_sm.jpg\" alt=\""+image_name+"\" border=0></A>");
						document.write("<br>"+image_name+"</td></tr></table></td>");
						if (counter==columns){document.write("</tr><tr>");counter=0}
					}
				counter = counter+1;
				}
				document.write("</tr></table></div></td></tr></table>");
			}
		}
	}
} //end display_thumbnails
