//floating basket code
var added_cart_msg = "The <b>" + product_name + "</b> has been added to your cart!<br>";
var added_wish_msg = "The <b>" + product_name + "</b> has been added to your wish list!<br>";

function _check_add_basket()
{

	var query = window.location.search.substring(1);
	
	if(query.indexOf('addto=4') != -1)
	{
	//redirect to wish_basket
	  window.location.replace("wish_basket.asp");
	}else if(query.indexOf('addto=2') != -1)
	{
	  //redirect to basket_compare
	  window.location.replace("compare_basket.asp");
	}else
	{
	
	
	if((query.indexOf('&addfrom=product&msg=added&')>0)&&(query.indexOf('&error=')<=0) && (shopping_basket.no_items > 0))
	{
		var cart_pop_fill = "";
		cart_pop_fill += "<table width=430 cellpadding=0 cellspacing=2 border=0 class=\"outermostpop\">";
		cart_pop_fill += "    <tr><td><table cellpadding=2 width=430 cellspacing=2 border=0 class=\"outerpop\">";
		cart_pop_fill += "        <tr><td><table cellpadding=10 width=\"430\" cellspacing=0 border=0 class=\"innerbg\">";
		cart_pop_fill += "        <tr><td align=\"right\"><a href=\"product.asp\" onClick=\"document.getElementById('cartpop').style.visibility = 'hidden';if (typeof document.getElementById('ddDiv')!='undefined'){document.getElementById('ddDiv').style.visibility = 'visible';}return false;\"><img src=\"assets/images/btn_close.gif\" border=0></a></td></tr>";
		if (query.indexOf('addto=1')!= -1)
		{
			cart_pop_fill += "            <tr><td>" + added_cart_msg + "</td></tr>";
			cart_pop_fill += "            <tr><td height=\"10\"></td></tr><tr><td>";
			cart_pop_fill += draw_pop_table();
			cart_pop_fill += draw_pop_buttons();
		}
		//~ else if (query.indexOf('addto=4')!= -1)
		//~ {
			//~ cart_pop_fill += "            <tr><td>" + added_wish_msg + "</td></tr>";
			//~ cart_pop_fill += "						<tr><td>Click <a href=\"wish_basket.asp\" onclick=\"return(visitargs('wish_basket.asp','','URL'));\">HERE</a> to view/modify your Online Gift Registry.</td></tr>";
			//~ cart_pop_fill += "            <tr><td height=\"10\"></td></tr><tr><td>";
			//~ cart_pop_fill += draw_pop_buttons_wish();
		//~ }
		//cart_pop_fill += draw_pop_buttons();
		cart_pop_fill += "            </td></tr></table>";
		cart_pop_fill += "      </td></tr>";
		cart_pop_fill += "  </table></td></tr></table>";
    	document.getElementById("cartpop").innerHTML = cart_pop_fill;
		if (typeof document.getElementById('ddDiv')!='undefined'){ document.getElementById('ddDiv').style.visibility = "hidden"; }
		}else{
   		document.getElementById("cartpop").style.height = 0;
	}
  }

} //end check_add_basket

function draw_pop_table()
{
  var cart_pop_tbl = "";
	if(shopping_basket.no_items > 0)
	{
		cart_pop_tbl += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" class=\"inneredge\">";
		cart_pop_tbl += "<tr><td><table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\">";
		cart_pop_tbl += "<tr class=\"innerheader\"><td align=\"center\">Item</td>";
		cart_pop_tbl += "<td width=160>Name / Attributes</td>";
		cart_pop_tbl += "<td align=\"center\">Qty</td>";
		cart_pop_tbl += "<td align=\"center\">Price Each</td>";
		cart_pop_tbl += "<td align=\"center\">Total</td></TR>";
		for (atn=0;atn< shopping_basket.items.length ;atn++)
		{
			cart_pop_tbl += "<tr bgcolor=\"#FFFFFF\"><TD class=cart_list_item align=center>";
	    cart_pop_tbl += "<img border=0 width=50 alt=\"\" src=\"assets/product_images/" + shopping_basket.items[atn].image + "\">";
			cart_pop_tbl += " </TD> ";
			cart_pop_tbl += "<TD class=cart_list_item>";
      cart_pop_tbl += shopping_basket.items[atn].name;
			cart_pop_tbl += " <span class=\"cart_item_attr\">";
			var tempstr ="";

			if (shopping_basket.items[atn].attr_value1 !=""){ tempstr = shopping_basket.items[atn].attr_value1; }
			if (shopping_basket.items[atn].attr_value2 !=""){ tempstr += ", " + shopping_basket.items[atn].attr_value2; }
			if (shopping_basket.items[atn].attr_value3 !=""){ tempstr += ", " + shopping_basket.items[atn].attr_value3; }
			if (shopping_basket.items[atn].attr_value4 !=""){ tempstr += ", " + shopping_basket.items[atn].attr_value4; }
			if (shopping_basket.items[atn].attr_value5 !=""){ tempstr += ", " + shopping_basket.items[atn].attr_value5; }
      if (shopping_basket.items[atn].info_attr1 !=""){ tempstr += ", " + shopping_basket.items[atn].info_attr1; }
      if (shopping_basket.items[atn].info_attr2 !=""){ tempstr += ", " + shopping_basket.items[atn].info_attr2; }
      if (shopping_basket.items[atn].info_attr3 !=""){ tempstr += ", " + shopping_basket.items[atn].info_attr3; }
			cart_pop_tbl += tempstr;
			cart_pop_tbl += "</span></TD>";
			cart_pop_tbl += "<TD class=cart_list_item  ALIGN=CENTER>" + shopping_basket.items[atn].quantity + "</TD>";
			cart_pop_tbl += "<TD class=cart_list_item  ALIGN=CENTER> $" + OKStrOfPenny(shopping_basket.items[atn].item_price) +" </TD>";
			cart_pop_tbl += "<TD class=cart_list_item  ALIGN=CENTER> $" + OKStrOfPenny(shopping_basket.items[atn].item_total) +" </TD>";
      cart_pop_tbl += "</TR>";
		}

    cart_pop_tbl += "<tr class=\"tablebgcolor\"><td colspan=\"4\" align=\"right\"><span class=\"cart_list_total\">Sub-Total:</span></td><td ALIGN=CENTER><span class=\"cart_list_total\">";
		cart_pop_tbl += " $"+ OKStrOfPenny(shopping_basket.sub_total) +" </TD></TR>";
		cart_pop_tbl += "</TABLE></td></tr><tr><td height=\"2\" class=\"tablebgcolor\"></td></tr></table>";
	}
	return cart_pop_tbl;
}
function draw_pop_buttons()
{
	var cart_pop_btns = "";
	if(shopping_basket.no_items > 0)
	{
		cart_pop_btns += "<TABLE width=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR><td align=center>";
		//cart_pop_btns += "<a href=\"product.asp\" onClick=\"document.getElementById('cartpop').style.visibility = 'hidden';if (typeof document.getElementById('ddDiv')!='undefined'){ document.getElementById('ddDiv').style.visibility = 'visible'; }return false;\"><img src=\"assets/images/btn_continue_shopping.gif\" alt=\"click to return to the catalog\" border=\"0\"></a>&nbsp;&nbsp;";
		//cart_pop_btns += "&nbsp;&nbsp;<a href=\"basket.asp\" onClick=\"return(visitargs('basket.asp','','URL'));\"><img src=\"assets/images/btnupdatebskt2.gif\" alt=\"update your cart\" border=\"0\"></a>";
		cart_pop_btns += "<a href=\"basket.asp\" onClick=\"return(visitargs('basket.asp','','URL'));\"><img src=\"assets/images/btntotal2.gif\" alt=\"click to checkout\" border=\"0\"></a></td>";
    cart_pop_btns += "</TR></TABLE>";
	}
	return cart_pop_btns;
}

function draw_pop_buttons_wish()
{
	var cart_pop_btns = "";
	//~ if(shopping_basket.no_items > 0)
	//~ {
		cart_pop_btns += "<TABLE width=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
		cart_pop_btns += "<td align=center><a href=\"product.asp\" onClick=\"document.getElementById('cartpop').style.visibility = 'hidden';if (typeof document.getElementById('ddDiv')!='undefined'){ document.getElementById('ddDiv').style.visibility = 'visible'; }return false;\"><img src=\"assets/images/btntotal2.gif\" alt=\"click to return to the catalog\" border=\"0\"></a>";
		//cart_pop_btns += "&nbsp;&nbsp;<a href=\"basket.asp\" onClick=\"return(visitargs('basket.asp','','URL'));\"><img src=\"assets/images/btnupdatebskt2.gif\" alt=\"update your cart\" border=\"0\"></a>";
		//cart_pop_btns += "&nbsp;&nbsp;<a href=\"basket.asp\" onClick=\"return(visitargs('basket.asp','','URL'));\"><img src=\"assets/images/btntotal2.gif\" alt=\"click to checkout\" border=\"0\"></a></td>";
    cart_pop_btns += "</TR></TABLE>";
	//~ }
	return cart_pop_btns;
}

//~ function chk_qty()
//~ {
  //~ var qty_val = document.getElementById("qty").value;
  //~ var sku_val = document.getElementById("sku").value;
  //~ var bskt_val = 0;
  //~ //check for existing qty in basket
  //~ if (shopping_basket.items.length > 0)
  //~ {
    //~ for (h=0;h<shopping_basket.items.length;h++)
    //~ {
      //~ if (sku_val == shopping_basket.items[h].sku)
      //~ {
        //~ bskt_val = shopping_basket.items[h].quantity;
      //~ }
    //~ }
  //~ }
  //~ var des_total = Number(qty_val) + Number(bskt_val);
	//~ var limit_num;
	//~ var x;
  //~ //this is only used if site is set to listen to inventory
  //~ if (i_jscript_uu_invmode != "1")
  //~ {
    //~ //check to see if total desired is more than avail
    //~ for (i=0;i<product_var.length;i++)
    //~ {
      //~ if (sku_val == product_var[i].sku)
      //~ {
  		  //~ //use number available in stock
  		  //~ limit_num = Number(product_var[i].avail);
        //~ if (des_total > limit_num)
        //~ {
          //~ var new_qty = limit_num - bskt_val;
          //~ if (new_qty <= 0)
          //~ {
            //~ alert("Your desired quantity exceeds the quantity available for this product. No additional product has been added to your cart.");
            //~ return false;
          //~ }
          //~ document.getElementById("qty").value = new_qty;
          //~ alert("Your desired quantity is more than the quantity available for this product. It has been adjusted.");

        //~ }
      //~ }
    //~ }
  //~ }
  //~ return true;
//~ }