
$("document").ready(function(){$("#txtNewUsers").keypress(function(e){txtNewUsers_KeyPress(e);});$("#btnAssignRights").click(function(){btnAddUsers_Click();});$(".memberDelete").live("click",function(e){confirmDeleteMember(e);});$("#dialog").dialog({autoOpen:false,bgiframe:true,resizable:false,height:140,modal:true,overlay:{backgroundColor:'#000',opacity:0.5},buttons:{Cancel:function(){$(this).dialog('close');},'Ok':function(){$(this).dialog('close');deleteMember();}}});});var txtNewUsersExpanded=false;function txtNewUsers_KeyPress(e){if((e.which==59)||(e.which==32)||(e.which==44)){if(!txtNewUsersExpanded){$("#txtNewUsers").animate({rows:"10"},"normal","linear",null);txtNewUsersExpanded=true;}}}
var memberAccess;function btnAddUsers_Click(){$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'emailString':'"+$("#txtNewUsers").val()+"'}",url:_reposRoot+'/ProcessDefinition.asmx/AddSiteAdminUsers',success:function(data){usersAdded(data);}});}
function usersAdded(data){var newMembers="";for(var member in data.d.Users){$("div.memberDetailContainer[u='"+data.d.Users[member].UserId+"']").slideUp("slow",function(){$(this).remove();});var newMember="<div class='memberDetailContainer' u='"+data.d.Users[member].UserId+"'><div class='memberDetail memberDetailImage avatar'>"
newMember+="<img src='"+data.d.Users[member].GravatarUrl+"' width='40px' height='40px' />";newMember+="</div>";newMember+="<div class='memberDetail memberDetailDetails'>";newMember+="<p> <strong>"+data.d.Users[member].Name+"</strong></p>";newMember+="<p> "+data.d.Users[member].Email+"</p>";newMember+="</div>";newMember+="<div class='memberDetail memberDetailIcons'>";newMember+="<span class='memberDelete ui-icon ui-icon-trash'>";newMember+="</span>";newMember+="</div>";newMember+="<br class='clear' />";newMember+="</div>";newMembers+=newMember;}
if(newMembers.length>0)
{var newMembersObject=$(newMembers);newMembersObject.hide();$(".newMembers",$(".siteAdmins")).append(newMembersObject);newMembersObject.slideDown("slow");$("#txtNewUsers").val("");}}
var userIdToRemove="";var containerToRemove;function confirmDeleteMember(e){containerToRemove=$($(e.target)[0].parentNode.parentNode);userIdToRemove=containerToRemove.attr("u");$("#dialog").dialog("open");}
function deleteMember(){$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'userId':"+userIdToRemove+"}",url:_reposRoot+'ProcessDefinition.asmx/RemoveSiteAdminUser',success:function(){containerToRemove.slideUp("normal");}});}