home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 April / PCWorld_2002-04_cd.bin / Software / Komercni / abra / coolmenus3_shrinked.js < prev    next >
Text File  |  2002-01-11  |  27KB  |  430 lines

  1. /**************
  2. Copyright (c) 2001 Thomas Brattli (www.dhtmlcentral.com)
  3.  
  4. eXperience DHTML coolMenus - Get it at  www.dhtmlcentral.com
  5. Version 3.02
  6. This script can be used freely as long as all copyright messages are
  7. intact. 
  8. **************/
  9.  
  10. /*************
  11. Pageobject
  12. ***************/
  13. function cm_page(win,fr){
  14.     if(!win) win=window
  15.     this.x=0;this.x2=(bw.ns4 || bw.ns6)?win.innerWidth-1:win.document.body.offsetWidth;
  16.     if(!fr&&bw.ie) this.x2-=20; else if(!fr&&bw.ns4) this.x2-=4; else if(bw.ns6) this.x2+=1
  17.     this.y=0;this.y2=(bw.ns4 || bw.ns6)?win.innerHeight:win.document.body.offsetHeight;
  18.     if(bw.ns4&&!win.rows) this.x2+=5; if(!fr&&bw.ie) this.y2-=4; else if(bw.ns4&&fr) this.y2+=4
  19.     this.y2orig=this.y2; this.x50=this.x2/2; this.y50=this.y2/2; return this;
  20. }
  21. /*************
  22. Debugging function
  23. ***************/
  24. function debug(txt,ev){if(mDebugging==2) self.status=txt; else alert(txt); if(ev) eval(ev); return false}
  25. /************
  26. Scroll function
  27. *************/
  28. function cm_cScroll(obj){
  29.     if(bw.ns4 || bw.ns6) obj.scrolledY=obj.win.pageYOffset
  30.     else obj.scrolledY=obj.win.document.body.scrollTop
  31.     if(obj.scrolledY!=obj.lastScrolled){
  32.         if(!obj.useframes){
  33.             for(i=0;i<obj.l[0].num;i++){var sobj=obj.l[0].o[i].oBorder; sobj.moveY(sobj.y+(obj.scrolledY-obj.lastScrolled))}
  34.             if(obj.usebar) obj.oBar.moveY(obj.oBar.y+(obj.scrolledY-obj.lastScrolled))
  35.         }
  36.         obj.lastScrolled=obj.scrolledY; page.y=obj.scrolledY; page.y2=page.y2orig+obj.scrolledY
  37.         if(!obj.useframes || bw.ie){ clearTimeout(obj.tim); obj.isover=0; obj.hideSubs(1,0)}
  38.     }if((bw.ns4 || bw.ns6) && !obj.useframes) setTimeout("cm_cScroll("+obj.name+")",200)
  39. }
  40. /***********************
  41. Checking if the values are % or not.
  42. ***************/
  43. function cm_checkp(num,w,check,istop,ds){
  44.     if(num){ var p=istop?toppage:page
  45.         if(num.toString().indexOf("%")!=-1){if(w || (check && this.rows)) num=(p.x2*parseFloat(num)/100)
  46.         else num=(p.y2*parseFloat(num)/100)
  47.         }else num=eval(num)
  48.     }else num=0; return num
  49. }
  50. /************
  51. Making DIV objects + DIV objects code
  52. *************/
  53. function cm_obj(obj,name,level,win,nest,o){
  54.     if(o&&(bw.ns4||bw.ns6)) this.evnt=o
  55.     else this.evnt=bw.dom?win.document.getElementById(obj):bw.ie4?win.document.all[obj]:bw.ns4?nest?win.document[nest].document[obj]:win.document[obj]:0;
  56.     if(!this.evnt) return debug('There seems to be an error with this layer:\nFrame: '+win+'\nLayer: '+nest + "." + obj)
  57.     this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;    this.ref=bw.dom || bw.ie4?win.document:bw.ns4?this.css.document:0;
  58.     this.hideIt=cm_hideIt; this.showIt=cm_showIt; this.writeIt=cm_writeIt; this.seta=cm_seta; this.addEvents=cm_addEvents; 
  59.     this.moveIt=cm_moveIt; this.clipTo=cm_clipTo; if(name) this.parent=name; this.moveY=cm_moveY; this.l=level; this.clipOut=cm_clipOut; 
  60.     this.filterIt=cm_filterIt; this.obj = obj + "Object";     eval(this.obj + "=this"); this.tim=10; this.clipy=0; return this
  61. }
  62. function cm_writeIt(text){if(!this.img1){if(bw.ns4){this.ref.write(text);
  63. this.ref.close()}else this.evnt.innerHTML=text}}; function cm_moveY(y){this.y=y; this.css.top=y}
  64. function cm_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}
  65. function cm_showIt(){this.css.visibility="visible"; this.vis=1}; function cm_hideIt(){this.css.visibility="hidden"; this.vis=0}
  66. function cm_clipOut(px,w,ystop,tim,name){
  67.     if(!this.vis) return; if(this.clipy<ystop-px){this.clipy+=px; this.clipTo(0,w,this.clipy,0,1)
  68.         this.tim=setTimeout(this.obj+".clipOut("+px+","+w+","+ystop+","+tim+",'"+name+"')",tim)
  69.     }else{if(bw.ns6){this.hideIt();}; this.clipTo(0,w,ystop,0,1); if(bw.ns6){this.showIt()}}
  70. }
  71. function cm_filterIt(f){if(this.evnt.filters[0]) this.evnt.filters[0].Stop(); else this.css.filter=f; this.evnt.filters[0].Apply(); this.showIt(); this.evnt.filters[0].Play();}
  72. function cm_seta(on,name,frmmouse){
  73.     if(!name) name=this.name; var tobj=this.parent.m[name]
  74.     if(tobj.img){if(tobj.img2){if(on) this.ref.images[tobj.img].src=tobj.img2; else this.ref.images[tobj.img].src=tobj.img1}
  75.     }else{
  76.         if(on){var color=tobj.c2; var fcolor=tobj.c4; var re=tobj.c3}else{var color=tobj.c1; var fcolor=tobj.c3; var re=tobj.c4}
  77.         if(color){if(bw.dom || bw.ie4) this.css.backgroundColor=color; else if(bw.ns4) if(color=="transparent") color=null; this.css.bgColor=color}
  78.         if(fcolor && !bw.ns4){if(bw.ie4) this.evnt.style.color=fcolor; else if(this.evnt.childNodes[0]) this.evnt.style.color=fcolor
  79.         }else if(fcolor&&frmmouse){t=this.parent.m[name].text; t=t.replace(re,fcolor); this.writeIt(t); if(on) this.addEvents(name,this.parent.name,tobj.lnk,this.parent.useclick)}
  80.         if(tobj.l==0&&bw.ns6){this.parent.l[0].o[tobj.num].oBorder.hideIt(); this.parent.l[0].o[tobj.num].oBorder.showIt();} //Stupid fix for netscape 6....
  81.     }
  82. }
  83. function cm_clipTo(t,r,b,l,w){if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r; this.css.clip.bottom=b;this.css.clip.left=l
  84. }else{this.css.clip="rect("+t+","+r+","+b+","+l+")"; if(w){this.css.width=r; this.css.height=b}}; this.width=r; this.height=b}
  85. function cm_addEvents(n,name,url,useclick){
  86.     this.evnt.onmouseover=new Function(name+".mover('"+n+"')"); 
  87.     this.evnt.onmouseout=new Function(name+".mmout('"+n+"')")
  88.     if(!url && useclick) ev=new Function(name+".mover('"+n+"',1)")
  89.     else ev=new Function(name+".go('"+n+"')")
  90.     if(bw.ns4){this.ref.captureEvents(Event.MOUSEDOWN); this.ref.onmousedown=ev}
  91.     else this.evnt.onclick=ev
  92. }
  93. /************
  94. Making menu object
  95. *************/
  96. function cm_makeMenu(name,parent,text,link,target,width,height,img1,img2,bgcoloroff,bgcoloron,textcolor,hovercolor,onclick,onmouseover,onmouseout){
  97.     this.m[name]=new Object(); var obj=this.m[name]; obj.name=name;    obj.subs=new Array(); obj.parent=parent; var tt, ll
  98.     obj.lnk=(link==0||link=='')?"":link; obj.target=target
  99.     if(parent!="" && parent){this.m[parent].subs[this.m[parent].subs.length]=name; l=this.m[parent].l+1} else l=0
  100.     obj.l=l; p=l<this.level.length?this.level[l]:this.level[this.level.length-1]; p2=this.level[0]
  101.     if(this.l.length<=l){
  102.         this.l[l]=new Object(); ll=this.l[l]; ll.num=0; if(l==0) ll.names=new Array()
  103.         ll.clip=p["clip"]||p2["clip"]||0; ll.clippx=p["clippx"]||p2["clippx"]||0
  104.         ll.cliptim=p["cliptim"]||p2["cliptim"]||0; ll.filter=p["filter"]||p2["filter"]||0
  105.         ll.border=p["border"]||p2["border"]; ll.maxnum=0
  106.         ll.bordercolor=p["bordercolor"]||p2["bordercolor"];
  107.         s=p["align"]||p2["align"]; if(s=="left") s=1; else if(s=="right") s=0; 
  108.         else if(s=="top") s=3; else if(s=="bottom") s=2; ll.align=s; this.aobj[l]=-1;
  109.         ll.height=p["height"]||p2["height"]; ll.width=p["width"]||p2["width"];
  110.         ll.style=p["style"]||p2["style"]; ll.tc=textcolor||p.textcolor||p2.textcolor; 
  111.         ll.offsetX=String(p["offsetX"])!="undefined"?p["offsetX"]:p2["offsetX"]
  112.         this.l[l].offsetY=String(p["offsetY"])!="undefined"?p["offsetY"]:p2["offsetY"]
  113.     }if(l==0) this.l[l].names[this.l[l].names.length]=name
  114.     if(parent!="" && parent){obj.num=this.m[parent].subs.length-1}else obj.num=this.l[l].num
  115.     this.l[l].num++; prop=l<this.level.length?this.level[l]:this.level[this.level.length-1]
  116.     obj.width=this.checkp(width?width:p.width?p.width:p2.width,1,0,1);
  117.     obj.height=this.checkp(height?height:p.height?p.height:p2.height,0,0,1);
  118.     if(parent!="" && parent){if(this.m[parent].subs.length>this.l[l].maxnum) this.l[l].maxnum=this.m[parent].subs.length 
  119.         if(this.m[parent].totheight==0) this.m[parent].totheight=this.l[l].border
  120.         this.m[parent].totheight+=obj.height+ this.l[l].border
  121.         if(this.m[parent].maxwidth<obj.width) this.m[parent].maxwidth=obj.width+this.l[l].border*2
  122.     }else{this.l[l].maxnum=this.l[l].names.length; this.totwidth+=obj.width; this.totheight+=obj.height
  123.         this.maxwidth=this.maxwidth>obj.width?this.maxwidth:obj.width; this.maxheight=this.maxheight>obj.height?this.maxwidth:obj.height
  124.     }if(img1) text='<img src="'+img1+'" border="0" name="imgCMenu'+name+'">'
  125.     else if(bw.ns4){text='<font size="'+(p.NS4fontSize||p2.NS4fontSize)+'" face="'+(p.NS4font||p2.NS4font)+'" color="'+(textcolor||this.l[l].tc)+'">'+text+'</font>'}
  126.     if(bw.ns4&&this.useNS4links&&(l==0||!this.useframes) ||(l==0&&img1)){tt=img1&&l==0?this.useclick?this.name+".mover('"+name+"',1);":this.name+".go('"+name+"');":"";text='<a href="#" onclick="'+tt+'return false" class="clNS4">'+text+'</a>'}
  127.     if(img1){obj.preimg1=new Image(); obj.preimg1.src=img1}; if(img2){obj.preimg2=new Image(); obj.preimg2.src=img2}
  128.     if(img2) obj.img="imgCMenu"+name; else obj.img=0; obj.img1=img1||""; obj.img2=img2||""; obj.text=text; obj.subx=-1;
  129.     obj.c1=bgcoloroff||p.bgcoloroff||p2.bgcoloroff; obj.c2=bgcoloron||p.bgcoloron||p2.bgcoloron;
  130.     obj.c3=textcolor||this.l[l].tc; obj.c4=hovercolor||p.hovercolor||p2.hovercolor;  obj.suby=-1;
  131.     obj.mclick=onclick||""; obj.mover=onmouseover||""; obj.mout=onmouseout||"";    obj.totheight=0; obj.maxwidth=0; 
  132. }
  133. /************
  134. Onmouseout
  135. *************/
  136. function cm_mout(name,cl){
  137.     if(!name&&cl&&!this.isover){this.isclicked=0; this.hideSubs(1,0,0,0,1);  this.aobj[0]=-1; return}
  138.     if(!name) return; var l=this.m[name].l;
  139.     if((this.m[name].subs.length==0||!this.loaded)||(this.useclick&&!this.isclicked)){if((this.aobj[l+1]==-1||l>=this.l.length-1)&&this.aobj[l]!=-1){this.aobj[l].seta(0,0,1); this.aobj[l]=-1;}}
  140.     if(this.m[name].mout!="") eval(this.m[name].mout)
  141.     if(this.useclick){this.isover=0; return}; clearTimeout(this.tim); 
  142.     if(!(!bw.ie&&this.useframes&&l==0&&this.aobj1)){ this.isover=0; this.aobj1=0; this.tim=setTimeout(this.name+".hideSubs(1,0,0,0,1)",this.wait)} 
  143. }
  144. /************
  145. Onmouseover
  146. *************/
  147. function cm_mover(name,cl){
  148.     clearTimeout(this.tim); this.isover=1; var l=this.m[name].l;
  149.     if(this.aobj[l].name==name){
  150.         if(this.aobj[l+1]!=-1 && l<this.l.length-1){
  151.             this.aobj[l+1].seta(0,0,1); this.aobj[l+1]=-1; this.hideSubs(l+2,1); return
  152.         }else if((!this.useclick)||(this.useclick&&this.isclicked)) return
  153.     }if(this.m[name].mover!="") eval(this.m[name].mover)
  154.     var num=this.m[name].num; var obj=this.l[l].o[num]
  155.     if(this.aobj[l].name!=name){if(this.aobj[l]!=-1) this.aobj[l].seta(0,0,1); this.aobj[l]=obj; this.aobj[l].name=name; obj.seta(1,0,1)}
  156.     if(l==1)this.aobj1=1; if(l==0 && cl && this.useclick) this.isclicked=1; 
  157.     if(!this.isclicked&&this.useclick) return; if(!this.loaded) return;
  158.     this.showSubs(name,l,num,cl)
  159. }
  160. /************
  161. Hiding subelements
  162. *************/
  163. function cm_hideSubs(l,system,cl,sys2,hc){
  164.     if(this.isover && !system) return
  165.     if(l==1 && this.aobj[0]!=-1&&!sys2){this.aobj[0].seta(0,0,1);this.aobj[0]=-1}
  166.     if(!this.loaded) return; if(cl==1) return
  167.     for(i=l;i<this.l.length;i++){if(this.l[i].oBorder.vis==0) break; this.l[i].oBorder.hideIt(); this.aobj[i]=-1;}
  168.     if(hc&&this.hcode){eval(this.hcode); this.hcode=""}
  169. }
  170. /************
  171. Get x/y coords. Only the first time :)
  172. *************/
  173. function cm_getCoords(name,l,num,topalign,align,ln,border,cn,lev1b){
  174.     if(cn==5){ this.m[name].subx=0; this.m[name].suby=0; return }//Just in case infinitive loops
  175.     if(l==1) var pobj=this.l[l-1].o[num].oBorder
  176.     else var pobj=this.l[l-1].oBorder
  177.     var x=pobj.x; var y=pobj.y;
  178.     if(l!=1){y+=this.l[l-1].o[num].y}
  179.     pborder=this.l[l-1].border; 
  180.     lx=x+pobj.width; rx=x-this.m[name].maxwidth- (this.l[l-1].offsetX*2)
  181.     if(align==0){if(l==1){y+=border} if(l==1&&this.useframes) x=0; else x=lx
  182.     }else if(align==1){x=rx; if(l==1){if(this.useframes) x=page.x2 - this.m[name].maxwidth; y+=border}}
  183.     if((align==2||topalign==2)&&lev1b!=3){
  184.         if(l!=1 && (align!=1&&align!=0)){if(topalign==1) x=rx; else x=lx}
  185.         if(l==1) if(this.useframes) y=0; else y+=this.m[name].height+border+pborder;
  186.     }if((align==3||topalign==3)&&lev1b!=2){
  187.         if(l!=1&&align!=1&&align!=0){if(topalign==1) x=rx; else x=lx}
  188.         if(this.useframes&&l==1) y=page.y2 - this.m[name].totheight - this.l[l-1].offsetY*2
  189.         else y-=this.m[name].totheight - this.l[l].offsetY*2; if(l!=1||lev1b==3) y+=this.m[name].height
  190.     }this.m[name].scrollY=this.lastScrolled; this.m[name].subx=x+this.l[l-1].offsetX; 
  191.     this.m[name].suby=y+this.l[l-1].offsetY; if(this.useframes&&l==1&&align!=3) this.m[name].suby+=this.lastScrolled
  192.     if(this.pagecheck&&(l!=1||!this.useframes)) this.checkPage(name,l,num,topalign,align,ln,border,cn)
  193. }
  194. /************
  195. Checking page coords
  196. *************/
  197. function cm_checkPage(name,l,num,topalign,align,ln,border,cn){
  198.     cn++; 
  199.     if(this.m[name].subx+this.m[name].maxwidth>page.x2){
  200.         if(align!=1){if(align==3&&topalign!=0) topalign=3; align=1; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
  201.     }else if(this.m[name].subx<page.x){
  202.         if(align!=0){if(align==3) topalign=3; align=0; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
  203.     }else if((this.m[name].suby+this.m[name].totheight)>page.y2){
  204.         if(l==1){topalign=3; this.getCoords(name,l,num,topalign,align,ln,border,cn,3)}
  205.         else if(align!=3){ align=3; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
  206.     }else if(this.m[name].suby<page.y){
  207.         if(l==1){topalign=2; this.getCoords(name,l,num,topalign,align,ln,border,cn,2)}
  208.         else if(align!=2){align=2; this.getCoords(name,l,num,topalign,align,ln,border,cn)}
  209.     }
  210. }
  211. /************
  212. Showing subelements
  213. *************/
  214. function cm_showSubs(name,l,num,cl){
  215.     l+=1; if(l>=this.l.length) return; ln=this.m[name].subs.length
  216.     if(ln==0){this.hideSubs(l,1,0,1); return}
  217.     else this.hideSubs(l+1,1); var border=this.l[l].border; this.aobj[l]=-1
  218.     if(this.useframes&&(bw.ns4||bw.ns6)) cm_cScroll(this)
  219.     if((this.m[name].subx==-1 || this.m[name].suby==-1) || this.m[name].scrollY!=this.lastScrolled || this.isresized){
  220.         var topalign=this.l[0].align; var align=this.l[l-1].align; 
  221.         this.getCoords(name,l,num,topalign,align,ln,border,0)
  222.     }var x=this.m[name].subx; var y=this.m[name].suby;
  223.     var bobj=this.l[l].oBorder; bobj.hideIt(); 
  224.     if(this.l[l-1].clip&&!(this.l[l-1].filter&&bw.filter)){
  225.         clearTimeout(bobj.tim); bobj.clipy=0; bobj.clipTo(0,this.m[name].maxwidth,0,0);
  226.     }else bobj.clipTo(0,this.m[name].maxwidth,this.m[name].totheight,0,1)
  227.     bobj.moveIt(x,y); var yy=border
  228.     for(i=0;i<this.l[l].maxnum;i++){
  229.         var obj=this.l[l].o[i]
  230.         if(i<ln){
  231.             var n=this.m[name].subs[i]; obj.aname=n; if(!bw.ns4||!this.NS4hover) obj.writeIt(this.m[n].text)
  232.             obj.addEvents(n,this.name,this.m[n].lnk,this.useclick); var w=this.m[n].width; var h=this.m[n].height
  233.             if(obj.y!=yy) obj.moveY(yy); yy+=h+border; if(!obj.img) obj.seta(0,n,1); 
  234.             if(obj.width!=w||obj.height!=h) obj.clipTo(0,w,h,0,1); obj.css.visibility="inherit"
  235.         }else obj.hideIt()
  236.     }if(this.l[l-1].filter&&bw.filter) bobj.filterIt(this.l[l-1].filter)
  237.     else if(this.l[l-1].clip){bobj.showIt(); bobj.clipOut(this.l[l-1].clippx,this.m[name].maxwidth,this.m[name].totheight,this.l[l-1].cliptim,name);}
  238.     else bobj.showIt(); 
  239.     if(!bw.ns4&&this.checkselect){ //CHECKING FOR SELECT BOXES
  240.         for(i=0;i<this.sel.length;i++){
  241.             selx=0; sely=0; var selp;
  242.             if(this.sel[i].offsetParent){selp=this.sel[i]; while(selp.offsetParent){selp=selp.offsetParent; selx+=selp.offsetLeft; sely+=selp.offsetTop;}}
  243.             selx+=this.sel[i].offsetLeft; sely+=this.sel[i].offsetTop
  244.             selw=this.sel[i].offsetWidth; selh=this.sel[i].offsetHeight
  245.             if(((selx+selw)>this.m[name].subx && selx<(this.m[name].subx+this.m[name].maxwidth))
  246.             &&((sely+selh)>this.m[name].suby && sely<(this.m[name].suby+this.m[name].totheight))){
  247.                 if(this.sel[i].style.visibility!="hidden"){this.sel[i].level=l; this.sel[i].style.visibility="hidden"; this.hcode+=this.name+".sel["+i+"].style.visibility='visible';"}
  248.             }else if(l<=this.sel[i].level) this.sel[i].style.visibility="visible"
  249.         }
  250.     }else if(bw.ns4&&this.hideForm){eval(this.hideForm+".visibility='hide'"); this.hcode=this.hideForm+".visibility='show'"}
  251. }
  252. /************
  253. Making all top elements
  254. *************/
  255. function cm_makeTop(rr){
  256.     var m,rows,border,x,y,mpa
  257.     m=this.menuplacement; rows=this.rows; this.pxbetween=this.checkp(this.pxbetween,0,1,1)
  258.     border=this.l[0].border;y=this.checkp(this.fromtop,0,0,1)+border;x=this.checkp(this.fromleft,0,0,1)+border
  259.     if(m=="bottomcenter"||m=="bottom"){
  260.         if(m=="bottomcenter") x=toppage.x2/2-(this.totwidth+border*this.l[0].num+this.pxbetween*(this.l[0].num-1))/2
  261.         y=toppage.y2-this.maxheight-border
  262.     }else if(m=="right") x=toppage.x2-this.maxwidth-border*2
  263.     else if(m=="bottom") y=toppage.y2-this.maxheight-border*2
  264.     else if(m=="center"){if(rows==0) x=toppage.x2/2 -  (this.maxwidth+border*2)/2; else x=toppage.x2/2 - (this.totwidth + border*this.l[0].num +this.pxbetween*(this.l[0].num-1))/2}
  265.     else if(m.toString().indexOf(",")>-1) mpa=1
  266.     if(this.usebar){ var bx,by,bww,bh,oBb
  267.         oNS=bw.ns6?this.oNS[this.l[0].maxnum]:0
  268.         this.oBar=new cm_obj('div'+this.name+'Bar',0,0,window,0,oNS)
  269.         if(this.barx=="menu") bx=mpa&&rows?this.checkp(m[0],1,0,1)-border:x-border; else{ bx=this.checkp(this.barx,1,0,1) }
  270.         if(this.bary=="menu") by=mpa&&!rows?this.checkp(m[0],0,0,1)-border:y-border; else by=this.checkp(this.bary,0,0,1);  this.oBar.moveIt(bx,by)
  271.         if(this.barwidth=="menu"){bww=rows?mpa?(this.checkp(m[m.length-1],1,0,1)-bx)+this.m[this.l[0].names[this.l[0].num-1]].width+border:(this.totwidth +this.pxbetween*(this.l[0].num-1)):this.maxwidth; 
  272.         bww+=!rows?border*2:0;}else bww=this.checkp(this.barwidth,1,0,1); 
  273.         if(bw.ie&&rows&&this.barwidth=="100%"&&this.useframes) bww+=parseInt(self.document.body.leftMargin)*2
  274.         if(this.barheight=="menu"){bh=!rows?mpa?(this.checkp(m[m.length-1],0,0,1)-by)+this.m[this.l[0].names[this.l[0].num-1]].height+border:(this.totheight + this.pxbetween*(this.l[0].num-1)):this.maxheight;
  275.         bh+=rows?this.l[0].border*2:0;} else bh=this.checkp(this.barheight,0,0,1);
  276.         this.oBar.clipTo(0,bww,bh,0,1);
  277.         if(this.barinheritborder&&border){oBb=new cm_obj('div'+this.name+'Barb',0,0,window,'div'+this.name+'Bar'); 
  278.         oBb.moveIt(border,border); oBb.clipTo(0,bww-border*2,bh-border*2,0,1); oBb=null;}
  279.     }this.l[0].o=new Array()
  280.     for(j=0;j<this.l[0].maxnum;j++){
  281.         this.l[0].o[j]=new cm_obj('div'+this.name+'0_'+j,this,0,window,'div'+this.name+'0_'+j+'b'); if(bw.ns6) oNS=this.oNS[j]; else oNS=0
  282.         this.l[0].o[j].oBorder=new cm_obj('div'+this.name+'0_'+j+'b',0,0,window,0,oNS)
  283.         obj=this.l[0].o[j]; w=this.m[this.l[0].names[j]].width; h=this.m[this.l[0].names[j]].height
  284.         obj.addEvents(this.l[0].names[j],this.name,this.m[this.l[0].names[j]].lnk,this.useclick); obj.clipTo(0,w,h,0,1)
  285.         if(mpa){if(rows==1) x=this.checkp(m[j],0,1,1); else y=this.checkp(m[j],0,0,1)}
  286.         obj.moveIt(border,border); 
  287.         obj.seta(0,this.l[0].names[j])
  288.         obj.oBorder.moveIt(x-border,y-border); obj.oBorder.clipTo(0,w+border*2,h+border*2,0,1); obj.oBorder.showIt()
  289.         if(rows==0) y+=h+border+this.pxbetween
  290.         else x+=w+border+this.pxbetween; obj.showIt()
  291.     }if(!rr){
  292.         if(this.useclick) coolFMouseup+=this.name+".mmout('',1);"; if(!this.useframes&&!bw.ns4) this.refresh()
  293.         else if(!this.useframes&&bw.ns4){l=""; if(onload){l=String(onload.toString()); l=l.replace("function onload(event)",""); l=l.slice(25,l.length-2)} l+=this.name+ ".refresh();"; onload=new Function(l)}
  294.         if(this.resizecheck) setTimeout('window.onresize=new Function("'+this.name+'.resized()")',500)
  295.         if(this.checkscroll){if(bw.ns4 || bw.ns6){if(this.checkscroll!=2&&this.useframes!=1){setTimeout("cm_cScroll("+this.name+")",200)}}}
  296.         if(this.useframes&&!rr) this.checkFrame(0); else this.win=window
  297.     }
  298. }
  299. /************
  300. Refreshing/making all sub elements
  301. *************/
  302. function cm_refresh(ev){
  303.     var border,obj,oNS,oNS2
  304.     if(this.useframes) page=new cm_page(this.win,this.useframes); else page=toppage
  305.     for(i=1;i<this.l.length;i++){
  306.         this.l[i].o=new Array();
  307.         border=this.l[i].border; defheight=this.checkp(this.l[i].height)
  308.         if(bw.ns4){oNS=new Layer(this.l[i].width,this.win); oNS.zIndex=(500+i);  if(this.l[i].border) oNS.bgColor=this.l[i].bordercolor;}
  309.         else if(bw.ns6){oNS=document.createElement("DIV"); oNS.setAttribute("style",this.ns6styleb[i]); this.win.document.body.appendChild(oNS)}
  310.         this.l[i].oBorder=new cm_obj('div'+this.name+i+"b",0,0,this.win,0,oNS)
  311.         for(j=0;j<this.l[i].maxnum;j++){
  312.             if(bw.ns4){oNS2=new Layer(this.l[i].width,oNS);}
  313.             else if(bw.ns6){oNS2=document.createElement("DIV");    oNS2.setAttribute("style",this.ns6style[i]); oNS.appendChild(oNS2)}
  314.             this.l[i].o[j]=new cm_obj('div'+this.name+i+'_'+j,this,i,this.win,0,oNS2)
  315.             obj=this.l[i].o[j]; if(!obj.addEvents) return; obj.moveIt(border,(border+defheight)*j + border)
  316.         }    
  317.     }this.loaded=1;
  318.     if(this.checkscroll&&bw.ie){this.win.document.body.onscroll=new Function("cm_cScroll("+this.name+")"); cm_cScroll(this)}
  319.     if(this.useclick){this.win.document.onmouseup=new Function(coolFMouseup); if(this.useframes) document.onmouseup=new Function(coolFMouseup); }
  320.     if(!bw.ns4&&this.checkselect) this.sel=bw.ie4?this.win.document.all.tags("SELECT"):this.win.document.getElementsByTagName("SELECT")
  321. }
  322. function cm_NS6_createElement(st,inn){el=document.createElement("DIV"); if(st) el.setAttribute("style",st); if(inn) el.innerHTML=inn; document.body.appendChild(el); return el}
  323. /************
  324. Making code
  325. *************/
  326. function cm_construct(){
  327.     this.level=null; var str=""; var str2=""; var frstr=""; var tempstr; num=bw.ie?this.l.length:1;
  328.     for(i=0;i<num;i++){
  329.         if(i!=0) frstr+='<div id="div'+this.name+i+'b" style="'+this.ns6styleb[i]+'" class="cl'+this.name+i+'b">\n'
  330.         for(j=0;j<this.l[i].maxnum;j++){
  331.             tempstr='<div id="div'+this.name+i+'_'+j+'" '; if(i!=0) tempstr+='style="'+this.ns6style[i]+'"'
  332.             if(i==0){n=this.l[0].names[j]; txt=this.m[n].text
  333.                 if(!bw.ns6){
  334.                     str+='<div id="div'+this.name+'0_'+j+'b" class="cl'+this.name+'b'+i+'">'
  335.                     str+=tempstr+' class="cl'+this.name+i+'">'+txt+'</div>'; str+='</div>\n'
  336.                 }else this.oNS[j]=cm_NS6_createElement(this.ns6styleb[i],tempstr+' class="cl'+this.name+i+'">'+txt+'</div>')
  337.             }else frstr+=tempstr+'"></div>\n'
  338.         }if(i!=0){frstr+='</div>\n'}
  339.     }if(this.usebar){
  340.         if(this.barinheritborder) str2='<div id="div'+this.name+'Barb"></div>'; 
  341.         if(bw.ns6) this.oNS[this.l[0].maxnum]=cm_NS6_createElement(this.ns6styleb[this.ns6styleb.length-1],str2)
  342.         else{str+='<div id="div'+this.name+'Bar">';str+=str2+'</div>\n'}
  343.     }if(!this.useframes&&bw.ie) str+=frstr; else this.frstr=frstr; if(!bw.ns6) document.write(str)
  344.     this.makeTop();    if(this.useframes) window.onerror=cm_check_error;
  345. }
  346. /**************
  347. Make styles
  348. **************/
  349. function cm_makeStyle(){
  350.     var str="<style>\n"; var zindex=150;  var c,w,st,bg
  351.     this.ns6style=new Array(); this.ns6styleb=new Array()
  352.     for(i=0;i<this.l.length;i++){
  353.         if(i==0){if(bw.ns4){w="width:" +this.l[0].width+";"; this.l[i].style=""} else w=""; str+='.cl'+this.name+i+'{position:absolute; '+w+' background-color:transparent; color:'+this.l[i].tc+';'+this.l[i].style+'; cursor:pointer; cursor:hand; visibility:inherit; z-index:'+zindex+'}\n'}
  354.         else{st='position:absolute; '+this.l[i].style+';  cursor:pointer; cursor:hand; visibility:inherit; z-index:'+zindex; this.ns6style[i]=st}
  355.         bc=this.l[i].border?bw.ns4?'layer-background-color:'+this.l[i].bordercolor:'; background-color:'+this.l[i].bordercolor:"";
  356.         if(!bw.ns4) bc+="; overflow:hidden"
  357.         tempstr='position:absolute; clip:rect(0,0,0,0); visibility:hidden; '+bc+'; z-index:'+(zindex-50)
  358.         if(i==0&&!bw.ns6) str+='.cl'+this.name+'b'+i+'{'+tempstr+'}\n'; 
  359.         else this.ns6styleb[i]=tempstr; zindex+=100
  360.     }    
  361.     if(this.usebar){
  362.         bg=this.barinheritborder?this.l[0].bordercolor:this.barcolor
  363.         st='z-index:80; position:absolute; background-color:'+bg+'; layer-background-color:'+bg
  364.         if(!bw.ns6) str+='#div'+this.name+'Bar{'+st+'}\n'; else this.ns6styleb[this.ns6styleb.length]=st
  365.         if(this.barinheritborder){str+='#div'+this.name+'Barb{z-index:85; position:absolute; background-color:'+this.barcolor+'; layer-background-color:'+this.barcolor+'}\n'}
  366.     }
  367.     if(bw.ns4) str+="A.clNS4{text-decoration:none; padding:"+this.NS4padding+"}\n"; document.write(str+"\n</style>\n")
  368. }
  369. /************
  370. Refreshing page if it's resized
  371. *************/
  372. function cm_resized(){
  373.     page2=new cm_page(window,this.useframes); 
  374.     if(page2.x2!=toppage.x2 || page2.y2!=toppage.y2){
  375.         if(!bw.ns4){
  376.             toppage=new cm_page(window,this.useframes); this.makeTop(1)
  377.             if(!this.useframes) page=toppage; this.isresized=1; eval(this.resizecode)
  378.         }else{this.win.location.reload(); location.reload()}
  379.     }if(!bw.ns4&&this.useframes){page=new cm_page(this.win,this.useframes)}
  380. }
  381. /************
  382. Going to another page
  383. *************/
  384. function cm_go(name){
  385.     obj=this.m[name]; url=obj.lnk; target=obj.target; fc=obj.mclick
  386.     if(url){
  387.         if(this.useframes&&!coolFrameError) loc=this.win.location.href; else loc=location.href
  388.         if(fc) eval(fc); url=this.checkFolder(loc.toString(),url); this.isover=0;
  389.         this.hideSubs(1,0,1); this.isclicked=0; this.aobj[0]=-1
  390.         if(String(target)=="undefined" || target=="" || target==0 || target=="_self"){
  391.             this.win.location.href=url
  392.         }else if(target=="_blank") window.open(url)
  393.         else if(target=="_top" || target=="window") top.location.href=url  
  394.         else if(top[target]) top[target].location.href=url
  395.         else{fr=findFrame(target); if(fr) fr.location.href=url}
  396.     }else if(fc) eval(fc)
  397. }
  398. /************
  399. Getting folders - THANKS TO DCAGE FOR THIS FIX
  400. *************/
  401. function cm_checkFolder(tmp,url){
  402.     if(url.indexOf("mailto:")>-1 || url.indexOf("/")==0 || url.indexOf("http://")==0) return url
  403.     else if(this.useframes && bw.ie || bw.ns6) return url
  404.     var addr=''; var lvl=''; var off_cnt=0; var cnt=0;
  405.     if(tmp.indexOf('file:')>-1 || tmp.charAt(1)==':') addr=this.offlineUrl;
  406.     else if(tmp.indexOf('http:')>-1) addr=this.onlineUrl;
  407.     for(var i=0;i<addr.length;i++){if(addr.charAt(i)=='\/') off_cnt+=1}
  408.     for(var i=0;i<tmp.length;i++){if(tmp.charAt(i)=='\/'){ cnt+=1; if(cnt>off_cnt) lvl+='../'; }}
  409.     return lvl + url
  410. }
  411. /************
  412. Make menu object
  413. *************/
  414. var coolFName=""; var onload; var coolFMouseup="";
  415. function makeCoolMenu(name){
  416.     coolFName=name; this.name=name; this.lastScrolled=0;
  417.     this.win=window; toppage=new cm_page(window,parent.frames.length);
  418.     this.aobj=new Array(); this.m=new Array(); this.l=new Array()
  419.     this.level=new Array(); this.resized=cm_resized;
  420.     this.makeMenu=cm_makeMenu; this.showSubs=cm_showSubs; this.makeTop=cm_makeTop;
  421.     this.getCoords=cm_getCoords; this.checkPage=cm_checkPage;
  422.     this.mmout=cm_mout; this.mover=cm_mover; this.checkp=cm_checkp;
  423.     this.hideSubs=cm_hideSubs; this.construct=cm_construct;
  424.     this.makeStyle=cm_makeStyle; this.refresh=cm_refresh;
  425.     this.go=cm_go; this.frstr=""; this.mobj=new Array()
  426.     this.totwidth=0; this.totheight=0; this.maxwidth=0; this.maxheight=0
  427.     this.tim=10; this.loaded=0; this.isover=false; 
  428.     this.checkFolder=cm_checkFolder; this.hcode=""; this.oNS=new Array(); this.oNS2=new Array()
  429.     bw.filter=(bw.ie6||bw.ver.indexOf("MSIE 5.5")>-1) && !bw.mac
  430. }