var log = function (str) {
  try {
    console.log(str);
  }
  catch (e) {
    // pass
  }
};
String.prototype.startsWith = function (str) {
  return (this.match('^' + str) == str);
};
String.prototype.endsWith = function (str) {
  return (this.match(str + '$') == str);
};
String.prototype.trim = function () {
  return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};
if (!Array.prototype.indexOf) {
  Array.prototype.indexOf = function (obj, fromIndex) {
    if (fromIndex == null) {
        fromIndex = 0;
    } else if (fromIndex < 0) {
        fromIndex = Math.max(0, this.length + fromIndex);
    }
    for (var i = fromIndex, j = this.length; i < j; i++) {
        if (this[i] === obj)
            return i;
    }
    return -1;
  };
}

ZeroClipboard.setMoviePath('/storage/swf/ZeroClipboard.swf');

(function ($) {
    
    var clip = new ZeroClipboard.Client();
    
    $(document).ready(
      function () {
        
        // hook up the share this link
        var stlink = document.getElementById('share-this-link');
        var stentry = SHARETHIS.addEntry({}, {button:false});
        stentry.attachButton(stlink)
          
        // make the copy this URL icon work
        clip.setText(window.location.href);
        /*
        clip.glue('copythis');
        clip.addEventListener(
          'complete', 
          function (client, text) {
            // alert("Copied text to clipboard: " + text );
            $('#copythis').css({'background': 'yellow'});
            window.setTimeout(
              "$('#copythis').css({'background': 'white'});", 
              500
            );
          }
        );
        */
        
        /*
        // render the tweets
        jQuery("#user-recent-feeds").tweet({
            'username': ["insidecop15"],
            'count': 5,
            'avatar_size': 48,
            'loading_text': ['Loading tweets ...'],
            'query': ['%23incop']
          }
        );
        jQuery('#user-recent-feeds li').eq(0).css({
            'border-top': 'none',
            'padding-top': '0em'
        });
        */
        
      }
    );
    
    $(window).bind(
      'resize', 
      function () {
        clip.reposition();
      }
    );
    
  
})(jQuery);