var abxs = window.location.hostname;
if (abxs == "localhost")
{
	var tb_pathToFile="http://"+abxs+"/Economicalhost-2010/check_domain_ajax.php";
	var tb_pathToFile_add="http://"+abxs+"/Economicalhost-2010/add_domain_ajax.php";
	var tb_pathToFile_demo="http://"+abxs+"/Economicalhost-2010/add_domain_demo_ajax.php";
	var tb_pathDomToFile_del="http://"+abxs+"/Economicalhost-2010/delete_domain_ajax.php";
	var tb_rj_add="http://"+abxs+"/Economicalhost-2010/registrar_ajax.php";
	var tb_pathToImage="http://"+abxs+"/Economicalhost-2010/js/check_domain.gif";
	var tb_pathLoToImage="http://"+abxs+"/Economicalhost-2010/js/check_domain.gif";
} else {
	var tb_pathToFile="http://"+abxs+"/check_domain_ajax.php";
	var tb_pathToFile_add="http://"+abxs+"/add_domain_ajax.php";
	var tb_pathToFile_demo="http://"+abxs+"/add_domain_demo_ajax.php";
	var tb_pathDomToFile_del="http://"+abxs+"/delete_domain_ajax.php";
	var tb_rj_add="http://"+abxs+"/registrar_ajax.php";
	var tb_pathToImage="http://"+abxs+"/js/check_domain.gif";
	var tb_pathLoToImage="http://"+abxs+"/js/check_domain.gif";
}

function createObjectxmax() {
var request_typexmax;
var browserxmax = navigator.appName;
if(browserxmax == "Microsoft Internet Explorer"){
request_typexmax = new ActiveXObject("Microsoft.XMLHTTP");
}else{	
request_typexmax = new XMLHttpRequest();
}
return request_typexmax;
}
var http = createObjectxmax();
var nocachealls = 0;
function check_ext() {
	// Optional: Show a waiting message in the layer with ID login_response
	document.getElementById('display_domain').innerHTML = "<img src='"+tb_pathToImage+"' border='0'>";	
	// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.	
	var option_a= encodeURI(document.getElementById("domain").value);
	var option_b= encodeURI(document.getElementById("ext").value);
	var option_c= encodeURI(document.getElementById("option").value);
	//var option_d1= encodeURI(document.getElementById("registrar1").value);
	
	radios = document.getElementsByName("registrar");
    for (i = 0; i < radios.length; i++) {
        if (radios[i].checked) {
			var option_d2 = radios[i].value;
		}
    }
	// Set te random number to add to URL request
	nocachealls = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_pathToFile+'?option_aa='+option_a+'&option_bb='+option_b+'&option_cc='+option_c+'&option_dm='+option_d2+'&nocachealls='+nocachealls);
	http.onreadystatechange = insertReplyalls;
	http.send(null);
}
function insertReplyalls() {
	if(http.readyState == 4){
		var responsealls = http.responseText;
		//alert(responsealls);
		// else if login is ok show a message: "Site added+ site URL".
		document.getElementById('display_domain').innerHTML = ''+responsealls;
	}	
}

var nocachenhys = 0;
function add_cart_domain(domain, ext, sample) {	
	// Optional: Show a waiting message in the layer with ID login_response	
	document.getElementById('display_domainx').innerHTML = "<img src='"+tb_pathToImage+"' border='0'>";		
	nocachenhys = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_pathToFile_add+'?option_aa='+domain+'&option_bb='+ext+'&option_cc='+sample+'&nocachenhys='+nocachenhys);
	http.onreadystatechange = insertReplynhys;
	http.send(null);
}
function insertReplynhys() {
	if(http.readyState == 4){
		var responsenhys = http.responseText;
		// else if login is ok show a message: "Site added+ site URL".
		//document.getElementById('display_domainx').innerHTML = ''+responsenhys;
		jQuery(document).ready(function($) {
			jQuery.facebox(responsenhys);
		})
	}	
}
var noncacheksa = 0;
function delete_dom(delid){
	document.getElementById('imgloading').innerHTML = "<img src='"+tb_pathLoToImage+"' border='0'>";	
	noncacheksa = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_pathDomToFile_del+'?tickdelid='+delid+'&noncacheksa='+noncacheksa);
	http.onreadystatechange = insertReplyksa;
	http.send(null);
}
function insertReplyksa() {
	if(http.readyState == 4){
		var responseksa = http.responseText;		
		var klit = responseksa.split("^");
		var mlay = klit[0];	
		var idlay = klit[1];
		// else if login is ok show a message: "Site added+ site URL".
		//document.getElementById('display_domainx').innerHTML = ''+responseksa;
		jQuery(document).ready(function($) {
			jQuery.facebox(mlay);
		});
		document.getElementById("domId_"+idlay).innerHTML = "";
	}	
}

var nocachevbnc = 0;
function change_ext_option(type) {	
	// Optional: Show a waiting message in the layer with ID login_response	
	document.getElementById('extensions_open').innerHTML = "wait...";		
	nocachevbnc = Math.random();
	// Pass the login variables like URL variable
	http.open('get', tb_rj_add+'?ttype='+type+'&nocachevbnc='+nocachevbnc);
	http.onreadystatechange = insertReplyvbnc;
	http.send(null);
}
function insertReplyvbnc() {
	if(http.readyState == 4){
		var responsevbnc = http.responseText;
		document.getElementById('extensions_open').innerHTML = ""+responsevbnc;
	}	
}


var nocachekawq = 0;
function add_cart_demo(domain, ext, vid) {	
	// Optional: Show a waiting message in the layer with ID login_response
	document.getElementById('checkingnadding'+vid).innerHTML = "<img src='"+tb_pathToImage+"' border='0'>";		
	nocachekawq = Math.random();
	// Pass the login variables like URL variable
	http.open("get", tb_pathToFile_demo+"?option_aa="+domain+"&option_bb="+ext+"&vcid="+vid+"&nocachekawq="+nocachekawq);
	http.onreadystatechange = insertReplykawq;
	http.send(null);
}
function insertReplykawq() {
	if(http.readyState == 4){
		var responsekawq = http.responseText;
		var jklit = responsekawq.split("^");
		var mlcay = jklit[0];	
		var idlcay = jklit[1];
		// else if login is ok show a message: "Site added+ site URL".
		//document.getElementById('display_domainx').innerHTML = ''+responsekawq;
		jQuery(document).ready(function($) {
			jQuery.facebox(mlcay);
		});
		document.getElementById("checkingnadding"+idlcay).innerHTML = "<span style='color:#ffffff;'>Item added</span>";
	}	
}
