/* Social Network Shares
* Last updated: March 21th, 2010. This notice must stay intact for usage 
* Author: Mikael Grönlund at Grillguiden
* http://www.grillguiden.se/
*/

function GetUrl() {return location.href;}
function GetUrlEncoded() {return encodeURIComponent(GetUrl());}
function GetTitle() {return document.title;}
function GetTitleEncoded() {return encodeURIComponent(GetTitle());}
function GetSource() {return "Grillguiden";}
function GetSourceEncoded() {return encodeURIComponent(GetSource());}
function GetSummary() {return GetMetaContents("description");}
function GetSummaryEncoded() {return encodeURIComponent(GetSummary());}

function GetMetaContents(name) {
    var metas = document.getElementsByTagName('meta');
    for (var meta in metas) {
        if (metas[meta].name == name) {
            return metas[meta].content;
        }
    } 
}    

function ShareOnFacebook() {
  var share = document.getElementById('shareFacebook');
  share.href = "http://www.facebook.com/share.php?u=" + GetUrlEncoded();
}
function ShareOnLinkedIn() {
  var share = document.getElementById('shareLinkedIn');
  share.href = "http://www.linkedin.com/shareArticle?mini=true&url=" + GetUrlEncoded() + "&title=" + GetTitleEncoded() + "&summary=" + GetSummaryEncoded() + "&source=" + GetSourceEncoded();
}
function ShareOnTwitter() {
  var share = document.getElementById('shareTwitter');
  share.href = "http://twitter.com/home?status=" + GetUrlEncoded();
}
function ShareOnDelicious() {
  var share = document.getElementById('shareDelicious');
  share.href = "http://delicious.com/save?jump=close&url=" + GetUrlEncoded() + "&title=" + GetTitleEncoded();
}
function ShareOnMySpace() {
  var share = document.getElementById('shareMySpace');
  share.href = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + GetTitleEncoded()    + '&c=' + GetSummaryEncoded() + '&u=' + GetUrlEncoded() 
}
function ShareOnBloggy() {
  var share = document.getElementById('shareBloggy');
  share.href = "http://bloggy.se/home?status=&Auml;r p&aring; Grillguiden:" + GetTitleEncoded() + "&link=" + GetUrlEncoded();
}
function ShareOnPusha() {
  var share = document.getElementById('sharePusha');
  share.href = "http://www.pusha.se/posta?url=" + GetUrlEncoded() + "&title=" + GetTitleEncoded();
}
function ShareOnMail() {
  var share = document.getElementById('shareMail');
  share.href = "mailto:?subject=" + GetTitleEncoded() + "&body=" + GetUrlEncoded();
}
function InitiateShares() {
ShareOnFacebook();
ShareOnLinkedIn();
ShareOnTwitter();
ShareOnDelicious();
ShareOnMySpace();
ShareOnBloggy();
ShareOnPusha();
ShareOnMail();
}

