﻿var url = location.href;
var title = window.document.title;
var rss = "http://" + window.location.hostname + "/Pages/pgRss.aspx";

function sendMail() {
    var sText = "mailto:?subject=" + title + "&body=" + title + " " + url;
    window.open(sText);
}

function shareGoogle() {
    var sText = "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=" + url + "&title=" + encodeURIComponent(title);
    window.open(sText);
}

function shareFacebook() {
    var sText = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + encodeURIComponent(title);
    window.open(sText);

}

function shareTwitter() {
//    var sTitle = encodeURIComponent(title)
//    var sTotal = sTitle + url;
//    if (sTotal.length > 139) {
//        sTitle = sTitle.substring(0, 139 - url.length);
//    }

    var sText = "http://twitter.com/intent/tweet?url=" + url + "&text=" + encodeURIComponent(title);
    window.open(sText);
}

function shareFriendFeed() {
    var e = document.createElement('script');
    e.setAttribute('type', 'text/javascript');
    e.setAttribute('src', 'http://friendfeed.com/share/bookmarklet/javascript');
    e.text = url;
    e.title = encodeURIComponent(title);
    document.body.appendChild(e);
    return false;
}

function shareDelicious() {
    var sText = "http://delicious.com/save?url=" + url + "&title=" + encodeURIComponent(title);
    window.open(sText);
}

function shareDigg() {
    var sText = "http://digg.com/submit/?phase=2&url=" + url + "&title=" + convertTurkishCharacter(title);
    window.open(sText);
}

function shareLinkedin() {
    var sText = "http://www.linkedin.com/shareArticle?mini=true&url=" + url + "&title=" + encodeURIComponent(title);
    window.open(sText);
}

function subscribeRss() {
    window.open(rss);
}

function convertTurkishCharacter(sInfo) {
    var turkishCharacters = new Array("ı", "ğ", "ş", "ç", "ü", "ö", "İ", "Ğ", "Ş", "Ç", "Ü", "Ö", "&");
    var englishCharacters = new Array("i", "g", "s", "c", "u", "o", "I", "G", "S", "C", "U", "O", "");
    // alert(sInfo);
    for (var i = 0; i < sInfo.length; i++) {
        for (var j = 0; j < turkishCharacters.length; j++) {
            if (sInfo.charAt(i) == turkishCharacters[j]) {
                sInfo = sInfo.replace(sInfo.charAt(i), englishCharacters[j]);
            }
        }
    }
    return sInfo;
}

function replaceSpace(sInfo) {
    for (var i = 0; i < sInfo.length; i++) {
        if (sInfo.charAt(i) == " ")
            sInfo = sInfo.replace(sInfo.charAt(i), "+");
    }
    return sInfo;
}

