
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
   if (i == Num)
   {
    thisObj.className = "active"; 
       document.getElementById(tabObj+"_Content"+i).style.display = "block";
   }else{
    tabList[i].className = "normal"; 
    document.getElementById(tabObj+"_Content"+i).style.display = "none";
   }
} 
}

function nTabq(thisObj,Num){
if(thisObj.className == "active2")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
   if (i == Num)
   {
    thisObj.className = "active2"; 
       document.getElementById(tabObj+"_Content"+i).style.display = "block";
   }else{
    tabList[i].className = "normal2"; 
    document.getElementById(tabObj+"_Content"+i).style.display = "none";
   }
} 
}

function fclick(objname)
{

  if(objname==1)
  {
   jQuery("#search_zz").show();
   jQuery("#search_checi").hide();
   jQuery("#search_cz").hide();
  }
  else if(objname==2)
  {
   jQuery("#search_zz").hide();
   jQuery("#search_checi").show();
   jQuery("#search_cz").hide();
  }
  else if(objname==3)
  {
   jQuery("#search_zz").hide();
   jQuery("#search_checi").hide();
   jQuery("#search_cz").show();
  }
  else if(objname=='trans')
  {
   jQuery("#ticket_zr").show();
   jQuery("#ticket_qg").hide();
  }
  else if(objname=='buy')
  {
  jQuery("#ticket_zr").hide();
   jQuery("#ticket_qg").show();
  }
  
}
function iclick(objvalue)
{
  if(objvalue==1)
  {
    jQuery("#liecheimg").attr("src","image/serchm1_1.jpg");
	jQuery("#ticketimg").attr("src","image/serchm2_2.jpg");
	jQuery("#dianimg").attr("src","image/serchm0_2.jpg");
	jQuery("#search_lieche").show();
	jQuery("#search_ticket").hide();
	jQuery("#search_dian").hide();
	return false;
  }
  else if(objvalue==2)
  {
    jQuery("#liecheimg").attr("src","image/serchm1_2.jpg");
	jQuery("#ticketimg").attr("src","image/serchm2_1.jpg");
	jQuery("#dianimg").attr("src","image/serchm0_2.jpg");
	jQuery("#search_lieche").hide();
	jQuery("#search_ticket").show();
	jQuery("#search_dian").hide();
	return false;
  }
  else if(objvalue==3)
  {
    jQuery("#liecheimg").attr("src","image/serchm1_2.jpg");
	jQuery("#ticketimg").attr("src","image/serchm2_2.jpg");
	jQuery("#dianimg").attr("src","image/serchm0_1.jpg");
	jQuery("#search_lieche").hide();
	jQuery("#search_ticket").hide();
	jQuery("#search_dian").show();
	return false;
  }
}
function ajaxsearchzz()
{
/*
  if(jQuery("#k1").val()!='' && jQuery("#k2").val()!='' )
  {
    jQuery.get("newajaxzz.php",{k1:jQuery('k1').val(),k2:jQuery('k2').val()},
	function(msg)
	{
	   jQuery("#search_right").val(msg);
	}
	);
  }
  */
}
function fsubmit(fid)
{
  jQuery("#"+fid).submit();
}
function fload()
{
    jQuery.getJSON("newajaxzz.php",{k1:'北京',k2:'上海'},function(msg)
		{
		   //alert(msg['tn'].totalnum);
		   var str="<a href=http://lieche.huoche.com/zz-"+msg['other'].city1 +"-"+msg['other'].city2+"/ class='a2'>"+msg['tn'].station1+"到"+msg['tn'].station2+"共"+msg['tn'].totalnum+"次列车</a>";
		   jQuery("#ajaxcontent").html(str);
		   var alieche='';
		   if(msg['dc'].di!=0)
		   {
			alieche+= " <p><strong>D-动车组:</strong> 共"+msg['dc'].di+"次 上午"+msg['dc'].dcs+"次 下午"+msg['dc'].dcx+"次 晚上"+msg['dc'].dcw+"次</p>";
		   }
		   if(msg['tk'].tk!=0)
		   {
			alieche+=" <p><strong>T-空调特快:</strong> 共"+msg['tk'].tk+"次 上午"+msg['tk'].tks+"次 下午"+msg['tk'].tkx+"次 晚上"+msg['tk'].tkw+"次</p>";
		   }
		   if(msg['ks'].ks!=0)
		   {
			alieche+=" <p><strong>K-空调快速:</strong> 共"+msg['ks'].ks+"次 上午"+msg['ks'].kss+"次 下午"+msg['ks'].ksx+"次 晚上"+msg['ks'].ksw+"次</p>";
		   }
		   if(msg['zk'].zktid!='')
		   {
			alieche+=" <p><strong>最快车次:</strong><a href=http://lieche.huoche.com/c"+msg['zk'].zktid+" >"+msg['zk'].tname+"</a> 运行时间"+msg['zk'].tall+"";
		   }
		   if(msg['zp'].zptid!='')
		   {
			alieche+="<p><strong>最便宜车次:</strong><a href=http://lieche.huoche.com/c"+msg['zp'].zptid+" >"+msg['zp'].trainname+"</a>票价"+msg['zp'].price+"元";
		   }
		   jQuery("#ajaxlieche").html(alieche);
		   var str2='<a href="http://www.huoche.com/dingpiao/chengshi/'+msg['other'].city1+' " target=_blank>'+msg['tn'].station1+'火车票售票点</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=http://www.huoche.com/piao/z'+msg['other'].cid1+'z'+msg['other'].cid2+' target=_blank >转让票信息</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://hotel.huoche.com/List-'+msg['other'].hotelid+'" target=_blank>'+msg['tn'].station2+'酒店</a>';
		  jQuery("#ajaxlieche2").html(str2); 
		}
		);	
  }

jQuery(function($){
	
	$('#from,#to').suggest('http://piao.huoche.com/api/s.php?callback=?');
	//输入日期	
	$('#departureDate').datepicker({dateFormat:'yy-mm-dd',minDate:'0',maxDate:'+30D',numberOfMonths: 2});

	//输入检查
	$('#search-form').submit(function(){
		var submit = true;
		$('.required').each(function(){
			if($(this).val()==''){
				$(this).focus();
				submit = false;
				return false;
			}
		})
		

		return submit;
	});
	
});

