var httpObj = getXMLHTTPRequest();

function getXMLHTTPRequest() {
	try {
		req = new XMLHttpRequest();
	} catch(err1) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			alert(err1);
		} catch (err2) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err3) {
				req = false;
			}
		}
	}
	return req;
}

function clearAllNodesFrom(parent) {
	if (parent.hasChildNodes()) {
		while (parent.childNodes.length >= 1) {
			parent.removeChild(parent.firstChild);
		}
	}
}

function displayLoadingWidget() {
	var displayPanelObj = document.getElementById("popupBody");
	var ajaxLoader = document.createElement("div");
	ajaxLoader.setAttribute("id","loadingWidget");
	var ajaxLoaderImg = document.createElement("img");
	ajaxLoaderImg.setAttribute("src","images/popup/ajaxloader.gif");
	ajaxLoaderImg.setAttribute("alt","Loading...");
	ajaxLoaderImg.setAttribute("border","0");
	ajaxLoaderImg.setAttribute("width","220");
	ajaxLoaderImg.setAttribute("height","19");
	ajaxLoader.appendChild(ajaxLoaderImg);
	displayPanelObj.appendChild(ajaxLoader);
}

function displaySmallLoadingWidget() {
	var smallAjaxLoaderObj = document.getElementById("smallAjaxLoader");
	
	if (!smallAjaxLoaderObj.hasChildNodes()) {
		var ajaxLoaderImg = document.createElement("img");
		ajaxLoaderImg.setAttribute("src","images/popup/ajax-loader-small.gif");
		ajaxLoaderImg.setAttribute("alt","Loading...");
		ajaxLoaderImg.setAttribute("border","0");
		ajaxLoaderImg.setAttribute("width","16");
		ajaxLoaderImg.setAttribute("height","16");
		smallAjaxLoaderObj.appendChild(ajaxLoaderImg);
	}
}

function hideSmallLoadingWidget() {
	clearAllNodesFrom(document.getElementById("smallAjaxLoader"));
}