// -*- coding: utf-8 -*-
// insert a twitter div tag before element myEle
function insertTwitter (myEle) {
    var twtBox = document.createElement("div");
    twtBox.setAttribute("class", "twt");
    twtBox.style.margin="2px";

    twtBox.innerHTML='<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="xah_lee">Tweet</a>';

    var ele = document.createElement("script");
    ele.type = "text/javascript";
    ele.src = "http://platform.twitter.com/widgets.js";

    twtBox.appendChild(ele);

    myEle.parentNode.insertBefore(twtBox, myEle.nextSibling);
}


// insert a donation box before the the object myEle
function insertDonation (myEle) {
    var donationBox = document.createElement("div");
    donationBox.setAttribute("style", "text-align:center");

    donationBox.innerHTML='If you spend more than 60 minutes on the site, please pay USD $6. <a href="http://xahlee.info/thanks.html">Thank you</a> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="Y4V2F8TA949M2"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" name="submit" alt="PayPal"><img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></div></form>';

    myEle.parentNode.insertBefore(donationBox, myEle);
}

var pCount = (document.getElementsByTagName("p")).length; // or jQuery $("p").size()

insertTwitter((document.getElementsByTagName("h1"))[0]);

insertDonation((document.getElementsByTagName("h1"))[0]);

