var ajaxConnector = undefined;
var ajaxCell = undefined;

function ajaxGetMattresses() {
	if ((ajaxConnector) && (ajaxCell)) {
		if (ajaxConnector.readyState == 4) {
			if (ajaxConnector.status == 200) {
				if (ajaxConnector.responseXML) {
					if ((ajaxConnector.responseXML.documentElement.tagName == 'mattressHTML') && (ajaxConnector.responseXML.documentElement.childNodes.length == 1)) {
						if (ajaxConnector.responseXML.documentElement.childNodes.item(0).tagName == 'data') {
							ajaxCell.innerHTML = ajaxConnector.responseXML.documentElement.childNodes.item(0).firstChild.data;
							ajaxCell = null;

//							var innerHTML = '<div align="center">';
//							innerHTML = innerHTML + '<img src="' + ajaxConnector.responseXML.documentElement.childNodes.item(0).firstChild.data + '" /><br />';
//							innerHTML = innerHTML + '<a href="javascript:hideClipArt(\'' + clipArtElementId + '\');"><b>Close</b></a>';
//							innerHTML = innerHTML + '</div>';

//							clipArtElement.innerHTML = innerHTML;
//							clipArtElement.style.display = 'inline';
//							clipArtElement = null;
//							clipArtElementId = null;
						}
					}
				}
			}
		}
	}
}

function ajaxUpdatePage(form, cell) {
	if ((form) && (cell)) {
		var mattressForm = document.getElementById(form);
		ajaxCell = document.getElementById(cell);

		if ((mattressForm) && (ajaxCell)) {
			var ajaxURL = 'ajaxgetmattresses.cfm?';
			var mattressTypeIdList = '';
			var manufacturerIdList = '';
			var priceList = '';

			if (mattressForm.mattressTypeIdList != null) {
				for (var i=0; i<mattressForm.mattressTypeIdList.length; i++) {
					if (mattressForm.mattressTypeIdList[i].checked) {
						if (mattressTypeIdList != '') {
							mattressTypeIdList = mattressTypeIdList + ',';
						}
						mattressTypeIdList = mattressTypeIdList + mattressForm.mattressTypeIdList[i].value;
					}
				}
			}

			if (mattressForm.manufacturerIdList != null) {
				for (var i=0; i<mattressForm.manufacturerIdList.length; i++) {
					if (mattressForm.manufacturerIdList[i].checked) {
						if (manufacturerIdList != '') {
							manufacturerIdList = manufacturerIdList + ',';
						}
						manufacturerIdList = manufacturerIdList + mattressForm.manufacturerIdList[i].value;
					}
				}
			}

			if (mattressForm.priceList != null) {
				for (var i=0; i<mattressForm.priceList.length; i++) {
					if (mattressForm.priceList[i].checked) {
						if (priceList != '') {
							priceList = priceList + ',';
						}
						priceList = priceList + mattressForm.priceList[i].value;
					}
				}
			}

			ajaxURL = ajaxURL + 'mattressTypeIdList=' + escape(mattressTypeIdList) + '&manufacturerIdList=' + escape(manufacturerIdList) + '&priceList=' + escape(priceList);
			ajaxConnector = undefined;

			if (window.XMLHttpRequest) {
				ajaxConnector = new XMLHttpRequest();
				if (ajaxConnector) {
					ajaxConnector.onreadystatechange = ajaxGetMattresses;
					ajaxConnector.open('GET', ajaxURL, true);
					ajaxConnector.send(null);
				}
			}
			else if (window.ActiveXObject) {
				ajaxConnector = new ActiveXObject('Microsoft.XMLHTTP');
				if (ajaxConnector) {
					ajaxConnector.onreadystatechange = ajaxGetMattresses;
					ajaxConnector.open('GET', ajaxURL + clipArtId, true);
					ajaxConnector.send();
				}
			}
		}
	}
}
