//<!-- Copyright (c) 1999-2005 UniteU Technologies Inc.  All rights reserved.   //-->
//<!--

//This comments out one line

/*
anything between
these points
is commented out
*/

/*
Strings are encapsulated by quotations.   "This is a string"  would print out: This is a string
Strings can contain quotes if they are escaped "Harry said, \"Today is beautiful\""    would print out: Harry said, "Today is beautiful"

We can connect pieces of a string together using the + sign for concatenation.   "This " + "is " + "a " + "String."    would print out:  This is a String

Variables do not have quotes... eg) product_name

create a variable:
[variable keyword] [variable name] [assignment operator] [variable content]
var name = "kate";

document.write(name);  //Would print out: kate
name = "clark";
document.write(name); //Would print out : clark

http://www.w3schools.com/js/default.asp
*/


function draw_image_1(){
	if (product_image[0].image!="" && product_image[0].image_show==1){
		document.write("<IMG ALT=\"" + product_name + "\" ALIGN=\"" + product_image[0].align + "\" BORDER=0 SRC=\"assets/product_images/" + product_image[0].image + "\" usemap=\"#" + pf_id + "\" ");
		if (product_image[0].width!="") {
			document.write("WIDTH =" +product_image[0].width);
		}
		document.write(" BORDER=0  VSPACE=0  HSPACE=0>");
	}
}

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 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 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 draw_leaf_tree()
{
  var base_dept="3001";
  var passed_base=false;
  if ((typeof(leaf_tree)!="nothing")&&(leaf_tree.length>0))
  {
		for (i=leaf_tree.length-1;i>=0;i--)
		{
			if (passed_base && leaf_tree[i].dept_name.toLowerCase()!="navigation name 10" && leaf_tree[i].dept_name.toLowerCase()!="root name 0")
			{
				//seperator
				
				document.write("&nbsp;>&nbsp;");
				//link and name
				document.write("<a href=\"" + leaf_tree[i].dept_link + "\" class=LeafTree >" + leaf_tree[i].dept_name.toLowerCase() + "<\/a>");
			}else{
				if (leaf_tree[i].dept_id==base_dept && leaf_tree[i].dept_name.toLowerCase()!="navigation name 10" && leaf_tree[i].dept_name.toLowerCase()!="root name 0")
				{
					passed_base=true;
					//HOME link and HOME name
					
					document.write("<a href=default.asp class=LeafTree >home<\/a>");
				}
			}
		}
  }
} //end draw_leaf_tree

function draw_options(){
	i=0;
	while (attr_label[i]!= "") { 
		if (attr_label[i]!= "U_Prod_Xlink"){
			if (attr_values[i].length > 0){
				document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel >" + attr_label[i] + ":</TD><TD class=ProductAttr>");
			}
			if (attr_values[i].length==0){
				document.write("<INPUT TYPE=HIDDEN  NAME=\"attr_value" + (i+1) + "\" VALUE=\"\" >");
			}else if (attr_values[i].length==1){
				while (attr_values[i][0].indexOf("'")>0){
					attr_values[i][0]=attr_values[i][0].replace("'","&#39;");
				}
				document.write("<INPUT TYPE=HIDDEN  NAME=\"attr_value" + (i+1) + "\" VALUE='" + attr_values[i][0] + "' >");
				document.write(attr_values[i][0]);
				document.write("</TD>");
			}else if(attr_values[i].length >1) {
				document.write("<SELECT class=ProductAttr NAME=\"attr_value" + (i+1) + "\" onchange=return(argschange(\"" + (i+1) + "\")); >");
				for (atn=0;atn< attr_values[i].length ;atn++){
					writeoption(attr_values[i][atn],attr_values[i][atn],sel_values[i]);
				}
				document.write("</SELECT></TD>");
			}
			if (attr_values[i].length > 0){document.write("</TR><tr><td height=2></td></tr>");}		
		}
		if (attr_label[i]== "U_Prod_Xlink" ){
			document.write("<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 VALIGN=TOP ALIGN=CENTER >");	
			i_rows=0;
			for (atn=0;atn< U_Prod_Xlink.length ;atn++){
				if (i_rows ==0){document.write("<TR><TD></TD>");} 
				i_rows++ ;		
				document.write("<TD VALIGN=TOP CELLPADDING=1 WIDTH =60 ALIGN=CENTER >");
				document.write("<A HREF=\"#\" onClick=return(visitargs('product.asp','dept_id=" + U_Prod_Xlink[atn].dept_id + "&pf_id=" + U_Prod_Xlink[atn].pf_id + "&'));>");
				document.write("<img ALIGN =CENTER WIDTH =60 BORDER=0  VSPACE=0  HSPACE=0  ALT=\""+ U_Prod_Xlink[atn].name +"\"");  
				document.write("SRC=\"assets/product_images/"+ U_Prod_Xlink[atn].image + " \"> </A>");
				document.write("<SMALL>"+ U_Prod_Xlink[atn].name +"</SMALL> </TD>");
				if (i_rows == 4) {
					document.write("</TR>"); 
					i_rows=0;
				} 
			}
		}	
		i++;	
	}
} // end function draw_options

var extraWindow;
function createPopWindow()
{
  var tempWindow = window.open('','prints','height=325,width=325,top=0,left=0,scrollbars=no,resizable');
  tempWindow.document.write("<html><head><title>Product Image</title></head><body><table><tr><td id=\"pop_content\"></td></tr></table></body></html>");
  return tempWindow;
}
function simple_pop_args(product_name,image_name) 
{				
    if (extraWindow==null){
    extraWindow = createPopWindow();
    }
    var mycontentArea = extraWindow.document.getElementById('pop_content');
    mycontentArea.innerHTML = "<td><div style=\"position:absolute; top:0; left:0; width:350px; background-color: #ffffff;\"><FONT color=red><B> "+ product_name + " </B></FONT><BR><BR><img src=\"assets/product_images/" + image_name + "\"  border=\"0\"></div></td>";
		extraWindow.window.focus();
		extraWindow = null;
		//Note: This return is required as well
		// false tells the browser to ignore the default action entirely
	return;	
	}

function killWindow()
{
  extraWindow = null;
}

function draw_alu_swatch(){
		
		if (U_Prod_Xlink.length > 1 ){
			document.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=3 VALIGN=TOP ALIGN=CENTER >");
	
			i_rows=0;
				for (atn=0;atn< U_Prod_Xlink.length ;atn++){
					if (i_rows ==0){
					document.write("<TR>");
					} 
				i_rows++ ;		
				document.write("<TD VALIGN=TOP CELLPADDING=1 ALIGN=CENTER >");
				document.write("<A HREF=\"javascript:simple_pop_args('" + U_Prod_Xlink[atn].name + "','" + U_Prod_Xlink[atn].image2 + "');\" >");
				document.write("<img ALIGN =CENTER BORDER=0  VSPACE=0  HSPACE=0  ALT=\""+ U_Prod_Xlink[atn].short_description +"\"");  
				document.write("SRC=\"assets/product_images/"+ U_Prod_Xlink[atn].image + " \"> </A>");
				document.write("<br clear=all><A HREF=\"javascript:simple_pop_args('" + U_Prod_Xlink[atn].name + "','" + U_Prod_Xlink[atn].image2 + "');\" >");
				document.write(U_Prod_Xlink[atn].name +"</A>");
				document.write("</TD>");
					if (i_rows == 3) {
					document.write("</TR>"); 
					i_rows=0;
					} 
				}
			document.write("</table>");	
		}
} // end function draw_alu_swatch

function draw_sku_option()
{
	if (product_var.length >= 1 ){
		if(product_var.length==1){
			document.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>");
			if (product_var[0].attr_value1!=""){
			document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[0] + "</TD><TD>");
			document.write("&nbsp;" + product_var[0].attr_value1 + "</TD></TR>");
			}
			if (product_var[0].attr_value2!=""){
					document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[1] + "</TD><TD>");
					document.write("&nbsp;" + product_var[0].attr_value2 + "</TD></TR>");
			}
			/*if (product_var[0].attr_value3!=""){
				document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[2] + "</TD><TD>");
				document.write("&nbsp;" + product_var[0].attr_value3 + "</TD></TR>");
			}*/
			if (product_var[0].attr_value4!=""){
				document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[3] + "</TD><TD>");
				document.write("&nbsp;" + product_var[0].attr_value4 + "</TD></TR>");
			}
			if (product_var[0].attr_value5!=""){
				document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[4] + "</TD><TD>");
				document.write("&nbsp;" + product_var[0].attr_value5 + "</TD></TR>");
			}
			//document.write("<TR><TD colspan=2>" + product_var[0].avail_msg + "</TD>");
			document.write("<INPUT TYPE=HIDDEN id=\"sku\" NAME=sku VALUE=\"" + product_var[0].sku + "\" >");
			document.write("</TABLE>");
		}else{	
			document.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>");
			document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel ><b>For Pricing, Select Size and Material:</b><br></TD></TR><TR><TD>");
			document.write("<SELECT class=ProductAttr NAME=sku  >");
			i=0;
			labelstr="";
			while (attr_label[i]!= "" && i < attr_values.length ) {				
				labelstr=labelstr + attr_label[i] + " ";
				if(i < attr_values.length - 1){ //WCD - 20090406 - SUP35293 - Adds an ampersand between values... except after the last one.
					labelstr += "&amp; ";
				}
				i++;
			}
			writeoption("",labelstr ,sel_values[0]);
			for (atn=0;atn< product_var.length ;atn++){
				if (useVariantPrice=="True"){
					if (on_sale=="True"){
						if (product_var[atn].attr_value5!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - " + product_var[atn].attr_value5 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
						}
						else if (product_var[atn].attr_value4!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
						}
						else if (product_var[atn].attr_value3!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
						}
						else if (product_var[atn].attr_value2!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
						}
						else{
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
						}
					}else{
						if (product_var[atn].attr_value5!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - " + product_var[atn].attr_value5 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value4!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value3!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value2!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else{
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
					}
				}else{
					//if (product_var[atn].avail_msg==""){
					//	product_var[atn].avail_msg="on back order";
					//}
					if (product_var[atn].attr_value5!=""){
						writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - " + product_var[atn].attr_value5 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
					}
					else if (product_var[atn].attr_value4!=""){
						writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
					}
					else if (product_var[atn].attr_value3!=""){
						writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
					}
					else if (product_var[atn].attr_value2!=""){
						writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - $"+ OKStrOfPenny(product_var[atn].price_sale)),sel_values[0]);
					}
					else{
						if (product_var[atn].attr_value5!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - " + product_var[atn].attr_value5 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value4!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - " + product_var[atn].attr_value4 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value3!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - " + product_var[atn].attr_value3 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else if (product_var[atn].attr_value2!=""){
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - " + product_var[atn].attr_value2 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
						else{
							writeoption(product_var[atn].sku,(product_var[atn].attr_value1 + " - $"+ OKStrOfPenny(product_var[atn].price_list)),sel_values[0]);
						}
					}
				}
			}
			document.write("</SELECT></TD>");	
			document.write("</TR></TABLE>");
		}
	}
} //end draw_sku_option

function draw_related(){
	var prodlink="";
	//page_option_4: 0=horizontal 1=vertical
	
	if (nRelated>0)
	{
		document.write("<Table border=0 cellpadding=2 cellspacing=2 width=\"100%\"><TR>");
		for (atn=0;atn< nRelated ;atn++)
		{
			prodlink="<A HREF=\"product.asp?pf_id=" + Related_prod[atn].pf_id + "&dept_id=" + Related_prod[atn].dept_id + "&\" onClick=\"return(visitargs('product.asp','pf_id=" + Related_prod[atn].pf_id + "&dept_id=" + Related_prod[atn].dept_id + "&'));\">";
			if (page_option_4==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[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[atn].name + "\" SRC=\"assets/product_images/" + Related_prod[atn].image + "\"><\/A>");
			}else{
			document.write("<img ALIGN=CENTER WIDTH =\"" + Related_prod[atn].width + "\" BORDER=0  VSPACE=0  HSPACE=0  ALT=\"" + Related_prod[atn].name + "\" SRC=\"assets/product_images/"+ Related_prod[atn].image +"\"><\/A>");
			}
			if (page_option_4==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[atn].name + "<\/A>");
			
			//product price (if enabled)
			if ((page_option_5==1)&&(Related_prod[atn].list_price!="")){
			if (Related_prod[atn].on_sale=="True"){
			document.write("<font class=ListPricewSaleR>" + rel_list_pricelab + Related_prod[atn].list_price + " <\/font>");
			document.write("<font class=SalePriceR>" + rel_sale_pricelab + Related_prod[atn].sale_price + " <\/B><\/font>");
			}else{
			document.write("<font class=ListPricewoSaleR>" + rel_our_pricelab + Related_prod[atn].list_price + " <\/font>");
			}
			}
			if (atn!=(nRelated-1)) {
				document.write("<hr class=\"rel\" />");	
			}
			document.write("<\/TD>");
			if (page_option_4!=1){
				if ((atn+1)%3==0){
					if((atn+1)%3==0&&(atn+1)!==nRelated){
						document.write("</tr>");
					}
				}
			}
		if (page_option_4==1){document.write("<\/TR>");}
		}
		document.write("<\/Table>");
	}
}//end function draw_related

function argschange(attr){
	// false tells the browser to ignore the default action entirely
	return(false);	
}
function popargs(dept_id,pf_id){
	// false tells the browser to ignore the default action entirely
	return(false);	
}

//--------------------------------
// Structures
//--------------------------------
function PImage()
{
	this.image
	this.image_show
	this.align
	this.width
	this.alt_text
	this.scr
	this.target
}

function XLINK()
{
	this.pf_id
	this.dept_id
	this.name
	this.short_description
	this.image
	this.image2
}

function Sku()
{
	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 Attrbute()
{
	this.attname
	this.attvalue
}

function RelSku()
{
	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 Related()
{
	this.pf_id
	this.dept_id
	this.name
	this.image
	this.onsale
	this.MSRP_price
	this.list_price
	this.sale_price
	this.skus	
}
function searchable_attr_struct(){
	this.sku
	this.name
	this.value
}
//-->	
