/*
 *  about.js - Copyright (C) 2008, 2009, 2010 Wojciech Polak
 */

google.load ('feeds', '1');
google.setOnLoadCallback (function () {
  var feedControl = new google.feeds.FeedControl ();
  feedControl.addFeed ('http://groups.google.com/group/foaf-vix/feed/rss_v2_0_topics.xml',
		       'FOAF.Vix Google Group');
  feedControl.setNumEntries (7);
  feedControl.draw (document.getElementById ('feedControl'));
});

window.onload = function () {
  var frm = document.getElementById ('frm');
  var uri = document.getElementById ('uri');
  var nocache = document.getElementById ('nocache');
  var hl = document.getElementById ('hl');
  if (frm && uri) {
    frm.onsubmit = function () {
      var r = /^https?:\/\/.+/;
      var n = /^[^ ]+$/;
      var opts = '';
      if (nocache.checked)
	opts += '&nocache=1';
      if (hl.value != '')
	opts += '&hl=' + hl.value;
      var u = uri.value;
      if (u.indexOf ('&') != -1)
	u = encodeURIComponent (u);
      if (r.test (uri.value))
	document.location = frm.action + '?uri=' + u + opts;
      else if (n.test (uri.value))
	document.location = frm.action + '?uri=http://' + u + opts;
      return false;
    };
  }
  var anchors = document.getElementsByTagName ('a');
  for (var i = 0; i < anchors.length; i++) {
    if (!anchors[i].href.match ('addthis.com'))
      anchors[i].onclick = trko;
  }
};

function trko () {
  if (typeof tracker == 'undefined')
    return true;
  try {
    var href = this.href;
    if (href.match (/^http/) && !href.match (document.domain)) {
      tracker._trackPageview (href.replace (/^https?:\/\//i, '/outbound/'));
      setTimeout (function () { window.location = href; }, 150);
      return false;
    }
  } catch (e) {}
  return true;
}

