/*
	This function is used to Create and Send the Request to Server Asynchronously
	inputs: 1: ServerURL to know to where the request is to be sent.
			2: Name of the Container
			3: Flag to know that the request is for Get or POST--> Ture for POST and False for GET
			4: OPTIONAL Parameters in the case of POST request
	OUTPut: Relays the Data accordingly			
*/
function CreateXMLHttpObjectAndProcess(SrvURL,ContainerId, flag, parameters)
  {
	var xmlHttp; 	// Used to store xmlHttp Object
	var Container	=	document.getElementById(ContainerId);	// Used to store the container of data.	
	
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp	=	new XMLHttpRequest();

		if (xmlHttp.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            xmlHttp.overrideMimeType('text/html');
         }
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}//Closing of try
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}//Closing of Catch
	//-------------------------------------------------------------------------------------------
	xmlHttp.onreadystatechange=function()
	{
		try {
				if(xmlHttp.readyState==4)
				{ 
					if (xmlHttp.status == 200)
					{
						//If Container is a text box
						if(Container.type == "text")
							Container.value		=	xmlHttp.responseText;
						else
						{
							//if there is nothing, don't perform any action)
							if( xmlHttp.responseText != "" )
								Container.innerHTML	=	xmlHttp.responseText;
							else
								Container.innerHTML	=	"";
						}// Closing of else
					}//Closing of if (xmlHttp.status == 200)
					else
						alert('Sorry! We could not fulfill your request. There was some problem.');
				}//Closing of if(xmlHttp.readyState==4)
				else
				{
					//If Container is a text box
					if(Container.type == "text")
						Container.value		=	"<div aling=\"center\">Processing...</div>";			
					//If container is Div
					else
						Container.innerHTML	=	"<div aling=\"center\" class=\"Contents_txt\"><br /><img src='"+ root +"images/loader.gif'>  Processing the Request.</div>";
				}
			}//End of try
		catch(e){}		
	}//Closing of Annonymous function
	//-------------------------------------------------------------------------------------------
	//Time stamp for cache problem
	var Stamp = new Date();

	//If the request is for post
	if(flag)
	{
	  xmlHttp.open('POST', SrvURL, true);
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
      xmlHttp.setRequestHeader("Connection", "close");
 	  xmlHttp.send(parameters);		
	}// Closing of if(url)
	else
	{
		//Make URL
		SrvURL = SrvURL+ "&TS="+ Stamp;
		//Open the Connection with the Server
		xmlHttp.open("GET",SrvURL,true);
		//Now finally send the Request
		xmlHttp.send(null);	
    }// Else
  }//Closing of CreateXMLHttpObjectAndProcess()