var actionPage="company_domain.php";

function getChildNodes(objContainer){
	var returnValue=new Array();
	for(counter=0;counter<objContainer.childNodes.length;counter++){
		if(objContainer.childNodes[counter].tagName!=undefined){
			returnValue.push(objContainer.childNodes[counter]);
		}
	}
	return returnValue;
}


function domain_query(){
//        var errs=new Array();
//        errs.push(check_custom_domain_name());
//        errs.push(check_rdomain_select());
	var errorCodes="";
//        errorCodes=implode(",",errs);
//        domain_request_info.custom_domain_name=encodeURIComponent($("txt_custom_domain_name").value.trim());

        if(errorCodes==""){
                var varObjs=new Array(
						"txt_custom_domain_name",
						"rdomain[]"
                                                );
                /* 开始提交数据 */
                $("btn_query").disabled=true;
                new Ajax.Request(actionPage, {
                        method: 'post',
                        parameters:"action=query_domain&"+assembleParam(varObjs),
                        onSuccess: function(transport) {
				query_result=eval(transport.responseText);
//                                show_available_domain();
				$("btn_query").disabled=false;
				$("domain_result_panel").style.display="none";
				$("topic_1").style.display="none";
				$("img_s_1").style.display="none";
				$("img_c_1").style.display="block";
				var lst_query_result=$("lst_query_result");
				var firstChildFound=false;
				for(counter=0;counter<lst_query_result.childNodes.length;counter++){
					if(lst_query_result.childNodes[counter].tagName!=undefined && firstChildFound){
						lst_query_result.removeChild(lst_query_result.childNodes[counter]);
						counter--;
					}
//					alert(lst_query_result.childNodes[counter].tagName);
					if(lst_query_result.childNodes[counter].tagName!=undefined){
						firstChildFound=true;
// 						alert("only once");
					}
				}
// 				alert("Hello world");
				for(counter=0;counter<query_result.length;counter++){
					var new_row=document.createElement("tr");
					var new_cell=document.createElement("td");
					new_cell.setAttribute("align","left");
					new_cell.style.cssText="border-bottom: 1px solid rgb(204, 226, 241);";
					new_cell.innerHTML=$("txt_custom_domain_name").value+query_result[counter].rdomain;
					new_row.appendChild(new_cell);
					var new_cell=document.createElement("td");
					new_cell.setAttribute("align","center");
					new_cell.style.cssText="border-bottom: 1px solid rgb(204, 226, 241);";
					new_cell.innerHTML=query_result[counter].amount==0?"--":query_result[counter].amount;
					new_row.appendChild(new_cell);
					
//					new_row.innerHTML="<td align=\"left\" style=\"border-bottom: 1px solid rgb(204, 226, 241);\">"+$("txt_custom_domain_name").value+query_result[counter].rdomain+"</td><td align=\"center\" style=\"border-bottom: 1px solid rgb(204, 226, 241);\">"+(query_result[counter].amount==0?"已注册":query_result[counter].amount)+"</td>";
//					alert(new_row.innerHTML);
					$("lst_query_result").appendChild(new_row);
				}
				$("domain_result_panel").style.display="block";
				$("topic_1").style.display="block";
				$("img_s_1").style.display="block";
				$("img_c_1").style.display="none";
//                                $("btn_register").disabled=false;
			}
		});
		return true;
	}

	guide(errorCodes);
	return false;
}
