﻿/* Social Add It Button Script By ByteBlocks.com" */
ByteBlocks_SocialIt = function(elId, linkUrl, linkTitle) {
    this.el = document.getElementById(elId);
    this.linkUrl = linkUrl;
    this.linkTitle = linkTitle;
    if (linkUrl == 'undefined' || null == linkUrl || linkUrl.length == 0) {
        this.linkUrl = document.location.href;
    }

    if (linkTitle == 'undefined' || null == linkTitle || linkTitle.length == 0) {
        if (document.title == 'undefined' || document.title == null || document.title.length == 0) {
            this.linkTitle = 'Share Link';
        }
        else {
            this.linkTitle = document.title;
        }
    }

    // Instantiate a Panel from script
    var panelId = elId + "_ovrlay";
    if (ByteBlocks_SocialIt._displayPanel != null) {
        ByteBlocks_SocialIt._displayPanel.hide();
    }
    ByteBlocks_SocialIt._displayPanel = new YAHOO.widget.Panel(panelId, { context: [elId, "tl", "bl", ["beforeShow", "windowResize"]], visible: true, draggable: false, close: true });
    ByteBlocks_SocialIt._displayPanel.setHeader(linkTitle);
    ByteBlocks_SocialIt._displayPanel.setBody(this._createLinkTable(this.linkUrl, this.linkTitle));
    ByteBlocks_SocialIt._displayPanel.setFooter("<a href='http://www.ByteBlocks.com' title=''>ByteBlocks</a>");
    ByteBlocks_SocialIt._displayPanel.render(document.body);
};

ByteBlocks_SocialIt.prototype._createLinkTable = function(linkUrl, linkTitle) {
    var s = "<table class='socialLinkTable'>";
    s += this._createBlogRow(linkUrl, linkTitle);
    s += "</table>";
    return s;
};

ByteBlocks_SocialIt.prototype._createBlogRow = function(linkUrl, title) {
        var s = "<tr>";
        s += "<td><span>Bookmark:</span></td>";
        s += "<td><a target='_blank' title='del.icio.us' href='http://del.icio.us/post?url=" + linkUrl + "&title=" + title + "'><img src='http://www.byteblocks.com/pics/delicious.png' alt='del.icio.us' /></a><td>";
        s += "<td><a target='_blank' title='stumble upon' href='http://www.stumbleupon.com/submit?url=" + linkUrl + "&title=" + title + "'><img src='http://www.byteblocks.com/pics/stumbleupon.png' alt='stumbleupon' /></a><td>";
        s += "<td><a target='_blank' title='reddit upon' href='http://www.reddit.com/submit?url=" + linkUrl + "&title=" + title + "'><img src='http://www.byteblocks.com/pics/reddit.png' alt='reddit' /></a><td>";
        s += "<td><a target='_blank' title='reddit upon' href='http://www.diigo.com/post?url=" + linkUrl + "&title=" + title + "'><img src='http://www.byteblocks.com/pics/diigo.png' alt='diigo' /></a><td>";
        s += "<td><a target='_blank' title='reddit upon' href='http://www.digg.com/submit?url=" + linkUrl + "&title=" + title + "'><img src='http://www.byteblocks.com/pics/digg.png' alt='digg' /></a><td>";
        s += "</tr>";
        return s;
}

ByteBlocks_SocialIt._displayPanel = null;

function ByteBlocks_ShowSocialPanel(el, linkUrl, linkTitle) {
    mySocialPanel = new ByteBlocks_SocialIt(el, linkUrl, linkTitle);
}
