// JavaScript Document
//Author: Udeep Tandukar 7th Apr 2008
//This file is used to get contenct from the server asynchronously and method is get
var eleID;
var imagePath = false;

function makeRequest() //argument should be url, elementID, ajaxLoader Image
{
	var url = makeRequest.arguments[0];
	
	if(makeRequest.arguments[1])
		eleID = makeRequest.arguments[1];
	if(makeRequest.arguments[2])
		imagePath = makeRequest.arguments[2];
	
	if(imagePath) {
		
		document.getElementById(eleID).innerHTML = 'Loading ... <img name="ajaxLoading" src="' + 
													imagePath + '" align="center"/>';
	}
	else {
		
		document.getElementById(eleID).innerHTML = 'Loading ... ';
	}

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...

		httpRequest = new XMLHttpRequest();
		
		if (httpRequest.overrideMimeType) {

			httpRequest.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) { // IE

		try {
		
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			
			try {
				
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) { }
		}
	}

	if (!httpRequest) {
	
		//alert('Cannot create an XMLHTTP instance');
		return false;
	}

	httpRequest.onreadystatechange = function () { showContent(eleID, httpRequest); };

	httpRequest.open('GET', url, true);
	httpRequest.send(null);
}

function showContent(eleID,httpRequest) { //used to get content
	
	if (httpRequest.readyState == 4) {
		
		if (httpRequest.status == 200) {
			
			document.getElementById(eleID).innerHTML = httpRequest.responseText;		
		} 
		else {
			
			//alert('Something went wrong ...');	
		}
    }
}
