﻿
	 	//首页 机票查询验证
	  function checkAirFormIndex(theForm){
	 		var journey_type = theForm.journey_type.value;
	 		if(journey_type == '1'){//单程
	 			return single(theForm);
	 		} else if(journey_type == '0') { //往返
	 			return double(theForm);
	 		}	else if(journey_type == '2') {//联程
	 			return trueSingle(theForm);
	 		} else {
	 			return false;
	 		}
	 	}

	 	
 	//频道首页 查询框表单验证
 	function checkAirFormTicketIndex(theForm){
 		var type = theForm.journey_type;
 		if(type != null && type.length > 0){
 			for(k = 0 ; k < type.length ; k ++){
 				if(type[k].checked){
 					if(type[k].value == 1){	//单程
 						return single(theForm);
 					} else if(type[k].value == 0){ //往返
 						return double(theForm);
 					} else if(type[k].value == 2){ //联程
 						return trueSingle(theForm);
 					}
 				}
 			}
 		}
 		
 		
 		return false;
 	}
 	
 	//查询二级页面 查询框表单验证
 	function checkAirFormSecondTicketIndex(theForm){
 		var journey_type = theForm.journey_type.value;
 		if(journey_type == '0'){//单程
 			return single(theForm);
 		} else if(journey_type == '1') { //往返
 			return double(theForm);
 		}	else if(journey_type == '2') {//联程
 			return trueSingle(theForm);
 		} else {
 			return false;
 		}
 	}


 	//单程验证
 	function single(theForm){
 		if(checkNullEle(theForm.orgairport.value)){
 		 theForm.orgairport.focus();
 			alert("请选择出发城市");
 			return false;
 		}
 		if(checkNullEle(theForm.start_date.value)){
 		 theForm.start_date.focus();
 			alert("请选择出发日期");
 			return false;
 		}
 		if(checkNullEle(theForm.dstairport.value)){
 		theForm.dstairport.focus();
 			alert("请选择目的城市");
 			return false;
 		}
 		
 		//机场是否相同判断
		if(isEqual(theForm.orgairport.value,theForm.dstairport.value)){
			alert("出发城市和目的城市不可以相同！");
			theForm.dstairport.select();
			return false;
		}
 		
		//判断是否是同一个城市的航班--------北京
		if((isEqual(theForm.orgairport.value,"北京首都") && isEqual(theForm.dstairport.value,"北京南苑")) || 
			(isEqual(theForm.orgairport.value,"北京南苑") && isEqual(theForm.dstairport.value,"北京首都"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		//--------上海
		if((isEqual(theForm.orgairport.value,"上海浦东") && isEqual(theForm.dstairport.value,"上海虹桥")) || 
			(isEqual(theForm.orgairport.value,"上海虹桥") && isEqual(theForm.dstairport.value,"上海浦东"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		
		//排除深圳到广州的航行
		
 		return true;
 	}
 	 	//往返验证
 	function double(theForm){
 		if(checkNullEle(theForm.orgairport.value)){
 		 theForm.orgairport.focus();
 			alert("请选择出发城市");
 			return false;
 		}
 		if(checkNullEle(theForm.start_date.value)){
 		theForm.start_date.focus();
 			alert("请选择出发日期");
 			return false;
 		}
 		if(checkNullEle(theForm.dstairport.value)){
 		theForm.dstairport.focus();
 			alert("请选择目的城市");
 			return false;
 		}
 		if(checkNullEle(theForm.end_date.value)){
 		theForm.end_date.focus();
 			alert("请选择返回日期");
 			return false;
 		}
 		
 		//机场是否相同判断
		if(isEqual(theForm.orgairport.value,theForm.dstairport.value)){
			alert("出发城市和目的城市不可以相同！");
			return false;
		}
		
		//判断是否是同一个城市的航班--------北京
		if((isEqual(theForm.orgairport.value,"北京首都") && isEqual(theForm.dstairport.value,"北京南苑")) || 
			(isEqual(theForm.orgairport.value,"北京南苑") && isEqual(theForm.dstairport.value,"北京首都"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		//--------上海
		if((isEqual(theForm.orgairport.value,"上海浦东") && isEqual(theForm.dstairport.value,"上海虹桥")) || 
			(isEqual(theForm.orgairport.value,"上海虹桥") && isEqual(theForm.dstairport.value,"上海浦东"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		
 		
 		return true;
 	}
 	 	//联程验证
 	function trueSingle(theForm){
 		if(checkNullEle(theForm.orgairport.value)){
 		theForm.orgairport.focus();
 			alert("请选择出发城市");
 			return false;
 		}
 		if(checkNullEle(theForm.start_date.value)){
 		theForm.start_date.focus();
 			alert("请选择出发日期");
 			return false;
 		}
 		if(checkNullEle(theForm.middleairport.value)){
 		theForm.middleairport.focus();
 			alert("请选择中转机场");
 			return false;
 		}
 		if(checkNullEle(theForm.middle_date.value)){
 		theForm.middle_date.focus();
 			alert("请选择中转日期");
 			return false;
 		}
 		if(checkNullEle(theForm.dstairport.value)){
 		theForm.dstairport.focus();
 			alert("请选择目的城市");
 			return false;
 		}
 		
 		//机场是否相同判断
		if(isEqual(theForm.orgairport.value,theForm.middleairport.value)){
			alert("出发城市和中转城市不可以相同！");
			theForm.middleairport.select();
			return false;
		} else if(isEqual(theForm.middleairport.value,theForm.dstairport.value)){
			alert("中转城市和目的城市不可以相同！");
			theForm.dstairport.select();
			return false;
		} else if(isEqual(theForm.orgairport.value,theForm.dstairport.value)){
			alert("选择联程时，出发市和目的城市不可以相同！");
			theForm.dstairport.select();
			return false;
		}
		
		//判断是否是同一个城市的航班--------北京
		if((isEqual(theForm.orgairport.value,"北京首都") && isEqual(theForm.middleairport.value,"北京南苑")) || 
			(isEqual(theForm.orgairport.value,"北京南苑") && isEqual(theForm.middleairport.value,"北京首都"))
			){
			alert("出发城市和中转城市不可以选择同一个城市的机场！");
			theForm.middleairport.select();
			return false;
		}
		//--------上海
		if((isEqual(theForm.orgairport.value,"上海浦东") && isEqual(theForm.middleairport.value,"上海虹桥")) || 
			(isEqual(theForm.orgairport.value,"上海虹桥") && isEqual(theForm.middleairport.value,"上海浦东"))
			){
			alert("出发城市和中转城市不可以选择同一个城市的机场！");
			theForm.middleairport.select();
			return false;
		}
		
		if((isEqual(theForm.middleairport.value,"北京首都") && isEqual(theForm.dstairport.value,"北京南苑")) || 
			(isEqual(theForm.middleairport.value,"北京南苑") && isEqual(theForm.dstairport.value,"北京首都"))
			){
			alert("中转城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		//--------上海
		if((isEqual(theForm.middleairport.value,"上海浦东") && isEqual(theForm.dstairport.value,"上海虹桥")) || 
			(isEqual(theForm.middleairport.value,"上海虹桥") && isEqual(theForm.dstairport.value,"上海浦东"))
			){
			alert("中转城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		
		
		if((isEqual(theForm.orgairport.value,"北京首都") && isEqual(theForm.dstairport.value,"北京南苑")) || 
			(isEqual(theForm.orgairport.value,"北京南苑") && isEqual(theForm.dstairport.value,"北京首都"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		//--------上海
		if((isEqual(theForm.orgairport.value,"上海浦东") && isEqual(theForm.dstairport.value,"上海虹桥")) || 
			(isEqual(theForm.orgairport.value,"上海虹桥") && isEqual(theForm.dstairport.value,"上海浦东"))
			){
			alert("出发城市和目的城市不可以选择同一个城市的机场！");
			theForm.dstairport.select();
			return false;
		}
		
 		
 		return true;
 	}
 	//检测元素是否为空
 	function checkNullEle(value){
 		if(value == null || "" == value){
 			return true;
 		} else {
 			return false;
 		}
 	}
 	
 	//比较两个参数是否相同
 	function isEqual(arg1,arg2){
 		if(arg1 == arg2){
 			return true;
 		} else {
 			return false;
 		}
 	}
 	
 	//没有航班的航线。如：深圳到广州、深圳到珠海、广州到珠海
 	function noExistAirLine(){
 		
 	}

