function setShorthandOmni(element,customTag) { setOmniValues(element,'o',customTag,'','','',0,'',''); } var navBar = new Class({ initialize: function(){ this.navElms = $$(".nav_item"); this.szSmall = 30; this.szFull = 130; this.szNormal = 40; this.fx = new Fx.Elements(this.navElms, { wait: false, duration: 100, transition: Fx.Transitions.linear }); // set current page in nav this.curPage = $('curPage').value; $(this.curPage).addClass("current"); // enable events and states this.setEvents(); this.setHovers(); this.setCurrentElement(); this.setActiveNavItem(); }, setActiveNavItem: function(){ var curSex = $('sex').value; var curCat = $('category').value; if(curSex != '' && curCat != ''){ var curAnchors = $(this.curPage).getElements('.' + curSex); curAnchors.each(function(curAnchor, i) { if(curCat == 0 && curAnchor.hasClass('poy')){ curAnchor.addClass("selected"); } else if(curCat == 1 && curAnchor.hasClass('first')){ curAnchor.addClass("selected"); } else if(curCat == 2 && curAnchor.hasClass('second')){ curAnchor.addClass("selected"); } else if(curCat == 3 && curAnchor.hasClass('third')){ curAnchor.addClass("selected"); } }); } }, setHovers: function() { // set hovers on all nav items this.navElms.each(function(navElm, i) { navElm.addEvent("mouseenter", function(e) { navElm.addClass("normalhover"); }.bind(this)); navElm.addEvent("mouseleave", function(e) { navElm.removeClass("normalhover"); }.bind(this)); }.bind(this)); }, setEvents: function(){ // set all hovers on kwicks this.navElms.each(function(navElm, i) { navElm.addEvent("mouseenter", function(e) { e = new Event(e); if(i > 2 && i < 9){ this.runEffect(navElm, i); } e.stop(); }.bind(this)); }.bind(this)); // if a user mouse out of nav kwicks container $("nav_kwicks").addEvent("mouseleave", function(e) { var hasCurrent = $("nav_kwicks").getElement(".current"); if($type(hasCurrent)){ // if a kwick is current page this.setCurrentElement(); } else { // if its not hide everything this.sizeKwick(280); this.removeCurrent(); var o = {}; // set all kwicks to normal size this.navElms.each(function(navElm, i) { o[i] = {width: [navElm.getStyle("width").toInt(), this.szNormal]} // hide if($type(navElm.getElement('.nav_detail'))){ navElm.getElement('.nav_detail').setStyle("display", "none"); } }.bind(this)); this.fx.start(o); } }.bind(this)); }, setCurrentElement: function() { this.navElms.each(function(navElm, i) { //initialize first one to be open if(i > 2 && i < 9){ if(this.curPage == navElm.id){ this.runEffect(navElm, i); } } }.bind(this)); }, sizeKwick: function(newWidth) { // resizes the kwicks container var reSize = { width: newWidth }; var reSizeFx = new Fx.Styles($('nav_kwicks'), { wait: false, duration: 100, transition: Fx.Transitions.linear }); reSizeFx.start(reSize); }, runEffect: function(curNavElm, i) { var navDetails = curNavElm.getElement(".nav_detail"); this.sizeKwick(320); // set kwick hover container this.removeCurrent(); curNavElm.addClass("kwickhover"); // adjust the size of all other elements to small var o = {}; this.navElms.each(function(navElm, j) { if(i != j){ var w = navElm.getStyle("width").toInt(); if(w != this.szSmall) { o[j] = {width: [w, this.szSmall]}; } } }.bind(this)); // set the size of the active qwick o[i] = {width: [curNavElm.getStyle("width").toInt(), this.szFull]} this.fx.stop(); this.fx.start(o); // show and fade in content if($type(navDetails)){ navDetails.setStyle("display", "block"); } if(!curNavElm.hasClass("current")){ this.detailEffect = new Fx.Styles(navDetails, { duration: 300, transition: Fx.Transitions.Cubic.easeIn }); this.fadeIn(this.detailEffect); } }, removeCurrent: function(){ // removes kwickhover from all kwicks this.navElms.each(function(navElm, j) { if(navElm.hasClass("kwickhover")){ navElm.removeClass("kwickhover"); } if($type(navElm.getElement(".nav_detail"))){ navElm.getElement(".nav_detail").setStyle("display", "none"); } }.bind(this)); }, fadeIn: function(effect) { effect.element.setStyle("opacity", "0"); effect.start({ 'opacity': [0, 1] }); } }); window.addEvent('domready', function() { var myNavBar = new navBar(); });