if (navigator.userAgent.match(/firefox|flock|gecko/i)) try {
  (function() {
var baseurl = "http://www.mashlogic.com";
var defhtml = null || '<img src="http://mashlogic.com/images/icon-mash-long-16.png" title="Subscribe to this Mash Feed" class="mashlogic" style="border-style: none"/>';
var scripts = document.getElementsByTagName("script");
if (scripts.length) {
  var script = scripts[scripts.length-1];
  var q = urlParse(script.src, { html: defhtml, more: null || "/brands/mashlogic/" });
  var url = (/:/.test(q.more) ? "" : baseurl) + q.more;
  document.write('<a class="mashlogic" href="'+ url +'">'+ q.html +'</a>');
}
if (!document.MashfeedsAugmented) {
  addEventListener("DOMContentLoaded", injectMashFeedLinkers, false);
  document.MashfeedsAugmented = true;
}

var w = 300;
var h = 202;

var noncapswords = /^(a|about|above|across|after|after|against|along|also|although|amid|among|an|and|around|as|at|because|before|behind|below|beneath|beside|besides|between|beyond|both|but|by|concerning|despite|down|during|each|either|except|for|from|if|in|including|inside|into|lest|like|minus|near|neither|nor|notwithstanding|of|off|on|onto|opposite|or|out|outside|over|past|per|plus|regarding|since|so|than|that|the|though|through|throughout|till|to|toward|towards|under|underneath|unless|unlike|until|up|upon|versus|via|when|whereas|whether|while|with|within|without|yet)$/;

function injectMashFeedLinkers() {
  var installed = false;
  setTimeout(waitForMashLogic, 100);
  function waitForMashLogic() {
    if ("object" == typeof mashlogic) {
      installed = true;
    }
    findScripts(/^http:..[^\/]*\bmashlogic.com\/mash-feeds\/subscribe\.js/i).
      forEach(replaceScript);
  }

  function capitalize(words) {
    function maybeCapitalize(word, pos) {
      if (word.length && !pos || !noncapswords.test(word))
        return word.charAt().toUpperCase() + word.slice(1);
      return word;
    }
    return words.split(/\s+/).map(maybeCapitalize).join(" ");
  }

  // create a link here instead:
  function replaceScript(script) {
    var args = urlParse(script.src);
    var a = document.createElement("a");
    var xpi = args.xpi || null || (args.more ? args.more+"&install=1":"mashlogic.xpi");
    var more = args.more || null || "/brands/mashlogic/";
    var mfname = urlParse(args.more || "-").mfname || "";
    var title = args.title || null ||
      (mfname ? capitalize(mfname) : "Mash Feeds from MashLogic");
    a.href = (/:/.test(more) ? "" : baseurl) + more;
    a.className = "mashlogic";
    a.innerHTML = args.html || defhtml;
    if (!installed) {
      var bound = partial(openMashLogicCallout, xpi, more, mfname, title);
      a.addEventListener("mouseover", bound, false);
    } else {
      if (mfname) a.title = mfname + " mash feed";
    }
    var parent = script.parentNode;
    var next = script.nextSibling;
    if (("mashlogic" == next.className) && next.href &&
	("a" == next.nodeName.toLowerCase()))
      script = next; // replace the added a instead
    parent.replaceChild(a, script);
  }
}

// partially applies func with parameters, returning a pre-param-bound function
function partial(func /*, param 1, param 2, ... */) {
  var params = Array.prototype.slice.call(arguments, 1);
  return function( /* param1, ..., param n,   param n+1, ... */ ) {
    return func.apply(self, params.concat([].slice.call(arguments)));
  };
}

var iframeNode;

function findScripts(re) {
  var feeds = [];
  var scripts = document.getElementsByTagName("script");
  for (var i = 0, script; script = scripts[i]; i++)
    if (re.test(script.src||""))
      feeds.push(script);
  return feeds;
}

function urlParse(url, defaults) {
  if (!url) url = location.search || location.hash || "";
  var keys = defaults || {};
  url.replace(/([^=&?#]+)=([^&]*)/g, function(m, key, value) {
    keys[decodeURIComponent(key)] = decodeURIComponent(value);
  });
  return keys;
}

function open(e, w, h, url) {
  var layout = getOrientation(e);

  // Move callout to correct location and display
  var cfs = iframeNode.style;
  cfs.left = Math.ceil(layout.x, 0) + "px";
  cfs.top  = Math.ceil(layout.y, 0) + "px";
  var old = (iframeNode.src || "")
	      .replace(/^http:..[^\/]+/, "")
	      .replace(/#.*/, "");
  if (old == url) {
    iframeNode.contentWindow.postMessage(layout.orientation, "*");
    postMessage("showCallout", "*");
  } else {
    iframeNode.src = url + layout.orientation;
  }
}

function calloutListener(e) {
  var display;
  switch (e.data) {
    case "hideCallout": iframeNode.style.display = "none"; break;
    case "showCallout": iframeNode.style.display = "block"; break;
    default: return;
  }
  e.stopPropagation();
  e.preventDefault();
}

function getOrientation(e) {
  var node = e.target;
  var x, y, xorient = "left", yorient = "top";

  var mx = e.mousePageX || e.pageX; // document coords (includes page[XY]Offset)
  var my = e.mousePageY || e.pageY; // (the two properties e.client[XY], do not)

  var box = (node && node.getBoundingClientRect) ?
              node.getBoundingClientRect() : null; // FF3+ (IE5+) feature
  var scrY = pageYOffset || 0;
  var minY = Math.floor(box ? box.top    : my);
  var maxY = Math.ceil((box ? box.bottom : my) - 2);

  // calculate content vertical dimensions/orientation based on available space:
  var ch, cw = w - 25; // border stuff
  if (h > minY) { // pointy thing on top; content below clicked item
    yorient = "top";
    y = scrY + maxY;
  } else {             // pointy thing below;  content above clicked item
    yorient = "bottom";
    y = scrY + minY - h;
  }

  // calculate horizontal location based on whereabouts of the clicked item
  if (e.clientX < w) {
    xorient = "left";
    x = mx - 48;
  } else {
    xorient = "right";
    x = mx - w + 48;
  }

  //console.warn("x:%x, y:%x px:%x py:%x, cw:%x, h:%x", x, y, px, py, cw, ch);
  return { x: x, y: y, xorient: xorient, yorient: yorient,
	   orientation: "#x="+ xorient +"&y="+ yorient };
}

function openMashLogicCallout(xpi, more, mfname, title, e) {
  var url = "/mash-feeds/callout?title="+ encodeURIComponent(title) +
    "&xpi="+ encodeURIComponent(xpi) +"&more="+ encodeURIComponent(more) +
    "&mfname="+ encodeURIComponent(mfname);
  if (!iframeNode) {
    var name = "mashlogic-install-bubble";
    iframeNode = document.createElement("iframe");
    var layout = getOrientation(e);
    var attrs = { src: baseurl + url + layout.orientation, name: name, id: name,
      style: "overflowY:hidden; overflowX:hidden; z-index:9999; border:0; " +
	"margin:0; padding:0; top:auto; right:auto; bottom:auto; left:auto; " +
	"display:none; position:absolute; width:"+ w +"px; height:"+ h +"px;"
    }; // top:0; left:0;
    for (var a in attrs)
      iframeNode.setAttribute(a, attrs[a]);
    document.body.appendChild(iframeNode);
    addEventListener("message", calloutListener, false);
  } else {
    iframeNode.style.display = "none";
  }
  open(e, w, h, url);
}

})(); } catch(e) {};
