// JavaScript Document
//Ajax check url

var url = "ajax_callback.php?d=";

function chk_me() {
	//Create Temporary message
	var notationS = document.getElementById("results")
	notationS.innerHTML = '<img src="imagens/please_wait.gif"><br><font color="#0000FF" face=verdana size=1>Aguarde enquanto verificamos a disponibilidade... ';
	
	//Check domain here	
	var word_value = document.getElementById("domain").value;
	http.open("GET", url + escape(word_value), true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}

function handleHttpResponse() {
	if (http.readyState == 4) {
    	// Split the comma delimited response into an array
		var domain = document.getElementById("domain").value;
	    var results = http.responseText;
	
		//If domain is valid
		if(results == '0'){
			var is_show = '<font color="#FF0000" size=1 face=verdana><b>*** Nome de dominio inválido. ***</b></font>';
		} else {
			if(results == '1'){
				var is_show = '<font color="#000000" face=verdana size=1><b>Domínio '+domain+' disponível. <font size=1 color=#000000>Clique <a href="index.php?p=formulario_hospedagem&dominio='+domain+'">aqui</a> e continue sua solicitação.</font>';
			} else {
				var is_show = '<font color="#000000" face=verdana size=1>Não foi possível verificar se o domínio '+domain+' esta disponível. <br><font size=1 color=#000000>Clique <a href="index.php?p=formulario_hospedagem&dominio='+domain+'">aqui</a> e continue sua solicitação. Se o dominio estiver indisponível informaremos por e-mail.</font>';
			}
		}
		var notationS = document.getElementById("results")
		notationS.innerHTML = is_show;
	}
}

function getHTTPObject() { 
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
					xmlhttp = false;
				}
		}
	@else xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object 

