﻿// JScript File

var xmlHttp;
function CreateXmlReq()
{
    //
	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;
            }
        }
    }
}

//send a http request and pass the respose to a function
function SendRequestGetResponse(request_Url,callback_function)
{
    //create an xml http request
    CreateXmlReq();
    
	if(xmlHttp)
	{
	    xmlHttp.onreadystatechange = eval(callback_function);//set the response method
		xmlHttp.open("GET", request_Url, true);
		xmlHttp.send(null);		
	}
}

//send a http request and pass the respose to a function
function SendPostRequestGetResponse(request_Url,callback_function,str)
{
    //create an xml http request
    CreateXmlReq();
    
	if(xmlHttp)
	{
	    xmlHttp.onreadystatechange = eval(callback_function);//set the response method
		xmlHttp.open("POST", request_Url, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		xmlHttp.send(str);		
	}
}

