// JavaScript Document

var req=null;
var console=null;
var READY_STATE_UNINITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_INTERACTIVE=3;
var READY_STATE_COMPLETE=4;


function sendRequest(url,params,HttpMethod)
{
	//alert('params='+params);
	//	alert('HttpMethod='+HttpMethod);
	
	if (!HttpMethod)
	{
		HttpMethod="POST";
	}
	req=initXMLHTTPRequest();
	if (req)
	{
	   // alert("TEWSTS");
		req.onreadystatechange=onReadyState;
		
		req.open(HttpMethod,url,true);
		 
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		req.send(params);
		 
	}
}
/******************************         copy this function to each page     *******************************************
function onReadyState()
{

	//var ready=req.readyState;
	var data=null;
	if (req.readyState==READY_STATE_COMPLETE)
	{
		var xmlDoc = this.req.responseText;
		
//*******************Creating and Intializing DOM**********************************************
		if (typeof DOMParser == "undefined") { DOMParser = function (){}
  			DOMParser.prototype.parseFromString = function (str, contentType)
			{
				if (typeof ActiveXObject != "undefined")
				 { 
					var d = new ActiveXObject("MSXML.DomDocument"); 
						d.loadXML(str); 
					return d; 
				} 
				 else if (typeof XMLHttpRequest != "undefined")
				 {
					  var req = new XMLHttpRequest; 
					  req.open("GET", "data:" + (contentType || "application/xml") + ";charset=utf-8," + encodeURIComponent(str), false); 
					  if (req.overrideMimeType) { 
						req.overrideMimeType(contentType); 
					  } 
					  req.send(null); 
					  return req.responseXML; 
				} 
		 	 } 
		}
//*****************************************************************
		 xmlDocument = (new DOMParser()).parseFromString(xmlDoc,"text/xml");
	}
	else
	{
		//alert("loding"+req.readyState);
		
	}
	
	//return xmlDoc;
}
****************************************                  copy              ************************************/
//****************************creating the XMLHTTPRequest object
function initXMLHTTPRequest()
{
	var xRequest=null;
	if (window.XMLHttpRequest)
	{
		xRequest=new XMLHttpRequest();
	} else if (window.ActiveXObject)
	{
		xRequest=new ActiveXObject
		("Microsoft.XMLHTTP");
	}
	//alert(xRequest);
	return xRequest;
}