/*!-- Copyright (c) 1999-2005 UniteU Technologies Inc.  All rights reserved.   //-->
* HICKEY STYLE 
* DESCR: added s_id=2 & width and height size to Draw Related, editor:cls, date:26.OCT.2007  
//<% version = " 4.91dg 05/17/05 " %>
**************************************************************/
//<!--
var winPhoto;
function makeNewWindow(path,title)
{
	winPhoto = window.open("","AltView","height=500,width=500,status=0,scrollbars=0,location=0,resizable=1");
	winPhoto.document.open();
	winPhoto.document.write('<html>');
	winPhoto.document.write('    <head>');
	winPhoto.document.write('        <title>');
	winPhoto.document.write(title);
	winPhoto.document.write('        </title>');
	winPhoto.document.write(' <link rel="stylesheet" type="text/css" href="assets/images/hickeystyle/includes/hickeystyle.css">');
	winPhoto.document.write('<script lang=javascript>');
	winPhoto.document.write('var largeimage = new Image();');
	winPhoto.document.write('largeimage.src ="' + path + '"');
	winPhoto.document.write('</script>');
	winPhoto.document.write('    </head>');
	winPhoto.document.write('    <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
	
	winPhoto.document.write('    <table border="0" cellspacing="0" cellpadding="2" align="center">');
	winPhoto.document.write('      <tr>');
	winPhoto.document.write('        <td valign="bottom">');
	winPhoto.document.write('          <table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>');	
	winPhoto.document.write('        	 <td><img src="assets/images/hickeystyle/hickeystyle_Header_r1_c1_pop.jpg"></td>');
	winPhoto.document.write('            <td background="assets/images/hickeystyle/hickeystyle_Header_r4_c2_pop.jpg" style="background-repeat:repeat-x; background-position:bottom;" width="100%" valign="bottom"><img src="assets/images/hickeystyle/hickeystyle_Header_r4_c2_pop.jpg"></td>');
	winPhoto.document.write('            <td valign="bottom"><img src="assets/images/hickeystyle/hickeystyle_Header_r4_c3_pop.jpg"></td></tr></table>');
	winPhoto.document.write('        </td>');
	winPhoto.document.write('      </tr>');
	winPhoto.document.write('      <tr>');
	winPhoto.document.write('      	<td align="center"><img align=center src="' + path + '" onLoad="window.resizeTo(largeimage.width+100,largeimage.height+200);" ></td>');
	winPhoto.document.write('      </tr>');
	winPhoto.document.write('      <tr>');
	winPhoto.document.write('      	<td background="assets/images/hickeystyle/hickey_footer_r1_c7.jpg" style="background-repeat:no-repeat; background-position:right;" bgcolor="#e8e8e8"><a class="FooterLink" href="javascript:window.close();">close window</a></td>');
	winPhoto.document.write('      </tr>');
	winPhoto.document.write('    </table>');
	
	winPhoto.document.write('    </body>');
	winPhoto.document.write('</html>');
	winPhoto.document.close();
	winPhoto.focus();
	return false;
}

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 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=0  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 =" + product_image[1].width + " ");}
			document.write(" BORDER=0  VSPACE=0  HSPACE=0 ALT=\"" + product_image[1].alt_text + "\" ");         
			document.write(" SRC=\"assets/product_images/" + product_image[1].image +"\">");
		}  		
	}
}

function shareproduct(PageURL,args,SURL) 
{ 

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+ '&pf_id='+pf_id+ '&'+ '&s_id='+s_id+ '&'+ args ;
	}else{
		PageURL =PageURL + '?dept_id='+dept_id+ '&pf_id='+pf_id+ '&'+ '&s_id='+s_id+ '&'+ args ;
	}
	
	plink=i_jscript_uu_rootURL+"product.asp?dept_id=" + dept_id + "&pf_id="+ pf_id +"&s_id=2&" ;
	emailbody="Dear #RecipientName#,<BR> #Text_field_3# <BR><BR>";
	if (product_image[0].image!=""){
	emailbody = emailbody + "<A HREF=\"#URL#\" ><img src=\""+i_jscript_uu_rootURL+"assets/product_images/"+product_image[0].image+"\" border=0 alt=\""+ product_name+"\" ></a>" ;
	}
	emailbody = emailbody + "<A HREF=\"#URL#\" >"+ product_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



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>");
			}
			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>");}		
		}
		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("<TD></TD><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 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("</TD>");
					if (i_rows == 4) {
					document.write("</TR>"); 
					i_rows=0;
					} 
				}
		}
} // end function draw_alu_swatch

function draw_sku_option()
{
	if (product_var.length >= 1 ){
		if(product_var.length==1){
			document.write("<TD> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>");
			document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[0] + "</TD><TD>");
			document.write("&nbsp;" + product_var[0].attr_value1 + "</TD></TR>");
			document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel>" + attr_label[1] + "</TD><TD>");
			document.write("&nbsp;" + product_var[0].attr_value2 + "</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("</TR></TABLE></TD>");
		}else{	
			document.write("<TD> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>");
			document.write("<TR VALIGN=TOP ><TD class=ProductAttrlabel >");
			document.write("<SELECT class=ProductAttr NAME=sku  >");
			i=0;
			labelstr="";
			//while (attr_label[i]!= "" && i < attr_values.length ) {
				//labelstr=labelstr + attr_label[i] + " ";
				//i++;
			//}
			//writeoption("",labelstr ,sel_values[0]);
			for (atn=0;atn< product_var.length ;atn++){
				if (useVariantPrice=="True"){
					if (on_sale=="True"){
						writeoption(product_var[atn].sku,(product_var[atn].attr_value2 + "  " + product_var[atn].attr_value1 + "  $"+ OKStrOfPenny(product_var[atn].price_sale)) + " " + product_var[atn].avail_msg + "" ,sel_values[0]);
					}else{
						writeoption(product_var[atn].sku,(product_var[atn].attr_value2 + "  " + product_var[atn].attr_value1 + "  $"+ OKStrOfPenny(product_var[atn].price_list)) + " " + product_var[atn].avail_msg + "" ,sel_values[0]);
					}
				}else{
					if (product_var[atn].avail_msg==""){
						product_var[atn].avail_msg="on back order";
					}
					writeoption(product_var[atn].sku,(product_var[atn].attr_value2 + "  " + product_var[atn].attr_value1) + " " + product_var[atn].avail_msg + "",sel_values[0]);
				}
			}
			document.write("</SELECT></TD>");	
			document.write("</TR></TABLE></TD>");
		}
	}
} //end draw_sku_option


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);	
}
//--------------------------------
// Value Pairs
//--------------------------------

function addsku(sku){
	document.form1.sku[1].value= sku ;
	return(true);
}

function checkforrelated(pf_id){
var foundindex=-1;
	if (Related_prod.length>0){
		for (atni=0;atni< Related_prod.length ;atni++){
				if (Related_prod[atni].pf_id==pf_id){
					foundindex=atni;
					break;
				}
		}
		
	}
	return foundindex;
}

function display_rel_product(index,display){
var prodlink;
	prodlink="<A HREF=\"" + Related_prod[index].link + "\">";
	if (display==1){
		document.write("<TR class=relProduct><TD class=relProduct WIDTH=\"100%\" VALIGN=TOP ALIGN=CENTER>");
	}else{
		document.write("<TD class=relProduct VALIGN=CENTER ALIGN=CENTER>");
	}
	//product image & link
		if ((Related_prod[index].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[index].name + "\" SRC=\"assets/product_images/" + Related_prod[index].image + "\"><\/A>");
			}else{
				document.write("<img ALIGN=CENTER  BORDER=0  VSPACE=0  HSPACE=0  ALT=\"" + Related_prod[index].name + "\" SRC=\"assets/product_images/"+ Related_prod[index].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[index].name + "<\/A>");	
			//product price (if enabled)
			if ((page_option_5==1)&&(Related_prod[index].list_price!="")){
				if (Related_prod[index].on_sale!="False" && Related_prod[index].sale_price!=""){
					document.write("<font class=ListPricewSaleR><BR>Currently priced seperatly at " + Related_prod[index].list_price + " <\/font>");
					document.write("<font class=SalePriceR><BR>Currently priced seperatly on Sale at "  + Related_prod[index].sale_price + " <\/B><\/font>");
				}else{
					document.write("<font class=ListPricewoSaleR><BR>Currently priced seperatly at " + Related_prod[index].list_price + " <\/font>");
				}
			}
			document.write("<\/TD>");
			if (display==1){document.write("<\/TR>");}
}


function display_valuepair(message,display)
{
  var relprodindex="";
  if(packages_array.length>0)
  {
		document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"SubHeadbgcolor\"><tr><td><table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\">");
	  document.write("<TR><TD class=\"relProductlabel\"");
	  if (display==0){document.write(" colspan=3");}
  	document.write(">" + message + "</TD></TR><TR valign=bottom>");	
  	for (atnp=0;atnp< packages_array.length ;atnp++)
  	{		
  		for (atn=0;atn< packages_array[atnp].children.length ;atn++)
  		{
  			document.write("<TD class=\"tablebgcolor\" align=\"center\">");	
  			document.write("<TABLE border=0 cellpadding=2 cellspacing=2 ALIGN=CENTER><TR valign=bottom>");
				relprodindex=checkforrelated(packages_array[atnp].children[atn].pf_id);
				if(relprodindex!=-1)
				{
					display_rel_product(relprodindex,display);
				}
				document.write("<TD class=relProduct VALIGN=CENTER ALIGN=CENTER>");
				
				document.write("<img src=\"assets/product_images/" + packages_array[atnp].children[atn].pf_id + "t.jpg\">");
				document.write("</TR><tr valign=bottom><td class=relProduct ALIGN=CENTER>");
				document.write(packages_array[atnp].children[atn].group +" for <BR> ");
				if (product_var.length == 0)
				{
					if (on_sale=="True")
					{
						document.write("$"+OKStrOfPenny(product_var[0].price_sale));
						document.write(" \+ $"+OKStrOfPenny(packages_array[atnp].children[atn].price)+"= $ " + OKStrOfPenny(Number(packages_array[atnp].children[atn].price) + Number(product_var[0].price_sale)));
					}else{
						document.write("$"+OKStrOfPenny(product_var[0].price_list));
						document.write(" \+ $"+OKStrOfPenny(packages_array[atnp].children[atn].price)+"= $ " + OKStrOfPenny(Number(packages_array[atnp].children[atn].price) + Number(product_var[0].price_list)));
					}
				}else{
					document.write("$"+OKStrOfPenny(packages_array[atnp].children[atn].price) + " more");
					
				}	
				document.write("<br><br>");
				document.write("<input type=hidden name=sku value=''>");
				document.write("<INPUT TYPE=Image  NAME=\"pbasket\" onclick=\"return(addsku('"+packages_array[atnp].children[atn].def_sku+"'));\" SRC=\"assets/images/" + button + "bskt1.gif\" ");
				document.write("BORDER=0 ALT=\"Add both to your shopping cart\" ALIGN=CENTER > ");		
				document.write("</TD></TR>");
				document.write("</TABLE></TD>");	
			  if (display==1){
			    document.write("</TR>");
			  }else if((atnp+1)%3==0&&(atnp+1)!=packages_array[atnp].children.length)
			  {
				  document.write("</TR>");
			  }
		  }
	  }
	  document.write("</TABLE></td></tr><tr><td height=\"10\" class=\"tablebgcolor\"></td></tr></table>");
  }	
}


//--------------------------------
// 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 searchable_attr_struct(){
	this.sku
	this.name
	this.value
}

function PackageChild(){
    this.pf_id
    this.group
    this.allowed_qty
    this.price
    this.def_sku
    this.rule
}
function PackageGroup(){
    this.group
	this.children
}

//-->	