function bookmark(was) {
  var redir='';
  switch(was) {
    case 'delicious':
	var loc=location.href;
	var apos=loc.indexOf('#');
	loc=(apos>0?loc.substring(0,apos):loc);
	window.open('http://del.icio.us/post?v=2&amp;url='+encodeURIComponent(loc)+'&amp;title='+encodeURIComponent(document.title));
	break;
    case 'wong':
	location.href="http://www.mister-wong.de/index.php?action=addurl&bm_url="+encodeURIComponent(location.href)+"&bm_description="+encodeURIComponent(document.title)+"";
	break;
    case 'yigg':
	window.open('http://yigg.de/neu?exturl='+encodeURIComponent(location.href));
	break;
    case 'linkarena':
      	//window.open(redir+encodeURIComponent('http://linkarena.com/bookmarks/addlink/?url=')+sburl+encodeURIComponent('&title=')+sbtitle+encodeURIComponent('&desc=&tags='));
	window.open('http://linkarena.com/bookmarks/addlink/?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&desc=&tags=');
	break;
    case 'oneview':
	window.open('http://beta.oneview.de:80/quickadd/neu/addBookmark.jsf?URL='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title) );
	break;
    case 'webnews':
	window.open('http://www.webnews.de/einstellen?url='+encodeURIComponent(document.location)+'&title='+encodeURIComponent(document.title));
	break;
  }
}

function shareContent(service, self_kat, artikelid, redaktionid, title)
{
	var longurl = encodeURIComponent("http://"+window.location.host+self_kat+"&artikel="+artikelid+"&red="+redaktionid);
	shareFinal(service, longurl, title);
}

function shareEvent(service, self_kat, kid, datum, title)
{
	var longurl = encodeURIComponent("http://"+window.location.host+self_kat+"&kid="+kid+"&datum="+datum);
	shareFinal(service, longurl, title);
}


function shareFinal(service, longurl, title)
{
    $.ajax({
	    type: "POST",
	    url: "http://"+window.location.host+"/ajax/get.tinyurl.php",
	    data: "longurl="+longurl,
	    success: function(data){
            if(data != ""){
                var shareurl = encodeURIComponent(data);
                
                if (service == "twitter")
                {
                    var status = shareurl+" - "+encodeURIComponent(title);
                    if (status.length > 140)
                    {
                        status = shareurl+" - "+encodeURIComponent(title.slice(0, 108))+"...";
                    }
                    var serviceurl = "http://twitter.com/home?status="+status;   
                    var newsize = "width=775,height=520";
                }
                else if (service == "facebook")
                {
                    var serviceurl = "http://www.facebook.com/sharer.php?u="+shareurl+"&t="+encodeURIComponent(title);
                    var newsize = "width=775,height=490";
                }
                else if(service == "vz")
                {
                    var serviceurl = "http://www.studivz.net/Suggest/Selection/?u="+shareurl+"&desc="+encodeURIComponent(title)+"&prov=sbh-life";
                    var newsize = "width=800,height=550";
                }
                else if (service == "myspace")
                {
                    var serviceurl = "http://de.myspace.com/index.cfm?fuseaction=postto&u="+shareurl+"&t="+title;
                    var newsize = "width=775,height=490";
                }
                else if (service == "delicious")
                {
                    var serviceurl = "http://del.icio.us/post?url="+shareurl+"&title="+encodeURIComponent(title);
                    var newsize = "width=775,height=490";
                }
                else if (service == "misterwong")
                {
                    var serviceurl = "http://www.mister-wong.de/index.php?action=addurl&bm_url="+shareurl+"&bm_description="+title;
                    var newsize = "width=775,height=550";
                }
                else if (service == "linkedin")
                {
                    var serviceurl = "http://www.linkedin.com/shareArticle?mini=true&url="+shareurl+"&title="+title+"&source=gaeubote.de";
                    var newsize = "width=775,height=500";
                }
                else if (service == "google-bm")
                {
                    var serviceurl = "http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk="+shareurl+"&title="+encodeURIComponent(title);
                    var newsize = "width=775,height=520";
                }	
                else if (service == "googlewave")
                {
                    var serviceurl = "https://wave.google.com/wave/wavethis?u="+shareurl+"&t="+title+"&c="+desc;
                    var newsize = "width=890,height=600";
                }
                
                if (serviceurl != "" && serviceurl != "undefined")
                {
                    window.open(serviceurl, "Teilen", newsize);
                }
            }
	    }
	})
}
