function signup() {
    var email = document.getElementById('bbemail').value;
    var zip = document.getElementById('bbzip').value;
    var script = document.createElement('script');
    script.src = 'http://services.sunlightlabs.com/brandingbar/post_signup/?source=impactdashboard&email=' + email + '&zip=' + zip;
    document.getElementsByTagName('head')[0].appendChild(script);
}

function injectHat(data) {
    // inject stylesheet
    var link = document.createElement('link');
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://assets.sunlightfoundation.com/css/brandingbar/brandingbar.css';
    document.getElementsByTagName('head')[0].appendChild(link);

    var hat = document.createElement('div');
    hat.innerHTML = data;
    hat.id = 'brandingbar';
    document.body.insertBefore(hat, document.body.firstChild);
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload !== 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        };
    }
}

addLoadEvent(function() { injectHat('\x3Cdiv id\x3D\x22bbinner\x22\x3E   \x3Ca id\x3D\x22sllink\x22 href\x3D\x22http://sunlightfoundation.com\x22 title\x3D\x22Sunlight Foundation\x22\x3E\x3C/a\x3E   \x3Ca href\x3D\x22#\x22 onclick\x3D\x22javascript:if(document.getElementById(\x27bbprojects\x27).style.display !\x3D \x27block\x27) { document.getElementById(\x27bbprojects\x27).style.display \x3D\x27block\x27\x3B } else { document.getElementById(\x27bbprojects\x27).style.display \x3D\x27none\x27\x3B }\x22 id\x3D\x22bbexpand\x22\x3E(Who is the Sunlight Foundation?)\x3C/a\x3E   \x3Cspan id\x3D\x22bbjoin\x22\x3E     Join Our Mailing List     \x3Cinput id\x3D\x22bbemail\x22 name\x3D\x22email\x22 value\x3D\x22Your Email\x22 onfocus\x3D\x22javascript:if(this.value\x3D\x3D\x27Your Email\x27) { this.value\x3D\x27\x27\x3B }\x22 size\x3D\x2212\x22/\x3E     \x3Cinput id\x3D\x22bbzip\x22 name\x3D\x22zip\x22 value\x3D\x22Your Zip\x22 size\x3D\x2210\x22 onfocus\x3D\x22javascript:if(this.value\x3D\x3D\x27Your Zip\x27) { this.value\x3D\x27\x27\x3B }\x22 /\x3E     \x3Cinput type\x3D\x22submit\x22 value\x3D\x22subscribe\x22 onclick\x3D\x22javascript:signup()\x3B\x22 /\x3E   \x3C/span\x3E \x3C/div\x3E    \x3Cdiv id\x3D\x22bbprojects\x22 style\x3D\x22display: none\x3B\x22\x3E     \x3Cdiv id\x3D\x22bbfooter\x22\x3E     \x3Cdiv id\x3D\x22bbbox_1\x22\x3E       \x3Ch6\x3EAbout Sunlight Foundation\x3C/h6\x3E       \x3Cp\x3EThe Sunlight Foundation uses cutting\x2Dedge technology and ideas to make government transparent and accountable. Underlying all of our efforts is a fundamental belief that increased transparency will improve the public\x27s confidence in government\x3C/p\x3E     \x3C/div\x3E      \x3Cdiv id\x3D\x22bbbox_2\x22\x3E\x3Ch6\x3ERecent Sunlight Foundation Projects\x3C/h6\x3E       \x3Cp\x3E\x3Cul\x3E              \x3Cli\x3E\x3Ca href\x3D\x22http://www.opencongress.org/\x22 class\x3D\x22project\x22\x3EOpen Congress\x3C/a\x3E\x3Ca href\x3D\x22http://www.opencongress.org/\x22 \x3E \x2D Everyone can be an insider\x3C/a\x3E\x3C/li\x3E              \x3Cli\x3E\x3Ca href\x3D\x22http://reporting.sunlightfoundation.com/\x22 class\x3D\x22project\x22\x3EReporting Group\x3C/a\x3E\x3Ca href\x3D\x22http://reporting.sunlightfoundation.com/\x22 \x3E \x2D Digging into data and disclosures\x3C/a\x3E\x3C/li\x3E              \x3Cli\x3E\x3Ca href\x3D\x22http://www.sunlightfoundation.com/WhiteHouseVisitors/\x22 class\x3D\x22project\x22\x3EWhite House Visitor Logs\x3C/a\x3E\x3Ca href\x3D\x22http://www.sunlightfoundation.com/WhiteHouseVisitors/\x22 \x3E \x2D A Mashup\x3C/a\x3E\x3C/li\x3E              \x3Cli\x3E\x3Ca href\x3D\x22http://transparencycorps.org/\x22 class\x3D\x22project\x22\x3ETransparency Corps\x3C/a\x3E\x3Ca href\x3D\x22http://transparencycorps.org/\x22 \x3E \x2D Help Us Make the Government More Transparent\x3C/a\x3E\x3C/li\x3E              \x3C/ul\x3E\x3C/p\x3E     \x3C/div\x3E      \x3Cdiv id\x3D\x22bbbox_3\x22\x3E\x3Ch6\x3EFeatured Project\x3C/h6\x3E       \x3Ca href\x3D\x22http://sunlightlabs.com/blog/2009/congress\x2Dtheres\x2Dan\x2Dandroid\x2Dapp\x2Dfor\x2Dthat/\x22\x3E\x3Cimg src\x3D\x22http://assets.sunlightfoundation.com/bumpers/75x75/android_75x75.png\x22 align\x3D\x22left\x22 border\x3D\x220\x22\x3E\x3C/a\x3E       \x3Cp\x3ECongress: There\x26#39\x3Bs an (Android) App for that\x3C/p\x3E     \x3C/div\x3E   \x3C/div\x3E  \x3C/div\x3E '); });
