
function readxml(){ 
	var xmlDoc = loadXML(getContextPath()+"/pages/2008/js/realXML/orgcity.xml");
	var root = xmlDoc.documentElement;  // 根节点
	var childNodes = root.getElementsByTagName("city");
	var html="<select onChange='selectOrgCity(this.value)' id='flightConditionEntity.orgCity1' name='flightConditionEntity.orgCity1'>";
	for(var i=0;i<childNodes.length;i++){
		var selected="";	   
		var cityInfo=childNodes[i].firstChild.nodeValue;
		var city=cityInfo.split(";");
		if(city[0]=='SZX'){
	    selected=" selected";
	   }
		html += "<option value='"+city[0]+";"+city[1]+"'"+selected+">" + city[1] + "</option>";
	}
	html+="</select>";
	//document.getElementById("OrgCity").innerHTML=html;
	dwr.util.setValue("OrgCity", html,{ escapeHtml:false });
	dwr.util.setValue("startCity", html,{ escapeHtml:false });
	selectOrgCity("SZX");
}


function selectOrgCity(cityInfo){
	var orgcity=cityInfo.split(";")[0];
	var xmlDoc = loadXML(getContextPath()+"/pages/2008/js/realXML/dstCity.xml");
	var root = xmlDoc.documentElement;  // 根节点
	var childNodes = root.getElementsByTagName("city");
	var html="<select id='flightConditionEntity.dstCity0' name='flightConditionEntity.dstCity0'>"
	for(var i=0;i<childNodes.length;i++){
	var orgcityInfo=childNodes[i].getElementsByTagName("o");
		for(var j=0;j<orgcityInfo.length;j++){
			if(orgcityInfo[j].firstChild.nodeValue==orgcity){
				var dstCity=childNodes[i].getElementsByTagName("d");
				for(var p=0;p<dstCity.length;p++){
				var selected="";
				var dstCityInfo=dstCity[p].firstChild.nodeValue.split(";");
					if(orgcity=='SZX'&&dstCityInfo[0]=='PEK'){
	    			selected=" selected";
	   				}
					html += "<option value='"+dstCityInfo[0]+";"+dstCityInfo[1]+";"+dstCityInfo[2]+"'"+selected+">" + dstCityInfo[1] + "</option>";
				}
			}
		}
	}
	html+="</select>";
	//document.getElementById("DstCity").innerHTML=html;
	dwr.util.setValue("DstCity", html,{ escapeHtml:false });
	dwr.util.setValue("endCity", html,{ escapeHtml:false });
}

function loadXML(xmlFile) {
        var xmlDoc;
        if (window.ActiveXObject) {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.load(xmlFile);
        }
        else if (document.implementation && document.implementation.createDocument) {
            xmlDoc = document.implementation.createDocument("", "", null);
            xmlDoc.async = false;
            xmlDoc.load(xmlFile);
        } else {
            alert('您的浏览器不支持该系统脚本！');
        }
        return xmlDoc;
    } 
    
    //取得主机路径名(注意：只适合机票预订)
	function getContextPath(){
		var contextPath = window.location.href; 
		var position = contextPath.indexOf("common/");
		if(position == -1){
			position = contextPath.indexOf("module/");
		}
		return contextPath.substr(0, position - 1);
	} 