www.gusucode.com > uu8机票实时查询系统静态下载 > js/Common(1).js

    
	//获取document的id
	function G(id){ return document.getElementById(id); }

	//根据document的id获取值
	function V(id){ return G(id).value;}

	function myBlur2() {
		if (G('HelpList')) {
			G('HelpList').style.visibility='visible';
		}
	}
	/**
	返回表单元素name的一些属性
	* */
	function Gs(name) { return document.getElementsById ; }

	//获取document的name
	function GN(name){ return document.getElementsByName(name); }

	//确认是否删除
	function IsDel(msg){ if(confirm(msg)){return true;}return false;}
	//确定与取消提示框
	function  myconfirm(msg){ if(confirm(msg)){return true;}return false;}
	//通用删除提示
	function Tips(){ if(confirm("您确定要删除吗(不可恢复)?")){return true;}return false;}

	function Left(mainStr,lngLen) {
		if (lngLen>0) {return mainStr.substring(0,lngLen)} else{ return null; }
	}
	function Right(mainStr,lngLen) {
		if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
			return mainStr.substring(mainStr.length-lngLen,mainStr.length)
		} else{
			return null;
		}
	}
	function Mid(mainStr,starnum,endnum){
		if (mainStr.length>=0){ return mainStr.substr(starnum,endnum) } else { return null}
	}

//取得mainStr中 str1与str2中间的字符(不包括str1和str2)
	function StrMid(mainStr,str1,str2)
	{
		index1=mainStr.indexOf(str1);
		index2=mainStr.indexOf(str2);
		len1=len(str1);
		len2=len(str2);
		s=index1+len1;
		e=index2-index1-len1;
		str=mainStr.substr(s,e);
		return str;
	}
//取得字符串的长度
	function len(s)
	{
		var l=0;
		var a=s.split("");
		for(i=0;i<a.length;i++)
		{
			if(a[i].charCodeAt(0)<299)
			{
				l++;
			}
			else
			{
				l+=2;
			}
		}
		return l;
	}
	/*指定到某个页*/
	function Url(myUrl) {
		location.href=myUrl;
	}


	/* 获得 obj的绝对位置 getAbsolutePosition*/

	function getAP(obj)
	{
	position = new Object();
	position.x = 0;
	position.y = 0;
	var tempobj = obj;
		while(tempobj!=null && tempobj!=document.body)
		{
			if(window.navigator.userAgent.indexOf("MSIE")!=-1)
			{
				position.x += tempobj.offsetLeft+1;
				position.y += tempobj.offsetTop+15;
			}
			else if(window.navigator.userAgent.indexOf("Firefox")!=-1)
			{
				position.x += tempobj.offsetLeft;
				position.y += tempobj.offsetTop;
			}
			tempobj = tempobj.offsetParent
		}
		//alert(position);
	return position;
	}

	function SetnPos(obj)
	{
		var pos=getAP(document.getElementById(obj));
		//alert(pos.x+'|'+pos.y);
		document.getElementById(obj).style.display='';
		document.getElementById(obj).style.left=pos.x+"px";
		document.getElementById(obj).style.top=pos.y+"px";
	}

	/* 刷新验证码 */
	function reloadImage(ImgID,File) {

		document.images[ImgID].src="/Common/"+File+".php#"+GetRndNum(1,99999);
	}

	/*产生随机数*/
	function GetRndNum(Min,Max){
		var Range = Max - Min;
		var Rand = Math.random();
		return(Min + Math.round(Rand * Range));
	}

	/* 检测原密码是否正确 */
	function CheckPassWord(uid,pwd) {
		var myRnd=GetRndNum(1,100000);
		$.get("/jQueryGetData.php",{ Action:"GetUserCheckPassWord",UserID:uid,UserValue:pwd,Rnd:myRnd },function(Data){
			if (Data!='') {
				$("#thisResult").html(Data);
			}
		});
	}

	/*图片自适应*/
	function SetSize(obj, width, height){
		myImage = new Image();
		myImage.src = obj.src;
		if (myImage.width>0 && myImage.height>0){
			var rate = 1;
			if (myImage.width>width || myImage.height>height){
				if (width/myImage.width<height/myImage.height){
					rate = width/myImage.width;
				} else {
					rate = height/myImage.height;
				}
			}
			if (window.navigator.appName == "Microsoft Internet Explorer") {
			  obj.style.zoom = rate;
			} else {
			  obj.width = myImage.width*rate;
			  obj.height = myImage.height*rate;
			}
		}
	}

	/* 图片自动适应 */
	var flag=false;
	function DrawImage(ImgD,w,h){
		var width=w
		var height=h
		var image=new Image();
		image.src=ImgD.src;
		if(image.width>0 && image.height>0){
			flag=true;
			if(image.width/image.height>= width/height){
				if(image.width>width){
					ImgD.width=width;
					ImgD.height=(image.height*width)/image.width;
				} else {
					ImgD.width=image.width;
					ImgD.height=image.height;
				}
				//ImgD.alt=image.width+"×"+image.height;
			} else {
				if(image.height>height){
					ImgD.height=height;
					ImgD.width=(image.width*height)/image.height;
				} else {
					ImgD.width=image.width;
					ImgD.height=image.height;
				}
					//ImgD.alt=image.width+"×"+image.height;
			}
		}
	}
	//-------------------------------------------------------------------------------------------
	//检查身份证号
	function CheckIdCard(Str)
	{
		if (Str.length == 0) return true;
		if (Str.search(/^((\d{17}[\d,x])|\d{15}){1}$/) != -1)
			return true;
		else
			return false;
	}
	//检查文本字段是否为身份证号
	//Form:表单名称或序号
	//Name:文本字段名称
	//Str:字符串,弹出的警告字符串
	function CheckFormIdCard(Form,Name,Str)
	{
	  var ObjEle = document.forms[Form].elements[Name];
		if (!CheckIdCard(ObjEle.value))
		{
			if (Str !== '') alert(Str);
			ObjEle.focus();
			return false;
		}
		return true;
	}

	/*-------------------------------------------------------------------------------------------
		广告统计
		广告位置,宽,高
	*/
	function myAdCount(objID,Url) {
		myUrl="/myAdCount.php?obj="+objID+"&from="+Url;
		window.open(myUrl,"_blank");
  		return false;
	}
	/*   返回字节数2008-11-28   */
	String.prototype.lenb=function(){
	  return this.replace(/[^\x00-\xff]/g,"**").length;
	}
	/* 验证填写姓名 */
	function guestname(GuestName) {
		var ErrStr;
		var ErrChar;
		var ArryErrStr;
		//ErrChar="!@#$%^&*()_+|-=\\~`;'[]{}\"':,;.<>?~!@#¥%^&×()……+|-=、〔〕{}:“;‘《》?,。、0123456789";
		ErrChar="!@#$%^&*()_+|-=\\~`;'[]{}\"':,;.<>?~!@#¥%^&×()……+|-=、〔〕{}:“;‘《》?,。、";
		ErrStr="虚拟,傻冒,先生,小姐,代订,代定,测试";
		ArryErrStr = ErrStr.split(",");
		//是否含有非法字符
		for(var k=0;k<GuestName.length;k++){
			if(ErrChar.indexOf(GuestName.charAt(k))>-1){
				return false;
			}
		}
		//是否含有非法字符串
		if ( ErrStr!=null && ErrStr!="" ){
			for (k=0; k<ArryErrStr.length; k++){
				if (GuestName.indexOf(ArryErrStr[k])>-1){
					return false;
				}
			}
		}
		return true;
	}

	/*验证身份证号码*/
	function IDCard(sNo)
	{
	    sNo = sNo.toString()
	    if (sNo.length==18) {
	       var a,b,c
	       if (!checkSum(sNo.substr(0,17))) {return false}
	       a=parseInt(sNo.substr(0,1))*7+parseInt(sNo.substr(1,1))*9+parseInt(sNo.substr(2,1))*10;
	       a=a+parseInt(sNo.substr(3,1))*5+parseInt(sNo.substr(4,1))*8+parseInt(sNo.substr(5,1))*4;
	       a=a+parseInt(sNo.substr(6,1))*2+parseInt(sNo.substr(7,1))*1+parseInt(sNo.substr(8,1))*6;
	       a=a+parseInt(sNo.substr(9,1))*3+parseInt(sNo.substr(10,1))*7+parseInt(sNo.substr(11,1))*9;
	       a=a+parseInt(sNo.substr(12,1))*10+parseInt(sNo.substr(13,1))*5+parseInt(sNo.substr(14,1))*8;
	       a=a+parseInt(sNo.substr(15,1))*4+parseInt(sNo.substr(16,1))*2;
	       b=a%11;
	       if (b==2){
	          c=sNo.substr(17,1).toUpperCase();
	       } else {
	         c=parseInt(sNo.substr(17,1));
	       }

	       switch(b) {
	         case 0: if ( c!=1 ) {return false;}break;
	         case 1: if ( c!=0 ) {return false;}break;
	         case 2: if ( c!="X") {return false;}break;
	         case 3: if ( c!=9 ) {return false;}break;
	         case 4: if ( c!=8 ) {return false;}break;
	         case 5: if ( c!=7 ) {return false;}break;
	         case 6: if ( c!=6 ) {return false;}break;
	         case 7: if ( c!=5 ) {return false;}break;
	         case 8: if ( c!=4 ) {return false;}break;
	         case 9: if ( c!=3 ) {return false;}break;
	         case 10: if ( c!=2 ){return false}
	      }
	   }

	}


	/* Email验证 2008-12-1*/
	function isEmail(strEmail) {
		if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true; else return false;
	}

	/* js checkbox 全选 */
	function selcheck() {
		var objs = document.getElementsByTagName("input");
		for(var i=0; i<objs.length; i++) {
			if(objs[i].type.toLowerCase() == "checkbox" )
				objs[i].checked == true ? objs[i].checked=false:objs[i].checked=true;
		}
	}

	/* 选中某个发送信息 */
	function sendmsg(url) {
		var objs = document.getElementsByName("user");
		for(var i=0; i<objs.length; i++) {
			if(objs[i].type.toLowerCase()=="checkbox")
				if (objs[i].checked) {
					location.href="Admin_Member_SendMessage.php?user="+objs[i].value+"&Url="+url;
				}
		}
	}

	/* 省市[县]选择 2008-11-07 Modify 2008-11-29*/
	function GetCityData(thisID,obj,con) {
		thisValue=G(thisID).value;
		if (thisValue==0 || thisValue=='') return false;
		newObj="#"+obj;
		jQuery(newObj).get(0).options.length=0;
		objStr='<option value="" selected>正在加载,请稍候...</option>';
		G(obj).style.color="#8A8A8A";
		jQuery(objStr).appendTo(newObj);
		G(obj).disabled=false;
		if (thisValue!='') {
			jQuery.get("/jQueryGetData.php",{Action:con,myValue:thisValue},function(Data){
				Data=trim(Data);
				if (Data!="") {
					G(obj).style.color='';
					jQuery(newObj).get(0).options.length=0;
					jQuery(Data).appendTo(newObj);
					jQuery('<option value="" selected>-请选择-</option>').appendTo(newObj);
				} else {

					//(obj).style.color='';
					jQuery(newObj).get(0).options.length=0;
					jQuery('<option value="0" selected>暂无</option>').appendTo(newObj);
				}
			});
		}
		if (thisID=='szcs1') { AreaClear('szcs3');}
		if (thisID=='jd_ssqy1') { AreaClear('jd_ssqy3');}
	}
	
	function GetCityData1(thisID,obj,con) {
		thisValue=G(thisID).value;
		if (thisValue==0 || thisValue=='') return false;
		newObj="#"+obj;
		$j(newObj).get(0).options.length=0;
		objStr='<option value="" selected>正在加载,请稍候...</option>';
		G(obj).style.color="#8A8A8A";
		$j(objStr).appendTo(newObj);
		G(obj).disabled=false;
		if (thisValue!='') {
			$j.get("/jQueryGetData.php",{Action:con,myValue:thisValue},function(Data){
				Data=trim(Data);
				if (Data!="") {
					G(obj).style.color='';
					$j(newObj).get(0).options.length=0;
					$j(Data).appendTo(newObj);
					$j('<option value="" selected>-请选择-</option>').appendTo(newObj);
				} else {

					//(obj).style.color='';
					$j(newObj).get(0).options.length=0;
					$j('<option value="0" selected>暂无</option>').appendTo(newObj);
				}
			});
		}
		if (thisID=='szcs1') { AreaClear1('szcs3');}
		if (thisID=='jd_ssqy1') { AreaClear1('jd_ssqy3');}
	}
	/*当选择省份时,清空县数据*/
	function AreaClear1 (obj) {
		$j("#"+obj).get(0).options.length=0;
		var opt=' <option value="" selected="selected">-所在县-</option>';
		$j(opt).appendTo("#"+obj);
	}


	/*当选择省份时,清空县数据*/
	function AreaClear (obj) {
		jQuery("#"+obj).get(0).options.length=0;
		var opt=' <option value="" selected="selected">-所在县-</option>';
		jQuery(opt).appendTo("#"+obj);
	}

	function trim(str) {
		return str.replace(/^\s+|\s+$/,'')	;
	}

	/* 世界各国家,根据国家加载城市
	* @params 当前select ID,目标ID
	* @returns option
	* @authors xiaokang
	* @date 2009-1-8
	*/
	function GetCountryCity(thisCountryID,objID) {
		value=G(thisCountryID).value;
		$('#'+objID).get(0).options.length=0;
		if (value!='' && value!='0') {
			$.get("/jQueryGetData.php",{Action:'GetCountryData',From:'XiaoKang',Value:value},function(myData){
				//alert(myData);
				if (myData!='') {
					$(myData).appendTo('#'+objID);
				}
			})
		}
	}


	/* 显示隐藏切换 带渐变效果 */
	function toggle(obj){
		$("#"+obj).toggle(1000);//显示隐藏切换,参数可以无
	}

	/* 显示隐藏切换 */
	function myToggle(obj) {
			$("#"+obj).slideToggle("slow");
	}

	/*  身份证号码验证段 Copy From Net 2008-12-18------------------------------------------------------ */
	var yyyy;
	var mm;
	var dd;
	var birthday;
	var sex;

	function getYear(){
		return yyyy;
	}
	function getMonth(){
		return mm;
	}
	function getDate(){
		return dd;
	}
	function getBirthday(){
		return birthday;
	}
	function getSex(){
		return sex;
	}
	function getAge(){
		var mm=getMonth();
		if (mm<10)
				mm=mm.substring(1,2);
		return Math.floor((parseInt(_getYear())*12+parseInt(_getMonth())-parseInt(getYear())*12-parseInt(mm))/12);
	}
	//判断是否大龄,男50,女40
	function isBigAge(){
		if (parseInt(getAge())>=40 && parseInt(getSex())==2)
			return "1";
		if (parseInt(getAge())>=50 && parseInt(getSex())==1)
			return "1";
		return "0";
	}
	//校验身份证号码
	function CheckValue(idCard,num){
		var id=idCard;
		var id_length=id.length;

		if (id_length==0){
			alert("请输入乘机人"+num+"身份证号码!");
			return false;
		}

		if (id_length!=15 && id_length!=18){
			alert("乘机人"+num+"身份证号长度应为15位或18位!");
			return false;
		}

		if (id_length==15){
			yyyy="19"+id.substring(6,8);
			mm=id.substring(8,10);
			dd=id.substring(10,12);

			if (mm>12 || mm<=0){
				alert("乘机人"+num+"输入身份证号,月份非法!");
				return false;
			}

			if (dd>31 || dd<=0){
				alert("乘机人"+num+"输入身份证号,日期非法!");
				return false;
			}

			birthday=yyyy+ "-" +mm+ "-" +dd;

			if ("13579".indexOf(id.substring(14,15))!=-1){
				sex="1";
			}else{
				sex="2";
			}
		}else if (id_length==18){
			if (id.indexOf("X") > 0 && id.indexOf("X")!=17 || id.indexOf("x")>0 && id.indexOf("x")!=17){
				alert("乘机人"+num+"身份证中\"X\"输入位置不正确!");
				return false;
			}

			yyyy=id.substring(6,10);
			if (yyyy>2200 || yyyy<1900){
				alert("乘机人"+num+"输入身份证号,年度非法!");
				return false;
			}

			mm=id.substring(10,12);
			if (mm>12 || mm<=0){
				alert("乘机人"+num+"输入身份证号,月份非法!");
				return false;
			}

			dd=id.substring(12,14);
			if (dd>31 || dd<=0){
				alert("乘机人"+num+"输入身份证号,日期非法!");
				return false;
			}

			if (id.charAt(17)=="x" || id.charAt(17)=="X")
			{
				if ("x"!=GetVerifyBit(id,num) && "X"!=GetVerifyBit(id)){
					alert("乘机人"+num+"身份证校验错误,请检查最后一位!");
					return false;
				}

			}else{
				if (id.charAt(17)!=GetVerifyBit(id,num)){
					alert("乘机人"+num+"身份证校验错误,请检查最后一位!");
					return false;
				}
			}

			birthday=id.substring(6,10) + "-" + id.substring(10,12) + "-" + id.substring(12,14);
			if ("13579".indexOf(id.substring(16,17)) > -1){
				sex="1";
			}else{
				sex="2";
			}
		}

		return true;
	}


	//15位转18位中,计算校验位即最后一位
	function GetVerifyBit(id,num){
		var result;
		var nNum=eval(id.charAt(0)*7+id.charAt(1)*9+id.charAt(2)*10+id.charAt(3)*5+id.charAt(4)*8+id.charAt(5)*4+id.charAt(6)*2+id.charAt(7)*1+id.charAt(8)*6+id.charAt(9)*3+id.charAt(10)*7+id.charAt(11)*9+id.charAt(12)*10+id.charAt(13)*5+id.charAt(14)*8+id.charAt(15)*4+id.charAt(16)*2);
		nNum=nNum%11;
		switch (nNum) {
		   case 0 :
			  result="1";
			  break;
		   case 1 :
			  result="0";
			  break;
		   case 2 :
			  result="X";
			  break;
		   case 3 :
			  result="9";
			  break;
		   case 4 :
			  result="8";
			  break;
		   case 5 :
			  result="7";
			  break;
		   case 6 :
			  result="6";
			  break;
		   case 7 :
			  result="5";
			  break;
		   case 8 :
			  result="4";
			  break;
		   case 9 :
			  result="3";
			  break;
		   case 10 :
			  result="2";
			  break;
		}
		//document.write(result);
		return result;
	}
	//15位转18位
	function Get18(idCard,num){
		 if (CheckValue(idCard,num)){
			  var id = idCard;
			  var id18=id;
			  if (id.length==0){
				   alert("请输入乘机人"+num+"15位身份证号!");
				   return false;
			  }
			  if (id.length==15){
				   if (id.substring(6,8)>20){
						id18=id.substring(0,6)+"19"+id.substring(6,15);
				   }else{
						id18=id.substring(0,6)+"20"+id.substring(6,15);
				   }
				   id18=id18+GetVerifyBit(id18);
			  }
			  return id18;
		 } else {
		  	return false;
		 }
	}
	/*------------------------------------------------------ */


	/* 军人证号码验证*/
	function SoldierID(bb){
		var re=/\d{6}(19|20)[\d]{6}0000/;
		var s=re.test(bb);
		function cdate(d){
			 var t=d.substring(10,14);
			 var m=parseInt(t.substring(0,2));
			 var day=parseInt(t.substring(2,4));
			 if(m>12) return false;
			 if(day>31) return false;
			 if(m==2&&day>29) return false;
			 return true;
		}
	 return s&&cdate(bb);
	}

	/* 表格奇偶数背景 */
	function TableBg(tableID) {
		if (G(tableID)) {
			var Rows=G(tableID).rows.length;
			for(var i=1;i<Rows;i++) {
				if (i % 2==0) {
					G(tableID).rows[i].style.backgroundColor="#F3F4F4";
				} else {
					G(tableID).rows[i].style.backgroundColor="";
				}
	/*			G(tableID).rows[i].onmouseover=function(){
					Color=this.style.backgroundColor;
					this.style.backgroundColor= "#ECECEC";
					this.onmouseout=function(){
						this.style.backgroundColor=Color;
					}
				}*/
			}
		}
	}

	/* 表格奇偶数背景 */
	function TableBg2(tableID) {
		var Rows=G(tableID).rows.length;
		for(var i=1;i<Rows;i++) {
			if (i % 2==0) {
				G(tableID).rows[i].style.backgroundColor="#F3F4F4";
			} else {
				G(tableID).rows[i].style.backgroundColor="";
			}
			G(tableID).rows[i].onmouseover=function(){
				Color=this.style.backgroundColor;
				this.style.backgroundColor= "#E3F0F0";
				this.onmouseout=function(){
					this.style.backgroundColor=Color;
				}
			}
		}
	}


	/* 表格奇偶数背景 用于同行内页 */
	function myTableBg(tableID) {
		var Rows=G(tableID).rows.length;
		var Color;
		for(var i=0;i<Rows;i++) {
			if (i % 2==0) {
				if 	(G(tableID).rows[i+1]) {
					G(tableID).rows[i+1].style.backgroundColor="#F3F4F4";
				}
			}
/*			G(tableID).rows[i].onmouseover=function(){
				Color=this.style.backgroundColor;
				this.style.backgroundColor="#ECECEC";
				this.onmouseout=function(){
					this.style.backgroundColor=Color;
				}
			}*/
		}
	}
	/*当获得焦点时*/
	function myFocus(obj) {
		if (G(obj).value!="YYYY-MM-DD"){
			G(obj).value="";
			G(obj).style.color='#000000';
		}
	}

	/*当失去焦点时*/
	function myBlur(obj,val) {
		if (G(obj).value!=val && G(obj).value!="") {
			G(obj).style.color='#000000';
		}

	}

//////////////////////////////////////////////////////////////////////////////////////////
//显示指定id的div
function showdiv(divid)
{
	document.getElementById(divid).style.display="";
}


//隐藏指定id的div
function hiddiv(divid)
{
	document.getElementById(divid).style.display="none";
}

//改变指定id的单元格的内容
function editdiv(divid,content)
{
	if (document.getElementById(divid)) {
		document.getElementById(divid).innerHTML=content;
	}
}

//切换指定id对象的display属性
function changedisplay(divid)
{
	if(document.getElementById(divid).style.display!="none")
	{
		document.getElementById(divid).style.display="none";
	}
	else
	{
		document.getElementById(divid).style.display="";
	}
}


/*延迟跳转页面
@url 跳转地址
@content 提示内容
@time 延迟毫秒数 1秒=1000毫秒
*/
function gopage(url,content,time)
{
	document.write(content);
	setTimeout("window.parent.location.href=\""+url+"\"",time);
}
//////////////////////////////////////////////////////////////////////////////



//检测账号
function UserCheck(obj,result,type){
	var UserName=$("#"+obj).val();
	if (UserName=="") {
		window.alert("用户名称不能为空!");
		$("#"+obj).get(0).focus();
		return false;
	}
	if (UserName.lenb()<4) {
		window.alert("用户名称不能小于4个字符!");
		$("#"+obj).get(0).focus();
		return false;
	}
	$("#"+result).html('<span style="color:#cccccc">正在检测,请稍候...</span>');
	var myRnd=GetRndNum(1,100000);
	$.get("/jQueryGetData.php?UserName"+UserName,{Action:"GetUserCheck",Rnd:myRnd,Type:type},function(Data){
		if (Data!='') {
			$("#"+result).html(Data);
		}
	});
}


//检测账号不区分频道
function UserCheckn(obj,result){
	var UserName=$("#"+obj).val();
	if (UserName=="") {
		window.alert("用户名称不能为空!");
		$("#"+obj).get(0).focus();
		return false;
	}
	if (UserName.lenb()<4) {
		window.alert("用户名称不能小于4个字符!");
		$("#"+obj).get(0).focus();
		return false;
	}
	$("#"+result).html('<span style="color:#cccccc">正在检测,请稍候...</span>');
	var myRnd=GetRndNum(1,100000);
	$.get("/jQueryGetData.php",{Action:"GetUserCheck",UserName:UserName,Rnd:myRnd},function(Data){
		if (Data!='') {
			$("#"+result).html(Data);
		}
	});
}

/* 日期选择时触发事件 */
/*当获得焦点时*/
function thisDate1(object,val) {
	if (G('HelpList')) {
		G('HelpList').style.visibility='hidden';
	}
	var obj=object.id;
	if (G(obj).value==val){
		G(obj).value="";
		G(obj).style.color="#cccccc";
	} else {
		G(obj).value=val;
		G(obj).style.color="#ffffff";
	}
	ShowTwoMonthList(object,0,"thisDay");

}
/* 日期选择时触发事件 */
/*当获得焦点时*/
function thisDate2(object,val,date1ID) { //如果obj 的值等于val那么另obj的字体颜色为#009900,
	var obj=object.id;
	if (G(obj).value==val){
		G(obj).value="";
		G(obj).style.color="#cccccc";
	} else {
		G(obj).value=val;
		G(obj).style.color="#ffffff";
	}
	var date1=G(date1ID).value;
	var mydate=date1=='yyyy-mm-dd' || date1=='' ? "thisDay":DateAdd('d',date1,1);
	ShowTwoMonthList(object,0,mydate);
}

/*
*日期相加减,日期格式要求 yyyy/mm/dd 或 yyyy-mm-dd
*@params 年y、月m、日d,当前日期,相加(减)数字
*@returns 返回yyyy-mm-dd 格式日期
*@authors xiaokang create at 2009-1-11
*/
function DateAdd(thisType,thisDate,thisNum) {
	if (thisDate.indexOf('-')>0) {
		thisDate=thisDate.replace(/-/g,"/");
	}
	var date=new Date(thisDate);
	var num=parseInt(thisNum);
	switch(thisType) {
		case 'y' :
			date.setFullYear(date.getFullYear()+num);
			break;
		case 'm' :
			date.setMonth(date.getMonth()+num);
			break;
		case 'd' :
			date.setDate(date.getDate()+num);
			break;
		default:
	}
	return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
}

/*
*两日期相比较 有效格式 yyyy-mm-dd 或 yyyy/mm/dd
*@params 日期1,日期2
*@returns 日期1与日期2的差值(天)
*@authors xiaokang create at 2009-1-11
*/
function DateCompare(thisDate1,thisDate2) {
	if (thisDate1.indexOf('-')>0) {
		thisDate1=thisDate1.replace(/-/g,"/");
	}
	if (thisDate2.indexOf('-')>0) {
		thisDate2=thisDate2.replace(/-/g,"/");
	}
	var date1=new Date(thisDate1);
	var date2=new Date(thisDate2);
	var dateResult=(date1-date2)/24/60/60/1000;

	return dateResult;
}
/*取得某对象的坐标位置、宽、高,当前对象*/
function GetPosition(obj){
	var top=0;
	var left=0;
	var width=obj.offsetWidth;
	var height=obj.offsetHeight;
	while(obj.offsetParent){
		top+=obj.offsetTop;
		left+=obj.offsetLeft;
		obj=obj.offsetParent;
	}
	return{"top":top,"left":left,"width":width,"height":height};
}


/**
*文本框获得与得到焦点时 常用事件,用于后台搜索文本框提示效果
*@params object,值,颜色值
**/
function myThisFocus(obj) {
	if (obj.value=='' || obj.value=='关键字') {
		obj.style.color='#000000';
		obj.value='';
	}
	obj.onblur=function () {
		if (obj.value=='' || obj.value=='关键字') {
			obj.style.color='#cccccc';
			obj.value='关键字';
		}
	}
}


/**
*文本框获得与得到焦点时 常用事件,企业会员搜索文本框提示效果
*@params object,值,颜色值
**/
function myFocus2(obj,key,color1,color2) {
	if (obj.value=='' || obj.value==key) {
		obj.style.color=color1;
		obj.value='';
	} else {
		obj.style.color=color2;
	}
	obj.style.color=color2
	obj.onblur=function () {
		if (obj.value=='' || obj.value==key) {
			obj.style.color=color1;
			obj.value=key;
		} else {
			obj.style.color=color2;
		}
	}
}

/**
*文本框获得与得到焦点时 常用事件,用于同行会员搜索
*@params object,值,颜色值
**/
function myThisFocus_tx(obj,color) {
	obj.onblur=function () {
			obj.value='';
			obj.style.color=color;
	}
}

/**
* 提示确认后跳转
* @param str	提示文字
* @param url	跳转链接
* Return String
*/
function ConfirmAndGo(str,url)
{
	if(confirm(str))
	{
		location.href=url;
	}
}

/**
* 调用广告
* @params place,width,height
* @returns 广告
**/
function GetAd(p,w,h,div) {
	if (w!='' && h!='' && p!='') {
		jQuery.ajax({
			url:'/jQueryGetData.php?Action=GetAd&from=Ad&w='+w+'&h='+h+'&p='+p+'',
			cache:true,
			success:function(Data) {
				jQuery(Data).appendTo('#'+div);
			}
		})
	}
}

/**
* 获取服务器端日期
* @returns yyyy-mm-dd|yyyy-mm-dd+2
**/
function myGetDate() {
	return jQuery.ajax({url:'/jQueryGetData.php?Action=GetThisDate',async:false,cache:true}).responseText;
}

/**
*礼品兑换是否已经登录
**/

function exchange() {
	if (G('isLogin').value=='') {
		return myconfirm('您还没有登录,是否登录?');
	}
}

/*
*对话框弹出
**/
function sAlert(str,strtitle,w,h){
   var msgw,msgh,bordercolor;
   msgw=w;//提示窗口的宽度
   msgh=h;//提示窗口的高度
   titleheight=25 //提示窗口标题高度
   bordercolor="#336699";//提示窗口的边框颜色
   titlecolor="#99CCFF";//提示窗口的标题颜色
   var sWidth,sHeight,w1,h1;
   sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
   sHeight=document.body.offsetHeight;//屏幕高度(垂直分辨率)
	w1=w/2;
	h1=(screen.height-h)/2;

   //背景层(大小与窗口有效区域相同,即当弹出对话框时,背景显示为放射状透明灰色)
   var bgObj=document.createElement("div");//创建一个div对象(背景层)
   //定义div属性,即相当于
   //<div id="bgDiv" style="position:absolute; top:0; background-color:#777; filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75); opacity:0.6; left:0; width:918px; height:768px; z-index:10000;"></div>
   bgObj.setAttribute('id','bgDiv');
   bgObj.style.position="absolute";
   bgObj.style.top="0";
   bgObj.style.background="#777";
   bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
   bgObj.style.opacity="0.6";
   bgObj.style.left="0";
   bgObj.style.width=sWidth + "px";
   bgObj.style.height=sHeight + "px";
   bgObj.style.zIndex = "10000";
   document.body.appendChild(bgObj);//在body内添加该div对象

  var msgObj2=document.createElement("iframe")//创建一个iframe对象(提示框层)
   //定义div属性,即相当于
   //<div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;"></div>
   msgObj2.setAttribute("id","objif");
   msgObj2.setAttribute("align","center");
   msgObj2.style.background="white";
   msgObj2.style.border="1px solid " + bordercolor;
   msgObj2.style.position = "absolute";
   msgObj2.style.left = "50%";
   msgObj2.style.top = h1+"px";
   msgObj2.style.marginLeft = "-"+w1+"px";
   msgObj2.style.marginTop = -75+document.documentElement.scrollTop+"px";
   msgObj2.style.width = msgw + "px";
   msgObj2.style.height =msgh + "px";
   msgObj2.style.zIndex = "10001";


   var msgObj=document.createElement("div")//创建一个div对象(提示框层)
   //定义div属性,即相当于
   //<div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;"></div>
   msgObj.setAttribute("id","msgDiv");
   msgObj.setAttribute("align","center");
   msgObj.style.background="white";
   msgObj.style.border="1px solid " + bordercolor;
   msgObj.style.position = "absolute";
   msgObj.style.left = "50%";
   msgObj.style.top = h1+"px";
   msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
   msgObj.style.marginLeft =  "-"+w1+"px" ;
   msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
   msgObj.style.width = msgw + "px";
   msgObj.style.height =msgh + "px";
   msgObj.style.textAlign = "center";
   msgObj.style.lineHeight ="25px";
   msgObj.style.zIndex = "10001";

   var title=document.createElement("div");//创建一个h4对象(提示框标题栏)
   //定义h4的属性,即相当于
   //<h4 id="msgTitle" align="right" style="margin:0; padding:3px; background-color:#336699; filter:progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100); opacity:0.75; border:1px solid #336699; height:18px; font:12px Verdana,Geneva,Arial,Helvetica,sans-serif; color:white; cursor:pointer;" onclick="">关闭</h4>
   title.setAttribute("id","msgTitle");
   title.setAttribute("align","left");
   title.style.margin="0";
   title.style.padding="3px";
   title.style.background=bordercolor;
   title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
   title.style.opacity="0.75";
   title.style.border="1px solid " + bordercolor;
   title.style.height="18px";
   title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
   title.style.color="white";
   title.style.cursor="pointer";
   title.innerHTML=strtitle;
   title.style.position="relative";
   title.style.float="right";
   title.onclick=removeObj;


   var button=document.createElement("input");//创建一个input对象(提示框按钮)
   //定义input的属性,即相当于
   //<input type="button" align="center" style="width:100px; align:center; margin-left:250px; margin-bottom:10px;" value="关闭">
   button.setAttribute("type","button");
   button.setAttribute("value","关闭");
   button.style.width="60px";
   button.style.align="center";
   button.style.marginLeft=w/2+"px";
   button.style.marginTop="-20px";
   button.style.background=bordercolor;
   button.style.border="1px solid "+ bordercolor;
   button.style.color="white";
   button.onclick=removeObj;

   function removeObj(){//点击标题栏触发的事件
   	 document.body.removeChild(msgObj2);
     document.body.removeChild(bgObj);//删除背景层Div
     document.getElementById("msgDiv").removeChild(title);//删除提示框的标题栏
     document.body.removeChild(msgObj);//删除提示框层
   }
   document.body.appendChild(msgObj2);//在body内添加提示框iframe对象msgObj2
   document.body.appendChild(msgObj);//在body内添加提示框div对象msgObj
   document.getElementById("msgDiv").appendChild(title);//在提示框div中添加标题栏对象title
   var txt=document.createElement("p");//创建一个p对象(提示框提示信息)
   //定义p的属性,即相当于
   //<p style="margin:1em 0;" id="msgTxt">测试效果</p>
   txt.style.margin="1em 0"
   txt.setAttribute("id","msgTxt");
   txt.innerHTML=str;//来源于函数调用时的参数值
   document.getElementById("msgDiv").appendChild(txt);//在提示框div中添加提示信息对象txt
   document.getElementById("msgDiv").appendChild(button);//在提示框div中添加按钮对象button
}


/*
*对话框弹出
**/
function lAlert(str,strtitle,w,h){
   var msgw,msgh,bordercolor;
   msgw=w;//提示窗口的宽度
   msgh=h;//提示窗口的高度
   titleheight=25 //提示窗口标题高度
   bordercolor="#336699";//提示窗口的边框颜色
   titlecolor="#99CCFF";//提示窗口的标题颜色
   var sWidth,sHeight;
   sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
   sHeight=screen.height;//屏幕高度(垂直分辨率)
   lTop=Math.ceil(sWidth/2-w/2);
   lLeft=Math.ceil(sHeight/2-h/2);

   //背景层(大小与窗口有效区域相同,即当弹出对话框时,背景显示为放射状透明灰色)
   var bgObj=document.createElement("div");//创建一个div对象(背景层)
   //定义div属性,即相当于
   //<div id="bgDiv" style="position:absolute; top:0; background-color:#777; filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75); opacity:0.6; left:0; width:918px; height:768px; z-index:10000;"></div>
   bgObj.setAttribute('id','bgDiv');
   bgObj.style.position="absolute";
   bgObj.style.top="0";
   bgObj.style.background="#777";
   bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
   bgObj.style.opacity="0.6";
   bgObj.style.left="0";
   bgObj.style.width=sWidth + "px";
   bgObj.style.height=sHeight + "px";
   bgObj.style.zIndex = "10000";
   document.body.appendChild(bgObj);//在body内添加该div对象

  var ifrOut=document.createElement("iframe");
  ifrOut.setAttribute('id','Outside');
  ifrOut.style.position="absolute";
  ifrOut.style.left=lLeft;
  ifrOut.style.top="200px";
  ifrOut.style.width=w+"px";
  ifrOut.style.height=h+"px";
  ifrOut.style.backgroundColor="#FFFFFF";
  ifrOut.style.borderWidth="1px";
  ifrOut.style.borderStyle="solid ";
  ifrOut.style.borderColor="#1570b7";
  ifrOut.style.zIndex = "10000";

  var divOut=document.createElement("div");
  divOut.setAttribute('id','Outside');
  divOut.style.position="absolute";
  divOut.style.left=lLeft;
  divOut.style.top="200px";
  divOut.style.width=w+"px";
  divOut.style.height=h+"px";
  divOut.style.backgroundColor="#FFFFFF";
  divOut.style.borderWidth="1px";
  divOut.style.borderStyle="solid ";
  divOut.style.borderColor="#1570b7";
  divOut.style.zIndex = "10001";

  var div1=document.createElement("div");
  div1.setAttribute("id","lalertTitle");
  div1.style.height="23px";
  div1.style.background="#1570b7";
  div1.style.lineHeight="23px";
  div1.style.margin="0px";
  div1.style.textAlign="left";

  var span1=document.createElement("span");
  span1.setAttribute("id","txt1");
  span1.style.fontWeight="bold";
  span1.style.color="#FFFFFF";
  span1.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
  span1.style.paddingLeft="6px";

  var Content1=document.createElement("div");
  Content1.setAttribute("id","lcontent");


  var span2=document.createElement("span");
  span2.setAttribute("id","lspan2");
  span2.style.display="block";
  span2.style.margin="6px";
  span2.style.fontSize="12px";
  span2.style.lineHeight="20px";
  span2.style.textAlign="left";
  //span2.style.textIndent="1.5em";

  var div3=document.createElement("div");
  div3.setAttribute("id","lshut");
  div3.style.height="20px";
  div3.style.lineHeight="20px";
  div3.style.width=w+"px";
  div3.style.textAlign="center";

  var button=document.createElement("input");//创建一个input对象(提示框按钮)
   //定义input的属性,即相当于
   //<input type="button" align="center" style="width:100px; align:center; margin-left:250px; margin-bottom:10px;" value="关闭">
    button.setAttribute("type","button");
   button.setAttribute("value","关闭");
   button.style.width="60px";
   button.style.align="center";
  button.style.marginBottom="10px";
   button.style.background=bordercolor;
  button.style.border="1px solid "+ bordercolor;
   button.style.color="white";
   button.onclick=removeObj;

  function removeObj()
  {
	  	document.body.removeChild(ifrOut);
	  	document.body.removeChild(divOut);
		document.body.removeChild(bgObj);
  }
  document.body.appendChild(divOut);	//外层div
  document.body.appendChild(ifrOut);	//iframe
  document.getElementById("Outside").appendChild(div1);		//标题div
  document.getElementById("lalertTitle").appendChild(span1);		//标题文字span
  document.getElementById("Outside").appendChild(Content1);		//内容
  document.getElementById("lcontent").appendChild(span2);		//文字内容
  document.getElementById("Outside").appendChild(div3);		//关闭按钮所在div
  document.getElementById("lshut").appendChild(button);
  span1.innerHTML=strtitle+"<span style='float;left; width:10px; margin-left:270px;'><a href='javascript:void(0);' style=' color:#ffffff;font-size:12px;'>关闭</a></span>";
  span2.innerHTML=str;
}

/* 输出iframe */
function writeifr(ifrName) {
	document.write('<iframe id="'+ifrName+'" name="'+ifrName+'" style="position:absolute;top:0px;left:0px;display:none; border:solid 0px #000000; width:;" frameborder="0" scrolling="no"></iframe>');
}

/*
* 判断字符串str1是否存在于str中
* @param str1	待判断字符串
* @param str	原字符串
* Return String
*/
function isIn(str1,str)
{

	var len1;
	len1=str.length;
	str=str.replace(str1,"");
	len2=str.length;
	if(len1==len2)
	{
		return false;
	}
	else
	{
		return true;
	}
}

/**
* 在指定坐标显示div
* @param divid	显示对象的id
* @param top	显示对象的上边距
* @param left	显示对象的左边距
* Return Void
* sample
<div style=" position:relative; left:200px;width:200px" id="test" style="background-color:#FF0000" onmousemove="showdivabs('testh',(this.offsetTop+this.offsetHeight),this.offsetLeft)" onmouseout="hiddiv('testh')">
显示层
</div>
<div id="testh" style="position:absolute;display:none; background:#999999">隐藏内容</div>
*/
function showdivabs(divid,top,left)
{
	document.getElementById(divid).style.position='absolute';
	document.getElementById(divid).style.top=top;
	document.getElementById(divid).style.left=left;
	document.getElementById(divid).style.display='';
}

/**
* 替换全部字符串
* @param str1	新字符串
* @param str2	被替换字符串
* @param str	输入字符串
*/
function replaceAll(str1,str2,str)
{
	if(str1==str2)
	{
		return false;
	}
	while(str.indexOf(str1)>0)
	{
		str=str.replace(str1,str2);
	}
	return str;
}
//评论,有用 评论ID
function Pl_Ajax_Y(pid,divname,dj)
{

$j.get("/cevin_uu8/menpiao/Pl_Ajax.php?aa="+Math.random(10),{send:2,act:1,pid:pid},function(data){if(data!=''){
  	str=data;
	str=str.split('|');
	//alert(str[1]);
	alert(str[0]);
	editdiv(divname,"("+str[1]+"人)");
	//editdiv(spanname,"(<font color=red>"+data+"</font>)");
   }
   }
   );
}
//评论没有用pid 评论ID
function Pl_Ajax_M(pid,divname,dj)
{
	$j.get("/cevin_uu8/menpiao/Pl_Ajax.php",{send:2,act:2,pid:pid,dj:dj},function(data){if(data!=''){
    arry=data;
 	str=arry.split('@');
    alert(str[0]);
  	editdiv(divname,"("+str[1]+"人)");
   }
   }
   );
}
/*
*顶一下,不理踩返回数字
*
*/
function M_act(divname,n,pid){

	$j.get("/cevin_uu8/menpiao/PlS.php?a="+Math.random(10),{act:n,pid:pid},function(data){if(data!=''){
	//alert(Math.random(10));
	editdiv(divname,"("+data+"人)");

   }
   }
  );
}
/*
验证手机号
*/
function isMobile(mobile){
	reg = /^13|5|8\d{9}$/;
	if(reg.test(mobile)){
		return true;
	}
	else{
		return false;
	}
}
/*
验证身份证
*/
function checkIDNumber(id){
	id_length = id.length;
	num = id_length;
	if (id_length!=15 && id_length!=18){
		alert("身份证号长度应为15位或18位!");
		return false;
	}
	if (id_length==15){
		yyyy="19"+id.substring(6,8);
		mm=id.substring(8,10);
		dd=id.substring(10,12);

		if (mm>12 || mm<=0){
			alert("输入身份证号,月份非法!");
			return false;
		}

		if (dd>31 || dd<=0){
			alert("输入身份证号,日期非法!");
			return false;
		}

	}else if (id_length==18){
		if (id.indexOf("X") > 0 && id.indexOf("X")!=17 || id.indexOf("x")>0 && id.indexOf("x")!=17){
			alert("身份证中\"X\"输入位置不正确!");
			return false;
		}

		yyyy=id.substring(6,10);
		if (yyyy>2200 || yyyy<1900){
			alert("输入身份证号,年度非法!");
			return false;
		}

		mm=id.substring(10,12);
		if (mm>12 || mm<=0){
			alert("输入身份证号,月份非法!");
			return false;
		}

		dd=id.substring(12,14);
		if (dd>31 || dd<=0){
			alert("输入身份证号,日期非法!");
			return false;
		}

		if (id.charAt(17)=="x" || id.charAt(17)=="X")
		{
			if ("x"!=GetVerifyBit(id,num) && "X"!=GetVerifyBit(id)){
				alert("身份证校验错误,请检查最后一位!");
				return false;
			}

		}else{
			if (id.charAt(17)!=GetVerifyBit(id,num)){
				alert("身份证校验错误,请检查最后一位!");
				return false;
			}
		}
	}
	return true;
}

function GetVerifyBit(id,num){
	var result;
	var nNum=eval(id.charAt(0)*7+id.charAt(1)*9+id.charAt(2)*10+id.charAt(3)*5+id.charAt(4)*8+id.charAt(5)*4+id.charAt(6)*2+id.charAt(7)*1+id.charAt(8)*6+id.charAt(9)*3+id.charAt(10)*7+id.charAt(11)*9+id.charAt(12)*10+id.charAt(13)*5+id.charAt(14)*8+id.charAt(15)*4+id.charAt(16)*2);
	nNum=nNum%11;
	switch (nNum) {
	   case 0 :
		  result="1";
		  break;
	   case 1 :
		  result="0";
		  break;
	   case 2 :
		  result="X";
		  break;
	   case 3 :
		  result="9";
		  break;
	   case 4 :
		  result="8";
		  break;
	   case 5 :
		  result="7";
		  break;
	   case 6 :
		  result="6";
		  break;
	   case 7 :
		  result="5";
		  break;
	   case 8 :
		  result="4";
		  break;
	   case 9 :
		  result="3";
		  break;
	   case 10 :
		  result="2";
		  break;
	}
	//document.write(result);
	return result;
}
//景点评论分页
function NextPage(PageNum,content_id){
	//alert(PageNum);
$j.get("/cevin_uu8/menpiao/Pl_Ajax.php?aa="+Math.random(10),{PageNum:PageNum,content_id:content_id},function(data){if(data!=''){
  	str=data;
	//alert(str);
	editdiv("pl0",str);
	//editdiv(spanname,"(<font color=red>"+data+"</font>)");
  }
   }
  );

}
//注册页面,t=1为显示 t=0为隐藏
function jppla(t,divname){
	if(t==0){
		G(divname).style.display="none";
	}
	if(t==1){
		G(divname).style.display="";
	}
}
function disel(idname){                                                                         
	nex=G(idname);
	if(nex.disabled==true){
		nex.disabled=false;
	}else{
		nex.disabled=true;	
	}
}