// JavaScript Document
//计算天数差的函数，通用
//sDate1和sDate2是2006-12-18格式

function  DateDiff(sDate1,  sDate2){
       var  aDate,  oDate1,  oDate2,  iDays  
       aDate  =  sDate1.split("-")  
       oDate1  =  new  Date(aDate[1]  +  '/'  +  aDate[2]  +  '/'  +  aDate[0])    //转换为12-18-2006格式  
       aDate  =  sDate2.split("-")  
       oDate2  =  new  Date(aDate[1]  +  '/'  +  aDate[2]  +  '/'  +  aDate[0])  
       iDays  =  parseInt((oDate1  -  oDate2)  /  1000  /  60  /  60  /24)    //把相差的毫秒数转换为天数  
       return  iDays  
}

function getDayAdd(startdate,days)   
{   
  	var d,s,aDate,mstr,dstr
	
	aDate  =  startdate.split("-")
	
	d  =  new  Date(aDate[0]  +  '/'  +  aDate[1]  +  '/'  +  aDate[2])

  	d.setDate(d.getDate()+days)
	
	if((d.getMonth() + 1)<10){
		mstr = "0" + (d.getMonth() + 1)
	}else{
		mstr = (d.getMonth() + 1)	
	}
	
	if(d.getDate()<10){
		dstr = "0" + d.getDate()
	}else{
		dstr = d.getDate()	
	}
	
   	s = d.getFullYear() + "-" + mstr + "-" + dstr
  	return s  
} 

function addOption(objSelectNow,txt,val) 
{ 
    /// 使用W3C标准语法为SELECT添加Option 
    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=0; i<optGroup.length; i++) 
    { 
		 var MenuVar = optGroup[i].split("=>"); 
		 if (MenuVar[0] != ""){ 
			addOption(objSelectNow, MenuVar[0], MenuVar[1]); 
		 } 
    } 
}

//删除行
function removeTr(obj) {
	var sTr = obj.parentNode.parentNode;
	sTr.parentNode.removeChild(sTr);
}

function chooseHotel(name,id){
	$("#Hsearch_hotelname").val(name);
	$("#Hsearch_hotel").val(id);
	$("#Hsearch_hotel_list").hide();
}

function chooseHomestay(name,id){
	$("#HS_search_hotelname").val(name);
	$("#HS_search_hotel").val(id);
	$("#HS_search_hotel_list").hide();
}

function chooseSuite(name,id){
	$("#Ssearch_suitename").val(name);
	$("#Ssearch_suite").val(id);
	$("#Ssearch_suite_list").hide();
	LoadS_room();
}

function chooseSpecial(name,days,id){
	$("#Psearch_room_name").val(name);
	$("#Psearch_special_days").val(days);
	$("#Psearch_special_id").val(id);
	$("#Psearch_special_list").hide();
}

//计算总价
function count_total(){
	
	document.getElementById("All_total").value = Number(document.getElementById("TK_total").value) + Number(document.getElementById("HT_total").value) + Number(document.getElementById("ST_total").value) + Number(document.getElementById("SP_total").value);
	
	//selectPayType();
	
}

//按地区读取家庭旅馆列表
function LoadT_homestay() { 
	if( document.getElementById("HS_search_area").value.length > 0){
		urltxt = "select.server.php?action=homestay_list&id=" + document.getElementById("HS_search_area").value + "&timestamp" + new Date().getTime();
			$.ajax({
				type: "get",
			 	url:urltxt,
			 	beforeSend: function(XMLHttpRequest){
					$("#HS_search_hotel_list").show();
					$("#HS_search_hotel_list").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
			 	},
			  	success: function(data, textStatus){
					$("#HS_search_hotel_list").show();
					$("#HS_search_hotel_list").html(data);
				},
				complete: function(XMLHttpRequest, textStatus){
			   		//$("#Hsearch_hotel_list").show();
			 	},
				error: function(){
					//alert("数据读取失败");
					return false;	
				}
			});
	}else{
		alert("请先选择酒店地区");
		document.getElementById("HS_search_area").focus();
		return false;	
	}
}

//按地区读取酒店列表
function LoadT_hotel() { 
	if( document.getElementById("Hsearch_area").value.length > 0){
		urltxt = "select.server.php?action=hotel_list&id=" + document.getElementById("Hsearch_area").value + "&timestamp" + new Date().getTime();
			$.ajax({
				type: "get",
			 	url:urltxt,
			 	beforeSend: function(XMLHttpRequest){
					$("#Hsearch_hotel_list").show();
					$("#Hsearch_hotel_list").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
			 	},
			  	success: function(data, textStatus){
					$("#Hsearch_hotel_list").show();
					$("#Hsearch_hotel_list").html(data);
				},
				complete: function(XMLHttpRequest, textStatus){
			   		//$("#Hsearch_hotel_list").show();
			 	},
				error: function(){
					//alert("数据读取失败");
					return false;	
				}
			});
	}else{
		alert("请先选择酒店地区");
		document.getElementById("Hsearch_area").focus();
		return false;	
	}
}

//按酒店读取特价房型
function Load_special_rooms() { 

	if( $("#Psearch_hotel").val().length > 0){
		urltxt = "select.server.php?action=special_room_list&id="+ $("#Psearch_hotel").val() + "&timestamp" + new Date().getTime();
			$.ajax({
				type: "get",
			 	url:urltxt,
			 	beforeSend: function(XMLHttpRequest){
					$("#Psearch_room_name").val('');
					$("#Psearch_special_id").val('');
					$("#Psearch_special_list").show();
					$("#Psearch_special_list").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");			 	},
			  	success: function(data, textStatus){
					$("#Psearch_special_list").show();
					$("#Psearch_special_list").html(data);
				},
				complete: function(XMLHttpRequest, textStatus){

			 	},
				error: function(){
					//alert("数据读取失败");
					return false;	
				}
			});
	}else{
		alert("请先选择酒店");
		$("#Psearch_hotel").focus();
		return false;	
	}
}

function LoadS_room() { 
   
	if( $("#Ssearch_suite").val().length > 0){
		urltxt = "select.server.php?action=suiteroom&id="+ $("#Ssearch_suite").val() + "&timestamp" + new Date().getTime();
			$.ajax({
				type: "get",
			 	url:urltxt,
			 	beforeSend: function(XMLHttpRequest){
					$("#statusST").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
			 	},
			  	success: function(data, textStatus){
					addOptionGroup("Ssearch_room",data); 
				},
				complete: function(XMLHttpRequest, textStatus){
			   		$("#statusST").empty(); 
			 	},
				error: function(){
					//alert("数据读取失败");
					return false;	
				}
			});
	}else{
		alert("请先选择酒店套餐");
		$("#Ssearch_suitename").focus();
		return false;	
	}
}

//载入机票天数
function load_tk_days() { 
   
	if( document.getElementById("Tsearch_city").value.length > 0){
		urltxt = "select.server.php?action=ticket_days_list&city=" + document.getElementById("Tsearch_city").value + "&timestamp" + new Date().getTime();
			$.ajax({
				type: "get",
			 	url:urltxt,
			 	beforeSend: function(XMLHttpRequest){
					$("#statusTxt").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
			 	},
			  	success: function(data, textStatus){
					addOptionGroup("Tsearch_days",data); 
				},
				complete: function(XMLHttpRequest, textStatus){
			   		$("#statusTxt").empty(); 
			 	},
				error: function(){
					//alert("数据读取失败");
					return false;	
				}
			});
	}else{
		alert("请先选择出发城市");
		document.getElementById("Tsearch_city").focus();
		return false;	
	}
	
}

//查询机票
function SearchTicket(){
	var city = "";
	var days = "";
	if($("#Tsearch_date").val().length > 0){
		Tdate = $("#Tsearch_date").val();
	}else{
		alert("\“出发日期\”不可以为空！请选择出发日期");
		$("#Tsearch_date").focus();
		return false;
	}
	if(document.getElementById("Tsearch_city").value.length > 0){
		city = document.getElementById("Tsearch_city").value;
		city = encodeURI(encodeURI(city));
	}else{
		alert("请选择您的出发城市");
		return false;	
	}
	if( document.getElementById("Tsearch_days").value.length > 0){
		days = document.getElementById("Tsearch_days").value;
	}

	urltxt = "revdata.php?amode=get_ticket&Tsearch_date=" + Tdate + "&Tsearch_city="+ city +"&Tsearch_days="+ days + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_tk").show();
			$("#box_tk").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_tk").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});
}

//选择机票
//选择机票
function SelectTicket(id){
	
	TK_city_s 			= document.getElementById("TK_city_l_" + id).value;
	TK_no_s 			= document.getElementById("TK_no_l_" + id).value;
	TK_time_s 			= document.getElementById("TK_time_l_" + id).value;
	TK_model_s 			= document.getElementById("TK_model_l_" + id).value;
	TK_memo_s 			= document.getElementById("TK_memo_l_" + id).value;
	TK_days_s 			= document.getElementById("TK_days_l_" + id).value;
	TK_indate_s 		= document.getElementById("TK_indate_l_" + id).value;
	TK_adultnum_s 		= Number(document.getElementById("TK_adultnum_l_" + id).value);
	TK_adultprice_s 	= Number(document.getElementById("TK_adultprice_l_" + id).value);
	TK_adultpriceadd_s	= Number(document.getElementById("TK_adultpriceadd_l_" + id).value);
	TK_kidnum_s 		= Number(document.getElementById("TK_kidnum_l_" + id).value);
	TK_kidprice_s 		= Number(document.getElementById("TK_kidprice_l_" + id).value);
	TK_kidpriceadd_s 	= Number(document.getElementById("TK_kidpriceadd_l_" + id).value);
	TK_date_s			= document.getElementById("TK_date_l_" + id).value;	
	TK_dateback_s		= document.getElementById("TK_dateback_l_" + id).value;
	TK_printID_s		= document.getElementById("TK_printID_l_" + id).value;
	
	TK_g_no_s			= document.getElementById("TK_g_no_l_" + id).value;
	TK_g_model_s		= document.getElementById("TK_g_model_l_" + id).value;
	TK_g_time_s			= document.getElementById("TK_g_time_l_" + id).value;
	TK_g_atime_s		= document.getElementById("TK_g_atime_l_" + id).value;
	TK_g_airport_s		= document.getElementById("TK_g_airport_l_" + id).value;
	TK_ga_airport_s		= document.getElementById("TK_ga_airport_l_" + id).value;
	TK_b_no_s			= document.getElementById("TK_b_no_l_" + id).value;
	TK_b_model_s		= document.getElementById("TK_b_model_l_" + id).value;
	TK_b_time_s			= document.getElementById("TK_b_time_l_" + id).value;
	TK_b_atime_s		= document.getElementById("TK_b_atime_l_" + id).value;
	TK_b_airport_s		= document.getElementById("TK_b_airport_l_" + id).value;
	TK_ba_airport_s		= document.getElementById("TK_ba_airport_l_" + id).value;

	//设置计数器
	
	var TK_num;	
	TK_num = Number($("#TK_num").val());	
	TK_num = TK_num + 1 ;	
	$("#TK_num").val(TK_num);


	var table_show ="";
	
	table_show = $("#TK_select_box").html();
	
	table_show = table_show.replace("</TBODY>","");
	table_show = table_show.replace("</TABLE>","");
	table_show = table_show.replace("</tbody>","");
	table_show = table_show.replace("</table>","");
	
	table_show  += "<tr>" ;
	//城市
	table_show  +=	"<td>" + TK_city_s + "<br>" + TK_days_s + "</td>" ;
	//往返日期
	table_show  +=	"<td>" + TK_date_s + " 出发<br>" + TK_dateback_s + " 返回</td>" ;
	//航班
	table_show  +=	"<td>去程"+ TK_g_no_s + " " + TK_g_airport_s + " " + TK_g_time_s +"起飞<br/>返程"+ TK_b_no_s + " " + TK_b_airport_s + " " + TK_b_time_s + "起飞</td>" ;
	//机型
	table_show  +=	"<td>" + TK_g_model_s + "</td>" ;
	
	//备注	
	if( TK_indate_s ){
		table_show  +=	"<td align=\"center\"><img src=\"/rev/images/memo.gif\" alt=\"备注：" + TK_indate_s + "\" border=\"0\" style=\"cursor:pointer;\" onclick=\"alert($(this).attr('alt'));\" onMouseOver=\"window.status='点击可以查看';return true;\"> </td>" ;		
	}else{
		table_show  +=	"<td align=center>无</td>";
	}
	//人数
	table_show  +=	"<td>成人：<font color=\"#FF0000\">￥" + TK_adultprice_s + "</font> * " + TK_adultnum_s + "<br>儿童：<font color=\"#FF0000\">￥" + TK_kidprice_s + "</font> * " + TK_kidnum_s + "</td>" ;
	
	table_show  +=	"<td align=\"center\"> \
	<input id=\"TK_date_s_" + TK_num + "\"  name=\"TK_date_s_" + TK_num + "\" type=\"hidden\" value='" + TK_date_s + "'>\
	<input id=\"TK_city_s_" + TK_num + "\" name=\"TK_city_s_" + TK_num + "\" type=\"hidden\" value='" + TK_city_s + "'>\
	<input id=\"TK_kidnum_s_" + TK_num + "\" name=\"TK_kidnum_s_" + TK_num + "\" type=\"hidden\" value='" + TK_kidnum_s + "'>\
	<input id=\"TK_kidpriceadd_s_" + TK_num + "\" name=\"TK_kidpriceadd_s_" + TK_num + "\" type=\"hidden\" value='" + TK_kidpriceadd_s + "'>\
	<input id=\"TK_kidprice_s_" + TK_num + "\" name=\"TK_kidprice_s_" + TK_num + "\" type=\"hidden\" value='" + TK_kidprice_s + "'>\
	<input id=\"TK_adultnum_s_" + TK_num + "\" name=\"TK_adultnum_s_" + TK_num + "\" type=\"hidden\" value='" + TK_adultnum_s + "'>\
	<input id=\"TK_adultpriceadd_s_" + TK_num + "\" name=\"TK_adultpriceadd_s_" + TK_num + "\" type=\"hidden\" value='" + TK_adultpriceadd_s + "'>\
	<input id=\"TK_adultprice_s_" + TK_num + "\" name=\"TK_adultprice_s_" + TK_num + "\" type=\"hidden\" value='" + TK_adultprice_s + "'>\
	<input id=\"TK_indate_s_" + TK_num + "\" name=\"TK_indate_s_" + TK_num + "\" type=\"hidden\" value='" + TK_indate_s + "'>\
	<input id=\"TK_days_s_" + TK_num + "\" name=\"TK_days_s_" + TK_num + "\" type=\"hidden\" value='" + TK_days_s + "'>\
	<input id=\"TK_model_s_" + TK_num + "\" name=\"TK_model_s_" + TK_num + "\" type=\"hidden\" value='" + TK_model_s + "'>\
	<input id=\"TK_time_s_" + TK_num + "\" name=\"TK_time_s_" + TK_num + "\" type=\"hidden\" value='" + TK_time_s + "'>\
	<input id=\"TK_no_s_" + TK_num + "\" name=\"TK_no_s_" + TK_num + "\" type=\"hidden\" value='" + TK_no_s + "'>\
	<input id=\"TK_memo_s_" + TK_num + "\" name=\"TK_memo_s_" + TK_num + "\" type=\"hidden\" value='" + TK_memo_s + "'>\
	<input id=\"TK_dateback_s_" + TK_num + "\" name=\"TK_dateback_s_" + TK_num + "\" type=\"hidden\" value='" + TK_dateback_s + "'>\
	<input id=\"TK_g_no_s_" + TK_num + "\" name=\"TK_g_no_s_" + TK_num + "\" type=\"hidden\" value='" + TK_g_no_s + "'>\
	<input id=\"TK_g_model_s_" + TK_num + "\" name=\"TK_g_model_s_" + TK_num + "\" type=\"hidden\" value='" + TK_g_model_s + "'>\
	<input id=\"TK_g_time_s_" + TK_num + "\" name=\"TK_g_time_s_" + TK_num + "\" type=\"hidden\" value='" + TK_g_time_s + "'>\
	<input id=\"TK_g_atime_s_" + TK_num + "\" name=\"TK_g_atime_s_" + TK_num + "\" type=\"hidden\" value='" + TK_g_atime_s + "'>\
	<input id=\"TK_g_airport_s_" + TK_num + "\" name=\"TK_g_airport_s_" + TK_num + "\" type=\"hidden\" value='" + TK_g_airport_s + "'>\
	<input id=\"TK_ga_airport_s_" + TK_num + "\" name=\"TK_ga_airport_s_" + TK_num + "\" type=\"hidden\" value='" + TK_ga_airport_s + "'>\
	<input id=\"TK_b_no_s_" + TK_num + "\" name=\"TK_b_no_s_" + TK_num + "\" type=\"hidden\" value='" + TK_b_no_s + "'>\
	<input id=\"TK_b_model_s_" + TK_num + "\" name=\"TK_b_model_s_" + TK_num + "\" type=\"hidden\" value='" + TK_b_model_s + "'>\
	<input id=\"TK_b_time_s_" + TK_num + "\" name=\"TK_b_time_s_" + TK_num + "\" type=\"hidden\" value='" + TK_b_time_s + "'>\
	<input id=\"TK_b_atime_s_" + TK_num + "\" name=\"TK_b_atime_s_" + TK_num + "\" type=\"hidden\" value='" + TK_b_atime_s + "'>\
	<input id=\"TK_b_airport_s_" + TK_num + "\" name=\"TK_b_airport_s_" + TK_num + "\" type=\"hidden\" value='" + TK_b_airport_s + "'>\
	<input id=\"TK_ba_airport_s_" + TK_num + "\" name=\"TK_ba_airport_s_" + TK_num + "\" type=\"hidden\" value='" + TK_ba_airport_s + "'>\
	<input id=\"TK_printID_s_" + TK_num + "\" name=\"TK_printID_s_" + TK_num + "\" type=\"hidden\" value='" + TK_printID_s + "'>\
	<input id=\"TK_s_" + TK_num + "\" type=\"button\"  value=\"删除\" onClick=\"javascript:Delete_TK('TK_s_" + TK_num + "','" + TK_num + "');\">\
	</td>" ;
	table_show  +=	"</tr>";
	
	//证件表格	
	table_show += "<tr>\
      <td colspan=\"7\" style=\"background-color:#f7f7f7;\">\
      <div id='TK_s_paper_" + TK_num + "'><font color=#FF3300>您需要如实填写搭乘该航班乘客证件：</font></div>";
	
	//成人
	if(TK_adultnum_s>0){

		for(j=0;j<TK_adultnum_s;j++){
			paper_id = Number($("#TK_paper_num").val()) + 1;
			
			
			//生成成人证件输入
			table_show += "<li>成人 "+ eval(j+1) +"　姓名：<input id=paper_client_name_"+ paper_id +" name=paper_client_name_"+ paper_id +" type=text  size=12 maxlength=32  datatype=Require msg='姓名：为必填项' />\
			证件：<select id=paper_type_"+ paper_id +" name=paper_type_"+ paper_id +" size=1 >\
          <option value=\"身份证\" selected=\"selected\">身份证</option>\
          <option value=\"护照\">护照</option>\
          <option value=\"军人证\">军人证</option>\
          <option value=\"回乡证\">回乡证</option>\
          <option value=\"台胞证\">台胞证</option>\
          <option value=\"港澳通行证\">港澳通行证</option>\
          <option value=\"国际海员证\">国际海员证</option>\
          <option value=\"外国人永久居留证\">外国人永久居留证</option>\
        </select>\
        <input id=\"paper_no_"+ paper_id +"\" name=\"paper_no_"+ paper_id +"\" type=\"text\" size=\"18\" maxlength=\"32\"  datatype=\"Require\" msg='证件号码：为必填项' />\
        性别\
        <select id=\"paper_sex_"+ paper_id +"\" name=\"paper_sex_"+ paper_id +"\" size=\"1\">\
          <option value=\"男\">男</option>\
          <option value=\"女\">女</option>\
        </select>\
        <input id=\"paper_client_type_"+ paper_id +"\" name=\"paper_client_type_"+ paper_id +"\" type=\"hidden\"  value='成人' />\
        <input id=\"paper_tk_id_"+ paper_id +"\" name=\"paper_tk_id_"+ paper_id +"\" type=\"hidden\" value='" + TK_num + "'/>\
      </li>";
			
			//证件计数
			$("#TK_paper_num").val( paper_id );
		}
	}
	//儿童
	if(TK_kidnum_s>0){
		for(j=0;j<TK_kidnum_s;j++){
			
			paper_id = Number($("#TK_paper_num").val()) + 1;
			
			//生成儿童证件输入
			table_show += "<li>儿童 "+ eval(j+1) +"　姓名：<input id=\"paper_client_name_"+ paper_id +"\" name=\"paper_client_name_"+ paper_id +"\" type=\"text\" size=\"12\" maxlength=\"32\" datatype=\"Require\" msg='姓名：为必填项' />\
			证件：<select id=\"paper_type_"+ paper_id +"\" name=\"paper_type_"+ paper_id +"\" size=\"1\" >\
			<option value=\"其它\" selected=\"selected\">出生年月日（凭户口本登机）</option>\
			<option value=\"身份证\">身份证</option>\
        </select>\
        <input id=\"paper_no_"+ paper_id +"\" name=\"paper_no_"+ paper_id +"\" type=\"text\" size=\"18\" maxlength=\"32\"  datatype=\"Require\" msg='证件号码：为必填项' />\
        性别\
        <select id=\"paper_sex_"+ paper_id +"\" name=\"paper_sex_"+ paper_id +"\" size=\"1\">\
          <option value=\"男\">男</option>\
          <option value=\"女\">女</option>\
        </select>\
        <input id=\"paper_client_type_"+ paper_id +"\"name=\"paper_client_type_"+ paper_id +"\" type=\"hidden\"  value='儿童' />\
        <input id=\"paper_tk_id_"+ paper_id +"\" name=\"paper_tk_id_"+ paper_id +"\" type=\"hidden\" value='" + TK_num + "'/>\
      </li>";
			
			//证件计数
			$("#TK_paper_num").val(paper_id);
		}
	}	
	
	  
	table_show += "</td></tr>";
	//证件表格结束
	
	table_show += "</TBODY></TABLE>";
	
	//载入表格
	$("#TK_select_box").html(table_show) ;
	//显示机票购物车
	$("#TK_buy_cart").show();
	
	//计算价格
	var price ;
	price = (TK_adultnum_s * TK_adultprice_s) + (TK_kidnum_s * TK_kidprice_s) ;
	document.getElementById("TK_total").value = Number(document.getElementById("TK_total").value) + price;
	count_total();
	
	//计算乘客数量
	$("#TK_adult_num").val( Number($("#TK_adult_num").val()) + TK_adultnum_s );
	$("#TK_kid_num").val( Number($("#TK_kid_num").val()) + TK_kidnum_s );
	
	alert("成功添加到“已选项目”！");
}


//删除机票
function Delete_TK(btn,id){
	
	if (confirm('您确认要删除吗?\n')) {
		
		TK_adultnum_s 	= Number(document.getElementById("TK_adultnum_s_" + id).value);
		TK_adultprice_s = Number(document.getElementById("TK_adultprice_s_" + id).value);
		TK_kidnum_s 	= Number(document.getElementById("TK_kidnum_s_" + id).value);
		TK_kidprice_s 	= Number(document.getElementById("TK_kidprice_s_" + id).value);

		var price;
		price = (TK_adultnum_s * TK_adultprice_s) + (TK_kidnum_s * TK_kidprice_s) ;
		
		$("#TK_total").val( Number($("#TK_total").val()) - price );
		
		if( $("#TK_total").val() == '0'){
			//隐藏
			$("#TK_buy_cart").hide();
		}
		
		//计算乘客数量
		$("#TK_adult_num").val( Number($("#TK_adult_num").val()) - TK_adultnum_s );
		$("#TK_kid_num").val( Number($("#TK_kid_num").val()) - TK_kidnum_s );
		
		count_total();
	
		var obj = document.getElementById(btn);
		
		//删除证件行
		removeTr(document.getElementById("TK_s_paper_"+id));
		
		removeTr(obj);
		
	}
		
	return false;
}

//查询家庭旅馆
function SearchHS(){
	var hdate = "";
	var hdate2 = "";
	var harea = "";
	var hotel = "";
	
	if($("#HS_search_date").val().length > 0){
		hdate = $("#HS_search_date").val();
		
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#HS_search_date").focus()
		return false;
	}
	
	if($("#HS_search_date2").val().length > 0){
		hdate2 = $("#HS_search_date2").val();
	}else{
		alert("\“离店日期\”不可以为空！请选择离店日期");
		$("#HS_search_date2").focus()
		return false;
	}
	
	if( DateDiff(hdate2,hdate) < 1 ){
	
		alert("\“离店日期\”必须大于\“入住日期\”，请重新选择\"离店日期\"");
		$("#HS_search_date2").focus()
		return false;
	}
	
	if( DateDiff(hdate2,hdate) > 28 ){
	
		alert("入住时间段不能超过28天，请重新选择您的\“离店时间\”");
		$("#HS_search_date2").focus()
		return false;
	}
	
	if( $("#HS_search_area").val().length > 0 ){
		harea = $("#HS_search_area").val();
	}else{
		alert("请选择您要入住的\“酒店地区\”");
		$("#HS_search_area").focus()
		return false;	
	}	
	
	if( $("#HS_search_hotel").val().length > 0 ){
		hotel = $("#HS_search_hotel").val();
	}else{
		alert("请选择您要入住的\“酒店\”");
		$("#HS_search_hotel").focus()
		return false;		
	}
	

	urltxt = "revdata.php?amode=get_hs&hdate="+ hdate +"&hdate2="+ hdate2 +"&harea="+ harea +"&hotel="+ hotel + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_hs").show();
			$("#box_hs").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_hs").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});	
	
}
//选择旅馆
function SelectHS(id){
	
	HT_num = Number($("#HT_num").val());
	
	HT_num = HT_num + 1 ;
	
	$("#HT_num").val(HT_num) ;

	var table_show ="";
	
	table_show = $("#HT_select_box").html();
	table_show = table_show.replace("</TBODY>","");
	table_show = table_show.replace("</TABLE>","");
	table_show = table_show.replace("</tbody>","");
	table_show = table_show.replace("</table>","");

	HT_date_s 			= document.getElementById("HS_date_l_" + id).value;
	HT_date2_s 			= document.getElementById("HS_date2_l_" + id).value;
	HT_area_s 			= document.getElementById("HS_area_l_" + id).value;
	HT_hotel_s 			= document.getElementById("HS_hotel_l_" + id).value;
	HT_hotel_id_s 		= document.getElementById("HS_hotel_id_l_" + id).value;
	HT_memo_s 			= document.getElementById("HS_memo_l_" + id).value;
	HT_room_s 			= document.getElementById("HS_room_l_" + id).value;
	HT_room_num_s 		= Number(document.getElementById("HS_room_num_l_" + id).value);
	HT_room_price_s 	= Number(document.getElementById("HS_room_price_l_" + id).value);
	HT_room_priceadd_s	= Number(document.getElementById("HS_room_priceadd_l_" + id).value);	
	HT_days_s 			= Number(document.getElementById("HS_days_l_" + id).value);	
	HT_room_price_list_s 		= document.getElementById("HS_room_price_list_l_" + id).value;
	HT_room_priceadd_list_s 	= document.getElementById("HS_room_priceadd_list_l_" + id).value;
	HT_bf_info_list_s 			= document.getElementById("HS_bf_info_list_l_" + id).value;
	HT_printID_s 				= document.getElementById("HS_printID_l_" + id).value;
	
	HT_price_sum_s 			= Number(document.getElementById("HS_price_sum_l_" + id).value);
	HT_use_reserve_s 			= Number(document.getElementById("HS_use_reserve_l_" + id).value);

	HT_brf_num_s 			= Number(document.getElementById("HS_brf_num_l_" + id).value);
	HT_brf_price_s 			= Number(document.getElementById("HS_brf_price_l_" + id).value);
	HT_brf_price_add_s 		= Number(document.getElementById("HS_brf_price_add_l_" + id).value);
	HT_brf_num_kid_s 		= Number(document.getElementById("HS_brf_num_kid_l_" + id).value);
	HT_brf_price_kid_s 		= Number(document.getElementById("HS_brf_price_kid_l_" + id).value);
	HT_brf_price_kid_add_s 	= Number(document.getElementById("HS_brf_price_kid_add_l_" + id).value);
	HT_bed_num_s 			= Number(document.getElementById("HS_bed_num_l_" + id).value);
	HT_bed_price_s 			= Number(document.getElementById("HS_bed_price_l_" + id).value);
	HT_bed_price_add_s 		= Number(document.getElementById("HS_bed_price_add_l_" + id).value);

	var plus_str = "";
	
	if(HT_brf_num_s){
		plus_str  += "成早<font color=#FF0000>￥" + HT_brf_price_s + "</font> * " + HT_brf_num_s + "份 * " + HT_days_s + "晚<br/>";
	}
	if(HT_brf_num_kid_s){
		plus_str  += "童早<font color=#FF0000>￥" + HT_brf_price_kid_s + "</font> * " + HT_brf_num_kid_s + "份 * " + HT_days_s + "晚<br/>";
	}
	if(HT_bed_num_s){
		plus_str  += "加床<font color=#FF0000>￥" + HT_bed_price_s + "</font> * " + HT_bed_num_s + "份 * " + HT_days_s + "晚";
	}
	
	
	table_show  += "<tr>" ;
	
	//日期
	table_show  +=	"<td style=\"white-space:nowrap;\">" + HT_date_s + " 入住<br> "+HT_date2_s+" 离店</td>" ;
	//酒店
	table_show  +=	"<td>" + HT_hotel_s + "</td>" ;
	//房型
	table_show  +=	"<td>" + HT_room_s + " </td>" ;
	//费用
	table_show  +=	"<td style=\"white-space:nowrap;\">均价 <font color=#FF0000>￥" + HT_room_price_s + "</font> * " + HT_days_s + " 晚</td>" ;
	
	//加订
	if(plus_str){
		table_show  +=	"<td style=\"white-space:nowrap;\">" + plus_str + "</td>" ;
	}else{
		table_show  +=	"<td>无</td>" ;
	}

	//间数
	table_show  +=	"<td>" + HT_room_num_s + "</td>" ;
	
	//备注	
	if( HT_memo_s ){
		table_show  +=	"<td align=center><img src=/rev/images/memo.gif alt=\"备注：" + HT_memo_s + "\" border=0 style=\"cursor:pointer;\" onclick=\"alert($(this).attr('alt'));\" onMouseOver=\"window.status='点击可以查看';return true;\"> </td>" ;		
	}else{
		table_show  +=	"<td align=center>无</td>";
	}
	
	//预订数据
	table_show  +=	"<td align=center>\
	<input id=HT_s_" + HT_num + " type=button class=9ptblack value=删除 onClick=javascript:Delete_HT('HT_s_" + HT_num + "','" + HT_num + "');>\
	<input id=HT_area_s_" + HT_num + " name=HT_area_s_" + HT_num + " type=hidden value='" + HT_area_s + "'>\
	<input id=HT_hotel_s_" + HT_num + " name=HT_hotel_s_" + HT_num + " type=hidden value='" + HT_hotel_s + "'>\
	<input id=HT_hotel_id_s_" + HT_num + " name=HT_hotel_id_s_" + HT_num + " type=hidden value='" + HT_hotel_id_s + "'>\
	<input id=HT_memo_s_" + HT_num + " name=HT_memo_s_" + HT_num + " type=hidden value='" + HT_memo_s + "'>\
	<input id=HT_date_s_" + HT_num + " name=HT_date_s_" + HT_num + " type=hidden value='" + HT_date_s + "'>\
	<input id=HT_date2_s_" + HT_num + " name=HT_date2_s_" + HT_num + " type=hidden value='" + HT_date2_s + "'>\
	<input id=HT_room_price_list_s_" + HT_num + " name=HT_room_price_list_s_" + HT_num + " type=hidden value='" + HT_room_price_list_s + "'>\
	<input id=HT_room_priceadd_list_s_" + HT_num + "  name=HT_room_priceadd_list_s_" + HT_num + " type=hidden value='" + HT_room_priceadd_list_s + "'>\
	<input id=HT_room_s_" + HT_num + " name=HT_room_s_" + HT_num + " type=hidden value='" + HT_room_s + "'>\
	<input id=HT_room_price_s_" + HT_num + " name=HT_room_price_s_" + HT_num + " type=hidden value='" + HT_room_price_s + "'>\
	<input id=HT_room_priceadd_s_" + HT_num + " name=HT_room_priceadd_s_" + HT_num + " type=hidden value='" + HT_room_priceadd_s + "'>\
	<input id=HT_room_num_s_" + HT_num + " name=HT_room_num_s_" + HT_num + " type=hidden value='" + HT_room_num_s + "'>\
	<input id=HT_days_s_" + HT_num + " name=HT_days_s_" + HT_num + " type=hidden value='" + HT_days_s + "'>\
	<input id=HT_bf_info_list_s_" + HT_num + " name=HT_bf_info_list_s_" + HT_num + " type=hidden value='" + HT_bf_info_list_s + "'>\
	<input id=HT_printID_s_" + HT_num + " name=HT_printID_s_" + HT_num + " type=hidden value='" + HT_printID_s + "'>\
	<input id=HT_price_sum_s_" + HT_num + " name=HT_price_sum_s_" + HT_num + " type=hidden value='" + HT_price_sum_s + "'>\
	<input id=HT_use_reserve_s_" + HT_num + " name=HT_use_reserve_s_" + HT_num + " type=hidden value='" + HT_use_reserve_s + "'>\
	<input id=\"HT_brf_num_s_" + HT_num + "\" name=\"HT_brf_num_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_num_s + "'>\
	<input id=\"HT_brf_price_s_" + HT_num + "\" name=\"HT_brf_price_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_s + "'>\
	<input id=\"HT_brf_price_add_s_" + HT_num + "\" name=\"HT_brf_price_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_add_s + "'>\
	<input id=\"HT_brf_num_kid_s_" + HT_num + "\" name=\"HT_brf_num_kid_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_num_kid_s + "'>\
	<input id=\"HT_brf_price_kid_s_" + HT_num + "\" name=\"HT_brf_price_kid_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_kid_s + "'>\
	<input id=\"HT_brf_price_kid_add_s_" + HT_num + "\" name=\"HT_brf_price_kid_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_kid_add_s + "'>\
	<input id=\"HT_bed_num_s_" + HT_num + "\" name=\"HT_bed_num_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_num_s + "'>\
	<input id=\"HT_bed_price_s_" + HT_num + "\" name=\"HT_bed_price_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_price_s + "'>\
	<input id=\"HT_bed_price_add_s_" + HT_num + "\" name=\"HT_bed_price_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_price_add_s + "'>\
</td>" ;
	table_show  +=	"</tr>";	
	
	table_show += "</TBODY></TABLE>";

	//载入表格
	$("#HT_select_box").html(table_show) ;
	//显示酒店购物车
	$("#HT_buy_cart").show();


	//计算价格
	
	var price ;
	
	price = ( HT_price_sum_s * HT_room_num_s ) + (HT_brf_num_s * HT_brf_price_s * HT_days_s * HT_room_num_s) + (HT_brf_num_kid_s * HT_brf_price_kid_s * HT_days_s * HT_room_num_s) + (HT_bed_num_s * HT_bed_price_s * HT_days_s * HT_room_num_s);

	
	$("#HT_total").val(Number($("#HT_total").val()) + price);
	
	count_total();
	
	alert("成功添加到“已选项目”！");
	
	
}


//查询酒店
function SearchHT(){
	var hdate = "";
	var hdate2 = "";
	var harea = "";
	var hotel = "";
	
	if($("#Hsearch_date").val().length > 0){
		hdate = $("#Hsearch_date").val();
		
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#Hsearch_date").focus()
		return false;
	}
	
	if($("#Hsearch_date2").val().length > 0){
		hdate2 = $("#Hsearch_date2").val();
	}else{
		alert("\“离店日期\”不可以为空！请选择离店日期");
		$("#Hsearch_date2").focus()
		return false;
	}
	
	if( DateDiff(hdate2,hdate) < 1 ){
	
		alert("\“离店日期\”必须大于\“入住日期\”，请重新选择\"离店日期\"");
		$("#Hsearch_date2").focus()
		return false;
	}
	
	if( DateDiff(hdate2,hdate) > 28 ){
	
		alert("入住时间段不能超过28天，请重新选择您的\“离店时间\”");
		$("#Hsearch_date2").focus()
		return false;
	}
	
	if( $("#Hsearch_area").val().length > 0 ){
		harea = $("#Hsearch_area").val();
	}else{
		alert("请选择您要入住的\“酒店地区\”");
		$("#Hsearch_area").focus()
		return false;	
	}	
	
	if( $("#Hsearch_hotel").val().length > 0 ){
		hotel = $("#Hsearch_hotel").val();
	}else{
		alert("请选择您要入住的\“酒店\”");
		$("#Hsearch_hotel").focus()
		return false;		
	}
	

	urltxt = "revdata.php?amode=get_ht&hdate="+ hdate +"&hdate2="+ hdate2 +"&harea="+ harea +"&hotel="+ hotel + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_ht").show();
			$("#box_ht").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_ht").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});	
	
}

//选择酒店
function SelectHT(id){
	
	HT_num = Number($("#HT_num").val());
	
	HT_num = HT_num + 1 ;
	
	$("#HT_num").val(HT_num) ;

	var table_show ="";
	
	table_show = $("#HT_select_box").html();
	table_show = table_show.replace("</TBODY>","");
	table_show = table_show.replace("</TABLE>","");
	table_show = table_show.replace("</tbody>","");
	table_show = table_show.replace("</table>","");

	HT_date_s 			= document.getElementById("HT_date_l_" + id).value;
	HT_date2_s 			= document.getElementById("HT_date2_l_" + id).value;
	HT_area_s 			= document.getElementById("HT_area_l_" + id).value;
	HT_hotel_s 			= document.getElementById("HT_hotel_l_" + id).value;
	HT_hotel_id_s 		= document.getElementById("HT_hotel_id_l_" + id).value;
	HT_memo_s 			= document.getElementById("HT_memo_l_" + id).value;
	HT_room_s 			= document.getElementById("HT_room_l_" + id).value;
	HT_room_num_s 		= Number(document.getElementById("HT_room_num_l_" + id).value);
	HT_room_price_s 	= Number(document.getElementById("HT_room_price_l_" + id).value);
	HT_room_priceadd_s	= Number(document.getElementById("HT_room_priceadd_l_" + id).value);	
	HT_days_s 			= Number(document.getElementById("HT_days_l_" + id).value);	
	HT_room_price_list_s 		= document.getElementById("HT_room_price_list_l_" + id).value;
	HT_room_priceadd_list_s 	= document.getElementById("HT_room_priceadd_list_l_" + id).value;
	HT_bf_info_list_s 			= document.getElementById("HT_bf_info_list_l_" + id).value;
	HT_printID_s 				= document.getElementById("HT_printID_l_" + id).value;
	
	HT_price_sum_s 			= Number(document.getElementById("HT_price_sum_l_" + id).value);
	HT_use_reserve_s 			= Number(document.getElementById("HT_use_reserve_l_" + id).value);
	
	HT_brf_num_s 			= Number(document.getElementById("HT_brf_num_l_" + id).value);
	HT_brf_price_s 			= Number(document.getElementById("HT_brf_price_l_" + id).value);
	HT_brf_price_add_s 		= Number(document.getElementById("HT_brf_price_add_l_" + id).value);
	HT_brf_num_kid_s 		= Number(document.getElementById("HT_brf_num_kid_l_" + id).value);
	HT_brf_price_kid_s 		= Number(document.getElementById("HT_brf_price_kid_l_" + id).value);
	HT_brf_price_kid_add_s 	= Number(document.getElementById("HT_brf_price_kid_add_l_" + id).value);
	HT_bed_num_s 			= Number(document.getElementById("HT_bed_num_l_" + id).value);
	HT_bed_price_s 			= Number(document.getElementById("HT_bed_price_l_" + id).value);
	HT_bed_price_add_s 		= Number(document.getElementById("HT_bed_price_add_l_" + id).value);

	var plus_str = "";
	
	if(HT_brf_num_s){
		plus_str  += "成早<font color=#FF0000>￥" + HT_brf_price_s + "</font> * " + HT_brf_num_s + "份 * "  + HT_days_s + "晚<br/>";
	}
	if(HT_brf_num_kid_s){
		plus_str  += "童早<font color=#FF0000>￥" + HT_brf_price_kid_s + "</font> * " + HT_brf_num_kid_s + "份 * " + HT_days_s + "晚<br/>";
	}
	if(HT_bed_num_s){
		plus_str  += "加床<font color=#FF0000>￥" + HT_bed_price_s + "</font> * " + HT_bed_num_s + "份 * " + HT_days_s + "晚";
	}

	table_show  += "<tr>" ;
	
	//日期
	table_show  +=	"<td style=\"white-space:nowrap;\">" + HT_date_s + " 入住<br> "+HT_date2_s+" 离店</td>" ;
	//酒店
	table_show  +=	"<td>" + HT_hotel_s + "</td>" ;
	//房型
	table_show  +=	"<td>" + HT_room_s + " </td>" ;
	//费用
	table_show  +=	"<td style=\"white-space:nowrap;\">均价 <font color=#FF0000>￥" + HT_room_price_s + "</font> * " + HT_days_s + " 晚</td>" ;
	
	//加订
	if(plus_str){
		table_show  +=	"<td style=\"white-space:nowrap;\">" + plus_str + "</td>" ;
	}else{
		table_show  +=	"<td>无</td>" ;
	}

	//间数
	table_show  +=	"<td>" + HT_room_num_s + "</td>" ;
	
	//备注	
	if( HT_memo_s ){
		table_show  +=	"<td align=center><img src=/rev/images/memo.gif alt=\"备注：" + HT_memo_s + "\" border=0 style=\"cursor:pointer;\" onclick=\"alert($(this).attr('alt'));\" onMouseOver=\"window.status='点击可以查看';return true;\"> </td>" ;		
	}else{
		table_show  +=	"<td align=center>无</td>";
	}
	
	//预订数据
	table_show  +=	"<td align=center>\
	<input id=\"HT_s_" + HT_num + "\" type=\"button\" value=\"删除\" onClick=\"javascript:Delete_HT('HT_s_" + HT_num + "','" + HT_num + "');\">\
	<input id=\"HT_area_s_" + HT_num + "\" name=\"HT_area_s_" + HT_num + "\" type=\"hidden\" value='" + HT_area_s + "'>\
	<input id=\"HT_hotel_s_" + HT_num + "\" name=\"HT_hotel_s_" + HT_num + "\" type=\"hidden\" value='" + HT_hotel_s + "'>\
	<input id=\"HT_hotel_id_s_" + HT_num + "\" name=\"HT_hotel_id_s_" + HT_num + "\" type=hidden value='" + HT_hotel_id_s + "'>\
	<input id=\"HT_memo_s_" + HT_num + "\" name=\"HT_memo_s_" + HT_num + "\" type=\"hidden\" value='" + HT_memo_s + "'>\
	<input id=\"HT_date_s_" + HT_num + "\" name=\"HT_date_s_" + HT_num + "\" type=\"hidden\" value='" + HT_date_s + "'>\
	<input id=\"HT_date2_s_" + HT_num + "\" name=\"HT_date2_s_" + HT_num + "\" type=\"hidden\" value='" + HT_date2_s + "'>\
	<input id=\"HT_room_price_list_s_" + HT_num + "\" name=\"HT_room_price_list_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_price_list_s + "'>\
	<input id=\"HT_room_priceadd_list_s_" + HT_num + "\"  name=\"HT_room_priceadd_list_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_priceadd_list_s + "'>\
	<input id=\"HT_room_s_" + HT_num + "\" name=\"HT_room_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_s + "'>\
	<input id=\"HT_room_price_s_" + HT_num + "\" name=\"HT_room_price_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_price_s + "'>\
	<input id=\"HT_room_priceadd_s_" + HT_num + "\" name=\"HT_room_priceadd_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_priceadd_s + "'>\
	<input id=\"HT_room_num_s_" + HT_num + "\" name=\"HT_room_num_s_" + HT_num + "\" type=\"hidden\" value='" + HT_room_num_s + "'>\
	<input id=\"HT_days_s_" + HT_num + "\" name=\"HT_days_s_" + HT_num + "\" type=\"hidden\" value='" + HT_days_s + "'>\
	<input id=\"HT_bf_info_list_s_" + HT_num + "\" name=\"HT_bf_info_list_s_" + HT_num + "\" type=hidden value='" + HT_bf_info_list_s + "'>\
	<input id=\"HT_printID_s_" + HT_num + "\" name=\"HT_printID_s_" + HT_num + "\" type=\"hidden\" value='" + HT_printID_s + "'>\
	<input id=\"HT_price_sum_s_" + HT_num + "\" name=\"HT_price_sum_s_" + HT_num + "\" type=\"hidden\" value='" + HT_price_sum_s + "'>\
	<input id=\"HT_use_reserve_s_" + HT_num + "\" name=\"HT_use_reserve_s_" + HT_num + "\" type=hidden value='" + HT_use_reserve_s + "'>\
	<input id=\"HT_brf_num_s_" + HT_num + "\" name=\"HT_brf_num_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_num_s + "'>\
	<input id=\"HT_brf_price_s_" + HT_num + "\" name=\"HT_brf_price_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_s + "'>\
	<input id=\"HT_brf_price_add_s_" + HT_num + "\" name=\"HT_brf_price_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_add_s + "'>\
	<input id=\"HT_brf_num_kid_s_" + HT_num + "\" name=\"HT_brf_num_kid_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_num_kid_s + "'>\
	<input id=\"HT_brf_price_kid_s_" + HT_num + "\" name=\"HT_brf_price_kid_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_kid_s + "'>\
	<input id=\"HT_brf_price_kid_add_s_" + HT_num + "\" name=\"HT_brf_price_kid_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_brf_price_kid_add_s + "'>\
	<input id=\"HT_bed_num_s_" + HT_num + "\" name=\"HT_bed_num_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_num_s + "'>\
	<input id=\"HT_bed_price_s_" + HT_num + "\" name=\"HT_bed_price_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_price_s + "'>\
	<input id=\"HT_bed_price_add_s_" + HT_num + "\" name=\"HT_bed_price_add_s_" + HT_num + "\" type=\"hidden\" value='" + HT_bed_price_add_s + "'>\
</td>" ;
	table_show  +=	"</tr>";	
	
	table_show += "</TBODY></TABLE>";

	//载入表格
	$("#HT_select_box").html(table_show) ;
	//显示酒店购物车
	$("#HT_buy_cart").show();


	//计算价格
	
	var price ;
	
	price = ( HT_price_sum_s * HT_room_num_s ) + (HT_brf_num_s * HT_brf_price_s * HT_days_s * HT_room_num_s) + (HT_brf_num_kid_s * HT_brf_price_kid_s * HT_days_s * HT_room_num_s) + (HT_bed_num_s * HT_bed_price_s * HT_days_s * HT_room_num_s);

	
	$("#HT_total").val(Number($("#HT_total").val()) + price);
	
	count_total();
	
	alert("成功添加到“已选项目”！");
	
}


//删除酒店
function Delete_HT(btn,id){
	
	if (confirm('您确认要删除吗?\n')) {
	
		HT_room_num_s 			= Number(document.getElementById("HT_room_num_s_" + id).value);
		HT_price_sum_s 			= Number(document.getElementById("HT_price_sum_s_" + id).value);
		HT_days_s 				= Number(document.getElementById("HT_days_s_" + id).value);
		HT_brf_num_s 			= Number(document.getElementById("HT_brf_num_s_" + id).value);
		HT_brf_price_s 			= Number(document.getElementById("HT_brf_price_s_" + id).value);
		HT_brf_price_add_s 		= Number(document.getElementById("HT_brf_price_add_s_" + id).value);
		HT_brf_num_kid_s 		= Number(document.getElementById("HT_brf_num_kid_s_" + id).value);
		HT_brf_price_kid_s 		= Number(document.getElementById("HT_brf_price_kid_s_" + id).value);
		HT_brf_price_kid_add_s 	= Number(document.getElementById("HT_brf_price_kid_add_s_" + id).value);
		HT_bed_num_s 			= Number(document.getElementById("HT_bed_num_s_" + id).value);
		HT_bed_price_s 			= Number(document.getElementById("HT_bed_price_s_" + id).value);
		HT_bed_price_add_s 		= Number(document.getElementById("HT_bed_price_add_s_" + id).value);
		
		var price ;
			
		price = ( HT_price_sum_s * HT_room_num_s ) + (HT_brf_num_s * HT_brf_price_s * HT_days_s * HT_room_num_s) + (HT_brf_num_kid_s * HT_brf_price_kid_s * HT_days_s * HT_room_num_s) + (HT_bed_num_s * HT_bed_price_s * HT_days_s * HT_room_num_s);
		
		
		$("#HT_total").val( Number($("#HT_total").val()) - price );
		
		count_total();
		
		if( $("#HT_total").val() == '0'){
			//隐藏购物车
			$("#HT_buy_cart").hide();
		}

		var obj = document.getElementById(btn);
			removeTr(obj);
		}
		
	return false;
}

//查询套餐自动型
function SearchSTauto(id){

	var Sdate = "";
	var Ssuite = "";
	var Sroom = "";
	
	if($("#Ssearch_suite").val().length > 0){
		Ssuite = $("#Ssearch_suite").val();
	}else{
		alert("请选择一个酒店套餐！");
		$("#Ssearch_suitename").focus();
		return false;
	}

	if(document.getElementById("Ssearch_date").value.length > 0){
		Sdate = document.getElementById("Ssearch_date").value;
		
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#Ssearch_date").focus();
		return false;
	}
	
	Sadddays = $("#Ssearch_add_days").val();
	
	urltxt = "revdata.php?amode=get_st&Sdate="+ Sdate +"&Ssuite="+ Ssuite + "&Sroom="+ Sroom + "&Sadddays="+ Sadddays + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_st").show();
			$("#box_st").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_st").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});		

}

//查询套餐
function SearchST(id){

	var Sdate = "";
	var Ssuite = "";
	
	if($("#Ssearch_suite").val().length > 0){
		Ssuite = $("#Ssearch_suite").val();
		
	}else{
		alert("请选择一个酒店套餐！");
		$("#Ssearch_suitename").focus();
		return false;
	}
	
	if(document.getElementById("Ssearch_room").value.length > 0){
		Sroom = document.getElementById("Ssearch_room").value;
		
	}else{
		alert("请选择一个套餐房型！");
		$("#Ssearch_room").focus();
		return false;
	}

	if(document.getElementById("Ssearch_date").value.length > 0){
		Sdate = document.getElementById("Ssearch_date").value;
		
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#Ssearch_date").focus();
		return false;
	}
	
	Sadddays = $("#Ssearch_add_days").val();
	
	urltxt = "revdata.php?amode=get_st&Sdate="+ Sdate +"&Ssuite="+ Ssuite + "&Sroom="+ Sroom + "&Sadddays="+ Sadddays + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_st").show();
			$("#box_st").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_st").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});		

}


//选择套餐
function SelectST(id){
	

	ST_date_s 			= document.getElementById("ST_date_l_" + id).value;
	ST_area_s 			= document.getElementById("ST_area_l_" + id).value;
	ST_suite_name_s 	= document.getElementById("ST_suite_name_l_" + id).value;
	ST_hotel_s 			= document.getElementById("ST_hotel_l_" + id).value;
	ST_hotel_id_s 			= document.getElementById("ST_hotel_id_l_" + id).value;
	ST_room_name_s  	= document.getElementById("ST_room_name_l_" + id).value;
	ST_days_s 			= Number(document.getElementById("ST_days_l_" + id).value);
	ST_Sadddays_s		= Number(document.getElementById("ST_Sadddays_l_" + id).value);
	ST_Sadddays_price_s	= Number(document.getElementById("ST_Sadddays_price_l_" + id).value);
	ST_num_s 			= Number(document.getElementById("ST_num_l_" + id).value);
	ST_price_s 			= Number(document.getElementById("ST_pirce_l_" + id).value);
	ST_priceadd_s 		= Number(document.getElementById("ST_pirce_add_l_" + id).value);
	ST_daysprice_s 		= document.getElementById("ST_daysprice_l_" + id).value;
	ST_printID_s 		= document.getElementById("ST_printID_l_" + id).value;
	ST_use_reserve_s 		= document.getElementById("ST_use_reserve_l_" + id).value;

	ST_brf_num_s 			= Number(document.getElementById("ST_brf_num_l_" + id).value);
	ST_brf_price_s 			= Number(document.getElementById("ST_brf_price_l_" + id).value);
	ST_brf_price_add_s 		= Number(document.getElementById("ST_brf_price_add_l_" + id).value);
	ST_brf_num_kid_s 		= Number(document.getElementById("ST_brf_num_kid_l_" + id).value);
	ST_brf_price_kid_s 		= Number(document.getElementById("ST_brf_price_kid_l_" + id).value);
	ST_brf_price_kid_add_s 	= Number(document.getElementById("ST_brf_price_kid_add_l_" + id).value);
	ST_bed_num_s 			= Number(document.getElementById("ST_bed_num_l_" + id).value);
	ST_bed_price_s 			= Number(document.getElementById("ST_bed_price_l_" + id).value);
	ST_bed_price_add_s 		= Number(document.getElementById("ST_bed_price_add_l_" + id).value);

	var plus_str="";
	
	if(ST_brf_num_s){
		plus_str  += "成早<font color=#FF0000>￥" + ST_brf_price_s + "</font> * " + ST_brf_num_s + "份 * " + ST_days_s + "晚<br/>";
	}
	if(ST_brf_num_kid_s){
		plus_str  += "童早<font color=#FF0000>￥" + ST_brf_price_kid_s + "</font> * " + ST_brf_num_kid_s + "份 * "  + ST_days_s + "晚<br/>";
	}
	if(ST_bed_num_s){
		plus_str  += "加床<font color=#FF0000>￥" + ST_bed_price_s + "</font> * " + ST_bed_num_s + "份 * "  + ST_days_s + "晚";
	}

	var ST_num;
	ST_num = Number($("#ST_num").val());
	ST_num = ST_num + 1 ;
	$("#ST_num").val(ST_num) ;

	var table_show ="";
	table_show = document.getElementById("ST_select_box").innerHTML;
	table_show = table_show.replace("</TBODY>","");
	table_show = table_show.replace("</TABLE>","");
	table_show = table_show.replace("</tbody>","");
	table_show = table_show.replace("</table>","");
	
	table_show  += "<tr>" ;
	//日期
	table_show  +=	"<td style=\"white-space:nowrap;\">" + ST_date_s + "</td>" ;
	//套餐
	table_show  +=	"<td>" + ST_hotel_s + " " + ST_suite_name_s + "</td>" ;
	//房型
	table_show  +=	"<td>" + ST_room_name_s + "</td>" ;
	//费用
	table_show  +=	"<td style=\"white-space:nowrap;\"><font color=#FF0000>￥" + (ST_price_s + ST_priceadd_s) + "</font></td>" ;
	//延住
	if( ST_Sadddays_s ){
		table_show  +=	"<td>均价<font color=#FF0000>￥" + ST_Sadddays_price_s + "</font> * " + ST_Sadddays_s + "晚</td>" ;		
	}else{
		table_show  +=	"<td align=center>无</td>";
	}

	//加订
	if(plus_str){
		table_show  +=	"<td style=\"white-space:nowrap;\">" + plus_str + "</td>" ;
	}else{
		table_show  +=	"<td>无</td>" ;
	}
	
	//数量
	table_show  +=	"<td style=\"white-space:nowrap;\">" + ST_num_s + "</td>" ;	

	//删除
	table_show  +=	"<td align=center><input id=ST_s_" + ST_num + " type=button class=9ptblack value=删除 onClick=javascript:Delete_ST('ST_s_" + ST_num + "','" + ST_num + "');>\
	<input id=\"ST_date_s_" + ST_num + "\" name=\"ST_date_s_" + ST_num + "\" type=\"hidden\" value='" + ST_date_s + "'>\
	<input id=\"ST_area_s_" + ST_num + "\" name=\"ST_area_s_" + ST_num + "\" type=hidden value='" + ST_area_s + "'>\
	<input id=\"ST_suite_name_s_" + ST_num + "\" name=\"ST_suite_name_s_" + ST_num + "\" type=hidden value='" + ST_suite_name_s + "'>\
	<input id=\"ST_hotel_s_" + ST_num + "\" name=\"ST_hotel_s_" + ST_num + "\" type=hidden value='" + ST_hotel_s + "'>\
	<input id=\"ST_hotel_id_s_" + ST_num + "\" name=\"ST_hotel_id_s_" + ST_num + "\" type=hidden value='" + ST_hotel_id_s + "'>\
	<input id=\"ST_room_name_s_" + ST_num + "\" name=\"ST_room_name_s_" + ST_num + "\" type=hidden value='" + ST_room_name_s + "'>\
	<input id=\"ST_days_s_" + ST_num + "\" name=\"ST_days_s_" + ST_num + "\" type=\"hidden\" value='" + ST_days_s + "'>\
	<input id=\"ST_Sadddays_s_" + ST_num + "\" name=\"ST_Sadddays_s_" + ST_num + "\" type=\"hidden\" value='" + ST_Sadddays_s + "'>\
	<input id=\"ST_Sadddays_price_s_" + ST_num + "\" name=\"ST_Sadddays_price_s_" + ST_num + "\" type=hidden value='" + ST_Sadddays_price_s + "'>\
	<input id=\"ST_num_s_" + ST_num + "\" name=\"ST_num_s_" + ST_num + "\" type=\"hidden\" value='" + ST_num_s + "'>\
	<input id=\"ST_price_s_" + ST_num + "\" name=\"ST_price_s_" + ST_num + "\" type=\"hidden\" value='" + ST_price_s + "'>\
	<input id=\"ST_priceadd_s_" + ST_num + "\" name=\"ST_priceadd_s_" + ST_num + "\" type=\"hidden\" value='" + ST_priceadd_s + "'>\
	<input id=\"ST_daysprice_s_" + ST_num + "\" name=\"ST_daysprice_s_" + ST_num + "\" type=hidden value='" + ST_daysprice_s + "'>\
	<input id=\"ST_use_reserve_s_" + ST_num + "\" name=\"ST_use_reserve_s_" + ST_num + "\" type=hidden value='" + ST_use_reserve_s + "'>\
	<input id=\"ST_printID_s_" + ST_num + "\" name=\"ST_printID_s_" + ST_num + "\" type=\"hidden\" value='" + ST_printID_s + "'>\
	<input id=\"ST_brf_num_s_" + ST_num + "\" name=\"ST_brf_num_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_num_s + "'>\
	<input id=\"ST_brf_price_s_" + ST_num + "\" name=\"ST_brf_price_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_price_s + "'>\
	<input id=\"ST_brf_price_add_s_" + ST_num + "\" name=\"ST_brf_price_add_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_price_add_s + "'>\
	<input id=\"ST_brf_num_kid_s_" + ST_num + "\" name=\"ST_brf_num_kid_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_num_kid_s + "'>\
	<input id=\"ST_brf_price_kid_s_" + ST_num + "\" name=\"ST_brf_price_kid_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_price_kid_s + "'>\
	<input id=\"ST_brf_price_kid_add_s_" + ST_num + "\" name=\"ST_brf_price_kid_add_s_" + ST_num + "\" type=\"hidden\" value='" + ST_brf_price_kid_add_s + "'>\
	<input id=\"ST_bed_num_s_" + ST_num + "\" name=\"ST_bed_num_s_" + ST_num + "\" type=\"hidden\" value='" + ST_bed_num_s + "'>\
	<input id=\"ST_bed_price_s_" + ST_num + "\" name=\"ST_bed_price_s_" + ST_num + "\" type=\"hidden\" value='" + ST_bed_price_s + "'>\
	<input id=\"ST_bed_price_add_s_" + ST_num + "\" name=\"ST_bed_price_add_s_" + ST_num + "\" type=\"hidden\" value='" + ST_bed_price_add_s + "'>\
	</td>" ;
	table_show  +=	"</tr>";	
	table_show += "</TBODY></TABLE>";

	//载入表格
	$("#ST_select_box").html(table_show) ;
	//显示酒店购物车
	$("#ST_buy_cart").show();
	
	var price ;
	price = ( ST_price_s + ST_priceadd_s ) * ST_num_s + (ST_brf_num_s * ST_brf_price_s * ST_days_s * ST_num_s) + (ST_brf_num_kid_s * ST_brf_price_kid_s * ST_days_s * ST_num_s) + (ST_bed_num_s * ST_bed_price_s  * ST_days_s * ST_num_s);;
	$("#ST_total").val( Number($("#ST_total").val()) + price );
	$("#ST_select_box").html(table_show);
	
	count_total();
	
	alert("成功添加到“已选项目”！");

}


//删除套餐
function Delete_ST(btn,id){
	
	if (confirm('您确认要删除吗?\n')) {
		ST_price_s 	= Number(document.getElementById("ST_price_s_" + id).value);
		ST_priceadd_s = Number(document.getElementById("ST_priceadd_s_" + id).value);
		ST_num_s 	= Number(document.getElementById("ST_num_s_" + id).value);
		
		ST_days_s 				= Number(document.getElementById("ST_days_s_" + id).value);
		ST_brf_num_s 			= Number(document.getElementById("ST_brf_num_s_" + id).value);
		ST_brf_price_s 			= Number(document.getElementById("ST_brf_price_s_" + id).value);
		ST_brf_price_add_s 		= Number(document.getElementById("ST_brf_price_add_s_" + id).value);
		ST_brf_num_kid_s 		= Number(document.getElementById("ST_brf_num_kid_s_" + id).value);
		ST_brf_price_kid_s 		= Number(document.getElementById("ST_brf_price_kid_s_" + id).value);
		ST_brf_price_kid_add_s 	= Number(document.getElementById("ST_brf_price_kid_add_s_" + id).value);
		ST_bed_num_s 			= Number(document.getElementById("ST_bed_num_s_" + id).value);
		ST_bed_price_s 			= Number(document.getElementById("ST_bed_price_s_" + id).value);
		ST_bed_price_add_s 		= Number(document.getElementById("ST_bed_price_add_s_" + id).value);
	
		var price ;
		price = ( ST_price_s + ST_priceadd_s ) * ST_num_s + (ST_brf_num_s * ST_brf_price_s * ST_days_s * ST_num_s) + (ST_brf_num_kid_s * ST_brf_price_kid_s * ST_days_s * ST_num_s) + (ST_bed_num_s * ST_bed_price_s  * ST_days_s * ST_num_s);
		
		$("#ST_total").val( Number($("#ST_total").val()) - price );
		
		if( $("#ST_total").val() == '0'){
			//隐藏购物车
			$("#ST_buy_cart").hide();
		}
		
		count_total();
		var obj = document.getElementById(btn);
		removeTr(obj);
	}
	return false;
}


//查询惊喜特价自动型
function SearchSPauto(id){
	
	var Pindate,Poutdate,Pname,Proom_id,Pldays;
	
	if($("#Psearch_room_name").val().length > 0){
		Pname = $("#Psearch_room_name").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}

	if($("#Psearch_special_id").val().length > 0){
		Proom_id = $("#Psearch_special_id").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}
	
	if($("#Psearch_special_days").val().length > 0){
		Pldays = $("#Psearch_special_days").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}

	if(document.getElementById("Psearch_date").value.length > 0){
		Pindate = document.getElementById("Psearch_date").value;
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#Psearch_date").focus();
		return false;
	}

	if(document.getElementById("Psearch_date2").value.length > 0){
		Poutdate = document.getElementById("Psearch_date2").value;
	}else{
		alert("\“离店日期\”不可以为空！请选择离店日期");
		$("#Psearch_date2").focus();
		return false;
	}
	
	if( DateDiff(Poutdate,Pindate) < 1 ){
		alert("\“离店日期\”必须大于\“入住日期\”，请重新选择\"离店日期\"");
		$("#Psearch_date2").focus()
		return false;
	}

	if( DateDiff(Poutdate,Pindate) < Pldays ){
		alert("此特价房型‘"+ Pldays +"’晚起订，请重新选择\"离店日期\"");
		$("#Psearch_date2").focus()
		return false;
	}

	if( DateDiff(Poutdate,Pindate) > 28 ){
		alert("入住时间段不能超过28天，请重新选择您的\“离店时间\”");
		$("#Psearch_date2").focus()
		return false;
	}

	urltxt = "revdata.php?amode=get_sp&Pindate="+ Pindate +"&Poutdate="+ Poutdate +"&Pname="+ Pname + "&Proom_id="+ Proom_id  + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_sp").show();
			$("#box_sp").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_sp").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});		


}
//查询惊喜特价
function SearchSP(id){

	var Pindate,Poutdate,Pname,Proom_id,Pldays;
	
	if($("#Psearch_room_name").val().length > 0){
		Pname = $("#Psearch_room_name").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}

	if($("#Psearch_special_id").val().length > 0){
		Proom_id = $("#Psearch_special_id").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}
	
	if($("#Psearch_special_days").val().length > 0){
		Pldays = $("#Psearch_special_days").val();
	}else{
		alert("请选择一个特价房型！");
		$("#Psearch_room_name").focus();
		return false;
	}

	if(document.getElementById("Psearch_date").value.length > 0){
		Pindate = document.getElementById("Psearch_date").value;
	}else{
		alert("\“入住日期\”不可以为空！请选择入住日期");
		$("#Psearch_date").focus();
		return false;
	}

	if(document.getElementById("Psearch_date2").value.length > 0){
		Poutdate = document.getElementById("Psearch_date2").value;
	}else{
		alert("\“离店日期\”不可以为空！请选择离店日期");
		$("#Psearch_date2").focus();
		return false;
	}
	
	if( DateDiff(Poutdate,Pindate) < 1 ){
		alert("\“离店日期\”必须大于\“入住日期\”，请重新选择\"离店日期\"");
		$("#Psearch_date2").focus()
		return false;
	}

	if( DateDiff(Poutdate,Pindate) < Pldays ){
		alert("此特价房型‘"+ Pldays +"’晚起订，请重新选择\"离店日期\"");
		$("#Psearch_date2").focus()
		return false;
	}

	if( DateDiff(Poutdate,Pindate) > 28 ){
		alert("入住时间段不能超过28天，请重新选择您的\“离店时间\”");
		$("#Psearch_date2").focus()
		return false;
	}

	urltxt = "revdata.php?amode=get_sp&Pindate="+ Pindate +"&Poutdate="+ Poutdate +"&Pname="+ Pname + "&Proom_id="+ Proom_id  + "&timestamp" + new Date().getTime();

	$.ajax({
		type: "get",
		url:urltxt,
		beforeSend: function(XMLHttpRequest){
			$("#box_sp").show();
			$("#box_sp").html("<img src='/images/ajax-loader.gif' border='0' align='absmiddle' />　正在读取数据中……");
		},
		success: function(data, textStatus){
			$("#box_sp").html(data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//$("#Hsearch_hotel_list").show();
		},
		error: function(){
			//alert("数据读取失败");
			return false;	
		}
	});		

}


//选择惊喜特价
function SelectSP(id){
	

	SP_num = Number($("#SP_num").val());
	
	SP_num = SP_num + 1 ;
	
	$("#SP_num").val(SP_num) ;

	var table_show ="";
	
	table_show = $("#SP_select_box").html();
	table_show = table_show.replace("</TBODY>","");
	table_show = table_show.replace("</TABLE>","");
	table_show = table_show.replace("</tbody>","");
	table_show = table_show.replace("</table>","");

	SP_indate_s 			= document.getElementById("SP_indate_l_" + id).value;
	SP_outdate_s 			= document.getElementById("SP_outdate_l_" + id).value;
	SP_area_s 				= document.getElementById("SP_area_l_" + id).value;
	SP_hotel_s 				= document.getElementById("SP_hotel_l_" + id).value;
	SP_hotel_id_s 				= document.getElementById("SP_hotel_id_l_" + id).value;
	SP_room_s 				= document.getElementById("SP_room_l_" + id).value;
	SP_days_s 				= Number(document.getElementById("SP_days_l_" + id).value);
	SP_memo_s 				= document.getElementById("SP_memo_l_" + id).value;
	SP_room_price_s 		= Number(document.getElementById("SP_room_price_l_" + id).value);
	SP_room_priceadd_s		= Number(document.getElementById("SP_room_priceadd_l_" + id).value);	
	SP_room_price_list_s 	= document.getElementById("SP_room_price_list_l_" + id).value;	
	SP_room_priceadd_list_s = document.getElementById("SP_room_priceadd_list_l_" + id).value;
	SP_bf_info_list_s 		= document.getElementById("SP_bf_info_list_l_" + id).value;
	SP_limitdays_s			= Number(document.getElementById("SP_limitdays_l_" + id).value);
	SP_printID_s 			= document.getElementById("SP_printID_l_" + id).value;
	SP_room_num_s 			= Number(document.getElementById("SP_room_num_l_" + id).value);
	SP_price_sum_s 			= Number(document.getElementById("SP_price_sum_l_" + id).value);
	SP_use_reserve_s 			= Number(document.getElementById("SP_use_reserve_l_" + id).value);

	SP_brf_num_s 			= Number(document.getElementById("SP_brf_num_l_" + id).value);
	SP_brf_price_s 			= Number(document.getElementById("SP_brf_price_l_" + id).value);
	SP_brf_price_add_s 		= Number(document.getElementById("SP_brf_price_add_l_" + id).value);
	SP_brf_num_kid_s 		= Number(document.getElementById("SP_brf_num_kid_l_" + id).value);
	SP_brf_price_kid_s 		= Number(document.getElementById("SP_brf_price_kid_l_" + id).value);
	SP_brf_price_kid_add_s 	= Number(document.getElementById("SP_brf_price_kid_add_l_" + id).value);
	SP_bed_num_s 			= Number(document.getElementById("SP_bed_num_l_" + id).value);
	SP_bed_price_s 			= Number(document.getElementById("SP_bed_price_l_" + id).value);
	SP_bed_price_add_s 		= Number(document.getElementById("SP_bed_price_add_l_" + id).value);

	var plus_str = "";
	
	if(SP_brf_num_s){
		plus_str  += "成早<font color=#FF0000>￥" + SP_brf_price_s + "</font> * " + SP_brf_num_s + "份 * "  + SP_days_s + "晚<br/>";
	}
	if(SP_brf_num_kid_s){
		plus_str  += "童早<font color=#FF0000>￥" + SP_brf_price_kid_s + "</font> * " + SP_brf_num_kid_s + "份 * " + SP_days_s + "晚<br/>";
	}
	if(SP_bed_num_s){
		plus_str  += "加床<font color=#FF0000>￥" + SP_bed_price_s + "</font> * " + SP_bed_num_s + "份 * " + SP_days_s + "晚";
	}
	
	table_show  += "<tr>" ;
	
	//日期
	table_show  +=	"<td style=\"white-space:nowrap;\">" + SP_indate_s + " 入住<br> "+SP_outdate_s+" 离店</td>" ;
	//酒店
	table_show  +=	"<td>" + SP_hotel_s + "</td>" ;
	//房型
	table_show  +=	"<td>" + SP_room_s + " </td>" ;
	//费用
	table_show  +=	"<td style=\"white-space:nowrap;\">均价 <font color=#FF0000>￥" + SP_room_price_s + "</font> * " + SP_days_s + " 晚</td>" ;

	//加订
	if(plus_str){
		table_show  +=	"<td style=\"white-space:nowrap;\">" + plus_str + "</td>" ;
	}else{
		table_show  +=	"<td>无</td>" ;
	}

	//间数
	table_show  +=	"<td>" + SP_room_num_s + "</td>" ;

	//备注	
	if( SP_memo_s ){
		table_show  +=	"<td align=center><img src=/images/memo_title.gif alt=\"备注：" + SP_memo_s + "\" border=0 style=\"cursor:pointer;\" onclick=\"alert($(this).attr('alt'));\" onMouseOver=\"window.status='点击可以查看';return true;\"> </td>" ;		
	}else{
		table_show  +=	"<td align=center>无</td>";
	}
	
	//预订数据
	table_show  +=	"<td align=center>\
	<input id=\"SP_s_" + SP_num + "\" name=\"SP_s_" + SP_num + "\" type=\"button\" value=\"删除\" onClick=\"javascript:Delete_SP('SP_s_" + SP_num + "','" + SP_num + "');\">\
	<input id=\"SP_indate_s_" + SP_num + "\" name=\"SP_indate_s_" + SP_num + "\" type=\"hidden\" value='" + SP_indate_s + "'>\
	<input id=\"SP_outdate_s_" + SP_num + "\" name=\"SP_outdate_s_" + SP_num + "\" type=\"hidden\" value='" + SP_outdate_s + "'>\
	<input id=\"SP_area_s_" + SP_num + "\" name=\"SP_area_s_" + SP_num + "\" type=\"hidden\" value='" + SP_area_s + "'>\
	<input id=\"SP_hotel_s_" + SP_num + "\" name=\"SP_hotel_s_" + SP_num + "\" type=\"hidden\" value='" + SP_hotel_s + "'>\
	<input id=\"SP_hotel_id_s_" + SP_num + "\" name=\"SP_hotel_id_s_" + SP_num + "\" type=\"hidden\" value='" + SP_hotel_id_s + "'>\
	<input id=\"SP_room_s_" + SP_num + "\" name=\"SP_room_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_s + "'>\
	<input id=\"SP_days_s_" + SP_num + "\" name=\"SP_days_s_" + SP_num + "\" type=\"hidden\" value='" + SP_days_s + "'>\
	<input id=\"SP_memo_s_" + SP_num + "\"  name=\"SP_memo_s_" + SP_num + "\" type=\"hidden\" value='" + SP_memo_s + "'>\
	<input id=\"SP_room_price_s_" + SP_num + "\" name=\"SP_room_price_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_price_s + "'>\
	<input id=\"SP_room_priceadd_s_" + SP_num + "\" name=\"SP_room_priceadd_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_priceadd_s + "'>\
	<input id=\"SP_room_price_list_s_" + SP_num + "\" name=\"SP_room_price_list_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_price_list_s + "'>\
	<input id=\"SP_room_priceadd_list_s_" + SP_num + "\" name=\"SP_room_priceadd_list_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_priceadd_list_s + "'>\
	<input id=\"SP_bf_info_list_s_" + SP_num + "\" name=\"SP_bf_info_list_s_" + SP_num + "\" type=\"hidden\" value='" + SP_bf_info_list_s + "'>\
	<input id=\"SP_limitdays_s_" + SP_num + "\" name=\"SP_limitdays_s_" + SP_num + "\" type=\"hidden\" value='" + SP_limitdays_s + "'>\
	<input id=\"SP_printID_s_" + SP_num + "\" name=\"SP_printID_s_" + SP_num + "\" type=\"hidden\" value='" + SP_printID_s + "'>\
	<input id=\"SP_room_num_s_" + SP_num + "\" name=\"SP_room_num_s_" + SP_num + "\" type=\"hidden\" value='" + SP_room_num_s + "'>\
	<input id=\"SP_price_sum_s_" + SP_num + "\" name=\"SP_price_sum_s_" + SP_num + "\" type=\"hidden\" value='" + SP_price_sum_s + "'>\
	<input id=\"SP_use_reserve_s_" + SP_num + "\" name=\"SP_use_reserve_s_" + SP_num + "\" type=hidden value='" + SP_use_reserve_s + "'>\
	<input id=\"SP_brf_num_s_" + SP_num + "\" name=\"SP_brf_num_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_num_s + "'>\
	<input id=\"SP_brf_price_s_" + SP_num + "\" name=\"SP_brf_price_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_price_s + "'>\
	<input id=\"SP_brf_price_add_s_" + SP_num + "\" name=\"SP_brf_price_add_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_price_add_s + "'>\
	<input id=\"SP_brf_num_kid_s_" + SP_num + "\" name=\"SP_brf_num_kid_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_num_kid_s + "'>\
	<input id=\"SP_brf_price_kid_s_" + SP_num + "\" name=\"SP_brf_price_kid_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_price_kid_s + "'>\
	<input id=\"SP_brf_price_kid_add_s_" + SP_num + "\" name=\"SP_brf_price_kid_add_s_" + SP_num + "\" type=\"hidden\" value='" + SP_brf_price_kid_add_s + "'>\
	<input id=\"SP_bed_num_s_" + SP_num + "\" name=\"SP_bed_num_s_" + SP_num + "\" type=\"hidden\" value='" + SP_bed_num_s + "'>\
	<input id=\"SP_bed_price_s_" + SP_num + "\" name=\"SP_bed_price_s_" + SP_num + "\" type=\"hidden\" value='" + SP_bed_price_s + "'>\
	<input id=\"SP_bed_price_add_s_" + SP_num + "\" name=\"SP_bed_price_add_s_" + SP_num + "\" type=\"hidden\" value='" + SP_bed_price_add_s + "'>\
</td>" ;
	table_show  +=	"</tr>";	
	
	table_show += "</TBODY></TABLE>";

	//载入表格
	$("#SP_select_box").html(table_show) ;
	//显示酒店购物车
	$("#SP_buy_cart").show();


	//计算价格
	
	var price ;
	
	price = ( SP_price_sum_s * SP_room_num_s ) + (SP_brf_num_s * SP_brf_price_s * SP_days_s * SP_room_num_s) + (SP_brf_num_kid_s * SP_brf_price_kid_s * SP_days_s * SP_room_num_s) + (SP_bed_num_s * SP_bed_price_s  * SP_days_s * SP_room_num_s);
	
	$("#SP_total").val(Number($("#SP_total").val()) + price);
	
	//alert($("#SP_total").val());
	
	count_total();
	
	alert("成功添加到“已选项目”！");

}


//删除特价
function Delete_SP(btn,id){
	
	if (confirm('您确认要删除吗?\n')) {
	
		SP_room_num_s 	= Number(document.getElementById("SP_room_num_s_" + id).value);
		SP_price_sum_s = Number(document.getElementById("SP_price_sum_s_" + id).value);
		SP_days_s 				= Number(document.getElementById("SP_days_s_" + id).value);
		SP_brf_num_s 			= Number(document.getElementById("SP_brf_num_s_" + id).value);
		SP_brf_price_s 			= Number(document.getElementById("SP_brf_price_s_" + id).value);
		SP_brf_price_add_s 		= Number(document.getElementById("SP_brf_price_add_s_" + id).value);
		SP_brf_num_kid_s 		= Number(document.getElementById("SP_brf_num_kid_s_" + id).value);
		SP_brf_price_kid_s 		= Number(document.getElementById("SP_brf_price_kid_s_" + id).value);
		SP_brf_price_kid_add_s 	= Number(document.getElementById("SP_brf_price_kid_add_s_" + id).value);
		SP_bed_num_s 			= Number(document.getElementById("SP_bed_num_s_" + id).value);
		SP_bed_price_s 			= Number(document.getElementById("SP_bed_price_s_" + id).value);
		SP_bed_price_add_s 		= Number(document.getElementById("SP_bed_price_add_s_" + id).value);
		var price ;
			
		price = ( SP_room_num_s * SP_price_sum_s ) + (SP_brf_num_s * SP_brf_price_s * SP_days_s * SP_room_num_s) + (SP_brf_num_kid_s * SP_brf_price_kid_s * SP_days_s * SP_room_num_s) + (SP_bed_num_s * SP_bed_price_s  * SP_days_s * SP_room_num_s);
		
		$("#SP_total").val( Number($("#SP_total").val()) - price );
		
		count_total();
		
		if( $("#SP_total").val() == '0'){
			//隐藏购物车
			$("#SP_buy_cart").hide();
		}

		var obj = document.getElementById(btn);
			removeTr(obj);
		}
		
	return false;
}
//检查表单
function checkform(){
	if(document.getElementById("customer_name").value.length < 1){
		alert("请填写联系人");
		document.getElementById("customer_name").focus();
		return false;
	}
	
	if(document.getElementById("customer_phone").value.length < 1){
		alert("请填写手机");
		document.getElementById("customer_phone").focus();
		return false;	
	}
	
	if(document.getElementById("customer_paytype").value.length < 1){
		alert("请选择您的支付方式");
		document.getElementById("customer_paytype").focus();
		return false;	
	}
	if(Number(document.getElementById("All_total").value) < 1){
			alert("您没有选择任何往返机票或是酒店客房或是酒店套餐，不能提交空订单！");
			return false;
	}else{
		
			if (confirm('\n您已经详细查看过所订内容并确定要提交本订单吗？')) return true;
			return false;
	}
	
	
}

function selectPayType(){

	var total_num;
	var h_num,t_num,s_num;
	
	if(document.getElementById("TK_total").value > 0){
		t_num = 1;
	}else{
		t_num = 0;	
	}
	if(document.getElementById("HT_total").value > 0){
		h_num = 1;
	}else{
		h_num = 0;	
	}	
	if(document.getElementById("ST_total").value > 0){
		s_num = 1;
	}else{
		s_num = 0;	
	}	
	total_num = h_num + t_num + s_num;

	var optionText;	
	var obj = document.getElementById("customer_city").value;
	
	if(obj=='其他' || obj=='广州'){
		optionText = "信用卡支付=>信用卡支付,支付宝=>支付宝,网上银行=>网上银行,银行转帐=>银行转帐";	
	}else{
		if(total_num > 1){
			optionText = "信用卡支付=>信用卡支付,上门付费=>上门付费,支付宝=>支付宝,网上银行=>网上银行,银行转帐=>银行转帐";
		}else{
			optionText = "信用卡支付=>信用卡支付,上门付费=>上门付费,支付宝=>支付宝,网上银行=>网上银行,银行转帐=>银行转帐";
		}
	}	
	addOptionGroup("customer_paytype",optionText);
}

function tab_select_tk(){
	$("#tab_tk").attr("class","tab_select");  
	$("#tab_ht").attr("class","tab_noselect");
	$("#tab_st").attr("class","tab_noselect");
	$("#tab_sp").attr("class","tab_noselect");
	$("#tab_hs").attr("class","tab_noselect");
	$('#TK_search_box').show(); 
	$('#HT_search_box').hide(); 
	$('#ST_search_box').hide();
	$('#SP_search_box').hide();
	$('#HS_search_box').hide();
	
}
function tab_select_ht(){
	$("#tab_tk").attr("class","tab_noselect");  
	$("#tab_ht").attr("class","tab_select");
	$("#tab_st").attr("class","tab_noselect");
	$("#tab_sp").attr("class","tab_noselect");
	$("#tab_hs").attr("class","tab_noselect");
	$('#TK_search_box').hide(); 
	$('#HT_search_box').show(); 
	$('#ST_search_box').hide();
	$('#SP_search_box').hide();
	$('#HS_search_box').hide();
}
function tab_select_hs(){
	$("#tab_tk").attr("class","tab_noselect");  
	$("#tab_ht").attr("class","tab_noselect");
	$("#tab_st").attr("class","tab_noselect");
	$("#tab_sp").attr("class","tab_noselect");
	$("#tab_hs").attr("class","tab_select");
	$('#TK_search_box').hide(); 
	$('#HT_search_box').hide(); 
	$('#ST_search_box').hide();
	$('#SP_search_box').hide();
	$('#HS_search_box').show();
}
function tab_select_st(){
	$("#tab_tk").attr("class","tab_noselect");  
	$("#tab_ht").attr("class","tab_noselect");
	$("#tab_st").attr("class","tab_select");
	$("#tab_sp").attr("class","tab_noselect");
	$("#tab_hs").attr("class","tab_noselect");
	$('#TK_search_box').hide(); 
	$('#HT_search_box').hide(); 
	$('#ST_search_box').show();
	$('#SP_search_box').hide();
	$('#HS_search_box').hide();
}
function tab_select_sp(){
	$("#tab_tk").attr("class","tab_noselect");  
	$("#tab_ht").attr("class","tab_noselect");
	$("#tab_st").attr("class","tab_noselect");
	$("#tab_sp").attr("class","tab_select");
	$("#tab_hs").attr("class","tab_noselect");
	$('#TK_search_box').hide(); 
	$('#HT_search_box').hide(); 
	$('#ST_search_box').hide();
	$('#SP_search_box').show();
	$('#HS_search_box').hide();
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function gohead(){
	$('#Hsearch_date').val('');
	$('#Hsearch_date2').val('');
	$('#Hsearch_hotelname').val('');
	$('#Hsearch_hotel').val('');
	
	$('#HS_search_hotelname').val('');
	$('#HS_search_hotel').val('');
	
	$('#Ssearch_date').val('');
	$('#Psearch_room_name').val('');
	$('#Psearch_date').val('');
	$('#box_tk').html('<font color="#999999">您可以同时预订多个航班的机票</font>');
	$('#box_ht').html('<font color="#999999">您可以同时预订多个不同的酒店住宿</font>');
	$('#box_hs').html('<font color="#999999">您可以同时预订多个不同的家庭旅馆住宿</font>');
	$('#box_st').html('<font color="#999999">您可以同时预订多个不同的酒店套餐和酒店客房住宿</font>');
	$('#box_sp').html('<font color="#999999">三亚之星独家特惠，预订越多，优惠越多</font>');
	$('html, body').animate({scrollTop: '0px'}, 300);
	return false;	
}

//预载入图片
MM_preloadImages('/rev/images/memo.gif','/rev/images/arrow_orange.gif','/rev/images/page01_02.gif','/images/ajax-loader.gif');

function display_cfsub(value){
	if(value=='电子邮件'){
		$('#customer_email').attr( 'datatype','Require' );
		$('#customer_fax').removeAttr('datatype');
		$('#email_box').show();
		$('#fax_box').hide();
	}else{
		$('#customer_fax').attr( 'datatype','Require' );
		$('#customer_email').removeAttr('datatype');
		$('#email_box').hide();
		$('#fax_box').show();			
	}
	return false;
}