var jiveMenuTimeout;var jiveMenuIndex=-1;var jiveMenuID;function jiveKeypressMenuHandler(F){if(Element.visible(jiveMenuID)){var C=F.which||F.keyCode;var A;switch(C){case Event.KEY_DOWN:A=$(jiveMenuID).getElementsByTagName("li");if(jiveMenuIndex>-1&&jiveMenuIndex<(A.length-1)){A[jiveMenuIndex].className="jive-userbar-menu-nohover"}if(jiveMenuIndex<(A.length-1)){jiveMenuIndex++;A[jiveMenuIndex].className="jive-userbar-menu-hover"}break;case Event.KEY_UP:A=$(jiveMenuID).getElementsByTagName("li");if(jiveMenuIndex>0){A[jiveMenuIndex].className="jive-userbar-menu-nohover"}if(jiveMenuIndex>0){jiveMenuIndex--;A[jiveMenuIndex].className="jive-userbar-menu-hover"}break;case Event.KEY_RETURN:var B=$(jiveMenuID).getElementsByTagName("li");var D=B[jiveMenuIndex];var E=D.getElementsByTagName("a");if(E.length>0){document.location.href=E[0].href}break}Event.stop(F)}}function jivetoggleMenu(C){clearTimeout(jiveMenuTimeout);if($("jiveContentCreatePanel")){if($("jiveContentCreatePanel").visible()){$("jiveContentCreatePanel").hide();var B=$("jiveContentCreateContainer").childElements();B.each(function(D){$(D).remove()})}}if($("jiveTaskCreatePanel")){if($("jiveTaskCreatePanel").visible()){$("jiveTaskCreatePanel").hide();var B=$("jiveTaskCreateContainer").childElements();B.each(function(D){$(D).remove()})}}var A=$(C).hasClassName("jive-userbar-menu-hidden")!=true;if(!A){jiveCloseAllMenus();$(C).removeClassName("jive-userbar-menu-hidden");$(C+"Link").addClassName("jive-userbar-droplink-on");jiveMenuID=C;Event.observe(document,"keypress",jiveKeypressMenuHandler,true)}}function jiveSwapMenu(C){clearTimeout(jiveMenuTimeout);var B=null;var D=$$(".jive-userbar-menu");for(var A=0;A<D.length;A++){if(D[A].hasClassName("jive-userbar-menu-hidden")!=true){B=D[A];break}}if(B!=null){if(B.id!=C){jiveCloseAllMenus();$(C).removeClassName("jive-userbar-menu-hidden");$(C+"Link").addClassName("jive-userbar-droplink-on")}}}function jiveInsideMenu(){clearTimeout(jiveMenuTimeout)}function jiveOutsideMenu(A){try{var B=A.relatedTarget||A.toElement;if(typeof (B)!="undefined"){while(B.parentNode&&(typeof (B.tagName)=="undefined"||B.tagName.toUpperCase()!="DIV")){B=B.parentNode}}if(typeof (B)=="undefined"||!B.tagName||(!Element.hasClassName(B,"jive-userbar-menu"))){jiveMenuTimeout=setTimeout("jiveCloseAllMenus()",1500)}}catch(C){jiveMenuTimeout=setTimeout("jiveCloseAllMenus()",1500)}}function jiveLoadMenus(){var C=$$(".jive-userbar-menu");for(var A=0;A<C.length;A++){var B=document.getElementById(C[A].id+"Link")}}function jiveCloseAllMenus(){var D=$$(".jive-userbar-menu");for(var C=0;C<D.length;C++){if(D[C].hasClassName("jive-userbar-menu-hidden")!=true){$(D[C]).addClassName("jive-userbar-menu-hidden");$(D[C].id+"Link").removeClassName("jive-userbar-droplink-on");var B=D[C].getElementsByTagName("li");for(var A=0;A<B.length;A++){B[A].className="jive-userbar-menu-nohover"}}}Event.stopObserving(document,"keypress",jiveKeypressMenuHandler,true);jiveMenuIndex=-1}function jiveGetY(A){var B=0;if(A.offsetParent){while(A.offsetParent){B+=A.offsetTop;A=A.offsetParent}}return B}function jiveGetX(B){var A=0;if(B.offsetParent){while(B.offsetParent){A+=B.offsetLeft;B=B.offsetParent}}return A}function jiveEscapeKey(A){var B=document.layers?A.which:document.all?event.keyCode:document.getElementById?A.keyCode:0;if(B==27){jiveCloseAllMenus()}}function jiveBodyClick(B){B=B||window.event;var C=Event.findElement(B,"div");if(C){var A=Event.element(B).parentNode;if(!C.tagName||(C.id!="jive-userbar-droplink"&&!Element.hasClassName(C,"jive-userbar-menu")&&!Element.hasClassName(A,"dhtmlTreeStyle")&&!Element.hasClassName(A.parentNode,"dhtmlTreeStyle"))){jiveCloseAllMenus()}}}function jiveChooseContainerForm(A){jiveCloseAllMenus();Element.addClassName(document.body,"jive-progresscursor");new Ajax.Updater("jiveContentCreateContainer",A,{evalScripts:true,onComplete:function(){new Effect.SlideDown("jiveContentCreatePanel",{duration:0.7});Element.removeClassName(document.body,"jive-progresscursor")}})}function jiveSubmitChooseContainerForm(B,A){$("jive-choose-container-type").value=B;$("jive-choose-container-id").value=A;$("jiveChooseContainerForm").submit()}function jiveRemoveChooseContainerForm(){new Effect.SlideUp("jiveContentCreatePanel",{duration:0.7,afterFinish:function(){var A=$("jiveContentCreateContainer").childElements();A.each(function(B){B.remove()})}})}function jiveAdvancedChooseContainerForm(A){var B=$("jiveChooseContainerForm").serialize(true);A+="?contentType=";A+=B.contentType;if(B.upload){A+="&upload=";A+=B.upload}parent.location.href=A}function jiveShowQuickTaskForm(A){jiveCloseAllMenus();Element.addClassName(document.body,"jive-progresscursor");var C=jiveGetSelectedText();var B;if(C!=""){B={subject:C}}new Ajax.Updater("jiveTaskCreateContainer",A,{parameters:B,evalScripts:true,onComplete:function(){new Effect.SlideDown("jiveTaskCreatePanel",{duration:0.7,afterFinish:function(){document.jivequicktaskform.subject.focus()}});Element.removeClassName(document.body,"jive-progresscursor")}})}function jiveSubmitQuickTaskForm(A){new Ajax.Updater("jiveTaskCreateContainer",A,{parameters:$("jivequicktaskform").serialize(true),evalScripts:true})}function jiveRemoveQuickTaskForm(){new Effect.SlideUp("jiveTaskCreatePanel",{duration:0.7,afterFinish:function(){var A=$("jiveTaskCreateContainer").childElements();A.each(function(B){B.remove()})}})}function jiveSendToAdvancedTaskForm(A){var B=$(document.jivequicktaskform).serialize(true);A+="?subject=";A+=B.subject;if(B.project){A+="&project=";A+=B.project}if(B.owner){A+="&owner=";A+=B.owner}if(B.dueDate){A+="&dueDate=";A+=B.dueDate}parent.location.href=A}function jiveGetSelectedText(){var A="";if(window.getSelection){A=window.getSelection()}else{if(document.all){A=document.selection.createRange().text}else{if(document.getSelection){A=document.getSelection()}}}return A}function jivetoggleLogin(){Element.toggle("jiveLoginWelcome");Element.toggle("jiveLoginForm");if($("jiveLoginForm").style.display!="none"){$("login-username").focus()}else{$("login-username").blur()}}function selectDocument(){$("jive-doc-collab").checked=true;$("jive-doc-type-write").addClassName("jive-choose-doc-type-selected");$("jive-doc-type-upload").removeClassName("jive-choose-doc-type-selected")}function selectUpload(){$("jive-doc-upload").checked=true;$("jive-doc-type-upload").addClassName("jive-choose-doc-type-selected");$("jive-doc-type-write").removeClassName("jive-choose-doc-type-selected")};

var JiveSpotlightSearch=Class.create();JiveSpotlightSearch.prototype={initialize:function(B,A,C){this.spotlightSearchInput=B;this.spotlightSearchContainer=A;this.spotlightSearchURL=C;this.spotlightSearchIndex=0;$(this.spotlightSearchInput).observe("keyup",this.observeSpotlightSearchQuery.bind(this));$(this.spotlightSearchInput).observe("blur",this.onBlur.bind(this))},observeSpotlightSearchQuery:function(A){switch(A.keyCode){case Event.KEY_UP:this.selectIndex(this.spotlightSearchIndex-1);Event.stop(A);return ;case Event.KEY_DOWN:this.selectIndex(this.spotlightSearchIndex+1);Event.stop(A);return ;case Event.KEY_RETURN:this.clearSpotlightSearchEvent();if(this.spotlightSearchIndex>0){this.loadSelectedIndex()}else{$(this.spotlightSearchInput).form.submit()}Event.stop(A);return ;case Event.KEY_ESC:this.clearSpotlightSearch();Event.stop(A);return ;case Event.KEY_LEFT:case Event.KEY_RIGHT:case Event.KEY_TAB:case Event.KEY_HOME:case Event.KEY_END:case Event.KEY_PAGEUP:case Event.KEY_PAGEDOWN:Event.stop(A);return }this.clearSpotlightSearchEvent();this.spotlightSearchEvent=setTimeout(this.executeSpotlightSearch.bind(this),400)},onBlur:function(){setTimeout(this.clearSpotlightSearch.bind(this),250)},clearSpotlightSearch:function(){$(this.spotlightSearchContainer).update("")},executeSpotlightSearch:function(){var A=$F(this.spotlightSearchInput);if(A.length>=3){A=A+"*";new Ajax.Updater(this.spotlightSearchContainer,this.spotlightSearchURL,{method:"get",asynchronous:true,evalScripts:true,parameters:{query:A}})}else{this.clearSpotlightSearch()}this.spotlightSearchIndex=0},viewAllResults:function(){var A=$F(this.spotlightSearchInput);if(A.length>0){A=A+"*";$(this.spotlightSearchInput).value=A;$(this.spotlightSearchInput).form.submit()}},selectIndex:function(A){if(A>0){var B=$("spotlight-index-"+A);if(B){$("jive-spotlight-search").select("li.hover").each(function(C){C.removeClassName("hover")});B.addClassName("hover");B.scrollIntoView(false);this.spotlightSearchIndex=A}}else{$("jive-spotlight-search").select("li.hover").each(function(C){C.removeClassName("hover")});$(this.spotlightSearchInput).scrollIntoView(false);this.spotlightSearchIndex=0}},loadSelectedIndex:function(){var A=$("spotlight-index-"+this.spotlightSearchIndex);if(A){A.select("a").each(function(B){location.href=B.href})}},clearSpotlightSearchEvent:function(){if(this.spotlightSearchEvent){clearTimeout(this.spotlightSearchEvent)}}};

