﻿function getTwitterText(lang) {
  var txt = document.title;
  var i = txt.indexOf(" on City");
  if (i > 0)
    txt = txt.substring(0,i);
  i = txt.indexOf("- Statistics");
  if (i > 0)
    txt = txt.substring(0,i+1) + " Population" + txt.substring(i+1);
  if (txt.length > 100)
    txt = txt.substring(0,100);
  txt += " -";
  //content = '<img id="twimg" src="images/twimg_'+lang+'.gif" />'
  //return '<a href="https://twitter.com/share?original_referer='+encodeURIComponent(window.location.href)+'&amp;source=tweetbutton&amp;text='+encodeURIComponent(txt)+'&amp;url='+encodeURIComponent(window.location.href)+'" class="twitter-share-button" data-count="horizontal" target="_blank">'+content+'</a>';
  return '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="//platform.twitter.com/widgets/tweet_button.html?text='+encodeURIComponent(txt)+'&lang='+lang+'" style="width:130px; height:20px;"></iframe>';
}

function async_call_tail (adr,tag,parentID) {
  function async_load(){
    var s = document.createElement('script');
    s.type = 'text/javascript'; s.async = true; s.src = adr; s.defer = true;
    if (tag != null) {
      var x = document.getElementsByTagName(tag)[0]; x.parentNode.insertBefore(s, x);
    }
    else {
      var x = document.getElementById(parentID); x.appendChild(s);
    }
  }
  if (window.attachEvent)
    window.attachEvent('onload', async_load);
  else
    window.addEventListener('load', async_load, false);
}

try {
  var tables = document.getElementsByTagName("table");
  if (tables && tables[1] && tables[1].getAttribute("class")=="sep") {
    var th = tables[1].firstChild.firstChild;
    if (language == 'D')
      if (vizMode == "")
        th.firstChild.innerHTML = '<span style="font-size:13px;height:18px;padding-left:33px;">In den nachfolgenden Tabellen kann für eine Kartenanzeige und weitere Infos auf das linke <img src="images/info_small.png" alt=""> Symbol geklickt werden.</span>';
      else
        th.firstChild.innerHTML = '<span style="font-size:13px;height:18px;"><img src="images/info_small.png" alt=""> für Karten-Links und weitere Infos anklicken.</span>';
    else
      if (vizMode == "")
        th.firstChild.innerHTML = '<span style="font-size:13px;height:18px;padding-left:33px;">In the following tables, click on the left <img src="images/info_small.png" alt=""> symbol for map display and further information.</span>';
      else
        th.firstChild.innerHTML = '<span style="font-size:13px;height:18px;">Click on <img src="images/info_small.png" alt=""> for map links and further information.</span>';
  }
} catch (ex) {}


if (vizMode == "") {
  window.___gcfg = {
    lang: (language=='D'?'de':'en-US')
  };
  //document.writeln('<div id="googleplus"><g:plusone size="medium" annotation="none"><\/g:plusone>');
  //document.writeln('<div id="googleplus"><g:plusone size="medium"><\/g:plusone>');
  //document.writeln('<script type="text/javascript" src="https://apis.google.com/js/plusone.js" defer="defer"></script>');
  document.writeln('</div>');
  document.writeln('<div id="twhead">' + getTwitterText((language=='D'?'de':'en')));
  document.writeln('</div>');
  document.writeln('<div id="fbhead"><iframe src="//www.facebook.com/plugins/like.php?href='+window.location.href+'&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=recommend&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; border-width:0px; overflow:hidden; width:110px; height:21px;" allowTransparency="true"></iframe>');
  document.writeln('</div>');

  //async_call_tail('http://platform.twitter.com/widgets.js',null,'twhead');
  //async_call_tail('https://apis.google.com/js/plusone.js',null,'googleplus');
  //async_call_tail('https://apis.google.com/js/plusone.js','script',null);
}


