function $(e) {
	return (typeof e == 'string') ? document.getElementById(e) : e;
}

/*****************************************************
 * Social Bookmak Bar
 * 16x16 icons must be stored as '/images/socialize_MODE.gif'
 * 2007 Martin Wendt
 **/

// encoded URL (strip parameters)
//var thisUrl   = encodeURIComponent ( location.href.split('?') [0] );
var thisUrl   = encodeURIComponent ( location.href);
var thisTitle = encodeURIComponent (document.title);

var bmbDefaultHint = 'Bookmark this story'; 

var aUrl = new Array();
var MyURL= thisUrl;
thisTitle=replace(thisTitle,'Mister-Info.com','');
thisTitle=thisTitle.substring(7);
aUrl ['blinklist']  = { url:  'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=' + thisUrl + '&Title=' + thisTitle,
		                hint: 'Blink It' };
aUrl ['delicious']  = { url:  'http://del.icio.us/post?v=4&noui&jump=close' + '&url=' + MyURL + '&title=' + thisTitle,
		                hint: 'Save this Page to del.icio.us' };
aUrl ['digg']       = { url:  'http://digg.com/submit?phase=2&topic=software' + '&url=' + thisUrl + '&title=' + thisTitle,
		                hint: 'Digg This' };
aUrl ['furl']       = { url:  'http://www.furl.net/storeIt.jsp?u=' + thisUrl + '&t=' + thisTitle + ' ',
		                hint: 'Furl It' };  
aUrl ['google']     = { url:  'http://www.google.com/bookmarks/mark?op=add&bkmk=' + thisUrl + '&title=' + thisTitle + ' ',
		                hint: 'Bookmark at Google' };
aUrl ['misterwong'] = { url:  'http://www.mister-wong.de/index.php?action=addurl&amp;bm_url=' + thisUrl + '&bm_description=' + thisTitle,
		                hint: 'Zu Mister Wong hinzuf&uuml;gen' };
aUrl ['newsvine']   = { url:  'http://www.newsvine.com/_tools/seed&amp;save?u=' + thisUrl + '&h=' + thisTitle,
		                hint: 'Add to NewsVine' };
aUrl ['reddit']     = { url:  'http://reddit.com/submit?url=' + thisUrl + '&title=' + thisTitle,
		                hint: 'Add to reddit' };
aUrl ['slashdot']   = { url:  'http://slashdot.org/bookmark.pl?url=' + thisUrl + '&title=' + thisTitle,
		                hint: 'Slashdot It!' };
aUrl ['technorati'] = { url:  'http://technorati.com/faves?add=' + thisUrl,
		                hint: 'Add to Technorati' };
aUrl ['yahoo']      = { url:  'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + thisUrl + '&t=' + thisTitle,
		                hint: 'Add to Yahoo My Web' };
aUrl ['spurl']      = { url:  'http://www.spurl.net/spurl.php?title=' + thisTitle + '&url=' + thisUrl,
		                hint: 'Add to Spurl' };

function replace(string,text,by) {
// Replaces text with by in string
   var strLength = string.length, txtLength = text.length;
   if ((strLength == 0) || (txtLength == 0)) return string;

  var i = string.indexOf(text);
  if ((!i) && (text != string.substring(0,txtLength))) return string;
  if (i == -1) return string;

      var newstr = string.substring(0,i) + by;

   if (i+txtLength < strLength)
           newstr += replace(string.substring(i+txtLength,strLength),text,by);

        return newstr;
	}

function writeBookmarkHtml (mode) {
	document.write ('<a href=' + aUrl[mode].url 
	+ ' title="' + aUrl[mode].hint + '"'
	+ ' onMouseOver="$(\'idBmbHint\').innerHTML=this.title"'
	+ ' onMouseOut="$(\'idBmbHint\').innerHTML=bmbDefaultHint"'
//	+ ' target="_blank">'
	+ '<img src="/images/socialize_' + mode + '.gif" width="16" height="16" border="0">'
	+ '</a>');
}
function insertSocialBookmarkBar() {
	document.write('<div class="socialBookmarkBar">');
	document.write('<span id="idBmbHint">' + bmbDefaultHint + '</span>');
	document.write('<span class="bmbLinks">');
/* this works, but we loose control about the icon order: 
	for (var u in aUrl) {
		writeBookmarkHtml (u);
	}
*/	
	writeBookmarkHtml ('delicious');
	writeBookmarkHtml ('digg');
	writeBookmarkHtml ('furl');
	writeBookmarkHtml ('google');
	writeBookmarkHtml ('misterwong');
	writeBookmarkHtml ('newsvine');
	writeBookmarkHtml ('reddit');
	writeBookmarkHtml ('slashdot');
	writeBookmarkHtml ('technorati');
	writeBookmarkHtml ('yahoo');
	writeBookmarkHtml ('blinklist');
	writeBookmarkHtml ('spurl');

	document.write('</span>');
	document.write('</div>');
}
