<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="G+ Badge (Google Plus)"
     title_url="http://howtohtml5.com" 
     height="200" 
     width="300" 
     description="Add Google Plus Badge to your Google Site." 
     author="Joshua Woodward" 
     author_email="googwoodward@gmail.com"/>
  <UserPref name="gplusID" 
    display_name="G+ ID" 
    datatype="string"
    required="true"/>
  <Content type="html">
     <![CDATA[
        <div id="GPlusBadge"></div>
        <script type="text/javascript">
        function modifyHead(){
            var prefs = new gadgets.Prefs();
            var gplusID = prefs.getString('gplusID');
            document.getElementById('GPlusBadge').innerHTML='<g:plus href="https://plus.google.com/'+gplusID+'" size="badge"></g:plus>';
            
            link=document.createElement('link');
            link.href='https://plus.google.com/'+gplusID;
            link.rel='publisher';
            document.getElementsByTagName('head')[0].appendChild(link);
            
            script=document.createElement('script');
            script.type='text/javascript';
            script.innerHTML='(function(){var po = document.createElement("script");po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po, s);})();';
            document.getElementsByTagName('head')[0].appendChild(script);
        }
        gadgets.util.registerOnLoadHandler(modifyHead);
        </script>
     ]]>
  </Content> 
</Module>