MySpace.UI.PopupBehavior=function(A){MySpace.UI.PopupBehavior.initializeBase(this,[A]);this._x=0;this._y=0;this._positioningMode=MySpace.UI.PositioningMode.Absolute;this._parentElement=null;this._parentElementID=null;this._moveHandler=null;this._firstPopup=true;this._originalParent=null;this._visible=false;this._hideOnDocumentClick=false;this._onShow=null;this._onShowEndedHandler=null;this._onHide=null;this._onHideEndedHandler=null};MySpace.UI.PopupBehavior.prototype={initialize:function(){MySpace.UI.PopupBehavior.callBaseMethod(this,"initialize");this._hidePopup();this.get_element().style.position="absolute";this._onShowEndedHandler=Function.createDelegate(this,this._onShowEnded);this._onHideEndedHandler=Function.createDelegate(this,this._onHideEnded);$addHandler(document.body,"mousedown",Function.createDelegate(this,this._onDocumentClick))},dispose:function(){var A=this.get_element();if(A){if(this._visible){this.hide()}if(this._originalParent){A.parentNode.removeChild(A);this._originalParent.appendChild(A);this._originalParent=null}A._hideWindowedElementsIFrame=null}this._parentElement=null;if(this._onShow&&this._onShowEndedHandler){this._onShow.remove_ended(this._onShowEndedHandler)}this._onShowEndedHandler=null;this._onShow=null;if(this._onHide&&this._onHideEndedHandler){this._onHide.remove_ended(this._onHideEndedHandler)}this._onHideEndedHandler=null;this._onHide=null;MySpace.UI.PopupBehavior.callBaseMethod(this,"dispose")},show:function(){if(this._visible){return}var A=new Sys.CancelEventArgs();this.raiseShowing(A);if(A.get_cancel()){return}this._visible=true;var B=this.get_element();B.style.visibility="visible";this.setupPopup();if(this._onShow){B.style.visibility="hidden";this.onShow()}else{this.raiseShown(Sys.EventArgs.Empty)}},hide:function(){if(!this._visible){return}var A=new Sys.CancelEventArgs();this.raiseHiding(A);if(A.get_cancel()){return}this._visible=false;if(this._onHide){this.onHide()}else{this._hidePopup();this._hideCleanup()}},getBounds:function(){var D=this.get_element();var F=D.offsetParent;if(!F||(F==document.documentElement)){F=document.body}var G;var H;if(this._parentElement){H=Sys.UI.DomElement.getBounds(this._parentElement);var C=Sys.UI.DomElement.getLocation(F);G={x:H.x-C.x,y:H.y-C.y}}else{H=Sys.UI.DomElement.getBounds(F);G={x:0,y:0}}var E=D.offsetWidth-(D.clientLeft?D.clientLeft*2:0);var B=D.offsetHeight-(D.clientTop?D.clientTop*2:0);if(this._firstpopup){D.style.width=E+"px";this._firstpopup=false}var A;switch(this._positioningMode){case MySpace.UI.PositioningMode.Center:A={x:Math.round(H.width/2-E/2),y:Math.round(H.height/2-B/2)};break;case MySpace.UI.PositioningMode.BottomLeft:A={x:0,y:H.height};break;case MySpace.UI.PositioningMode.BottomRight:A={x:H.width-E,y:H.height};break;case MySpace.UI.PositioningMode.TopLeft:A={x:0,y:-D.offsetHeight};break;case MySpace.UI.PositioningMode.TopRight:A={x:H.width-E,y:-D.offsetHeight};break;case MySpace.UI.PositioningMode.Right:A={x:H.width,y:0};break;case MySpace.UI.PositioningMode.Left:A={x:-D.offsetWidth,y:0};break;default:A={x:0,y:0}}A.x+=this._x+G.x;A.y+=this._y+G.y;return new Sys.UI.Bounds(A.x,A.y,E,B)},adjustPopupPosition:function(D){var B=this.get_element();if(!D){D=this.getBounds()}var A=Sys.UI.DomElement.getBounds(B);var C=false;if(A.x<0){D.x-=A.x;C=true}if(A.y<0){D.y-=A.y;C=true}if(C){Sys.UI.DomElement.setLocation(B,D.x,D.y)}},addBackgroundIFrame:function(){var A=this.get_element();if((Sys.Browser.agent===Sys.Browser.InternetExplorer)&&(Sys.Browser.version<7)){var B=A._hideWindowedElementsIFrame;if(!B){B=document.createElement("iframe");B.src="javascript:'<html></html>';";B.style.position="absolute";B.style.display="none";B.scrolling="no";B.frameBorder="0";B.tabIndex="-1";B.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";A.parentNode.insertBefore(B,A);A._hideWindowedElementsIFrame=B;this._moveHandler=Function.createDelegate(this,this._onMove);Sys.UI.DomEvent.addHandler(A,"move",this._moveHandler)}B.style.width=A.offsetWidth+"px";B.style.height=A.offsetHeight+"px";B.style.display=A.style.display;if(A.currentStyle&&A.currentStyle.zIndex){B.style.zIndex=A.currentStyle.zIndex}else{if(A.style.zIndex){B.style.zIndex=A.style.zIndex}}}},setupPopup:function(){var A=this.get_element();var B=this.getBounds();Sys.UI.DomElement.setLocation(A,B.x,B.y);this.adjustPopupPosition(B);A.style.zIndex=1000;this.addBackgroundIFrame()},_hidePopup:function(){var A=this.get_element();A.style.visibility="hidden";if(A.originalWidth){A.style.width=A.originalWidth+"px";A.originalWidth=null}},_hideCleanup:function(){var A=this.get_element();if(this._moveHandler){Sys.UI.DomEvent.removeHandler(A,"move",this._moveHandler);this._moveHandler=null}if(Sys.Browser.agent===Sys.Browser.InternetExplorer){var B=A._hideWindowedElementsIFrame;if(B){B.style.display="none"}}this.raiseHidden(Sys.EventArgs.Empty)},_onDocumentClick:function(B){if(!this._hideOnDocumentClick||!this._visible){return}for(var A=B.target;A;A=A.parentNode){if(A==this.get_element()){return}}this.hide()},_onMove:function(){var A=this.get_element();if(A._hideWindowedElementsIFrame){A.parentNode.insertBefore(A._hideWindowedElementsIFrame,A);A._hideWindowedElementsIFrame.style.top=A.style.top;A._hideWindowedElementsIFrame.style.left=A.style.left}},get_onShow:function(){return this._onShow},set_onShow:function(A){this._onShow=A;if(A){A.set_target(this.get_element());A.add_ended(this._onShowEndedHandler)}},onShow:function(){if(this._onShow){if(this._onHide){this._onHide.stop()}this._onShow.play()}},_onShowEnded:function(){this.adjustPopupPosition();this.addBackgroundIFrame();this.raiseShown(Sys.EventArgs.Empty)},get_onHide:function(){return this._onHide},set_onHide:function(A){this._onHide=A;if(A){A.set_target(this.get_element());A.add_ended(this._onHideEndedHandler)}},onHide:function(){if(this._onHide){if(this._onShow){this._onShow.stop()}this._onHide.play()}},_onHideEnded:function(){this._hideCleanup()},get_parentElement:function(){if(!this._parentElement&&this._parentElementID){this.set_parentElement($get(this._parentElementID))}return this._parentElement},set_parentElement:function(A){this._parentElement=A},get_parentElementID:function(){if(this._parentElement){return this._parentElement.id}return this._parentElementID},set_parentElementID:function(A){this._parentElementID=A;if(this.get_isInitialized()){this.set_parentElement($get(A))}},get_positioningMode:function(){return this._positioningMode},set_positioningMode:function(A){this._positioningMode=A},get_x:function(){return this._x},set_x:function(A){if(A!=this._x){this._x=A;if(this._visible){this.setupPopup()}}},get_y:function(){return this._y},set_y:function(A){if(A!=this._y){this._y=A;if(this._visible){this.setupPopup()}}},get_visible:function(){return this._visible},get_hideOnDocumentClick:function(){return this._hideOnDocumentClick},set_hideOnDocumentClick:function(A){this._hideOnDocumentClick=A},add_showing:function(A){this.get_events().addHandler("showing",A)},remove_showing:function(A){this.get_events().removeHandler("showing",A)},raiseShowing:function(A){var B=this.get_events().getHandler("showing");if(B){B(this,A)}},add_shown:function(A){this.get_events().addHandler("shown",A)},remove_shown:function(A){this.get_events().removeHandler("shown",A)},raiseShown:function(A){var B=this.get_events().getHandler("shown");if(B){B(this,A)}},add_hiding:function(A){this.get_events().addHandler("hiding",A)},remove_hiding:function(A){this.get_events().removeHandler("hiding",A)},raiseHiding:function(A){var B=this.get_events().getHandler("hiding");if(B){B(this,A)}},add_hidden:function(A){this.get_events().addHandler("hidden",A)},remove_hidden:function(A){this.get_events().removeHandler("hidden",A)},raiseHidden:function(A){var B=this.get_events().getHandler("hidden");if(B){B(this,A)}}};MySpace.UI.PopupBehavior.registerClass("MySpace.UI.PopupBehavior",Sys.UI.Behavior);MySpace.UI.PositioningMode=function(){throw Error.invalidOperation()};MySpace.UI.PositioningMode.prototype={Absolute:0,Center:1,BottomLeft:2,BottomRight:3,TopLeft:4,TopRight:5,Right:6,Left:7};MySpace.UI.PositioningMode.registerEnum("MySpace.UI.PositioningMode");MySpace.UI.AutoCompleteBehavior=function(A){MySpace.UI.AutoCompleteBehavior.initializeBase(this,[A]);this._servicePath=null;this._serviceMethod=null;this._serviceParams=null;this._isJsonpService=false;this._contextKey=null;this._useContextKey=false;this._minimumPrefixLength=3;this._triggerPrefix="";this._completionItems=null;this._completionInterval=1000;this._completionListWrapperID=null;this._completionListElementID=null;this._completionListAlwaysVisible=false;this._currentPrefix=null;this._selectIndex=-1;this._enableCaching=true;this._enableCacheSubstrings=false;this._flyoutHasFocus=false;this._textBoxHasFocus=false;this._completionListCssClass=null;this._completionListItemCssClass=null;this._completionListFixedHeight=null;this._completionListMaxHeight=200;this._completionListWidth=null;this._lazyLoadPlaceholderHeight=null;this._groupHeaderCssClass=null;this._highlightedItemCssClass=null;this._delimiterCharacters=null;this._firstRowSelected=false;this._showOnlyCurrentWordInCompletionListItem=false;this._webRequest=null};MySpace.UI.AutoCompleteBehavior.prototype={initialize:function(){MySpace.UI.AutoCompleteBehavior.callBaseMethod(this,"initialize");this._popupBehaviorHiddenHandler=Function.createDelegate(this,this._popupHidden);this._tickHandler=Function.createDelegate(this,this._onTimerTick);this._focusHandler=Function.createDelegate(this,this._onGotFocus);this._blurHandler=Function.createDelegate(this,this._onLostFocus);this._keyDownHandler=Function.createDelegate(this,this._onKeyDown);this._mouseDownHandler=Function.createDelegate(this,this._onListMouseDown);this._mouseUpHandler=Function.createDelegate(this,this._onListMouseUp);this._mouseOverHandler=Function.createDelegate(this,this._onListMouseOver);this._mouseOutHandler=Function.createDelegate(this,this._onListMouseOut);this._completionListBlurHandler=Function.createDelegate(this,this._onCompletionListBlur);this._completionListScrollHandler=Function.createDelegate(this,this._drawMissingItems);this._bodyClickHandler=Function.createDelegate(this,this._onBodyClick);this.initializeTextBox();if(this._completionListElementID!==null){this._completionListElement=$get(this._completionListElementID)}if(this._completionListElement==null){this._completionListElement=document.createElement("div");this._completionListElement.id=this.get_id()+"_completionListElem";this._getOuterEl().parentNode.insertBefore(this._completionListElement,this._getOuterEl().nextSibling)}if(this._completionListWrapperID){this._completionListWrapper=$get(this._completionListWrapperID)}else{this._completionListWrapper=this._completionListElement}this.initializeCompletionList();if(this._completionListAlwaysVisible){this._onTimerTick()}else{this._popupBehavior=$create(MySpace.UI.PopupBehavior,{id:this.get_id()+"PopupBehavior",parentElement:this._getOuterEl(),positioningMode:MySpace.UI.PositioningMode.BottomLeft},null,null,this._completionListWrapper);this._popupBehavior.add_hidden(this._popupBehaviorHiddenHandler);if(this._onShow){this._popupBehavior.set_onShow(this._onShow)}if(this._onHide){this._popupBehavior.set_onHide(this._onHide)}}},dispose:function(){if(this._popupBehavior){if(this._popupBehaviorHiddenHandler){this._popupBehavior.remove_hidden(this._popupBehaviorHiddenHandler)}this._popupBehavior.dispose();this._popupBehavior=null}this._stopTimer();if(this._completionListElement){$removeHandler(this._completionListElement,"blur",this._completionListBlurHandler);$removeHandler(this._completionListElement,"scroll",this._completionListScrollHandler);$removeHandler(this._completionListElement,"mousedown",this._mouseDownHandler);$removeHandler(this._completionListElement,"mouseup",this._mouseUpHandler);$removeHandler(this._completionListElement,"mouseover",this._mouseOverHandler);$removeHandler(this._completionListElement,"mouseout",this._mouseOutHandler)}if(this._bodyClickHandler){$removeHandler(document.body,"click",this._bodyClickHandler);this._bodyClickHandler=null}this._popupBehaviorHiddenHandler=null;this._tickHandler=null;this._focusHandler=null;this._blurHandler=null;this._keyDownHandler=null;this._completionListBlurHandler=null;this._mouseDownHandler=null;this._mouseUpHandler=null;this._mouseOverHandler=null;this._mouseOutHandler=null;MySpace.UI.AutoCompleteBehavior.callBaseMethod(this,"dispose")},_startTimer:function(){this._intervalId=window.setInterval(this._tickHandler,this._completionInterval)},_stopTimer:function(){window.clearInterval(this._intervalId)},initializeTextBox:function(){var A=this._getInnerEl();A.autocomplete="off";A.setAttribute("autocomplete","off");$addHandler(A,"focus",this._focusHandler);$addHandler(A,"blur",this._blurHandler);$addHandler(A,"keydown",this._keyDownHandler)},initializeCompletionList:function(){var B=this._completionListElement;var D=this._completionListWrapper;var C=B.style;if(this._completionListCssClass){Sys.UI.DomElement.addCssClass(B,this._completionListCssClass)}else{C.textAlign="left";C.overflow="auto";C.overflowX="hidden";C.cursor="default";C.padding="0px";C.margin="0px! important";if(Sys.Browser.agent===Sys.Browser.Safari){C.border="solid 1px gray";C.backgroundColor="white";C.color="black"}else{C.border="solid 1px buttonshadow";C.backgroundColor="window";C.color="windowtext"}if(this._completionListAlwaysVisible){if(this.get_servicePath()){C.background='url("'+MySpace.StaticContentBase+'/modules/common/static/img/loadercircles.gif") center center no-repeat'}}else{D.style.visibility="hidden"}var A=Sys.UI.DomElement.getBounds(this._getOuterEl());this._completionListElement.style.width=(this.get_completionListWidth()||Math.max(1,A.width-2))+"px"}if(this._completionListFixedHeight){C.height=this._completionListFixedHeight+"px"}$addHandler(B,"mousedown",this._mouseDownHandler);$addHandler(B,"mouseup",this._mouseUpHandler);$addHandler(B,"mouseover",this._mouseOverHandler);$addHandler(B,"mouseout",this._mouseOutHandler);$addHandler(B,"blur",this._completionListBlurHandler);$addHandler(B,"scroll",this._completionListScrollHandler);$addHandler(document.body,"click",this._bodyClickHandler)},_currentCompletionWord:function(){var E=this.get_value();var C=E;if(this.get_isMultiWord()){var D=this._getCurrentWordStartIndex();var B=this._getCurrentWordEndIndex(D);if(B<=D){C=E.substring(D)}else{C=E.substring(D,B)}}var A=this.get_triggerPrefix().toLowerCase();if(A){if(!C.toLowerCase().startsWith(A)){return""}else{return C.substring(A.length)}}else{return C}},_getCursorIndex:function(){return this.get_element().selectionStart},_getCurrentWordStartIndex:function(){var D=this.get_value().substring(0,this._getCursorIndex());var A=0;var E=-1;for(var C=0;C<this._delimiterCharacters.length;++C){var B=D.lastIndexOf(this._delimiterCharacters.charAt(C));if(B>E){E=B}}A=E;if(A>=this._getCursorIndex()){A=0}return A<0?0:A+1},_getCurrentWordEndIndex:function(A){var F=this.get_value();var E=F.substring(A);var B=0;for(var D=0;D<this._delimiterCharacters.length;++D){var C=E.indexOf(this._delimiterCharacters.charAt(D));if(C>0&&(C<B||B==0)){B=C}}return B<=0?F.length:B+A},get_isMultiWord:function(){return(this._delimiterCharacters!=null)&&(this._delimiterCharacters!="")},_getTextWithInsertedWord:function(A){var H=A;var G=0;var F=this.get_value();if(this.get_isMultiWord()){var E=this._getCurrentWordStartIndex();var C=this._getCurrentWordEndIndex(E);var B="";var D="";if(E>0){B=F.substring(0,E)}if(C>E){D=F.substring(C)}H=B+A+D}return H},_hideCompletionList:function(){if(!(this._popupBehavior&&this._popupBehavior.get_visible())){return}var A=new Sys.CancelEventArgs();this.raiseHiding(A);if(A.get_cancel()){return}this.hidePopup()},showPopup:function(){if(this._popupBehavior){this._popupBehavior.show();this.raiseShown(Sys.EventArgs.Empty)}},hidePopup:function(){if(this._popupBehavior){this._popupBehavior.hide()}else{this._popupHidden()}},_popupHidden:function(){this._completionListElement.innerHTML="";this._selectIndex=-1;this._flyoutHasFocus=false;this.raiseHidden(Sys.EventArgs.Empty)},_highlightItem:function(C){var B=this._completionListElement.childNodes;for(var A=0;A<B.length;A++){var D=B[A];if(D._highlighted){D._highlighted=false;if(this._completionListItemCssClass){Sys.UI.DomElement.removeCssClass(D,this._highlightedItemCssClass);Sys.UI.DomElement.addCssClass(D,this._completionListItemCssClass)}else{if(Sys.Browser.agent===Sys.Browser.Safari){D.style.backgroundColor="white";D.style.color="black"}else{D.style.backgroundColor="window";D.style.color="windowtext"}}this.raiseItemOut(new MySpace.UI.AutoCompleteItemEventArgs(D,D.firstChild.nodeValue,D._value))}}if(C){if(this._highlightedItemCssClass){Sys.UI.DomElement.removeCssClass(C,this._completionListItemCssClass);Sys.UI.DomElement.addCssClass(C,this._highlightedItemCssClass)}else{if(Sys.Browser.agent===Sys.Browser.Safari){C.style.backgroundColor="lemonchiffon"}else{C.style.backgroundColor="highlight";C.style.color="highlighttext"}}C._highlighted=true;if(!C._isPlaceholder){this.raiseItemOver(new MySpace.UI.AutoCompleteItemEventArgs(C,C.firstChild.nodeValue,C._value))}}},_onBodyClick:function(A){var B=A.target;while(B){if(B==this._completionListWrapper){return}B=B.parentNode}this._onCompletionListBlur(A)},_onCompletionListBlur:function(A){this._hideCompletionList()},_getCompletionItem:function(A){while(A){if(A.parentNode==this._completionListElement&&!A._isGroupHeader){return A}A=A.parentNode}},_onListMouseDown:function(B){var A=this._getCompletionItem(B.target);if(A){this._setText(A);this._flyoutHasFocus=false;B.stopPropagation()}else{this._flyoutHasFocus=true}},_onListMouseUp:function(A){if(!this._flyoutHasFocus){try{this._getInnerEl().focus()}catch(B){}}},_onListMouseOver:function(B){var A=B.target;if(A!==this._completionListElement){A=this._getCompletionItem(A);if(A){this._highlightItem(A);this._selectIndex=Array.indexOf(A.parentNode.childNodes,A)}}},_onListMouseOut:function(B){if(B.target==this._completionListElement){this._highlightItem(null)}else{var A=this._getCompletionItem(B.target);if(A&&A._highlighted){this._highlightItem(null)}}},_onGotFocus:function(A){this._textBoxHasFocus=true;if(this._flyoutHasFocus){this._hideCompletionList()}if((this._minimumPrefixLength==0)&&(!this.get_value())){this._startTimer()}},_onKeyDown:function(C){this._stopTimer();var A=C.keyCode?C.keyCode:C.rawEvent.keyCode;if(A===Sys.UI.Key.esc){if(this._popupBehavior&&this._popupBehavior.get_visible()){this._hideCompletionList();C.preventDefault();C.stopPropagation()}}else{if(A===Sys.UI.Key.up){var B=this._getAdjacentItemIndex(this._selectIndex,-1);if(B>=0){this._selectIndex=B;this._handleScroll(this._completionListElement.childNodes[B],B);this._highlightItem(this._completionListElement.childNodes[B]);C.stopPropagation();C.preventDefault()}}else{if(A===Sys.UI.Key.down){var B=this._getAdjacentItemIndex(this._selectIndex,1);if(B<this._completionListElement.childNodes.length){this._selectIndex=B;this._handleScroll(this._completionListElement.childNodes[B],B);this._highlightItem(this._completionListElement.childNodes[B]);C.stopPropagation();C.preventDefault()}}else{if(A===Sys.UI.Key.enter){if(this._selectIndex!==-1){this._setText(this._completionListElement.childNodes[this._selectIndex]);C.preventDefault();C.stopPropagation()}else{this.hidePopup()}}else{if(A===Sys.UI.Key.tab){if(this._selectIndex!==-1){this._setText(this._completionListElement.childNodes[this._selectIndex]);if(this.get_isMultiWord()){C.preventDefault();C.stopPropagation()}}}else{this._startTimer()}}}}}},_getAdjacentItemIndex:function(A,C){var B=this._completionListElement.childNodes;do{A+=C}while(A>=0&&A<B.length&&B[A]._isGroupHeader);return A},_handleScroll:function(F,E){var C=this._completionListElement,B=F.offsetHeight||0,G=F.offsetParent==C,H=G?0:C.offsetTop;var A=F.offsetTop-H+B-C.scrollTop-C.offsetHeight;if(A>0){C.scrollTop+=A}var D=C.scrollTop-F.offsetTop+H;if(D>0){C.scrollTop-=D}},_handleFlyoutFocus:function(){if(!this._textBoxHasFocus){if(!this._flyoutHasFocus){if(this._webRequest){this._webRequest.get_executor().abort();this._webRequest=null}this._hideCompletionList()}else{}}},_onLostFocus:function(){this._textBoxHasFocus=false;this._stopTimer();window.setTimeout(Function.createDelegate(this,this._handleFlyoutFocus),500)},_onMethodComplete:function(A,B){this._webRequest=null;if(this._completionListElement){this._completionListElement.style.backgroundImage=""}this._update(B,A,true)},_onMethodFailed:function(C,A,B){this._webRequest=null},_onTimerTick:function(D,C){this._stopTimer();var E=this._currentCompletionWord();if(E.trim().length<this._minimumPrefixLength){this._currentPrefix=null;this._update("",null,false);return}var A=(!this._popupBehavior||this._popupBehavior.get_visible());if((this._currentPrefix!==E||!A)||((E=="")&&(this._minimumPrefixLength==0)&&!this._webRequest)){this._currentPrefix=E;if(this._cache){var B=this._getCachedItems(E);if(B){this._update(E,B,false);return}}var C=new Sys.CancelEventArgs();this.raisePopulating(C);if(C.get_cancel()){return}this._fetchCompletionItems(E)}},_getCachedItems:function(B){if(!this._cache){return null}if(this._cache[B]){return this._cache[B]}if(this.get_enableCacheSubstrings()){for(var A in this._cache){if(B.startsWith(A)){this._completionItems=this._cache[A];return this.getCompletionItems(B)}}}return null},_fetchCompletionItems:function(C){if(this._servicePath&&(this._isJsonpService||this._serviceMethod)){var D={prefixText:this._currentPrefix};if(this._serviceParams){for(var A in this._serviceParams){D[A]=this._serviceParams[A]}}if(this._useContextKey){D.contextKey=this._contextKey}if(this._isJsonpService){MySpace.Net.JsonpWebServiceProxy.invoke(this.get_servicePath(),D,Function.createDelegate(this,this._onMethodComplete),Function.createDelegate(this,this._onMethodFailed),null,C)}else{if(this._webRequest){this._webRequest.get_executor().abort();this._webRequest=null}this._webRequest=Sys.Net.WebServiceProxy.invoke(this.get_servicePath(),this.get_serviceMethod(),false,D,Function.createDelegate(this,this._onMethodComplete),Function.createDelegate(this,this._onMethodFailed),C)}}else{var B=this.getCompletionItems(C);if(B){this._update(C,B)}}},getCompletionItems:function(D){D=D.toLowerCase();var C=[];for(var A=0;A<this._completionItems.length;A++){var B=this._completionItems[A];if((B.text||B).toLowerCase().startsWith(D)){C.push(this._completionItems[A])}}return C},_setText:function(A){var C=null;if(A){C=A._text||(A.firstChild?A.firstChild.nodeValue:null)}this._stopTimer();var B=this._showOnlyCurrentWordInCompletionListItem?this._getTextWithInsertedWord(C):C;this.set_value(B,true);this.raiseItemSelected(new MySpace.UI.AutoCompleteItemEventArgs(A,C,A?A._value:null));this._currentPrefix=this._currentCompletionWord();this._hideCompletionList()},_update:function(E,H,J){if(J&&this.get_enableCaching()){if(!this._cache){this._cache={}}this._cache[E]=H}this._currentCompletionItems=H;if((!this._completionListAlwaysVisible&&!this._textBoxHasFocus)||(E!=this._currentCompletionWord())){this._hideCompletionList();return}if(this._completionListAlwaysVisible||(H&&H.length)){this._completionListElement.innerHTML="";this._selectIndex=-1;var L=null,K=null,I=null,C=null,B=this._lazyLoadPlaceholderHeight;for(var D=0;D<H.length;D++){if(H[D]&&H[D].groupHeader){C=this.createGroupHeader(H[D])}else{if(B){C=document.createElement("div");C.style.height=B+"px";C._isPlaceholder=true}else{C=this.createCompletionItem(H[D]);if(L==null){L=C}}}this._completionListElement.appendChild(C)}var G=Sys.UI.DomElement.getBounds(this._getOuterEl());this._completionListElement.style.width=(this.get_completionListWidth()||Math.max(1,G.width-2))+"px";var F=new Sys.EventArgs();F.completionItems=H;F.completionListElement=this._completionListElement;this.raisePopulated(F);var A=new Sys.CancelEventArgs();this.raiseShowing(A);if(!A.get_cancel()){if(!this._completionListFixedHeight){this._completionListElement.style.height="1px"}this.showPopup();if(!this._completionListFixedHeight){this._completionListElement.style.height="";if(this._completionListElement.offsetHeight>this._completionListMaxHeight){this._completionListElement.style.height=this._completionListMaxHeight+"px"}}this._completionListElement.scrollTop=0;if(this._firstRowSelected&&(L!=null)){this._highlightItem(L);this._selectIndex=0}this._drawMissingItems()}}else{this._hideCompletionList()}},_drawMissingItems:function(){var F=this._completionListElement,D=F.childNodes[0]&&(F.childNodes[0].offsetParent==F),E=D?0:F.offsetTop,I=E+F.scrollTop-4*this._lazyLoadPlaceholderHeight,G=I+F.offsetHeight+8*this._lazyLoadPlaceholderHeight,H=F.childNodes.length,A=null;for(var C=0;C<H;C++){A=F.childNodes[C];if(A.offsetTop<I){continue}if(A.offsetTop>G){break}if(A._isPlaceholder){var B=this.createCompletionItem(this._currentCompletionItems[C]);F.replaceChild(B,A);if(this._selectIndex==-1&&this._firstRowSelected){this._highlightItem(B);this._selectIndex=C}}}},createCompletionItem:function(C){var B=document.createElement("div");var E,D;if(C&&C.text){E=C.text;D=C.value}else{E=C;D=C}var F=this._showOnlyCurrentWordInCompletionListItem?E:this._getTextWithInsertedWord(E);B.innerHTML=F;B._value=D;if(this._completionListItemCssClass){Sys.UI.DomElement.addCssClass(B,this._completionListItemCssClass)}else{var A=B.style;A.padding="0px";A.textAlign="left";A.textOverflow="ellipsis";A.cursor="pointer";if(Sys.Browser.agent===Sys.Browser.Safari){A.backgroundColor="white";A.color="black"}else{A.backgroundColor="window";A.color="windowtext"}}return B},createGroupHeader:function(C){var B=document.createElement("div");B.appendChild(document.createTextNode(C.groupHeader));B._isGroupHeader=true;if(this._groupHeaderCssClass){Sys.UI.DomElement.addCssClass(B,this._groupHeaderCssClass)}else{var A=B.style;A.fontWeight="bold";A.fontStyle="italic"}return B},_getInnerEl:function(){return this.get_element()},_getOuterEl:function(){return this.get_element()},get_value:function(){var B=this.get_element();var A=Sys.UI.Behavior.getBehaviorByName(B,"DefaultTextboxBehavior");return A?A.get_value():B.value},set_value:function(D,C){var B=this.get_element();var A=Sys.UI.Behavior.getBehaviorByName(B,"DefaultTextboxBehavior");if(A){A.set_value(D)}else{B.value=D||""}if(!C){this._onTimerTick()}},get_onShow:function(){return this._popupBehavior?this._popupBehavior.get_onShow():this._onShow},set_onShow:function(A){if(this._popupBehavior){this._popupBehavior.set_onShow(A)}else{this._onShow=A}},onShow:function(){if(this._popupBehavior){this._popupBehavior.onShow()}},get_onHide:function(){return this._popupBehavior?this._popupBehavior.get_onHide():this._onHide},set_onHide:function(A){if(this._popupBehavior){this._popupBehavior.set_onHide(A)}else{this._onHide=A}},onHide:function(){if(this._popupBehavior){this._popupBehavior.onHide()}},get_visible:function(){return this._popupBehavior&&this._popupBehavior.get_visible()},get_completionItems:function(){return this._completionItems},set_completionItems:function(A){this._completionItems=A},get_completionInterval:function(){return this._completionInterval},set_completionInterval:function(A){this._completionInterval=A},get_completionList:function(){return this._completionListElement},set_completionList:function(A){this._completionListElement=A},get_minimumPrefixLength:function(){return this._minimumPrefixLength},set_minimumPrefixLength:function(A){this._minimumPrefixLength=A},get_triggerPrefix:function(){return this._triggerPrefix},set_triggerPrefix:function(A){this._triggerPrefix=A},get_serviceMethod:function(){return this._serviceMethod},set_serviceMethod:function(A){this._serviceMethod=A},get_servicePath:function(){return this._servicePath},set_servicePath:function(A){this._servicePath=A},get_serviceParams:function(){return this._serviceParams},set_serviceParams:function(A){this._serviceParams=A},get_isJsonpService:function(){return this._isJsonpService},set_isJsonpService:function(A){this._isJsonpService=A},get_contextKey:function(){return this._contextKey},set_contextKey:function(A){this._contextKey=A;this.set_useContextKey(true)},get_useContextKey:function(){return this._useContextKey},set_useContextKey:function(A){this._useContextKey=A},get_enableCaching:function(){return this._enableCaching},set_enableCaching:function(A){this._enableCaching=A},get_enableCacheSubstrings:function(){return this._enableCacheSubstrings},set_enableCacheSubstrings:function(A){this._enableCacheSubstrings=A},get_completionListWrapperID:function(){return this._completionListWrapperID},set_completionListWrapperID:function(A){this._completionListWrapperID=A},get_completionListElementID:function(){return this._completionListElementID},set_completionListElementID:function(A){this._completionListElementID=A},get_completionListAlwaysVisible:function(){return this._completionListAlwaysVisible},set_completionListAlwaysVisible:function(A){this._completionListAlwaysVisible=A},get_completionListCssClass:function(){return this._completionListCssClass},set_completionListCssClass:function(A){this._completionListCssClass=A},get_completionListItemCssClass:function(){return this._completionListItemCssClass},set_completionListItemCssClass:function(A){this._completionListItemCssClass=A},get_completionListFixedHeight:function(){return this._completionListFixedHeight},set_completionListFixedHeight:function(A){this._completionListFixedHeight=A},get_completionListMaxHeight:function(){return this._completionListMaxHeight},set_completionListMaxHeight:function(A){this._completionListMaxHeight=A},get_completionListWidth:function(){return this._completionListWidth},set_completionListWidth:function(A){this._completionListWidth=A},get_lazyLoadPlaceholderHeight:function(){return this._lazyLoadPlaceholderHeight},set_lazyLoadPlaceholderHeight:function(A){this._lazyLoadPlaceholderHeight=A},get_groupHeaderCssClass:function(){return this._groupHeaderCssClass},set_groupHeaderCssClass:function(A){this._groupHeaderCssClass=A},get_highlightedItemCssClass:function(){return this._highlightedItemCssClass},set_highlightedItemCssClass:function(A){this._highlightedItemCssClass=A},get_delimiterCharacters:function(){return this._delimiterCharacters},set_delimiterCharacters:function(A){this._delimiterCharacters=A},get_firstRowSelected:function(){return this._firstRowSelected},set_firstRowSelected:function(A){this._firstRowSelected=A},get_showOnlyCurrentWordInCompletionListItem:function(){return this._showOnlyCurrentWordInCompletionListItem},set_showOnlyCurrentWordInCompletionListItem:function(A){this._showOnlyCurrentWordInCompletionListItem=A},add_populating:function(A){this.get_events().addHandler("populating",A)},remove_populating:function(A){this.get_events().removeHandler("populating",A)},raisePopulating:function(A){var B=this.get_events().getHandler("populating");if(B){B(this,A)}},add_populated:function(A){this.get_events().addHandler("populated",A)},remove_populated:function(A){this.get_events().removeHandler("populated",A)},raisePopulated:function(A){var B=this.get_events().getHandler("populated");if(B){B(this,A)}},add_showing:function(A){this.get_events().addHandler("showing",A)},remove_showing:function(A){this.get_events().removeHandler("showing",A)},raiseShowing:function(A){var B=this.get_events().getHandler("showing");if(B){B(this,A)}},add_shown:function(A){this.get_events().addHandler("shown",A)},remove_shown:function(A){this.get_events().removeHandler("shown",A)},raiseShown:function(A){var B=this.get_events().getHandler("shown");if(B){B(this,A)}},add_hiding:function(A){this.get_events().addHandler("hiding",A)},remove_hiding:function(A){this.get_events().removeHandler("hiding",A)},raiseHiding:function(A){var B=this.get_events().getHandler("hiding");if(B){B(this,A)}},add_hidden:function(A){this.get_events().addHandler("hidden",A)},remove_hidden:function(A){this.get_events().removeHandler("hidden",A)},raiseHidden:function(A){var B=this.get_events().getHandler("hidden");if(B){B(this,A)}},add_itemSelected:function(A){this.get_events().addHandler("itemSelected",A)},remove_itemSelected:function(A){this.get_events().removeHandler("itemSelected",A)},raiseItemSelected:function(A){var B=this.get_events().getHandler("itemSelected");if(B){B(this,A)}},add_itemOver:function(A){this.get_events().addHandler("itemOver",A)},remove_itemOver:function(A){this.get_events().removeHandler("itemOver",A)},raiseItemOver:function(A){var B=this.get_events().getHandler("itemOver");if(B){B(this,A)}},add_itemOut:function(A){this.get_events().addHandler("itemOut",A)},remove_itemOut:function(A){this.get_events().removeHandler("itemOut",A)},raiseItemOut:function(A){var B=this.get_events().getHandler("itemOut");if(B){B(this,A)}}};MySpace.UI.AutoCompleteBehavior.registerClass("MySpace.UI.AutoCompleteBehavior",Sys.UI.Behavior);MySpace.UI.AutoCompleteItemEventArgs=function(A,C,B){MySpace.UI.AutoCompleteItemEventArgs.initializeBase(this);this._item=A;this._text=C;this._value=(B!==undefined)?B:null};MySpace.UI.AutoCompleteItemEventArgs.prototype={get_item:function(){return this._item},set_item:function(A){this._item=A},get_text:function(){return this._text},set_text:function(A){this._text=A},get_value:function(){return this._value},set_value:function(A){this._value=A}};MySpace.UI.AutoCompleteItemEventArgs.registerClass("MySpace.UI.AutoCompleteItemEventArgs",Sys.EventArgs);Type.registerNamespace("FriendFinder");FriendFinder.CreateElement=function(D,B,C,A,F){var E=document.createElement(B);E.type=C;E.name=A;E.value=F;D.appendChild(E)};FriendFinder.ClearText=function(){if(this.defaultValue==this.value){this.value="";this.style.color="#000000"}};FriendFinder.BlinkText=function(B,D,E,G){G=G*2+1;var A=B;var F=A.style.color;var C=setInterval(function(){A.style.color=(A.style.color==F)?D:F},E);setTimeout("clearInterval("+C+");",E*G)};FriendFinder.KeyPressHandler=function(C,A){var B;if(!C){C=window.event}if(window.event){B=event.keyCode}else{if(C.which){B=C.which}else{if(C.charCode){B=C.charCode}}}if(B==13){C.preventDefault();$get(A.buttonId).click();return false}return true};FriendFinder.InitializeDropDown=function(D,B,C){var A=D.options.length;for(i=0;i<A;i++){D.remove(0)}D.options[0]=new Option(B,"-1");if(C){D.disabled=true}};FriendFinder.PopulateControl=function(C,A,B){FriendFinder.InitializeDropDown(C,B,false);for(var D in A){optionObject=new Option(A[D],D);if(optionObject.value.indexOf("function")!=0){C.options[C.options.length]=optionObject}}if(C.length<=1){C.disabled=true}else{C.disabled=false}};FriendFinder.DisplayError=function(B,A){B.innerHTML=String.format("<Label class='errorDisplay'>{0}</Label>",A)};FriendFinder.ClearError=function(A){if(A.innerHTML.trim()!=""){A.innerHTML=""}};FriendFinder.DisableControlAndDisplayError=function(C,B,A){emptyResult={};FriendFinder.PopulateControl(C,emptyResult,A);FriendFinder.DisplayError(B,MySpaceRes.Header.ErrorMessage)};FriendFinder.SearchPeople=function(A,B){this._peopleSearchUrl=A;this._searchTextBox=$get("searchPeopleTextBox");this._searchByDropDown=$get(B)};FriendFinder.SearchPeople.prototype={Find:function(C,A){if(A.sender.Validate(A.sender._searchTextBox)){var B=A.sender._searchByDropDown.options[A.sender._searchByDropDown.selectedIndex].value;if(A.addToBlog){A.sender.CreateCookie("SHOWADDTOBLOGPREFERREDLIST","True")}self.location.href=String.format(A.sender._peopleSearchUrl,encodeURIComponent(A.sender._searchTextBox.value),"friend_finder-search",encodeURIComponent(B))}},CreateCookie:function(A,B){if(MySpace.Cookies){if(MySpace.Cookies.MSSession){MySpace.Cookies.MSSession.get_values()[A]=B;MySpace.Cookies.save(MySpace.Cookies.MSSession,".myspace.com")}else{MySpace.Cookies.save(new MySpace.Cookie("MSSession",A+"="+B),".myspace.com")}}},Validate:function(B){var A="true";if(B.value.trim()==0){B.value=B.defaultValue;A="false"}if(A=="true"&&B.value==B.defaultValue){A="false"}if(A=="false"){B.style.color="#888888";FriendFinder.BlinkText(B,"red","400","3");return false}else{return true}},dispose:function(){FriendFinder.SearchPeople.callBaseMethod(this,"dispose")}};FriendFinder.SearchPeople.registerClass("FriendFinder.SearchPeople",Sys.Component);FriendFinder.Schools=function(B,D,A,E){FriendFinder.Schools.initializeBase(this);var C=$get("schools");this._countryControl=$get(B,C);this._schoolNameControl=$get(D,C);this._errorControl=$get("schoolsErrorMessage");this._currentCulture=A;this._schoolsUrl=E};FriendFinder.Schools.prototype={initialize:function(){FriendFinder.Schools.callBaseMethod(this,"initialize")},Find:function(){if(this.ValidateCountry()&&this.ValidateSchoolName()){FriendFinder.ClearError(this._errorControl);this.SubmitSchoolSearch()}},SubmitSchoolSearch:function(){var A=document.createElement("form");A.method="POST";A.name="SchoolsForm";A.action=this._schoolsUrl;FriendFinder.CreateElement(A,"input","hidden","FFCountry",this._countryControl.value);FriendFinder.CreateElement(A,"input","hidden","FFSchoolName",this._schoolNameControl.value);document.body.appendChild(A);A.submit()},AddHiddenValue:function(C,A,D){var B=document.createElement("INPUT");B.type="hidden";B.name=A;B.value=D;C.appendChild(B)},ValidateCountry:function(){var A=this._countryControl.value;if(A=="0"||A=="DD"){FriendFinder.DisplayError(this._errorControl,MySpaceRes.SchoolsPage.CountryErrorMessage);return false}else{return true}},ValidateSchoolName:function(){var A=this._schoolNameControl.value;if(A==null||A==""||A==MySpaceRes.SchoolsPage.SchoolName2){FriendFinder.DisplayError(this._errorControl,MySpaceRes.SchoolsPage.PleaseEnterSchoolName);return false}else{return true}},dispose:function(){FriendFinder.Schools.callBaseMethod(this,"dispose")}};FriendFinder.Schools.registerClass("FriendFinder.Schools",Sys.Component);
