flyui.namespace("flyui.apps.imagemashup2");flyui.apps.imagemashup2.Application=function(){var A=null;var E=null;var B=null;var D=null;var C=this;this.initGenefinder=function(){var G="initGenefinder";try{flyui.info("instantiate a service for the genefinder widget",G);var F=new flyui.flybase.Service("../../../data/flybase");flyui.info("instantiate a renderer for the genefinder widget",G);var J=document.getElementById("genefinderWidget");var H=new flyui.genefinder.DefaultRenderer();H.setCanvas(J);flyui.info("instantiate a genefinder widget",G);A=new flyui.genefinder.Widget(F,H)}catch(I){flyui.err("unexpected error: "+I.name+" "+I.message,G);throw I}};this.initFlyted=function(){var G="initFlyted";try{flyui.info("instantiate a service for the flyted image widget",G);var F=new flyui.flyted.Service("../../../data/flyted");flyui.info("instantiate a renderer for the flyted image widget",G);var J=document.getElementById("flytedImageWidget");var H=new flyui.flyted.ImageWidget.DefaultRenderer();H.setCanvas(J);flyui.info("instantiate a flyted image widget",G);E=new flyui.flyted.ImageWidget(F,H)}catch(I){flyui.err("unexpected error: "+I.name+" "+I.message,G);throw I}};this.initBdgp=function(){var G="initBdgp";try{flyui.info("instantiate a service for the bdgp image widget",G);var F=new flyui.bdgp.Service("../../../data/bdgp");flyui.info("instantiate a renderer for the bdgp image widget",G);var J=document.getElementById("bdgpImageWidget");var H=new flyui.bdgp.ImageWidget.DefaultRenderer();H.setCanvas(J);flyui.info("instantiate a bdgp image widget",G);B=new flyui.bdgp.ImageWidget(F,H)}catch(I){flyui.err("unexpected error: "+I.name+" "+I.message,G);throw I}};this.initState=function(){var G="initState";try{var I=new String(window.location.href);var M=I.indexOf("#query=");var H=I.indexOf(";selection=");if(M>0){var F=(H>0)?H:I.length;var K=I.substring(M+7,F);flyui.info("found query: "+K,G);A.findGenesByAnyName(K,false)}if(H>0){var J=I.substring(H+11,I.length);flyui.info("found selection: "+J,G);D=J}}catch(L){flyui.err("unexpected error: "+L.name+" "+L.message,G);throw L}};this.init=function(){var F="init";try{var H=new YAHOO.widget.LogReader("logger");this.initGenefinder();flyui.info("init flyted widget",F);this.initFlyted();flyui.info("init bdgp widget",F);this.initBdgp();A.subscribe("GENESELECTED",this.onGeneSelected,null);A.subscribe("GENESFOUND",this.onGenesFound,null);flyui.info("hook form submission to widget call",F);YAHOO.util.Event.addListener("queryForm","submit",this.onFormSubmitted);flyui.info("application loaded, showing main pane",F);flyui.mvcutils.hide(document.getElementById("loadingPane"));flyui.mvcutils.show(document.getElementById("applicationPane"));this.initState()}catch(G){flyui.err("unexpected error: "+G.name+" "+G.message,F);throw G}};this.onGenesFound=function(L,I){var F="onGenesFound";try{flyui.info("application: genes found",F);var K=I[0];if(D!=null){flyui.info("attempting to apply deferred selection: "+D,F);var H=-1;for(var J=0;J<K.length;J++){if(D==K[J].flybaseID){H=J}}if(H>=0&&K.length>1){A.setSelectionIndex(H)}else{flyui.err("failed to apply deferred selection: "+D,F)}D=null}}catch(G){flyui.err("unexpected error: "+G.name+" "+G.message,F);throw G}};this.onGeneSelected=function(I,H){var F="onGeneSelected";try{var J=H[0];flyui.info("gene selected: "+J+" "+J.flybaseID,F);E.findImagesByGene(J);B.findImagesByGene(J);flyui.mvcutils.show(document.getElementById("flytedImageWidget"));flyui.mvcutils.show(document.getElementById("bdgpImageWidget"));C.setSelectionState(J)}catch(G){flyui.err("unexpected error: "+G.name+" "+G.message,F);throw G}};this.onFormSubmitted=function(I){var G="onFormSubmitted";try{flyui.info("form submitted",G);var J=document.getElementById("queryInput").value;document.getElementById("queryInput").value="";var F=false;flyui.info("case sensitive: "+F,G);A.findGenesByAnyName(J,F);flyui.mvcutils.hide(document.getElementById("flytedImageWidget"));flyui.mvcutils.hide(document.getElementById("bdgpImageWidget"));C.setQueryState(J)}catch(H){flyui.err("unexpected error: "+H.name+" "+H.message,G);throw H}};this.setQueryState=function(H){var F=new String(window.location.href);var G=F.indexOf("#");if(G>0){F=F.substring(0,G)}window.location.href=F+"#query="+H};this.setSelectionState=function(H){var F=new String(window.location.href);var G=F.indexOf(";selection=");if(G>0){F=F.substring(0,G)}window.location.href=F+";selection="+H.flybaseID};this.init()};YAHOO.util.Event.onDOMReady(function(){new flyui.apps.imagemashup2.Application()})