function passDomain(n,x,h) {//n=domain name; x=domain extension (.com, .net, etc); h=host path
	var ex=new Array(".com",".net",".biz",".org",".info");
	var isWhois={'com':'whois.crsnic.net','net':'whois.crsnic.net','biz':'whois.biz','org':'whois.pir.org','info':'whois.afilias.net'};
	var isKeyword={'com':'No match for','net':'No match for','biz':'Not found','org':'NOT FOUND','info':'NOT FOUND'};
	var isDom=document.getElementById(n).value;
	var isEx=document.getElementById(x).value;
	for(var e=0;e<ex.length;e++) {
		if(isDom.indexOf(ex[e])!=-1) {
			var brkDom=isDom.split(ex[e]);
			isDom=brkDom[0];
			document.getElementById(n).value=isDom;
			delete brkDom;
			break;
		}
	}
	var fullDomain=isDom+"."+isEx;
	checkDom(h,fullDomain,isWhois[isEx],isKeyword[isEx]);
}
function newSearch() {
	document.getElementById('domainCheckDiv').style.display="block";
	document.getElementById('domainResultDiv').style.display="none";
	document.getElementById('domainResultDiv').innerHTML="";
}
var gotDomain="";
function checkDom(h,ds,ss,sk) {//h=host path; ds=domain to search; ss= whois service to scan; sk=search keyword/phrase
    try{
		rq.abort();
	}catch(er) {
		//
	}
	var rq=null;
    if(window.XMLHttpRequest) {
        rq=new XMLHttpRequest();
    }else if(window.ActiveXObject) {
        try {
            rq=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (er) {
            try {
                rq=new ActiveXObject("Microsoft.XMLHTTP");
            }catch (er) {
                alert("It appears your Internet Explorer has ActiveX disabled or is not supported.\nPlease enable your ActiveX or update your Internet Explorer to a version that supports it.");
                return false;
            }
        }
    }else{
        alert("It appears your browser does not support the XMLHttpRequest or ActiveX.\nTo utilize this option, please use a browser with one of the support.");
        return false;
    }
    h=(h=="hosting.freelancerlisting.net" ? h : h+"/hosting");
    var theURL="http://"+h+"/modules/domain_checker.php";
    var params="domainsearch="+ds+"&searchserver="+ss+"&searchkey="+sk;
    rq.open('POST',theURL,true);
    rq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    rq.setRequestHeader("Content-Length",params.length);
    rq.setRequestHeader("Connection","close");
    //
    rq.onreadystatechange=function() {
        if(rq.readyState==4) {
            if(rq.status==200) {
                myInfo=rq.responseText;
                if(myInfo!="") {
                	document.getElementById('domainResultDiv').innerHTML=(myInfo=="failed-connection" ? "Service is currently not available" : "Domain '"+ds+"'<br />is "+myInfo+(myInfo=="Available" ? "<br />&nbsp;<input type=\"button\" name=\"secure_domain\" id=\"secureDomain\" value=\"Secure this domain\" onclick=\"saveDomain(this);\" class=\"mt5 floatR px11\" />" : "")+"&nbsp;<input type=\"button\" name=\"new_dom_search\" value=\"new search\" class=\"mt5 floatR px11\" onclick=\"newSearch();\" />");
                	if(myInfo=="Available") {
                        gotDomain=ds;
                    }
                }
            }else{
            	try{
            		rq.abort();
            	}catch(er) {
            		//
            	}
            	checkDom(h,ds,ss,sk);
            }
        }else{
        	document.getElementById('domainCheckDiv').style.display="none";
        	document.getElementById('domainResultDiv').style.display="block";
        	document.getElementById('domainResultDiv').innerHTML="<img src=\"images/icon_loading.gif\" border=\"0\" class=\"valignM\" /> &nbsp; Please wait while I do a search...";
        }
    }
    rq.send(params);
}
//WHEN DOMAIN IS SEARCHED AND 'SECURED'
function saveDomain(t) {
    window.location.replace("hostingplans.php?secure="+gotDomain);
}