function CreateHTTPObject(){
    var xmlhttp;
    
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp = false;
        }
    }
    
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e) {
            xmlhttp=false;
        }
    }
    
    if (!xmlhttp && window.createRequest) {
        try {
            xmlhttp = window.createRequest();
        }
        catch (e) {
            xmlhttp=false;
        }
    }
    
    return xmlhttp;
}

function OnReadyStateChng(res,xmlhttp) {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            res.innerHTML = xmlhttp.responseText;
        }
        else {
            alert("HTTP ´íÎó,´íÎó´úÂë:" + xmlhttp.status);
        }
    }else{
		res.innerHTML = "<img class=loading src=/images/loading.gif>";
	}
}

function search_pos(val,pos,res){
	res.style.display='block';
	start_pos(val,'baidu',$('baidu'));
	start_pos(val,'google',$('google'));
	start_pos(val,'sogou',$('sogou'));
	start_pos(val,'yahoo',$('yahoo'));
	
}

function search_pr(val,pos,res){
	res.style.display='block';
	start_pos(val,'toolbarqueries.google.com',$('pr_1'));
	start_pos(val,'64.233.161.104',$('pr_2'));
	start_pos(val,'72.14.253.99',$('pr_3'));
	start_pos(val,'64.233.187.99',$('pr_4'));
	start_pos(val,'59.151.21.100',$('pr_5'));
	start_pos(val,'66.102.11.104',$('pr_6'));
}

function start_pos(val,pos,res){
	res.innerHTML='';
	res.style.display='block';
	
	var xmlhttp = CreateHTTPObject();
	xmlhttp.open("POST", 'include/query.php', true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange = function () { OnReadyStateChng(res,xmlhttp);};
	xmlhttp.send('value='+val+'&action='+pos);
	var sna=res.parentNode.parentNode.getElementsByTagName('A')[1] || res.parentNode.parentNode.parentNode.getElementsByTagName('A')[1] || res.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('A')[1];
	sna.style.display='';
}
