var shopper=false;
var mDI = window.setInterval("hidePrep()", 6000);
var fc = 1;
var fc5 = 1;
var tcurr = 2;

function popSnow(i)
{ if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
  { var f="alrt";} else {var f="old";}
  if (i==1) {var l="";} else { var l="../";}
  var s = 'Free shipping on orders over $50. Use code: Jolly. <p />'
	+ 'Sale ends 12/11/2011. US orders only. Promotions cannot be combined.<p />'
	+ '<img src="images/continue_button.gif" alt="continue" onclick="hide'+f+'();" />';
  return showalrt(s); }

function popHappy(i)
{ if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
  { var f="alrt";} else {var f="old";}
  if (!i) {var l="";} else { var l="../";}
  var s = '<b>Buy More, Save More!</b><p />'
	+ '10% Off Orders of $100 or more<br />'
	+ '15% Off Orders of $150 or more<br />'
	+ '20% Off Orders of $200 or more<p />'
	+ 'Enter promo code Snowflake<p />'
	+ 'Sale ends 12/15/2011. Promotions cannot be combined.<p />'
	+ 'Excludes Gift Certificates, Combo Sets, Sale Items, and Collapsible Top Hats.<p />'
	+ '<img src="' + l + 'images/continue_button.gif" alt="continue" onclick="hide'+f+'();" />';
  return showalrt(s); }

function doStars()
{ window.setInterval('restar()', 100); }

/*
function restar()
{ var a = document.getElementsByTagName("div");
  for (i=0; i<a.length; i++)
  { if (a[i].className=="prSnippetRatingUnclickable")
    { if (window.attachEvent) {a[i].attachEvent("onclick", readReviews);}
	else {a[i].addEventListener("click", readReviews, false);}
	a[i].style.cursor="pointer"; }
    else if (a[i].className=="prSnippetNumberOfRatingsText")
    { a[i].innerHTML=a[i].innerHTML.replace("Ratings", "Customer Reviews"); }
} }
*/

function restar()
{ var a = document.getElementsByTagName("div");
  for (i=0; i<a.length; i++)
  { if (a[i].className=="pr-snippet-stars")
    { if (window.attachEvent) {a[i].attachEvent("onclick", readReviews);}
	else {a[i].addEventListener("click", readReviews, false);}
	a[i].style.cursor="pointer"; }
} }

function readReviews()
{ if (tcurr!=2) {light_r();}
  window.location.hash='ReviewHeader'; }
function readDescs()
{ if (tcurr!=0) {light_d();}
  window.location.hash='viewDescs'; }
function readVides()
{ if (tcurr!=3) {light_v();}
  window.location.hash='viewVides'; }

function makeDollar(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 navgr(m, o)
{ document.navver.m.value = m;
  document.navver.o.value = o;
  document.navver.submit(); return false; }

function hidePrep()
 { window.clearInterval(mDI);
   mDI = window.setInterval("hideShop()", 100); }
function hideShop()
 { if (shopper)
   { document.getElementById("shopMenu").style.display = "none";
     shopper=false;
     window.clearInterval(mDI);
     mDI = window.setInterval("hideShop()", 30000); } }
function showShop()
 { document.getElementById("shopMenu").style.display = "block";
   shopper=true;
   window.clearInterval(mDI);
   mDI = window.setInterval("hideShop()", 30000); }

function stripper(x)
    { return (x.replace(/^\W+/,'')).replace(/\W+$/,''); }

function hideold()
{ document.getElementById("alrt").style.display = "none";
  return false; }

function hidealrt()
{ document.getElementById("dim").style.display = "none";
  document.getElementById("bkg").style.display = "none";
  return false; }

function hidexpop()
{ document.getElementById("xpop").style.display = "none";
  return false; }

function showalrt(txt)
{ var newdiv = document.createElement("div");
  if (txt!="") {document.getElementById("padalert").innerHTML = "";}
  newdiv.innerHTML = txt;
  var container = document.getElementById("padalert");
  container.appendChild(newdiv);
// || (event && !/(background|src)/.test(event.propertyName))) return;
  if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
  { document.getElementById("dim").style.display = "block";
    document.getElementById("bkg").style.display = "block"; }
  else
  { if (!document.body.scrollTop)
    { var y = document.documentElement.scrollTop; }
    else { var y = document.body.scrollTop; }
    document.getElementById("alrt").style.top = "" + (y+200) + "px"; 
    document.getElementById("alrt").style.display = "block"; }
  return false; }

function popUp(txt)
{ return showalrt(txt); }

function popAlert(txt)
{ if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
  { var f="alrt";} else {var f="old";}
  txt = '<h2>'+txt+'</h2>\n'+'<img src="../images/continue_button.gif" alt="continue" onclick="hide'+f+'();" />';
  return showalrt(txt); }

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 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 getFline(s)
{ a = s.split("|"); if (a[1]) {return a[1];} else {return 1;} }

function verifyOrder(opn, l)
{ var bTotal = 0;
  var pTotal = 0;
  var bv = document.fm.elements["bQty[]"];
  if (bv)
  { for (i=0; i<bv.length; i++) { bTotal += bv[i].value; } }
  var qt = document.fm.elements["pQty[]"];
if (opn) {
  var op1 = document.fm.elements["pOption[]"];
  var x = "var ops = [0, op1";
  if (opn>1)
  { for (i=2; i<=opn; i++)
    { var z = "var op" + i + " = document.fm.elements['pOption" + i + "[]']"; eval(z); }
    for (i=2; i<=opn; i++)
    { x += ",op" + i; } }
  x += "]"; eval(x);
}
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (opn) { for (c=1; c<=opn; c++)
	{ if (ops[c][i].value == "no selection")
	  { x = popAlert("Please select " + earr[c-1] + "."); 
	    qt[i].focus(); qt[i].select(); return false; } } }
    } }
if (l>0)
{ var qt = document.fm.elements["pQty5[]"];
  var op1 = document.fm.elements["pOption5[]"];
  var x = "var ops = [0, op1";
  if (opn>1)
  { for (i=2; i<=opn; i++)
    { var z = "var op" + i + " = document.fm.elements['pOption" + (i+4) + "[]']"; eval(z); }
    for (i=2; i<=opn; i++)
    { x += ",op" + i; } }
  x += "]"; eval(x);
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	for (c=1; c<=opn; c++)
	{ if (ops[c][i].value == "no selection")
	  { x = popAlert("Please select " + earr[c-1+opn] + "."); 
	    qt[i].focus(); qt[i].select(); return false; } }
    } }
}
  if ((pTotal + bTotal) == 0)
  { return popAlert("You must input a quantity for something."); }
  return true; }

function doAnother(opn, l)
{ if (l>0)
  { var op1 = document.fm.elements["pOption5[]"];
    var qt = document.fm.elements["pQty5[]"];
    var ax = 4; var am = opn; }
  else
  { var op1 = document.fm.elements["pOption[]"];
    var qt = document.fm.elements["pQty[]"];
    var ax = 0; var am = 0; }
  lg = qt.length - 1;
  var s = "";
  var x = "var ops = [0, op1";
  if (opn>1)
  { for (i=2; i<=opn; i++)
    { var z = "var op" + i + " = document.fm.elements['pOption" + (i+ax) + "[]']"; eval(z); }
    for (i=2; i<=opn; i++)
    { x += ",op" + i; } }
  x += "]"; eval(x);

  for (c=opn; c>0; c--)
  { if (ops[c][lg].value == "no selection") { s = "Please select " + earr[c-1+am] + "."; } }
  if (s.length<2 && qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}

  if (s.length>2) {x = popAlert(s);}
  else
  { var newdiv = document.createElement("div");
    if (l>0)
    { newdiv.innerHTML = document.getElementById("fline2").innerHTML;
	var container = document.getElementById("flines2");
	++fc5; var fcc = fc5; var ax = 4; }
    else
    { newdiv.innerHTML = document.getElementById("fline").innerHTML;
	var container = document.getElementById("flines");
	++fc; var fcc = fc; var ax = 0; }
    container.appendChild(newdiv);
    ns = "|" + fcc;
    for (i=1; i<=opn; i++)
    { if (i==1) { if (l>0) {s = "pOption5[]";} else {s = "pOption[]";} }
	else {s = "pOption" + (i+ax) + "[]";}
	var x = "var op = document.fm.elements[\"" + s + "\"][" + fcc + "]"; eval(x);
	for (c=1; c < op.length; c++) { op.options[c].value += ns; } }
  }
  return false; }

function verifyThese(opn)
{ var bTotal = 0;
  var bv = document.fm.elements["bQty[]"];
  if (bv)
  { for (i=0; i<bv.length; i++) { bTotal += bv[i].value; } }
  var qt = document.fm.elements["pQty[]"];
  var op1 = document.fm.elements["pOption[]"];
  for (i=2; i<=opn; i++)
  { var x = "var op" + i + " = document.fm.elements['pOption" + i + "[]']";
    eval(x); }
  var x = "var ops = [0, op1";
  for (i=2; i<=opn; i++)
  { x += ",op" + i; }
  x += "]"; eval(x);
  var pTotal = 0;
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	for (c=1; c<=opn; c++)
	{ if (ops[c][i].value == "no selection")
	  { x = popAlert("Please select " + earr[c-1] + "."); 
	    qt[i].focus(); qt[i].select(); return false; } }
    } }
  if ((pTotal + bTotal) == 0)
  { return popAlert("You must input a quantity for something."); }
  return true; }

function doLots(opn)
{ var op1 = document.fm.elements["pOption[]"];
  var qt = document.fm.elements["pQty[]"];
  lg = qt.length - 1;
  var s = "";

  for (i=2; i<=opn; i++)
  { var x = "var op" + i + " = document.fm.elements['pOption" + i + "[]']";
    eval(x); }
  var x = "var ops = [0, op1";
  for (i=2; i<=opn; i++)
  { x += ",op" + i; }
  x += "]"; eval(x);

  for (c=opn; c>0; c--)
  { if (ops[c][lg].value == "no selection") { s = "Please select " + earr[c-1] + "."; } }
  if (s.length<2 && qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}

  if (s.length>2) {x = popAlert(s);} else {x = doMore(opn+1);}
  return false; }

function verifyThis(sel, xel)
{ var bTotal = 0;
  var bv = document.fm.elements["bQty[]"];
  if (bv)
  { for (i=0; i<bv.length; i++) { bTotal += bv[i].value; } }
  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 == "no selection")
	{ x = popAlert("Please select " + xel + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
    } }
  if ((pTotal + bTotal) == 0)
  { return popAlert("You must input a quantity for something."); }
  return true; }
function doSome(sel, xel)
{ var op = document.fm.elements["pOption[]"];
  var ox = document.fm.elements["pOption2[]"];
  var qt = document.fm.elements["pQty[]"];
  lg = qt.length - 1;
  var s = "";
  if (op[lg].value == "no selection") {s="Please select " + sel + ".";}
  else if (ox[lg].value == "no selection") {s="Please select " + xel + ".";}
  else if (qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}
  if (s.length>2) {x = popAlert(s);} else {x = doMore(3);}
  return false; }
function verifyMe(sel)
{ var bTotal = 0;
  var bv = document.fm.elements["bQty[]"];
  if (bv)
  { for (i=0; i<bv.length; i++) { bTotal += bv[i].value; } }
  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 + bTotal) == 0) { return popAlert("You must input a quantity for something."); }
  return true; }
function doLess(sel)
{ var op = document.fm.elements["pOption[]"];
  var qt = document.fm.elements["pQty[]"];
  lg = qt.length - 1;
  var s = "";
  if (op[lg].value == "no selection") {s="Please select " + sel + ".";}
  else if (qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}
  if (s.length>2) {x = popAlert(s);} else {x = doMore(2);}
  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 reProduct(o)
{ i = o.selectedIndex - 1;
  f = getFline(o.value);
  if (i > -1)
  { document.fm.elements["pNum[]"][f].value = pNums[i];
    document.fm.elements["pName[]"][f].value = pNames[i];
    document.fm.elements["pPrice[]"][f].value = pPrices[i]; } }
function reGlowProduct(o)
{ n = o.selectedIndex + 1;
  if (n==o.length) {i=1;} else {i=0;}
  f = getFline(o.value);
  document.fm.elements["pNum[]"][f].value = pNums[i];
  document.fm.elements["pName[]"][f].value = pNames[i];
  document.fm.elements["pPrice[]"][f].value = pPrices[i]; }

function reGlowModel(o)
{ f = getFline(o.value);
  i = document.fm.elements["pOption[]"][f].selectedIndex;
  c = document.fm.elements["pOption2[]"][f].selectedIndex + 1;
  cl = document.fm.elements["pOption2[]"][f].length;
 if (i>0) { --i;
  if (c==cl)
  { document.fm.elements["pNum[]"][f].value = gNums[i];
    document.fm.elements["pName[]"][f].value = gNames[i];
    document.fm.elements["pPrice[]"][f].value = gPrices[i]; }
  else
  { document.fm.elements["pNum[]"][f].value = pNums[i];
    document.fm.elements["pName[]"][f].value = pNames[i];
    document.fm.elements["pPrice[]"][f].value = pPrices[i]; } } }
function reProductColor(o)
{ p = o.selectedIndex;
  f = getFline(o.value);
  if (p > 0)
  { i = p - 1;
    document.fm.elements["pNum[]"][f].value = pNums[i];
    document.fm.elements["pName[]"][f].value = pNames[i];
    document.fm.elements["pPrice[]"][f].value = pPrices[i]; }
  ns = "|" + f;
  var op = document.fm.elements["pOption2[]"][f];
  op.length = 1; var c = 0;
  var ac = colors[p];
  for (i=0; i < (ac.length); i++)
  { if (ac[i].indexOf(".") == -1)
    { c = op.length; op.length = (c+1);
	ncolor = ac[i];
	if (p > 0) {ncolor += ns;}
	var nOpt = new Option(ac[i]);
	op.options[c] = nOpt;
	op.options[c].value = ncolor; } }
  document.fm.elements["pOption2[]"][f].selectedIndex = 0; }

function light_d()
{ document.getElementById("descs").style.display = "block";
  document.getElementById("books").style.display = "none";
  document.getElementById("revws").style.display = "none";
  if(document.getElementById("vides")) {document.getElementById("vides").style.display = "none";}
  light_tabs(0); }
function light_b()
{ document.getElementById("descs").style.display = "none";
  document.getElementById("books").style.display = "block";
  document.getElementById("revws").style.display = "none";
  if(document.getElementById("vides")) {document.getElementById("vides").style.display = "none";}
  light_tabs(1); }
function light_r()
{ document.getElementById("descs").style.display = "none";
  document.getElementById("books").style.display = "none";
  document.getElementById("revws").style.display = "block";
  if(document.getElementById("vides")) {document.getElementById("vides").style.display = "none";}
  light_tabs(2); }
function light_v()
{ document.getElementById("descs").style.display = "none";
  document.getElementById("books").style.display = "none";
  document.getElementById("revws").style.display = "none";
  if(document.getElementById("vides")) {document.getElementById("vides").style.display = "block";}
  light_tabs(3); }

function light_tabs(i)
{ if (i==0 || tcurr==0)
  { if (i==0) {n="_on.gif')";} else {n="_off.gif')";}
    document.getElementById("dlnk").style.backgroundImage = "url('../images/1" + n; }
  if (i==1 || tcurr==1)
  { if (i==1) {n="_on.gif')";} else {n="_off.gif')";}
    document.getElementById("blnk").style.backgroundImage = "url('../images/2" + n; }
  if (i==2 || tcurr==2)
  { if (i==2) {n="_on.gif')";} else {n="_off.gif')";}
    document.getElementById("rlnk").style.backgroundImage = "url('../images/3" + n; }
  if (i==3 || tcurr==3)
  { if (i==3) {n="_on.gif')";} else {n="_off.gif')";}
    document.getElementById("vlnk").style.backgroundImage = "url('../images/4" + n; }
  tcurr = i; }

function clrSrch()
  { if (document.getElementById("srcher").value == "search")
    { document.getElementById("srcher").value = ""; } }

