flyui.namespace("flyui.apps.expressionmashup");flyui.apps.expressionmashup.Application=function(){var A=null;var D=null;var F=null;var B=null;var G=null;var E=null;var C=this;this.initGenefinder=function(){try{flyui.info("instantiate a service for the genefinder widget");var H=new flyui.flybase.Service("../../../data/flybase");flyui.info("instantiate a renderer for the genefinder widget");var K=document.getElementById("genefinderWidget");var J=new flyui.genefinder.DefaultRenderer();J.setCanvas(K);flyui.info("instantiate a genefinder widget");A=new flyui.genefinder.Widget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initFlyatlas=function(){try{flyui.info("instantiate a service for the flyatlas widget");var H=new flyui.flyatlas.Service();H.setEndpoint("../../../data/flyatlas");flyui.info("instantiate a renderer for the flyatlas widget");var J=new flyui.flyatlas.Widget.DefaultRenderer();J.setCanvas($("#flyatlasWidget"));flyui.info("instantiate a flyatlas widget");D=new flyui.flyatlas.Widget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initFlybasepub=function(){try{flyui.info("instantiate a service for the flybase publication widget");var H=new flyui.flybasepub.Service();H.setEndpoint("../../../data/flybase");flyui.info("instantiate a renderer for the flybase publication widget");var J=new flyui.flybasepub.PublicationWidget.SimpleRenderer();J.setCanvas($("#flybasepubPublicationWidget"));flyui.info("instantiate a flybase publication widget");G=new flyui.flybasepub.PublicationWidget(H,J)}catch(I){flyui.apps.publicationmashup.handleError(I)}};this.initFlyted=function(){try{flyui.info("instantiate a service for the flyted image widget");var H=new flyui.flyted.Service("../../../data/flyted");flyui.info("instantiate a renderer for the flyted image widget");var K=document.getElementById("flytedImageWidget");var J=new flyui.flyted.ImageWidget.DefaultRenderer();J.setCanvas(K);flyui.info("instantiate a flyted image widget");F=new flyui.flyted.ImageWidget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initBdgp=function(){try{flyui.info("instantiate a service for the bdgp image widget");var H=new flyui.bdgp.Service("../../../data/bdgp");flyui.info("instantiate a renderer for the bdgp image widget");var K=document.getElementById("bdgpImageWidget");var J=new flyui.bdgp.ImageWidget.CompactRenderer();J.setCanvas(K);flyui.info("instantiate a bdgp image widget");B=new flyui.bdgp.ImageWidget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initState=function(){try{var K=new String(window.location.href);var N=K.indexOf("#query=");var J=K.indexOf(";selection=");if(N>0){var H=(J>0)?J:K.length;var M=K.substring(N+7,H);flyui.info("found query: "+M);A.findGenesByAnyName(M,false)}if(J>0){var L=K.substring(J+11,K.length);flyui.info("found selection: "+L);E=L}}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.init=function(){try{var I=new YAHOO.widget.LogReader("logger");this.initGenefinder();this.initFlyatlas();this.initFlyted();this.initBdgp();this.initFlybasepub();A.subscribe("GENESELECTED",this.onGeneSelected,null);A.subscribe("GENESFOUND",this.onGenesFound,null);flyui.info("hook form submission to widget call");YAHOO.util.Event.addListener("queryForm","submit",this.onFormSubmitted);flyui.info("application loaded, showing main pane");flyui.mvcutils.hide(document.getElementById("loadingPane"));flyui.mvcutils.show(document.getElementById("applicationPane"));this.initState()}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.onGenesFound=function(M,J){try{flyui.info("application: genes found");var L=J[0];if(E!=null){flyui.info("attempting to apply deferred selection: "+E);var I=-1;for(var K=0;K<L.length;K++){if(E==L[K].flybaseID){I=K}}if(I==0&&L.length==1){flyui.info("no need to apply deferred selection, only one result")}else{if(I>=0&&L.length>1){A.setSelectionIndex(I)}else{flyui.err("failed to apply deferred selection: "+E)}}E=null}}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.onGeneSelected=function(J,I){try{var K=I[0];flyui.info("gene selected: "+K+" "+K.flybaseID);D.getAssaysByGene(K);F.findImagesByGene(K);B.findImagesByGene(K);G.findPublicationsByGene(K);flyui.mvcutils.show(document.getElementById("flyatlasWidget"));flyui.mvcutils.show(document.getElementById("flytedImageWidget"));flyui.mvcutils.show(document.getElementById("bdgpImageWidget"));flyui.mvcutils.show(document.getElementById("flybasepubPublicationWidget"));C.setSelectionState(K)}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.onFormSubmitted=function(J){try{flyui.info("form submitted");$("#errorMessage").hide().html("this should never be visible");var K=document.getElementById("queryInput").value;document.getElementById("queryInput").value="";var H=false;flyui.info("case sensitive: "+H);A.findGenesByAnyName(K,H);flyui.mvcutils.hide(document.getElementById("flyatlasWidget"));flyui.mvcutils.hide(document.getElementById("flytedImageWidget"));flyui.mvcutils.hide(document.getElementById("bdgpImageWidget"));flyui.mvcutils.hide(document.getElementById("flybasepubPublicationWidget"));C.setQueryState(K)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.setQueryState=function(K){try{var I=new String(window.location.href);var J=I.indexOf("#");if(J>0){I=I.substring(0,J)}window.location.href=I+"#query="+K}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.setSelectionState=function(K){try{var I=new String(window.location.href);var J=I.indexOf(";selection=");if(J>0){I=I.substring(0,J)}window.location.href=I+";selection="+K.flybaseID}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.init()};flyui.apps.expressionmashup.handleError=function(A){flyui.err(A.name+" :: "+A.message);$("#errorMessage").html("an error has occurred, please see the log for more details").show()};YAHOO.util.Event.onDOMReady(function(){new flyui.apps.expressionmashup.Application()})