/*
  Social Bookmarking Script
  
  Version: 2.0.0
  
  Copyright (c) 2008,2009 by Christian Petersen (www.iscp.de) - All rights reserved
  
  This script is licensed under: Creative Commons Attribution-Share Alike 3.0 
  http://creativecommons.org/licenses/by-sa/3.0/
  
  This means, that you can use this script free of charge for commercial and noncommercial.
  We would like if you put an seo-friendly ("do follow") link to http://www.social-bookmarking-script.com on the site
  which uses this script.
  
  For the newest version of the Social Bookmarking Script visit: http://www.social-bookmarking-script.com
 
*/

/*  *********************************************************
    Functions for internal use
    ********************************************************* 
*/

function sbsintern_title(title,encoding) {
    /* 
      This function tests if a external title is given. If not the title of the document is used.
      It encodes the url if wanted:
      encoding:
        0: encodeURIComponent 
        1: no encoding
        3: escape
        
        
        Call: sbsintern_title(title,encoding)
        
     */ 
      
      var functiontitle = "";
      
      if (typeof title != "undefined") functiontitle = title;
      else functiontitle = document.title;
      
//      return functiontitle;
      switch(encoding){
       case 1: 
        return functiontitle;
        break;
       case 2: 
        return escape(functiontitle);
        break;
       default:
        return encodeURIComponent(functiontitle);
      }
      
}

function sbsintern_url(url,encoding) {
    /* 
      This function tests if a external url is given. If not the url of the document is used.
      It encodes the url if wanted:
      encoding:
        0: encodeURIComponent 
        1: no encoding
        3: escape
        
        
        Call: sbsintern_url(url,encoding)
     */ 
     
    var functionurl = "";
      
    if (typeof url != "undefined") {
      if (url != "") functionurl = url
      else functionurl = location.href;
    }
    else functionurl = location.href; 
    
    switch(encoding){
      case 1: 
        return functionurl;
        break;
      case 2: 
        return escape(functionurl);
        break;
      default:
        return encodeURIComponent(functionurl);
    }

}
  
/*  *********************************************************
    Functions for calling bookmarking-services
    ********************************************************* 
*/
  
function sbs_digg(url,title) { window.open('http://digg.com/submit?phase=2&url='+sbsintern_url(url,0)+'&bodytext=&tags=&title='+sbsintern_title(title,0)); return false; }
function sbs_reddit(url,title) { window.open('http://reddit.com/submit?url='+sbsintern_url(url,0)+'&title='+sbsintern_title(title,0)); return false; }
function sbs_stumbleupon(url,title) { window.open('http://www.stumbleupon.com/submit?url='+sbsintern_url(url,0)+'&title='+sbsintern_title(title,0)); return false; }