var socializeit = function(options) {
  if (!options || !options.domain) {
    throw new Error('Error: must pass socializeit a domain (e.g. socializeit({domain:"www.example.com"})).')
  }

  var d = document,
      l = d.location,
      e = encodeURIComponent,
      u = e(l.href),
      t = e(d.title),
      domain = options.domain,
      urlroot = 'http://www.'+domain+'/objects/';

  var sites = [
    {name: 'Google', 
     img: urlroot+'google.gif',
     url: 'http://www.google.com/ig/adde?moduleurl=www.google.com/ig/modules/bookmarks.xml&hl=en/u='+ u +'&t=' + t},
    {name: 'Buzz',
     img: urlroot+'yahoobuzz1.gif',
     url: 'http://buzz.yahoo.com/submit?submitUrl='+ u +'&t=' + t},
    {name: 'Facebook',
     img: urlroot+'Facebook.jpg',
     url: 'http://www.facebook.com/share.php?u='+ u +'&t=' + t},
    {name: 'Myspace',
     img: urlroot+'myspace.gif',
     url: 'http://www.myspace.com/Modules/PostTo/Pages/?u='+ u +'&t=' + t},
    {name: 'StumbleUpon', 
     img: urlroot+'StumbleUpon.jpg',
     url: 'http://www.stumbleupon.com/submit?url=' + u + '&title=' + t},
    {name: 'Technorati',
     img: urlroot+'Technorati.jpg',
     url: 'http://technorati.com/faves/?add=' + u},
    {name: 'del.icio.us',
     img: urlroot+'del.jpg',
     url: 'http://del.icio.us/post?v=4&noui&jump=close&url=' + u + '&title=' + t},
    {name: 'Twitter',
     img: urlroot+'twitter.gif',
     url: 'http://twitter.com/home?status=Reading%20about%20this:%20'+t+'%20-%20' + u}
  ];

  var html = '<hr><table><tbody><tr><td rowspan="2" nowrap><strong>Share this page:&nbsp;</strong>';
  if (options.whatIsThisUrl) {
    html += '<br><span style="font-size:11px;"><a href="#" onclick="window.open\(\''+options.whatIsThisUrl+'\', \'sharer\',\'toolbar=0,status=0,width=700,height=500,resizable=yes,scrollbars=yes\'\); return false;">What\'s This?</a></span>';
  }
  html += '</td>';
  // visually want two rows of links
  var midpoint = Math.floor((sites.length-1)/2);
  for (var i=0, ilen=sites.length; i<ilen; i++) {
    var site = sites[i].name;
    var imgURL = sites[i].img;
    var url = sites[i].url;
    html += '<td><a href="#share_on_'+site+'" onclick="window.open(\''+url+'\', \'sharer\', \'toolbar=0,status=0,width=700,height=500,resizable=yes,scrollbars=yes\');return false;"><img src="'+imgURL+'" alt="'+site+'" style="border:0"></a></td>';
    if ((i == midpoint) && (i+1)<ilen) {
      html += '</tr><tr>';
    }
  }
  html += '</tr></tbody></table>';
  document.writeln(html);
};
