function makeMenuObj(obj,nest){ nest=(!nest) ? "":'document.'+nest+'.' this.evnt = document.getElementById?document.getElementById(obj):document.all?document.all[obj]:document.layers?eval(nest+'document.'+obj):0; this.css = this.evnt.style?this.evnt.style:this.evnt; this.ref=document.layers?this.evnt.document:document; this.x=this.css.left||this.evnt.offsetLeft; this.y=this.css.top||this.evnt.offsetTop; this.hideIt=b_hideIt; this.showIt=b_showIt; this.movey=b_movey this.moveIt=b_moveIt; this.moveBy=b_moveBy; this.status=0; this.bgImg=b_bgImg; this.obj = obj + "Object"; eval(this.obj + "=this"); this.clipTo=b_clipTo; return this } function b_showIt(){this.css.visibility="visible"; this.status=1} function b_hideIt(){this.css.visibility="hidden"; this.status=0} function b_movey(y){this.y=y; this.css.top=this.y} function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y} function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x;this.css.top=this.y} function b_bgImg(img){ if(document.getElementById) document.getElementById(this.id+"_img").src = img else if(document.layers) this.ref.layers[0].document.images[0].src = img else document.images[this.id+"_img"].src = img } function b_clipTo(t,r,b,l,w){if(document.layers){this.css.clip.top=t;this.css.clip.right=r this.css.clip.bottom=b;this.css.clip.left=l }else{this.css.clip="rect("+t+"px,"+r+"px,"+b+"px,"+l+"px)"; if(w){this.css.pixelWidth=this.css.width=r; this.css.pixelHeight=this.css.height=b}}} /******************************************************************************** Initiating page, making objects.. ********************************************************************************/ createSlideMenu.prototype.init = function(){ document.write("") this.cont=new makeMenuObj(this.name+'cont') this.cont.moveIt(this.menux,this.menuy) var yy = 0, el //Make top menus for(var j=0;j0){ //With subs if(i==el.childs.length-1) img=this.l[temp.lev].subRound else img=this.l[temp.lev].subImg }else if(i==el.childs.length-1){ img=this.l[temp.lev].roundImg2 } if(img){ temp.o.bgImg(img); temp.img = img }else temp.img = this.l[temp.lev].regImage } p = this.menus[temp.parent] //Setting the next elements if(temp.chnum != p.childs.length-1){ //Not the last el temp.nextel = p.childs[temp.chnum+1].num temp.nexttop = temp.lev==1?p.nexttop:p.nextel }else{ //Last el, so we only have nexttop temp.nexttop = p.nextel if(temp.nexttop==-1) temp.nexttop = p.nexttop } if(temp.childs.length>0){ this.loop(temp.num,j) //Recursive call } } } /******************************************************************************** Moving all objects in the array after a provided array number ********************************************************************************/ createSlideMenu.prototype.moveItems = function(px,num){ for(i=num;i-1){ var n = -1 if(m.lev>0){ if(this.active[m.lev]>-1) n=this.active[m.lev] else n=this.active[m.lev-1] }else n = this.active[0] m = this.menus[n] if(m.lev == 0 && olev==0) y = m.nexttop!=-1?this.menus[m.nexttop].origy:-1 else if(clnum!=m.num){ var ny = m.o.y + m.o.h + this.l[m.lev].between if(clnum>m.num && olev==m.lev) y = Math.min(ny,y) else if(onext==m.num) y = Math.max(ny,y) } } this.moveUp(m.nextel!=-1?m.nextel:m.nexttop,num,y) } /******************************************************************************** Move items up ********************************************************************************/ createSlideMenu.prototype.moveUp = function(top,num,y){ var move = 0, m, yy=0; if(this.active[0]>-1 && top>-1){ m = this.menus[top] if(m.o.y>y){ if((m.o.y-this.pxspeed)-1){ temp = this.menus[this.active[i]] temp.o.moveIt(temp.o.x-this.inset,temp.o.y) if(this.useImages) temp.o.bgImg(temp.img) //Change bg if(this.arrow) temp.ar.replaceChild(document.createTextNode(">"),temp.ar.childNodes[0]) ch = temp.childs for(var j=0;j0 && m.chnum!=this.menus[m.parent].childs.length-1){ yy=y; y = this.menus[m.parent].endy + this.l[m.lev].between } m.o.moveIt(m.o.x+this.inset,m.o.y) //Inset current item: if(this.useImages) m.o.bgImg(this.l[m.lev].roundImg) //Change bg this.active[m.lev] = num //Set active if(this.arrow) m.ar.replaceChild(document.createTextNode(">"),m.ar.childNodes[0]) if(m.nexttop>-1 || m.nextel>-1) this.moveDown(m.nexttop,m.nextel,y,yy) //Then start moving all other elements down else this.going=0 } } /******************************************************************************** Move items down ********************************************************************************/ createSlideMenu.prototype.moveDown = function(top,num,y,yyy){ var m = this.menus[top],yy if(m && m.o.yy) yy = y-m.o.y else yy=this.pxspeed this.moveItems(yy,top) setTimeout(this.name+".moveDown("+top+","+num+","+y+","+yyy+")",this.timspeed) }else if(num>-1){ this.moveDown(num,-1,yyy,0) }else this.going=0 } /******************************************************************************** Slide menu object ********************************************************************************/ function createSlideMenu(name){ document.write('
') //The cont div start this.name = name this.menus = new Array() this.curr = 0 this.lasttype = new Array() this.writesubsonly = 0 this.level = new Array() this.l = new Array() this.topmenus = new Array() this.active = new Array() return this } /******************************************************************************** Function to create the objects and the divs ********************************************************************************/ createSlideMenu.prototype.makeMenu = function(type,text,lnk,target,end){ var str="",tg="",parent,m,cl m = this.menus[this.curr] = new Object() this.lasttype[type] = this.curr; if(!lnk) lnk="#" m.lev = 0; m.type = type; m.childs = new Array() m.num = this.curr; m.parent = -1; m.nextel = -1 m.nexttop = -1; parent = 0 //DEBUGGING:::::: m.text = text if(type.indexOf("sub")>-1){ //Find parent type if(type.length == 3){ //sub parent = "top"; m.lev = 1 }else{ parent = type.substr(3,1) //sub2+ m.lev = parent; parent-- if(parent==1){ parent = "sub"; m.lev = 2 }else parent = "sub"+parent } } if(m.lev>=this.l.length){//Level control (same as CM4) var p1,p2=0; if(m.lev>=this.level.length) p1=this.l[this.level.length-1]; else p1=this.level[m.lev]; this.l[m.lev]=new Array(); if(!p2) p2=this.l[m.lev-1] if(m.lev!=0 && p1){ for(i in p1){ //Copying an entire object if(p1[i]==null) this.l[m.lev][i]=p2[i]; else this.l[m.lev][i]=p1[i] } }else{ this.l[m.lev]=this.level[0]; } this.level[m.lev]=p1=p2=null } this.active[m.lev] = -1 if(parent){ //Find parent element m.parent = this.lasttype[parent] parent = this.menus[this.lasttype[parent]] parent.childs[parent.childs.length] = m if(this.arrow && parent.childs.length==1){ if(document.getElementById && document.getElementById(parent.id).childNodes){ str='' parent.ar = document.getElementById(parent.id).childNodes[this.useImage?1:0].childNodes[0] parent.ar.innerHTML = str+parent.ar.innerHTML; parent.ar=parent.ar.childNodes[0]} else this.arrow="" } }else this.topmenus[this.topmenus.length] = this.curr if(!this.writesubsonly || type!="top"){ cl = this.l[m.lev].className m.id = id = this.name + "_" + this.curr str= '
' //main div start if(this.useImages){ str+='
'//bgdiv str+='' str+='
' //bgdiv } if(target) tg =' target="'+target+'" ' str+='\n' str+="
\n\n" //main div end document.write(str) } this.curr++ } /******************************************************************************** Level object ********************************************************************************/ function slideMenu_makeLevel(){ var c=this, a=arguments; c.left=a[0]||0; c.width=a[1]||null; c.height=a[2]||null; c.between=a[3]||null; c.className=a[4]||null; c.classNameA=a[5]||null; c.regImage=a[6]||null; c.roundImg=a[7]||null; c.roundImg2=a[8]||null; c.subImg=a[9]||null; c.subRound=a[10]||null; return c } /******************************************************************************** Preloading images ********************************************************************************/ function preLoadBackgrounds(){ for(i=0;i