var initSite = { start: function() { initSite.mainNav(); initSite.memberDashboard(); if ($('product-finder')) { initSite.productFinder() }; }, mainNav: function() { navSliders = $$('.main-nav-tier'); navTogglers = $$('.toggle-nav'); sliders = []; menuOpened = false; navTogglers.each(function(toggler, x) { if (window.webkit419) { navSliders[x].setStyle('display','block'); sliders[x] = new Fx.Slide(navSliders[x]).hide(); } else { sliders[x] = new Fx.Slide(navSliders[x]).hide(); navSliders[x].setStyle('display','block'); } $(navTogglers[x]).addEvent('click', function() { initSite.handleNavToggle(toggler, x); }); }); }, handleNavToggle: function(el, iToToggle) { navSliders.each(function(menu, i) { if(i != iToToggle && sliders[i].isVisible()) { sliders[i].hide(); navTogglers[i].getParent().removeClass('active'); } if(i == iToToggle) { if(!sliders[iToToggle].isVisible()) { // check if slider div html has been loaded if(navSliders[i].innerHTML.replace(/^\s+|\s+$/g, '') == '') { //using inline styles here - safari2 becomes a sad panda when height is added to div.main-nav-tier navSliders[i].setHTML('
Loading... Loading...
'); var tierUrl = '/livery/fragments/tier/' + navSliders[i].id + '.htm'; new Ajax(tierUrl, { method: 'get', update: navSliders[i], data: { channel_id: channelID } }).request(); } if(menuOpened == false) { sliders[i].slideIn(); menuOpened = true; } else { //safari 2 fix if (window.webkit419 && navSliders[i].getStyle('margin-top').toInt() < 0) { setMargin = sliders[i].show().offset; sliders[i].show(); navSliders[i].setStyle('margin-top',setMargin); } else { sliders[i].show(); } } el.getParent().addClass('active'); } else { sliders[i].slideOut(); el.getParent().removeClass('active'); menuOpened = false; } } }); }, memberDashboard: function() { if ($('logged-in') && $('logged-in').getStyle('display') !== 'none') { suckerfish(sfHover, 'LI', 'member-dashboard'); } else if ($('not-logged-in')) { initOverLabels(); } }, productFinder: function() { setHeight = ($('search-filters').getStyle('height').toInt()) - 1; $('search-options').setStyle('height',setHeight); searchFilters = $$('#search-filters li a'); searchOptions = $$('#search-options fieldset'); searchFilters.each(function(el, i) { if (searchFilters[i].getParent().id !== 'more-options') { $(searchFilters[i]).addEvent('mouseenter', function() { searchOptions.each(function(el, x) { searchOptions[x].setStyle('display','none'); searchFilters[x].getParent().removeClass('selected'); if (x == i) { searchOptions[x].setStyle('display','block'); searchFilters[x].getParent().addClass('selected'); } }); }); $(searchFilters[i]).addEvent('click', function(e) { e = new Event(e).stop(); }); } }); } }; window.addEvent('load', initSite.start); /*------------------------------------------------------------------- Miscellaneous site functions ------------------------------------------------------------------- */ function toggleSection (id,onClass,offClass) { var styleObject = $(id); var currentClass = styleObject.className; if (styleObject) { if (currentClass != offClass) { styleObject.removeClass(onClass).addClass(offClass); } else { styleObject.removeClass(offClass).addClass(onClass); } return true; } else { return false; } } function toggleOpacity(id) { var fader = new Fx.Style(id, 'opacity', {duration:400}); display = $(id).getStyle('display'); if (display == 'none') { $(id).setStyles({'display':'block', 'opacity':0}); fader.start(0,1); } else { fader.start(1,0).chain(function(){$(id).setStyle('display','none')}); } } /*------------------------------------------------------------------- Replicate :hover pseudo class on any element for IE ------------------------------------------------------------------- */ function suckerfish(type, tag, parentId) { if (window.attachEvent) { window.attachEvent('onload', function() { var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag); type(sfEls); }); } } var sfHover = function(sfEls) { for (var i=0; i For more documentation check out: http://clientside.cnet.com/cnet.gf/docs/files3/common/layout-widgets/carousel-js.html Example carousel: new CNETcarousel('music-carousel', { buttonsSelector: '.nav-button', rotateAction: 'click', slideInterval: 4000 }); ------------------------------------------------------------------- */ var CNETcarousel = new Class({ initialize: function(container, options){ this.container = $(container); if(!this.container.hasClass('hasCarousel')){ this.container.addClass('hasCarousel'); this.slides = []; this.buttons = []; this.setOptions({ onRotate: Class.empty, onStop: Class.empty, onAutoPlay: Class.empty, onShowSlide: Class.empty, slidesSelector: ".slide", buttonsSelector: ".button", slideInterval: 4000, transitionDuration: 500, startIndex: 0, buttonOnClass: "selected", buttonOffClass: "off", rotateAction: "none", rotateActionDuration: 100, autoplay: true }, options); this.slides = $(container).getElements(this.options.slidesSelector); this.buttons = $(container).getElements(this.options.buttonsSelector); this.createFx(); this.showSlide(this.options.startIndex); if(this.options.autoplay) this.autoplay(); if(this.options.rotateAction != 'none') this.setupAction(this.options.rotateAction); return this; } else return false; }, setupAction: function(action) { this.buttons.each(function(el, idx){ $(el).addEvent(action, function() { this.slideFx.setOptions(this.slideFx.options, {duration: this.options.rotateActionDuration}); if(this.currentSlide != idx) this.showSlide(idx); this.stop(); }.bind(this)); }, this); }, createFx: function(){ this.slideFx = new Fx.Elements(this.slides, {duration: this.options.transitionDuration}); this.slides.each(function(slide){ slide.setStyle('opacity',0); }); }, showSlide: function(slideIndex){ var action = {}; this.slides.each(function(slide, index){ if(index == slideIndex && index != this.currentSlide){ //show $(this.buttons[index]).removeClass(this.options.buttonOffClass).addClass(this.options.buttonOnClass); //slide.setStyle('display','block'); action[index.toString()] = { 'opacity': [1] } } else { $(this.buttons[index]).removeClass(this.options.buttonOnClass).addClass(this.options.buttonOffClass); //slide.setStyle('display','none'); action[index.toString()] = { 'opacity': [0] } } }, this); this.fireEvent('onShowSlide', slideIndex); this.currentSlide = slideIndex; this.slideFx.start(action); }, autoplay: function(){ this.createFx(); this.slideshowInt = this.rotate.periodical(this.options.slideInterval, this); this.fireEvent('onAutoPlay'); }, stop: function(){ clearInterval(this.slideshowInt); this.fireEvent('onStop'); }, rotate: function(){ var current = this.currentSlide; var next = (current+1 >= this.slides.length) ? 0 : current+1; this.showSlide(next); this.fireEvent('onRotate'); }, show: function() { $(this.options.carouselContainer).setStyle('visibility','visible'); if(!$(this.options.carouselContainer).isVisible())$(this.options.carouselContainer).setStyle('display','block'); }, hide: function(){ $(this.options.carouselContainer).setStyle('visibility','hidden'); } }); CNETcarousel.implement(new Options); CNETcarousel.implement(new Events); var CNETcarouselWithButtons = CNETcarousel.extend({ initialize:function(el, options){ this.parent(el, $merge({ bubbleButtonBGImgSelector: '.bbg', buttonOnGifSrc: 'http://i.i.com.com/cnwk.1d/i/fd/c/green_button.gif', buttonOffGifSrc: 'http://i.i.com.com/cnwk.1d/i/fd/c/gray_button.gif' }, options)); }, showSlide: function(slideIndex){ this.buttons.each(function(button, index){ $(button).getElement(this.options.bubbleButtonBGImgSelector).src = (index == slideIndex)?this.options.buttonOnGifSrc:this.options.buttonOffGifSrc; }, this); this.parent(slideIndex); } }); var carousel = null; /*------------------------------------------------------------------- Multiple. open. accordion.js: by Aaron Newton, For more documentation check out: http://clientside.cnet.com/cnet.gf/docs/files3/common/layout-widgets/multiple-open-accordion-js.html ------------------------------------------------------------------- */ var MultipleOpenAccordion = Fx.Elements.extend({ options: { openAll: true, allowMultipleOpen: true, firstElementsOpen: [0], start: 'open-first', fixedHeight: false, fixedWidth: false, alwaysHide: true, wait: false, onActive: Class.empty, onBackground: Class.empty, height: true, opacity: true, width: false }, initialize: function(togglers, elements, options){ this.parent(elements, options); this.setOptions(options); this.previousClick = null; this.elementsVisible = []; togglers.each(function(tog, i){ $(tog).addEvent('click', function(){this.toggleSection(i)}.bind(this)); }, this); this.togglers = togglers; this.h = {}; this.w = {}; this.o = {}; this.now = []; this.elements.each(function(el, i){ el = $(el); this.now[i] = {}; el.setStyle('overflow','hidden'); if(!(this.options.openAll && this.options.allowMultipleOpen)) el.setStyle('height', 0); }, this); if(!this.options.openAll || !this.options.allowMultipleOpen) { switch(this.options.start){ case 'first-open': this.showSection(this.options.firstElementsOpen[0]); break; case 'open-first': this.toggleSection(this.options.firstElementsOpen[0]); break; } } if (this.options.openAll && this.options.allowMultipleOpen) this.showAll(); else if (this.options.allowMultipleOpen) this.openSections(this.options.firstElementsOpen); }, hideThis: function(i){ this.elementsVisible[i] = false; if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, 0]}; if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, 0]}; if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 1, 0]}; this.fireEvent("onBackground", [this.togglers[i], this.elements[i]]); }, showThis: function(i){ this.elementsVisible[i] = true; if (this.options.height) this.h = {'height': [this.elements[i].offsetHeight, this.options.fixedHeight || this.elements[i].scrollHeight]}; if (this.options.width) this.w = {'width': [this.elements[i].offsetWidth, this.options.fixedWidth || this.elements[i].scrollWidth]}; if (this.options.opacity) this.o = {'opacity': [this.now[i]['opacity'] || 0, 1]}; this.fireEvent("onActive", [this.togglers[i], this.elements[i]]); }, toggleSection: function(iToToggle){ if(iToToggle != this.previousClick || this.options.alwaysHide || this.options.allowMultipleOpen) { this.previousClick = iToToggle; var objObjs = {}; var err = false; this.elements.each(function(el, i){ var update = false; this.now[i] = this.now[i] || {}; if(i==iToToggle){ if (this.elementsVisible[i] && (this.options.allowMultipleOpen || this.options.alwaysHide)){ if(!(this.options.wait && this.timer)) { update = true; this.hideThis(i); } else { this.previousClick = null; err = true; } } else if(!this.elementsVisible[i]){ if(!(this.options.wait && this.timer)) { update = true; this.showThis(i); } else { this.previousClick = null; err = true; } } } else if(this.elementsVisible[i] && !this.options.allowMultipleOpen) { if(!(this.options.wait && this.timer)) { update = true; this.hideThis(i); } else { this.previousClick = null; err = true; } } if(update) objObjs[i] = $merge(this.h, $merge(this.o, this.w)); }, this); if (err) return false; return this.custom(objObjs); } return false; }, showSection: function(i, useFx){ if($pick(useFx, false)) { if (!this.elementsVisible[i]) this.toggleSection(i); } else { this.setSectionStyle(i,$(this.elements[i]).scrollWidth, $(this.elements[i]).scrollHeight, 1); this.elementsVisible[i] = true; this.fireEvent("onActive", [this.togglers[i], this.elements[i]]); } }, hideSection: function(i, useFx){ if($pick(useFx, false)) { if (this.elementsVisible[i]) this.toggleSection(i); } else { this.setSectionStyle(i,0,0,0); this.elementsVisible[i] = false; this.fireEvent("onBackground", [this.togglers[i], this.elements[i]]); } }, setSectionStyle: function(i,w,h,o){ if (this.options.opacity) $(this.elements[i]).setOpacity(o); if (this.options.height) $(this.elements[i]).setStyle('height',h+'px'); if (this.options.width) $(this.elements[i]).setStyle('width',w+'px'); }, showAll: function(){ if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ this.showSection(idx, false); }, this); } }, hideAll: function(){ if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ this.hideSection(idx, false); }, this); } }, openSections: function(sections) { if(this.options.allowMultipleOpen){ this.elements.each(function(el,idx){ if(sections.test(idx)) this.showSection(idx, false); else this.hideSection(idx, false); }, this); } } }); MultipleOpenAccordion.implement(new Options); MultipleOpenAccordion.implement(new Events); /*------------------------------------------------------------------- SimpleSlide.js: Developed by Gravita, www.gravita.se For more documentation check out: http://tobiaswallin.com/files/SlideShow/documentation.php Example slider: new SimpleSlide("thumbnail-slides",{type: "scroll", goTo:2, duration:150}); ------------------------------------------------------------------- */ eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('a W=j L({X:8(5,7){4.5=5;4.7=7;6(4.7.n=="M"||4.7.n=="C"){a o;4.o=4.D.N(4.7.O,4,$(4.5))}b{4.D($(4.5))}},D:8(5){a f;6(4.7)f=4.7.f;b f="A";a 3;6(4.7.d){a d=4.7.d.K();d-=1}a 9=5.c().c()[0];9.r(8(e){6(e.i=="s"){3=e}});6(d||d==0){6(5.c()[0].c()[d])3=5.c()[0].c()[d];b P("Q "+d+" R S T")}b{6(!3){6(f=="A"){3=9[0].w()}b 6(f=="H"){3=5.c()[0].F()}}b{6(f=="A"){a t=5.c()[0].F();6(t==3.w()&&4.7.n=="C")$I(4.o);6(t==3)3=9[0];b 3=3.w()}b 6(f=="H"){a E=5.c()[0].V();6(E==3.J()&&4.7.n=="C")$I(4.o);6(E==3)3=5.c()[0].F();b 3=3.J()}}}6(3){6(4.7.G=="l")4.l(5,9,3);b 6(4.7.G=="h")4.h(5,9,3);b 6(4.7.G=="v")4.v(5,9,3)}},l:8(5,9,3){a l=j k.u(5,{g:4.7.g,m:8(){9.r(8(e){e.i=""});3.i="s"}}).x(3)},h:8(5,9,3){a h=j k.y(5,\'z\',{g:4.7.g,m:8(){j k.u(5,{g:1,m:8(){9.r(8(e){e.i=""});3.i="s";j k.y(5,\'z\').q(0.p,1)}}).x(3)}});h.q(1,0.p)},v:8(5,9,3){a B=4.7.g.K();a h=j k.y(5,\'z\',{g:(B/2)});h.q(1,0.p).U(8(){h.q(0.p,1)});j k.u(5,{g:B,m:8(){9.r(8(e){e.i=""});3.i="s"}}).x(3)}});',60,60,'|||child|this|container|if|options|function|children|var|else|getChildren|goTo||direction|duration|fade|id|new|Fx|scroll|onComplete|auto|automated|01|start|each|currentChild|lastElement|Scroll|scrollfade|getNext|toElement|Style|opacity|forward|durationInt|once|slider|firstElement|getLast|type|back|clear|getPrevious|toInt|Class|loop|periodical|time|alert|Slide|does|not|exist|chain|getFirst|SimpleSlide|initialize'.split('|'),0,{})) /*------------------------------------------------------------------- Plugin extensions ------------------------------------------------------------------- */ function sumArr(arr) { var sum = 0; arr.each(function(el){sum += el;}); return sum; } Element.extend({ clearValue: function(){ switch(this.getTag()){ case 'select': $each(this.options, function(option){ if (option.selected) option.selected = false; }); case 'input': if (this.checked || ['hidden','submit','button'].contains(this.type)) { if (['checkbox', 'radio'].contains(this.type)) this.checked = false; break; } case 'textarea': this.value = ''; } return false; }, clearFormElements: function(){ this.getFormElements().each(function(el){ el.clearValue() }); } }); Fx.Slide.implement({ isVisible: function() { return (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) ? false: true; } }); var myAccordion = Accordion.extend({ options: { onActive: function(toggler, element){ toggler.addClass('expand-nav'); }, onBackground: function(toggler, element) { toggler.removeClass('expand-nav'); //recalculate the offset height including expanded sliders var harr = $$(element.getChildren()).getStyle('height'); var harrint = harr.map(function(item, index) { return item.toInt(); } ); var hsum = sumArr(harrint); if (element.offsetHeight > 0) { element.setStyle('height', hsum+"px"); } }, onComplete: function() { //reset the accordion height to allow nested sliders to expand var el = $(this.elements[this.previous]); if (el.offsetHeight > 0) { el.setStyle('height','auto'); } } } }); var MyMultipleOpenAccordion = MultipleOpenAccordion.extend({ options: { onActive: function(toggler, element){ toggler.setHTML('-'); }, onBackground: function(toggler, element) { toggler.setHTML('+'); } } });