﻿
//// general helper functions
//function getElementFromID(id) {
//  var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
//  if (el) el.css = (el.style)? el.style: el;
//  return el;
//}

function sb_launch(X, title) {
  if (X.id) {
    var url = window.location.href;
    var type = X.id;
    if ('sb_email' == type) {return sb_launch_email(title, url)}
    else if ('sb_print' == type) {return sb_launch_print(title, url)}
    else if ('sb_delicious' == type) {return sb_launch_delicious(title, url)}
    else if ('sb_digg' == type) {return sb_launch_digg(title, url)}
    else if ('sb_facebook' == type) {return sb_launch_facebook(title, url)}
    else if ('sb_reddit' == type) {return sb_launch_reddit(title, url)}
    else return false;
  }
  else return false;
}
function sb_launch_delicious(t, u) {
  window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t),'delicious','toolbar=no,width=626,height=436,scrollbar=auto');
  return true;
}
function sb_launch_digg(t, u) {
  var d = '';
  window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t)+'&bodytext='+encodeURIComponent(d)+'&topic=world_news','digg','toolbar=no,width=626,height=436,scrollbar=auto');
  return true;
}
function sb_launch_reddit(t, u) {
  window.open('http://reddit.com/submit?url='+u+'&title='+t,'reddit','toolbar=0,status=0,width=626,height=436,scrollbar=auto');
  return true;
}
function sb_launch_facebook(t, u) {
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436,scrollbars=1');
  return true;
}

function sb_launch_print(t, u) {
  if (u.indexOf('?') > -1) {
    window.open(''+u+'&print=yes','print','toolbar=1,status=0,width=740,height=436,scrollbars=1,menubar=1');
  }
  else
  {
    window.open(''+u+'?print=yes','print','toolbar=1,status=0,width=740,height=436,scrollbars=1,menubar=1');
  }
  return true;
}
function sb_launch_email(t, u) {
  window.open('/emailafriend.asp?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'email','toolbar=0,status=0,width=626,height=436,scrollbars=1');
  return true;
}