[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/ -> coolMenu.js (source)

   1  /************************************************************
   2  
   3    coolMenu for osCommerce
   4    
   5    author:    Andreas Kothe 
   6    url:        http://www.oddbyte.de
   7  
   8    last modified: 02.17.03
   9  
  10    
  11    -----
  12  
  13  
  14    Coolmenus Beta 4.06 - Copyright Thomas Brattli - www.dhtmlcentral.com
  15    Last updated: 11.13.02
  16  
  17    v4.06 - with basic frame support
  18    
  19  *************************************************************/
  20  /*Browsercheck object*/
  21  function cm_bwcheck(){
  22      //In theory we should use object detection, but this script needs work-arounds for almost every browser...
  23      this.ver=navigator.appVersion
  24      this.agent=navigator.userAgent.toLowerCase()
  25      this.dom=document.getElementById?1:0
  26      this.ns4=(!this.dom && document.layers)?1:0;
  27      this.op=window.opera 
  28      this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
  29      this.ie=this.agent.indexOf("msie")>-1 && !this.op
  30      if(this.op){
  31          this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
  32          this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
  33          this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
  34      }else if(this.moz) this.ns6 = 1
  35      else if(this.ie){
  36          this.ie4 = !this.dom && document.all
  37        this.ie5 = (this.agent.indexOf("msie 5")>-1)
  38        this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  39        this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
  40      }
  41      this.mac=(this.agent.indexOf("mac")>-1)
  42      this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  43    this.usedom= this.ns6||this.op7//Use dom creation
  44    this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  45    this.px=this.dom&&!this.op5?"px":""
  46      return this
  47  }
  48  var bw=new cm_bwcheck()
  49  
  50  /*Variable declaration*/
  51  var cmpage
  52  /*Crossbrowser objects functions*/
  53  function cm_message(txt){alert(txt); return false}
  54  function cm_makeObj(obj,nest,o,doc){ //Changed in v4.05
  55    if(!doc) doc=document 
  56    if(bw.usedom&&o) this.evnt=o
  57    else{nest=(!nest) ? "doc.":'doc.layers.'+nest+'.'
  58      this.evnt=bw.dom? doc.getElementById(obj):
  59      bw.ie4?doc.all[obj]:bw.ns4?eval(nest+"layers." +obj):0;
  60    }
  61    if(!this.evnt) return cm_message('The layer does not exist ('+obj+')' 
  62      +'- \nIf your using Netscape please check the nesting of your tags (on the entire page)\nNest:'+nest)
  63    this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; this.ok=0
  64    this.ref=bw.dom||bw.ie4?doc:this.css.document; 
  65    this.obj = obj + "Object";     eval(this.obj + "=this");
  66    this.x=0; this.y=0; this.w=0; this.h=0; this.vis=0; return this
  67  }
  68  cm_makeObj.prototype.moveIt = function(x,y){this.x=x;this.y=y; this.css.left=x+bw.px;this.css.top=y+bw.px}
  69  cm_makeObj.prototype.showIt = function(o){this.css.visibility="visible"; this.vis=1; if(bw.op5&&this.arr){ this.arr.showIt(); }}//alert('showing arrow')}} 
  70  cm_makeObj.prototype.hideIt = function(no){this.css.visibility="hidden"; this.vis=0;}
  71  cm_makeObj.prototype.clipTo = function(t,r,b,l,setwidth){ 
  72  this.w=r; this.h=b; if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r; this.css.clip.bottom=b;this.css.clip.left=l
  73  }else{if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0; this.css.clip="rect("+t+bw.px+","+r+bw.px+","+b+bw.px+","+l+bw.px+")";
  74  if(setwidth){if(bw.op5||bw.op6){this.css.pixelWidth=r; this.css.pixelHeight=b;}else{this.css.width=r+bw.px; this.css.height=b+bw.px;}}}}
  75  function cm_active(on,h){
  76      if(this.o.arr) on?this.o.arr.hideIt():bw.op5?this.o.arr.showIt():this.o.arr.css.visibility="inherit"
  77    if(bw.reuse||bw.usedom){
  78      if(!this.img2) this.o.evnt.className=on?this.cl2:this.cl
  79      else this.o.ref.images["img"+this.name].src=on?this.img2.src:this.img1.src; //Changed v4.05
  80      if(on && bw.ns6){this.o.hideIt(); this.o.css.visibility='inherit' }; //netscape 6 bug fix  
  81    }else{  
  82      if(!this.img2){ if(on) this.o.over.showIt(); else this.o.over.hideIt();
  83      }else this.o.ref.images["img"+this.name].src=on?this.img2.src:this.img1.src;
  84    }this.isactive=on?1:0
  85  }
  86  /***Pageobject **/
  87  function cm_page(frame){ //Changed v4.05
  88    if(!frame) frame = self 
  89    this.x=0; this.x2 =(!bw.ie)?frame.innerWidth:frame.document.body.offsetWidth-20;
  90    this.y=0; this.orgy=this.y2= (!bw.ie)?frame.innerHeight:frame.document.body.offsetHeight-6;
  91    this.x50=this.x2/2; this.y50=this.y2/2; return this
  92  }
  93  /***check positions**/
  94  function cm_cp(num,w,minus){
  95      if(num){if(num.toString().indexOf("%")!=-1){var t = w?cmpage.x2:cmpage.y2; num=parseInt((t*parseFloat(num)/100))
  96    if(minus) num-=minus }else num=eval(num);} else num=0; return num
  97  }
  98  /**Level object**/
  99  function cm_makeLevel(){//changed 4.06
 100      var c=this, a=arguments; c.width=a[0]||null; c.height=a[1]||null; 
 101    c.regClass=a[2]||null; c.overClass=a[3]||null; c.borderX=a[4]>-1?a[4]:null; 
 102    c.borderY=a[5]>-1?a[5]:null; c.borderClass=a[6]||null; c.rows=a[7]>-1?a[7]:null; 
 103    c.align=a[8]||null; c.offsetX=a[9]||null; c.offsetY=a[10]||null; c.arrow=a[11]||null; 
 104    c.arrowWidth=a[12]||null; c.arrowHeight=a[13]||null; c.roundBorder=a[14]||null; return c
 105  }
 106  /***Making the main menu object**/
 107  function makeCM(name){ //Changed v4.06
 108    var c=this; c.mc=0; c.name = name; c.m=new Array(); c.scrollY=-1; c.level=new Array(); c.l=new Array(); c.tim=100; c.isresized=0;
 109    c.isover=0; c.zIndex=100; c.frameStartLevel=1; c.bar=0; c.z=0; c.totw=0; c.toth=0; c.maxw=0; c.maxh=0; cmpage = new cm_page(); c.constructed = 0;
 110      return this
 111  }//events
 112  makeCM.prototype.onshow=""; makeCM.prototype.onhide=""; makeCM.prototype.onconstruct="";
 113  /***Creating layers**/
 114  function cm_divCreate(id,cl,txt,w,c,app,ex,txt2){
 115    if(bw.usedom){var div=document.createElement("DIV"); div.className=cl; div.id=id; 
 116      if(txt) div.innerHTML=txt; if(app){app.appendChild(div); return div}
 117      if(w) document.body.appendChild(div); return div
 118    }else{var dstr='<div id="'+id+'" class="'+cl+'"' 
 119      if(ex&&bw.reuse) dstr+=" "+ex; dstr+=">"+txt; ; if(txt2) dstr+=txt2; 
 120      if(c) dstr+='</div>'; if(w) document.write(dstr); else return dstr
 121    }return ""
 122  }
 123  /***Getting layer string for each menu**/
 124  function cm_getLayerStr(m,app,name,fill,clb,arrow,ah,aw,root){
 125    var no=m.nolink,arrstr='',l=m.lev,str='',txt=m.txt,ev='', id=name + '_' + m.name,d1; if(app) d1=app
 126    if((!bw.reuse||l==0) && !no){
 127      ev=' onmouseover="'+name+'.showsub(\''+m.name+'\')"' 
 128      +' onmouseout="'+name+'.mout(\''+m.name+'\')"'
 129      +' onclick="'+name+'.onclck(\''+m.name+'\'); return false" '
 130    }
 131    if(bw.reuse&&l!=0) txt=''; if(l==0) str+=d1=cm_divCreate(id+'_0',clb,''); str+=m.d2=cm_divCreate(id,m.cl,txt,0,0,d1,ev)
 132    if(l==0&&bw.usedom){ 
 133      m.d2.onclick=new Function(name+'.onclck("'+m.name+'")'); 
 134      m.d1=d1; 
 135      m.d2.onmouseover=new Function(name+'.showsub("'+m.name+'")'); 
 136      m.d2.onmouseout=new Function(name+'.mout("'+m.name+'")')
 137    }if(!bw.reuse && !m.img1 && !no){
 138      str+=cm_divCreate(id+'_1',m.cl2,txt,0,1)
 139      str+=cm_divCreate(id+'_3',"clCMAbs",'<a href="#" '+ev+'><img alt="" src="'+root+fill+'" width="'+m.w+'" height="'+m.h+'" border="0" /></a>',0,1)
 140    }str+='</div>'; 
 141    if(l==0){if(arrow)str+=m.d3=cm_divCreate(id+'_a','clCMAbs','<img alt="" height="'+aw+'" width="'+ah+'" src="'+root+arrow+'" />',0,1,d1); str+="</div>"}
 142    str+="\n"; if(!bw.reuse){m.txt=null; m.d2=null; m.d3=null;}
 143    if(bw.usedom){ if(l==0) document.body.appendChild(d1); str=''}
 144    return str
 145  }
 146  /***get align num from text (better to evaluate numbers later)**/
 147  function cm_checkalign(a){
 148    switch(a){
 149      case "right": return 1; break; case "left": return 2; break;
 150      case "bottom": return 3; break; case "top": return 4; break;
 151      case "righttop": return 5; break; case "lefttop": return 6; break;
 152      case "bottomleft": return 7; break; case "topleft": return 8; break;
 153    }return null
 154  }
 155  /**Making each individual menu **/
 156  makeCM.prototype.makeMenu=function(name,parent,txt,lnk,targ,w,h,img1,img2,cl,cl2,align,rows,nolink,onclick,onmouseover,onmouseout){
 157    var c = this; if(!name) name = c.name+""+c.mc; var p = parent!=""&&parent&&c.m[parent]?parent:0;
 158    if(c.mc==0){
 159          //Added 4.07 - bug(?) in opera 7 - you cannot dom-add layers created in one document to another one (or so it seems) - so turn of usedom
 160          if(bw.op7 && this.frames)    bw.usedom=0
 161          var tmp=location.href;
 162      if(tmp.indexOf('file:')>-1||tmp.charAt(1)==':') c.root=c.offlineRoot; else c.root=c.onlineRoot
 163      if(c.useBar){if(!c.barBorderClass) c.barBorderClass=c.barClass; c.bar1 = cm_divCreate(c.name+'bbar_0',c.barClass,'',0,1);
 164        c.bar = cm_divCreate(c.name+'bbar',c.barBorderClass,'',1,1,0,0,c.bar1); if(bw.usedom) c.bar.appendChild(c.bar1);    
 165      }}var create=1,img,arrow; var m = c.m[name] = new Object(); m.name=name; m.subs=new Array(); m.parent=p; m.arnum=0; m.arr=0
 166    var l = m.lev = p?c.m[p].lev+1:0; c.mc++; m.hide=0;
 167    if(l>=c.l.length){
 168      var p1,p2=0; if(l>=c.level.length) p1=c.l[c.level.length-1];
 169      else p1=c.level[l]; c.l[l]=new Array(); if(!p2) p2=c.l[l-1]
 170      if(l!=0){ if(isNaN(p1.align)) p1["align"]=cm_checkalign(p1.align)
 171        for(var i in p1){if(i!="str"&&i!="m"){if(p1[i]==null) c.l[l][i]=p2[i]; else c.l[l][i]=p1[i] }}
 172      }else{c.l[l]=c.level[0]; c.l[l].align=cm_checkalign(c.l[l].align)}
 173      c.l[l]["str"]=''; c.l[l].m=new Array(); if(!c.l[l].borderClass) c.l[l].borderClass=c.l[l].regClass
 174      c.l[l].app=0; c.l[l].max=0; c.l[l].arnum=0; c.l[l].o=new Array(); c.l[l].arr=new Array()
 175      c.level[l]=p1=p2=null
 176      if(l!=0) c.l[l].str=c.l[l].app=cm_divCreate(c.name+ '_' +l+'_0',c.l[l].borderClass,'')
 177    }if(p){p = c.m[p]; p.subs[p.subs.length]=name; 
 178      if(p.subs.length==1&&c.l[l-1].arrow){ p.arr=1; 
 179        if(p.parent){c.m[p.parent].arnum++
 180          if(c.m[p.parent].arnum>c.l[l-1].arnum){
 181            c.l[l-1].str+=c.l[l-1].arr[c.l[l-1].arnum]=cm_divCreate(c.name+ '_a' +(l-1)+'_'+c.l[l-1].arnum,'clCMAbs','<img height="'+c.l[l-1].arrowHeight
 182              +'" width="'+c.l[l-1].arrowWidth+'" src="'+c.root+c.l[l-1].arrow+'" alt="" />',0,1,c.l[l-1].app); c.l[l-1].arnum++
 183          }}}if(bw.reuse) if(p.subs.length>c.l[l].max) c.l[l].max = p.subs.length; else create=0
 184    }m.rows=rows>-1?rows:c.l[l].rows; m.w=cm_cp(w||c.l[l].width,1); m.h=cm_cp(h||c.l[l].height,0); m.txt=txt; m.lnk=lnk; 
 185    if(align) align=cm_checkalign(align); m.align=align||c.l[l].align; m.cl=cl=cl||c.l[l].regClass; 
 186    m.targ=targ; m.cl2=cl2||c.l[l].overClass; m.create=create;  m.mover=onmouseover; m.mout=onmouseout; 
 187    m.onclck=onclick; m.active = cm_active; m.isactive=0; m.nolink=nolink
 188    if(create) c.l[l].m[c.l[l].m.length]=name
 189    if(img1){m.img1 = new Image(); m.img1.src=c.root+img1; if(!img2) img2=img1; m.img2 = new Image(); m.img2.src=c.root+img2;
 190      m.cl="clCMAbs"; m.txt=''; if(!bw.reuse&&!nolink) m.txt = '<a href="#" onmouseover="'+c.name+'.showsub(\''+name+'\')" onmouseout="'+c.name+'.mout(\''+name+'\')" onclick="'+c.name+'.onclck(\''+name+'\'); return false">';;
 191      m.txt+='<img alt="" src="'+c.root+img1+'" width="'+m.w+'" height="'+m.h+'" id="img'+m.name+'" '
 192      if(bw.dom&&!nolink) m.txt+='style="cursor:pointer; cursor:hand"'; if(!bw.reuse){if(!bw.dom) m.txt+='name="img'+m.name+'"'; m.txt+=' border="0"'}; m.txt+=' />'; if(!bw.reuse&&!nolink) m.txt+='</a>'
 193    }else{m.img1=0; m.img2=0}; 
 194    if(l==0||create) c.l[l].str+=cm_getLayerStr(m,c.l[l].app,c.name,c.fillImg,c.l[l].borderClass,c.l[l].arrow,c.l[l].arrowWidth,c.l[l].arrowHeight,c.root)
 195    if(l==0){if(m.w>c.maxw) c.maxw=m.w; if(m.h>c.maxh) c.maxh=m.h; c.totw+=c.pxBetween+m.w+c.l[0].borderX;c.toth+=c.pxBetween+m.h+c.l[0].borderY}
 196    if(lnk && !onmouseover){
 197          var path=lnk.indexOf("mailto:")>-1||lnk.indexOf("http://")>-1?"":c.root
 198          m.mover="self.status='"+path+m.lnk+"'"
 199          if(!m.mout) m.mout=""; m.mout+=";self.status='';"
 200      }
 201  }
 202  /**Getting x/y coords for subs **/
 203  makeCM.prototype.getcoords=function(m,bx,by,x,y,maxw,maxh,ox,oy){
 204    var a=m.align; x+=m.o.x; y+=m.o.y
 205    switch(a){
 206      case 1:  x+=m.w+bx; break; case 2:  x-=maxw+bx; break;
 207      case 3:  y+=m.h+by; break; case 4:  y-=maxh+by; break;
 208      case 5:  x-=maxw+bx; y-=maxh-m.h; break;
 209      case 6:  x+=m.w+bx; y-=maxh-m.h; break;
 210      case 7:  y+=m.h+by; x-=maxw-m.w; break;
 211      case 8:  y-=maxh+by; x-=maxw-m.w+bx; break;
 212    }//Added v4.05
 213    if(m.lev==this.frameStartLevel-1 && this.frames){
 214      switch(a){
 215        case 1:  x=0; break; 
 216        case 2:  x=this.cmpage.x2-maxw; break;
 217        case 3:  y=0; break; 
 218        case 4:  y-=maxh+by; break;
 219        case 5:  x-=maxw+bx; y-=maxh-m.h; break;
 220        case 6:  x+=m.w+bx; y-=maxh-m.h; break;
 221        case 7:  y+=m.h+by; x-=maxw-m.w; break;
 222        case 8:  y-=maxh+by; x-=maxw-m.w+bx; break;
 223      }
 224    }
 225    m.subx=x + ox; m.suby=y + oy
 226  }
 227  /**Showing sub elements**/
 228  makeCM.prototype.showsub=function(el){ //Changed v4.06
 229    var c=this,pm=c.m[el],m,o,nl
 230    if(!pm.b||(c.isresized&&pm.lev>0)) pm.b=c.l[pm.lev].b; c.isover=1
 231    clearTimeout(c.tim);
 232    var ln=pm.subs.length,l=pm.lev+1
 233    if(c.l[pm.lev].a==el&&l!=c.l.length && !c.openOnClick){if(c.l[pm.lev+1].a) c.hidesub(l+1,el); return}
 234    c.hidesub(l,el); if(pm.mover) eval(pm.mover); if(!pm.isactive) pm.active(1);
 235    c.l[pm.lev].a = el; if(ln==0) return; 
 236      if(c.openOnClick && !c.clicked) return//Added v4.06
 237      if(!c.l[l].b) return //Added v4.05
 238    var b = c.l[l].b, bx=c.l[l].borderX, by=c.l[l].borderY, rows=pm.rows
 239      var rb=c.l[l].roundBorder;//added 4.06
 240    var x=bx+rb,y=by+rb,maxw=0,maxh=0,cn=0; b.hideIt()
 241    for(var i=0;i<c.l[l].m.length;i++){  
 242      if(!bw.reuse) m=c.m[c.l[l].m[i]]
 243      else m=c.m[c.m[el].subs[i]]
 244      if(m && m.parent==el&&!m.hide){
 245        if(!bw.reuse) o=m.o; else o=m.o=c.l[l].o[i]
 246        if(x!=o.x||y!=o.y) o.moveIt(x,y); nl=m.subs.length //changed 4.06
 247        if(bw.reuse){
 248          if(o.w!=m.w || o.h!=m.h) o.clipTo(0,m.w,m.h,0,1)
 249          if(o.evnt.className!=m.cl){ 
 250            m.isactive=0; o.evnt.className=m.cl
 251            if(bw.ns6){o.hideIt(); o.css.visibility='inherit'} //NS6 bugfix
 252          }if(bw.ie6) b.showIt()//IE6 bugfix (scrollbars)
 253          o.evnt.innerHTML=m.txt; if(bw.ie6) b.hideIt() 
 254                  if(!m.nolink){
 255            o.evnt.onmouseover=new Function(c.name+".showsub('"+m.name+"')")
 256            o.evnt.onmouseout=new Function(c.name+".mout('"+m.name+"')") //Added v4.05
 257            o.evnt.onclick=new Function(c.name+".onclck('"+m.name+"')")
 258            if(o.oldcursor){o.css.cursor=o.oldcursor; o.oldcursor=0;}
 259          }else{o.evnt.onmouseover=''; o.evnt.onclick='';  if(o.css.cursor=='') o.oldcursor=bw.ns6?"pointer":"hand"; else o.oldcursor=o.css.cursor; o.css.cursor="auto"}        
 260        }if(m.arr){o.arr=c.l[l].arr[cn]; o.arr.moveIt(x + m.w-c.l[l].arrowWidth-3,y+m.h/2-(c.l[l].arrowHeight/2)); 
 261        o.arr.css.visibility="inherit"; cn++;} else o.arr=0
 262        if(!rows){y+=m.h+by; if(m.w>maxw) maxw=m.w; maxh=y}
 263        else{x+=m.w+bx; if(m.h>maxh) maxh=m.h; maxw=x;}
 264        o.css.visibility="inherit"; if(bw.op5||bw.op6) o.showIt()
 265      }else{o = c.m[c.l[l].m[i]].o; o.hideIt();} }
 266    if(!rows) maxw+=bx*2+rb; else maxh+=by*2+rb; //changed 4.06
 267      if(rb){maxw+=rb; maxh+=rb}//added 4.06
 268      b.clipTo(0,maxw,maxh,0,1)
 269      //Check frame scroll
 270      if(c.chkscroll) c.chkscroll() //Added v4.05 - not the best solution
 271    if(c.chkscroll||!pm.subx||!pm.suby||c.scrollY>-1||c.isresized) c.getcoords(pm,c.l[l-1].borderX,c.l[l-1].borderY,pm.b.x,pm.b.y,maxw,maxh,c.l[l-1].offsetX,c.l[l-1].offsetY) //Changed 4.06
 272      x=pm.subx; if(c.chkscroll&&l==c.frameStartLevel) pm.suby+=c.scrollY; y=pm.suby; b.moveIt(x,y); if(c.onshow) eval(c.onshow); b.showIt()
 273  }
 274  /**Hide sub elements **/
 275  makeCM.prototype.hidesub=function(l,el){ //Changed v4.05
 276    var c = this,tmp,m,i,j,hide
 277    if(!l) {l=1; hide=1; c.clicked=0}
 278    for(i=l-1;i<c.l.length;i++){
 279      if(i>0&&i>l-1) if(c.l[i].b) c.l[i].b.hideIt()//Changed v4.05
 280      if(c.l[i].a&&c.l[i].a!=el){
 281        m=c.m[c.l[i].a]; m.active(0,1); if(m.mout) eval(m.mout); c.l[i].a=0
 282        if(i>0&&i>l-1) if(bw.op5||bw.op6) for(j=0;j<c.l[i].m.length;j++) c.m[c.l[i].m[j]].o.hideIt()
 283      }if(i>l){for(j=0;j<c.l[i-1].arnum;j++){c.l[i-1].arr[j].hideIt(); if(bw.op6) c.l[i-1].arr[j].moveIt(-1000,-1000)}} //opera bug
 284    }if(hide&&c.onhide) eval(c.onhide) //onhide event
 285  }
 286  /***Make all menu div objects**/
 287  makeCM.prototype.makeObjects=function(nowrite,fromframe){ //Changed v4.06
 288    var c = this,oc,name,bx,by,w,h,l,no,ar,id,nest,st=0,en=c.l.length,bobj,o,m,i,j
 289    //Added v4.05
 290    if(fromframe){
 291      st = this.frameStartLevel
 292      this.body = fromframe.document.body
 293      this.doc = fromframe.document
 294      this.deftarget=fromframe
 295      this.cmpage = new cm_page(fromframe)
 296    }else{
 297      this.body=document.body
 298      this.doc=document
 299      if(this.frames) en = this.frameStartLevel
 300      this.deftarget=self
 301    }
 302    if(!nowrite){
 303      for(i=st;i<en;i++){ //changed 4.06
 304        if(!bw.usedom) this.doc.write(c.l[i].str)
 305        else if(i>0) this.body.appendChild(c.l[i].app)
 306        if(!this.frames) c.l[i].str=null
 307      }}c.z=c.zIndex+2
 308    for(i=st;i<en;i++){oc=0
 309      if(i!=0){bobj=c.l[i].b = new cm_makeObj(c.name + "_"+i+"_0","",c.l[i].app,this.doc); bobj.css.zIndex=c.z; 
 310      if(bw.dom) bobj.css.overflow='hidden'}; bx=c.l[i].borderX; by=c.l[i].borderY; c.l[i].max=0;
 311      for(j=0;j<c.l[i].m.length;j++){
 312        m = c.m[c.l[i].m[j]]; name=m.name; w=m.w; h=m.h; l=m.lev; no=m.nolink;
 313        if(i>0){m.b = bobj; nest=i}
 314        else{m.b = new cm_makeObj(c.name + "_"+name+"_0","",m.d1,this.doc); m.b.css.zIndex=c.z; m.b.clipTo(0,w+bx*2,h+by*2,0,1); nest=name}
 315        id = c.name + "_"+name; nest=c.name + "_"+nest;
 316        if(m.create){
 317          o=m.o=new cm_makeObj(id,nest+"_0",m.d2,this.doc); o.z=o.css.zIndex=c.z+1; if(bw.reuse){c.l[l].o[oc]=o; oc++}; 
 318          if(l==0&&m.img1) o.css.visibility='inherit'; if(bw.op5) o.showIt(); o.arr=0;
 319        }if(!bw.reuse||l==0) o.clipTo(0,w,h,0,1); o.moveIt(bx,by); o.z=o.css.zIndex=c.z+2
 320        if(j<c.l[i].arnum){
 321          c.l[i].arr[j]=new cm_makeObj(c.name+"_a"+i+"_"+j,nest+"_0",nowrite?0:c.l[i].arr[j],this.doc)
 322          c.l[i].arr[j].css.zIndex=c.z+30+j;
 323        }else if(l==0&&m.arr==1){
 324          o.arr=new cm_makeObj(id+"_a",nest+"_0",m.d3,this.doc)
 325          o.arr.moveIt(bx+m.w-c.l[i].arrowWidth-3,by+m.h/2-(c.l[i].arrowHeight/2)); 
 326          o.arr.css.zIndex=c.z+20;
 327        }if(!no && !bw.reuse && !m.img1){  
 328          o.over=new cm_makeObj(c.name + "_"+name+"_1",nest+"_0"+".document.layers."+id,"",this.doc)
 329          o.over.moveIt(0,0); o.over.hideIt(); o.over.clipTo(0,w,h,0,1); o.over.css.zIndex=c.z+3
 330          img=new cm_makeObj(c.name + "_"+name+"_3",nest+"_0"+".document.layers."+id,"",this.doc); img.moveIt(0,0)
 331          img.css.visibility="inherit"; img.css.zIndex=c.z+4; if(bw.op5) img.showIt()
 332        }c.z++; 
 333      }
 334    }
 335      if(fromframe){    ///Set scroll vars - added v4.05
 336          c.chkscroll = function(){//changed 4.06
 337              if (bw.ie&&!bw.ie6) this.scrollY=this.body.scrollTop;
 338              else if (bw.ie6 || bw.op7){
 339                  if (this.doc.compatMode && document.compatMode != "BackCompat")    this.scrollY=this.doc.documentElement.scrollTop
 340                  else this.scrollY=this.body.scrollTop
 341              }else this.scrollY=this.deftarget.pageYOffset;
 342          }
 343      }
 344  }
 345  /**Onmouseout**/
 346  makeCM.prototype.mout = function(){ //Changed v4.06
 347      var c = this; clearTimeout(c.tim); c.isover = 0; var f="if(!"+c.name+".isover)"+c.name+".hidesub()"
 348    if(!c.closeOnClick) c.tim = setTimeout(f,c.wait)
 349      else{
 350          if(bw.ns4){ document.captureEvents("Event.MOUSEDOWN"); document.onmousedown=new Function(f)}
 351          else document.onclick=new Function(f); 
 352          if(this.frames){
 353              if(bw.ns4){this.doc.captureEvents("Event.MOUSEDOWN"); this.doc.onmousedown=new Function(f)}
 354              else this.doc.onclick=new Function(f)
 355          }
 356      }
 357  }
 358  /**Constructing and initiating top items and bar**/
 359  makeCM.prototype.construct=function(nowrite){ //Changed v4.06
 360    var c=this; if(!c.l[0]||c.l[0].m.length==0) return cm_message('No menus defined');
 361       if(!nowrite){for(var i=1;i<c.l.length;i++){c.l[i].str+="</div>"}} //Added 4.06
 362    c.makeObjects(nowrite); cmpage = new cm_page(); 
 363    var mpa,o,maxw=c.maxw,maxh=c.maxh,i,totw=c.totw,toth=c.toth,m,px=c.pxBetween
 364    var bx=c.l[0].borderX,by=c.l[0].borderY,x=c.fromLeft,y=c.fromTop,mp=c.menuPlacement,rows=c.rows
 365    if(rows){toth=maxh+by*2; totw=totw-px+bx;}else{totw=maxw+bx*2; toth=toth-px+by;}
 366    switch(mp){
 367      case "center": x=cmpage.x2/2-totw/2; if(bw.ns4) x-=9; break;
 368      case "right": x=cmpage.x2-totw; break;
 369      case "bottom": case "bottomcenter": y=cmpage.y2-toth; if(mp=="bottomcenter") x=cmpage.x2/2-totw/2; break;
 370      default: if(mp.toString().indexOf(",")>-1) mpa=1; break;
 371    }for(var i=0;i<c.l[0].m.length;i++){
 372      m = c.m[c.l[0].m[i]]; o = m.b; if(mpa) rows?x=cm_cp(mp[i]):y=cm_cp(mp[i],0,0,1); 
 373      o.moveIt(x,y); o.showIt(); if(m.arr) m.o.arr.showIt(); o.oy=y; 
 374      if(!mpa) rows?x+=m.w+px+bx:y+=m.h+px+by
 375    }if(c.useBar==1){ //Background-Bar
 376      var bbx=c.barBorderX,bby=c.barBorderY; 
 377      var bar1=c.bar1= new cm_makeObj(c.name+'bbar_0',c.name+'bbar',nowrite?0:c.bar1,document)
 378      var bar=c.bar= new cm_makeObj(c.name+'bbar','',nowrite?0:c.bar,document); bar.css.zIndex=c.zIndex+1
 379      var barx=c.barX=="menu"?c.m[c.l[0].m[0]].b.x-bbx:cm_cp(c.barX,1);
 380      var bary=c.barY=="menu"?c.m[c.l[0].m[0]].b.y-bby:cm_cp(c.barY);
 381      var barw=c.barWidth=="menu"?totw:cm_cp(c.barWidth,1,bbx*2);
 382      var barh=c.barHeight=="menu"?toth:cm_cp(c.barHeight,0,bby*2);
 383      bar1.clipTo(0,barw,barh,0,1); bar1.moveIt(bbx,bby); bar1.showIt();
 384      bar.clipTo(0,barw+bbx*2,barh+bby*2,0,1); bar.moveIt(barx,bary); bar.showIt();
 385    }if(c.resizeCheck){ //Window resize code - updated 4.06 - stil sucks
 386      if(bw.ns4||bw.op5||bw.op6)setTimeout('window.onresize=new Function("'+c.name+'.resized()")',500)
 387          else window.onresize=new Function(c.name+".resized()")
 388      c.resized=cm_resized; if(bw.op5||bw.op6) document.onmousemove=new Function(c.name+".resized()")
 389    }if(c.onconstruct) eval(c.onconstruct) //onconstruct event
 390    c.constructed = 1 //Added v4.05
 391    return true
 392  }
 393  /**Capturing resize**/
 394  var cm_inresize=0
 395  function cm_resized(){
 396    if(cm_inresize) return
 397      page2=new cm_page(); var off=(bw.op6||bw.op5)?20:5
 398    if(page2.x2<cmpage.x2-off || page2.y2<cmpage.orgy-off || page2.x2>cmpage.x2+off || page2.y2>cmpage.orgy+off){
 399          if(bw.ie||bw.ns6||bw.op7||bw.ns4){
 400        cmpage=page2; this.isresized=1; 
 401        if(this.onresize) eval(this.onresize); this.construct(1);
 402        if(this.onafterresize) eval(this.onafterresize);
 403          }else{cm_inresize=1; location.reload()} 
 404    }
 405  }
 406  /**Onclick of an item**/
 407  makeCM.prototype.onclck=function(m){ //Changed v4.06
 408    m = this.m[m]
 409    if(m.onclck) eval(m.onclck);
 410      if(this.openOnClick && m.subs.length>0){
 411          this.clicked = 1; this.showsub(m.name); return
 412      } 
 413    var lnk=m.lnk, targ=m.targ
 414    if(lnk){
 415      if(lnk.indexOf("mailto")!=0 && lnk.indexOf("http")!=0) lnk=this.root+lnk
 416          if(String(targ)=="undefined" || targ=="" || targ==0 || targ=="_self"){
 417        if(this.frames){ //Turning of all level 1 + vars
 418          if(this.l[0].a){
 419            this.m[this.l[0].a].active(0,1)
 420            this.l[0].a =0
 421          }
 422          for(i=this.frameStartLevel;i<this.l.length;i++){
 423            if(this.l[i].b){
 424              this.l[i].b.hideIt()
 425              this.l[i].b = null
 426              for(j=0;j<this.l[i].m.length;j++){
 427                this.m[this.l[i].m[j]].b = null;
 428              }
 429            }
 430          }
 431          this.isover=0
 432        }
 433        this.deftarget.location.href=lnk 
 434      }
 435      else if(targ=="_blank") window.open(lnk)
 436      else if(targ=="_top" || targ=="window") top.location.href=lnk
 437      else if(top[targ]) top[targ].location.href=lnk
 438      else if(parent[targ]) parent[targ].location.href=lnk
 439    }else return false
 440  }
 441  
 442  
 443  
 444  bw.filter=(bw.ie55||bw.ie6) && !bw.mac
 445  makeCM.prototype.onshow+=";if(c.l[pm.lev].filter) b.filterIt(c.l[pm.lev].filter)"
 446  cm_makeLevel.prototype.filter=null
 447  cm_makeObj.prototype.filterIt=function(f){
 448    if(bw.filter){
 449      if(this.evnt.filters[0]) this.evnt.filters[0].Stop(); 
 450      else this.css.filter=f; 
 451      this.evnt.filters[0].Apply(); 
 452      this.showIt(); 
 453      this.evnt.filters[0].Play();
 454    }
 455  }
 456  
 457  


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7