常用Js JavaScrript Tjquery Class

来源:互联网 发布:bdp商业数据平台 编辑:程序博客网 时间:2024/06/14 12:15
/** * CreateDate 2011-8-23 22:49:44 * * Description of Tjquery * * @author tanyong *//////////////////////////////////////////////////////////////////////////** *当bug=true 时开启调试 *bug=false 时关闭调试 */var bug//=true;window.onerror=function (msg,url,line){        if(bug){                txt=String.fromCharCode(24320,21457,32773,21644,31649,29702,21592,27880,24847)+"\r\n\n\n"                txt+=String.fromCharCode(26412,39029,20013,23384,22312,38169,35823)+"\u3002\r\n\n"                txt+="\u9519误:" + msg + "\r\n\n"                txt+="URL: " + url + "\r\n\n"                txt+="\u884c:" + line + "\r\n\n"                txt+="\u70b9击\"确定\"继续。\r\n\n"                txt+="*\u5f53bug=true 时开启\u8c03\u8bd5\r\n\n\n";                txt+="*bug=false \u65f6关闭调\u8bd5\r\n"                alert(txt)                return true;        }else{                return false;        }       }/** *建立选择器 *获取对象Id 节点 *@param objectId 对象名称 *@return objectId *@type String */var getid=function (objectId){        if(document.getElementById && document.getElementById(objectId)) {                // W3C DOM                return document.getElementById(objectId);        } else if (document.layers && document.layers[objectId]) {                // NN 4 DOM.. note: this won't find nested layers                return document.layers[objectId];        }else if (document.all && document.all(objectId)) {                // MSIE 4 DOM                return document.all(objectId);        } else if(eval(objectId)){                return eval(objectId);        }        else{                return false;        }};/** *获取对象名称 *@param name 对象名称 *@return tag *@type String */var getname=function (name){        return document.getElementsByName(name);};/** *获取标签名称 *@param tag 标签名称 *@return tag *@type String */var gettag=function (tag){        return document.getElementsByTagName(tag);};/** *返回 或者设置 对象样式 *  @param id 字段名称 * @return value * @type String , obejct */function Css(id){        return getid(id).style;}/** *页面加载完毕执行代码 * onload后 同时执行多个函数 * 默认只能执行一个 * @example onloadReady(function (){ *  insert somecode; *   }) * @param fnct 参数 可以在里面传递 function * @return Not return ; * @type eventElement */function onloadReady(fnct){        if(typeof window.addEventListener != "undefined" ){                window.addEventListener("load",fnct,false);        }else{                if(typeof window.attachEvent != "undefined"){                        window.attachEvent("onload", fnct);                }else{                        if(window.onload != null){                                var oldOnload = window.onload;                                window.onload = function (e){                                        oldOnload(e); window[fnct]();                                };                        }else{                                window.onload = fnc;                        }                }        }}/** *判断浏览器 *@return Bool  false  ture *@type Obejct */var Browser = new Object();/** *判断isMozilla *@return Bool  false  ture */Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');/** *判断 ie *@return Bool  false  ture */Browser.isIE = window.ActiveXObject ? true : false;/** *判断火狐 *@return Bool  false  ture */Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);/** *判断苹果 *@return Bool  false  ture */Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari")!=-1);/** *判断opera *@return Bool  false  ture */Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);/* *@name Tjquery class *该类包含所有常规操作 *表单操作 鼠标 对象位置 对象拉对 *@type Object */var Tjquery={        //表单操作        /**         * 获取某表单内多个文本框的值         * @param frmname 表单名称         * @param name  字段名称         * @return array         * @type Array         */        getValues:function(frmname, name){                var form = document.forms[frmname];                var eles = form[name];                var values = new Array();                var index = -1;                for(var i=0; i<eles.length;i++){                        if(eles[i].type=="checkbox" || eles[i].type=="radio"){                                if(eles[i].checked){                                        index++;                                        values[index] = eles[i].value;                                }                        }else{                                index++;                                values[index] = eles[i].value;                        }                }                return values;        }  ,        /*         *获取单选框的值 没有选中返回null         * @param frmname 表单名称         * @param name  字段名称         * @return array         * @type Array         */        getRadioValue:function(frmname, name){                var form = document.forms[frmname];                var eles = form[name];                var value = null;                for(var i=0; i<eles.length;i++){                        if(eles[i].checked) value = eles[i].value;                }                return value;        } ,        /**         *全选         * @param frmname 表单名称         * @param name  字段名称         * @return array         * @type Array         */        CheckAll:function(frmname, name){                var form = document.forms[frmname];                var eles = form[name];                for(var i=0; i<eles.length; i++){                        if(eles[i].name != "checkAll" && eles[i].disabled != true) eles[i].checked = form.checkAll.checked;                }        }  ,        /**         *反选         * @param frmname 表单名称         * @param name  字段名称         * @return array         * @type Array         */        reCheck:function(frmname, name){                var form = document.forms[frmname];                var eles = form[name];                for(var i=0; i<eles.length; i++){                        eles[i].checked = !eles[i].checked;                }        }  ,        /**         *获取文件扩展名         *@param fileName         *@type String         *@return String         */        getFileExt:function(fileName){                var temp = fileName.split(".");                var fileExt = temp[temp.length-1].toLowerCase();                return fileExt;        },        /**         *创建节点         *@param  tagName 标签名         *@return HtmltagNameElement         *@type Object         */        CreateElement:function (tagName){                return  document.createElement(tagName)        },        /**         *添加节点         *@param  Element 父节点 当为空时 默认为body         *@param AddElement         *@return Element         *@type Object         */        appendChild:function (AddElement,Element){                Element= Element?getid(Element).appendChild(AddElement):gettag("body")[0].appendChild(AddElement);                return Element;        },        /**         *移除节点         *@param  htmlElement 父节点 当为空时 默认为body         *@param  oldChild         *@return htmlElement         *@type Object         */        removeChild:function (oldChild,htmlElement){                htmlElement= htmlElement?getid(htmlElement).removeChild(getid(oldChild)):gettag("body")[0].removeChild(getid(oldChild))                return htmlElement;        },        //常规操作        /**         *写cookie         *@param name cookie名称         *@param value cookie 值         *@param hours 时间         *@type String  cookie         *@return cookie.toString;         */        writeCookie:function (name, value, hours){                var expire = "";                if(hours != null){                        expire = new Date((new Date()).getTime() + hours * 3600000);                        expire = "; expires=" + expire.toGMTString();                }                document.cookie = name + "=" + escape(value) + expire;        },        /**         *读取cookie         *@param name cookie 名称         *@return String cookieValue;         *@type String          */        readCookie:function (name){                var cookieValue = "";                var search = name + "=";                if(document.cookie.length > 0){                        offset = document.cookie.indexOf(search);                        if (offset != -1){                                offset += search.length;                                end = document.cookie.indexOf(";", offset);                                if (end == -1) end = document.cookie.length;                                cookieValue = unescape(document.cookie.substring(offset, end))                        }                }                return cookieValue;        }, ///删除Cookie ///*@param name cookie 名称     delCookie:function(name) {  var expires = new Date();    expires.setTime(expires.getTime()-1);   document.cookie = name + "=" + getCookie(name) + ";expires= " + expires.toGMTString();  },        /**         *显示隐藏某对象(层)         *@param id 对象的id         *@param  value 属性值 常用的有: none 为不显示 ,block 为块状显示 ,"" 显示         *@return value;  *@type function          */        showhide:function (id,value){                if(Tjquery.findObj(id)){                      return getid(id).style.display=value                }        },        /**         *查找对象可以替换该文档中的getid ,或者document.getElementById(id);         *如果对象不存在 返回 bool false         *@param theObj 对象的id         *@param theDoc 默认是window.document || document         *@return String HtmlElement || bool         *@type String HtmlElement         */        findObj:function (theObj, theDoc){                var p, i, foundObj;                if(!theDoc) theDoc = document || window.document;                if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){                        theDoc = parent.frames[theObj.substring(p+1)].document;                        theObj = theObj.substring(0,p);                }                if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];                for (i=0; !foundObj && i < theDoc.forms.length; i++)                        foundObj = theDoc.forms[i][theObj];                for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)                        foundObj = findObj(theObj,theDoc.layers[i].document);                if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);                return foundObj;        },        /**         *获取客户端时间         *@return Array         *@type Array         */        gettime:function (){                var time=new Date();                return [time.getFullYear(),time.getMonth(),time.getDate(),time.getHours(),time.getMinutes(),time.getSeconds()]        },        /**         *获取窗口的长宽         *@return [myW, myH];         *@type Array         */        getwinWH:function(){                var myW = 0, myH = 0;                if(typeof window.innerHeight != "undefined"){                        //Non-IE                        myW = window.innerWidth;                        myH = window.innerHeight;                }else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){                        //IE 6+                        myW = document.documentElement.clientWidth;                        myH = document.documentElement.clientHeight;                }else if(document.body && (document.body.clientWidth || document.body.clientHeight)){                        //IE 4                        myW = document.body.clientWidth;                        myH = document.body.clientHeight;                }                return [myW, myH];          } ,        /**         *获取滚动条scroller偏移量         *@return [myW, myH];         *@type Array         */            getScrollXY:function(){                var myX = 0, myY = 0;                if(typeof window.pageYOffset != "undefined"){                        //Netscape compliant                        myX = window.pageXOffset;                        myY = window.pageYOffset;                }else if( document.body && (document.body.scrollLeft || document.body.scrollTop)){                        //DOM compliant                        myX = document.body.scrollLeft;                        myY = document.body.scrollTop;                }else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){                        //IE6 standards compliant mode                        myX = document.documentElement.scrollLeft;                        myY = document.documentElement.scrollTop;                }                return [myX, myY];        },        /**         *获取鼠标位置         *@param Event 鼠标事件 默认当函数作为变量 或者事件时 可以不需要  Event=window.event || Event; //兼容性 针对非IE         *@return [MouseX,MouseY]         *@type Array         */           getmouseXY:function(Event){                //Event=window.event || Event;                var ScrollXY,MouseX,MouseY;                ScrollXY = Tjquery.getScrollXY();                if(document.all){                        MouseX = parseInt(ScrollXY[0]) + event.clientX; MouseY = parseInt(ScrollXY[1]) + event.clientY;                }else{                        MouseX = Event.pageX; MouseY = Event.pageY;                }                return [MouseX,MouseY];        } ,        /**         *获取对象坐标         *@param id 对象Id           *@return [ObjX, ObjY]         *@type Array         */           getObjectXY:function(id){                var ScrollXY,ObjX,ObjY;                if(getid(id))id = getid(id);                ScrollXY = Tjquery.getScrollXY();                if(document.all || window.ActiveXObject){  //死ie                        ObjX = parseInt(ScrollXY[0]) + id.offsetLeft; ObjY = parseInt(ScrollXY[1]) + id.offsetTop;                }else{                        ObjX = id.offsetLeft; ObjY = id.offsetTop;                }                return [ObjX, ObjY];        }   ,        /**         *图层数字定位         *定位数字层 num 图层 img;         *@param num 需要定位的层         *@param img 从跌的层         *@return  left,top         *@type function or Array[value]         */        imgNum:function (num,img){                function numxy(){                        //var imgx=Tjquery.getObjectXY(img)[0];                        //var imgy=Tjquery.getObjectXY(img)[1];                        var endx=parseInt(getid(img).style.width)-parseInt(getid(num).style.width);                        var endy=parseInt(getid(img).style.height)-parseInt(getid(num).style.height);                        getid(num).style.position="absolute";                        getid(num).style.zIndex="999";                        getid(num).style.left=getid(img).offsetLeft+endx+"px";                        getid(num).style.top=getid(img).offsetTop+endy+"px";                        //getid(num).style.left=imgx+"px";                        //getid(num).style.top=imgy+"px";                        //getid(num).style.left=imgx+(getid(img).clientWidth-getid(num).clientWidth)+"px";                        //getid(num).style.top=parseInt(imgy-(getid(img).clientHeight-getid(num).clientHeight))+"px";//得出来是负数 哥给陈一                        window.onload=window.onresize=numxy;                //setTimeout("Tjquery.imgNum()",100);                }                numxy();                return [getid(num).style.left,getid(num).style.top];        },        /**         *获取对象宽高 及 父级名称         *@param id 对象的id         *@return [id.offsetWidth, id.offsetHeight, id.offsetParent.nodeName];         *@type Array         */        /*getObjectWHN:function(id){                if(getid(id))id = getid(id);                return [id.offsetWidth, id.offsetHeight, id.offsetParent.nodeName];        },*/        /**         *拖动对象         *@example Tjquery.moveElement("span","div");         *@param handler 鼠标层         *@param movediv 移动层         *@param cursor 鼠标样式         *@return null         *@type function          */        moveElement:function (handler, movediv, cursor) { // 注册鼠标移动的一些事件。                var isclick = false;                var clickleft = 0;                var clicktop = 0;                var target =getid(handler);                movediv =getid(movediv);                movediv.style.position="absolute";                target.style.cursor = cursor || "move";                function clickdrop(e) { // 按下鼠标左键时的事件。                        e = window.event || e;  // 获取当前事件对象。                        isclick = true;  // 记录已经准备开始移动了。                        movediv.style.left=movediv.style.left?movediv.style.left:1+"px";                        movediv.style.top=movediv.style.top?movediv.style.top:1+"px";                        //alert(parseInt(movediv.style.left))                        clickleft = Tjquery.getmouseXY()[0] - parseInt(movediv.style.left); // 记录当前坐标轴。                        clicktop = Tjquery.getmouseXY()[1] - parseInt(movediv.style.top);                //alert(parseInt(movediv.style.top));                }                function startdrop(e) { // 鼠标开始移动时的事件。                        e = window.event || e; // 获取当前事件对象。                        if (!isclick) return false; // 如果isclick不等于真了返回。                        movediv.style.left = (parseInt((e.clientX+Tjquery.getScrollXY()[0])-clickleft))  + "px"; // 把鼠标当前移动的位置赋值给div - clickleft                        movediv.style.top = (parseInt((e.clientY+Tjquery.getScrollXY()[1])-clicktop)) + "px"; // 当前位置减去开始位置就是层当前存放的位置。- clicktop                //if(Browser.isIE){window.status="移动中:  坐标X  "+movediv.style.left+" ,坐标Y  "+movediv.style.top;};                //document.title= movediv.style.left+" , "+movediv.style.top;                }                function endrop() { // 释放鼠标左键时的事件。                        if (isclick) { // 如果isclick还为真那么就赋值为假。                                if (Browser.isIE) movediv.releaseCapture(); //该函数从当前的窗口释放鼠标捕获,并恢复通常的鼠标输入处理。                                isclick = false;                                document.documentElement.onmousemove = null;                        //document.title=null || "";                        //if(Browser.isIE){window.status=null || ""};                        }                }                target.onmouseover= clickdrop;                target.onmousedown = clickdrop; // 鼠标按下事件。                document.onmouseup = endrop;  // 鼠标释放事件。                document.onmousemove = startdrop; // 鼠标移动事件。                document.body.onscroll= startdrop;        // movediv.onselectstart = movediv.oncontextmenu = function () { return false; }; // 禁止选择和右键菜单。        } , /** *鼠标提示效果  非mouse  Client 使用对象坐标 *@param altdiv  透水层  *@param Elementdiv 事件层 */ /*Mousealt:function (altdiv,Elementdiv){  Css(altdiv).top=(parseInt(Tjquery.imgNum(altdiv,Elementdiv)[1])-30)+"px";//这里只需要一次top 或者left 就可以完成  Css(altdiv).left=parseInt(Css("div1").left)+getid(Elementdiv).offsetWidth/2+"px"  //这里是可选的 让其在事件对象的上面 居中  },*/         /**         *居中某个对象          *@param id 对象id  *@param overflow  当为true时 隐藏body的滚动条         *@return null         *@type function          */             setCenter:function(id,overflow){                if(Tjquery.findObj(id)){                        var innerwh = Tjquery.getwinWH();                        var offxy = Tjquery.getScrollXY();   overflow==true?document.body.style.overflow="hidden":document.body.style.overflow="auto";                        if(Browser.isIE){ //IE                                if(getid(id)){                                        getid(id).style.top = ((innerwh[1]-getid(id).clientHeight)/2 + offxy[1])+"px";                                        getid(id).style.left = ((innerwh[0]-getid(id).clientWidth)/2 + offxy[0])+"px";                                }else{                                        id.style.top = ((innerwh[1]-id.clientHeight)/2 + offxy[1])+"px";                                        id.style.left = ((innerwh[0]-id.clientWidth)/2 + offxy[0])+"px";                                }                        }else{                                if(getid(id)){                                        getid(id).style.top = ((innerwh[1]-getid(id).clientHeight)/2)+"px";                                        getid(id).style.left = ((innerwh[0]-getid(id).clientWidth)/2)+"px";                                }else{                                        id.style.top = ((innerwh[1]-id.clientHeight)/2)+"px";                                        id.style.left = ((innerwh[0]-id.clientWidth)/2)+"px";                                }                        }                }                window.onresize=function (){                        Tjquery.setCenter(id);                };  return [getid(id).style.left,getid(id).style.top];        } ,        /**         *透明某个对象         *@param id 对象id         *@param num 数值         *@return  null         *@type function          */             setAlpha:function(id,num){                if(Tjquery.findObj(id)){                        if(Browser.isIE){ //IE                                if(getid(id)){                                        getid(id).style.filter = "alpha(opacity="+num+")";                                }else{                                        id.style.filter = "alpha(opacity="+num+")";                                }                        }else{                                if(getid(id)){                                        getid(id).style.opacity = parseInt(num)/100;                                }else{                                        id.style.opacity = parseInt(num)/100;                                }                        }                }        },        /**         *赋值操作         *@param id 对象的id         *@param value 属性值  String         *@return         *@type         */           /*     setValue:function(id,value){                value=value || getid(id).innerHTML;                if(Tjquery.findObj(id)){                        if(getid(id)){                                getid(id).innerHTML = value;                        }else{                                id.innerHTML = value;                        }                }                return getid(id).innerHTML        },*/        /**         *刷新页面         */        Reload:function(){                window.location.reload();        },        /**         *获取当前页地址栏地址         */        Location:function(){                return window.location;        },        /**         *加入收藏夹         */        addFavorite:function (title,url){                if(!url)url = Tjquery.Location();                if(Browser.isIE){                        window.external.addFavorite(url,title);                }else if(Browser.isFirefox){                        window.sidebar.addPanel(title,url,'');                }else return true;        },        /**         *设为主页         */             setHomepage:function(url){                if(!url)url = Tjquery.Location();                if(Browser.isIE){                        document.body.style.behavior="url(#default#homepage)";                        document.body.setHomePage(url);                }else if(Browser.isFirefox){                        if(window.netscape){                                try{                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); //解决执行命令的问题                                        alert("设置成功");                                }catch(e){                                        alert(NoAgreeText);                                        return false;                                }                        }                        var Prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components. interfaces.nsIPrefBranch);                        Prefs.setCharPref("browser.startup.homepage",url);                }                return true;        },        /**         *复制内容         */           CopyText:function(text){                if(Browser.isIE){                        //if(window.clipboardData){                        window.clipboardData.clearData();                        window.clipboardData.setData("Text", text); alert("\u590d制\u6210功");                }else if(Browser.isFirefox){                        if(window.netscape){                                try{                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); //解决执行命令的问题                                        alert("\u590d制成功");                                }catch(e){                                        alert("\u7531于浏览器安全设置因素,\u590d制失败");                                        return false;                                }                        }                        var Clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);                        if(!Clip) return false;                        var Trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);                        if(!Trans) return false;                        Trans.addDataFlavor('text/unicode');                        var TextStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);                        TextStr.data = text;                        Trans.setTransferData("text/unicode",TextStr,text.length*2);                        var ClipID = Components.interfaces.nsIClipboard;                        Clip.setData(Trans,null,ClipID.kGlobalClipboard);                }                return true;        } ,        /**         *运行代码         */          RunCode:function(id){                var value = "";                if(getid(id)){                        value = getid(id).value;                }else{                        value = id.value;                }                var newWin = window.open("", "_blank", "");                newWin.document.open("text/html", "replace");                newWin.opener = null;                newWin.document.write(value);                newWin.document.close();        } ,        /**         *保存代码         */        SaveCode:function(id){                var value = "";                if(getid(id)){                        value = getid(id).value;                }else{                        value = id.value;                }                var newWin = window.open("", "_blank", "top=10000");                newWin.document.open("text/html", "replace");                newWin.document.write(value);                newWin.document.execCommand("Saveas",false,"code.htm");                newWin.close();        },        init: null ,        /**         *html编码if(Tjquery.findObj(id)){         */        htmlEncode:function(str){                return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/(^\s*)|(\s*$)/g, " ");        },        /**         *去除字符空格         */        strTrim:function(str){                str = str.replace(/(^\s*)|(\s*$)/g, "");                return str;        } ,        /**         *不包含空格的长         */        strLen:function(str){                return str.replace(/[^\x00-\xff]/g, "**").length;        },        /**         *是不是数字         */        isNum:function(val){                var reg = /[\d|\.|,]+/;                return reg.test(val);        },        /**         *透明数值检验         */        isAlphaNum:function (str){                var result=str.match(/^[a-zA-Z0-9]+$/);                if(result==null) return false;                return true;        } ,        /**         *是不是正整数         */        isInt:function(val){                var reg = /\d+/;                return reg.test(val);        }  ,        /**         *email检测         */        "isEMail":function(email){                var reg = /([\w|_|\.|\+]+)@([-|\w]+)\.([A-Za-z]{2,4})/gi;                return reg.test(email);        },        /**         *日期格式检测         */        isDate:function (str){                var result=str.match(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2})$/);                if(result==null) return false;                var d=new Date(result[1], result[3]-1, result[4]);                return (d.getFullYear()==result[1] && d.getMonth()+1==result[3] && d.getDate()==result[4]);        } ,        isDateTime:function(val){                var result=str.match(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);                if(result==null) return false;                var d = new Date(result[1], result[3]-1, result[4], result[5], result[6], result[7]);                return (d.getFullYear()==result[1]&&(d.getMonth()+1)==result[3]&&d.getDate()==result[4]&&d.getHours()==result[5]&&d.getMinutes()==result[6]&&d.getSeconds()==result[7]);        }   ,        /**         *检查表单的一组选项是否已经有一个被选中         *name选项对象name         */        isChecked:function(frmname, name){                var form = document.forms[frmname];                var eles = form[name];                if(typeof(eles.length) == "undefined") return eles.checked;                for(var i=0; i<eles.length; i++){                        if(eles[i].checked) return true;                }                return false;        } ,        /**         *身份证和地区性别的关系         */        IdCardInfo:function (id){                var sum=0; //var info="";                var city={                        11:"\u5317京",                        12:"\u5929津",                        13:"\u6cb3北",                        14:"\u5c71西",                        15:"\u5185蒙古",                        21:"\u8fbd宁",                        22:"\u5409林",                        23:"\u9ed1龙江",                        31:"\u4e0a海",                        32:"\u6c5f苏",                        33:"\u6d59江",                        34:" \u5b89徽",                        35:"\u798f建",                        36:"\u6c5f西",                        37:"\u5c71东",                        41:"\u6cb3南",                        42:"\u6e56北",                        43:"\u6e56南",                        44:"\u5e7f东",                        45:"\u5e7f西",                        46:"\u6d77南",                        50:"\u91cd庆",                        51:"\u56db川",                        52:"\u8d35州",                        53:"\u4e91南",                        54:"\u897f藏",                        61:"\u9655西",                        62:"\u7518肃",                        63:"\u9752海",                        64:"\u5b81夏",                        65:"\u65b0疆",                        71:"\u53f0湾",                        81:"\u9999港",                        82:"\u6fb3门",                        91:"\u56fd外"                };              //  if(!Regexs.idcard.test(id))return false; //非法证号                id=id.replace(/x$/i,"a");                if(city[parseInt(id.substr(0,2))]==null) return false; //非法地区 身份证前俩位是地区                var birthday=id.substr(6,4)+"-"+Number(id.substr(10,2))+"-"+Number(id.substr(12,2));                var d=new Date(birthday.replace(/-/g,"/"));                if(birthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate())) return false; //非法生日                for(var i = 17;i>=0;i --) sum += (Math.pow(2,i) % 11) * parseInt(id.charAt(17 - i),11)                if(sum%11!=1) return false; //非法证号                return [city[parseInt(id.substr(0,2))]+","+birthday+","+(id.substr(16,1)%2?"男":"女")];         } ,        /**         *判断是否登录         */        isLogin:function(name){                var flag=false;                if(getCookie(name) != null) flag=true;                return flag;        }};/** *特效类 sligtools 对象的高 缩手或者趁手;  *@param Element 对象 *@param onEvent  当为false时 递增   默认为false *@param send  时间; 默认100; *//*var sligtools={ reg:function (Element,onEvent,send){  this.Element=Element;  this.send=send || 100;;  this.firstheight=parseInt(Css(Element).height);  this.secendheight=this.firstheight;  //存储 以便恢复;  this.i=1;  this._isClick=onEvent || false;  this.timer=null;  this.sligfun();  }, "sligfun":function (){  css=Css(this.Element);  if(this._isClick==true){   if(this.firstheight<=1){   Tjquery.setAlpha(this.Element,this.firstheight-20)    this.firstheight=this.secendheight;   this.firstheight-=1;   clearTimeout("this.timer");   //this._isClick=false;   css.display="none";    }else{     this.firstheight-=1;     css.height=this.firstheight+"px"     this.timer=setTimeout("sligtools.sligfun()",this.send     );    }   }   if(this._isClick==false){     css.display="block";    if(this.i>=this.firstheight){    this.i=1;    this.i+=1;    clearTimeout("this.timer");    //this._isClick=true;    }else{     Tjquery.setAlpha(this.Element,this.i+20)     this.i+=1;     css.height=this.i+"px"     this.timer=setTimeout("sligtools.sligfun()",this.send);     }      }  }  } */ /** * 透明显示IE中PNG图片 */function CorrectPNG(){        if(Browser.isIE){                for(var i=0; i<document.images.length; i++){                        var img = document.images[i];                        var imgName = img.src.toLowerCase();//imgName.substring(imgName.length-3, imgName.length)                         if(Tjquery.getFileExt(imgName)== "png"){                                var imgID = (img.id) ? "id='" + img.id + "' " : "";                                var imgClass = (img.className) ? "class='" + img.className + "' " : "";                                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";                                var imgStyle = "display:inline-block;" + img.style.cssText;                                if(img.align == "left") imgStyle = "float:left;" + imgStyle;                                if(img.align == "right") imgStyle = "float:right;" + imgStyle;                                if(img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;                                var strNewHTML = "<span " + imgID + imgClass + imgTitle                                + " style=\"" + "width:" + img.width + "px; margin:6px; height:" + img.height + "px;" + imgStyle + ";"                                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"                                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";                                img.outerHTML = strNewHTML;                                i = i-1;                        }                }        }}onloadReady(CorrectPNG);/** * 图片显示效果 */var flag=false;function setPicWH(ImgD,w,h){        var image=new Image();        image.src=ImgD.src;        if(image.width>0 && image.height>0){                flag=true;                if(image.width/image.height>= w/h){                        if(image.width>w){                                ImgD.width=w;                                ImgD.height=(image.height*w)/image.width;                                ImgD.style.display="block";                        }else{                                ImgD.width=image.width;                                ImgD.height=image.height;                                ImgD.style.display="block";                        }                }else{                        if(image.height>h){                                ImgD.height=h;                                ImgD.width=(image.width*h)/image.height;                                ImgD.style.display="block";                        }else{                                ImgD.width=image.width;                                ImgD.height=image.height;                                ImgD.style.display="block";                        }                }        }}/*function slitogo(id,send){ this.send=send; this.slii=1; this.fh=parseInt(Css(id).height); this.fh2=fh; this.timer=null;  }var c=new slitogo()var playup=function (){ slitogo.prototype.playups=function (){  with(this){    } }} slitogos=new slitogo()slitogos*/  //slitogo.prototype.playup= //图像交互工具  模仿flash/*onloadReady(function (){ var slii=1; var fh=parseInt(Css("div").height); var fh2=fh; var timer=null; id="div"; send=10; var image=["../Image1.jpg","../Image2.jpg","../Image3.gif"] var len=image.length; var is=0; getid("bt").onclick=function (){  if(getid("img").src=="http://127.0.0.1/temp/js%20class/undefined"){     is=0; //修正索引     }   if(slii>=fh){   clearTimeout("timer")   slii=1;   slii+=1;   getid("img").src=image[is]   Css("img").display="block";   setTimeout("getid('bt1').onclick()",5000);   }else{Css("div").display="block";    Tjquery.setAlpha("img",slii+5)    slii+=1;    Css(id).height=slii+"px";    timer=setTimeout("getid('bt').onclick()",send);    };    document.title=is+","+getid("img").src;      }; getid("bt1").onclick=function (){    if(fh<=1){   clearTimeout("timer")   fh=fh2;   fh-=1;   is<len?is+=1:is=0;   Css("img").display="none"    Css("div").display="none";   getid("img").src=image[is];   setTimeout("getid('bt').onclick()",50);   }else{    fh-=1;    Tjquery.setAlpha("img",fh-25)    Css(id).height=fh+"px";    timer=setTimeout("getid('bt1').onclick()",send);    };      };  getid('bt').onclick();  }) */


原创粉丝点击