function POSTRequest(obj) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/include.php";
    var comment = obj.form.comment.value;
    var query = "page=&save=Submit+Comment&comment=" + encodeURI(comment);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments");
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function POSTRequestId(obj, id) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/include-articles.php";
    var comment = "";
    for(i=0;i<obj.form.elements.length;i++){ 
      if(obj.form.elements[i].name=="comment_" + id){ 
        comment= obj.form.elements[i].value; 
    }}
    var query = "page=&save=Submit+Comment&comment=" + encodeURI(comment) + "&articleid=" + encodeURI(id);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments_" + id);
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function POSTLogin(obj) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/login.php";
    var username = obj.form.username.value;
    var password = obj.form.password.value;
    var query = "username=" + encodeURI(username) + "&password=" + encodeURI(password);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments");
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function POSTLoginId(obj, id) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/login.php";
    var username = obj.form.username.value;
    var password = obj.form.password.value;
    var query = "username=" + encodeURI(username) + "&password=" + encodeURI(password) + "&articleid=" + encodeURI(id);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments_" + id);
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function POSTRegister(obj) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/newuser.php";
    var username = obj.form.new_username.value;
    var password1 = obj.form.password1.value;
    var password2 = obj.form.password2.value;
    var email = obj.form.email.value;
    var homepage = obj.form.homepage.value;
    var query = "username=" + encodeURI(username) + "&password1=" + encodeURI(password1) + "&password2=" + encodeURI(password2) + "&email=" + encodeURI(email) + "&homepage=" + encodeURI(homepage);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments");
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function POSTRegisterId(obj, id) {
    var xmlHttp = createXMLRequest();

    var url = "http://www.humoron.com/comments/newuser.php";
    var username = obj.form.new_username.value;
    var password1 = obj.form.password1.value;
    var password2 = obj.form.password2.value;
    var email = obj.form.email.value;
    var homepage = obj.form.homepage.value;
    var query = "username=" + encodeURI(username) + "&password1=" + encodeURI(password1) + "&password2=" + encodeURI(password2) + "&email=" + encodeURI(email) + "&homepage=" + encodeURI(homepage) + "&articleid=" + encodeURI(id);

    xmlHttp.open("POST", url, true);
    xmlHttp.onreadystatechange = function()
    {
            if(xmlHttp.readyState==4)
            {
                    var container = document.getElementById("comments_" + id);
                    container.innerHTML=xmlHttp.responseText;
            }
    }
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(query);
}

function createXMLRequest()
{
        var xmlHttp;
        try
        {
                // Firefox, Opera 8.0+, Safari
                xmlHttp=new XMLHttpRequest();
        }
        catch (e)
        {
                // Internet Explorer
                try
                {
                        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e)
                {
                        try
                        {
                                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e)
                        {
                                alert("Your browser does not support AJAX!");
                                return false;
                        }
                }
        }
        return xmlHttp;
}

function showComments()
{
        var xmlHttp = createXMLRequest();
        xmlHttp.onreadystatechange=function()
        {
                if(xmlHttp.readyState==4)
                {
                        var container = document.getElementById("comments");
                        container.innerHTML=xmlHttp.responseText;
                }
        }

        xmlHttp.open("GET","http://www.humoron.com/comments/include.php",true);
        xmlHttp.send(null);
}

function getComments(id)
{
        var xmlHttp = createXMLRequest();
        xmlHttp.onreadystatechange=function()
        {
                if(xmlHttp.readyState==4)
                {
                        var container = document.getElementById("comments_" + id);
			container.innerHTML = xmlHttp.responseText;
                }
        }
        xmlHttp.open("GET","http://www.humoron.com/comments/include-articles.php?articleid=" + id ,true);
        xmlHttp.send(null);
}

function commentBanner()
{
        var xmlHttp = createXMLRequest();
        xmlHttp.onreadystatechange=function()
        {
                if(xmlHttp.readyState==4)
                {
                        var container = document.getElementById("comments");
                        container.innerHTML=xmlHttp.responseText;
                }
        }

        xmlHttp.open("GET","http://www.humoron.com/comments/commentbanner.php",true);
        xmlHttp.send(null);
}


