var trackClick = function(playlistId,id) {
	ajax('http://curationstation.com/widget/click/'+playlistId+'/'+id);
	return true;
}

var listen = function(elem, e, f) {
  if (elem.addEventListener) {
    elem.addEventListener(e,f,false);
  } else if (elem.attachEvent) {
    var r = elem.attachEvent("on"+e, f);
    return r;
  }
};

var walk_the_DOM = function walk(node, f) {
  f(node);

  node = node.firstChild;
  while (node) {
    walk(node, f);
    node = node.nextSibling;
  }
};

var getElementsByAttribute = function(att, value) {
  var results = [];

  walk_the_DOM(document.body, function(node) {
    var actual = node.nodeType === 1 && node.getAttribute(att);
    if (typeof actual === 'string' && (actual === value || typeof value !== 'string')) {
      results.push(node);
    }
  });

  return results;
};

var ajax = function(url) {
  var xmlhttp = (function() {
    if (window.XDomainRequest) {
      return new XDomainRequest();
    }
    else if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
      return null;
    }
  })();
  
  if  (xmlhttp) {
    xmlhttp.onreadstatechange = function() {};
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
  }   
}
