var c_msg={
	CmobileStr:'请正确填写手机号码，非13或15或18开头的手机号码或号码位数不对',
	emailStr:'请正确填写邮件地址',
	tocityStr:"去程和回程的目的地不能相同，请重新选择！",
	tocityStrs:"请选择目的地！"
}
function frmsubmit(form){
	var patternDate = /^(\d{4})-(\d{2})-(\d{2})$/;
	with(form)
	{
		if(tocity.value == fromcity.value)
		{
			if( tocity.value=="中文/拼音" )
			{
				ShowMessageBox(fromcity,c_msg["tocityStr"],'300');
			}
			else
			{
				ShowMessageBox(tocity,c_msg["tocityStr"],'300');
			}
			return ;
		}
		if(tocity.value=="中文/拼音")
		{
			ShowMessageBox(tocity,c_msg["tocityStrs"],'300');
			return ;
		}
		if(sd1.value == "yyyy-mm-dd" || sd1.value == ""){
			ShowMessageBox(sd1,"预约起始日期不能为空",'300');
			return ;
		}
		if(!patternDate.test(sd1.value)){
			ShowMessageBox(sd1,"填写的起始日期格式不正确，应该是yyyy-mm-dd",'300');
			return ;
		}
		if (sd1.value < (new Date()).getShortDateStr()){
			ShowMessageBox(sd1,"选择的起始日期必须大于当前日期，请重新设置！",'300');
			return ;
		}		
		if(sd2.value == "yyyy-mm-dd" || sd2.value == ""){
			ShowMessageBox(sd2,"预约结束日期不能为空",'300');
			return ;
		}
		if(!patternDate.test(sd2.value)){
			ShowMessageBox(sd2,"选择的预约结束日期必须大于当前日期，请重新设置！",'300');
			return ;
		}
		if(sd2.value < sd1.value){
			ShowMessageBox(sd2,"预约结束日期不能早于起始日期，请重新填写！",'300');
			return ;
		}
		if(DateDiff(sd1.value,sd2.value)>30){
			ShowMessageBox(sd2,"起始日期到结束日期不能超过一个月。",'300');
			return ;
		}
		var inPutFrom = getThreeWordByCity(fromcity.value);
		var inPutTo = getThreeWordByCity(tocity.value);
		if( inPutFrom=="" )
		{
			ShowMessageBox(fromcity,"预约起始城市错误，请重新输入",'300');
			return;
		}
		if( inPutTo=="" )
		{
			ShowMessageBox(tocity,"预约结束城市错误，请重新输入",'300');
			return;
		}
		if( inPutFrom!=sc.value )
		{
			sc.value=inPutFrom;
		}
		if( inPutTo!=ec.value )
		{
			ec.value=inPutTo;
		}
		if(btntype2.checked){
			if(!$validator("number", price.value)){
				ShowMessageBox(price,"价格填写错误。",'300');price.select();price.focus();return;
			}
		}
		if(!$validator("Cmobile", mobile.value)){
				ShowMessageBox(mobile,c_msg["CmobileStr"],'300');mobile.select();mobile.focus();return;
		}
		if(email.value!=""){
				if(!$validator("email", email.value)){ShowMessageBox(email,c_msg["emailStr"],'300');email.select();email.focus();return;}
		}
	}
	$("btnfltsearch").disabled = true;
	$("msgplane").innerHTML="正在提交...";
	var url = "action.asp";
	var para = 'sc='+$("sc").value+'&ec='+$("ec").value+'&sd1='+$("sd1").value+'&sd2='+$("sd2").value+'&priceselect='+$('priceselect').value+'&zhekou='+$('zhekou').options[$('zhekou').selectedIndex].value+'&price='+$('price').value+'&mobile='+$('mobile').value+'&email='+$('email').value+'&t=add&rng='+Math.random();
	//prompt('',para);
	new Ajax.Request(url,{method: 'get',parameters: para,onComplete: showResponse});	
	function showResponse(originalRequest)
	{
		var reqstr = originalRequest.responseText;
		var tmpreqstr = new Function("return "+reqstr);reqstr = tmpreqstr();
		if(reqstr.status){
			window.location.href=reqstr.url;
		}
		else{
			$("msgplane").innerHTML = reqstr.msg;
			$("btnfltsearch").disabled = false;
		}
	}
}
function checkycemail(){
	var v=$("contact").value;
	if(!$validator("Cmobile", v)){
		if(!$validator("email", v)){
			$("yyerror").innerHTML = '不是有效的联系方式（手机号或邮箱）';
			$("yyerror").style.display="";
			$("contact").select();
			$("contact").focus();
			return;
		}
	}
	var url = "action.asp";
	var para = "contact="+v+"&t=cancel&rng="+Math.random();
	new Ajax.Request(url,{method: 'get',parameters: para,onComplete: showResponse2});	
	function showResponse2(originalRequest)
	{
		var reqstr = originalRequest.responseText;
		var tmpreqstr = new Function("return "+reqstr);reqstr = tmpreqstr();
		if(reqstr.status){
			window.location.href=reqstr.url;
		}
		else{
			$("yyerror").innerHTML = reqstr.msg;$("yyerror").style.display="";
			$("sumbmitcancel").disabled = false;
		}
	}
}
Date.prototype.getShortDateStr=function(){
	var str=this.getFullYear().toString();
	str+="-";
	if(this.getMonth()<9)
		str+="0";
	str+=(this.getMonth()+1).toString();
	str+="-";
	if(this.getDate()<10)
		str+="0";
	str+=this.getDate().toString();
	return str;
}

