/* Browser Compatability function. It returns the correct XMLHttpRequest depending on the current browser. */
function createRequestObject()
{
/* Initialising the variable xmlhttp */
	var xmlhttp=false;
	
/* Try and catch block for creating xmlhttp object according to the browser */
	try
	{
	/* The xmlhttp object is built into the Microsoft XML Parser. */
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try 
		{
		/* The xmlhttp object is built into the Microsoft IE. */
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
/* The xmlhttp object is built into the browsers other than Microsoft IE. */
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

var response;
var duplFlag = false;

/* Function to perform operations */
function performOperation(action,params)
{
/* Variable request to hold XMLHTTP request object by calling function createRequestObject() */
	var request = createRequestObject();

/* The open method initializes a XMLHTTP request and specifies the method, URL for the request. */
	request.open('POST', 'check.php?&action='+action+params,true);
	
/* An event handler for an event that fires at every state change*/
	request.onreadystatechange = function()
	{
	/* The readyState Property represents the state of the request. */
	/* readyState = 4 indicates that all the data has been received and is available */
		if(request.readyState == 4)
		{
		/* The status Property is read-only and represents the HTTP status code returned by a request. It is only valid after the send method returns successfully */
			if(request.status == 200)
			{
			/* Variable response holds the data obtained by XMLHTTP object */
			/* The responseText Property represents the response entity body as a string */
				response= request.responseText;
		       //alert(response);
//alert(response);
			/* Operation to perform when the request for duplicate check is succeeded */
				if(action == "C")
					chkResponseDupl();
			
			/* Operation to perform when the request for save Registration is succeeded */
				if(action == "D")
				{
				chkResponseDupl2();
				}
				if(action == "E")
				{
				chkResponseDupl21();
				}

			
			}
		}
	}
/* The send() method sends an HTTP request to the server and receives a response */
	request.send(null);
}
