window.tws=window.tws||{};window.tws.topEventSelectedGenre='';window.tws.asReady=window.tws.asReady||[];window.tws.asReady.push('eventFilter');window.tws.eventFilter=function(){var genres=['exhibition','concert','onsitelab','residence','external'];var all=$$('#events div.event');var $highPriority=$$('#events div.event-priority1');var $lowPriority=$$('#events div.event-priority3');var highers=[];$highPriority.each(function($event){highers.push($event.id)});for(var i=highers.length-1;i>=0;i--){$(highers[i]).inject($('events'),'top')}$lowPriority.each(function($event){$event.inject($('events'),'bottom')});all=$$('#events div.event');var hrefs=$$('#events div.event .continue a');var exhibition=$$('#events div.exhibition');var concert=$$('#events div.concert');var onsitelab=$$('#events div.onsitelab');var residence=$$('#events div.residence');var external=$$('#events div.external');var events={'all':all,'exhibition':exhibition,'concert':concert,'onsitelab':onsitelab,'residence':residence,'external':external};var filter=$$('#filter a');var selBtn=$$('#filter a img');var showEvents=function(genre){$$('#events .'+genre).each(function(item){showEvent(item)})};var hideEvents=function(genre){$$('#events .'+genre).each(function(item){hideEvent(item)})};var showEvent=function(item){item.style.display='block';var hideEventFx=new Fx.Tween(item,{property:'opacity',duration:400,transition:Fx.Transitions.Cubic.easeOut,wait:false});hideEventFx.start(1);item.removeClass('unselected')};var hideEvent=function(item){var hideEventFx=new Fx.Tween(item,{property:'opacity',duration:400,transition:Fx.Transitions.Cubic.easeOut,wait:false});hideEventFx.start(0.2);item.addClass('unselected')};var compare2=function(d1,d2,border){if(border=='-'){if(d1<d2){return true}else{return false}}else if(border=='+'){if(d1<=d2){return true}else{return false}}return false};var toolTipsclassNames=['tips_ex-tip','tips_con-tip','tips_onsite-tip','tips_resi-tip','tips_exwork-tip'];$$('img.Tips').each(function($img,idx){var tit=$img.getAttribute('title');$img.removeAttribute('title');var $parent=$img.getParent();var content=tit.split('::');$parent.store('tip:title',content[0]);if(content[1].length>25){content[1]=content[1].substring(0,25)}$parent.store('tip:text',content[1]);new Tips($parent,{offsets:{'x':-10,'y':15},className:toolTipsclassNames[idx]}).addEvents({show:function(tip){tip.setStyle('opacity','0.9')}})});all.each(function(item,i){item.addEvent('mouseenter',function(e){if(item.hasClass('unselected')){var hideEventFx=new Fx.Tween(item,{property:'opacity',duration:400,transition:Fx.Transitions.Cubic.easeOut,wait:false});hideEventFx.start(0.8)}else{var hideEventFx=new Fx.Tween(item,{property:'opacity',duration:150,transition:Fx.Transitions.Cubic.easeOut,wait:false,onComplete:function(item){var hideEventFxCB=new Fx.Tween(item,{property:'opacity',duration:150,transition:Fx.Transitions.Cubic.easeOut,wait:false});hideEventFxCB.start(1)}});hideEventFx.start(0.8)}});item.addEvent('mouseleave',function(e){var hideEventFx=new Fx.Tween(item,{property:'opacity',duration:400,transition:Fx.Transitions.Cubic.easeOut,wait:false});if(item.hasClass('unselected')){hideEventFx.start(0.2)}else{}});item.addEvent('click',function(e){window.location.href=hrefs[i]})});filter.each(function(item,i){item.addEvent('mouseover',function(e){var str=e.target.src;e.target.src=str.replace("_off.gif","_on.gif")});item.addEvent('mouseout',function(e){var str=e.target.src;if(tws.topEventSelectedGenre==e.target.id.substring(7)){e.target.src=str.replace("_off.gif","_on.gif")}else{e.target.src=str.replace("_on.gif","_off.gif")}});item.addEvent('mousedown',function(e){var str=e.target.src;if(e.target.id.substring(7)=='all'){if(tws.topEventSelectedGenre!=''){for(var i=0;i<selBtn.length;i++){var str=selBtn[i].src;selBtn[i].src=str.replace("_on.gif","_off.gif")}tws.topEventSelectedGenre=''}for(var i=0;i<genres.length;i++){showEvents(genres[i])}}else{if(tws.topEventSelectedGenre!=e.target.id.substring(7)){if(tws.topEventSelectedGenre==''){var strl=selBtn[0].src;selBtn[0].src=strl.replace("_on.gif","_off.gif")}for(var i=1;i<selBtn.length;i++){if(selBtn[i].id.substring(7)!=e.target.id.substring(7)){var str=selBtn[i].src;selBtn[i].src=str.replace("_on.gif","_off.gif")}else{tws.topEventSelectedGenre=selBtn[i].id.substring(7)}}for(var i=0;i<genres.length;i++){if(tws.topEventSelectedGenre!=genres[i]){hideEvents(genres[i])}else{showEvents(tws.topEventSelectedGenre)}}}}e.stop()})})};
