var trackMenu;var scheduleMenu;var sessionBrowser;var loader=false;var productList=[];var skillsList=[];var instancesList=[];var audienceTypes=[];var speakerList=[];var typesList=[];var filters;var filtersLoaded=0;var filtersLoadedTimer=false;var originalWindowHeight=0;var listHeight=0;var addSessionToScheduleFunction;var removeSessionFromScheduleFunction;var displayFilesForEveryone=true;Event.onDOMReady(function(){Prototype.Browser.IE6=(navigator.appVersion.indexOf("MSIE 6")>0);Prototype.Browser.IE7=(navigator.appVersion.indexOf("MSIE 7")>0);Prototype.Browser.Firefox2Mac=((navigator.userAgent.indexOf("Firefox/2")>0)&&(navigator.userAgent.indexOf("Mac")>0));originalWindowHeight=document.documentElement.clientHeight;listHeight=$("sessions").getDimensions().height;loader=new FancyLoader();loginService=new BySessionLoginService();sessionBrowser=new SessionBrowser();trackMenu=new TrackMenu((Prototype.Browser.IE?function(){setTimeout(sessionBrowser.refresh.bind(sessionBrowser),25)}:sessionBrowser.refresh.bind(sessionBrowser)));scheduleMenu=new ScheduleMenu();loadFilter("skills",$("filterSkillLevel"),skillsList);loadFilter("audienceTypes",$("filterAudienceTypes"),audienceTypes);loadFilter("products",$("filterProducts"),productList);loadFilter("speakers",$("filterSpeakers"),speakerList);loadFilter("sessionTypes",$("filterTypes"),typesList);filtersLoadedTimer=setInterval(function(){if(filtersLoaded==5){clearInterval(filtersLoadedTimer);filtersLoadedTimer=false;try{loginService.checkLogin()}catch(A){alert(A.message)}sessionBrowser.refresh()}},100);Event.observe(window,"resize",sessionBrowser.handleResize.bind(sessionBrowser));sessionBrowser.handleResize();popupService=new SpeakerPopupService("popup");popupServiceShower=popupService.show.bind(popupService);addSessionToScheduleFunction=sessionBrowser.addSessionToSchedule.bind(sessionBrowser);removeSessionFromScheduleFunction=sessionBrowser.removeSessionFromSchedule.bind(sessionBrowser);$("download-pdf").observe("click",sessionBrowser.downloadPDF.bind(sessionBrowser))});var timer=false;var BySessionLoginService=Class.create(LoginService,{initializeCallback:function(){var A=new Element("div",{position:"absolute",display:"none"});document.getElementsByTagName("body")[0].appendChild(A);if(Prototype.Browser.IE7){$("save").setStyle({position:"relative"})}else{$("save").setStyle({position:"static"})}A.appendChild($("save"))},logoutCallback:function(){$("download-pdf").show();var C=$$("div.instance");for(var A=0;A<C.length;A++){C[A].removeChild(C[A].firstChild)}if(!displayFilesForEveryone){var B=$$("tr.files");for(var A=0;A<B.length;A++){B[A].setStyle({display:"none"})}}var D=window.location.toString();setTimeout(function(){window.location=D},0)},_loginCallback:function(A){this.hideLogin(false,A.suppress);$("hello").setStyle({top:"95px"});$("download-pdf").hide();this.sessions=[];for(var D=0;D<A.sessions.length;D++){for(var B=0;B<A.sessions[D].length;B++){this.sessions.push(A.sessions[D][B])}}var G=$$("div.instance");for(var D=0;D<G.length;D++){var H=false;for(var B=0;B<this.sessions.length;B++){if(parseInt(G[D].getAttribute("id"))==parseInt(this.sessions[B])){var F=new Element("a");F.addClassName("remove-session");F.observe("click",removeSessionFromScheduleFunction);G[D].insertBefore(F,G[D].firstChild);H=true}}if(!H){var C=new Element("a");C.addClassName("add-session");C.observe("click",addSessionToScheduleFunction);G[D].insertBefore(C,G[D].firstChild)}}if(!displayFilesForEveryone){var E=$$("tr.files");for(var D=0;D<E.length;D++){E[D].setStyle({display:(Prototype.Browser.IE6||Prototype.Browser.IE7?"block":"table-row")})}}}});var SessionBrowser=Class.create({initialize:function(){this.container=$("list");this.cache=new Hash()},handleResize:function(A){var B=document.documentElement.clientHeight-156;$("sessions").setStyle({height:B+"px"});if(Prototype.Browser.IE){var C=$("content");var D=C.getDimensions().height;if(document.documentElement.clientHeight-D<136){C.setStyle({height:(document.documentElement.clientHeight-136)+"px"})}}},refresh:function(D){this.clear();this.setStatus("Searching...");loader.show();if(D&&(typeof D=="undefined")){D=false}else{if(D&&(typeof D=="object")){D=-1}}var E=window.location.toString().indexOf("#");if(E==-1&&D>0){window.location=window.location.toString()+"#"+D}else{if(E>0&&D>0){window.location=window.location.toString().substring(0,E+1)+D}else{if(E>0&&!D){D=window.location.toString().substring(E+1)}else{if(E>0&&D==-1){window.location=window.location.toString().substring(0,E+1)}}}}var B=[];if(D>0){trackMenu.setTrack(0);$("filterProducts").selectedIndex=0;$("filterAudienceTypes").selectedIndex=0;$("filterSpeakers").selectedIndex=0;$("filterSkillLevel").selectedIndex=0;$("filterTypes").selectedIndex=0;B.push("id="+D);setCookie($("filterProducts").id,$("filterProducts").getValue());setCookie($("filterAudienceTypes").id,$("filterAudienceTypes").getValue());setCookie($("filterSpeakers").id,$("filterSpeakers").getValue());setCookie($("filterSkillLevel").id,$("filterSkillLevel").getValue());setCookie($("filterTypes").id,$("filterTypes").getValue())}var A=parseInt(trackMenu.getTrack());var H=parseInt($("filterProducts").getValue());var C=parseInt($("filterAudienceTypes").getValue());var I=parseInt($("filterSpeakers").getValue());var F=parseInt($("filterSkillLevel").getValue());var G=parseInt($("filterTypes").getValue());if(A>0){B.push("track="+A)}if(H>0){B.push("product="+H)}if(C>0){B.push("audience="+C)}if(I>0){B.push("speaker="+I)}if(F>0){B.push("skill="+F)}if(G>0){B.push("type="+G)}new Ajax.Request("/"+urlPrefix+"/json/getAllSessionsWithFilter/?"+B.join("&"),{method:"get",onSuccess:(function(L,J){var K=L.responseText.evalJSON();loader.hide();this.populate(K)}).bind(this)})},clear:function(){for(var A=this.container.childNodes.length-1;A>=0;A--){this.container.removeChild(this.container.childNodes[A])}},populate:function(D){loader.hide();this.setStatus(D.length+" session"+(D.length!=1?"s":"")+" found."+(D.length?" Click on speaker's name for bio.":""));for(var A=0;A<D.length;A++){try{this.container.appendChild(this.getDiv(D[A]))}catch(C){log(C.message)}}if(D.length==0){var B=$(document.createElement("div"));B.addClassName("no-sessions");B.appendChild(document.createTextNode("No matching sessions found."));this.container.appendChild(B)}},getDiv:function(I){var C=new Element("div",{"class":"details"});switch(parseInt(I.type)){case 1:C.addClassName("sess");break;case 2:C.addClassName("lab");break;case 3:C.addClassName("preevent");break}var J=document.createElement("h1");var L=new Element("a",{href:"javascript:sessionBrowser.refresh("+I.id+")"});L.update(I.title);J.appendChild(L);var M=document.createElement("p");M.appendChild(document.createTextNode(I.description));C.appendChild(J);var H=$(document.createElement("div"));H.appendChild(M);C.appendChild(H);var K=$(document.createElement("table"));K.addClassName("info");var D=$(document.createElement("tbody"));if(I.speakers.length){var N=this.displaySpeakers(I.speakers,speakerList,"Speakers:");if(N){D.appendChild(N)}}if(I.audienceTypes.length){D.appendChild(this.displayIds(I.audienceTypes,audienceTypes,"Audience:"))}if(I.skillLevel){if($("filterSkillLevel").getValue()=="0"){D.appendChild(this.getRow("Skill:",skillsList[I.skillLevel]))}}if(I.products.length){if(!(I.products.length==1&&productList[I.products[0]]=="All")){D.appendChild(this.displayIds(I.products,productList,"Products:"))}}if(I.instances.length){var B=[];for(var G=0;G<I.instances.length;G++){var F=new Element("div");F.addClassName("instance");F.id=I.instances[G].id;F.appendChild(document.createTextNode(I.instances[G].date+", "+I.instances[G].times+", "+I.instances[G].room));B.push(F)}D.appendChild(this.getRow("When:",B))}else{D.appendChild(this.getRow("When:","TBA"))}if(I.files&&I.files.length){var A=[];for(var G=0;G<I.files.length;G++){var E=new Element("div");E.addClassName("file");E.appendChild(new Element("a",{href:"/content/uploads/"+I.files[G][0]+"/"+I.files[G][1]}).update(I.files[G][1]));A.push(E)}var N=$(this.getRow("Files:",A));if(!displayFilesForEveryone){if(loginService.isLoggedIn()){N.setStyle({display:(Prototype.Browser.IE6||Prototype.Browser.IE7?"block":"table-row")})}else{N.setStyle({display:"none"})}}N.addClassName("files");D.appendChild(N)}K.appendChild(D);C.appendChild(K);return C},setStatus:function(A){$("status").innerHTML=A},getRow:function(C,G,E){var H=document.createElement("tr");var F=$(document.createElement("td"));F.addClassName("label");var B=document.createElement("td");F.appendChild(document.createTextNode(C));if(typeof G=="string"){B.appendChild(document.createTextNode(G))}else{var A=", ";for(var D=0;D<G.length;D++){B.appendChild(G[D]);if(E&&D+1<G.length){B.appendChild(document.createTextNode(A))}}}H.appendChild(F);H.appendChild(B);return H},displayIds:function(D,B,E){var A=[];for(var C=0;C<D.length;C++){if(typeof B[D[C]]!="undefined"){A.push(B[D[C]])}}if(A.length==0){return this.getRow(E,"-")}return this.getRow(E,A.join(", "))},displaySpeakers:function(E,B,F){var A=[];for(var C=0;C<E.length;C++){if(B[E[C]]){var D=new Element("a",{href:"javascript:__click()",title:"Click to see bio."}).update(B[E[C]]);D.addClassName("speaker");D.setAttribute("speakerId",E[C]);D.observe("click",popupServiceShower);A.push(D)}}if(A.length==0){return false}return this.getRow(F,A,true)},addSessionToSchedule:function(C){var B=Event.element(C);var A=B.parentNode.getAttribute("id");popupX=x;popupY=y;new Ajax.Request("/"+urlPrefix+"/json/saveAttendeeSession/"+loginService.getUserId()+"/"+A,{method:"get",onSuccess:this._addSessionToSchedule.bind(this)})},_addSessionToSchedule:function(E,D){var B=E.responseText.evalJSON();if(B.error){if(B.expired){loginService.logout()}popupService.manualShow(popupX-Math.floor(popupService.popup.getDimensions().width/2),popupY,"Sorry!",B.message)}else{popupService.manualShow(popupX-Math.floor(popupService.popup.getDimensions().width/2),popupY,"Hooray!","This session was added to your schedule.");var A=$(B.instanceId);if(A){var C=$(A.firstChild);C.addClassName("remove-session");C.removeClassName("add-session");Event.stopObserving(C,"click",addSessionToScheduleFunction);C.observe("click",removeSessionFromScheduleFunction)}}},removeSessionFromSchedule:function(C){var B=Event.element(C);var A=B.parentNode.getAttribute("id");popupX=x;popupY=y;new Ajax.Request("/"+urlPrefix+"/json/removeAttendeeSession/"+loginService.getUserId()+"/"+A,{method:"get",onSuccess:this._removeSessionFromSchedule.bind(this)})},_removeSessionFromSchedule:function(E,D){var B=E.responseText.evalJSON();if(B.error){if(B.expired){loginService.logout()}popupService.manualShow(popupX-Math.floor(popupService.popup.getDimensions().width/2),popupY,"Sorry!",B.message)}else{popupService.manualShow(popupX-Math.floor(popupService.popup.getDimensions().width/2),popupY,"Hooray!","This session was removed from your schedule.");var A=$(B.instanceId);if(A){var C=$(A.firstChild);C.addClassName("add-session");C.removeClassName("remove-session");Event.stopObserving(C,"click",removeSessionFromScheduleFunction);C.observe("click",addSessionToScheduleFunction)}}},downloadPDF:function(){var G=[];var B=parseInt(trackMenu.getTrack());var F=parseInt($("filterProducts").getValue());var D=parseInt($("filterAudienceTypes").getValue());var C=parseInt($("filterSpeakers").getValue());var A=parseInt($("filterSkillLevel").getValue());var E=parseInt($("filterTypes").getValue());if(B>0){G.push("track="+B)}if(F>0){G.push("product="+F)}if(D>0){G.push("audience="+D)}if(C>0){G.push("speaker="+C)}if(A>0){G.push("skill="+A)}if(E>0){G.push("type="+E)}setTimeout(function(){window.location.href="/"+urlPrefix+"/json/sessions.pdf"+(G.length>0?"?"+G.join("&"):"")},0)}});var SpeakerPopupService=Class.create(PopupService,{show:function(B){if(!dragging){this.visible=true;var A=Event.element(B);var C=A.getAttribute("speakerId");if(C==null){return }this.setTitle("Loading...");this.setBody("Please wait while the bio loads...");this.setSpeaker(null);new Ajax.Request("/"+urlPrefix+"/json/getSpeakerBio/"+C,{method:"get",evalJSON:"force",onSuccess:this._setSpeakerBio.bind(this)});this.posX=Event.pointerX(B)-this.popup.getDimensions().width/2-20;this.posY=Event.pointerY(B)-this.popup.getDimensions().height;this.setPosition();this.height=this.popup.getDimensions().height}},setPosition:function(){if(Prototype.Browser.IE6){var B=$($("popupBody").parentNode);if(B.getDimensions().height){B.setStyle({height:B.getDimensions().height+"px"})}}if(this.posY<0){this.posY=10}if(this.posX<0){this.posX=10}var A=window.innerWidth?window.innerWidth:document.documentElement.clientWidth;var C=window.innerHeight?window.innerHeight:document.documentElement.clientHeight;if(this.posX+this.popup.getDimensions().width>A-10){this.posX-=this.posX+this.popup.getDimensions().width-A+20}if(this.height<this.popup.getDimensions().height){this.posY-=(this.popup.getDimensions().height-this.height);if(this.posY<0){this.posY=0}}if(!dragging){this.popup.setStyle({left:this.posX+"px",top:this.posY+"px"});this.popup.appear({duration:0.2})}},_setSpeakerBio:function(B){if(B.responseJSON==null){this.setTitle("Error");this.setBody("An error occurred while trying to retrieve this bio. Please try again shortly.");this.setPosition()}else{var A=B.responseText.evalJSON();if(!A.error){this.setTitle(A.speaker.FIRST_NAME+" "+A.speaker.LAST_NAME);this.setBody(A.speaker.BIO?A.speaker.BIO:"Bio not yet available.");this.setPosition()}else{this.setTitle("Error");this.setBody("An error occurred while trying to retrieve this bio. Please try again shortly.");this.setPosition()}}}});function loadFilter(A,C,B){new Ajax.Request("/"+urlPrefix+"/json/getFilter/"+A,{method:"get",onSuccess:function(H,F){var G=H.responseText.evalJSON();var E;if(C){E=getCookie(C.id)}for(var D=0;D<G.length;D++){if(C){appendToSelect(C,G[D].id,G[D].description,E==G[D].id)}B[G[D].id]=G[D].description}$(C).observe("change",saveFilter.bind(C));if(Prototype.Browser.IE){$(C).observe("change",function(I){sessionBrowser.refresh(I)})}else{$(C).observe("change",sessionBrowser.refresh.bind(sessionBrowser))}filtersLoaded++}})}function saveFilter(){setCookie(this.id,$(this).getValue())};