﻿//Global XMLHTTP Request object
var XmlHttp;
var Path = 'http://localhost:9613';
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp() {
    //Creating object of XMLHTTP in IE
    try {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (oc) {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari 
    if (!XmlHttp && typeof XMLHttpRequest != "undefined") {
        XmlHttp = new XMLHttpRequest();
    }
}
function HandleQuestionResponse() {
    // To make sure receiving response data from server is completed
    if (XmlHttp.readyState == 4) {
        // To make sure valid response is received from the server, 200 means response received is OK
        if (XmlHttp.status == 200) {
            var divValue = "";
            var divValue = document.getElementById('UserPaging');

            if (divValue != null && divValue != "") {

                divValue.innerHTML = "";
                divValue.innerHTML = XmlHttp.responseText;
            }

        }
        else {
            alert("There was a problem retrieving data from the server.");
        }
    }
}

function MemberSearch(Search, PageNo) {


    // URL to get states for a given country
    //var requestUrl = "";
    var requestUrl = Path + "/Member/?query=" + Search + "&PageNo=" + PageNo;
    CreateXmlHttp();

    // If browser supports XMLHTTPRequest object
    if (XmlHttp) {
        //Setting the event handler for the response
        XmlHttp.onreadystatechange = HandleQuestionResponse;

        //Initializes the request object with GET (METHOD of posting), 
        //Request URL and sets the request as asynchronous.
        XmlHttp.open("GET", requestUrl, true);

        //Sends the request to server
        XmlHttp.send(null);
    }
    
}
function InboxPaging(Search, PageNo) {


    // URL to get states for a given country
    //var requestUrl = "";
    var requestUrl = Path + "/User/Dashboard/Inbox/?PageNo=" + PageNo;
    alert(requestUrl);
    CreateXmlHttp();

    // If browser supports XMLHTTPRequest object
    if (XmlHttp) {
        //Setting the event handler for the response
        XmlHttp.onreadystatechange = HandleQuestionResponse;

        //Initializes the request object with GET (METHOD of posting), 
        //Request URL and sets the request as asynchronous.
        XmlHttp.open("GET", requestUrl, true);

        //Sends the request to server
        XmlHttp.send(null);
    }
    //getValue(q_page);
    //return XmlHttp;
}











