var r1, r2, r3;
		r1 = new RegExp('[^A-Za-z0-9_]','');
		r2 = new RegExp('[^A-Za-z0-9]','');
		r3 = new RegExp('[^0-9]','');
		
//用户名由<SPAN class=style1>a-z的英文字母(不分大小写)0-9的数字或下划线</SPAN>组成，并以英文字母开头
function verifyUsername(strUsername){
	//var patrn=/(^[A-Za-z]{1,}[A-Za-z0-9_]{0,}$)/; 
	var patrn=/(^[A-Za-z0-9]{1,}$)/; 
			if (!patrn.exec(strUsername)) return false 
			return true
}


//校验普通电话、传真号码：可以“+”开头，除数字外，可含有“-” 
			function isTel(s) 
			{ 
			/*
			(1)电话号码由数字、"("、")"和"-"构成
　　		(2)电话号码为3到8位
　　		(3)如果电话号码中包含有区号，那么区号为三位或四位
　　		(4)区号用"("、")"或"-"和其他部分隔开
			*/
			//var patrn=/(^[0-9]{3,4}\-[0-9]{5,8}$)|(^[0-9]{5,8}$)|(^\([0-9]{3,4}\)[0-9]{5,8}$)|(^[0-9]{3,4}\-[0-9]{5,8}\/[0-9]{3,6}$)|(^[0-9]{5,8}\/[0-9]{3,6}$)|(^\([0-9]{3,4}\)[0-9]{5,8}\/[0-9]{3,8}$)/; 

			var patrn=/(^[0-9]{3,4}\-[0-9]{5,8}$)|(^[0-9]{5,8}$)|(^\([0-9]{3,4}\)[0-9]{5,8}$)|(^[0-9]{3,4}\-[0-9]{5,8}\/[0-9]{1,8}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			function fMobile(s) 
			{ 
			/*
				固定电话
			*/
			var patrn=/(^[0-9]{6,20}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			//校验普通电话、传真号码：可以“+”开头，除数字外，可含有“-” 
			function isMobile(s) 
			{ 
			/*
　　		(5)移动电话号码为11或12位，如果为12位,那么第一位为0
　　		(6)11位移动电话号码的第一位和第二位为"13"
　　		(7)12位移动电话号码的第二位和第三位为"13"
			*/
			var patrn=/(^0{0,0}1[358]{1,1}[0-9]{9}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			function isPhoneD(s) 
			{ 
			/*
				区号
			*/
			var patrn=/(^[0-9]{3,4}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			function isPhoneG(s) 
			{ 
			/*
				固定电话
			*/
			var patrn=/(^[0-9]{6,8}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			function isPhoneSub(s) 
			{ 
			/*
				分机号码
			*/
			var patrn=/(^[0-9]{3,6}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			function isPostCode(s) 
			{ 
			/*
				邮政编码
			*/
			var patrn=/(^[0-9]{6,6}$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			
			function isData(s) 
			{ 
			/*
				是否数字
			*/
			var patrn=/(^[0-9]*[1-9][0-9]*$)/; 
			if (!patrn.exec(s)) return false 
			return true 
			} 
			function NormalPD(str)
			{
			var patrn=/(^[A-Z]{2,2}[0-9]{1,12}$)/; 
				//var rexIP = new RegExp(@"^([A-Z]{2,2}\.[0-9]{1,12})$");
			if ( str.length < 2 )
				return "长度不能少于2";
			else if ( !patrn.exec(str) )
				return "请输入正确的常旅客卡号，例如：CA23423412342";
			return 0;
			
			
			
			}

/*
	检验电子邮件
*/

function isValidEmail(s) {

		var reg1 = new RegExp('^[a-zA-Z0-9][a-zA-Z0-9@._-]{3,}[a-zA-Z]$');
		var reg2 = new RegExp('[@.]{2}');
		
		if (s.search(reg1) == -1
				|| s.indexOf('@') == -1
				|| s.lastIndexOf('.') < s.lastIndexOf('@')
				|| s.lastIndexOf('@') != s.indexOf('@')
				|| s.search(reg2) != -1)
			return false;
		
		return true;
}
	
/*
	检验身份证号
*/

function isIdCardNo_bak(num) {

        var IdeInfor = "";
        if (isNaN(num)) { alert("身份证输入的不是数字!\n"); return false;}
        var len = num.length, re; 
        if (len == 15)
          re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
        else if (len == 18)
          re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);
        else { alert("身份证输入的数字位数不对!\n"); return false;}
        var a = num.match(re);
        if (a != null)
        {
          if (len==15)
          {
            var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
          }
          else
          {
            var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
          }
          if (!B) { alert("输入的身份证号 "+ a[0]+" 里出生日期不对！!\n"); return false;}
        }
        return true;
}

function isIdCardNew(num) 
{

        var IdeInfor = "";
        var len = num.length, re;
        var a;
        var date;
		//var sdd = "19"+num.substring(6,8)+num.substring(8,10)+num.substring(10,12);
		//return sdd;
        
        
        if ( len != 15 && len != 18 )
        {       
			alert ("身份证输入的位数不对");
			return false;
        }
        else if (len == 15)
        {
			re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
			regExp = num.match(re);		
			if( isNaN(num) )
			{	alert( "15位身份证请输入数字");
				return false;
			}
			else if( !validateDate(num) )
			{
				alert ("15位身份证中出生日期不正确");
				return false;
			}
			else
				return true;//验证通过
			
		}
		else if ( len == 18 )
		{
			re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);

			if ( ( len == 18 && isNaN(num.substring(0,17)) ) || (len == 18 && isNaN(num.substring(17,18)) && num.substring(17,18) != "X" && num.substring(17,18) != "x") )
			{	alert( "18位身份证中前17位请输入数字，最后一位请输入数字或大写X");
				return false;
			}
			else if( !validateDate(num) )
			{
				alert( "18位身份证中出生日期不正确");
				return false;
			}
			else
				return true;//验证通过
		}
		else
			return true;//验证通过
}

function isIdCard(num) 
{

        var IdeInfor = "";
        var len = num.length, re;
        var a;
        var date;
		//var sdd = "19"+num.substring(6,8)+num.substring(8,10)+num.substring(10,12);
		//return sdd;
        
        
        if ( len != 15 && len != 18 )
        {       
			return "身份证输入的位数不对";
        }
        else if (len == 15)
        {
			re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);
			regExp = num.match(re);		
			if( isNaN(num) )
				return "15位身份证请输入数字";
			else if( !validateDate(num) )
			{
				return "15位身份证中出生日期不正确";
			}
			else
				return 0;//验证通过
			
		}
		else if ( len == 18 )
		{
			re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);

			if ( ( len == 18 && isNaN(num.substring(0,17)) ) || (len == 18 && isNaN(num.substring(17,18)) && num.substring(17,18) != "X" ) )
				return "18位身份证中前17位请输入数字，最后一位请输入数字或大写X";
			else if( !validateDate(num) )
			{
				return "18位身份证中出生日期不正确";
			}
			else
				return 0;//验证通过
		}
		else
			return 0;//验证通过
}

function validateDate(num)
{
       
        if (  num.length == 15  )
        {
			if ( parseInt(num.substring(8,10),10) > 12
			||   parseInt(num.substring(10,12),10) > 31
			 )     
				return false;
			else
				return true;
		}
				
        else if ( num.length == 18  )
        {
			if ( parseInt(num.substring(6,10),10) > 2500
			||   parseInt(num.substring(6,10),10) < 1900
			||   parseInt(num.substring(10,12),10) > 12
			||   parseInt(num.substring(12,14),10) > 31
			 )       
				return false;
			else
				return true;
        }


       /* if(parseInt(year) > 1900 && parseInt(year) < 2500 && ((tempDate.getFullYear
			()).toString()==year) && (tempDate.getMonth()==parseInt(month,10)-1) && (tempDate.getDate()
			==parseInt(day)))
            return true;
        else
            return false;*/
  
}












function isIdCardNoLen(num) {

        var len = num.length;
        if (len != 15 && len != 18)
        {
			//alert("请输入15位或18位的身份证!\n"); 
			return false;
        }
        else
			return true;
}
function isIdCardNoNum(num) {

        var len = num.length;
        if ( isNaN(num.substring(0,14)) || isNaN(num.substring(0,17)) )
        { 
			//alert("身份证的前14或17位请输入数字!\n"); 
			return false;
        } 
        else
			return true;      
}

function isIdCardNoNum15(num) {

        var len = num.length;
        if ( isNaN(num) && len == 15 )
        { 
			//alert("身份证的前14或17位请输入数字!\n"); 
			return false;
        } 
        else
			return true;      
}

function isIdCardNoNum18(num) {

        var len = num.length;
        if ( ( len == 18 && isNaN(num.substring(0,17)) ) || (len == 18 && isNaN(num.substring(17,18)) && num.substring(17,18) != "X" ) )
        { 
			//alert("身份证的前14或17位请输入数字!\n"); 
			return false;
        } 
        else
			return true;      
}










/*	中文限制	*/
function isChinese(str){
  str = str.replace(" ", "");
  for (i=0;i<str.length;i++)
  { 
     if (str.charCodeAt(i)< 255)
     {
       return false;
     }
   }
   return true;
}
/*	中文限制	*/
function isCode(str){
  str = str.replace(" ", "");
  for (i=0;i<str.length;i++)
  { 
     if (str.charCodeAt(i) >= 255)
     {
       return false;
       break;
     }
   }
   return true;
}


//检查中英文姓名
//检查中英文姓名
function CheckName(tt) {
var errdetect=true;
var NameSplit ;//= new Array("","");
var hz=0;
len=tt.length;
if(tt=="所选证件上的姓名") return false;

if (len >=2)
{
        //返回该字符串位于第位置位的单个字符,并且url编码(%号开始)
        dd = escape(tt.charAt(0));
		//是英文字符开始
		if (dd.length<=3)
		{hz=0;}
		else
		{hz=1;}
		/*
			for (i=0; i<len; i++)
			{
				dd = escape(tt.charAt(i));
				//英文字符
				if (dd.length<=3)
				{
					if (hz==0){if(parseInt(dd)){errdetect=false;break;}}
					if (hz==1){errdetect=false;break;}
				}
				else
				{
					if (hz==0){errdetect=false;break;}
				}
			}

		*/
		//汉字开始
		if(hz == 1)
		{
			for (i=1; i<len - 1; i++)
			{
				dd = escape(tt.charAt(i));
				nextdd = escape(tt.charAt(i+1));
				if (dd.length <= 3 && nextdd.length > 3)
				{
					errdetect=false;
					break;
				}
				
			}
        }
        if ( (errdetect) && (hz == 0) ){
			//if(tt.length<5){errdetect=false;return false;}
                indexg = tt.indexOf("/");
                if (indexg!=-1){
				NameSplit = tt.split("/");
				if ( NameSplit.length > 2 )
					errdetect=false;
				else
				{							
					if (  NameSplit[0].length < 2 || NameSplit[1].length  < 2 )
						errdetect=false;
					else
						errdetect=true;		
				}			 
                }
                else{
				errdetect=false;
			}
        }
}
else
	{errdetect=false;}
return errdetect;
}


//function isChi


<!-- Begin
/*

计算距离某天的时间:年月日
婴儿和儿童检验

*/
function HowLongSince(type,starttime) {
	var ydiff1,mdiff1,dayst
	var atime = starttime.split("-");
	
	sdate=atime[2];
	smonth=atime[1]-1;
	syear=atime[0];
	var DaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	today = new Date()
	var thisyear = today.getFullYear();
	var thismonth = today.getMonth();
	var thisdate = today.getDate();
	mstart = new Date(syear,(smonth==12?1:smonth+1),1);
	days1 = (mstart - new Date(syear,smonth,sdate))/(24*60*60*1000)-1;
	mend = new Date(thisyear,thismonth,1);
	days2 = (new Date(thisyear,thismonth,thisdate) - mend)/(24*60*60*1000)+1;
	dayst = days1 + days2;
	if (dayst >= DaysInMonth[smonth])  {
	AddOneMonth = 1; 
	dayst -= DaysInMonth[smonth]; 
	}
	else AddOneMonth = 0;
	ydiff1 = thisyear-mstart.getFullYear();
	mdiff1 = thismonth-mstart.getMonth()+AddOneMonth;
	if (mdiff1 >11) { mdiff1=0; ydiff1++; }
	if (mdiff1 < 0) { mdiff1 = mdiff1 + 12; ydiff1--; }
	temp = (ydiff1==0?"":(ydiff1==1?ydiff1+" 年， ":ydiff1 + " 年，"));
	temp += (mdiff1==0?"0 months, ":(mdiff1==1?mdiff1+" month, ":mdiff1+" 个月，"));
	temp += (dayst==0?"no days":(dayst==1 ? " 1 day." : dayst + " 天" ));
	//婴儿 两年以下
	if ( type == "baby" ) {
		if ( ydiff1 == 2 &&  mdiff1 == 0 && dayst == 0)
			return true;
		if ( ydiff1 < 2 && ydiff1 >=0)
			return true;
	
	}
	//小孩
	if ( type == "child" ) {
		if ( ydiff1 == 2 &&  ( mdiff1 > 0 || dayst > 0 )  )
			return true;
		if ( ydiff1 == 12 &&  mdiff1 == 0 && dayst == 0 )
			return true;
		if ( ydiff1 < 12 && ydiff1 > 2  )
			return true;
	}
	
	return false;
	
	
	
	//return temp;
}
//  End -->

function HowLongTime(type,starttime,thisyear,thismonth,thisdate) {
	var ydiff1,mdiff1,dayst
	var atime = starttime.split("-");
	sdate=atime[2];
	smonth=atime[1]-1;
	syear=atime[0];
	var DaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
	
	mstart = new Date(syear,(smonth==12?1:smonth+1),1);
	days1 = (mstart - new Date(syear,smonth,sdate))/(24*60*60*1000)-1;
	mend = new Date(thisyear,thismonth,1);
	days2 = (new Date(thisyear,thismonth,thisdate) - mend)/(24*60*60*1000)+1;
	dayst = days1 + days2;
	if (dayst >= DaysInMonth[smonth])  {
	AddOneMonth = 1; 
	dayst -= DaysInMonth[smonth]; 
	}
	else AddOneMonth = 0;
	ydiff1 = thisyear-mstart.getFullYear();
	mdiff1 = thismonth-mstart.getMonth()+AddOneMonth;
	if (mdiff1 >11) { mdiff1=0; ydiff1++; }
	if (mdiff1 < 0) { mdiff1 = mdiff1 + 12; ydiff1--; }
	temp = (ydiff1==0?"":(ydiff1==1?ydiff1+" 年， ":ydiff1 + " 年，"));
	temp += (mdiff1==0?"0 months, ":(mdiff1==1?mdiff1+" month, ":mdiff1+" 个月，"));
	temp += (dayst==0?"no days":(dayst==1 ? " 1 day." : dayst + " 天" ));
	//婴儿 两年以下
	if ( type == "baby" ) {
		if ( ydiff1 == 2 &&  mdiff1 == 0 && dayst >= 0)
			return true;
		if ( ydiff1 < 2 && ydiff1 >=0)
			return true;
	
	}
	//小孩
	if ( type == "child" ) {
		if ( ydiff1 == 2 &&  ( mdiff1 > 0 || dayst > 0 )  )
			return true;
		if ( ydiff1 == 12 &&  mdiff1 == 0 && dayst >= 0 )
			return true;
		if ( ydiff1 < 12 && ydiff1 > 2  )
			return true;
	}
	
	return false;
	
	
	
	//return temp;
}

  function selectTime(txtId) 
    { 
		var timestring = showModalDialog("../Component/selecttime.htm", "", "dialogLeft:"+(event.screenX-80)+";dialogTop:"+(event.screenY-80)+";dialogWidth:165px; dialogHeight:165px; edge:raised;help:off;status:off;scroll:off");
		if(timestring!="")
		{
			document.all(txtId).value = timestring;  
		}   
    }
    
    //弹出新窗户居中
    
   function goURL(szURL,w, h) { 

	var width,height;
	if(w==null)
	width="600";
	else
	width=w;
	
	if(h==null)
	height="400";
	else
	height=h;
	
	
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
	xposition = (screen.width - width) / 2;
	yposition = (screen.height - height) / 2;
	}
	theproperty= "width=" + width + "," 
	+ "height=" + height + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=0,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	+ "left=" + xposition + "," //IE
	+ "top=" + yposition; //IE 
	window.open(szURL,"new",theproperty);
	var date = new Date();	
} 

function DivSetVisible(state)
			{
				try
				{
					var DivRef = document.getElementById('divNewPassenger');
					var IfrRef = document.getElementById('DivShim');
					if(state)
					{
						DivRef.style.display = "block";
						IfrRef.style.width = DivRef.offsetWidth;
						IfrRef.style.height = DivRef.offsetHeight;
						IfrRef.style.top = DivRef.style.top;
						IfrRef.style.left = DivRef.style.left;
						IfrRef.style.zIndex = DivRef.style.zIndex - 1;
						IfrRef.style.display = "block";
					}
					else
					{
						DivRef.style.display = "none";
						IfrRef.style.display = "none";
					   
					}
				}
				catch(e)
				{
					alert("执行脚本DivSetVisible发生错误，请与天益游商旅网客服人员联系。");
				}	
			}
			
			function DivSetVisible1(state)
			{
				try
				{
					var DivRef = document.getElementById('divNewPassenger1');
					var IfrRef = document.getElementById('DivShim1');
					if(state)
					{
						DivRef.style.display = "block";
						IfrRef.style.width = DivRef.offsetWidth;
						IfrRef.style.height = DivRef.offsetHeight;
						IfrRef.style.top = DivRef.style.top;
						IfrRef.style.left = DivRef.style.left;
						IfrRef.style.zIndex = DivRef.style.zIndex - 1;
						IfrRef.style.display = "block";
					}
					else
					{
						DivRef.style.display = "none";
						IfrRef.style.display = "none";
					   
					}
				}
				catch(e)
				{
					alert("执行脚本DivSetVisible发生错误，请与天益游商旅网客服人员联系。");
				}	
			}


