
function InitializeAjax()

{
	// creating new object for ajax 
	var req= new Object();
	if(window.XMLHttpRequest) 
	{	
		// branch for native XMLHttpRequest object
		try 
		{
			req = new XMLHttpRequest();
		} 
		catch(e) 
		{
			req = false;
		}
	}
	else if(window.ActiveXObject) 
	{	
		// branch for IE/Windows ActiveX version
		try 
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) 
		{
			try 
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(e) 
			{
				req = false;
			}
		}
	}

	return req;
}

function CallXmlData(ActionCode,Url,Flds)
{

	// Initializing the Global Object	
	var req=false;
	// Check for browser compatibility
	req=InitializeAjax();
	// check the object for the rest of the operations
	if(req)
	{
		// Check Action Code
		switch(ActionCode)
		{

			case 1:

				// Used For Get Operation
				req.onreadystatechange = showValues;
				req.open("GET", Url, true);
				req.send(Flds);

			break;
			case 2:
				// Use for Post Operation
				req.onreadystatechange = showPost;
				req.open("POST", Url, true);
				req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
				req.send(Flds);
			break;		
		}
	}

	// This functionXML will depend on the different Modules
	function displayXML()
	{
		var objXML = req.responseXML;
		for(var i = 0; i < objXML.getElementsByTagName('DivBody').length; i++)
		{	
			var divArray= new Array();
			var j=0;
			node=objXML.getElementsByTagName('DivBody')[i].firstChild;
			while(node)
			{				
				divArray[j++]= node.firstChild.nodeValue;
				node=node.nextSibling;
			}
			document.getElementById(divArray[0]).innerHTML=divArray[1];
			
		}
		for(var i = 0; i < objXML.getElementsByTagName('JS').length; i++)
		{
			var JSCall="";
			node=objXML.getElementsByTagName('JS')[i].firstChild;
			while(node)
			{				
				JSCall= node.firstChild.nodeValue;
				node=node.nextSibling;
				eval(JSCall);
			}
		}
	}
	
	function showValues()
	{	

		// Default Function set to the Event State Object 

		// Setting the status value true 

		if(req.readyState == 4)

		{

			var objXML = req.responseXML;
			if(req.responseXML)
			{
				if(objXML.getElementsByTagName('DivBody').length>0 || objXML.getElementsByTagName('JS').length>0)
				{
					displayXML();	
				}
				else
					alert(req.responseText);		
			}
			else
			{
				alert(req.responseText);
			}
		}
	}

	function showPost()

	{	

		// Default Function set to the Event State Object 

		// Setting the status value true 

		if(req.readyState == 4)

		{

			var objXML = req.responseXML;
			if(req.responseXML)
			{
				if(objXML.getElementsByTagName('DivBody').length>0 || objXML.getElementsByTagName('JS').length>0)
				{
					displayXML();	
				}
				else
					alert(req.responseText);		
			}
			else
			{
				alert(req.responseText);
			}
		}
	}
}

function CallXML(category,id,block,action){
		
		var url = "page.php?category="+category+"&id="+id+"&Block="+block+"&Action="+action;
		url.toString();
		CallXmlData(1,url,'');

}

function CallXML2(category,id,action){
	
		var url = "page2.php?category="+category+"&id="+id+"&Action="+action;
		url.toString();
		CallXmlData(1,url,'');

}

function CallXML3(cat,id,action,page){
	
		var url = "page3.php?cat="+cat+"&id="+id+"&action="+action+"&page="+page;
		url.toString();
		CallXmlData(1,url,'');
		
}