function onLoad(f) {
  var old = window.onload;
  if (typeof(old) != 'function') {
    window.onload = f;
  } else {
    window.onload = function() {
      if (old && typeof(old) == 'function') {
        tryCalling(old);
      }
      tryCalling(f);
    }
  }
}

function tryCalling(f) {
  try {
    f();
  } catch(x) {
    trace("exception: ", x, " while calling: ", f);
    trace(printStackTrace({e: x}));
  }
}

function trim(s){
  return(s||"").replace(/^\s+|\s+$/g,"")
}

function trace() {
  try {
    console.log.apply(console, arguments);
  } catch (ignore) {
    try {
      if (!isEmpty(arguments)) {
        alert(arguments.join(" "));
      }
    } catch (ignore) {
    }
  }
}

function showFBiLike() {
  if ($('#iLike').length > 0) {
    $('#iLike').attr('allowTransparency', 'true');
    $('#iLike').attr('scrolling', 'no');
    $('#iLike').attr('frameborder', '0');
    $('#iLike').attr('height', '80');
    $('#iLike').attr('width', '300');
    $('#iLike').css({border: "none", overflow: "visible", width: "300px", height: "72px"});
    $('#iLike').attr('src',
        'http://www.facebook.com/plugins/like.php?' +
        'href=http%3A%2F%2Fwww.zipeg.com&amp;' +
        'layout=standard&amp;' +
        'show_faces=true&amp;width=300&amp;action=like&amp;font&amp;colorscheme=light&amp;' +
        'height=80');
  }
}

function plusone_vote( obj ) {
    _gaq.push(['_trackEvent','plusone',obj.state]);
}

