﻿var aj_MainDelimeter = "~!";
var aj_AttributeDelimeter = "~|";
var aj_RowDelimeter = "~:";
var aj_ColumnDelimeter = "~^";

wm_getHttp_new = function () {
	//this function is a close copy from jibbering: http://jibbering.com/2002/4/httprequest.html
	//(however with the advent of XMLHttpRequest in IE7, the test object order is not good, but I need to keep it until I find a way to test IE7 myself)
	try {
		return new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
			//return null;
		}
	}
	if (typeof XMLHttpRequest != 'undefined') {
		try {
			return new XMLHttpRequest(); //Mozilla & Safari 
		}
		catch (e) {
			//return null; 
		}
	}
	if (window.createRequest) {
		try {
			return window.createRequest(); //IceBrowser 
		}
		catch (e) {
			//return null;
		}
	}
	return null;
}

wm_Http_nvc = {
	add: function (pName, pHttpRequest) {
		this.remove(pName);
		var pair = new this.Pair(pName, pHttpRequest);
		this.pairs.push(pair);
	},

	remove: function (pName) {
		for (var p = 0; p < this.pairs.length; p++) {
			if (this.pairs[p].name == pName) {
				this.pairs.splice(p, 1);
				break;
			}
		}
	},

	getHttp: function (pName) {
		for (var p = 0; p < this.pairs.length; p++) {
			if (this.pairs[p].name == pName) {
				return this.pairs[p].httpRequest;
			}
		}
	},

	pairs: [],

	Pair: function (pName, pHttpRequest) {
		this.name = pName;
		this.httpRequest = pHttpRequest;
	}
}

startAjaxLoader = function (pLayoutContainerID) {
	var layoutContainer = document.getElementById(pLayoutContainerID);
	var elm = layoutContainer;
	var layoutContainerX = layoutContainer.offsetLeft;
	var layoutContainerY = layoutContainer.offsetTop;
	while (elm = elm.offsetParent) {
		layoutContainerX += elm.offsetLeft;
		layoutContainerY += elm.offsetTop;
	}
	var layoutContainerW = layoutContainer.offsetWidth;
	var layoutContainerH = layoutContainer.offsetHeight;

	var imgAjaxLoader = document.createElement("img");
	imgAjaxLoader.style.position = "absolute";
	imgAjaxLoader.style.visibility = "hidden";
	imgAjaxLoader.src = "_images/ajax-loader.gif";
	window.document.body.appendChild(imgAjaxLoader);

	var imgAjaxLoaderW = imgAjaxLoader.offsetWidth;
	var imgAjaxLoaderH = imgAjaxLoader.offsetHeight;
	var imgAjaxLoaderX = layoutContainerX + (layoutContainerW - imgAjaxLoaderW) / 2;
	var imgAjaxLoaderY = layoutContainerY + (layoutContainerH - imgAjaxLoaderH) / 2;

	imgAjaxLoader.style.top = Math.floor(imgAjaxLoaderY) + "px";
	imgAjaxLoader.style.left = Math.floor(imgAjaxLoaderX) + "px";
	imgAjaxLoader.id = pLayoutContainerID + "imgAjaxLoader";
	imgAjaxLoader.style.visibility = "visible";
}

stopAjaxLoader = function (pLayoutContainerID) {
	var imgAjaxLoader = document.getElementById(pLayoutContainerID + "imgAjaxLoader");
	if (imgAjaxLoader) {
		imgAjaxLoader.parentNode.removeChild(imgAjaxLoader);
	}
}		

