
 function checkSearchForm(obj,date,isFormViewSub){
 	var isRT = $$('routeTypeRT').checked;
   	if(trim(document.getElementById('departureAirport').value)==""){
    	richAlert("请输入出发地！");
	 	return false;
    }
    if(trim(document.getElementById('arrivalAirport').value)==""){
    	richAlert("请输入抵达地！");
     	return false;
    } 
   	if(trim(document.getElementById('departureAirport').value) == trim(document.getElementById('arrivalAirport').value)){
    	richAlert("出发地和抵达地不能相同");
	 	return false;
    }
    if(document.search.depDate.value==""){//判断出发日期是否为空
    	richAlert("请输入出发日期");
    	return false;
    }
	if(isRT){
		if(document.search.backDate.value==""){//判断出发日期是否为空
	    	richAlert("请输入返程日期");
	    	return false;
	    }
	}
    var d = $$("depDate").value;
    var toCompare = new Date();
    toCompare.setDate(toCompare.getDate() - 1);
    if ((new Date(d.replace(/-/g, "\/"))) < toCompare) {
        richAlert("出发日期必须大于等于今天");
        return false;
    }
    if (isRT && $$('backDate').value != "") {
        if (new Date($$('backDate').value.replace(/-/g, "\/")).getTime() < new Date($$('depDate').value.replace(/-/g, "\/")).getTime()) {
            richAlert("回程日期必须大于去程日期！")
            return false;
        }
    }
	document.search.submit();
	var v=document.search.elements; 
	for(var i=0;i<v.length;i++) 
	{ 
		if(v[i].type=="radio") 
		{ 
			v[i].value=""; 
		} 
	} 

}

function showProcessDiv(obj){
    showDiv('floatDiv',obj.onclick); 
}

function saveContact(id){
	if (trim(document.getElementById("CONN_PHON").value)==""){
		richAlert("请填写订票联系电话！");
		return;
	}else if(document.getElementById("CONN_PHON").value.length>30){
		richAlert("联系电话长度过长！");
		return;
	}
	var name = document.getElementById("CONN_PERS").value;
	var telephone = document.getElementById("CONN_PHON").value;
	ManageUser.updateContact(id,name,telephone,saveResult);
}
function saveResult(result){
	if(result=="success"){
		richAlert("已经变更,下次登录时将显示默认属性");
	}
}
function showMore(size){
	if(size > 4){
    	for(var i=0;i<9;i++){
    		var id = "policy";
			if(document.getElementById(id+i)!=null){
				document.getElementById(id+i).style.display="";
			}
    	}
	}
	document.getElementById("moreId").style.display="none";
	document.getElementById("lessId").style.display="";
}
function showLess(size){
	for(var i=4;i<size;i++){
    	var id = "policy";
    	document.getElementById(id+i).style.display="none";
    }
	document.getElementById("moreId").style.display="";
	document.getElementById("lessId").style.display="none";
}
function ReadAgreement(){

    if(window.dialogArguments!=null){
        window.dialogArguments.open('#springUrl("/manage/readAgreement.in")');
        // window.dialogArguments.showModelessDialog('#springUrl("/manage/readAgreement.in")',window,"dialogHeight:800px;dialogWidth:800px; resizable:no;help:no; status:no;center:yes;scroll:yes;");
    }else{
    	OW('#springUrl("/manage/readAgreement.in")','',false,800,800);
    }
}




/***************************************************************** ****
证件类型列表      (lhm)                  *****
*****************************************************************/ 
function
CertTypes(){
  certs = new Array();
  certs[1] = new Array('NI','身份证');
  certs[0] = new Array('PP','护照');
  certs[2] = new Array('OFFIC','军官证');
  certs[3] = new Array('SOLDI','士兵证');
  certs[4] = new Array('TW','台胞证');
  certs[5] = new Array('ID','其它');
  return certs ;
}


/***************************************************************** ****
连接字符串                        *****
*****************************************************************/ 
function StringBuffer(){
	this.data = [];
}
StringBuffer.prototype.append = function(){
	this.data.push(arguments[0]);
	return this;
}
StringBuffer.prototype.toString = function(){
	return this.data.join("");
}

/*****************************************************************
****                    国籍列表    (lihuoming)        *****
*****************************************************************/
function Nationalitis() {
  certs = new Array();
  certs[0] = new Array('CN','中国大陆');
  certs[1] = new Array('HK','中国香港');
  certs[2] = new Array('MO','中国澳门');
  certs[3] = new Array('TW','中国台湾');
  certs[4] = new Array('US','美国');
  certs[5] = new Array('GB','英国');
  certs[6] = new Array('JP','日本');
  certs[7] = new Array('GA','加拿大');
  certs[8] = new Array('FR','法国');
  certs[9] = new Array('KR','韩国');
  certs[10] = new Array('DE','德国');
  return certs ;
}

/*****************************************************************
****               填充select 的 option 项    (lihuoming)        *****
*****************************************************************/
function appendOptionStr(str ,arr,indexvalue) {
	for(var j=0;j<arr.length;j++){
      str +='  <option value="'+ arr[j][0]+'"';
      if (j==0) str +=' selected ';
      str +='>'+ arr[j][1]+'</option>';
    }
    return str;
}
/*****************************************************************
****               控制“往返open”  (lihuoming)        *****
*****************************************************************/
function changewf(routeType) {
	if(routeType=="1") {
		get("backDate").style.display="block";
	}	else {
		get("backDate").style.display="none";
	}
}

/*****************************************************************
****               找控件   (lihuoming)        *****
*****************************************************************/
function get(id)
{
	if (document.getElementById (id))
		return document.getElementById (id);
	else
		return null;
}



/*****************************************************************
****               "上一步"   (lihuoming)        *****
*****************************************************************/

function goPrve()
{
   $$("linkMan").style.display = "none";
   $$("cjr").style.display = "block";
   $$("showcjrList").style.display = "none";
   //$$("inftOption").style.display="none";
}
/*****************************************************************
****              比较日期 大于等于  (d1 >= d2 返回 true)        *****
*****************************************************************/
function dateG_E(d1,d2)
{
   return d1 >= d2;
}



/*****************************************************************
****     判断 输入的回程日期是否符合 去程运价的停留期限           *****
*****************************************************************/
function checkBackDate(arrDate,d2,minStay,maxStay)
{
		var arrDate = new Date(arrDate.replace(/-/g,"\/"));
		var d2 = new Date(d2.replace(/-/g,"\/"));
		// 没有停留期限制时 检查 回程日期 》= 去程日期
		if(minStay=="" && maxStay == "") {
			  if(dateG_E(d2,arrDate)) {
			  	return true;
			  }
		}
		
		// 最早回程日期
		var earliest = new Date();
		earliest.setTime(arrDate.getTime());
		// 最晚回程日期
		var lastest = new Date();
		lastest.setTime(arrDate.getTime());
		// 最短停留期为空的时候 earliest = arrDate, 此时判断回程日期不能早于 抵达日期
		if(minStay != "") {
			  earliest = modifyDate(earliest,minStay);
		}
		// 最长停留期为空的时候 不用判断是否满足最长停留期
		if(maxStay != "") {
				lastest = modifyDate(lastest,maxStay);
				return (dateG_E(d2,earliest)&&dateG_E(lastest,d2));
		} else {
				return dateG_E(d2,earliest);
		}
}


/*****************************************************************
****     根据最长最短停留期 获得最早 和 最迟返程日期           *****
*****************************************************************/
function modifyDate(a,modifyStr) {
		var addNum = eval(modifyStr.replace(/[A-Za-z]/g,""));
		if(modifyStr.indexOf("H") >= 0) {
				a.setHours(a.getHours() + addNum);
		} else if(modifyStr.indexOf("D") >= 0) {
				a.setDate(a.getDate() + addNum);
		} else if(modifyStr.indexOf("M") >= 0) {
				a.setMonth(a.getMonth() + addNum);
		} else if(modifyStr.indexOf("Y") >= 0) {
				a.setFullYear(a.getFullYear() + addNum);
		}
		
		return a;	
}


/*****************************************************************
****    根据出生日期和乘机日期 检查 乘客是否符合 婴儿 儿童        *****
****    婴儿 不满2周岁  儿童年满2周岁 不满12周岁        *****
*****************************************************************/
function checkPsgByDate(birthDate,deptDate,psgType)
{
	 var birth = new Date(birthDate.replace(/-/g,"\/"));
	 var dept = new Date(deptDate.replace(/-/g,"\/"));
	 var y1 = birth.getFullYear();
	 var m1 = birth.getMonth() + 1 ;
	 var d1 = birth.getDate();
	 
	 var y2 = dept.getFullYear();
	 var m2 = dept.getMonth() + 1 ;
	 var d2 = dept.getDate();
	 
	 if(psgType=="INF") {
			 // 大于2周岁
			 if(y2-y1>2) {
			 	  //alert("year" + (y2-y1));
			 		return false;
			 } 
			 // 年份差2年时 继续判断 月
			 else if (y2 - y1 == 2) {
			 		if(m2-m1>0) {
			 			//alert("month" + (m2-m1));
			 			return false;
			 		} 
			 		// 年份差2年 月份相同时 继续判断 天
			 		else if(m2==m1) {
			 			if(d2 >= d1) {
			 				//alert("day" + (d2-d1));
			 				return false;
			 			}
			 		}
			 }
	 } else if(psgType=="CHD"){
	 	   // 小于2周岁 或 大于 12周岁
	 	   if(y2-y1<2 || y2-y1>12) {
			 	  //alert("year" + (y2-y1));
			 		return false;
			 }
			 // 年份差2年时 继续判断 月
			 else if (y2 - y1 == 2) {
			 		if(m2-m1 < 0) {
			 			//alert("month" + (m2-m1));
			 			return false;
			 		} 
			 		// 年份差2年 月份相同时 继续判断 天
			 		else if(m2==m1) {
			 			// 不满2周岁时
			 			if(d2 < d1) {
			 				//alert("day" + (d2-d1));
			 				return false;
			 			}
			 		}
			 }
			 // 年份差12年时 继续判断 月 
			 else if (y2 - y1 == 12) {
			 		if(m2 - m1 > 0) {
			 			//alert("month" + (m2-m1));
			 			return false;
			 		} 
			 		// 年份差5年 月份相同时 继续判断 天
			 		else if(m2==m1) {
			 			if(d2 >= d1) {
			 				//alert("day" + (d2-d1));
			 				return false;
			 			}
			 		}
			 }
	 }
	 return true;
}


/*****************************************************************
****               检查乘客姓名   (lihuoming)        *****
*****************************************************************/
function isValidName(s) { 
	var patrn=/^[A-Za-z]+[\/][A-Za-z ]+$/;
	if (!patrn.exec(s)) 
		return false;
	return true; 
}

/*****************************************************************
****              姓为一个字母的情况，应该输入 名/姓   (lihuoming)        *****
*****************************************************************/

function checkFamilyName(s) { 
	var patrn=/^[A-Za-z]{1}[\/][A-Za-z]+$/; 
	if (patrn.exec(s)) 
		return false;
	return true; 
}
/*****************************************************************
****               在乘机人列表中显示票价   (lihuoming)        *****
*****************************************************************/
function getPriceOrTaxByType(psgType,flag)
{
    var hdmanPrice = eval(get("hdmanPrice").value);
    var hdmanTax = eval(get("hdmanTax").value);
    var hdchildPrice = eval( get("hdchildPrice").value);
    var hdchildTax = eval( get("hdchildTax").value);
		// 1 表示票价 
		if(flag==1) {
	      switch (psgType)
	      {
	          case "ADULT":
	              return hdmanPrice;
			  case "STU":
	              return hdmanPrice;
			  case "LABOR":
	              return hdmanPrice;
			  case "SEAF":
	              return hdmanPrice;
			  case "EMIG":
	              return hdmanPrice;
			  case "VISITOR":
	              return hdmanPrice;
	          case "CHD":
	              return hdchildPrice;
	      }
    } else {
	    	switch (psgType)
	      {
	          case "ADULT":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
				case "STU":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
				case "LABOR":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
				case "SEAF":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
				case "EMIG":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
				case "VISITOR":
	          	if(eval(hdmanTax)>0){
				  return hdmanTax;
				}else{
				  return "--";
			    }
			case "CHD":
              if(eval(hdchildTax)>0){
				return hdchildTax;
			  }else{
			  	return "--";
			 }
		}
    }
}

/*****************************************************************
****               更新票价   (lihuoming)        *****
*****************************************************************/
function displayDeal(){
	document.getElementById("allUsing").style.display="none";
 	document.getElementById("notAllUsing").style.display="";
 	document.getElementById("allTax").style.display="none";
 	document.getElementById("tax").style.display="none";
 	document.getElementById("allAccount").style.display="none";
 	document.getElementById("totalPrice").style.display="none";
 	document.getElementById("yuanM").style.display="none";
}

function displayDealOK(){
	document.getElementById("allUsing").style.display="";
 	document.getElementById("notAllUsing").style.display="none";
 	document.getElementById("allTax").style.display="";
 	document.getElementById("tax").style.display="";
 	document.getElementById("allAccount").style.display="";
 	document.getElementById("totalPrice").style.display="";
 	document.getElementById("yuanM").style.display="";
}

function updatePiaojia(count)
{
    var pj=0;
	var	sj=0;
    var cjrCount= count;
    if(count!=null) {
    	cjrCount = count;
    } else {
    	cjrCount = get("pCount").value;
    }
    var hdmanPrice = eval(get("hdmanPrice").value);
    var hdmanTax = eval(get("hdmanTax").value);
    var hdchildPrice = eval( get("hdchildPrice").value);
    var hdchildTax = eval( get("hdchildTax").value);
		
	var noneTax=0;
	var psgrCode = "ADULT";
    for ( var i = 0; i < cjrCount; i++)
    {   
		psgrCode = get("passengerType_"+i).value;
		if(get("passengerType_"+i).value=="成人") psgrCode = "ADULT";
		else if(get("passengerType_"+i).value=="留学生") psgrCode = "STU";
		else if(get("passengerType_"+i).value=="劳工") psgrCode = "LABOR";
		else if(get("passengerType_"+i).value=="海员") psgrCode = "SEAF";
		else if(get("passengerType_"+i).value=="移民") psgrCode = "EMIG";
		else if(get("passengerType_"+i).value=="探亲") psgrCode = "VISITOR";
        switch (psgrCode)
        {
            case "ADULT":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
			case "STU":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
			case "LABOR":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
			case "SEAF":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
			case "EMIG":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
			case "VISITOR":
                pj += hdmanPrice;
                if(eval(hdmanTax)>0){
                	sj += hdmanTax;
                }else{
                	noneTax=1;
                	sj += eval(0);
                }
                break;
            case "CHD":
                pj +=hdchildPrice;
                if(eval(hdchildTax)>0){
                	sj +=hdchildTax;
                }else{
                	noneTax=1;
                	sj+=eval(0);
                }
                break;
        }
    }

    get("psgCount").innerText = cjrCount;
    get("ticketPrice").innerText = pj.toFixed(2);
    if(eval(sj)>0 && noneTax==0){
    	displayDealOK();
    	get("tax").innerText = eval(sj.toFixed(2));
    	get("totalPrice").innerText =eval((pj +sj).toFixed(2));
    }else{
    	displayDeal();
    }

}

/*****************************************************************
****               "下一步"   (lihuoming)        *****
*****************************************************************/

function checkBook(psgType)
{
   var infos = new Array();
   var cjrCount = $$("pCount").value; //乘机人数据量
   var cjrlists = $$("cjrList");         //乘机人列表
   // 出发日期 当乘机人为 婴儿 或 儿童时 根据乘机人的出生日期 和 出发日期判断 乘客类型是否合法
   var deptDate = "$!intlBookingForm.depDate";
   var hasMan = false;          //有成人
   var haschild = false;        //有儿童
   var j = 0;
   
   for (var i = 0 ; i<cjrCount;i++)
   {    
	   j=i+1;
		var ddltype = get("passengerType_"+i);
		var cjr_name = get("name_"+i).value;       //英文名
		var cjr_midName = get("midName_"+i).value;       // 中间名
		var psgrTypeName = "成人";
		var cjr_type = ddltype.value;               //乘机人类型
		var cjr_gender = get("gender_"+i).value;       // 性别

		if ( hasMan == false &&  cjr_type == "ADULT")
			hasMan = true;
		if ( hasMan == false &&  cjr_type == "STU")
			hasMan = true;
		if ( hasMan == false &&  cjr_type == "LABOR")
			hasMan = true;
		if ( hasMan == false &&  cjr_type == "SEAF")
			hasMan = true;
		if ( hasMan == false &&  cjr_type == "EMIG")
			hasMan = true;
		if ( hasMan == false &&  cjr_type == "VISITOR")
			hasMan = true;
		if (haschild == false && cjr_type == "CHD")
			haschild = true;

		if ( cjr_name == ""){richAlert("第"+j+"位乘机人姓名不可为空！");checkResult=false;return false;}
		if ( cjr_name != "" && cjr_name.length>30){richAlert("第"+j+"位乘机人英文姓名长度不能超过30个字符。");checkResult=false;return false;}
		if ( cjr_midName != "" && cjr_midName.length>30){richAlert("第"+j+"位乘机人中间名长度不能超过30个字符。");checkResult=false;return false;}
		if ( !isValidName(cjr_name)) {
			richAlert("第"+j+"位乘机人姓名格式不正确！请输入英文名，姓名之间用“/”分隔","如:姓名为张三，则输入zhang/san");checkResult=false;return false;}
		var regexChar=/^[A-Za-z ]+$/;
		
		if ( cjr_midName!="" && !cjr_midName.match(regexChar)) {richAlert("第"+j+"位乘机人中间名格式不正确！请输入英文或汉语拼音");checkResult=false;return false;}
		if ( cjr_gender=="") {richAlert("请选择第"+j+"位乘机人性别！");checkResult=false;return false;}
		
   }

   if (haschild == true && hasMan == false){
        richAlert("乘机人只有儿童","无成人陪伴儿童不可预订"); 
        checkResult=false;
		return false; 
   }
}

/*****************************************************************
****               页面方法   (lihuoming)        *****
*****************************************************************/

//添加新行
function CreateTr(obj)
{	//添加一行参数为0，表示是加在第一行。参数为-1表示是加在最后一行。其他数字表示加在第几行
	if(obj.tagName=="TABLE"){return obj.insertRow(-1);}
}
//添加新的单元格
function CreateTd(obj){if (obj.tagName == "TR"){return obj.insertCell();}}

//添加表节点属性
function setElementAttribute(obj,name,value){if(obj.tagName=="TABLE" || obj.tagName=="TR" || obj.tagName=="TD" ){obj.setAttribute(name,value);}}

/********************************************************************
* 更新乘客类型时，更新票价
*********************************************************************/
function getPrice(index){
	var p_type = get("passengerType_"+index).value;
	if(p_type=="CHD"){
		get("pChdIndex").value=parseInt(get("pChdIndex").value)+1;
	}else
		get("pChdIndex").value=parseInt(get("pChdIndex").value)-1;
	sel(parseInt(get("pIndex").value)-parseInt(get("pChdIndex").value),parseInt(get("pChdIndex").value));
}
/*****************************************************************
****                    添加一个乘客 (国际票)    (lihuoming)        *****
*****************************************************************/
function AddIntlPassenger(indexname,pChdIndex,countname,tableobjname,name,memberDocument,freeTktNum,psgrTypeInt){
  var index = memberDocument.getElementById(indexname);
  var chdIndex = memberDocument.getElementById(pChdIndex);
  var tableobj = memberDocument.getElementById(tableobjname);
  var count=memberDocument.getElementById(countname);
	var countvalue = count.value;
	var pName="name_"+countvalue;
	var pMidName="midName_"+countvalue;
	var pGender="gender_"+countvalue;
	var passengerType="passengerType_"+countvalue;
  if (index==null || tableobj==null ||count==null){
    return ;
  }else{
    var rowindex = tableobj.rows.length;
	if(freeTktNum>=9){
		if(rowindex>8){  
			richAlert("一次最多只能订9张票");
			return ;
		}
	}
	else if (rowindex>freeTktNum-1){
		richAlert("选择的运价，最多只能订 "+freeTktNum+" 张票");
		return ;
    }

    var indexvalue = parseInt(index.value);
   
    var pasTypeStr = '<select name="'+name+'['+ countvalue+'].passengerType" id="'+passengerType+'" onchange="javascript:getPrice('+countvalue+');">'
    var arr = PassengerTypes();
    pasTypeStr = appendOptionStr(pasTypeStr,arr,indexvalue);
    pasTypeStr +='</select>';
	var pTypeN = "成人";
	var pTypeB = "ADULT";
	if(psgrTypeInt!="2"){
		if(psgrTypeInt=="1") {pTypeN="留学生";pTypeB = "STU";}
		if(psgrTypeInt=="3") {pTypeN="劳工";pTypeB = "LABOR";}
		if(psgrTypeInt=="4") {pTypeN="海员";pTypeB = "SEAF";}
		if(psgrTypeInt=="5") {pTypeN="移民";pTypeB = "EMIG";}
		if(psgrTypeInt=="6") {pTypeN="探亲";pTypeB = "VISITOR";}
		pasTypeStr='<input type="hidden" name="'+name+'['+ countvalue+'].passengerType" id="'+passengerType+'" value="'+pTypeB+'" />'
	}
    var objRow = tableobj.insertRow(rowindex);
   objRow.id = indexvalue;
   var objCel0 = objRow.insertCell(0);


    // 取div中的HTML代码
   var addStr = new StringBuffer();
   addStr.append("<div><table><tr style='border-top: #b5d7ff 1px solid'>");
   addStr.append('<td>英文姓名 <span class="friendTip">(格式：姓/名)</span><FONT color=#ff0000>*</FONT></td>');
   addStr.append('<td><input type="text" size="20" name="').append(name).append('[').append(countvalue).append('].name"').append(' id="').append(pName).append('"></td>');
   addStr.append('<td>中间名</td>');
   addStr.append('<td><input type="text" size="10" name="').append(name).append('[').append(countvalue).append('].midName"').append(' id="').append(pMidName).append('"></td>');
   addStr.append('<td>乘客类型 ');
   //if(psgrTypeInt!="2"){
	//   addStr.append('<span class="friendTip">(查询时已选)</span>：');
   //}
   if(psgrTypeInt=="2")
       addStr.append('<FONT color=#ff0000>*</FONT>');
   addStr.append('<td>').append(pasTypeStr);
   if(psgrTypeInt!="2")
	   addStr.append(pTypeN);
   addStr.append('</td>');
   addStr.append('<td>性别</td>');
   addStr.append('<td><select name="').append(name).append('[').append(countvalue).append('].gender"').append(' id="').append(pGender).append('"><option value="" selected>选择</option><option value="M">男</option><option value="F">女</option></select></td>');
   addStr.append('<td>').append('<a class="red_ink"  href="javascript:delIntlPassengerbyindex(\'').append(indexname).append('\',\'').append(countname).append('\',\'').append(tableobjname).append('\',\'').append(indexvalue).append('\',\'').append(name).append('\')">取消</a>').append('</td>');
   addStr.append("</tr>");
   addStr.append('</table></div>');
   objCel0.innerHTML=addStr.toString();
   index.value = parseInt(index.value) + 1 ; // 累加
   count.value = parseInt(countvalue) + 1 ; // 累加
	sel(index.value-chdIndex.value,chdIndex.value);
  }
}

/*****************************************************************
****               删除一个乘客 （国际）     (lhm)                    *****
*****************************************************************/
function delIntlPassengerbyindex(certindexname,certcountname,tableobjname,index,nameStr){
  var tableobj = document.getElementById(tableobjname);
  	var p_type = get("passengerType_"+index);
	var chdCount = get("pChdIndex").value;
	if(p_type=="CHD")
		get("pChdIndex").value=get("pChdIndex").value-1;
  if(index<tableobj.rows.length-1){
	  richAlert("请先取消后添加的乘客");
	  return;
  }
  var certificateindex = document.getElementById(certindexname);
  var certcount=document.getElementById(certcountname);
  var countvalue=certcount.value;
  var certificateindexvalue=certificateindex.value;
  if (certificateindex==null || tableobj==null || certcount==null) return ;
  for (var i=tableobj.rows.length-1; i>=0 ; i-- ){
    if (tableobj.rows[i].id == index){
      tableobj.deleteRow(i);
	    certificateindex.value=parseInt(countvalue)-1;
	   	certcount.value =parseInt(countvalue)-1 ;
	  }
	}
	sel(tableobj.rows.length-get("pChdIndex").value,get("pChdIndex").value);
}
/*****************************************************************
****                    添加一个乘客     (lihuoming)        *****
*****************************************************************/
function AddPassenger(certindexname,certcountname,tableobjname,name,memberDocument,freeTktNum,parPrice,price,parFuelTax,parAirportTax){

  var certificateindex = memberDocument.getElementById(certindexname);
  var tableobj = memberDocument.getElementById(tableobjname);
  var certcount=memberDocument.getElementById(certcountname);
 var countvalue = certcount.value;
	var priceId="price_"+countvalue;
	var clearPriceId="clear_price"+countvalue;
	var fuelTaxId="fuelTax_"+countvalue;
	var airportTaxId="airportTax_"+countvalue;
	var showClearingPrice="showClearingPrice_"+countvalue;
	var certificateType="certType_"+countvalue;
	var pName="name_"+countvalue;
	var passengerType="passengerType_"+countvalue;
	var milesCard="milesCard_"+countvalue;
	var certificateNum="certificateNum_"+countvalue;
	var showPrice="showPrice_"+countvalue;
	var showClearPrice="showClearPrice_"+countvalue;
	//var birthday="birthday_"+countvalue;
	

  if (certificateindex==null || tableobj==null ||certcount==null){

    return ;
  }else{
    var rowindex = tableobj.rows.length;
	
	
	if(freeTktNum>=9){

		   if (rowindex>8){
			  
				richAlert("一次最多只能订9张票");
     
				  return ;
				 }
			}
	else
    if (rowindex>freeTktNum-1){
		
			richAlert("可售机票不足，最多只能订"+freeTktNum+"张票");
		
			return ;
    }

    var indexvalue = parseInt(certificateindex.value);
   

    var str = '<select name="'+name+'['+ countvalue+'].certificateType" id="'+certificateType+'" style="width:60px">'
    var arr = CertTypes();

    for(var j=0;j<arr.length;j++){
      str +='  <option value="'+ arr[j][0]+'"'
      if (indexvalue==0) str +=' selected '
      str +='>'+ arr[j][1]+'</option>';
    }

    str +='</select>'


    var objRow = tableobj.insertRow(rowindex);
    objRow.id = indexvalue;
    var objCel0 = objRow.insertCell(0);
    var objCel1 = objRow.insertCell(1);
    var objCel2 = objRow.insertCell(2);
    var objCel3 = objRow.insertCell(3);
    var objCel4 = objRow.insertCell(4);
    var objCel5 = objRow.insertCell(5);
    var objCel6 = objRow.insertCell(6);
    var objCel7 = objRow.insertCell(7);
    var objCel8 = objRow.insertCell(8);
    var objCel9 = objRow.insertCell(9);


    //objCel0.width = 120  ;
    //objCel1.width = 200 ;
	objCel0.innerHTML='<input  size=15 name="'+name+'['+ countvalue+'].name" id="'+pName+'" onblur=\"checkNameLength(this);\" >';
	objCel1.innerHTML='<select name="'+name+'['+ countvalue+'].passengerType"  id="'+passengerType+'" style="width:75px" onchange=showOtherPrice("'+countvalue+'",this.value); ><option value="ADULT" selected > 成人</option><option value="CHD" > 儿童</option><!--<option value="INF" > 婴儿</option>--></select>';
	objCel2.innerHTML= str;
    objCel3.innerHTML= '<input  size=15 name="'+name+'['+ countvalue+'].certificateNum" id="'+certificateNum+'" maxlength="18">';
	objCel4.innerHTML= '<input type=hidden  size=15 name="'+name+'['+ countvalue+'].milesCard" id="'+milesCard+'" maxlength="18">';
	objCel5.innerHTML= '<div  id="'+showPrice+'"  style="dispaly:none"> '+parPrice+'</div><input type=hidden size=15 name="'+name+'['+ countvalue+'].parPrice" maxlength="18" value="'+parPrice+'"  id="'+priceId+'">';
	objCel6.innerHTML= '<div  id="'+showClearPrice+'"  style="dispaly:none"> '+price+'</div><input type=hidden size=15 name="'+name+'['+ countvalue+'].price" maxlength="18" value="'+price+'"  id="'+clearPriceId+'">';
	objCel7.innerHTML= '<div  id="'+showClearingPrice+'" style="dispaly:none">'+parFuelTax+'/'+parAirportTax+'</div>'+'<input type=hidden size=10 name="'+name+'['+ countvalue+'].fuelTax" maxlength="18" value="'+parFuelTax+'"  id="'+fuelTaxId+'">'+'<input type=hidden size=10 name="'+name+'['+ countvalue+'].airportTax" maxlength="18" value="'+parAirportTax+'"  id="'+airportTaxId+'">';
	objCel8.innerHTML='<select name="'+name+'['+ countvalue+'].insurance"   style="width:50px"><option value=0 selected >不需</option><!--<option value=1 >一份</option><option value=2 >两份</option><option value=3 >三份</option>--></select>';
	objCel9.innerHTML='<a   href="javascript:delPassengerbyindex(\''+certindexname+'\',\''+ certcountname+'\',\''+tableobjname+'\','+ indexvalue+',\''+name+'\',document)" class="red_ink"> 取消</a>';
    certificateindex.value = parseInt(certificateindex.value) + 1 ; // 累加
    certcount.value = parseInt(countvalue) + 1 ; // 累加
  }

}

function checkNameLength(obj){
	if(obj.value.length>28){
		richAlert("乘客姓名长度不得超过28个字符，否则无法出票！请重新输入"+obj.value+"的姓名！");
		obj.focus();
		}
	}

/*****************************************************************
****               删除证件行      (lhm)                    *****
*****************************************************************/
function delPassengerbyindex(certindexname,certcountname,tableobjname,index,nameStr,memberDocument){

	
	
  var tableobj = memberDocument.getElementById(tableobjname);

  var certificateindex = memberDocument.getElementById(certindexname);
  var certcount=memberDocument.getElementById(certcountname);
  var countvalue=certcount.value;
  var certificateindexvalue=certificateindex.value;
  if (certificateindex==null || tableobj==null || certcount==null) return ;
  for (var i=tableobj.rows.length-1; i>=0 ; i-- ){
    if (tableobj.rows[i].id == index){
      tableobj.deleteRow(i);
	// certificateindex.value=countvalue-1;
	  // certcount.value =countvalue-1 ;

	  }

  }
	
  var rowArr=tableobj.rows;
 

/*  for(i=0; i<rowArr.length; i++){
    var selectObj=rowArr[i].getElementsByTagName("SELECT")[0];
	richAlert(i);
	richAlert(rowArr[].length);

    var inputObj=rowArr[i].getElementsByTagName("INPUT")[0];
	

    var str='<select name="'+nameStr+'['+i+'].certificateType" style="width:120">'+selectObj.innerHTML+'</select>';
    selectObj.parentNode.innerHTML=str;


    str='<input class="myinput" size=18 name="'+nameStr+'['+i+'].certificateNum" value="'+inputObj.value+'" maxlength="18">';
    inputObj.outerHTML=str;

  
  }*/
  
//row==0的时候 count也不减 校验需要按count循环
//if (tableobj.rows.length==0)
	//  certificateindex.value =1;
	
	  

}

/*
function setCertOptions(selectName,valueStr,memberDocument){
  var arr = CertTypes();
  var selectObj=memberDocument.getElementById(selectName);

  for(var i = 0; i < arr.length; i++) {
    selectObj.add(document.createElement("OPTION"));
    selectObj.options[i].text=arr[i][1];
    selectObj.options[i].value=arr[i][0];
    if(valueStr==selectObj.options[i].value){
      selectObj.options[i].selected=true;
    }
  }

}




now = new Date();
function writeYears(obj, date)
{
	var years = date.getYear()+100
	for (var i=1919; i<2010; i++)
	{
	var opt = document.createElement("option")
	opt.text = opt.value = i
	obj.add(opt)
	}
}
function writeMonths(obj)
{
	for (var i=1; i<13; i++)
	{
	var opt = document.createElement("option")
	opt.text = opt.value = Math.floor(i/10) ? i : "0"+i
	obj.add(opt)
	}
}
*/
function writeDate(obj, year, month)
{
	var date = new Date(""+year+"/"+(parseInt(month)+1)+"/"+0).getDate()
	var selectedIndex = (date-1)<obj.selectedIndex ? (date-1) : obj.selectedIndex;
	var len = obj.options.length;
	if (date > len) {
		for (var i = len + 1; i <= date; i++) {
			var opt = document.createElement("option");
			opt.text = opt.value = Math.floor(i / 10) ? i : "0" + i;
			obj.add(opt);
		}
	}
	obj.selectedIndex = selectedIndex;
}

function changeDate(){ 
	saveBirthday();
	var c_year = document.getElementById("c_year");
	var c_month = document.getElementById("c_month");
	var c_day = document.getElementById("c_day");
  writeDate(c_day, c_year.options(c_year.selectedIndex).value, c_month.options(c_month.selectedIndex).value)
}

function saveBirthday() {
	var birthdayBind = document.getElementById("birthday");
	var y = document.getElementById("c_year").value;
	var m = document.getElementById("c_month").value;
	var d = document.getElementById("c_day").value;
	birthdayBind.value=y+"-" + m + "-"+d;
	
}

// Q税金进度层用1
function showDivDisplay(){
	document.getElementById('floatDiv').style.display="";
	document.getElementById('processDiv').style.display="none";
	document.getElementById('proDescribe').style.display="";
	document.getElementById('processDiv').style.valign="middle";
	document.getElementById('proDescribe').style.valign="middle";
	document.getElementById('processDiv').style.display="";
	document.getElementById('divContentBye').style.display="";
}
// Q税金进度层用2
function divDisplayNone(){
    document.getElementById('overlay').style.display="none";
	document.getElementById('overlay').id="floatDiv";
	document.getElementById('processDiv').style.display="none";
	document.getElementById('floatDiv').style.display="none";
	document.getElementById('proDescribe').style.display="none";
	document.getElementById('divContentBye').style.display="none";
}

function showSeatInfoOrNot(obj,i){
	if(document.getElementById("seat_info_div"+i).style.display=="none"){
		document.getElementById("seat_info_div"+i).style.display="";
		obj.src="/liantuotravel/webfiles/images/index/searin_img12.gif";
	}else{
		document.getElementById("seat_info_div"+i).style.display="none";
		obj.src="/liantuotravel/webfiles/images/index/searin_img19.gif";
	}
}

function changePaymentTab(type){
	if(type==1){
		try{
			$$("alipay_pay").style.display="";
			$$("bank_pay").style.display="none";
			$$("alipay_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_05.gif)";
			$$("bank_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		try{
			$$("credit_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("credit_pay").style.display="none";
		}catch(e){
		}
		try{
			$$("apply_pay").style.display="none";
			$$("apply_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		$$("pay_helper").style.display="none";
		$$("help_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
	} else if(type==2){
		try{
			$$("alipay_pay").style.display="none";
			$$("alipay_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("bank_pay").style.display="none";
			$$("bank_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		try{
			$$("credit_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("credit_pay").style.display="none";
		}catch(e){
		}
		$$("apply_pay").style.display="";
		$$("apply_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_05.gif)";
		$$("pay_helper").style.display="none";
		$$("help_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
	} else if(type==3){
		try{
			$$("alipay_pay").style.display="none";
			$$("bank_pay").style.display="";
			$$("alipay_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("bank_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_05.gif)";
		}catch(e){
		}
		try{
			$$("credit_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("credit_pay").style.display="none";
		}catch(e){
		}
		try{
			$$("apply_pay").style.display="none";
			$$("apply_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		$$("pay_helper").style.display="none";
		$$("help_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
	} else if(type==4){
		try{
			$$("alipay_pay").style.display="none";
			$$("bank_pay").style.display="none";
			$$("alipay_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("bank_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		try{
			$$("credit_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("credit_pay").style.display="none";
		}catch(e){
		}
		try{
			$$("apply_pay").style.display="none";
			$$("apply_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		$$("pay_helper").style.display="";
		$$("help_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_05.gif)";
	} else if(type==5){
		try{
			$$("alipay_pay").style.display="none";
			$$("bank_pay").style.display="none";
			$$("alipay_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
			$$("bank_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		try{
			$$("credit_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_05.gif)";
			$$("credit_pay").style.display="";
		}catch(e){
		}
		try{
			$$("apply_pay").style.display="none";
			$$("apply_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
		}catch(e){
		}
		$$("pay_helper").style.display="none";
		$$("help_li").style.background="url(/liantuotravel/webfiles/images/index/anniu_03.gif)";
	}
	
}








  

