function CreateViewGroupManager(){this.cvgm_suggestions=[];this.cvgm_outp=document.createElement("div");this.cvgm_outp.className="cvfgView";this.cvgm_shadow=document.createElement("div");this.cvgm_shadow.className="cvfgShadow";this.cvgm_shadow.appendChild(this.cvgm_outp);this.cvgm_oldins=null;this.cvgm_posi=-1;this.cvgm_words=new Array();this.cvgm_input=null;this.cvgm_key=null;this.cvgm_oldFriendId=null;this.cvgm_friendId=null;this.cvgm_groupId=null;this.cvgm_addGroupElement=document.createElement("div");this.cvgm_addGroupElement.className="addGroupBox";this.cvgm_addGroupElement.owner=this;this.cvgm_firstTime=true;this.cvgm_addGroupElement.style.height="23px";this.cvgm_addGroupElement.onmouseover=this.cvgm_mouseHandler;this.cvgm_addGroupElement.onmouseout=this.cvgm_mouseHandlerOut;this.cvgm_addGroupElement.onclick=this.cvgm_mouseClick;this.cvgm_addGroupError=false;this.cvgm_setVisible("hidden");this.cvgm_shadow.owner=this;this.cvgm_addGroupMode=false;this.cvgm_groupField=document.createElement("input");this.cvgm_addToGroupLabel=document.createElement("div");this.cvgm_addToGroupLabel.style.borderBottom="1px solid #344968";this.cvgm_addToGroupLabel.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupName"><label style="padding-left: 8px;">add to group</label></div>  </div>';this.cvgm_cmdCancel=false;this.cvgm_viewAllLabel=document.createElement("div");this.cvgm_viewAllLabel.owner=this;this.cvgm_viewAllLabel.onmouseover=this.cvgm_mouseHandler;this.cvgm_viewAllLabel.onmouseout=this.cvgm_mouseHandlerOut;this.cvgm_viewAllLabel.onclick=this.cvgm_mouseClick;this.cvgm_viewAllLabel.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupName"><label style="padding-left: 8px; cursor: pointer;">view all...</label></div>  </div>';this.mouseOver=false;var a=document.getElementById("friendGroupNameLabel");if(a){if(getCookie("friendsGroupName")){a.innerHTML="("+prepareFromInput(getCookie("friendsGroupName"))+")"}}this.cvgm_callerPage=null}CreateViewGroupManager.prototype.cvgm_setVisible=function(c){var a=this.cvgm_shadow;var b=this.cvgm_inputElement;if(b){a.style.position="absolute";a.style.top=this.cvgm_findPosY(b);a.style.left=this.cvgm_findPosX(b)}a.style.visibility=c};CreateViewGroupManager.prototype.cvgm_findPosX=function(a){var b=0;if(a.offsetParent){while(a.offsetParent){b+=a.offsetLeft;a=a.offsetParent}}else{if(a.x){b+=a.x}}return($ie&&this.cvgm_callerPage=="groupPick")?b-162:b};CreateViewGroupManager.prototype.cvgm_findPosY=function(b){var a=0;if(b.offsetParent){a+=b.offsetHeight;while(b.offsetParent){a+=b.offsetTop;b=b.offsetParent}}else{if(b.y){a+=b.y;a+=b.height}}return a};CreateViewGroupManager.prototype.cvgm_addWord=function(b){var a=document.createElement("div");if(this.cvgm_friendId){a.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupName" style="overflow: hidden;"><span style="padding-left: 8px; cursor: pointer; display: block; width: 500px; margin-top: 3px;">'+prepareFromInput(b.name)+"</span></div></div>"}else{a.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupGlass"></div>  <div class="friendsGroupName" style="overflow: hidden;"><span style="cursor: pointer; display: block; width: 500px; margin-top: 3px;">'+prepareFromInput(b.name)+"</span></div></div>"}a.owner=this;a.onmouseover=this.cvgm_mouseHandler;a.onmouseout=this.cvgm_mouseHandlerOut;a.onclick=this.cvgm_mouseClick;a.id=b.id;a.name=b.name;this.cvgm_outp.appendChild(a)};CreateViewGroupManager.prototype.cvgm_clearOutput=function(){while(this.cvgm_outp.hasChildNodes()){var a=this.cvgm_outp.firstChild;this.cvgm_outp.removeChild(a)}this.cvgm_posi=-1};CreateViewGroupManager.prototype.cvgm_setColor=function(a,b,c){this.cvgm_outp.childNodes[a].style.background=b;this.cvgm_outp.childNodes[a].style.color=c};CreateViewGroupManager.prototype.cvgm_keygetter=function(a){if(!a&&window.event){a=window.event}if(a){this.owner.cvgm_key=a.keyCode}else{this.owner.cvgm_key=a.which}};CreateViewGroupManager.prototype.cvgm_keyHandler=function(b){if(this.owner.cvgm_shadow.style.visibility=="visible"){if(this.owner.cvgm_key==40){if(this.owner.cvgm_posi<this.owner.cvgm_suggestions.length){if(this.owner.cvgm_posi>=0){this.owner.cvgm_setColor(this.owner.cvgm_posi,"#fff","#344968")}this.owner.cvgm_setColor(++this.owner.cvgm_posi,"#e1e1e1","#344968")}}else{if(this.owner.cvgm_key==38){if(this.owner.cvgm_suggestions.length>0&&this.owner.cvgm_posi>=0){if(this.owner.cvgm_posi>=1){this.owner.cvgm_setColor(this.owner.cvgm_posi,"#fff","#344968");this.owner.cvgm_setColor(--this.owner.cvgm_posi,"#e1e1e1","#344968")}else{this.owner.cvgm_setColor(this.owner.cvgm_posi,"#fff","#344968");this.owner.cvgm_posi--}}}else{if(this.owner.cvgm_key==27){this.owner.cvgm_setVisible("hidden");this.owner.cvgm_posi=-1;textfield.focus();var a=this.owner.cvgm_trim(this.owner.cvgm_inputElement.value.toLowerCase());if(a.indexOf(",")!=-1&&a.lastIndexOf(",")+1<a.length){a=this.owner.cvgm_trim(a.substring(a.lastIndexOf(",")+1))}this.owner.cvgm_oldins=a}else{if(this.owner.cvgm_key==8){this.owner.cvgm_posi=-1;this.owner.cvgm_oldins=-1}else{if(this.owner.cvgm_key==13){if(this.owner.cvgm_posi>=0){textfield.value="";if(text.lastIndexOf(",")!=-1){text=text.substring(0,text.lastIndexOf(",")+2);textfield.value=text+this.owner.cvgm_outp.childNodes[this.owner.cvgm_posi].firstChild.nodeValue+", "}else{textfield.value=this.owner.cvgm_outp.childNodes[this.owner.cvgm_posi].firstChild.nodeValue+", "}}this.owner.cvgm_setVisible("hidden");this.owner.cvgm_oldins=this.owner.cvgm_outp.childNodes[this.owner.cvgm_posi].firstChild.nodeValue;this.owner.cvgm_posi=-1;this.owner.cvgm_inputElement.focus()}}}}}}};CreateViewGroupManager.prototype.cvgm_mouseHandler=function(){this.owner.mouseOver=true;if(!this.owner.cvgm_addGroupMode){for(var a=0;a<this.owner.cvgm_words.length;++a){this.owner.cvgm_setColor(a,"white","black")}this.style.background="#e1e1e1";this.style.color="#344968";this.style.cursor="pointer"}};CreateViewGroupManager.prototype.cvgm_mouseHandlerOut=function(){this.owner.mouseOver=false;if(!this.owner.cvgm_addGroupMode){this.style.background="white";this.style.color="#344968"}};CreateViewGroupManager.prototype.cvgm_stopEvent=function(a){if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}};CreateViewGroupManager.prototype.cvgm_mouseClick=function(d){if(!this.owner.cvgm_addGroupMode){if(this==this.owner.cvgm_addGroupElement){this.owner.cvgm_addGroupElement.innerHTML="";this.owner.cvgm_addGroupElement.style.height="50px";var a=document.createElement("div");a.className="fieldOuterBox";this.owner.cvgm_groupField.type="text";this.owner.cvgm_groupField.className="groupField";a.appendChild(this.owner.cvgm_groupField);var c=document.createElement("div");c.className="buttonRow";var b=document.createElement("div");var e=document.createElement("div");b.className="addButton";e.className="cancelButton";c.owner=this.owner;a.owner=this.owner;this.owner.cvgm_groupField.owner=this.owner;c.appendChild(e);c.appendChild(b);b.className="addButton";e.className="cancelButton";this.owner.cvgm_addGroupElement.appendChild(a);this.owner.cvgm_addGroupElement.appendChild(c);e.value="cancel";b.value="add";e.owner=this.owner;e.onclick=this.owner.cvgm_cancel;b.owner=this.owner;b.onclick=this.owner.cvgm_addGroup;this.owner.cvgm_addGroupMode=true;this.owner.cvgm_groupField.focus();return}if(this.owner.cvgm_friendId){this.owner.cvgm_addFriendToGroup(this.owner.cvgm_friendId,this.id);return}var f=document.location.href;if(f.indexOf("/gid")>-1){f=f.substring(0,f.indexOf("/gid"))}if(f.indexOf("?")>-1){f=f.substring(0,f.indexOf("?"))}if(this==this.owner.cvgm_viewAllLabel){reloadPage(f);deleteCookie("friendsGroupName");return}f+="/gid"+this.id;this.owner.cvgm_setVisible("hidden");this.owner.cvgm_posi=-1;setCookie("friendsGroupName="+this.name);reloadPage(f)}};CreateViewGroupManager.prototype.cvgm_viewGroups=function(){var b=null;if(this.owner){b=this.owner}else{b=this}if(b.cvgm_firstTime){b.cvgm_getGroups();document.body.appendChild(b.cvgm_shadow);document.body.onclick=function(c){if(!c){var c=window.event}if(c.target){if(!b.mouseOver&&c.target!=b.cvgm_inputElement){b.cvgm_hideMenu()}}else{if(c.srcElement){if(!b.mouseOver&&c.srcElement!=b.cvgm_inputElement){b.cvgm_hideMenu()}}}};this.cvgm_firstTime=false;return}if(b.popup){b.popup=false;b.cvgm_setVisible("hidden");b.cvgm_cancel();if(b.cvgm_friendId!=b.cvgm_oldFriendId){b.cvgm_setVisible("visible");b.popup=true;b.cvgm_oldFriendId=b.cvgm_friendId}else{return}}else{b.popup=true;b.cvgm_oldFriendId=b.cvgm_friendId}b.cvgm_clearOutput();if(b.cvgm_friendId){b.cvgm_outp.appendChild(b.cvgm_addToGroupLabel);b.cvgm_addGroupElement.style.borderBottom="0px solid #344968";b.cvgm_addGroupElement.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupPlus"></div>  <div class="friendsGroupName"><label style="padding-left: 0px; cursor: pointer;">create a new group...</label></div></div>';b.cvgm_outp.appendChild(b.cvgm_addGroupElement)}else{b.cvgm_addGroupElement.style.borderBottom="1px solid #344968";b.cvgm_addGroupElement.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupPlus"></div>  <div class="friendsGroupName"><label style="padding-left: none; cursor: pointer;">create a new group...</label></div></div>';b.cvgm_outp.appendChild(b.cvgm_addGroupElement);b.cvgm_outp.appendChild(b.cvgm_viewAllLabel)}for(var a=0;a<b.cvgm_suggestions.length;++a){b.cvgm_addWord(b.cvgm_suggestions[a])}b.cvgm_setVisible("visible")};CreateViewGroupManager.prototype.cvgm_cancel=function(a){var b;if(this.owner){b=this.owner;if(!a){var a=window.event}b.cvgm_stopEvent(a)}else{b=this}b.cvgm_addGroupElement.style.background="white";b.cvgm_groupField.value="";b.cvgm_addGroupElement.style.height="23px";if(b.cvgm_friendId){b.cvgm_addGroupElement.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupPlus"></div>  <div class="friendsGroupName"><label style="padding-left: 0px; cursor: pointer;">create a new group...</label></div></div>'}else{b.cvgm_addGroupElement.innerHTML='<div style="width: 160px; height: 23px;">  <div class="friendsGroupPlus"></div>  <div class="friendsGroupName"><label style="padding-left: none; cursor: pointer;">create a new group...</label></div></div>'}b.cvgm_addGroupMode=false};CreateViewGroupManager.prototype.cvgm_trim=function(a){a=a.replace(/(\s+)$/,"");a=a.replace(/^(\s+)/,"");return a};CreateViewGroupManager.prototype.cvgm_hideMenu=function(){if(this.popup&&!Application.hideAppletFlag){if(!this.cvgm_addGroupError){this.cvgm_setVisible("hidden");this.cvgm_cancel();this.popup=false;return}else{this.cvgm_addGroupError=false}}};CreateViewGroupManager.prototype.cvgm_addGroup=function(a){var b=this.owner.cvgm_groupField.value;if(this.owner.cvgm_trim(b)==""){Application.hideAppletFlag=true;this.owner.cvgm_addGroupError=true;showMessage("Please enter a group name",null,this.owner.cvgm_groupField);return}if(this.owner.cvgm_groupField.value.length>100){Application.hideAppletFlag=true;this.owner.cvgm_addGroupError=true;showMessage("Group name length must be less than 100 symbols",null,this.owner.cvgm_groupField);return}var c=new StRpcStub();c.setUrl(CRAZYMENU_BASE_URL+"/actions/json/CreateGroup.do");c.params.set("groupName",this.owner.cvgm_trim(b));c.fetchAsyncText(this.owner.cvgm_onAddGroup,this.owner)};CreateViewGroupManager.prototype.cvgm_onAddGroup=function(a){var c=this.cvgm_groupField.value;var b=evalJSON(a);if(b.result=="ok"){this.cvgm_getGroups();this.cvgm_groupField.value=""}else{showMessage(b.message)}};CreateViewGroupManager.prototype.cvgm_getGroups=function(){var a=new StRpcStub();a.setUrl(CRAZYMENU_BASE_URL+"/actions/json/GetGroups.do");a.fetchAsyncText(this.cvgm_onGetGroups,this)};CreateViewGroupManager.prototype.cvgm_onGetGroups=function(a){var b=evalJSON(a);if(b.result=="ok"){this.cvgm_suggestions=b.groups;if(this.cvgm_addGroupMode){this.cvgm_cancel();this.popup=false}this.cvgm_viewGroups()}else{}};CreateViewGroupManager.prototype.cvgm_addFriendToGroup=function(a,b){var c=new StRpcStub();c.setUrl(CRAZYMENU_BASE_URL+"/actions/json/AddMemberToGroup.do");c.params.set("groupId",b);c.params.set("addMemberId",a);c.fetchAsyncText(this.cvgm_onAddFriendToGroup,this)};CreateViewGroupManager.prototype.cvgm_onAddFriendToGroup=function(a){var b=evalJSON(a);if(b.result=="ok"){this.cvgm_viewGroups();this.cvgm_cancel();reloadPage(document.location.href)}else{}};CreateViewGroupManager.prototype.cvgm_deleteFriendFromGroup=function(){var a=new StRpcStub();a.setUrl(CRAZYMENU_BASE_URL+"/actions/json/RemoveMemberFromGroup.do");a.params.set("groupId",this.cvgm_groupId);a.params.set("removeMemberId",this.cvgm_friendId);this.cvgm_friendId=null;this.cvgm_groupId=null;a.fetchAsyncText(this.cvgm_onDeleteFriend,this)};CreateViewGroupManager.prototype.cvgm_onDeleteFriend=function(a){var b=evalJSON(a);if(b.result=="ok"){reloadPage(document.location.href)}else{}};CreateViewGroupManager.prototype.cvgm_deleteFriend=function(){var a=new StRpcStub();a.setUrl(CRAZYMENU_BASE_URL+"/actions/json/RemoveFriend.do");a.params.set("removeMemberId",this.cvgm_friendId);this.cvgm_friendId=null;a.fetchAsyncText(this.cvgm_onDeleteFriend,this)};