function GetEventFeedViaAjax() 
{
    //create object for ajax session
    xmlhttp = new XMLHttpRequest();

    //this will be an asynchronous request, and this is the function that will be called on return
    xmlhttp.onreadystatechange = function() {
        //4: request finished and response is ready
        //200: ok
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

            //insert returned message in the document    
            document.getElementById("dynamicDiv").innerHTML = xmlhttp.responseText;
        }
    }


    //open a post connection (true means asychronous...i.e. we'll need a function to call on return)
    xmlhttp.open("POST", "ajaxServer.php", true);

    //send the post data over the post connection
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //need this for post data

    //use this to send with post parameters
    xmlhttp.send("action=print"); //&dick=short
}

function GetEventFeedFormsViaAjax() {
    //create object for ajax session
    xmlhttp = new XMLHttpRequest();

    //this will be an asynchronous request, and this is the function that will be called on return
    xmlhttp.onreadystatechange = function() {
        //4: request finished and response is ready
        //200: ok
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

            //insert returned message in the document    
            document.getElementById("dynamicDiv").innerHTML = xmlhttp.responseText;
        }
    }


    //open a post connection (true means asychronous...i.e. we'll need a function to call on return)
    xmlhttp.open("POST", "ajaxServer.php", true);

    //send the post data over the post connection
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //need this for post data

    //use this to send with post parameters
    xmlhttp.send("action=printforms"); //&dick=short
}

function AddEventViaAjax() {
    //create object for ajax session
    xmlhttp = new XMLHttpRequest();

    //this will be an asynchronous request, and this is the function that will be called on return
    xmlhttp.onreadystatechange = function() {
        //4: request finished and response is ready
        //200: ok
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

            //insert returned message in the document    
            document.getElementById("dynamicDiv").innerHTML = xmlhttp.responseText;
        }
    }


    //open a post connection (true means asychronous...i.e. we'll need a function to call on return)
    xmlhttp.open("POST", "ajaxServer.php", true);

    //send the post data over the post connection
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //need this for post data

    //use this to send with post parameters
    //encode so we can pass special chars to server, will be decoded in ajaxServer.php
    var date = encodeURIComponent(document.getElementById("date").value);
    var title = encodeURIComponent(document.getElementById("title").value);
    var detail = encodeURIComponent(document.getElementById("detail").value);
    xmlhttp.send("action=add&date=" + date + "&title=" + title + "&detail=" + detail);
}

function DeleteEventViaAjax(deleteid) {
    //create object for ajax session
    xmlhttp = new XMLHttpRequest();

    //this will be an asynchronous request, and this is the function that will be called on return
    xmlhttp.onreadystatechange = function() {
        //4: request finished and response is ready
        //200: ok
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

            //insert returned message in the document    
            document.getElementById("dynamicDiv").innerHTML = xmlhttp.responseText;
        }
    }


    //open a post connection (true means asychronous...i.e. we'll need a function to call on return)
    xmlhttp.open("POST", "ajaxServer.php", true);

    //send the post data over the post connection
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //need this for post data

    //use this to send with post parameters
    xmlhttp.send("action=delete&deleteid=" + deleteid);
}

function AuthenticateViaAjax() {
    //create object for ajax session
    xmlhttp = new XMLHttpRequest();

    //this will be an asynchronous request, and this is the function that will be called on return
    xmlhttp.onreadystatechange = function() {
        //4: request finished and response is ready
        //200: ok
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

            //hide security div if authentication succeeds
            if (xmlhttp.responseText == "true") {
                document.getElementById("authenticateDiv").className = "authenticateDivhide";
            }
            else 
            {
                document.getElementById("message").innerHTML = "invalid Username or Password";
            }
        }
    }


    //open a post connection (true means asychronous...i.e. we'll need a function to call on return)
    xmlhttp.open("POST", "ajaxServer.php", true);

    //send the post data over the post connection
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //need this for post data

    //use this to send with post parameters
    xmlhttp.send("action=authenticate&userid=" + document.getElementById("userid").value + "&password=" + document.getElementById("password").value);
}
