var urlbase = ''
var mytitle = document.title
mytitle = unfancy(mytitle)
var mytitleencoded = encodeURIComponent(mytitle)
var myloc = location.href
var mylocencoded = encodeURIComponent(myloc)
var mydesc = getDesc();
mydesc = unfancy(mydesc)
mydescencoded = encodeURIComponent(mydesc)
var myimg = getImg();
myimgencoded = encodeURIComponent(myimg)
// share facebook
document.write('<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>')
// share twitter
document.write('<script type="text/javascript" src="http://ajax.twitthis.com/chuug.twitthis.scripts/twitthis.js"></script>')
mytxt = '<p class="share_a">'
mytxt = mytxt+'Share'
mytxt = mytxt+'&nbsp;<a name="fb_share" type="icon" href="http://www.facebook.com/sharer.php"></a>'
mytxt = mytxt+'<a href="javascript:;" onclick="TwitThis.pop();"><img src="'+urlbase+'menu/t_mini_a.png" alt="TwitThis" title="TwitThis" style="border:none;" /></a>'
// share email
mytxt = mytxt+'&nbsp;&nbsp;<a class="share_a" href="mailto:?subject=' + mytitleencoded;
mytxt = mytxt+'&body=I found this on the web and wanted to share it with you.%0A%0A'
mytxt = mytxt+ mydescencoded+"%0A%0A";
mytxt = mytxt+'You can view more details about '+mytitleencoded+' at ' + mylocencoded;
mytxt = mytxt+'"><img src="'+urlbase+'menu/envelope.jpg" border="0" alt="eMail to" title="eMail to" /></a>'
mytxt = mytxt+'<iframe src="http://www.facebook.com/plugins/like.php?href='+mylocencoded+'&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>'
mytxt = mytxt+'<br />'
//writetolayerplain('share_this',mytxt)
document.write(mytxt)

// go to url
function getDesc(){
  var metas = document.getElementsByTagName('meta');
  for(var i=0;i<metas.length;i++){
    if(metas[i].getAttribute('name').toLowerCase() == 'description'){
      return metas[i].getAttribute('content');
    }
  }
  return '';//or null if you prefer
}
function getImg(){
  var links = document.getElementsByTagName('link');
  for(var i=0;i<links.length;i++){
    if(links[i].getAttribute('rel').toLowerCase() == 'image_src'){
      return links[i].getAttribute('href');
    }
  }
  return '';//or null if you prefer
}

function unfancy(instr)
{
// replace mdash & ndash with hyphen
outstr = instr.replace(/—/g,'-')
outstr = outstr.replace(/–/g,'-')
// replace lsquo & rsquo with single quote
outstr = outstr.replace(/‘/g,"'")
outstr = outstr.replace(/’/g,"'")
// replace ldquo & rdquo with double quote
outstr = outstr.replace(/“/g,'"')
outstr = outstr.replace(/”/g,'"')
return outstr
}

