﻿var http_request = false;
function send_request(url,method) {
http_request = false;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/text');
}
}
else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
url1="/js/city1.asp?t="+url;
//alert(url1);
http_request.onreadystatechange = function () {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//document.getElementById("statusTxt").innerHTML="<a href=/q target=_blank>如想问路,可以去问吧留言!</a>";
addOptionGroup(method,http_request.responseText);
} else {
alert("您所请求的页面有异常。");
}
}else {
//document.getElementById("statusTxt").innerHTML="数据读取中……";
}
}
http_request.open("GET", url1, true);
http_request.send(null);
}

function loadCity(sel,ob1,ob2) {
document.getElementById(ob2).value="";
send_request(sel,ob1);
}

function cha1() {
if(document.getElementById('q4').value =="")
    {
    alert("请输入站点名称！");
    document.getElementById('q4').focus();
    return false;
    }
//window.location.href="resultz.asp?k=p&txtChezhan="+document.getElementById('q4').value;
window.open("resultz.asp?k=p&txtChezhan="+document.getElementById('q4').value,"_blank");
}
function cha2() {
if(document.getElementById('q1').value =="")
    {
    alert("请输入路线名称！");
    document.getElementById('q1').focus();
    return false;
    }
//window.location.href="resultc.asp?k=pp&txtCheCi="+document.getElementById('q1').value;
window.open("resultc.asp?k=pp&txtCheCi="+document.getElementById('q1').value,"_blank");
}
function cha3() {
if(document.getElementById('q2').value =="")
    {
    alert("请输入起点名称！");
    document.getElementById('q2').focus();
    return false;
    }
    if(document.getElementById('q3').value =="")
    {
    alert("请输入终点名称！");
    document.getElementById('q3').focus();
    return false;
    }
        if(document.getElementById('q3').value == document.getElementById('q2').value)
    {
    alert("起点名称和终点名称不允许相同！");
    document.getElementById('q3').focus();
    return false;
    }
//window.location.href="result.asp?k=p2p&txtChuFa="+document.getElementById('q2').value+"&txtDaoDa="+document.getElementById('q3').value;
window.open("result.asp?k=p2p&txtChuFa="+document.getElementById('q2').value+"&txtDaoDa="+document.getElementById('q3').value,"_blank");
}
function inputDistrict(ob1,ob2,ob3) {
	if(ob1=='ct1')
	{
document.getElementById(ob1).value=ob3.options[document.getElementById(ob2).value].text.substr(1)
	}
	else
	{
document.getElementById(ob1).value=ob3.options[document.getElementById(ob2).value].text
//document.getElementById(ob1).value=document.getElementById(ob2).value
	}
document.getElementById(ob1).focus();
}

function hc(pid)
{
if(event.keyCode==13)
{
switch (pid){case 1: cha1(); break; case 2: cha2(); break; case 3: cha3(); break;}
}
}
function addOption(objSelectNow,txt,val)
{
var objOption = document.createElement("OPTION");
objOption.text= txt;
objOption.value=val;
objSelectNow.options.add(objOption);
}
function addOptionGroup(selectId,optGroupString)
{
var optGroup = optGroupString.split(",");
var objSelect = document.getElementsByTagName("SELECT");
var objSelectNow = objSelect[selectId];
objSelectNow.length = 1;
for (i=1; i<optGroup.length; i++)
{
addOption(objSelectNow, optGroup[i], i);
//addOption(objSelectNow, optGroup[i], optGroup[i]);
}
}

//if (top.location != self.location) { top.location=self.location; }