|
|
<!--
|
|
|
function MM_openBrWindow(theURL,winName,features) { //v2.0
|
|
|
window.open(theURL,winName,features);
|
|
|
}
|
|
|
|
|
|
function Chk_CC()
|
|
|
{
|
|
|
var tc = document.getElementById("Txt_CC").value;
|
|
|
if (tc == "" || tc =="Train Number")
|
|
|
{
|
|
|
alert("Please input a train number.");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
function Chk_ZZ()
|
|
|
{
|
|
|
var tz = document.getElementById("Txt_FZ").value;
|
|
|
if (tz == "" || tz=="Station")
|
|
|
{
|
|
|
alert("You might forget to input a start station.");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
tz = document.getElementById("Txt_DZ").value;
|
|
|
|
|
|
if (tz == "" || tz=="Station")
|
|
|
{
|
|
|
alert("You might forget to input a final station.");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
function Chk_Z()
|
|
|
{
|
|
|
var Cn = document.getElementById("Txt_Ct").value ;
|
|
|
if (Cn == "" || Cn=="City Name" )
|
|
|
{
|
|
|
alert("Please input the city name you want to search.");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
//搜索表单检测
|
|
|
//传this即当前表单过来
|
|
|
//检测日期是否大于上一天日期 2014-5-22 modyfy
|
|
|
function Chk_searchForm(form){
|
|
|
|
|
|
//为了防止是点击返回按钮返回的首页,这样初始化显示的是国内搜索框,但是ItelTrain的数值却是0
|
|
|
//所以做一个是否是国内搜索框显示的判断
|
|
|
if ($("#InnerTrain").is(":visible")){
|
|
|
$("#ItelTrain").val("0");
|
|
|
}else{
|
|
|
$("#ItelTrain").val("1");
|
|
|
}
|
|
|
|
|
|
|
|
|
var isSub = true;
|
|
|
var showTip = function(o,msg){
|
|
|
$(o).after('<span style="display: block; position: absolute; color:#B00101;font-weight: bold;font-size: 10px;background-color:#FFF">'+msg+'</span>');
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($(form).length == 0){form = $('#ZZform1').get(0);}
|
|
|
if($(form).length == 0){return false;}//try again
|
|
|
|
|
|
|
|
|
//国际火车改版后,判断
|
|
|
if ($("#ItelTrain").val()=="1"){
|
|
|
//return true;
|
|
|
$("select[name^='IT_Txt_FZ_']").css('border-color',"").next("span").remove();
|
|
|
$("select[name^='IT_Txt_DZ_']").css('border-color',"").next("span").remove();
|
|
|
$("input[name^='stationDate_IT_']").css('border-color',"").next("span").remove();
|
|
|
|
|
|
var Item_Itel = $("#IterTrain").find("[id^='IT_Txt_FZ_']").length;
|
|
|
for (var j=1;j<=Item_Itel;j++){
|
|
|
oItem1=$(form).find("[name='IT_Txt_DZ_"+j+"']");
|
|
|
oItem2=$(form).find("[name='stationDate_IT_"+j+"']");
|
|
|
|
|
|
if($.trim(oItem1.val())==''){
|
|
|
showTip(oItem1,'Please select your arrival city');
|
|
|
oItem1.css('border-color',"#B00101");isSub = false;
|
|
|
}
|
|
|
if($.trim(oItem2.val())==''){
|
|
|
showTip(oItem2,'Please select a travel date.');
|
|
|
oItem2.css('border-color',"#B00101");isSub = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return isSub;
|
|
|
}
|
|
|
|
|
|
|
|
|
$("[name^='Txt_FZ_']").css('border-color',"").next("span").remove();
|
|
|
$("[name^='Txt_DZ_']").css('border-color',"").next("span").remove();
|
|
|
$("[name^='stationDate_']").css('border-color',"").next("span").remove();
|
|
|
|
|
|
var count = $(form).find("[id^='Txt_FZ_']").length;
|
|
|
for(var i=1;i<=count;i++){
|
|
|
o1 = $(form).find("[name='Txt_FZ_"+i+"']");
|
|
|
o2 = $(form).find("[name='Txt_DZ_"+i+"']");
|
|
|
o3 = $(form).find("[name='stationDate_"+i+"']");
|
|
|
if( count==2 && i==2 && $.trim(o1.val())=='' && $.trim(o2.val())=='' && $.trim(o3.val())=='' ){
|
|
|
subRoute();
|
|
|
}else{
|
|
|
if($.trim(o1.val())==''){
|
|
|
showTip(o1,'Please enter your departure city ');
|
|
|
o1.css('border-color',"#B00101");isSub = false;
|
|
|
}
|
|
|
if($.trim(o2.val())==''){
|
|
|
showTip(o2,'Please enter your arrival city');
|
|
|
o2.css('border-color',"#B00101");isSub = false;
|
|
|
}
|
|
|
if($.trim(o3.val())==''){
|
|
|
showTip(o3,'Please select a travel date.');
|
|
|
o3.css('border-color',"#B00101");isSub = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//check Next Date has behand current data.
|
|
|
var prevewVal = (new Date($(form).find("[name='stationDate_1']").val())).getTime();
|
|
|
for(i=2;i<=count;i++){
|
|
|
var curenVal = (new Date($(form).find("[name='stationDate_"+i+"']").val())).getTime();
|
|
|
if(curenVal < prevewVal){//当前日期不能小于头一天
|
|
|
alert("Departing date of Train "+i+" is error!");isSub=false;
|
|
|
}
|
|
|
prevewVal = curenVal;
|
|
|
}
|
|
|
if( false ){
|
|
|
if(window.location.pathname == '/china-trains/' || window.location.pathname == '/china-trains/search-result.asp'){
|
|
|
$.ajax({
|
|
|
url:$(form).attr('action')+'?ajax=y',
|
|
|
type:'POST',
|
|
|
beforeSend:function(){
|
|
|
var coverDiv='<div id="trainLoading888" style=" display:none;top: 0px; height: 100%; z-index: 200; width: 100%; left: 0px; position: fixed; background-color: rgb(255, 255, 255);"><div style="text-align: center; background-color: rgb(255, 255, 255); margin: 400px auto 0px; width: 500px; opacity: 2; color: rgb(0, 0, 0); height: 80px; font-size: 35px;"><img src="//data.chinahighlights.com/image/loading85.gif">loading........</div></div>';
|
|
|
$('body').append(coverDiv);
|
|
|
$('#trainLoading888').show();
|
|
|
url=window.location.origin+"/china-trains/search-result.asp";
|
|
|
var state = {title: document.title,url: url};
|
|
|
window.history.pushState(state, document.title, url);
|
|
|
|
|
|
},
|
|
|
complete :function(){$('#trainLoading888').remove();},
|
|
|
data:$(form).serialize(),
|
|
|
dataType:'html',
|
|
|
success :function(html){
|
|
|
$("body").html(html);
|
|
|
}
|
|
|
})
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return isSub;
|
|
|
}
|
|
|
|
|
|
//页面打印
|
|
|
function printpage(){
|
|
|
var newstr = document.getElementById("mainContent").innerHTML;
|
|
|
var oldstr = document.body.innerHTML;
|
|
|
document.body.innerHTML = newstr;
|
|
|
window.print();
|
|
|
document.body.innerHTML = oldstr;
|
|
|
}
|
|
|
//更新车次代码
|
|
|
function _getObj(o){
|
|
|
if($(o).size()>0) {
|
|
|
return $(o);
|
|
|
} else {
|
|
|
return $("body");
|
|
|
}
|
|
|
};
|
|
|
function CkFromCode(Obj){
|
|
|
var o = _getObj(Obj);
|
|
|
var cityName = $("#stationFrom",o).val();
|
|
|
$("#stationFromCode",o).val("");
|
|
|
if(cityName.length>0){
|
|
|
$("#stationFromCode",o).val(getStationCode(cityName));
|
|
|
}
|
|
|
}
|
|
|
function CkToCode(Obj){
|
|
|
var o = _getObj(Obj);
|
|
|
var cityName = $("#stationTo",o).val();
|
|
|
$("#stationToCode",o).val("");
|
|
|
if(cityName.length>0){
|
|
|
$("#stationToCode",o).val(getStationCode(cityName));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function checkCode(Obj){
|
|
|
var o = _getObj(Obj);
|
|
|
CkFromCode(Obj);
|
|
|
CkToCode(Obj);
|
|
|
if($("#stationFromCode",o).val() == ""){
|
|
|
alert("Train station doesn't exist!");
|
|
|
$("#stationFrom",o).focus();
|
|
|
return false;
|
|
|
}
|
|
|
if($("#stationToCode",o).val() == ""){
|
|
|
alert("Train station doesn't exist!");
|
|
|
$("#stationTo",o).focus();
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function getStationCode(EnName){
|
|
|
for(var i=0;i<stationArr.length;i++){
|
|
|
if($.trim(stationArr[i][1]) == $.trim(EnName)){
|
|
|
return stationArr[i][0];
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
function getStationENname(CnName){
|
|
|
for(var i=0;i<stationArr.length;i++){
|
|
|
if($.trim(stationArr[i][2]).toLowerCase() == $.trim(CnName).toLowerCase()){
|
|
|
return stationArr[i][1];
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
function zwdcx(){
|
|
|
cxlx = $("input[name=cxlx]:checked").val();
|
|
|
CZ = $("#CZ").val();
|
|
|
CC = $("#CC").val();
|
|
|
$.ajax({
|
|
|
type: "GET",
|
|
|
url: "/api/api.asp",
|
|
|
dataType:"json",
|
|
|
data:"method=cht.train.zwdcx&cz="+CZ+"&cc="+CC+"&lx="+cxlx,
|
|
|
beforeSend:function(){
|
|
|
$("#ZWDCX").html("<img src='/pic/ajax-loader-1.gif'/>").show();
|
|
|
},
|
|
|
success:function(data){
|
|
|
$("#ZWDCX").html(data.result)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
function morEreaShow(){
|
|
|
$("#officeErea").toggle().hover(function(){},function(){$(this).hide()});;
|
|
|
}
|
|
|
function fitterOffice(Str, _o){
|
|
|
$(".ticketOffice").show();
|
|
|
if(Str != ""){
|
|
|
$(".ticketOffice[val!="+Str+"]").hide();
|
|
|
}
|
|
|
$("a.cityList").html($(_o).html());
|
|
|
$("#officeErea").hide();
|
|
|
$(".ticketOffice:visible").each(function(i){$(this).find(" span").html(i+1)});
|
|
|
}
|
|
|
|
|
|
//新增项目
|
|
|
function addRoute(){
|
|
|
if ($("#InnerTrain").is(":visible")){
|
|
|
//国内
|
|
|
var Obj = $("#InnerTrain tr:eq(0)").clone();
|
|
|
var nowindex = $("#InnerTrain tr").size()+1;
|
|
|
//属性处理
|
|
|
Obj.find("td:eq(0) span").text('Journey ' + nowindex + ':');
|
|
|
Obj.find("input[name='Txt_FZ_1']").attr({'id':'Txt_FZ_'+nowindex,'name':'Txt_FZ_'+nowindex ,'onblur':'','onfocus':''});
|
|
|
Obj.find("input[name='Txt_DZ_1']").attr({'id':'Txt_DZ_'+nowindex,'name':'Txt_DZ_'+nowindex ,'onblur':'','onfocus':''});
|
|
|
Obj.find("input[name='stationDate_1']").attr({'id':'stationDate_'+nowindex,'name':'stationDate_'+nowindex});
|
|
|
//Obj.find("[type=hidden]").remove();
|
|
|
Obj.find("input[name^='Code_Txt_']").remove();
|
|
|
//插入
|
|
|
//$("#aR_tr").before(Obj);
|
|
|
$("#InnerTrain").append(Obj);
|
|
|
//事件
|
|
|
//auto complete
|
|
|
if(typeof $.fn.autoCPT=='function'){
|
|
|
Obj.find("input[name^='Txt_']").val('').autoCPT({'stationData':stationArr,'yOffset':0});
|
|
|
}
|
|
|
//datepicker
|
|
|
if(typeof $.datepicker =="object"){
|
|
|
Obj.find("input[name^='stationDate']").val('').removeClass("hasDatepicker").datepicker(
|
|
|
{showAnim:"fadeIn",duration:0,minDate: "0d", numberOfMonths: 2,showButtonPanel: true}
|
|
|
);
|
|
|
}else
|
|
|
{
|
|
|
Obj.find("input[name^='stationDate']").val('').removeClass("hasDatepicker").flatpickr({
|
|
|
altInput: true,
|
|
|
altFormat: "F j, Y",
|
|
|
dateFormat: "Y-m-d",
|
|
|
minDate: new Date().fp_incr(0),
|
|
|
maxDate: new Date().fp_incr(360)
|
|
|
|
|
|
});
|
|
|
Obj.find("input[name^='stationDate']").next("input").next("input").remove();
|
|
|
}
|
|
|
}else{
|
|
|
//国际火车票
|
|
|
var Obj = $("#IterTrain tr:eq(0)").clone();
|
|
|
var nowindex = $("#IterTrain tr").size()+1;
|
|
|
|
|
|
//属性处理
|
|
|
Obj.find("td:eq(0) span:first").text('Train ' + nowindex + ':');
|
|
|
Obj.find("select[name='IT_Txt_FZ_1']").attr({'id':'IT_Txt_FZ_'+nowindex,'name':'IT_Txt_FZ_'+nowindex });
|
|
|
Obj.find("select[name='IT_Txt_DZ_1']").attr({'id':'IT_Txt_DZ_'+nowindex,'name':'IT_Txt_DZ_'+nowindex });
|
|
|
Obj.find("input[name='stationDate_IT_1']").attr({'id':'stationDate_IT_'+nowindex,'name':'stationDate_IT_'+nowindex});
|
|
|
Obj.find("#ItelMsg_1").attr({'id':'ItelMsg_'+nowindex}).html('');
|
|
|
|
|
|
//插入
|
|
|
$("#IterTrain").append(Obj);
|
|
|
|
|
|
//事件
|
|
|
//datepicker
|
|
|
if(typeof $.datepicker =="object"){
|
|
|
Obj.find("input[name^='stationDate_IT_']").val('').removeClass("hasDatepicker").datepicker(
|
|
|
{showAnim:"fadeIn",duration:0,minDate: "0d", numberOfMonths: 2,showButtonPanel: true}
|
|
|
);
|
|
|
}else
|
|
|
{
|
|
|
Obj.find("input[name^='stationDate_IT_']").val('').removeClass("hasDatepicker").flatpickr({
|
|
|
altInput: true,
|
|
|
altFormat: "F j, Y",
|
|
|
dateFormat: "Y-m-d",
|
|
|
minDate: new Date().fp_incr(0),
|
|
|
maxDate: new Date().fp_incr(360)
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
BindInterTrain(nowindex);
|
|
|
}
|
|
|
}
|
|
|
//删除
|
|
|
function subRoute(){
|
|
|
// if($("#aR_tr").prevAll("tr.InnerTrain").size()>1){
|
|
|
// $("#aR_tr").prev("tr.InnerTrain").remove();
|
|
|
// }
|
|
|
if ($("#InnerTrain").is(":visible")){
|
|
|
if($("#InnerTrain").children("tr.InnerTrain").size()>1){
|
|
|
$("#InnerTrain tr.InnerTrain").last().remove();
|
|
|
}
|
|
|
}else{
|
|
|
if($("#IterTrain").children("tr.IterTrain").size()>1){
|
|
|
$("#IterTrain tr.IterTrain").last().remove();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function strHot(str){
|
|
|
var rStr = "";
|
|
|
var ary = Array(
|
|
|
['Hong Kong West Kowloon|XJA','Hong Kong West Kowloon(香港西九龙)'],['Beijing|BJP','Beijing(北京)'],['Shanghai|SHH','Shanghai(上海)'],['Xian|XAY','Xian(西安)'],
|
|
|
['Guangzhou|GZQ','Guangzhou(广州)'],['Hangzhou|HZH','Hangzhou(杭州)'],['Pingyao|PYV','Pingyao(平遥)'],
|
|
|
['Shenzhen|SZQ','Shenzhen(深圳)'],['Guilin|GLZ','Guilin(桂林)'],['Kunming|KMM','Kunming(昆明)'],
|
|
|
['Suzhou(Jiangsu province)|SZH','Suzhou(苏州)'],['Datong Railway Station|DTV','Datong(大同)'],
|
|
|
['Changsha|CSQ','Changsha(长沙)'],['Nanjing|NJH','Nanjing(南京)'],['Ningbo|NGH','Ningbo(宁波)'],
|
|
|
['Chengdu|CDW','Chendu(成都)'],['Taiyuan|TYV','Taiyuan(太原)'],['Nanning|NNZ','Nanning(南宁)'],
|
|
|
['Zhangjiajie|DIQ','Zhangjiajie(张家界)'],['Huangshan|HKH','Huangshan(黄山)']
|
|
|
);
|
|
|
var ary_g_f = Array(
|
|
|
['Hong Kong|JQO','Hung Hom, Hong Kong(香港)'],['Beijing|BJP','Beijing(北京)'],['Shanghai|SHH','Shanghai(上海)'],
|
|
|
['Guangzhou|GGQ','Guangzhou(广州)'],['Changping|DAQ','Changping(常平)'],['Foshan|FSQ','Foshan(佛山)'],
|
|
|
['Zhaoqing|ZVQ','Zhaoqing(肇庆)'],['Nanning|NNZ','Nanning(南宁)'],['Jining Nan (South)|JAC','Jining Nan(集宁南)'],
|
|
|
['Urumqi|WMR','Urumqi(乌鲁木齐)','<br>'],['Gia Lam, Hanoi|YNHN','Gia Lam, Hanoi(嘉林)'],['Harbin|HBB','Harbin(哈尔滨)']
|
|
|
);
|
|
|
var ary_g_t = Array(
|
|
|
['Hong Kong|JQO','Hung Hom, Hong Kong(香港)'],['Moscow|ELSM','Moscow,Russia(莫斯科)'],['Irkutsk|ELSY','Irkutsk,Russia(伊尔库茨克)'],
|
|
|
['Ulan-Bator|WLBT','Ulan-Bator,Mongolia(乌兰巴托)'],['Pyongyang|CXPY','Pyongyang,North Korea(平壤)'],
|
|
|
['Gia Lam, Hanoi|YNHN','Gia Lam, Hanoi(嘉林)'],['Almaty|HLAL','Almaty(阿拉木图)'],['Astana|HLAS','Astana(阿斯塔纳)','<br>'],
|
|
|
['Beijing|BJP','Beijing(北京)'],['Guangzhou|GGQ','Guangzhou(广州)'],['Shanghai|SHH','Shanghai(上海)'],
|
|
|
['Changping|DAQ','Changping(常平)'],['Foshan|FSQ','Foshan(佛山)'],['Zhaoqing|ZVQ','Zhaoqing(肇庆)'],['Nanning|NNZ','Nanning(南宁)'],['Chita|ELSC','Chita(赤塔)']
|
|
|
);
|
|
|
|
|
|
if(window.globaltrain && str.substr(0,6) == "Txt_FZ"){
|
|
|
array = ary_g_f;
|
|
|
}else if(window.globaltrain && str.substr(0,6) == "Txt_DZ") {
|
|
|
array = ary_g_t;
|
|
|
}else{
|
|
|
array = ary;
|
|
|
}
|
|
|
|
|
|
var celLineHeight = '';
|
|
|
if(window.TrainFrom.w<450){
|
|
|
rStr = '<div style="font-size:12px;display:block;position:absolute;background-color:#FFF;line-height:25px;border:1px solid #CCCCCC;z-index:444" id="hotStation" class="">';
|
|
|
celLineHeight = 'line-height: 15px;';
|
|
|
}else{
|
|
|
rStr = '<div style="font-size:12px;display:block;position:absolute;background-color:#FFF;line-height:25px;border:1px solid #CCCCCC;z-index:444" id="hotStation" class="">';
|
|
|
}
|
|
|
|
|
|
for(var j=0;j<array.length;j++) {
|
|
|
rStr += '<div style="float: left; '+celLineHeight+' margin: 2px; padding:5px;background-color:#FFF" data="'+array[j][0]+'" onclick="setDv(\''+str+'\',this)">'+array[j][1]+'</div>';
|
|
|
}
|
|
|
rStr += '<div style="clear:both"></div></div>';
|
|
|
return rStr;
|
|
|
}
|
|
|
|
|
|
function showDv(id){
|
|
|
if(typeof showHotCity == 'undefined')return;
|
|
|
if(!showHotCity) return;
|
|
|
var t = $("#"+id).offset();
|
|
|
var th = $("#"+id).outerHeight();
|
|
|
if($("#"+id).parents('table').size() || $("#"+id).parents('.tab-pane').size()){
|
|
|
var tp = $("#"+id).parents('table').offset();
|
|
|
var wd = $("#"+id).parents('table').width();
|
|
|
tp = tp ? tp : $("#"+id).parents('.tab-pane').offset();
|
|
|
wd = wd ? wd : $("#"+id).parents('.tab-pane').width();
|
|
|
}else{
|
|
|
var tp = $("#"+id).offset();
|
|
|
var wd = $("#"+id).width();
|
|
|
}
|
|
|
|
|
|
$("[id=hotStation]").remove();
|
|
|
if($('.container:eq(0)').size()){
|
|
|
$(strHot(id)).appendTo('.container:eq(0)');
|
|
|
}else{
|
|
|
$(strHot(id)).appendTo("body");
|
|
|
}
|
|
|
if(window.TrainFrom.w<450 && 1==2){
|
|
|
$("#hotStation").css('top',(window.TrainFrom.p.top)).css('left',window.TrainFrom.p.left).css('width',window.TrainFrom.w);
|
|
|
}else{
|
|
|
$("#hotStation").css('top',(t.top+th)).css('left',tp.left).css('width',wd);
|
|
|
}
|
|
|
$("#hotStation").find('div').css('cursor','pointer').hover(function(){$(this).css('background-color','#ccc')},function(){$(this).css('background-color','#FFF')});
|
|
|
}
|
|
|
function hideDv(){ $("#hotStation").remove(); }
|
|
|
function setDv(o1,o2)
|
|
|
{
|
|
|
data = $(o2).attr('data').split('|') ;
|
|
|
$('#'+o1).val( data[0] );
|
|
|
var CHid = "Code_"+o1;
|
|
|
if($("#"+CHid).size()==0){
|
|
|
$('#'+o1).after('<input type="hidden" name="'+CHid+'" value="'+data[1]+'" id="'+CHid+'" />');
|
|
|
}
|
|
|
$("#"+CHid).val(data[1]);
|
|
|
hideDv();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(function(){
|
|
|
window.stationArr = new Array();
|
|
|
if( typeof StationInfo == "string" ){
|
|
|
var station_names_Arr_tmp = StationInfo.split('@');
|
|
|
for(var i=0;i<station_names_Arr_tmp.length;i++){
|
|
|
var tmp = station_names_Arr_tmp[i].split('|')
|
|
|
//station_names_Arr.push(tmp);
|
|
|
stationArr.push(Array(tmp[1],tmp[2],tmp[3],tmp[4],tmp[5])); //code,name,cnName,group,province
|
|
|
}
|
|
|
}
|
|
|
if(typeof $.datepicker =="object"){
|
|
|
$("input[name^=stationDate_],input[id=starttime],input[id=endtime],#stationDate").datepicker(
|
|
|
{showAnim:"fadeIn",duration:0,minDate: "0d", maxDate :"8m",
|
|
|
numberOfMonths:(typeof numberOfMonths == 'number')?numberOfMonths:2,showButtonPanel: true,
|
|
|
beforeShow: function () {setTimeout(function () {$('#ui-datepicker-div').css("z-index", 6);}, 100);}}
|
|
|
);
|
|
|
}else {
|
|
|
$("input[name^=stationDate_]").flatpickr({
|
|
|
altInput: true,
|
|
|
altFormat: "F j, Y",
|
|
|
dateFormat: "Y-m-d",
|
|
|
minDate: new Date().fp_incr(0),
|
|
|
maxDate: new Date().fp_incr(360)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//单独配置给国际火车
|
|
|
if ($("#stationDate_IT_1").length>0){
|
|
|
$("#stationDate_IT_1").flatpickr({
|
|
|
altInput: true,
|
|
|
altFormat: "F j, Y",
|
|
|
dateFormat: "Y-m-d",
|
|
|
minDate: new Date().fp_incr(3),
|
|
|
maxDate: new Date().fp_incr(360)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
if(typeof $.fn.autoCPT=='function'){
|
|
|
$("input[name^='Txt_FZ'],input[name^='Txt_DZ']").autoCPT({'stationData':stationArr,'yOffset':0});
|
|
|
$("#Txt_FZ,#Txt_DZ").autoCPT({'stationData':stationArr,'yOffset':0});
|
|
|
}
|
|
|
|
|
|
if($('#tipIndex').size()>0){
|
|
|
(function(){
|
|
|
var d=new Date();
|
|
|
var m = d.getTimezoneOffset();
|
|
|
var mn= d.getTime() + m * 1000;
|
|
|
d.setTime(mn+ 480 * 1000)
|
|
|
d2 = new Date();
|
|
|
d2.setTime(d.getTime()+59*3600*24*1000)
|
|
|
var DTU = function (dd){
|
|
|
M = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
|
|
return M[dd.getMonth()] + '. '+ dd.getDate() + ' ' + dd.getFullYear();
|
|
|
}
|
|
|
$('#tipIndex').html(DTU(d) + ' to ' + DTU(d2));
|
|
|
})();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
if($("#navtraintop").size()){
|
|
|
$('#navtraintop li').click(function(){
|
|
|
$(this).addClass('active');
|
|
|
$(this).siblings().removeClass('active');
|
|
|
if( $(this).text() == 'China Train' ){
|
|
|
window.globaltrain=false;
|
|
|
$("#ItelTrain").val("0");
|
|
|
}else{
|
|
|
window.globaltrain=true
|
|
|
$("#ItelTrain").val("1");
|
|
|
}
|
|
|
|
|
|
// //新加国际 zp 2017-5-04
|
|
|
// $("#ZZform1 div.inforDiv table tr.city").hide();
|
|
|
// var tb_index=$('#navtraintop li').index(this);
|
|
|
// if (tb_index==0){
|
|
|
// $("#ZZform1 div.inforDiv table tr.InnerTrain").show();
|
|
|
// $("#addBtn").show();
|
|
|
// }else{
|
|
|
// $("#ZZform1 div.inforDiv table tr.IterTrain").show();
|
|
|
// $("#addBtn").hide();
|
|
|
// }
|
|
|
|
|
|
$("#InnerTrain,#IterTrain").hide();
|
|
|
var tb_index=$('#navtraintop li').index(this);
|
|
|
if (tb_index==0){
|
|
|
$("#InnerTrain").show();
|
|
|
}else{
|
|
|
$("#IterTrain").show();
|
|
|
}
|
|
|
|
|
|
});
|
|
|
window.TrainFrom={w:$("#navtraintop").parents('form').width(),h:$("#navtraintop").parents('form').height(),p:$("#navtraintop").parents('form').offset()};
|
|
|
}else{
|
|
|
window.TrainFrom={w:$("#ZZform1").width(),h:$("#ZZform1").height(),p:$("#ZZform1").offset()};
|
|
|
}
|
|
|
|
|
|
//设置默认日期
|
|
|
var df_date=adddays();
|
|
|
$("#stationDate").val(df_date);
|
|
|
if( window.location.pathname == "/china-trains/" ){
|
|
|
//$("#stationDate_1").val(df_date);
|
|
|
//$("#stationDate_IT_1").val(df_date);
|
|
|
}
|
|
|
// //是否移动设备
|
|
|
// searchIndexFrom = $('#ZZform1');
|
|
|
// if(searchIndexFrom.size()){
|
|
|
// if(is_mbAgent()){
|
|
|
// //searchIndexFrom.attr('action','/china-trains/search-result-mb.asp');
|
|
|
// searchIndexFrom.attr('action','https://www.chinahighlights.com/china-trains/app/');
|
|
|
// }
|
|
|
// }
|
|
|
//是否购物车过来
|
|
|
if(location.hash == "#cart"){
|
|
|
initSearchFrom();
|
|
|
}
|
|
|
});
|
|
|
function adddays(days) {
|
|
|
var DaysToAdd=parseInt(days);
|
|
|
if(isNaN(days)){DaysToAdd=3}
|
|
|
var newdate=new Date();
|
|
|
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
|
|
|
newdate.setTime(newtimems);
|
|
|
var yy=newdate.getFullYear(),
|
|
|
mm='0'+(newdate.getMonth()+1),
|
|
|
dd='0'+newdate.getDate();
|
|
|
return mm.substr(-2)+'/'+dd.substr(-2)+'/'+yy;
|
|
|
}
|
|
|
|
|
|
function is_mbAgent(){
|
|
|
if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initSearchFrom(){
|
|
|
var getAvalue = function(key) {
|
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
|
if (cookies[i][0] == key) {
|
|
|
return cookies[i][1];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var cookies = GetCookie('trainSeach').replace(/[+]/g," ").split('|');
|
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
|
cookies[i] = cookies[i].split('=');
|
|
|
}
|
|
|
|
|
|
var i = 1;
|
|
|
do {
|
|
|
si = getAvalue('si');
|
|
|
Txt_FZ = getAvalue('Txt_FZ_' + i);
|
|
|
Txt_DZ = getAvalue('Txt_DZ_' + i);
|
|
|
stationDate = getAvalue('stationDate_' + i);
|
|
|
Code_Txt_FZ = getAvalue('Code_Txt_FZ_' + i);
|
|
|
Code_Txt_DZ = getAvalue('Code_Txt_DZ_' + i);
|
|
|
if($('#Txt_FZ_'+i).size()==0){addRoute();}
|
|
|
|
|
|
$('#Txt_FZ_'+i).val(Txt_FZ);
|
|
|
$('#Txt_DZ_'+i).val(Txt_DZ);
|
|
|
$('#stationDate_'+i).val(stationDate);
|
|
|
|
|
|
if($('#Code_Txt_FZ_'+i).size()==0){
|
|
|
$('#Txt_FZ_'+i).after('<input type="hidden" name="Code_Txt_FZ_'+i+'" id="Code_Txt_FZ_'+i+'">');
|
|
|
}
|
|
|
if($('#Code_Txt_DZ_'+i).size()==0){
|
|
|
$('#Txt_DZ_'+i).after('<input type="hidden" name="Code_Txt_DZ_'+i+'" id="Code_Txt_DZ_'+i+'">');
|
|
|
}
|
|
|
|
|
|
$('#Code_Txt_FZ_'+i).val(Code_Txt_FZ);
|
|
|
$('#Code_Txt_DZ_'+i).val(Code_Txt_DZ);
|
|
|
|
|
|
i++;
|
|
|
} while (getAvalue('Txt_FZ_' + i) != undefined);
|
|
|
|
|
|
}
|
|
|
|
|
|
//2017-5-9 zp 国际火车票搜索框
|
|
|
$(function(){
|
|
|
BindInterTrain(1);
|
|
|
});
|
|
|
|
|
|
|
|
|
//绑定国际火车站select联动
|
|
|
//index 绑定的序列
|
|
|
function BindInterTrain(index){
|
|
|
|
|
|
var $FromS = $("#IT_Txt_FZ_"+index);
|
|
|
var $ToS = $("#IT_Txt_DZ_"+index);
|
|
|
var $ItelMsg = $("#ItelMsg_"+index);
|
|
|
|
|
|
$.getJSON("https://www.chinahighlights.com/guide-use.php/intel_train/get_rulejson/",function(json){
|
|
|
var html =[];
|
|
|
for (var key in json.TrainList){
|
|
|
html.push('<option value="' + json.TrainList[key].FromStation + '">' + json.TrainList[key].FromStation + '</option>');
|
|
|
}
|
|
|
|
|
|
//设置第二个select默认值
|
|
|
var html2=['<option value="">Please Select</option>'];
|
|
|
for (var key3 in json.TrainList[0].ToStations){
|
|
|
html2.push('<option value="' + json.TrainList[0].ToStations[key3].Station + '" data="'+json.TrainList[0].ToStations[key3].Message+'">' + json.TrainList[0].ToStations[key3].Station + '</option>');
|
|
|
}
|
|
|
$ToS.empty().append(html2);
|
|
|
|
|
|
$FromS.empty().append(html).change(function(){
|
|
|
var n = $(this).get(0).selectedIndex;
|
|
|
|
|
|
var html3 = ['<option value="">Please Select</option>'];
|
|
|
for (var key2 in json.TrainList[n].ToStations){
|
|
|
html3.push('<option value="' + json.TrainList[n].ToStations[key2].Station + '" data="'+json.TrainList[n].ToStations[key2].Message+'">' + json.TrainList[n].ToStations[key2].Station + '</option>');
|
|
|
}
|
|
|
|
|
|
$ToS.empty().append(html3).change(function(){
|
|
|
var ItelMsg = $(this).find("option:selected").attr("data");
|
|
|
if (ItelMsg!="" && typeof(ItelMsg)!="undefined"){
|
|
|
$ItelMsg.html(ItelMsg);
|
|
|
}else{
|
|
|
$ItelMsg.html("");
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$ItelMsg.html("");
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$ToS.change(function(){
|
|
|
var ItelMsg = $ToS.find("option:selected").attr("data");
|
|
|
if (ItelMsg!="" && typeof(ItelMsg)!="undefined"){
|
|
|
$ItelMsg.html(ItelMsg);
|
|
|
}else{
|
|
|
$ItelMsg.html("");
|
|
|
}
|
|
|
$(this).css('border-color',"").next("span").remove();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
////facebook代码
|
|
|
//$(function(){
|
|
|
// $( '#SearchTrainButton' ).click(function() {
|
|
|
// fbq('track', 'SearchTrain');
|
|
|
// });
|
|
|
//});
|
|
|
|
|
|
|
|
|
//-->
|