//<!-- Copyright (c) 1999-2004 UniteU Technologies Inc.  All rights reserved.   //-->
//<!--
function display_spanner_links(intCurrentPage,intMaxPages,spanner_links){document.write(" Page: "+ intCurrentPage + " of " + intMaxPages + " <BR> Select page <B> &lt; </B>" + spanner_links + "<B> &gt; </B><BR>");}
function display_dept(){if(dept_depts.length>0){display_dept_gen(dept_depts);}}
function display_label(pf_id,label){document.write("<TD>" + label + "</TD>");}
function display_products(){if (Dept_products.length>0){display_products_gen(Dept_products);}}

function display_product_link(purl,pname,short_desc,price_str,s_id,dept_id,pf_id,basket_enable){
	document.write("<a HREF=\"" + purl + "\" class=\"deptlinkP\" target=\"_top\">" + pname + "</a>&nbsp;" + short_desc );
	//document.write(price_str);
}

function OKStrOfPenny(X) {
	var T, S=new String(Math.round(X))
	while (S.length<3) S='0'+S
	return S.substr(0, T=(S.length-2)) + '.' + S.substr(T, 2);
}

function Display_sku(pf_name,pf_id,dept_id,sku,price_level,price_level2,price_level3,AvailabilitySTR,attr_value1,attr_value2,attr_value3,attr_value4,attr_value5,enable_basket,available){
 	document.write(attr_value1 +" "+ attr_value2 +"SKU:"+ sku );
	document.write(AvailabilitySTR);

	document.write("</TD><TD>$"+ OKStrOfPenny(price_level) +"</TD><TD>");

	onc ="return(visitargs('shopper_lookup.asp','target=xt_orderform_additem.asp&addto=1&auto_reg=1&pf_id="+ pf_id +"&dept_id="+ dept_id +"&attr_value1="+attr_value1+"&attr_value2="+attr_value2+"&attr_value3="+attr_value3+"&attr_value4="+attr_value4+"&attr_value5="+attr_value5+"'));"
	document.write("<A href=\"#\" onclick=\""+ onc +"\" ><b>Order Now</b></font></A>");
	document.write("</TD><TD>");
	onc="return(visitargs('product.asp','pf_id="+ pf_id +"&dept_id="+ dept_id +"&attr_value1="+attr_value1+"&attr_value2="+attr_value2+"&attr_value3="+attr_value3+"&attr_value4="+attr_value4+"&attr_value5="+attr_value5+"'));"
	document.write("<A href=\"#\" onclick=\""+ onc +"\" ><b>More Info</b></font></A>");
	document.write("</TD><TD>");
}

function display_dept_2nd(display_dept_gen){
	if (display_dept_gen.length >= 1){
		var n_dept=0;
		var atn;

		document.write(s_top_HTML);
		document.write(style_UL_open);
		for (atn=0;atn< display_dept_gen.length ;atn++){
			if (n_dept==0 || d_display_type!=4){document.write(style_LI_1_open + style_font_2_open);}
			n_dept=n_dept+1 ;
			if (s_image_align=="CENTER"){
				//document.write("<TABLE width=100% BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ALIGN=CENTER > <TR><TD ALIGN=CENTER >"+ style_font_2_open);
			}
			if (display_dept_gen[atn].dept_image_1_file!="" && s_image_src == "PRODUCT"){
				document.write("<A HREF=\"#\" onClick=return(visitargs('dept.asp','dept_id=" + display_dept_gen[atn].dept_id +"&','SURL')); class=\"deptlinkM\" target=_top >");
				document.write("<IMG ALIGN=\"left\" ");
				if(s_image_width==""){
					if (display_dept_gen[atn].dept_image_1_width!=""){
						document.write(" WIDTH="+ display_dept_gen[atn].dept_image_1_width +" ");
					}
				}else{
					document.write(" WIDTH ="+ s_image_width + " ");
				}
				document.write(" BORDER=0  VSPACE=5  HSPACE=5  ALT=\""+ display_dept_gen[atn].dept_name +"\" ");
				document.write(" SRC=\"assets/product_images/"+ display_dept_gen[atn].dept_image_1_file +"\"></A>");
				if (s_image_align=="CENTER"){
					//document.write(" </TD></TR> <TR><TD ALIGN=CENTER >"+ style_font_2_open);
				}
			}
			if (display_dept_gen[atn].dept_disable_name=="" || display_dept_gen[atn].dept_disable_name < 2){
				if (display_dept_gen[atn].dept_display_type==1 || display_dept_gen[atn].dept_display_type==4){
					document.write("<A HREF=\"#\" onClick=return(visitargs('dept.asp','dept_id="+ display_dept_gen[atn].dept_id +"&','SURL')); class=\"deptlinksub\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}else if (display_dept_gen[atn].dept_display_type==2){
					document.write("<A HREF=\"#\" onClick=return(visitargs('frameset.asp','target="+ display_dept_gen[atn].dept_hyperlink +"&','SURL')); class=\"deptlinksub\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}else{
					document.write("<A HREF=\"#\" onClick=return(visitargs('"+ display_dept_gen[atn].dept_hyperlink +"','','SURL')); class=\"deptlinkP\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}
			}
			document.write(display_dept_gen[atn].dept_short_description);

			if (display_dept_gen[atn].attached_depts!=null && display_dept_gen[atn].attached_depts.length>0){
				document.write("2ndlevelDEPT");
				//display_dept_gen(display_dept_gen[atn].attached_depts);
			}
			if (s_image_align=="CENTER"){
				//document.write(" </TABLE>");
				}
			if (d_display_type==4){
				if (n_dept==dept_cols){
					n_dept=0;
					document.write(style_LI_1_close);
				}else{
					document.write(style_font_2_close +"</TD><TD>" + style_font_2_open);
				}
			}else{
				document.write(style_LI_1_close);
			}

		} //end loop
		document.write(style_UL_close);
	}
}//end display_dept_2nd

function display_dept_gen(display_dept_gen){
	if (display_dept_gen.length >= 1){
		var n_dept=0;
		var atn;
		document.write(s_top_HTML);
		document.write(style_UL_open);

		for (atn=0;atn< display_dept_gen.length ;atn++){
			if (n_dept==0 || d_display_type!=4){document.write(style_LI_1_open + style_font_2_open);}
			n_dept=n_dept+1 ;
			if (s_image_align=="CENTER"){
				//document.write("<TABLE width=590 BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"5\" ALIGN=CENTER > <TR><TD ALIGN=left width=\"260\">"+ style_font_2_open);
			}
			if (display_dept_gen[atn].dept_image_1_file!="" && (s_image_src == "PRODUCT" || s_image_src == "IMAGE" )){
				document.write("<A HREF=\"#\" onClick=return(visitargs('dept.asp','dept_id=" + display_dept_gen[atn].dept_id +"&','SURL')); class=\"deptlinkM\" target=_top >");
				document.write("<IMG ALIGN=\"left\" ");
				if(s_image_width==""){
					if (display_dept_gen[atn].dept_image_1_width!=""){
						document.write(" WIDTH="+ display_dept_gen[atn].dept_image_1_width +" ");
					}
				}else{
					document.write(" WIDTH ="+ s_image_width + " ");
				}
				document.write(" BORDER=0  VSPACE=5  HSPACE=5  ALT=\""+ display_dept_gen[atn].dept_name +"\" ");
				if (s_image_src=="PRODUCT"){
					document.write(" SRC=\"assets/product_images/"+ display_dept_gen[atn].dept_image_1_file +"\"></A>");
				}else{
					document.write(" SRC=\"assets/images/"+ display_dept_gen[atn].dept_image_1_file +"\"></A>");
				}
				if (s_image_align=="CENTER"){
					//document.write(" </TD></TR> <TR><TD ALIGN=CENTER>"+ style_font_2_open);
				}
			}
			if(display_dept_gen[atn].dept_disable_name=="" || display_dept_gen[atn].dept_disable_name < 2){
				if (display_dept_gen[atn].dept_display_type==1 || display_dept_gen[atn].dept_display_type==4){
					document.write("<A HREF=\"#\" onClick=return(visitargs('dept.asp','dept_id="+ display_dept_gen[atn].dept_id +"&','SURL')); class=\"deptlinkM\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}else if (display_dept_gen[atn].dept_display_type==2){
					document.write("<A HREF=\"#\" onClick=return(visitargs('frameset.asp','target="+ display_dept_gen[atn].dept_hyperlink +"&','SURL')); class=\"deptlinksub\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}else{
					document.write("<A HREF=\"#\" onClick=return(visitargs('"+ display_dept_gen[atn].dept_hyperlink +"','','SURL')); class=\"deptlinkP\" target=_top >"+ display_dept_gen[atn].dept_name +"</A>");
				}
			}
			document.write(display_dept_gen[atn].dept_short_description);

			if (display_dept_gen[atn].attached_products!=null && display_dept_gen[atn].attached_products.length>0){
				display_products_gen(display_dept_gen[atn].attached_products,1);
			}
			if (display_dept_gen[atn].attached_depts!=null && display_dept_gen[atn].attached_depts.length>0){
				display_dept_2nd(display_dept_gen[atn].attached_depts);
			}
			if  (s_image_align=="CENTER"){
				//document.write(" </TABLE>");
			}
			if(d_display_type==4){
				if (n_dept==dept_cols){
					n_dept=0;
					document.write(style_LI_1_close);
				}else{
					document.write(style_font_2_close +"</TD><TD>" + style_font_2_open);
				}
			}else{
				document.write(style_LI_1_close);
			}
		} //end loop
		document.write(style_UL_close);
	}
} //end display_dept_gen

function display_products_gen(Dept_products_gen,p_display_type){

	if (p_display_type==null){
		p_display_type=display_type;
	}
	
	var sizes = "";
	var arSizes = new Array();
	var colors = "";
	var arColors = new Array();
	
	document.write("<div class=deptskuinfo><div class=DeptTitledeptsku>"+dept_name+"</div><br>");
	//~ if(Dept_products_gen.length>0)
	//~ {
		//~ display_thumbnails(Dept_products_gen[0].info_attributes,Dept_products_gen[0].pf_id);
	//~ }
	
	if (Dept_products_gen.length >= 1){
		var sku_index;
		var n_product=0;
		var atn;
		var n_columns=3;
		var index_wide=0;
		atn=0;

		//addto form
		document.write("<Form name=addtobasket method=GET action=\"shopper_lookup.asp\">");
		document.write("<Input type=hidden name=target value='xt_orderform_additem.asp'>");
		document.write("<Input type=hidden name=auto_reg value='1'>");
		document.write("<Input type=hidden name=sku id=sku value=''>");
		document.write("<Input type=hidden name=qty id=qty value=''>");
		document.write("<Input type=hidden name=addto value='1'>");
		document.write("<Input type=hidden name=s_id value='" + s_id + "'>");
		document.write("<Input type=hidden name=dept_id id=dept_id value='"+dept_id+"'>");
		document.write("<Input type=hidden name=pf_id id=pf_id value=''>");
		document.write("<span class=deptskuDescription><b>Description</b><br>");
		document.write("<div id=\"Top_desc\">Top:</div>");
		document.write("<div id=\"Bottom_desc\">Bottom:</div></span>");
		document.write("<br><span class=deptskuDescription><b>Sizes</b><br>");
		document.write("<div id=\"sizes\"></div></span>");
		document.write("<br><span class=deptskuDescription><b>Colors</b><br>");
		document.write("<div id=\"colors\"></div></span>");
		document.write("<br><span class=deptskuDescription><b>Price</b><br>");
		document.write("<div id=\"Top_price\">Top:</div>");
		document.write("<div id=\"Bottom_price\">Bottom:</div></span><br>");
		document.write(p_top_HTML);
		document.write("<div id=\"Top_select\">Top:</div>");
		document.write("<br><div id=\"Bottom_select\">Bottom:</div>");
		document.write("<br><Input type=image onclick=\"return add_all_items(" + Dept_products_gen.length + ");\" name=\"addall\" src=\"assets/images/btnaddbskt1.gif\"><br>");
		document.write("<br><A HREF=\"javascript:shareproductdeptsku('share_new.asp','none','SURL','"+Dept_products_gen[0].image+"');\">");
		document.write("<img src=\"assets/images/btnemlfriend.gif\" border=\"0\" alt=\"Share this product with a friend\"></a><br>");
		document.write("<br><A HREF=\"dept.asp?dept_id=130&\" onclick=\"return(visitargs('dept.asp','dept_id=130',''))\"><img src=\"assets/images/btnsizeguide.gif\" border=\"0\" alt=\"Size Guide\"></a><br>");
		document.write("</Form></div>");
		
		var draw_select = new Array();
		for (atn=0; atn<Dept_products_gen.length; atn++)
		{
			var which_part;
			var suit_part;
			
			if (Dept_products_gen[atn].porder_code.substr(0,2)=="3T" || Dept_products_gen[atn].porder_code.substr(0,2)=="3t")
			{
				suit_part="Top";
				which_part=0;
			}
			else
			{
				suit_part="Bottom";
				which_part=1;
			}
			Dept_products_gen[atn].skus.sort(UUSort);
			//sku array
			if(Dept_products_gen[atn].skus.length>0)
			{
				//dropdown for skus
				draw_select[which_part]=("<Input type=\"hidden\" id=\"sku_" + atn + "\" name=\"sku_" + atn + "\" value=\"multiple\">");
				draw_select[which_part]+=("<br>"+Dept_products_gen[atn].name+"<br>");
				draw_select[which_part]+=("<select id=\"sel_" + atn + "\" name=\"sel_" + atn + "\" class=\"ProductAttr\">");
				draw_select[which_part]+=("<option value=\"\" class=\"ProductAttrLabel\">"+suit_part+" Selections --</option>");
				for (sku_index=0;sku_index<Dept_products_gen[atn].skus.length ;sku_index++)
				{
					//begin code to fill size & color info into divs
					if (sizes.indexOf("," + Dept_products_gen[atn].skus[sku_index].attr_value1 + ",")==-1)
					{
						sizes += "," + Dept_products_gen[atn].skus[sku_index].attr_value1 + ",";
						arSizes.push(Dept_products_gen[atn].skus[sku_index].attr_value1);
					}
					if (colors.indexOf("," + Dept_products_gen[atn].skus[sku_index].attr_value2 + ",")==-1)
					{
						colors += "," + Dept_products_gen[atn].skus[sku_index].attr_value2 + ",";
						arColors.push(Dept_products_gen[atn].skus[sku_index].attr_value2);
					}
					//end code to fill size & color info into divs
				
					draw_select[which_part]+=("<option value=\"" + Dept_products_gen[atn].skus[sku_index].sku + "\" >");
					//attributes
					if (Dept_products_gen[atn].pvendor_code=="default")
					{
						draw_select[which_part]+=(Dept_products_gen[atn].skus[sku_index].attr_value2 + " - " + Dept_products_gen[atn].skus[sku_index].attr_value1+ " - " + Dept_products_gen[atn].skus[sku_index].avail_msg);
					}
					else
					{
						draw_select[which_part]+=(Dept_products_gen[atn].pvendor_code + " " +Dept_products_gen[atn].skus[sku_index].attr_value2 + " - " + Dept_products_gen[atn].skus[sku_index].attr_value1 + " - " + Dept_products_gen[atn].skus[sku_index].avail_msg);
					}
					draw_select[which_part]+=("</option>");
				}//end for
				draw_select[which_part]+=("</select>");
			}else{
				//single sku instance
				draw_select[which_part]+=("<Input type=\"hidden\" id=\"sku_" + atn + "\" name=\"sku_" + atn + "\" value=\"" + Dept_products_gen[atn].skus[sku_index].sku + "\">");
			}
			
			document.getElementById(suit_part+"_desc").innerHTML+="<br>"+Dept_products_gen[atn].name;
			document.getElementById("sizes").innerHTML=arSizes.toString();
			document.getElementById("colors").innerHTML=arColors.toString();
			document.getElementById(suit_part+"_price").innerHTML+="<br>"+Dept_products_gen[atn].price_str;
			draw_select[which_part]+=("<INPUT TYPE=hidden id=\"qty_" + atn + "\" name=\"qty_" + atn + "\" value=\"1\" >");
			draw_select[which_part]+=("<INPUT TYPE=hidden id=\"prodname_" + atn + "\" name=\"prodname_" + atn + "\" value=\""+Dept_products_gen[atn].name+"\"> ");
			document.getElementById(suit_part+"_select").innerHTML+=draw_select[which_part];
			n_product=n_product+1;				
		}//end for
	}else{
		document.write(style_font_1_open + p_no_product_HTML + style_font_1_close);
	}
}
function dept_add_item(prod_index){

	var selsku,elt;
	selsku="";
	//get the selected sku
	elt=document.getElementById("sku_" + prod_index);
	if (elt.value=="multiple"){
		//get the selected index off the dropdown
		elt=document.getElementById("sel_" + prod_index);
		selsku=elt[elt.selectedIndex].value;
	}else{
		selsku=elt.value;
	}
	
	var selqty;
	selqty="";
	//get the selected qty
	selqty=document.getElementById("qty_" + prod_index);

	if(selsku!=""){
		//set it to sku value
		document.getElementById("sku").value=selsku;
		document.getElementById("qty").value=selqty;
		document.getElementById("pf_id").value=Dept_products[prod_index].pf_id;
		document.getElementById("dept_id").value=Dept_products[prod_index].dept_id;
		//submit form
		return true;
	}else{return false;}
}

function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }
   
   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }
   
function add_all_items(i_prodcount){
	var errmsg="";
	var elt;
	var prodname="";
	var skulist="";
	var sku9="";
	var qtylist="";

	//first check to make sure all items have a chosen sku
	for (kk=0;kk<i_prodcount;kk++){
		if(document.getElementById("sku_" + kk).value=="multiple"){
			elt=document.getElementById("sel_" + kk);
			if(elt){
				sku9=elt[elt.selectedIndex].value
				if(sku9==''){
					//~ prodname=document.getElementById("prodname_" + kk).value;
					//~ errmsg=errmsg + "\There was no size/color picked for " + prodname + ".\n";
				}else{
					if(document.getElementById("qty_" + kk).value=="" || isInteger(document.getElementById("qty_" + kk).value)==false){
						//qtylist=qtylist+",1";
					}else{
						skulist=skulist + "," + sku9;
						qtylist=qtylist+","+document.getElementById("qty_" + kk).value;
					}
				}
			}
		}
		
	}
	
	if (skulist.length == 0)
	{
		errmsg = "Please make all selections and enter desired quantities before proceeding.";
	}
	
	//if we have all skus properly, submit the add, otherwise give msg and return false.
	if(errmsg.length>0){
		alert(errmsg);
		return false;
	}else{
		document.getElementById("sku").value=skulist;
		document.getElementById("qty").value=qtylist;
		return true;
	}
}

function display_spanner(){
	if(intMaxPages>1){
		var spanner_links="";
		var item;
		for (item=1;item <= intMaxPages ;item++){
			if (item !=intCurrentPage){
				spanner_links=spanner_links + "<A HREF=\"\" onClick=return(visitargs('dept.asp','dept_id="+ dept_id +"&page="+ item +"','SURL'));  target=_top > "+ item +"</A> "
			}else{
				spanner_links=spanner_links +" <B> "+ item +"</B>"
			}
		}
		display_spanner_links(intCurrentPage,intMaxPages,spanner_links);
	}
} //end display_spanner

function shareproductdeptsku(PageURL,args,SURL,prod_image) 
{ 

var plink;
var emailbody;
var url;
if (args.indexOf("=")<0 ||args.indexOf("&")<0 ){
args="";
}
	if (user_guid !=' ') 
	{
		PageURL =PageURL + '?mscssid='+ user_guid+ '&dept_id='+dept_id+ '&'+ args ;
	}else{
		PageURL =PageURL + '?dept_id='+dept_id+ '&'+ args ;
	}
	
	plink=i_jscript_uu_rootURL+"dept.asp?dept_id=" + dept_id + "&" ;
	emailbody="Dear #RecipientName#,<BR> #Text_field_3# <BR><BR>";
	if (prod_image!=""){
	emailbody = emailbody + "<A HREF=\"#URL#\" ><img src=\""+i_jscript_uu_rootURL+"assets/product_images/"+prod_image+"\" border=0 alt=\""+ dept_name +"\" ></a>" ;
	}
	emailbody = emailbody + "<A HREF=\"#URL#\" >"+ dept_name + "</a><BR>" ;
	emailbody = emailbody + "from #FromName#  at <A href=\"mailto:#FromEmail#\">#FromEmail# <BR>" ;
	window.location=PageURL +"referer="+escape(plink)+"&email_body="+escape(emailbody)+"&target="+ escape(window.location.href)+"&";
	//Note: This return is required as well
	// false tells the browser to ignore the default action entirely
	//usage Click Here II
	 return(false);
} //end shareproduct

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// structs
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ProdSku(){
	this.sku
	this.attr_value1
	this.attr_value2
	this.attr_value3
	this.attr_value4
	this.attr_value5
	this.price_list
	this.price_sale
	this.price_MSRP
	this.avail
	this.avail_msg
}

function Products(){
	this.pf_id
	this.dept_id
	this.name
	this.short_desc
	this.pvendor_code
	this.porder_code
	this.image
	this.image_width
	this.enable_basket
	this.onsale
	this.price_str_list
	this.price_str_sale
	this.price_str_msrp
	this.price_str
	this.attr_label1
	this.attr_label2
	this.attr_label3
	this.attr_label4
	this.attr_label5
	this.info_attributes
	this.skus
}

function departments(){
	this.dept_id
	this.dept_name
	this.dept_short_description
	this.dept_display_type
	this.dept_hyperlink
	this.dept_list_2_levels
	this.dept_list_product_levels
	this.dept_disable_name
	this.dept_image_1_file
	this.dept_image_1_width
	this.attached_depts
	this.attached_products
}

//-->	
/**
 * Returns true if 'e' is contained in the array 'a'
 * @author Johan Känngård, http://dev.kanngard.net
 */
function contains(a, e) {
	for(j=0;j<a.length;j++)if(a[j]==e)return true;
	return false;
}

function draw_related(type,display,message,rel_image_enable,rel_image_width,rel_list_pricelab,rel_sale_pricelab,rel_our_pricelab){
	var prodlink="";
	var typematch=0;
	var show_price=1;
	var number_of_columns=4;
	
	var shownItems=new Array(); //used to keep track of items that were already displayed

	if(typeof type=="undefined"){
	type="0";
	}
	if (typeof display=="undefined"){
	display=1;
	}
	if (typeof message=="undefined"){
	message="";
	}
	if (typeof rel_image_enable=="undefined"){
	rel_image_enable="PRODUCT";
	}
	if (typeof rel_image_width=="undefined"){
	rel_image_width="";
	}
	if (typeof rel_list_pricelab=="undefined"){
	rel_list_pricelab="Price ";
	}
	if (typeof rel_sale_pricelab=="undefined"){
	rel_sale_pricelab="Sale Price";
	}
	if (typeof rel_our_pricelab=="undefined"){
	rel_our_pricelab="Our Price";
	}

	if (Related_prod.length >0){
		for (itematn=0;itematn< Related_prod.length ;itematn++){
			for (atn=0;atn< Related_prod[itematn].related.length ;atn++){
				if (Related_prod[itematn].related[atn].crosstype==type){
					typematch=1;
				}
			}
		}
	}
	if (typematch==1) {
		document.write("<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"SubHeadbgcolor\"><tr><td>");
		document.write("<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"tablebgcolor\"><tr><td class=CartLabels>");
		document.write(message);
		document.write("</td></tr><tr><td align=center>");
	}

	if (Related_prod.length>0){
		document.write("<Table border=0 cellpadding=2 cellspacing=2>");
		document.write("<TR valign=\"bottom\">");
		for (itematn=0;itematn< Related_prod.length ;itematn++){
			for (atn=0;atn< Related_prod[itematn].related.length ;atn++){
				//if type matches and the product was not already shown...
				if (Related_prod[itematn].related[atn].crosstype==type && !contains(shownItems,Related_prod[itematn].related[atn].pf_id)){
					//add item to array of shown items 
					shownItems.push(Related_prod[itematn].related[atn].pf_id);
					
					if (user_guid !=' '){
							prodlink="<A HREF=\"" + Related_prod[itematn].related[atn].link +"s_id=" + i_jscript_uu_sid +  "&mscssid="+ user_guid+ "&\">";
					}
					else{
							prodlink="<A HREF=\"" + Related_prod[itematn].related[atn].link +"s_id=" + i_jscript_uu_sid +  "&\">";
					}
					if (display==1){
						document.write("<TD class=relProduct WIDTH=\"100%\" VALIGN=TOP ALIGN=CENTER>");
					}else{
					document.write("<TD class=relProduct VALIGN=TOP ALIGN=CENTER>");
					}
					//product image & link
					if ((Related_prod[itematn].related[atn].image!="")&&(rel_image_enable!="NONE")){
						document.write(prodlink);
						if (rel_image_width !=""){
							document.write("<img ALIGN=CENTER WIDTH =\"" + rel_image_width + "\" BORDER=0  VSPACE=0  HSPACE=0  ALT=\"" + Related_prod[itematn].related[atn].name + "\" SRC=\"assets/product_images/" + Related_prod[itematn].related[atn].image + "\"></A>");
						}else{
							document.write("<img ALIGN=CENTER BORDER=0  VSPACE=0  HSPACE=0  ALT=\"" + Related_prod[itematn].related[atn].name + "\" SRC=\"assets/product_images/"+ Related_prod[itematn].related[atn].image +"\"></A>");
						}
						if (display==1){
							document.write("</TD></TR><TR class=relProduct><TD class=relProduct WIDTH=100% VALIGN=TOP ALIGN=CENTER>");
						}else{
							document.write("<BR>");
						}
					}
					//product name link
					document.write(prodlink + Related_prod[itematn].related[atn].name + "</A>");
					//product price (if enabled)
					if ((show_price==1)&&(Related_prod[itematn].related[atn].list_price!="")){
						if (Related_prod[itematn].related[atn].on_sale!="False" && Related_prod[itematn].related[atn].sale_price!="" && Related_prod[itematn].related[atn].sale_price!="$0.00" && Related_prod[itematn].related[atn].sale_price!=Related_prod[itematn].related[atn].list_price){
							document.write("<font class=ListPricewSaleR>" + rel_list_pricelab + Related_prod[itematn].related[atn].list_price + " </font>");
							document.write("<font class=SalePriceR>" + rel_sale_pricelab + Related_prod[itematn].related[atn].sale_price + " </B></font>");
						}else{
							document.write("<font class=ListPricewoSaleR>" + rel_our_pricelab + Related_prod[itematn].related[atn].list_price + " </font>");
						}
					}
					document.write("</TD>");
					
					if (display==1){
							document.write("</TR>");
					}else if((atn+1)%number_of_columns==0&&(atn+1)!=Related_prod[itematn].length)
					{
					  document.write("</TR>");
					}
				}
			}
		
		document.write("</Table>");
		}
	}
	if (typematch==1) {
		document.write("</TD></TR></TABLE></TD></TR></TABLE>");
	}
}//end function draw_related
