﻿
		//fullpath = "http://localhost/app/chaccu/www62";
		httpRequest = new Object();

		function getServerName()
		{
			var str = window.location.protocol + '//' + window.location.hostname;
			return str;
		}
		
		function checkDomain( domainName, domainExt, domainR, domainID, loadingImage, showWhois, tableID ) {
			//  var url =  "http://localhost/www/app/whois/toras-whois/index.php?searchDomainName=AA&searchDomainExt=com&formSubmit=Check+domain&doAction=checkDomain";
			var url	= getServerName() + "/ffibovodich/checkvn.php?domain=" + domainName + "&exts=" + domainExt + "&id=" + tableID + "&dmroot=" + domainR;
			
   			//alert(url);
			var showDomainID = document.getElementById( domainID );
			showDomainID.innerHTML	= "<img src=\"" + loadingImage + "\" alt=\"Loading\" />";

			if ( url != 0 ) {

				if ( window.ActiveXObject ) {
					httpRequest[domainID] = new ActiveXObject("Microsoft.XMLHTTP");
				} else {
					httpRequest[domainID] = new XMLHttpRequest();
				}
				httpRequest[domainID].open("GET", url, true);

				httpRequest[domainID].onreadystatechange	= function () { processRequest( domainID, domainName, domainExt, showWhois ); } ;
				httpRequest[domainID].send(null);

			} else {
				document.getElementById(domainID).innerHTML = "";
			}

		}


		function processRequest( domainID, domainName, domainExt, showWhois ) {
			if ( httpRequest[domainID].readyState == 4 ) {
				if( httpRequest[domainID].status == 200 ) {
					var showDomainID	= document.getElementById( domainID );
					//var showDomainStatus	= document.getElementById( domainStatus );
					//alert(httpRequest[ domainName ].responseText);

					if ( httpRequest[ domainID ].responseText.indexOf('OK') >= 0 ) {
						//showDomainStatus.innerHTML	= "<div style=\"color:#00CC00 \">Chưa được đăng ký</div>";
						showDomainID.innerHTML		= "-";
					} else if ( httpRequest[ domainID ].responseText.indexOf("ERROR_101") >= 0 ) {
						//showDomainStatus.innerHTML	= "<div style=\"color:#FF0000 \">Đã bị đăng ký</div>";
						showDomainID.innerHTML		= "<a  href=\"javascript: showDomainWhois( '" + domainName + "." + domainExt + "' );\" style=\"color:#FF0000 \" >" + showWhois + "</a>";
					} else if ( httpRequest[ domainID ].responseText.indexOf("SERV_BUSY") >= 0 ) {
						//showDomainStatus.innerHTML	= "<div style=\"color:#FF0000 \">Server Busy!</div>";
						showDomainID.innerHTML		= "Server busy";
					} 
					else {
						//showDomainStatus.innerHTML	= "-";
						showDomainID.innerHTML		= "&nbsp;";
					}
				} else {
					alert( "Server Error \n"+ httpRequest[domainID].status +":"+ httpRequest[domainID].statusText );
				}
			}

		}
		/*function showDomainWhois( domainName, domainExt ) {
			window.open( "http://fibovietnam.com/ffibovodich/vnwhois.php?domain=" + domainName + domainExt, "whoisInfo", "width=500,height=600,left=50,top=50,scrollbars=1" );
		}*/