function HandleServerResponse()
{	
try
{
	if(XMLReq.readyState==4)
	{
		try
		{
			ShowHideProgress(2);
			if(XMLReq.status==200)
			{
				try
				{
					//alert(XMLReq.responseText)	
					//alert(XMLReq.getAllResponseHeaders());
					var contType 		= XMLReq.getResponseHeader("Content-Type");
		    		if(contType.indexOf("text/xml") >= 0)
					{					
						ProcessReturnXML(XMLReq.responseXML)
					}
										
					else
		    		{
		    			var responseHtml	= XMLReq.responseText;
		    			// Get the XML response ..
		    			var xmlStartPos		= responseHtml.indexOf("<AJAXElement>");
		    			var HTMLContents	= responseHtml.split("<AJAXElement>");  			
    					  
		    			//alert(HTMLContents[0]);
    					// parse inline xml response from the server 
    					xmlResponse	= xmlStartPos > 0 ? HTMLContents[1] : HTMLContents[0];
    					if(xmlResponse)
    					{    						
    						xmlResponse	= xmlResponse.replace(/&lt;/g, "<");
    						xmlResponse	= xmlResponse.replace(/&gt;/g, ">");
    						//alert(xmlResponse);
    						// xml parser initialiser.... ........................
							if (window.ActiveXObject)
							{
							  XMLRespObj		= new ActiveXObject("Microsoft.XMLDOM");
							  XMLRespObj.async	= "false";
							  XMLRespObj.loadXML(xmlResponse);
							  //XMLRespObj.load(xmlResponse); // for xml file
							}
							/*else if (document.implementation && document.implementation.createDocument)
							{
								XMLRespObj	=	document.implementation.createDocument("","",null);
								XMLRespObj.load(xmlResponse);
								//alert(XMLRespObj.readyState)
								//XMLRespObj.onload=ProcessReturnXML(XMLRespObj);
							}*/
							else
							{
								var parser		= new DOMParser();
							      XMLRespObj	= parser.parseFromString(xmlResponse,"text/xml");
							}
							var container		= XMLRespObj.documentElement.childNodes[0].getAttribute('container');
							document.getElementById(container).innerHTML	= HTMLContents[0];
							ProcessReturnXML(XMLRespObj);
    					} 
    					//alert(xmlResponse)     					
		    		}
				}
				catch (e)
				{
					//alert("Error reading the response"+e.toString());
				}
			}
			else
			{
				//alert("There was an error retriving the server data \n \t \t \t \t "+XMLReq.statusText +"\n"+XMLReq.responseText)
			}
		}
		catch(e)
		{
			//alert("x_ajax.js_42-63 \n \t \t \t \t"+e)
		}
	}
	else if(XMLReq.readyState==2 || XMLReq.readyState==3)	
	{
		//ShowHideProgress(1);
	}	
}
catch(e)
{
	//alert("Error reading the response "+e.toString());
}
}

function ProcessReturnXML(XMLRespObj)
{	
	if(XMLRespObj)
	{
		var docElmnt	= XMLRespObj.documentElement;
		for(ctIndx = 0; ctIndx < docElmnt.childNodes.length; ctIndx++)
		{
			try
			{
				var currProcessingChild	= docElmnt.childNodes[ctIndx];
				switch(currProcessingChild.getAttribute("display"))
				{
					case "css":
						PrintCSS(currProcessingChild);
					break;
					case "script":
						FormatScript(currProcessingChild);
					break;
					case "list":
						PrintListBorderTable(currProcessingChild);
					break;
					case "icon":
						PrintIconListTable(currProcessingChild);
					break;
					case "listRow":
						PrintListBorderTableRow(currProcessingChild);
					break;
					case "html":
						PrintHTML(currProcessingChild);
					break;
					case "selectBox":
						PrintSelectBox(currProcessingChild);
					break;
					case "tooltip":
						PrintToolTip(currProcessingChild);
					break;
					case "HTMLform":
						PrintHTMLForm(currProcessingChild);
					break;
				}
			}
			catch(e)
			{
				//alert("x_ajax_exc.js 99-129 \n \t \t \t \t"+e.toString+"\n \t"+e)
			}
		}
		
	}
}
			    		
	/*/ sample xml parser initialiser.... can be removed........................
	case "text/xhtml":
	alert(xmlResponse.documentElement.attributes[0].name);
	if (window.ActiveXObject)
	{
	  XMLRespObj		= new ActiveXObject("Microsoft.XMLDOM");
	  XMLRespObj.async	= "false";
	  XMLRespObj.loadXML(XMLReq.responseText);
	}
	else
	{
	  var parser		= new DOMParser();
	     XMLRespObj		= parser.parseFromString(xmlResponse,"text/xml");
	}
	var docElmnt		= XMLRespObj.documentElement;
	contType			= (docElmnt.attributes[0].name == "contentType" ? docElmnt.attributes[0].value : "text/HTML");
	break;
/*----------------------------------------------------------------------*/
function savefile( f ) 
{  
	f = f.elements;  //  reduce overhead 	
	var w = window.frames.w;  
	if( !w ) 
	{  
		w = document.createElement( 'iframe' );   
		w.id = 'w';   
		w.style.display = 'none';   
		document.body.insertBefore( w );   
		w = window.frames.w;   
		if( !w ) 
		{    
			w = window.open( '', '_temp', 'width=100,height=100' );    
			if( !w ) 
			{     
				window.alert( 'Sorry, could not create file.' ); 
				return false;    
			}   
		}  
	}   
	var d = w.document, ext = f.ext.options[f.ext.selectedIndex], name = f.filename.value.replace( /\//g, '\\' ) + ext.text;
		d.open( 'text/plain', 'replace' );  
		d.charset = ext.value;  
	if( ext.text==='.txt' ) 
	{   
		d.write( f.txt.value );   
		d.close();  
	} 
	else 
	{  //  '.html'   
		d.close();   
		d.body.innerHTML = '\r\n' + f.txt.value + '\r\n';  
	}   
	if( d.execCommand( 'SaveAs', null, name ) )
	{   
		window.alert( name + ' has been saved.' );  
	} 
	else 
	{   
		window.alert( 'The file has not been saved.\nIs there a problem?' );  
	}  
	w.close();  
	return false;  //  don't submit the form 
}