var gobuy=function(){
	
	var from=arguments[0];
	
	var to=arguments[1];
	var checi=arguments[2];
	var yupiao=arguments[3];
	var hezuo=arguments[4];
	
	var date=$("#date").val();
	if(yupiao == ''){
		yupiao = '1,2,3,4,5,6,8';
	}
	$.getJSON("http://www.99pto.com/backorder/checiRule.php?jsoncallback=?", 
				{from:from,
				to:to,
				checi:checi,
				date:date
				},
			function(data){
				//alert(data);
				if(data.tag == 'n'){
					//alert('不能代购');
					
					//$("#"+checi+"_button").html("不代购");
					
					$("#"+checi+"_button").html("<span style='color:#1B67B5;' title='热门车次得票率低，限制购买'>不代购</span>");
				}else if(data.tag == 'y'){
				
				
				if((data.mes) != ''){
					//alert('dddd');
					var arr_data = (data.mes).split(',');
					var arr_yupiao = yupiao.split(',');
					 datalen = arr_data.length;
					 yupiaolen= arr_yupiao.length;
					
					
					for(j=0;j< datalen;j++)
					{
						for(i=0;i<yupiaolen;i++)  
						{
							if(arr_data[j] == arr_yupiao[i]){
								arr_yupiao.splice(i,1);
							}
						}
					}
					var str = '';
					for(i=0;i<arr_yupiao.length;i++)  {
						str += arr_yupiao[i];
						if(i<arr_yupiao.length-1){
							str += ',';
						}
					}
					//alert(str);
					if(str.length > 0){
						//alert('能代购');
						str=escape(str);
						window.location="http://www.99pto.com/buy_now.php?from="+encodeURI(from)+"&to="+encodeURI(to)+"&checi="+checi+"&ymd="+date+"&yupiao="+str+"&hezuo="+hezuo	;	
					}else{
					  // alert('计算后不代购');
						//$("#"+checi+"_button").html("不代购");
						
						$("#f_button_"+checi).removeClass("selTab_btn");
						$("#f_button_"+checi).addClass("selTab_btn2");
						$("#f_button_"+checi).html("<a disabled=\"disabled\" >不代购</a>");
						$("#"+checi+"_button").html("<span style='color:#1B67B5;' title='热门车次得票率低，限制购买'>不代购</span>");
					}
				}else{
					yupiao=escape(yupiao);
					window.location="http://www.99pto.com/buy_now.php?from="+encodeURI(from)+"&to="+encodeURI(to)+"&checi="+checi+"&ymd="+date+"&yupiao="+yupiao+"&hezuo="+hezuo	;	

					//alert('能代购');
						
				}
				}//y
				
				
				
			});
	
	
	
	
}