// Title: COOLjsMenuPRO // URL: http://javascript.cooldev.com/scripts/coolmenupro/ // Version: 2.1.0 // Last Modify: 26 May 2003 // Author: Sergey Nosenko // Notes: Registration needed to use this script on your web site. // Copyright (c) 2001-2002 by CoolDev.Com // Copyright (c) 2001-2002 by Sergey Nosenko window.CMenus=[]; var BLANK_IMAGE="/images/pixel.gif"; function bw_check(){var is_major=parseInt(navigator.appVersion);this.nver=is_major;this.ver=navigator.appVersion;this.agent=navigator.userAgent;this.dom=document.getElementById?1:0;this.opera=window.opera?1:0;this.ie55=(this.ver.indexOf("MSIE 5.5")>-1&&this.dom&&!this.opera)?1:0;this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.ie55&&!this.opera)?1:0;this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera)?1:0;this.ie4=(document.all&&!this.dom&&!this.opera)?1:0;this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;this.ie3=(this.ver.indexOf("MSIE")&&(is_major<4));this.hotjava=(this.agent.toLowerCase().indexOf('hotjava')!=-1)?1:0;this.ns4=(document.layers&&!this.dom&&!this.hotjava)?1:0;this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera);this.ver3=(this.hotjava||this.ie3);this.opera7=((this.agent.toLowerCase().indexOf('opera 7')>-1) || (this.agent.toLowerCase().indexOf('opera/7')>-1));this.operaOld=this.opera&&!this.opera7;return this}; function none(){} function nn(val){return val != null} function und(val){return typeof(val)=='undefined'} function COOLjsMenuPRO(name, items){ this.bw=new bw_check(); this.bi=new Image(); this.bi.src=BLANK_IMAGE; if (this.bw.ns4) window.onresize=resizeHandler; window.CMenus[name]=this; window.CMenuHideTimers[name]=null; this.name=name; this.rel=items[0].pos=="relative"; this.root=[]; this.root.par=null;this.root.cd=[]; this.root.fmt=items[0]; this.root.pos=this.rel?[0,0]:items[0].pos; this.root.fmt.pos=this.root.pos;this.root.frameoff=items[0].pos?items[0].pos:[0,0]; this.items=[];this.root.index=0;this.root.lvl=new CMenuLevel(this, this.root); for (var i=1;ih) h=n.pos[1]+n.size[0]; if (n.pos[0]+n.size[1]>w) w=n.pos[0]+n.size[1]; } s=this.bw.ns4?'' + s + '':'
' + s +'
'; } return s; }; this.drawOther=function(){ var s=""; for (var i=0;i"; } this.menu_rect=function(){var r=[65535,65535,0,0];for (i in this.par.cd) {var itm = this.par.cd[i];if (itm.par==this.menu.root || itm.v) {var s=itm.style.shadow;var slt=(s<0?-s:0);var srt=(s>0?s:0);var l=itm.pos[0]-slt;var t=itm.pos[1]-slt;var w=itm.size[1]+itm.pos[0]+srt;var h=itm.size[0]+itm.pos[1]+srt;if(lr[2])r[2]=w;if(h>r[3])r[3]=h;}} return r;}; this.fix_form=function(lvl,v){if((this.menu.bw.ie55||this.menu.bw.ie6)&&(this.par!=this.menu.root||this.menu.root.fmt.popup)){this.iframe=this.iframe?this.iframe:this.menu.get_div("ifr"+this.menu.name+"_"+this.par.index);if (v) {var r=this.menu_rect();var st = this.iframe.style;st.left=r[0];st.top=r[1];st.width=Math.abs(r[0]-r[2]);st.height=Math.abs(r[1]-r[3]);this.iframe.style.visibility='visible'; }else this.iframe.style.visibility='hidden';} var fmt = this.menu.root.fmt; if ((this.menu.bw.ie5||this.menu.bw.ns4||this.menu.bw.operaOld)&&!(lvl==this.menu.root.lvl&&fmt.popup)&&fmt.forms_to_hide) { var hide = 0; for (var i=0;i 0}; this.hac=function(){return this.hc()&&this.cd[0].vis}; this.div=function(n){return und(this.divs[n])?this.divs[n]=this.get_div(this.id+n):this.divs[n]}; this.gen_code=function(state, off){ var res=''; var table=(nn(this.arrow) && this.hc()) || nn(this.image); var image=nn(this.image); var arrow=nn(this.arrow)&& this.hc(); if (table) res += ''; if (image) res += ''; if (table) res += ''; if (arrow) res += ''; if (table) res += '
'; res += '
'+(state=='n'?this.code:this.ocode)+'
'; if (table) res += '
'; return res; }; this.draw=function(){ var bl=bt=this.style.border; var br=bb=this.style.border*2; if (this.style.border && !und(this.style.borders)) { bl=this.style.borders[0]; bt=this.style.borders[1]; br=this.style.borders[2]+bl; bb=this.style.borders[3]+bt; } var s=this.style.shadow; var z=(!this.style.shadow?"":adiv(this.menu.bw, this.id+"s", this.z+1, this.pos[0]+s, this.pos[1]+s, this.size[1], this.size[0], this.style.color.shadow, "", ""))+ (!this.style.border?"":adiv(this.menu.bw, this.id+"b", this.z+2, this.pos[0], this.pos[1], this.size[1], this.size[0], this.style.color.border, "", ""))+ adiv(this.menu.bw, this.id+"n", this.z+3, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, this.style.color.bgON, this.gen_code('n', parseInt(bt)+parseInt(bb)))+ adiv(this.menu.bw, this.id+"o", this.z+4, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, this.style.color.bgOVER,this.gen_code('o', bt+bb))+ adiv(this.menu.bw, this.id+"e", this.z+5, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, "", ''+'','','onmouseover="mEvent(\''+this.menu.name+'\','+this.index+',\'o\');" onmouseout="mEvent(\''+this.menu.name+'\','+this.index+',\'t\');"'); return z; }; this.vis=function(s){ if (this.style.shadow) this.visDiv("s",s); if (this.style.border) this.visDiv("b",s); if (!s) { this.visDiv("o",0); this.visDiv("n",0); this.state="n"; }else if (this.state=="n") this.visDiv("n",1); else this.visDiv("o",1); this.visDiv("e",s); this.v=s; }; this.setVis = function (n){ if (this.state!=n) switch (n){ case "n": this.visDiv("n",1);this.visDiv("o",0); break; case "o": this.visDiv("n",0);this.visDiv("o",1); break; } this.state=n; }; this.visDiv=this.bw.ns4? visDivNS:visDivDom; this.getf=function(obj, name){ if (!und(obj) && nn(obj) && !und(obj.fmt)) { if (!und(obj.fmt[name])) return obj.fmt[name]; if (obj.par!=this.menu.root && obj.par && obj.par.sub && obj.par.sub[0][name]) return obj.par.sub[0][name]; return this.getf(obj.par, name); } return; }; this.ioff=this.getf(this, "itemoff"); this.loff=this.getf(this, "leveloff"); this.imgsize=this.getf(this, "imgsize"); this.arrsize=this.getf(this, "arrsize"); this.image=this.getf(this, "image"); this.oimage=this.getf(this, "oimage") || this.image; this.arrow=this.getf(this, "arrow"); this.oarrow=this.getf(this, "oarrow") || this.arrow; this.style=this.getf(this, "style"); this.size=this.getf(this, "size"); if (this.par==this.menu.root) this.fmt.pos=this.getf(this, "pos"); this.prev=this.pindex==0? null : this.par.cd[this.pindex-1]; this.setPos=function(){ if (this.prev==null){ this.z=this.par==this.menu.root? 10: this.par.z+10; this.pos=und(this.fmt.pos)?(this.par==this.menu.root? this.fmt.pos : this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]]):this.fmt.pos; }else{ this.prev.next=this; this.z=this.prev.z; this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]]; } }; this.setPosFromParent=function(){ if (this.index==0&&!this.menu.rel) { this.pos=[this.menu.root.pos[0], this.menu.root.pos[1]] } else if (this.prev==null){ this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]]; }else{ this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]]; } }; this.setPos(); this.sub=item.sub; if (!und(this.sub) && !und(this.sub.length)&& this.sub.length>0){ this.lvl=new CMenuLevel(menu, this); for (var i=1;i'+code+'\n': '
'+code+'
'; } function visDivNS(d,s){this.div(d).visibility=s?'show':'hide'} function visDivDom(d,s){this.div(d).style.visibility=s?'visible': 'hidden'} function mEvent(m,node_index,e) { if (nn(window.CMenuHideTimers[m])) { window.clearTimeout(window.CMenuHideTimers[m]); window.CMenuHideTimers[m]=null; } switch (e){ case "o": window.CMenus[m].items[node_index].par.lvl.setA(node_index,1); if (window.CMenus[m].onmouseover) window.CMenus[m].onmouseover(window.CMenus[m].items[node_index]); break; case "c": if (window.CMenus[m].items[node_index].hc()) window.CMenus[m].items[node_index].lvl.vis(!window.CMenus[m].items[node_index].lvl.v); else for (var i=0;i