//
// An ajax function to call a script to count the click.  
//
function checkButtonClick(buttonID) {
    var xmlHttp;
    // Firefox, Opera 8.0+, Safari, SeaMonkey
    try {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Sorry, your browser does not support AJAX.");
                // we want to return true so the click still goes to paypal, just
                // because they cannot handle AJAX should not mean they cannot donate
                return true;
            }
        }
    }
    
    //Get request string from _setup hook of passed function name
    if (buttonID !== undefined) {
        var queryString = "?button=" + buttonID;
        var requestString = "buttonCount.php" + queryString;
        // seems only to work if I set the asynch flag to false, I assume since the click we are tracking
        // takes us off this page to paypal so we need to wait for it to finish before leaving
        xmlHttp.open("GET", requestString, false);
        xmlHttp.send(null);
    }
    return true;
}
