<?xml version="1.0" encoding="UTF-8" ?> 
<Module>

<ModulePrefs title="Google Page Count"
    title_url="http://blog.outer-court.com"
    description="Displays the approximate number of web pages Google indexed"
    author="Philipp Lenssen"
    author_email="philipp.lenssen+widget@gmail.com"
    author_affiliation="Google Blogoscoped"
    author_location="Stuttgart, Germany"
    screenshot="http://blog.outer-court.com/homepage/screenshot/googlecounter.gif"
    height="80"
    scrolling="false"
/>

<Content type="html"><![CDATA[ 

<p id="pagecount" style="padding: 4px; font-family: arial, helvetica, sans-serif; font-size: 90%; text-align: center;">&nbsp;</p>

<script type="text/javascript">

document.body.onload = init();

function init()
{
    _IG_FetchContent( 'http://www.google.com/search?q=*+*', function (responseText) {
        var sPart = getTextBetween(responseText, "of about <b>", "</b> for");
        if (sPart != "") {
            echo("pagecount", "Searching about " + sPart + " web pages");
        }
        else {
            echo("pagecount", "(Failed pulling data, please refresh)");
        }
    } );
}

function echo(id, s)
{
    var elm = _gel(id);
    if (elm) {
        elm.innerHTML = s;
    }
}

function getTextBetween(sAll, sFrom, sTo)
{
    var sPart = "";

    var iFrom = sAll.indexOf(sFrom);
    var iTo = sAll.indexOf(sTo);
    iFrom += sFrom.length;
    if (iTo > iFrom) {
        sPart = sAll.substring(iFrom, iTo);
    }

    return sPart;
}

</script>

]]></Content>

</Module>