var panes=["searchFields","tagCloud","countrytagCloud","geoMap"];function updateCurrentSelectedTab(A){$("currentSelectedTab").value=A}function disableFields(A,C){var D=document.getElementsByClassName(A,C);for(var B=0;B<D.length;B++){D[B].disabled="disabled"}}function enableFields(A,C){var D=document.getElementsByClassName(A,C);for(var B=0;B<D.length;B++){D[B].disabled=""}}function searchProfile(){if(null!=$("countryCodeParam")){document.getElementById("countryCodeParam").value=""}resetErrorsInSearchPages();var A=Form.Methods.serialize(document.forms.SearchTabForm);showWorkingImage("searchResultsContainer",true,false);new Ajax.Updater("searchResultsContainer","ProfileSearch.action",Object.extend({parameters:A},{onComplete:function(B){var C=B.responseText;if(C.match("errorDiv")){document.getElementById("searchResultsContainer").style.display="none";document.getElementById("searchErrorDiv").innerHTML=C;C="";ShowProfile();return }else{document.getElementById("searchResultsContainer").style.display="block";document.getElementById("searchErrorDiv").innerHTML="";hideProfile()}}}))}function searchProfileByKeywords(A){var B=document.forms.SearchTabForm;var D=document.forms.CountryCloudTabForm;var E=document.getElementById("countryCodeParam");if(null!=B){resetForm(B,"homeSearchTextBox")}if(null!=D){resetForm(D,"homeSearchTextBox")}resetErrorsInSearchPages();$("keyword").value=A;var C=new Hash();C["criteria.keywords"]=A;showWorkingImage("searchResultsContainer",true,false);new Ajax.Updater("searchResultsContainer","ProfileSearch.action",Object.extend({parameters:C.toQueryString()},{onComplete:function(F){var G=F.responseText;if(G.match("errorDiv")){document.getElementById("searchResultsContainer").style.display="none";document.getElementById("keywordsErrorDiv").innerHTML=G;G="";ShowKeywords();return }else{document.getElementById("searchResultsContainer").style.display="block";document.getElementById("keywordsErrorDiv").innerHTML="";hideKeywords()}}}))}function searchProfileByCountry(D){var A=document.forms.SearchTabForm;var C=document.forms.KeywordsTabForm;if(null!=A){resetForm(A,"homeSearchTextBox")}if(null!=C){resetForm(C,"homeSearchTextBox")}resetErrorsInSearchPages();$("countryCloud").value=D;var B=new Hash();B["criteria.country"]=D;showWorkingImage("searchResultsContainer",true,false);new Ajax.Updater("searchResultsContainer","ProfileSearch.action",Object.extend({parameters:B.toQueryString()},{onComplete:function(E){var F=E.responseText;if(F.match("errorDiv")){document.getElementById("searchResultsContainer").style.display="none";document.getElementById("countriesErrorDiv").innerHTML=F;F="";ShowCountries();return }else{document.getElementById("searchResultsContainer").style.display="block";document.getElementById("countriesErrorDiv").innerHTML="";hideCountries()}}}))}function hideProfile(){document.getElementById("searchState").value="hide";document.getElementById("showInSearch").style.display="";document.getElementById("hideInSearch").style.display="none";document.getElementById("showhide").style.display="none";document.getElementById("ShowSearchOptions").style.display="";document.getElementById("showLeftCorner").style.display="";document.getElementById("showRightCorner").style.display=""}function showProfile(){document.getElementById("searchState").value="show";document.getElementById("hideInSearch").style.display="";document.getElementById("showInSearch").style.display="none";document.getElementById("showhide").style.display="";document.getElementById("ShowSearchOptions").style.display="none";document.getElementById("showLeftCorner").style.display="none";document.getElementById("showRightCorner").style.display="none"}function hideKeywords(){document.getElementById("searchState").value="hide";document.getElementById("showInKeywords").style.display="";document.getElementById("hideInKeywords").style.display="none";document.getElementById("ShowKeywordsOptions").style.display="";document.getElementById("showkeywords").style.display="none";document.getElementById("showleft").style.display="";document.getElementById("showright").style.display=""}function showKeywords(){document.getElementById("searchState").value="show";document.getElementById("hideInKeywords").style.display="";document.getElementById("showInKeywords").style.display="none";document.getElementById("ShowKeywordsOptions").style.display="none";document.getElementById("showkeywords").style.display="";document.getElementById("showleft").style.display="none";document.getElementById("showright").style.display="none"}function hideCountries(){document.getElementById("searchState").value="hide";document.getElementById("showInCountries").style.display="";document.getElementById("hideInCountries").style.display="none";document.getElementById("ShowCountriesOptions").style.display="";document.getElementById("showcountries").style.display="none";document.getElementById("showleftImg").style.display="";document.getElementById("showrightImg").style.display=""}function showCountries(){document.getElementById("searchState").value="show";document.getElementById("hideInCountries").style.display="";document.getElementById("showInCountries").style.display="none";document.getElementById("ShowCountriesOptions").style.display="none";document.getElementById("showcountries").style.display="";document.getElementById("showleftImg").style.display="none";document.getElementById("showrightImg").style.display="none"}function hideGeoMaps(){document.getElementById("searchState").value="hide";document.getElementById("showInGeoMaps").style.display="";document.getElementById("hideInGeoMaps").style.display="none";document.getElementById("ShowGeoMapOptions").style.display="";document.getElementById("showGeoMaps").style.display="none";document.getElementById("showleftImage").style.display="";document.getElementById("showrightImage").style.display=""}function showGeoMaps(){document.getElementById("searchState").value="show";document.getElementById("hideInGeoMaps").style.display="";document.getElementById("showInGeoMaps").style.display="none";document.getElementById("ShowGeoMapOptions").style.display="none";document.getElementById("showGeoMaps").style.display="";document.getElementById("showleftImage").style.display="none";document.getElementById("showrightImage").style.display="none"}function showPage(A){if(isNaN(A)){alert("Enter a numeric value");return }if(A<0){A=1}else{if(parseInt($("lastPageNumber").value)!=0&&A>parseInt($("lastPageNumber").value)){A=parseInt($("lastPageNumber").value)}}$("pageNumber").value=A;$("selectedTabInResult").value=$("currentSelectedTab").value;var B=Form.Methods.serialize(document.forms.ProfileResultForm);showWorkingImage("resultContainer",false,true);new Ajax.Updater("resultContainer","PartialProfileSearch.action",{parameters:B})}function sortProfile(A){$("totalNumberOfResults").value=0;$("sortOrderSelected").value=A.value;showPage(1)}function navigateTo(B){var A=document.forms.navigatableForm;$("selectedTabInResults").value=$("currentSelectedTab").value;A.action="/rid/"+B;A.method="POST";A.submit()}function showMap(){showWorldMapTab("filterMap",true)}function clearMap(){showWorldMapTab("clearMap",true)}function ShowPrevious(){if(document.getElementById("searchState").value=="show"){showProfile();showKeywords();showCountries();showGeoMaps()}else{hideProfile();hideKeywords();hideCountries();hideGeoMaps()}}function showSearchTab(H){var B="";if(null!=document.getElementById("pageErrorDiv")){B=document.getElementById("pageErrorDiv").innerHTML}var A="SearchTabForm";var D=$("selectedForm").value;$("selectedForm").value=A;var G=getCriteriaParamMap().toQueryString();var C=document.getElementById("searchTabLoaded").value;if("false"==C){new Ajax.Updater("searchFields","FetchSearchTab.action",Object.extend({parameters:G},{onComplete:function(I){if(B.length==0){if(false==H&&document.getElementById("searchStatus").value=="hide"){hideProfile()}}else{document.getElementById("searchErrorDiv").innerHTML=B}}}))}else{showProfile();if(D==A){return }}if(null!=$("ProfileResultForm")){setValueToBox("lastNameInResults","lastName");setValueToBox("firstNameInResults","firstName");setValueToBox("otherNameBoxInResults","includeOtherName");setValueToBox("pastInstBoxInResults","includePastInstitutions");setValueToBox("instNameInResults","institution");setValueToBox("countryInResults","country");setValueToBox("keywordsInResults","keywords");setValueToBox("researcherIdInResults","researcherID")}else{var E=document.forms.SearchTabForm;var F=$("searchTabLoaded");if(null!=E&&null!=F&&"true"==F.value){resetForm(E,"homeSearchTextBox")}}document.getElementById("searchFields").style.display="";document.getElementById("tagCloud").style.display="none";document.getElementById("countrytagCloud").style.display="none";document.getElementById("geoMap").style.display="none";switchTo(panes[0],updateCurrentSelectedTab,imageUrl)}function showKeywordsTab(F){var A="KeywordsTabForm";var C=$("selectedForm").value;$("selectedForm").value=A;var E=getCriteriaParamMap().toQueryString();var B=document.getElementById("keywordsLoaded").value;if("false"==B){new Ajax.Updater("tagCloud","FetchKeywordsTab.action",Object.extend({parameters:E},{onComplete:function(){if(false==F&&document.getElementById("searchStatus").value=="hide"){hideKeywords()}}}))}else{showKeywords();if(C==A){return }}if(null!=$("ProfileResultForm")){setValueToBox("keywordsInResults","keyword")}else{var D=document.forms.KeywordsTabForm;var G=$("keywordsLoaded");if(null!=D&&null!=G&&"true"==G.value){resetForm(D,"homeSearchTextBox")}}document.getElementById("searchFields").style.display="none";document.getElementById("tagCloud").style.display="";document.getElementById("countrytagCloud").style.display="none";document.getElementById("geoMap").style.display="none";switchTo(panes[1],updateCurrentSelectedTab,imageUrl)}function showCountryTab(G){var A="CountryCloudTabForm";var C=$("selectedForm").value;$("selectedForm").value=A;var F=getCriteriaParamMap().toQueryString();var B=document.getElementById("countriesLoaded").value;if("false"==B){new Ajax.Updater("countrytagCloud","FetchCountryCloudTab.action",Object.extend({parameters:F},{onComplete:function(){if(false==G&&document.getElementById("searchStatus").value=="hide"){hideCountries()}}}))}else{showCountries();if(C==A){return }}if(null!=$("ProfileResultForm")){setValueToBox("countryInResults","countryCloud")}else{var D=document.forms.CountryCloudTabForm;var E=$("countriesLoaded");if(null!=D&&null!=E&&"true"==E.value){resetForm(D,"homeSearchTextBox")}}document.getElementById("searchFields").style.display="none";document.getElementById("tagCloud").style.display="none";document.getElementById("countrytagCloud").style.display="";document.getElementById("geoMap").style.display="none";switchTo(panes[2],updateCurrentSelectedTab,imageUrl)}function showWorldMapTab(E,G){var D="WorldMapTabForm";var C=$("selectedForm").value;$("selectedForm").value=D;var B="WorldMap.action";var A=document.getElementById("worldMapLoaded").value;if(E=="filterMap"){B="FilterWorldMap.action"}var F=getCriteriaParamMap().toQueryString();new Ajax.Updater("geoMap",B,Object.extend({parameters:F},{onComplete:function(){if(false==G&&document.getElementById("searchStatus").value=="hide"){hideGeoMaps()}}}));document.getElementById("searchFields").style.display="none";document.getElementById("tagCloud").style.display="none";document.getElementById("countrytagCloud").style.display="none";document.getElementById("geoMap").style.display="";switchTo(panes[3],updateCurrentSelectedTab,imageUrl)}function initialiseTabs(A){if(panes[1]==A){showKeywordsTab(false)}else{if(panes[2]==A){showCountryTab(false)}else{if(panes[3]==A){showWorldMapTab("worldMap",false)}else{showSearchTab(false)}}}}function showWorkingImage(F,G,C){var B="";var E="working.gif";if(G){B="<br/>&nbsp;&nbsp;&nbsp;&nbsp;"}if(C){E="working2.gif"}var A=document.getElementById(F);if(null!=A&&undefined!=A){var D=document.getElementById("imageUrl").value;A.innerHTML=B+"<img src='"+D+"/"+E+"' height='22' width='88' title='working' alt='working'/>"}}function resetErrorsInSearchPages(){var C=$("searchErrorDiv");var B=$("keywordsErrorDiv");var A=$("countriesErrorDiv");if(null!=C){C.innerHTML=""}if(null!=B){B.innerHTML=""}if(null!=A){A.innerHTML=""}}function setValueToBox(B,A){if(null!=$(B)&&null!=$(A)){var C=$(B).value;if(null!=C){if($(A).type=="checkbox"){if("true"==C){$(A).checked=true}else{$(A).checked=false}}else{if($(A).type=="select-one"){if(""==C){$(A).value=$(A).options[0].value}else{$(A).value=C}}else{$(A).value=C}}}}}function getCriteriaParamMap(){var B=new Hash();if(null!=$("ProfileResultForm")){B["criteria.lastName"]=$("lastNameInResults").value;B["criteria.firstName"]=$("firstNameInResults").value;B["criteria.includeOtherName"]=$("otherNameBoxInResults").value;B["criteria.includePastInstitutions"]=$("pastInstBoxInResults").value;B["criteria.institution"]=$("instNameInResults").value;B["criteria.keywords"]=$("keywordsInResults").value;B["criteria.country"]=$("countryInResults").value;B["criteria.countryCode"]=$("countryCodeInResults").value;B["criteria.researcherId"]=$("researcherIdInResults").value}else{var A=getURLParam("criteria.lastName");if(A!=null&&A!=""){B["criteria.lastName"]=A}}return B}function getURLParam(C){C=C.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var B="[\\?&]"+C+"=([^&#]*)";var D=new RegExp(B);var A=D.exec(window.location.href);if(null==A){return""}else{return A[1]}};
