

// image swapping
function mOver (obj) { document.getElementById(obj).src = '/img/m/on/' + obj + '.gif'; }
function mOut (obj) { document.getElementById(obj).src = '/img/m/off/' + obj + '.gif'; }


// simple browser sniffer - h/t k10k
var isW3C = (document.getElementById) ? true : false;
var isAll = (document.all) ? true : false;


// no focused links
function unblur () { this.blur (); }
function getLinksToBlur () {
  if ((isW3C) || (isAll)) {
    if (isW3C) {
      var links = document.getElementsByTagName("a");
    } else {
      var links = document.all.tags("a");
    }
    for (i = 0; i < links.length; i++) {
      links[i].onfocus = unblur;
    }
  }
}


window.addEventListener ? window.addEventListener("load",getLinksToBlur,false) : window.attachEvent("onload",getLinksToBlur);

function newsletterPop () {
  window.open('/newsletter.html','newsletter','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=500');
}

function updateStock (stockType, stockPrice, stockWeight) {
  $('#stock-price').html(stockPrice);
  $('#option-price').val(stockPrice);
  $('#option-weight').val(stockWeight);
  if (stockType == 'In Stock' || stockType == 'Pre-Order Now') {
    $('#stock-type').html('<span style="color: #090">' + stockType + '</span>');
    $('#buy-button').html('<input type="image" src="/img/add-to-cart.png" class="add-to-cart" name="action" value="Add to Cart" />');
  } else {
    $('#stock-type').html('<span style="color: #900">' + stockType + '</span>');
    $('#buy-button').html('<img src="/img/add-to-cart-disabled.png" style="padding: 2px" />');
  }
}

function setPopups () {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName('a');
  for (var i = 0; i < anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'popup') anchor.onclick = function() {
      this.popAtt = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=600';
      window.open (this.href, 'popup', this.popAtt);
      return false;
    }
  }
}
window.addEventListener ? window.addEventListener("load",setPopups,false) : window.attachEvent("onload",setPopups);
