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()})}}if($("jiveBookmarkCreatePanel")){$("jiveBookmarkCreatePanel").hide();$("jiveBookmarkCreatePanel").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 jiveShowQuickBookmarkForm(a){jiveCloseAllMenus();$j("#jiveBookmarkCreatePanel").remove();$j.get(a,null,function(b){$j("#jive-userbar").append(b);jiveBookmarkFormRegisterEvents()})}function jiveBookmarkFormRegisterEvents(){$j("#jiveBookmarkGetURL-cancel").click(function(){new Effect.SlideUp("jiveBookmarkCreatePanel",{duration:0.7});return false});$j("#jive-bookmark-get-url-form").ajaxForm({beforeSubmit:function(){$j(".jive-form-buttons").find("span").show()},target:$j("#jive-quickbookmarkcreate-form .jive-bookmark-form"),success:jiveBookmarkFormRegisterEvents});if($j("#jiveBookmarkCreatePanel:visible").length<=0){new Effect.SlideDown("jiveBookmarkCreatePanel",{duration:0.7,afterFinish:function(){$j("#url-input-field").focus()}})}$j("#jive-bookmark-slidedown-form").ajaxForm({beforeSubmit:function(c){var b=false;for(var a=0;a<c.length;a++){if(c[a].name=="method:cancel"){b=true}}if(b){jiveRemoveQuickBookmarkForm2()}else{$j(".jive-form-buttons").find("span").show()}return !b},target:$j("#jive-quickbookmarkcreate-form .jive-bookmark-form"),success:jiveBookmarkFormRegisterEvents})}function jiveRemoveQuickBookmarkForm2(){new Effect.SlideUp("jiveBookmarkCreatePanel",{duration:0.7})}function jivetoggleLogin(){Element.toggle("jiveLoginWelcome");Element.toggle("jiveLoginForm");if($("jiveLoginForm").style.display!="none"){$("login-username").focus()}else{$("login-username").blur()}}function selectWriteContent(){$("jive-content-collab").checked=true;$("jive-content-type-write").addClassName("jive-choose-content-type-selected");$("jive-content-type-upload").removeClassName("jive-choose-content-type-selected")}function selectUpload(){$("jive-content-upload").checked=true;$("jive-content-type-upload").addClassName("jive-choose-content-type-selected");$("jive-content-type-write").removeClassName("jive-choose-content-type-selected")};

var JiveSpotlightSearch=Class.create();JiveSpotlightSearch.prototype={initialize:function(c,b,d,e,a){this.spotlightSearchInput=c;this.spotlightSearchContainer=b;this.spotlightSearchURL=d;this.containerType=e;this.containerID=a;this.containerSearch=false;this.spotlightSearchInputHasFocus=false;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(){this.spotlightSearchInputHasFocus=false;setTimeout(this.clearSpotlightSearch.bind(this),250)},clearSpotlightSearch:function(){if(!this.spotlightSearchInputHasFocus){$(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,containerType:this.containerType,containerID:this.containerID,filterContainer:this.containerSearch}})}else{this.clearSpotlightSearch()}this.spotlightSearchIndex=0},executeContainerSpotlightSearch:function(){this.containerSearch=true;this.spotlightSearchInputHasFocus=true;setTimeout(this.executeSpotlightSearch.bind(this),50);$(this.spotlightSearchInput).focus()},executeGlobalSpotlightSearch:function(){this.containerSearch=false;this.spotlightSearchInputHasFocus=true;setTimeout(this.executeSpotlightSearch.bind(this),50);$(this.spotlightSearchInput).focus()},viewAllResults:function(a,c){var b=$F(this.spotlightSearchInput);if(b.length>0){b=b+"*";if(a){if(c){$(this.spotlightSearchInput).form.elements.userID.value=this.containerID}else{$(this.spotlightSearchInput).form.elements.containerType.value=this.containerType;$(this.spotlightSearchInput).form.elements.container.value=this.containerID}}$(this.spotlightSearchInput).value=b;$(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)}}};

