var socializeit = function() {

  var d = document,
      l = d.location,
      e = encodeURIComponent,
      u = e(l.href),
      t = e(d.title),
      imgroot = '/image-files/';

  var sites = [
    {name: 'Google',      img: imgroot+'google.png',      url: 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+ u +'&title=' +t,                  title: 'Share this page on Google.',     newwindow: true  },
    {name: 'Buzz',        img: imgroot+'yahoobuzz.png',   url: 'http://buzz.yahoo.com/submit?submitUrl='+ u +'&amp;t=' + t,                            title: 'Buzz this page.',                newwindow: true  },
    {name: 'Facebook',    img: imgroot+'facebook.png',    url: 'http://www.facebook.com/share.php?u='+ u +'&amp;t=' + t,                               title: 'Share this page on Facebook.',   newwindow: true  },
    {name: 'Myspace',     img: imgroot+'myspace.png',     url: 'http://www.myspace.com/Modules/PostTo/Pages/?u='+ u +'&amp;t=' + t,                    title: 'Share this page on Myspace.',    newwindow: true  },
    {name: 'StumbleUpon', img: imgroot+'stumbleupon.png', url: 'http://www.stumbleupon.com/submit?url=' + u + '&amp;title=' + t,                       title: 'StumbleUpon this page.',         newwindow: true  },
    {name: 'Technorati',  img: imgroot+'technorati.png',  url: 'http://technorati.com/faves/?add=' + u,                                                title: 'Share this page on Technorati.', newwindow: true  },
    {name: 'del.icio.us', img: imgroot+'delicious.png',   url: 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' + u + '&amp;title=' + t, title: 'Share this page on Del.ici.ous', newwindow: true  },
    {name: 'Twitter',     img: imgroot+'twitter.png',     url: 'http://twitter.com/home?status=Reading%20about%20this:%20'+t+'%20-%20' + u,            title: 'Tweet this page.',               newwindow: true  },
    {name: 'Digg',        img: imgroot+'digg.png',        url: 'http://digg.com/submit?phase=2&url=' + l,                                              title: 'Digg this page.',                newwindow: true  },
    {name: 'Help',        img: imgroot+'help.png',        url: '/socializeit-help.html',                                                               title: 'What do these icons mean?',      newwindow: false }
  ];

  arguments.callee.getURL = function(which) {
    for (var i=0, ilen=sites.length; i<ilen; i++) {
      var site = sites[i];
      if (site.name == which) {
        return site.url;
      }
    }
  };

  var html = '';

  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;
    var title = sites[i].title;
    var href;
		
		if (site == 'Help') {
		  href = '#What_Do_These_Icons_Mean?';
		}
		else {
		  href = '#share_on_'+site;
		}
		
    if (sites[i].newwindow == true) {		
      html += '<li><a href="'+href+'" onclick="window.open(socializeit.getURL(\''+site+'\'), \'sharer\', \'toolbar=0,status=0,width=800,height=600,resizable=yes,scrollbars=yes\');return false;"><img src="'+imgURL+'" title="'+title+'" alt="'+site+'"></a></li>';
		}
    else {
      html += '<li><a href="'+href+'" onclick="window.location = socializeit.getURL(\''+site+'\');return false;"><img src="'+imgURL+'" title="'+title+'" alt="'+site+'"></a></li>';
    }
  }
 
  document.writeln(html);
};

