 function changeFromCity(fromCityId){
		//var fromCityId=e.value;
		netRouteDealAjax.changeToCity(fromCityId,function(reply){
		result = reply;
		//alert("length="+result.length);
		if(typeof(result)== "object" && result!= null){
			var oSelect = document.getElementById("city");
			 oSelect.options.length=0;
			for(var i = 0; i<result.length; i++){
				 	oSelect.options[i] = new Option (result[i][1],result[i][0]);
			}
		}else{
			alert("找不到相关图片数据，请联系管理员！");
		}			
	});
	}
	window.addEvent('domready', function() { 
			myCal3 = new Calendar({ bookTimeFrom: 'Y-m-d' }, { direction:0, tweak: {x: 4, y: 0} });
	});
	function initRunMeta(){
		var fromcity=E("fromcity").value;
		var tocity=E("city").value;
		if(fromcity==''){
			alert("出发城市");
			return false;		
		}
		E("loginForm:fromCityZone").value=fromcity;
		
		if(tocity==''){
			alert("出发城市");
			return false;		
		}
		E("loginForm:toCityId").value=tocity;
		var bookTimeFrom=document.getElementById("bookTimeFrom").value;
		var currencyId=document.getElementsByName("loginForm:currency_id");
		var check=false;
		for(i=0,len=currencyId.length;i<len;i++){
			if(currencyId[i].checked){
				check=true;
			}
		}
		if(check==false){
			alert("请选择支付币种！");
			return false;		
		}
		var onstatonId=E("on_statiion").value;
		var offstatonId=E("off_statiion").value;
		if(onstatonId==''){
			alert("上站点");
			return false;		
		}
		if(offstatonId==''){
			alert("下站点");
			return false;		
		}
		E("loginForm:onStationId").value=onstatonId;
		E("loginForm:offStationId").value=offstatonId;
		if(bookTimeFrom==''){
			alert("请选择日期！");
			return false;		
		}
		document.getElementById("loginForm:selectRunDate").value=bookTimeFrom;
		document.getElementById("loginForm:selectRunTime").value=document.getElementById("pre_selectRunTime").value;
		
		var tt=document.getElementsByName("trip_type_html");
		var jj=0;
		for(j=0;j<tt.length;j++){
			if(tt[j].checked&&tt[j].disabled==false){
				jj=jj+1;
				E('loginForm:trip_type').value=tt[j].value;
			}
		}
		if(jj==0){
			alert("请选择方式！");
			return false;	
		}
	}
	function initRunMeta_login(){
		var fromcity=E("fromcity").value;
		var tocity=E("city").value;
		if(fromcity==''){
			alert("出发城市");
			return false;		
		}
		E("loginForm:fromCityZone").value=fromcity;
		
		if(tocity==''){
			alert("出发城市");
			return false;		
		}
		E("loginForm:toCityId").value=tocity;
		var bookTimeFrom=document.getElementById("bookTimeFrom").value;
		var onstatonId=E("on_statiion").value;
		var offstatonId=E("off_statiion").value;
		if(onstatonId==''){
			alert("上站点");
			return false;		
		}
		if(offstatonId==''){
			alert("下站点");
			return false;		
		}
		E("loginForm:onStationId").value=onstatonId;
		E("loginForm:offStationId").value=offstatonId;
		if(bookTimeFrom==''){
			alert("请选择日期！");
			return false;		
		}
		document.getElementById("loginForm:selectRunDate").value=bookTimeFrom;
		document.getElementById("loginForm:selectRunTime").value=document.getElementById("pre_selectRunTime").value;
		
		var tt=document.getElementsByName("trip_type_html");
		var jj=0;
		for(j=0;j<tt.length;j++){
			if(tt[j].checked&&tt[j].disabled==false){
				jj=jj+1;
				E('loginForm:trip_type').value=tt[j].value;
			}
		}
		if(jj==0){
			alert("请选择方式！");
			return false;	
		}
	}
	
	function   diffhours(arr1 ,arr2)  
  {  				/*
  				var arr1= new Array();
				arr1[0]=yStr;
				arr1[1]=mStr;
				arr1[2]=dStr;
				arr1[3]=hourStr;
				arr1[4]=minStr;
				arr1[5]="00";
				var arr2=new Array();;
				var selet_time_arr=selectTimearray[0].split(':');
				arr2[0]=yStr;
				arr2[1]=mStr;
				arr2[2]=dStr;
				arr2[3]=selet_time_arr[0];
				arr2[4]=selet_time_arr[1];
				arr2[5]="00";
				var hour_inteval=diffhours(arr1,arr2);
				alert("hour_inteval=="+hour_inteval);*/
          //var   date1=document.all("stime").value;//stime值为("2005-1-10   8:00:00")  
          //var   date2=document.all("etime").value;//etime值为("2005-1-11   8:00:00")  
          //var   date1="2009-02-11 8:00:00";//stime值为("2005-1-10   8:00:00")  
          //var   date2="2009-02-11 9:20:00";//etime值为("2005-1-11   8:00:00")  
          var   oldtime=new Date(arr1[0],arr1[1],arr1[2],arr1[3],arr1[4],arr1[5]);  
          var   newtime=new   Date(arr2[0],arr2[1],arr2[2],arr2[3],arr2[4],arr2[5]);  
          var   diff   =(newtime   -   oldtime)/(1000*3600)   ;//得到毫秒差，换算成小时就可以了  
          var   hours=parseInt(diff,10);  
          return hours;
        //  alert(hours);  
  }   
/*$(document).ready(function() {
			var l=document.getElementsByName("city_choose");
			if(selectRouteId==11){
					for(i=0;i<l.length;i++){
						if(l[i].value=='hk'){
							l[i].checked=true;
						 }else{
						 	l[i].checked=false;
						 }
					}
			 }else {
				 	for(i=0;i<l.length;i++){
						if(l[i].value=='sz'){
							l[i].checked=true;
						 }else{
						 	l[i].checked=false;
						 }
					}
			}
			var l=document.getElementById("pre_selectRunTime");
			if(l!=null){
				for(i=0;i<l.length;i++){
					if(l.options[i].value==_selectTime){
						l[i].selected=true;
					}
				}
			}
		});
*/
/*
$(document).ready(function() {
			
			var l=document.getElementsByName("city_choose");
			if(selectRouteId==11){
					for(i=0;i<l.length;i++){
						if(l[i].value=='hk'){
							l[i].checked=true;
						 }else{
						 	l[i].checked=false;
						 }
					}
			 }else {
				 	for(i=0;i<l.length;i++){
						if(l[i].value=='sz'){
							l[i].checked=true;
						 }else{
						 	l[i].checked=false;
						 }
					}
			}
			var l=document.getElementById("pre_selectRunTime");
			if(l!=null){
				for(i=0;i<l.length;i++){
					if(l.options[i].value==_selectTime){
						l[i].selected=true;
					}
				}
			}
			
		
			var trip_type=document.getElementsByName('loginForm:trip_type');
			//alert("length=="+trip_type.length);
			for(i=0;i<trip_type.length;i++){
				if(trip_type[i].checked){
					if(trip_type[i].value=='round_trip_ticket'){
						document.getElementById('back_tr').style.display='';
						document.getElementById('back_div_height').style.display='';
					}
				}
			}
		});
	*/	
		
function setTripType(Object){
	var trip_type=Object.value;
	if(trip_type=='one_way'){
		document.getElementById('back_tr').style.display='none';
		document.getElementById('back_div_height').style.display='none';
	}else{
		document.getElementById('back_tr').style.display='';
		document.getElementById('back_div_height').style.display='';
	}

}	

$(document).ready(function() { 
		E('fromcity').value=selectFromZoneIdStr;
		changeFromCity(E('fromcity'));
		E('city').value=selectToCityZoneIdStr;
		changeToCity(E('city'));
		//changeToCity(E('city'));
		if(onStationIdStr!=null)
			E("on_statiion").value=onStationIdStr;
		if(offStationIdStr!=null)
			E("off_statiion").value=offStationIdStr;
		if(trip_type!=null){
			var tt=document.getElementsByName("trip_type_html");
			for(j=0;j<tt.length;j++){
				if(tt[j].value==trip_type){
					tt[j].checked=true;
				}
			}
		}
		controltripType();
		
	});
	function changeFromCity(obj){ 
			var currentValue = obj.value;
			city = E("city");
			city.options.length=0;
			for(j=0,k=0;j<toCityId.length;j++){
				if(currentValue == belongFromCityId[j] && (toCityId[j]==1 ||toCityId[j]==2||toCityId[j]==56||toCityId[j]==52)){			
					city.options[k] = new Option (toCityName[j],toCityId[j]);
					if(k == 0)
						city.options[k].selected = true;
					k++;
				}
			}
			//随动上站点
			on_statiion = E("on_statiion");
			on_statiion.options.length=0;
			off_statiion = E("off_statiion");
			off_statiion.options.length=0;
			var m=0;
			var on_has_set=false;
			var off_has_set=false;
			for(j=0,k=0,l=0;j<routeVsStationId.length;j++){
				
				for(i=0;i<stationCityId.length;i++){
					//上站点
					//if(on_has_set==false){
						if(currentValue==routeVsStationFromcityId[j]&&city.value==routeVsStationTocityId[j]
							&&currentValue == stationCityId[i]&&stationId[i]==routeVsStationId[j]){
								on_statiion.options[k] = new Option (stationName[i],stationId[i]);
								if(k == 0)
									on_statiion.options[k].selected = true;
								k++;
							
						}
					//}
					
					//下站点
					//if(off_has_set==false){
						if(currentValue==routeVsStationFromcityId[j]&&city.value==routeVsStationTocityId[j]
							&&city.value == stationCityId[i]&&stationId[i]==routeVsStationId[j]){
								off_statiion.options[l] = new Option (stationName[i],stationId[i]);
								if(l == 0)
									off_statiion.options[l].selected = true;
								l++;
							
						}
					//}
				}
			}
			
			controltripType();	
			
		}	
		function changeToCity(obj){
			var city = obj;
			//alert("city.value=="+city.value);
			currentValue = E('fromcity').value;
			//alert("currentValue=="+currentValue);
		//随动上站点
			on_statiion = E("on_statiion");
			on_statiion.options.length=0;
			off_statiion = E("off_statiion");
			off_statiion.options.length=0;
			var m=0;
			for(j=0,k=0,l=0;j<routeVsStationId.length;j++){
				for(i=0;i<stationCityId.length;i++){
					//上站点
					if(currentValue==routeVsStationFromcityId[j]&&city.value==routeVsStationTocityId[j]
						&&currentValue == stationCityId[i]&&stationId[i]==routeVsStationId[j]){
							on_statiion.options[k] = new Option (stationName[i],stationId[i]);
							if(k == 0)
								on_statiion.options[k].selected = true;
							k++;
						
					}
					
					//下站点
					if(currentValue==routeVsStationFromcityId[j]&&city.value==routeVsStationTocityId[j]
						&&city.value == stationCityId[i]&&stationId[i]==routeVsStationId[j]){
							off_statiion.options[l] = new Option (stationName[i],stationId[i]);
							if(l == 0)
								off_statiion.options[l].selected = true;
							l++;
						
					}
				}
			}
			
			//control 单双程
			/*if(off_statiion.value=='102' ||off_statiion.value=='1' ||off_statiion.value=='5' ){
				E("nocoupon").display='';
				E("havecoupon").display='none';
			}else{
				E("nocoupon").display='none';
				E("havecoupon").display='';
			}*/
			controltripType();
	}		
	
/*	function controltripType(){
			var off_statiion = E("off_statiion");
			if(off_statiion.value=='4' ||off_statiion.value=='102' ||off_statiion.value=='1' ||off_statiion.value=='5' ){
				E("nocoupon").style.display='';
				//document.getElementById("iu_control").removeChild(E("havecoupon"));
				E("havecoupon").style.display='none';
			}else{
				E("nocoupon").style.display='none';
				//document.getElementById("iu_control").removeChild(E("nocoupon"));
				E("havecoupon").style.display='';
			}
	}*/
	
	function controltripType(){
			var off_statiion = E("off_statiion");
			if(off_statiion.value=='4' ||off_statiion.value=='102' ||off_statiion.value=='1' ||off_statiion.value=='5' ){
				//E('shuang').disabled=true;
				var tt=document.getElementsByName("trip_type_html");
				for(j=0;j<tt.length;j++){
					if(tt[j].value=='round_trip_ticket'){
						tt[j].disabled=true;
					}
				}
			}else{
				var tt=document.getElementsByName("trip_type_html");
				for(j=0;j<tt.length;j++){
					if(tt[j].value=='round_trip_ticket'){
						tt[j].disabled=false;
					}
				}
			}
	}