var shopper=false;
var mDI = window.setInterval("hidePrep()", 6000);
var fc = 1;
var cf = 1;
var fc5 = 1;
var cf5 = 1;
var tcurr = 2;
var sw_curr=0;
var sw_godisp=true;
var sw_timer=false;
var swatcher=false;
var sw_optioner=1;
var sw_reswatch=false;

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 sw_setDisp(i,s)
{ if (swatcher)
  { window.clearTimeout(sw_timer);
    if (sw_reswatch!==false) {sw_unswatch();} }
  if (s) {sw_reswatch=i;}
  if (sw_curr!=i || swatcher)
  { sw_setImage(i);
    sw_godisp=true; }
  if (swatcher) {swatcher=false;} }

function sw_setImage(i)
{ if (sw_reswatch!==false)
  { var x = "swatch"+sw_reswatch;
    document.getElementById(x).src = "images/"+sw_reswatches[sw_reswatch]; }
  document.getElementById("swImage").src = "images/"+sw_images[i];
  document.getElementById("swLabel").value = sw_labels[i]; }

function sw_restoreDisp()
{ swatcher=true; sw_timer = window.setTimeout(sw_restoreImage, 100); }

function sw_restoreImage()
{ swatcher=false;
  if (sw_reswatch!==false) {sw_unswatch();}
  if (sw_godisp)
  { document.getElementById("swImage").src = "images/"+sw_images[sw_curr];
    document.getElementById("swLabel").value = sw_labels[sw_curr]; } }

function sw_unswatch()
{ var x = "swatch"+sw_reswatch;
  document.getElementById(x).src = "images/"+sw_swatches[sw_reswatch];
  sw_reswatch=false; }

function sw_setBorders(i)
{ var x = "swatch"+sw_curr;
  document.getElementById(x).style.borderColor = "#ccc";
  document.getElementById(x).style.borderWidth = "1px";
  sw_curr=i; x = "swatch"+sw_curr;
  document.getElementById(x).style.borderColor = "#f22";
  document.getElementById(x).style.borderWidth = "2px"; }

function sw_reOption(i,p)
{ if (sw_curr!=i)
  { sw_godisp=false;
    sw_setBorders(i);
    var x="pOption"+sw_optioner+"[]";
    document.fm.elements[x][cf].selectedIndex = i;
    if (p)
    { document.fm.elements["pNum[]"][cf].value = pNums[i];
	document.fm.elements["pName[]"][cf].value = pNames[i];
	document.fm.elements["pPrice[]"][cf].value = pPrices[i]; }
 } }

function sw_doCf(i)
{ if (i != cf)
  { cf=i; document.fm.elements["pSel"][cf].checked = true;
    var x="pOption"+sw_optioner+"[]";
    i=document.fm.elements[x][i].selectedIndex;
    sw_setBorders(i); sw_setImage(i); } }

function sw_setCf(s)
{ var i = getFline(s); sw_doCf(i); }
function sw_setModel(o)
{ sw_setCf(o.value);
  rePrice(o.selectedIndex - 1); }
function sw_setOption(o,p)
{ sw_setCf(o.value);
  var i=o.selectedIndex; sw_setBorders(i); sw_setImage(i);
    if (p)
    { document.fm.elements["pNum[]"][cf].value = pNums[i];
	document.fm.elements["pName[]"][cf].value = pNames[i];
	document.fm.elements["pPrice[]"][cf].value = pPrices[i]; }
 }
function rePrice(i)
{ if (i > -1)
  { document.fm.elements["pNum[]"][cf].value = pNums[i];
    document.fm.elements["pName[]"][cf].value = pNames[i];
    document.fm.elements["pPrice[]"][cf].value = pPrices[i]; } }
function getFline(s)
{ a = s.split("|"); if (a[1]) {return a[1];} else {return 1;} }



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 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 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 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 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 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[]"];

  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (opn) { for (c=1; c<=opn; c++)
	{ var z="pOption"+c+"[]";
	  if (document.fm.elements[z][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[]"];
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (opn) { for (c=1; c<=opn; c++)
	{ var z="pOption"+(c+4)+"[]";
	  if (document.fm.elements[z][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 qt = document.fm.elements["pQty5[]"];
    var lb = 5; var ub = opn+4; var fcc=fc5; }
  else
  { var qt = document.fm.elements["pQty[]"];
    var lb = 1; var ub = opn; var fcc=fc; }
  var s = "";

  for (i=lb; i<=ub; i++)
  { var z="pOption"+i+"[]";
    if (document.fm.elements[z][fcc].value == "no selection") { s = "Please select " + earr[i-1] + "."; } }
  if (s.length<2 && qt[fcc].value == 0) {s="Please select quantity."; qt[fcc].focus(); qt[fcc].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 cf5 = fc5; var fcc=fc5; var ax = 4; }
    else
    { newdiv.innerHTML = document.getElementById("fline").innerHTML;
	var container = document.getElementById("flines");

	++fc; cf = fc; var fcc=fc; var ax = 0; }
    container.appendChild(newdiv);

    ns = "|" + fcc;

    if (document.fm.elements["pSel"][fcc])
    {document.fm.elements["pSel"][fcc].value = fcc;
     document.fm.elements["pSel"][fcc].checked = true;}

    for (i=lb; i<=ub; i++)
    { z = "pOption" + i + "[]";
	var op = document.fm.elements[z][fcc];
	for (c=1; c < op.length; c++) { op.options[c].value += ns; } }
  }
  return false; }

function sw_Another(opn)
{ var qt = document.fm.elements["pQty[]"];
  var lb = 1; var ub = opn; var fcc=fc;
  var s = "";

  if (s.length<2 && qt[fcc].value == 0) {s="Please select quantity."; qt[fcc].focus(); qt[fcc].select();}

  if (s.length>2) {x = popAlert(s);}
  else
  { var newdiv = document.createElement("div");
    newdiv.innerHTML = document.getElementById("fline").innerHTML;
    var container = document.getElementById("flines");
    ++fc; cf = fc; var fcc=fc; var ax = 0;
    container.appendChild(newdiv);
    ns = "|" + fcc;

    if (document.fm.elements["pSel"][fcc])
    {document.fm.elements["pSel"][fcc].value = fcc;
     document.fm.elements["pSel"][fcc].checked = true;}

    for (i=lb; i<=ub; i++)
    { z = "pOption" + i + "[]";
	var op = document.fm.elements[z][fcc];
	for (c=0; c < op.length; c++) { op.options[c].value += ns; }
    if (typeof pNums != "undefined")
    { document.fm.elements["pNum[]"][cf].value = pNums[0];
	document.fm.elements["pName[]"][cf].value = pNames[0];
	document.fm.elements["pPrice[]"][cf].value = pPrices[0]; }
    sw_setBorders(0); sw_setImage(0); }
}

  return false; }

function light_d()
{ document.getElementById("descs").style.display = "block";
  if (document.getElementById("books"))
  { 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";
  if (document.getElementById("books"))
  { 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";
  if (document.getElementById("books"))
  { 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 = ""; } }

