/******* Social Bookmarking functions ******/
/**
* toggles SocialBookmark-Box on and off
* @param spDisplay - ture=on, false=off
*/
function spSocialBookmarkSetDisplay(spDisplay) {
spSocialBookmarkElement = document.getElementById("spSocialBookmark").style;
spSocialBookmarkElement.visibility = (spDisplay ? "visible" : "hidden");
spSocialBookmarkState=spDisplay;
}
/**
* toggle function called form Bookmark Link
* served spSocialBookmarkSetDisplay() and starts EventHandler
*/
function spSocialBookmarkToggle() {
if (!spSocialBookmarkState) {
spSocialBookmarkSetDisplay(true);
spStartMouseEvent();
}
else 
spSocialBookmarkSetDisplay(false);
}
/**
* Event handler function tests where the user clicked
* and acts	according to this (switch SocialBookmark-Box off 
* stops EventHandler)
*/
function spSocialBookmarkToggleDisplay(e) {
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
if (targ.id == "spSocialBookmarkLink") {
spStopMouseEvent();
return false;
}
var isInDiv = false;
while(targ != null) {
if (targ.id == "spSocialBookmark") {
isInDiv=true;
break;
}
if (targ.id == "spSocialBookmarkClose")
break;
targ = targ.parentNode;
}
if (!isInDiv) {
spSocialBookmarkSetDisplay(false);
spStopMouseEvent();
}
return false;
}

/**
* starts EventHandling
*/
function spStartMouseEvent(){
if (document.addEventListener) { // DOM Level 2 Event Model
document.addEventListener("mouseup", spSocialBookmarkToggleDisplay, true);
}
else if (document.attachEvent) { // IE 5+ Event Model
document.attachEvent("onmouseup", spSocialBookmarkToggleDisplay);
}
else { // IE 4 Event Model
document.onmouseup=spSocialBookmarkToggleDisplay;
}
}
/**
* stops EventHandling
* spOldHandler is a hack for EI4 Event Model
*/
var spOldHandler = document.onmouseup;	// Eventhandler for EI 4 StopEvent
function spStopMouseEvent() {
// Unregister the capturing event handlers.
if (document.removeEventListener) { // DOM Event Model
document.removeEventListener("mouseup", spSocialBookmarkToggleDisplay, true);
}
else if (document.detachEvent) { // IE 5+ Event Model
document.detachEvent("onmouseup", spSocialBookmarkToggleDisplay);
}
else { // IE 4 Event Model
document.onmouseup = spOldHandler;
}
}

if (document.layers) document.captureEvents(Event.MOUSEUP);
var spSocialBookmarkState=false; // State of SocialBookmark Box



var theBookmark = escape(document.location.href + document.getElementsByTagName("title")[0].text);
var theBookmarkAlltagz = 'http://www.alltagz.de/bookmarks/?action=add&address=' + document.location.href + '&title=' + document.getElementsByTagName("title")[0].text;
var theBookmarkYahoo = 'http://myweb.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.getElementsByTagName("title")[0].text)+'&u='+encodeURIComponent(window.location.href)+'&ei=UTF-8';
var theBookmarkMisterwong = 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' + theBookmark;
var theBookmarkDelicious = 'http://del.icio.us/post?url=' + theBookmark;
var theBookmarkLinkarena = 'http://linkarena.com/bookmarks/addlink/?url='+ document.location.href +'&title=' + document.getElementsByTagName("title")[0].text +'&desc=&tags=';
var theBookmarkGoogle = 'http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk=' + document.location.href + '&title=' + document.getElementsByTagName("title")[0].text;
