var currentURL = location.href;
var anchorPosition = currentURL.indexOf('#');
if (anchorPosition == -1) {
    var encodedCurrentURL = encodeURIComponent(currentURL);
} else {
    var encodedCurrentURL = encodeURIComponent(currentURL.substring(0, anchorPosition));
}

var hostName = encodeURIComponent(location.hostname);
// value is being get from META tag
var sharedTitle = encodeURIComponent($("meta[name='title']").attr("content"));
// value is being get from META tag
var sharedDescription = encodeURIComponent($("meta[name='description']").attr("content"));

/*
 Google Bookmarks: Add bookmark to google profile
 Title
 = Rejta.se
 Link
 = link to toplist which user comes from
 */
function gs_click(anchor) {
    var link = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + encodedCurrentURL + encodeURIComponent(anchor)
            + '&title=' + sharedTitle;
    window.open(link, 'googlesharer');
    return false;
}

/*
 Facebook: Message on the wall of the profile page with:
 Title
 = (value it's getting from meta tag "title") Rejta.se
 Image, user has possibility to choose picture from Page
 = <img> with attribute "src" linked to .jpg or .gif file
 Link to site,
 = link to toplist which user comes from
 Some invitation description
 = (value it's getting from meta tag "description") Sveriges st&ouml;rsta sajt f&ouml;r omd&ouml;men

 */
function fbs_click(anchor) {
    var link = 'http://www.facebook.com/sharer.php?u=' + encodedCurrentURL + encodeURIComponent(anchor)
            + '&t=' + sharedTitle;

    window.open(link, 'facebooksharer');
    return false;
}
/*
 Digg: Submit activity in some category
 Title
 = Rejta.se
 Image
 = Non
 Link to site
 = link to toplist which user comes from
 Some description
 = (value it's getting from meta tag "description") Sveriges st&ouml;rsta sajt f&ouml;r omd&ouml;men

 */
function ds_click(anchor) {
    var link = 'http://digg.com/submit?url=' + encodedCurrentURL + encodeURIComponent(anchor)
            + '&title=' + sharedTitle
            + '&bodytext=' + sharedDescription
            + '&media=news&topic=people&thumbnails=0';

    window.open(link, 'diggsharer');
    return false;
}

/*
 LinkedIn: Share article with friends
 Title
 = Rejta.se
 Some description
 = (value it's getting from meta tag "description") Sveriges st&ouml;rsta sajt f&ouml;r omd&ouml;men
 */
function lis_click(anchor) {
    var link = 'http://www.linkedin.com/shareArticle?mini=true&url=' + encodedCurrentURL + encodeURIComponent(anchor)
            + "&title=" + sharedTitle
            + '&summary=' + sharedDescription
            + '&source=' + hostName;
    window.open(link, 'linkedinsharer');
    return false;
}

/*
 Twitter :Some text about what user doing
 Link
 = link to toplist which user comes from
 Some description
 = (value it's getting from meta tag "description") Sveriges st&ouml;rsta sajt f&ouml;r omd&ouml;men
 */
function ts_click(anchor) {
    var link = 'http://twitter.com/home?status=' + encodedCurrentURL + encodeURIComponent(anchor)
            + " - " + sharedDescription;
    window.open(link, 'twittersharer');
    return false;
}
