//var xmlHttp;
var noCache = Math.random();
var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	/*var xmlHttp;
	if(window.ActiveObject)
		xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest)
		xmlHttp= new XMLHttpRequest();
	else
		alert("Error creating the XMLHttpRequest object.");
	return xmlHttp;
	var xmlHttp = null;*/
	
	var xmlHttp = null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}
	

function as(pField, pDiv)
{
	var field = document.getElementById(pField).value;
	url = "as.php";
	url = url + "?pDiv=" + pDiv + "&pField=" + field + "&pFieldName=" + pField;
	url = url + "&noCache=" + noCache;
	if(pDiv == "csicolorwall")
		xmlHttp.onreadystatechange = asCsiColorwallSC;
	if(pDiv == "colorlibrary")
		xmlHttp.onreadystatechange = asColorlibrarySC;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function asCsiColorwallSC()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		document.getElementById("csicolorwall").innerHTML=xmlHttp.responseText 
}

function asColorlibrarySC()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		document.getElementById("colorlibrary").innerHTML=xmlHttp.responseText 
}

function add(pFieldName, pTestAuto)
{
	document.getElementById(pFieldName).value = pTestAuto;
}