function createHttpRequest()
{
	var xmlHttpLoc = false;
/*
	@cc_on @
	@if (@_jscript_version >= 5)*/
	try {
		xmlHttpLoc= new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlHttpLoc = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlHttpLoc = false;
		}
	}
/*	@end @*/

	if (!xmlHttpLoc && typeof XMLHttpRequest != 'undefined') {
		xmlHttpLoc = new XMLHttpRequest();
	}

	return xmlHttpLoc;
}

var contentLoaderArray = new Array();

function loadContent(url, containerName)
{
	var container = document.getElementById(containerName);
	if(!container)
		return false;
	
	if(container.content_loader)
	{	
	//	container.innerHTML = "aborted prev req";
		container.content_loader.abort();
		container.content_loader=false;
	}
	
	var contentLoader = createHttpRequest();
	contentLoaderArray[contentLoaderArray.length] = contentLoader;
	contentLoader.open("GET",url,true);
    contentLoader.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    contentLoader.send(null);
	container.content_loader = contentLoader;
	var ii = contentLoaderArray.length-1;
	contentLoader.onreadystatechange = 
		function()
		{ 
			eval("loadContentListener( " +ii+", '"+containerName+"');");
		};		
	return contentLoader;
}

function loadContentListener(id, containerName)
{
	var contentLoader = contentLoaderArray[id];	
//	alert("loader ["+id+"] \n containerName:" +containerName);
	if(!contentLoader)
	{
//		alert("loader ["+id+"] closed");
		return;
	}
	if (contentLoader.readyState == 4) 
	{
//alert(id + "\n" + containerName);
		/*readyState
			0 UNINITIALIZED open() has not been called yet. 
			1 LOADING send() has not been called yet. 
			2 LOADED send() has been called, headers and status are available. 
			3 INTERACTIVE Downloading, responseText holds the partial data. 
			4 COMPLETED Finished with all operations.
		*/
		if ( contentLoader.status == 200 )
		{
			var elem = document.getElementById(containerName);
			if ( elem != null )
			{
//alert(contentLoader.responseText);
				var responseText = contentLoader.responseText;
				if(responseText != "")
				{
//alert(elem.style.display);
					elem.style.display="";
//alert("po"+elem.style.display);
					elem.innerHTML = responseText;
//alert(elem.innerHTML);
					elem.content_loader = false;
				}
			}
			else
			{
				alert("neradau contentLoader");
			}
		}
		else
		{
			alert("Error:" +contentLoader.status );
		}
	}
}

function stopAllContentLoaders()
{
	var i =0;
	for(i=0; i<contentLoaderArray.length; i++ )
	{
		contentLoaderArray[i]="";
	}
	contentLoaderArray = new Array();	
}

