var shopper=false;
var mDI = false;
var tDI = false;
var fc = 1;
var tcurr = 1;
var currT="";
var tobj=false;
var tidx=4;
var trt="";
var reb=false;
var submenu=false;

function popShip()
{ var o = document.getElementById("pship");
  var t = parseInt(o.offsetTop) + 20; var l = parseInt(o.offsetLeft)+80; // + (parseInt(o.offsetWidth) / 2);
  document.getElementById("tipMenu").style.top = t + "px";
  document.getElementById("tipMenu").style.left = l + "px";
  var s = 'Place $100 of items in your shopping cart; then enter <br />promo code HoopShip9 in the box labeled '
	+ '&ldquo;Enter promotional code.&rdquo;<br />Standard shipping on U.S. orders only. <br />'
	+ 'This offer cannot be combined with any other promotion.';
  document.getElementById("tipMenu").innerHTML = s;
  document.getElementById("tipMenu").style.display = "block";
  if (tDI) {window.clearTimeout(tDI);}
  tDI = window.setTimeout("hideTip()", 30000); return false; }

function popGift()
{ var o = document.getElementById("view1");
  var t = parseInt(o.offsetTop) + 300; var l = parseInt(o.offsetLeft)+0; // + (parseInt(o.offsetWidth) / 2);
  document.getElementById("tipMenu").style.top = t + "px";
  document.getElementById("tipMenu").style.left = l + "px";
  var s = 'Place any two hoops in your shopping cart; then enter <br />promo code GIFT2009 '
	+ 'in the box labeled &ldquo;Enter promotional code.&rdquo;<br />'
	+ 'The 30% discount will be applied at the payment page of checkout <br />to the hoop '
	+ 'of lesser or equal value. The discount CAN be repeated <br />within the same '
	+ 'order &ndash; if you purchase four hoops, the <br />discount will be applied to two; '
	+ 'if you purchase six hoops, <br />the discount will be applied to three, and so on.<br />'
	+ 'This offer cannot be combined with any other promotion.';
  document.getElementById("tipMenu").innerHTML = s;
  document.getElementById("tipMenu").style.display = "block";
  if (tDI) {window.clearTimeout(tDI);}
  tDI = window.setTimeout("hideTip()", 30000); return false; }

function verifyQ(sel)
{ var qt = document.fm.elements["pQty[]"];
  var pTotal = 0;
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value; } }
  if (pTotal == 0) { return popAlert("You must input a quantity."); }
  return true; }

function verifyMe(sel)
{ var qt = document.fm.elements["pQty[]"];
  var op = document.fm.elements["pOption[]"];
  var pTotal = 0;
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (op[i].value == "no selection")
	{ x = popAlert("Please select " + sel + "."); 
	  qt[i].focus(); qt[i].select();
	  return false; } } }
  if (pTotal == 0) { return popAlert("You must input a quantity."); }
  return true; }

function verifyThis(sel, xel)
{ var qt = document.fm.elements["pQty[]"];
  var op = document.fm.elements["pOption[]"];
  var ox = document.fm.elements["pOption2[]"];
  var pTotal = 0;
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (op[i].value == "no selection")
	{ x = popAlert("Please select " + sel + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
	else if (ox[i].value.substr(0, 12) == "no selection")
	{ x = popAlert("Please select " + xel + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
    } }
  if (pTotal == 0)
  { return popAlert("You must input a quantity for something."); }
  return true; }

function validEmail(s)
{ a = s.split("@"); if (!a[1]) {return 'No "@" in email address.';}
  b = a[1].split("."); if (!b[1]) {return 'No "." in email server.';}
  if (a[0].length < 1 || a[1].length < 4) {return 'Email address impossibly short.';}
  return false; }

function doMore(n)
{ var newdiv = document.createElement("div");
  newdiv.innerHTML = document.getElementById("fline").innerHTML;
  var container = document.getElementById("flines");
  container.appendChild(newdiv);
  ++fc; ns = "|" + fc;
  for (i=1; i<n; i++)
  { if (i==1) {s = "pOption[]";} else {s = "pOption" + i + "[]";}
    var x = "var op = document.fm.elements[\"" + s + "\"][" + fc + "]";
    eval(x);
    for (c=1; c < op.length; c++) { op.options[c].value += ns; } }
  return false; }

function navgr(m, o)
{ document.navver.m.value = m;
  document.navver.o.value = o;
  document.navver.submit(); return false; }
function decorer(m, t1, t2, t3, t4, t5)
{ document.decor.model.value = m;
  document.decor.tape1.value = t1;
  document.decor.tape2.value = t2;
  document.decor.tape3.value = t3;
  document.decor.tape4.value = t4;
  document.decor.tape5.value = t5;
  document.decor.submit(); return false; }

function optioner(m)
{ document.fm.elements["pOption[]"][1].selectedIndex = m;
  var b = m+""; borderer(b);
  return false; }
function borderer(t)
{ var b = ""; var x = t.substr(0,1);
  if (x!="n") {b = "hoop" + x;}
  if (currT)
  { var x = "document.getElementById(\"" + currT + "\").style.borderColor=\"transparent\""; eval(x); }
  currT = b;
  if (b) {var x = "document.getElementById(\"" + b + "\").style.borderColor=\"#b6a4b7\""; eval(x);} }

function hidePrep(i)
 { if (mDI) {window.clearTimeout(mDI);}
   mDI = window.setTimeout(function(){hideShop(i)}, 100); }
function hideShop(i)
 { if (mDI)
   { var x = "shopMenu"+submenu; document.getElementById(x).style.display = "none"; submenu=false;
     window.clearTimeout(mDI); } }
function keepShop(i)
 { window.clearTimeout(mDI); showShop(i); }
function showShop(i)
 { var x = "shopMenu"+i; document.getElementById(x).style.display = "block"; submenu=i;
   if (mDI) {window.clearTimeout(mDI);}
   mDI = window.setTimeout(function(){hideShop(i)}, 30000); }

function hideTrip()
 { if (tDI) {window.clearTimeout(tDI);}
   tDI = window.setTimeout("hideTip()", 100); }
function hideTip()
 { document.getElementById("tipMenu").style.display = "none";
   if (tDI) {window.clearTimeout(tDI); } }
function keepTip()
 { window.clearTimeout(tDI);
// showTip(tobj, tidx, trt);
 }
function showTip(o, i, r)
 { tobj=o; tidx=i; trt=r;
   var t = parseInt(o.offsetTop) - 20; var l = parseInt(o.offsetLeft) + (parseInt(o.offsetWidth) / 2);
   document.getElementById("tipMenu").style.top = t + "px";
   document.getElementById("tipMenu").style.left = l + "px";
   var x = i+'-Piece Hoop ... <a href="'+r+'about_our_hoops.php">More</a>';
   document.getElementById("tipMenu").innerHTML = x;
   document.getElementById("tipMenu").style.display = "block";
   if (tDI) {window.clearTimeout(tDI);}
   tDI = window.setTimeout("hideTip()", 30000); }

function stripper(x)
    { return (x.replace(/^\W+/,'')).replace(/\W+$/,''); }

function popUp(txt)
{ return showapop(txt); }

function popAlert(txt)
{ txt = '<h3>'+txt+'</h3>\n'+'<img src="../images/continue_button.gif" alt="continue" onclick="hideapop();" />';
  return showapop(txt); }

function popDetail(i, s)
{ if (s==1)
  { var imgs = ["1PButtonDetail.jpg", "1PieceDetail.jpg"];
    var txts = ["Snap Button Connects Hoop Ends", "1-Piece Collapsible Construction"]; }
  else if (s==2)
  { var imgs = ["DIY_UndecoBtn.jpg", "DIY_UndecoWhole.jpg"];
    var txts = ["Snap Button Connects Hoop Pieces", "Assembled Hoop"]; }
  else
  { var imgs = ["ButtonDetail.jpg", "4PieceDetail.jpg"];
    var txts = ["Snap Button Connects 4 Hoop Pieces", "Hoops Come in 4 Pieces"]; }
  var navs = ["1 of 2", "2 of 2"];
  var fwds = ["ForwardArrow_btn.gif", "spacer.gif"];
  var bcks = ["spacer.gif", "BackArrow_btn.gif"];
  var dirs = [1, 0];
  var msg = '<div class="detailp"><table><tr><td style="width: 342px; vertical-align: bottom;"><h4>' + txts[i] + '</h4></td>\n';
     msg += '<td colspan="3" class="right"><a href="#" onclick="return hideapop();">';
     msg += '<img src="images/close_button.gif" alt="" /></a></td></tr>\n';
     msg += '<tr><td colspan="4"><img src="images/' + imgs[i] + '" alt="" /></td></tr>\n';
     msg += '<tr><td></td><td style="width: 22px;">';
  if (i==0)
  {  msg += '<img src="images/' + bcks[i] + '" alt="" /></td>\n'; }
  else
  {  msg += '<a href="#" onclick="return popDetail(0, ' + s + ');"><img src="images/' + bcks[i] + '" alt="" /></a></td>\n'; }
     msg += '<td style="width: 40px; text-align: center;">' + navs[i] + '</td>\n';
     msg += '<td style="width: 22px;">';
  if (i==0)
  {  msg += '<a href="#" onclick="return popDetail(1, ' + s + ');"><img src="images/' + fwds[i] + '" alt="" /></a></td>\n'; }
  else
  {  msg += '<img src="images/' + fwds[i] + '" alt="" /></td>\n'; }
  msg += '</tr></table></div>';
  reb = true;
  document.getElementById("apop").style.backgroundColor = "#131145";
//  document.getElementById("padapop").style.padding = "10px";
  return showapop(msg); }

function makeDec(v)
  { var str = "" + Math.round (eval(v) * 100);
    while (str.length <= 2) {str = "0" + str; }
    var decpoint = str.length - 2;
    return str.substring(0, decpoint) + "." + str.substring(decpoint, str.length); }

function getFline(s)
{ a = s.split("|"); if (a[1]) {return a[1];} else {return 1;} }

function clrSrch()
  { if (document.getElementById("srcher").value == "SEARCH")
    { document.getElementById("srcher").value = ""; } }
