/* XML HTTP request */

// 通信
var _httpReq = false;
function httpRequest(url, func)
{
	if (window.XMLHttpRequest) {
		_httpReq = new XMLHttpRequest();
		if (_httpReq.overrideMimeType)
			_httpReq.overrideMimeType('text/xml');
	}
	else if (window.ActiveXObject) {	// IE
		try {
			_httpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				_httpReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!_httpReq)
		return false;
	_httpReq.onreadystatechange = func;
	_httpReq.open('GET', url, true);
	_httpReq.send(null);
}

function xmlResponse()
{
	if (_httpReq.readyState != 4 || _httpReq.status != 200)
		return false;
	return _httpReq.responseXML;
}

// bulb switch
var	_blbOff =  new Image(12, 19);
_blbOff.src = _imgD + 'mini/bulb_off.png';

var	_blbS = 0;
function bulbSwitch(im)
{
	if (im) {
		if (!_blbS++)
			dE('bulb').src = im.src;
	}
	else if (_blbS > 0) {
		if (!--_blbS)
			imgSwap(dE('bulb'), _blbOff);
	}
}

function bulbRequest(url, func, im)
{
	bulbSwitch(im);
	httpRequest(url, func);
}

function bulbResponse()
{
	if (res = xmlResponse())
		bulbSwitch(null);
	return res;
}
