var domain_array = new Array();
var found_array = new Array();
var detail_array = new Array();
var err_array = new Array();
function whois(domain,ext) {
	if (document.getElementById) {
		var http = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		if (http) {
			http.onreadystatechange = function () {
				if(http.readyState == 4) { // 0: Uninitialized, 1: Loading, 2: Loaded, 3: Interactive, 4: Finished
					roots = http.responseXML.documentElement;
					domain_array[ext] = domain;
					if (roots) {
						found_array[ext] = roots.getElementsByTagName('found')[0].firstChild.nodeValue;
						detail_array[ext] = roots.getElementsByTagName('content')[0].firstChild.nodeValue;
						err_array[ext] = '0';
					} else {
						err_array[ext] = '1';
					}
//----- Show image result
					if (err_array[ext]==1) {
						imagepath='/images/checkbox_unknown.gif';
					} else if (found_array[ext]==1) {
						imagepath='/images/checkbox_no.gif';
					} else if (found_array[ext]==0)	{
						imagepath='/images/checkbox_yes.gif';
					} else {
						imagepath='/images/checkbox_unknown.gif';
					}
					document.getElementById(ext).src=imagepath;
					if (mainext==ext) {
						showdetail(ext);
					}
//-----------------------
				}
			}
		}
		http.open('get', '/whois.php?domain='+domain+'.'+ext);
		http.send(null);
	}
}
function checkdomain(domain) {
	whois(domain,'com');
	whois(domain,'net');
	whois(domain,'org');
	whois(domain,'info');
	whois(domain,'biz');
	whois(domain,'us');
	whois(domain,'name');
	whois(domain,'in');
	whois(domain,'com.vn');
	whois(domain,'net.vn');
	whois(domain,'org.vn');
	whois(domain,'info.vn');
	whois(domain,'biz.vn');
	whois(domain,'gov.vn');
	whois(domain,'name.vn');
	whois(domain,'vn');
}
function showdetail(ext) {
	if(detail_array[ext]==undefined)
		detail_array[ext]='Unknown at this time, please check it late.';
	document.getElementById('detail').innerHTML = '<table align="center"><tr><td align="center"><font size="4">Whois '+domname+'.'+ext+'</font></td></tr><tr><td><pre>'+detail_array[ext]+'</td></tr></table></pre>';
}

