日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

本人寫的一個不錯的js封裝類(有什么不好的地方請?zhí)岢? - xiaofengnet的專欄 ...

 WindySky 2009-07-17

/****************************************************************************************
    作者:蕭 楓
    QQ:77182997
    MSN:xiaofengnet@hotmail.com
    Email:xiaofengnet@163.com
    網(wǎng)址:http://www.
    請保留版權(quán)  謝謝合作
    版本:V3.2
/*****************************************************************************************
*/
/*========================================================================================
  框架核心內(nèi)容--------【基礎(chǔ)工具類】
  ========================================================================================
*/

/*========================================================================================
【獲取一個指定ID的結(jié)點(diǎn)】
創(chuàng)建于[2005-05-03]
document.getElementById(Id)獲取一個指定ID的結(jié)點(diǎn),是這個方法的快捷方式和擴(kuò)展可以指定多個參
數(shù)返回一個對象數(shù)組。參數(shù)也不一定是ID也可以是對象本身的引用,例如$("id")等價于$($("id"))
*/
function $(){
 var elements = new Array();
 for(var i=0;i<arguments.length;i++){
  var element=arguments[i];
  if (typeof(element) == "string") element=document.getElementById?document.getElementById(element):document.all.element
  if (arguments.length==1) return element;
  elements.push(element);
 }
 return elements;
}
/*========================================================================================
【獲取一個指定ID的結(jié)點(diǎn)】
創(chuàng)建于[2005-05-03]
document.getElementsByName(id)獲取一個指定ID的結(jié)點(diǎn)集,是這個方法的快捷方式和擴(kuò)展可以指定多個參數(shù)返回一個對象數(shù)組
*/
function _$(){
 var elements = new Array();
 for(var i=0;i<arguments.length;i++){
  var element=arguments[i];
  if (typeof(element) == "string") element=document.getElementsByName?document.getElementsByName(element):document.all.element;
  if (arguments.length==1) return element;
  elements.push(element); 
 }
 return elements;
}
/*========================================================================================
【Ajax創(chuàng)建類】
[創(chuàng)建于2008-04-09]
var Http_Request=false;
*/
function CreateAjax(){
 var Ajax_Obj;
 if(typeof(window.XMLHttpRequest)!="undefined"){
  Ajax_Obj = new XMLHttpRequest();
  if(Ajax_Obj.overrideMimeType){
   Ajax_Obj.overrideMimeType("text/html");
  }
 }else if(window.ActiveXObject){
  var Versions=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
  for(var i=0;i<Versions.length;i++){
   try{
    var XmlHttp=new ActiveXObject(Versions[i]);
    Ajax_Obj = XmlHttp;
   }catch(Error){
    if(i == (Versions.length-1)){
     alert("出錯:創(chuàng)建服務(wù)器對象實(shí)例失敗[瀏覽器問題].");//瀏覽器問題//拋出Error.description
    }
   }
  }
 }
 return Ajax_Obj;
}
/*========================================================================================
【Ajax發(fā)送函數(shù)】
創(chuàng)建于[2008-04-09]
*/
function SendRequest(Method,Url,Content,ResponseType,CallBack){//初始化、指定處理函數(shù)、發(fā)送請求的函數(shù)
 var Http_Request = false;
 Http_Request = CreateAjax();//開始初始化XMLHttpRequest對象
 if(!Http_Request){ //異常,創(chuàng)建對象實(shí)例失敗
  alert("出錯:不能創(chuàng)建XMLHttpRequest對象實(shí)例.");
  return false;
 }
 if(ResponseType.toLowerCase()=="text") {
  Http_Request.onreadystatechange = function(){ CallBack(Http_Request);};
 }else if(ResponseType.toLowerCase()=="xml"){
  Http_Request.onreadystatechange = function(){ CallBack(Http_Request);};
 }else{
  alert("出錯:響應(yīng)類別參數(shù)錯誤.");
  return false;
 }
 //確定發(fā)送請求的方式和URL以及是否異步執(zhí)行下段代碼
 if(Method.toLowerCase()=="get") {
  Http_Request.open(Method,Url,true);
 }else if(Method.toLowerCase()=="post"){
  Http_Request.open(Method,Url, true);
  Http_Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
 }else{
  alert("出錯:http請求類別參數(shù)錯誤.");
  return false;
 }
 Http_Request.send(Content);
}
// 處理返回文本格式信息的函數(shù)
//function ProcessTextResponse(){
// if(Http_Request.readyState == 4){ //判斷對象狀態(tài)
//  if(Http_Request.status == 200){ //信息已經(jīng)成功返回,開始處理信息
//   var RstInfo = Http_Request.responseText;
//  }else{//頁面不正常
//   alert("出錯:您所請求的頁面有異常。");//Http_Request.statusText
//  }
// }
//}
////處理返回的XML格式文檔的函數(shù)
//function ProcessXMLResponse() {
// if (Http_Request.readyState == 4) {//判斷對象狀態(tài)
//  if (Http_Request.status == 200) {//信息已經(jīng)成功返回,開始處理息
//   var XmlDoc = Http_Request.responseXML;
//   var Roots = XmlDoc.documentElement.childNodes;
//   var Text = Roots[0].selectSingleNode("Title").text;
//   var Att_Value = Roots[0].getAttribute("Id");
//  }else{ //頁面不正常
//   alert("出錯:您所請求的頁面有異常。");//Http_Request.statusText
//  }
// }
//}
//Ajax類結(jié)束

/*========================================================================================
【Cookies操作類】
[創(chuàng)建于2008-04-09]
*/
function Cookies(){}
Cookies.prototype.GetVal=function(offset){
 //獲得Cookie解碼后的值
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
  endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
}
Cookies.prototype.Add=function(name,value,hours){
 //設(shè)定Cookie值 
 var expire = "";
 if(hours != null){
  expire = new Date((new Date()).getTime() + hours * 3600000);
  expire = "; expires=" + expire.toGMTString();
 }
 document.cookie = name + "=" + escape(value) + expire;
}
Cookies.prototype.Del=function(name){
 //刪除Cookie
 var exp = new Date();
 exp.setTime (exp.getTime() - 1);
 var cval = GetCookie (name);
 document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
Cookies.prototype.Get=function(name){
 //獲得Cookie的原始值
 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;
}
/*//======================================================================================
//【獲得對象實(shí)際坐標(biāo)】
[創(chuàng)建于2008-04-09]
*/
function GetDim(el){  
 var rd = {x:0,y:0};  
 do{
  rd.x += el.offsetLeft;
  rd.y += el.offsetTop;
  el = el.offsetParent;
 }while(el)
 return rd;
}
/*//========================================================================================
//【出錯彈出窗口】
[創(chuàng)建于2008-04-09]
*/
function Error_Show(M){
 var Err_Str="";
 switch(M){
  case 0: //超時
   Err_Str="出錯:您還未登錄或登錄已超時,請重新登錄.";
   break;
  case 1://參數(shù)出錯
   Err_Str="出錯:參數(shù)出錯,請聯(lián)系管理員.";
   break;
  case 2://Js出錯
   Err_Str="出錯:客戶端腳本出錯.";
   break;
  case 3://服務(wù)器出錯
   Err_Str="出錯:服務(wù)器響應(yīng)出錯.";
   break;
  case 4://加載出錯
   Err_Str="出錯:加載信息出錯.";
   break;
  default:
   Err_Str="未知錯誤!";
   break;
 }
 alert(Err_Str);
 //return ;
}
/*========================================================================================
【獲得參數(shù)值】
[創(chuàng)建于2008-04-09]
*/
function GetQuery(name){
 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
 var r = window.location.search.substr(1).match(reg);
 if (r!=null) return unescape(r[2]);
 return null;
}
/*========================================================================================
【漂浮類開始】
[創(chuàng)建于2008-04-09]
var Float=new Floats();
Float.Move_It("Float","Floater");
*/
function Floats(){
 this._lastScrollX = 0;
 this._lastScrollY = 0;
 this._NS = (document.layers) ? 1 : 0;
 this._IE = (document.all) ? 1: 0;
}
Floats.prototype.HeartBeat=function(Id){ 
 if(this._IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
 if(this._NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
 if(diffY !=this. _lastScrollY) {
  percent = .1 * (diffY - this._lastScrollY);
  if(percent > 0) percent = Math.ceil(percent);
  else percent = Math.floor(percent);
  if(this._IE) Id.style.pixelTop += percent;
  if(this._NS) Id.top += percent;
  this._lastScrollY = this._lastScrollY + percent;
 }
 if(diffX != this._lastScrollX) {
  percent = .1 * (diffX - this._lastScrollX);
  if(percent > 0) percent = Math.ceil(percent);
  else percent = Math.floor(percent);
  if(this._IE) Id.style.pixelLeft += percent;
  if(this._NS) Id.left += percent;
  this._lastScrollX = this._lastScrollX + percent;
 }
}
Floats.prototype.Hidden=function(e){
 e.style.display="none";
}
Floats.prototype.Drag=function(e){
 var x,y;
 if(parseInt(e.style.left).toString()=="NaN"){
  if(parseInt(e.style.right).toString()=="NaN"){
   x=1;  
  }else{
   x=parseInt(document.body.clientWidth)-parseInt(e.style.right)-parseInt(e.clientWidth);  
  } 
  e.style.left=x+"px";
 }else{
  x=parseInt(e.style.left);
 }
 if(parseInt(e.style.top).toString()=="NaN"){
  y=1;
  e.style.top=y+"px;";
 }else{
  y=parseInt(e.style.top);
 }
 var deltaX=event.clientX-x;
 var deltaY=event.clientY-y;
 var drag=true;
 e.onmousemove=function(){ 
  if(drag){
   e.style.left=(event.clientX-deltaX)+"px";
   e.style.top=(event.clientY-deltaY)+"px";
   e.setCapture();
  }
 }
 e.onmouseup=function(){
  drag=false;
  e.releaseCapture();
 }
}
Floats.prototype.Move_It=function(FloatName,Id){
 var action=window.setInterval(""+FloatName+".HeartBeat("+Id+")",100);
}
/*========================================================================================
【拖動函數(shù)】
創(chuàng)建于[2008-04-09]
*/
function Drag(MoveId){
 var x,y;
 if(parseInt(MoveId.style.left).toString()=="NaN"){
  if(parseInt(MoveId.style.right).toString()=="NaN"){
   x=1;  
  }else{
   x=parseInt(document.body.clientWidth)-parseInt(MoveId.style.right)-parseInt(MoveId.clientWidth);  
  } 
  MoveId.style.left=x+"px";
 }else{
  x=parseInt(MoveId.style.left);
 }
 if(parseInt(MoveId.style.top).toString()=="NaN"){
  y=1;
  MoveId.style.top=y+"px;";
 }else{
  y=parseInt(MoveId.style.top);
 }
 var deltaX=event.clientX-x;
 var deltaY=event.clientY-y;
 var drag=true;
 MoveId.style.filter="Alpha(Opacity=60)";
 MoveId.onmousemove=function(){  
  if(drag){
   MoveId.style.left=(event.clientX-deltaX)+"px";
   MoveId.style.top=(event.clientY-deltaY)+"px";
   MoveId.setCapture();
  }
 }
 MoveId.onmouseup=function(){
  MoveId.style.filter="Alpha(Opacity=100)";
  drag=false;
  MoveId.releaseCapture();
 }
}
/*========================================================================================
【字符轉(zhuǎn)換類】
創(chuàng)建于[2008-04-09]
*/
function StringToHtml(){}
StringToHtml.prototype.sTh=function(s){
 s = s.replace(/</gi,"<");
 s = s.replace(/>/gi,">");
 s = s.replace(/"/gi,"\"");
 s = s.replace(/&/gi,"&");
 s = s.replace(/ /gi," ");
 return s;
}
StringToHtml.prototype.hTs=function(s){
 s = s.replace(/</gi,"<");
 s = s.replace(/>/gi,">");
 s = s.replace(/\\/gi,""");
 s = s.replace(/&/gi,"&");
 s = s.replace(/ /gi," ");
 return s;
}
StringToHtml.prototype.bTy=function(s){
 s = s.replace(/\[/gi,"<");
 s = s.replace(/\]/gi,">");
 return s;
}
StringToHtml.prototype.yTb=function(s){
 s = s.replace(/</gi,"[");
 s = s.replace(/</gi,"[");
 s = s.replace(/>/gi,"]");
 s = s.replace(/>/gi,"]");
 s = s.replace(/ /gi," ");
 return s;
}
/*========================================================================================
【選擇類別】
創(chuàng)建于[2008-04-09]
修改日期[2008-05-21]
*/
function Class_CheckAll(){
 this.AllCheck = document.getElementById(typeof(arguments[0])=="undefined"?"Check_All":arguments[0]);
 this.SubCheck = document.getElementsByName(typeof(arguments[1])=="undefined"?"Check_Sub":arguments[1]);
 this.Btn_Check = document.getElementById(typeof(arguments[2])=="undefined"?"Btn_CheckAll":arguments[2]);
 this.Btn_Del = document.getElementById(typeof(arguments[3])=="undefined"?"Btn_CheckDel":arguments[3]);
 this.Url=document.getElementById(typeof(arguments[4])=="undefined"?"Ajax_Response.aspx":arguments[4]);
}
Class_CheckAll.prototype.SelectTd=function(Id){
 if(event.srcElement.tagName=="TD"){
  if(Id.getElementsByTagName("input")[0].checked==true){
   Id.getElementsByTagName("input")[0].checked=false;
  }else{
   Id.getElementsByTagName("input")[0].checked=true;
  }
 }
 this.Check_DelAble();
}
Class_CheckAll.prototype.CheckAll=function(){   
    if(this.AllCheck.checked==true){           
        this.Btn_Check.value="取 消";
        this.Btn_Del.disabled=false;
    }else{           
        this.Btn_Check.value="全 選";
        this.Btn_Del.disabled=true;
    }
    for(var i=0;i<this.SubCheck.length;i++){
        this.SubCheck[i].checked=this.AllCheck.checked;
    }
}
Class_CheckAll.prototype.Check_DelAble=function(){
 var m=0;
    var Flag=false;   
    for(var i=0;i<this.SubCheck.length;i++){
        if(this.SubCheck[i].checked==true){
           Flag=true;
           break;
        }
    }
    if(Flag==true){
        this.Btn_Del.disabled=false;
    }else{
        this.Btn_Del.disabled=true;
    }
 for(var i=0;i<this.SubCheck.length;i++){
        if(this.SubCheck[i].checked==true){
           m=m+1;          
        }
    }
 if(m==this.SubCheck.length){
  this.AllCheck.checked=true;
  this.Btn_Check.value="取 消";
 }else{
  this.AllCheck.checked=false;
  this.Btn_Check.value="全 選";
 }
}
Class_CheckAll.prototype.Check_AllAndCancel=function(){  
    if(this.AllCheck.checked==true){
        this.AllCheck.checked=false;
    }else{
        this.AllCheck.checked=true;
    }
    this.CheckAll();
}
Class_CheckAll.prototype.Check_Del=function(t){
    if(confirm("確定要刪除選中的項(xiàng)嗎?")){
        var Ids="";            
        for(var i=0;i<this.SubCheck.length;i++){
            if(this.SubCheck[i].checked==true){
               Ids+=this.SubCheck[i].value+",";
            }
        }
  if(Ids.replace(",","").length==0){
   alert("請選擇要操作的項(xiàng)目!");
   return false;
  }
        Ids=Ids.substring(0,Ids.length-1); 
        window.location.href=this.Url+"?s="+t+"&Ids="+Ids;        
    }
}
/*========================================================================================
【標(biāo)準(zhǔn)顯示Flash】
創(chuàng)建于[2008-04-09]
*/
function Show_Flash(file,w,h) {
    document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"    document.write("<param name=\"movie\" value=\"" + file + "\">");
    document.write("<param name=\"quality\" value=\"high\">");
    document.write("<param name=\"wmode\" value=\"transparent\">");
    document.write("<param name=\"menu\" value=\"false\">");
    document.write("<embed src=\"" + file + "\" quality=\"high\" pluginspage=\"
    document.write("</object>");
}
/*========================================================================================
【圖片按比例縮放】
[創(chuàng)建于2008-04-19]
*/
function DrawImage(ImgD,Img_Width,Img_Height,AltStr){
 var flag=false;
 var image=new Image();
 var iwidth = Img_Width; //定義允許圖片寬度,當(dāng)寬度大于這個值時等比例縮小
 var iheight = Img_Height; //定義允許圖片高度,當(dāng)寬度大于這個值時等比例縮小
 image.src=ImgD.src;
 if(image.width>0 && image.height>0){
  flag=true;
  if(image.width/image.height>= iwidth/iheight){
   if(image.width>iwidth){
    ImgD.width=iwidth;
    ImgD.height=(image.height*iwidth)/image.width;
   }else{
    ImgD.width=image.width;
    ImgD.height=image.height;
   }
 
  ImgD.alt=image.width+"×"+image.height;
  }else{
   if(image.height>iheight){
    ImgD.height=iheight;
    ImgD.width=(image.width*iheight)/image.height;
   }else{
    ImgD.width=image.width;
    ImgD.height=image.height;
   }
   ImgD.alt=AltStr;
  }
 }
}
/*========================================================================================
【圖片轉(zhuǎn)換類別】
[創(chuàng)建于2008-04-19]
*/
function Img_Change(){
 try{
  this.NowFrame = 1;
  this.MaxFrame = document.getElementsByName(typeof(arguments[1])=="undefined"?"Img_Name":arguments[1]).length;
  this.bStart = 0;
  this.T_Name=document.getElementById(typeof(arguments[0])=="undefined"?"Change_Img":arguments[0]);
  this.Img_Id=document.getElementsByName(typeof(arguments[1])=="undefined"?"Img_Name":arguments[1]);
  this.RunTime=(arguments[2]=="" || typeof(arguments[2])=="undefined")?3:parseInt(arguments[2]);
  this.Initialize();
 }catch(e){
  alert("參數(shù)出錯["+e.description+"]");
 }
}
Img_Change.prototype.Initialize=function(){
 this.T_Name.style.cssText += ";filter: progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=0, motion='forward');";
}
Img_Change.prototype.RunFun=function(){
 var next = this.NowFrame + 1;
 if(next == this.MaxFrame+1){
  this.NowFrame = this.MaxFrame;
  next = 1;
 }
 if(this.bStart == 0){
  this.bStart = 1;
  //window.clearInterval(this.ReadTimer);
  return;
 }else{
  this.T_Name.filters[0].Apply();
  this.Img_Id[next-1].style.display = "";
  this.Img_Id[this.NowFrame-1].style.display = "none";
  this.T_Name.filters[0].Play(duration=2);
  if(this.NowFrame == this.MaxFrame){
   this.NowFrame = 1;
  }else{
   this.NowFrame++;
  }
 }
}
Img_Change.prototype.Run=function(ClassName){
 window.setInterval(""+ClassName+".RunFun()",this.RunTime*1000);
}
/*========================================================================================
【類別列表類】
[創(chuàng)建于2008-05-03]
ClassArr 四級類別數(shù)組
IsOpen 0為不展開  1為展開 默認(rèn)不展開
IsImg 0為顯示  1為不顯示 默認(rèn)顯示
Big_Icon 大類前圖標(biāo) 空則無
Small_Icon 子類前圖標(biāo) 空則無
<%
str=""
str1=""
str2=""
str3=""
Call Class_String(7,0,0,0,0)
%>
var ClassListArr=new Array(<%=str%>,<%=str1%>,<%=str2%>,<%=str3%>);
var ClassLists=new Class_List(ClassListArr,0,0,"","");
ClassLists.Class_Create("ClassLists");
*/
function Class_List(){
 try{ 
  this.Class_One = arguments[0][0];
  this.Class_Two = arguments[0][1];
  this.Class_Three = arguments[0][2];
  this.Class_Four = arguments[0][3];
  this.IsOpen = (typeof(arguments[1])=="undefined" || arguments[1]=="")?0:arguments[1];/*0為不展開  1為展開 默認(rèn)不展開*/
  this.IsImg = (typeof(arguments[2])=="undefined" || arguments[2]=="")?0:arguments[2];;/*0為顯示  1為不顯示 默認(rèn)顯示*/
  this.BigIcon=(typeof(arguments[3])=="undefined" || arguments[3] =="")?"":"<img src=\""+arguments[3]+"\" />";
  this.SmallIcon=(typeof(arguments[4])=="undefined" || arguments[4] =="")?"":"<img src=\""+arguments[4]+"\" />";
 }catch(e){
  alert("參數(shù)出錯["+e.description+"]");
 }
}
Class_List.prototype.Class_Create=function(ClassList){
 try{
  var Num_Img=0;
  var Num_Two=0;
  var Num_Three=0;
  var Num_Four=0;
  var OpenStr="";
  var Fun_Str="";
  var Img_Str="";
  var Img_Alt="";
  var IsClassSub=true;
  if(this.IsOpen==0){
   OpenStr="display:none;";
  }else{
   OpenStr="display:;";
  }
  var ClassList_Str = '\
  <table width="100%" border="0" cellspacing="1" cellpadding="1">\
  ';
  /*第一級類別開始*/
  if (this.Class_One.length==0){
   ClassList_Str += '\
   <tr><td>暫無添加任何類別!</td></tr></table>\
   ';
   document.write(ClassList_Str);
   return;
  }else{
   for(var i=0;i<this.Class_One.length;i++){
    if(this.Class_Two[i].length>0){
     IsClassSub=true;
     Fun_Str='onclick="'+ClassList+'.Show_ClassList(1,'+Num_Two+','+Num_Img+')"';
     Img_Str="";
     Img_Alt="點(diǎn)擊展開二級類";
    }else{
     IsClassSub=false;
     Fun_Str="";
     Img_Str="_1";
     Img_Alt="";
    }
    ClassList_Str += '\
     <tr id="Menu_ClassOne">\
      <td id="MenuClassOne" align="left" '+Fun_Str+'>'+this.BigIcon+' <a href="Product.asp?lb='+this.Class_One[i][1].replace("$0","")+'">'+this.Class_One[i][0]+'</a>\
       <img src="Images/Icon/plus'+Img_Str+'.gif" width="9" height="9" id="ClassSub" style="cursor:hand;" alt="'+Img_Alt+'"/></td>\
     </tr>\
    ';
    Num_Img++;
    /*第二級類別開始*/
    if(IsClassSub==false){
     continue;
    }else{
     Num_Two++;
    }
    ClassList_Str += '\
      <tr id="Menu_ClassTwo" style="'+OpenStr+'">\
     <td align="left" id="MenuClassTwo">\
     <table width="100%" border="0" cellspacing="1" cellpadding="1" style="margin-left:20px;">\
       ';
       for(var j=0;j<this.Class_Two[i].length;j++){
      if(this.Class_Three[i][j].length>0){
       IsClassSub=true;
       Fun_Str='onclick="'+ClassList+'.Show_ClassList(2,'+Num_Three+','+Num_Img+')"';
       Img_Str="";
       Img_Alt="點(diǎn)擊展開三級類";
      }else{
       IsClassSub=false;
       Fun_Str="";
       Img_Str="_1";
       Img_Alt="";
      }
        ClassList_Str += '\
        <tr>\
       <td '+Fun_Str+'>'+this.SmallIcon+' <a href="Product.asp?lb='+this.Class_Two[i][j][1].replace("$0","")+'">'+this.Class_Two[i][j][0]+'</a> <img src="Images/Icon/plus'+Img_Str+'.gif" width="9" height="9" id="ClassSub" style="cursor:hand;" alt="'+Img_Alt+'"/></td>\
        </tr>\
        ';
        Num_Img++;           
        /*第三級類別開始*/
       if(IsClassSub==false){
        continue;
       }else{
        Num_Three++;
       }
        ClassList_Str += '\
         <tr id="Menu_ClassThree" style="'+OpenStr+'">\
        <td align="left" id="MenuClassThree">\
        <table width="100%" border="0" cellspacing="1" cellpadding="1" style="margin-left:20px;">\
          ';
          for(var m=0;m<this.Class_Three[i][j].length;m++){
         if(this.Class_Four[i][j][m].length>0){
          IsClassSub=true;
          Fun_Str='onclick="'+ClassList+'.Show_ClassList(3,'+Num_Four+','+Num_Img+')"';
          Img_Str="";
          Img_Alt="點(diǎn)擊展開四級類";
         }else{
          IsClassSub=false;
          Fun_Str="";
          Img_Str="_1";
          Img_Alt="";
         }
           ClassList_Str += '\
           <tr>\
          <td '+Fun_Str+'>'+this.SmallIcon+' <a href="Product.asp?lb='+this.Class_Three[i][j][m][1].replace("$0","")+'">'+this.Class_Three[i][j][m][0]+'</a> <img src="Images/Icon/plus'+Img_Str+'.gif" width="9" height="9" id="ClassSub" style="cursor:hand;" alt="'+Img_Alt+'"/></td>\
           </tr>\
           ';
            Num_Img++;
           /*第四級類別開始*/
          if(IsClassSub==false){
           continue;
          }else{
           Num_Four++;
          }
            ClassList_Str += '\
            <tr id="Menu_ClassFour" style="'+OpenStr+'">\
           <td align="left" id="MenuClassFour">\
           <table width="100%" border="0" cellspacing="1" cellpadding="1" style="margin-left:20px;">\
             ';
             for(var n=0;n<this.Class_Four[i][j][m].length;n++){
              ClassList_Str += '\
              <tr>\
             <td>'+this.SmallIcon+' <a href="Product.asp?lb='+this.Class_Four[i][j][m][n][1].replace("$0","")+'">'+this.Class_Four[i][j][m][n][0]+'</a> <img src="Images/Icon/plus_1.gif" width="9" height="9" id="ClassSub"/></td>\
              </tr>\
              ';                                            Num_Img++;
             }
          ClassList_Str += '\
            </table>\
           </td>\
            </tr>\
          ';
          /*第四級類別結(jié)束*/        
          }
       ClassList_Str += '\
         </table>\
        </td>\
         </tr>\
       ';
       /*第三級類別結(jié)束*/
       }
    ClassList_Str += '\
      </table>\
     </td>\
      </tr>\
    ';
    /*第二級類別結(jié)束*/
   }
   /*第一級類別結(jié)束*/
  }
  ClassList_Str += '\
  </table>\
  ';
  document.write(ClassList_Str);
  var Img_Show=_$("ClassSub");
  for(var i=0;i<Img_Show.length;i++){
   if(this.IsImg==0){
    Img_Show[i].style.display="";
   }else{
    Img_Show[i].style.display="none";
   }
  }
 }catch(e){
 
 }
}
Class_List.prototype.Show_ClassList=function(M,N,L){
 var ClassTb=_$("Menu_ClassOne","Menu_ClassTwo","Menu_ClassThree","Menu_ClassFour");
 var Class_Sub=_$("ClassSub");
 if(ClassTb[M][N].style.display=="none"){
  ClassTb[M][N].style.display="";
  Class_Sub[L].src="Images/Icon/Plus_1.gif";
  Class_Sub[L].alt=Class_Sub[L].alt.replace("展開","折疊");
 }else{
  ClassTb[M][N].style.display="none";
  Class_Sub[L].src="Images/Icon/Plus.gif";
  Class_Sub[L].alt=Class_Sub[L].alt.replace("折疊","展開");
 }
}
/*========================================================================================
【當(dāng)前日間】
[創(chuàng)建于2008-05-14]
*/
function CurrentDateTime(num){
 //num==0 為中文
 //num==1 為英文
 var Strs="";
 var str=new Array();
 str[0]=new Array("年","月","日","時","分","秒");
 str[1]=new Array("Year","Month","Day","Hour","Minute","Seconds");
 var Weeks=new Array();
 Weeks[0]=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
 Weeks[1]=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
 var Months=new Array();
 Months[0]=new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
 Months[1]=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 var today=new Date();
 var Year=today.getYear();
 var Month=today.getMonth()+1;
 var Day=today.getDate();
 var Hour=today.getHours();
 var Minute=today.getMinutes();
 var Second=today.getSeconds();
 var Week=today.getDay();
 Hour=Hour.toString().length>1?Hour.toString():"0"+Hour.toString();
 Minute=Minute.toString().length>1?Minute.toString():"0"+Minute.toString();
 Second=Second.toString().length>1?Second.toString():"0"+Second.toString();
 if(num==0){
  Strs=Year+str[0][0]+Month+str[0][1]+Day+str[0][2]+" "+Hour+str[0][3]+Minute+str[0][4]+Second+str[0][5]+"  "+Weeks[0][Week];
 }else{
  Strs=" At "+Hour+":"+Minute+":"+Second+" on "+Months[1][Month-1]+" "+Day+", "+Year+" "+Weeks[1][Week];
 }
 document.getElementById("CurrentDate").innerText=Strs;
}
/*========================================================================================
【驗(yàn)證表單類】
[創(chuàng)建于2008-05-14]
/* IsCard 驗(yàn)證身份證號碼是否正確!
/* IsEmail 驗(yàn)證Email格式是否正確!
/* IsMobile 驗(yàn)證手機(jī)號碼是否否合法!
/* IsTel 驗(yàn)證電話格式是否正確!
/* IsNum 驗(yàn)證字符是否是數(shù)字!
/* IsEn 驗(yàn)證字符里面是否有漢字!
/* IsDate 驗(yàn)證是不是日期格式!
*/
function Check_Form(){
 this.Errors=[[[1,"驗(yàn)證通過!"],[2,"身份證號碼位數(shù)不對!"],[3,"身份證號碼出生日期超出范圍或含有非法字符!"],[4,"身份證號碼校驗(yàn)錯誤!"],[5,"身份證地區(qū)非法!"]],[[1,"驗(yàn)證通過!"],[2,"Email格式不正確!"]],[[1,"驗(yàn)證通過!"],[2,"手機(jī)號碼必須由數(shù)字組成!"],[3,"手機(jī)號碼位數(shù)不正確!"],[4,"手機(jī)號碼格式不正確!"]],[[1,"驗(yàn)證通過!"],[2,"電話格式不正確!"]],[[1,"驗(yàn)證通過!"],[2,"必須有數(shù)字組成!"]],[[1,"驗(yàn)證通過!"],[2,"字符串里面含有漢字!"]],[[1,"驗(yàn)證通過!"],["2","日期格式不正確!"]]];
 this.IsNull=[0,"不能為空!"];
}
/*驗(yàn)證身份證號碼是否否合法*/
Check_Form.prototype.IsCard=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 var idcard=arguments[0];
 var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"內(nèi)蒙古",21:"遼寧",22:"吉林",23:"黑龍江",31:"上海",32:"江蘇",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山東",41:"河南",42:"湖北",43:"湖南",44:"廣東",45:"廣西",46:"海南",50:"重慶",51:"四川",52:"貴州",53:"云南",54:"西藏",61:"陜西",62:"甘肅",63:"青海",64:"寧夏",65:"新疆",71:"臺灣",81:"香港",82:"澳門",91:"國外"}
 var idcard,Y,JYM;
 var S,M;
 var idcard_array = new Array();
 idcard_array = idcard.split("");
 if(area[parseInt(idcard.substr(0,2))]==null) return this.Errors[0][4];
 switch(idcard.length){
  case 15:
   if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
    ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;
   }else{
 ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;
   }
   if(ereg.test(idcard)) return this.Errors[0][0];
   else return this.Errors[0][2];
   break;
  case 18:
   if( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
    ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//閏年出生日期的合法性正則表達(dá)式
   }else{
    ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正則表達(dá)式
   }
   if(ereg.test(idcard)){
    S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
    + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
    + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
    + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
    + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
    + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
    + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
    + parseInt(idcard_array[7]) * 1
    + parseInt(idcard_array[8]) * 6
    + parseInt(idcard_array[9]) * 3 ;
    Y = S % 11;
    M = "F";
    JYM = "10X98765432";
    M = JYM.substr(Y,1);
    if(M == idcard_array[17]) return this.Errors[0][0];
   else return this.Errors[0][3];
   }
   else return this.Errors[0][2];
   break;
  default:
   return this.Errors[0][1];
  break;
 } 
}
/*驗(yàn)證EMail是否否合法*/
Check_Form.prototype.IsEmail=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 if (arguments[0].search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
  return this.Errors[1][0];
 }else{
  return this.Errors[1][1];
 }
}
/*驗(yàn)證手機(jī)號碼是否否合法*/
Check_Form.prototype.IsMobile=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 var Mno=arguments[0];
 if (this.IsNum(Mno)[0]==2) return this.Errors[2][1];
 if (Mno.length!=11) return this.Errors[2][2];
 if (Mno.substring(0,2)!="13" && Mno.substring(0,2)!="15" ) return this.Errors[2][3];
 return this.Errors[2][0];
}
/*驗(yàn)證電話格式是否正確*/
Check_Form.prototype.IsTel=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 if(arguments[0].search(/^(((\+){0,1}[0-9]{2,2}(\-){0,1}0{0,1})[0-9]{2,3}(\-){0,1})?[2-9][0-9]{6,7}$/)!=-1) {               
  return this.Errors[3][0];
 }else{
  return this.Errors[3][1];
 }
}
/*驗(yàn)證字符是否是數(shù)字*/
Check_Form.prototype.IsNum=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 var number=arguments[0];
 var i,str1="0123456789";
 if (number==null||number=="")  return this.Errors[4][1];
 for(i=0;i<number.length;i++){
  if(str1.indexOf(number.charAt(i))==-1){
   return this.Errors[4][1];
   break;
  }
 }
 return this.Errors[4][0];
}
/*驗(yàn)證字符里面是否有漢字*/
Check_Form.prototype.IsEn=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 var text=arguments[0];
 for (i=0;i<text.length;i++)
  if (text.charCodeAt(i)>255) {
   //alert("抱歉!提交失敗,"+text+"不能含有漢字!");
   return this.Errors[5][1];
  }
 return this.Errors[5][0];
}
/*驗(yàn)證是不是日期格式*/
Check_Form.prototype.IsDate=function(){
 if(typeof(arguments[0])=="undefined" || arguments[0]=="") return this.IsNull;
 if(arguments[0].match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/)==null){
  return this.Errors[6][1];
 }else{
  return this.Errors[6][0];
 }
}


本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:
http://blog.csdn.net/xiaofengnet/archive/2008/05/22/2468982.aspx

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多