function showTip(json){
  if( !document.getElementById('tip-con') ) return;
  if(json.feed.entry.length < 0){ return; }
  var tips = [];
  for(var i=0,j=json.feed.entry.length;i<j;i++){
    var entry = json.feed.entry[i];
    var hash = {};
    hash.tip = entry.gsx$tip.$t.replace(/\n/g,'');
    tips.push(hash);
  }
  var ran = Math.floor(Math.random() * tips.length);
  document.getElementById('tip-con').innerHTML = tips[ran].tip;
}

function showWebinar(json){
  if( !document.getElementById('webinar-con') ) return;
  if( json.feed.entry.length < 0 ){return}
  var webinars = []
  for( var i=0,j=json.feed.entry.length;i<j;i++ ){
    var entry = json.feed.entry[i];
    var hash = {};
    hash.content = entry.gsx$content.$t.replace(/\n/g,'');
    hash.show = entry.gsx$show.$t == 'yes' ? true : false;
    webinars.push(hash);
  }
  var html = [];
  for(var i=0;i<webinars.length;i++){
    if( webinars[i].show ){
      if( webinars[i].content.indexOf('</p>') == -1 ){
        html.push('<p>' + webinars[i].content + '</p>');
      }else{
        html.push( webinars[i].content );
      }
    }
  }
  document.getElementById('webinar-con').innerHTML = html.join('');
}

var showtipScript = document.createElement('script');
showtipScript.src = 'http://spreadsheets.google.com/feeds/list/' +
                    'pUEVnX0dG9ZmW8BlHTH-6BA' +
                    '/od6/public/values?alt=json-in-script' +
                    '&callback=showTip';
showtipScript.type = 'text/javascript';
document.body.appendChild(showtipScript);

var webinarScript = document.createElement('script');
webinarScript.src = 'http://spreadsheets.google.com/feeds/list/' +
                    'pUEVnX0dG9ZmW8BlHTH-6BA' +
                    '/od7/public/values?alt=json-in-script' +
                    '&callback=showWebinar';
webinarScript.type = 'text/javascript';
document.body.appendChild(webinarScript);

