/* (c) 2008-2010 Agnition Enterprises, Inc. */

var CountryState={};CountryState.CountryPickerId="#country";CountryState.StatePickerId="#stateSelect";CountryState.StateTextId="#stateText";CountryState.StateValue="";CountryState.CountryValue="";CountryState.StateList="US:AK:Alaska|"+"US:AL:Alabama|"+"US:AR:Arkansas|"+"US:AS:American Samoa|"+"US:AZ:Arizona|"+"US:CA:California|"+"US:CO:Colorado|"+"US:CT:Connecticut|"+"US:DC:D.C.|"+"US:DE:Delaware|"+"US:FL:Florida|"+"US:FM:Micronesia|"+"US:GA:Georgia|"+"US:GU:Guam|"+"US:HI:Hawaii|"+"US:IA:Iowa|"+"US:ID:Idaho|"+"US:IL:Illinois|"+"US:IN:Indiana|"+"US:KS:Kansas|"+"US:KY:Kentucky|"+"US:LA:Louisiana|"+"US:MA:Massachusetts|"+"US:MD:Maryland|"+"US:ME:Maine|"+"US:MH:Marshall Islands|"+"US:MI:Michigan|"+"US:MN:Minnesota|"+"US:MO:Missouri|"+"US:MP:Marianas|"+"US:MS:Mississippi|"+"US:MT:Montana|"+"US:NC:North Carolina|"+"US:ND:North Dakota|"+"US:NE:Nebraska|"+"US:NH:New Hampshire|"+"US:NJ:New Jersey|"+"US:NM:New Mexico|"+"US:NV:Nevada|"+"US:NY:New York|"+"US:OH:Ohio|"+"US:OK:Oklahoma|"+"US:OR:Oregon|"+"US:PA:Pennsylvania|"+"US:PR:Puerto Rico|"+"US:PW:Palau|"+"US:RI:Rhode Island|"+"US:SC:South Carolina|"+"US:SD:South Dakota|"+"US:TN:Tennessee|"+"US:TX:Texas|"+"US:UT:Utah|"+"US:VA:Virginia|"+"US:VI:Virgin Islands|"+"US:VT:Vermont|"+"US:WA:Washington|"+"US:WI:Wisconsin|"+"US:WV:West Virginia|"+"US:WY:Wyoming|"+"US:AA:Military Americas|"+"US:AE:Military Europe/ME/Canada|"+"US:AP:Military Pacific|"+"CA:AB:Alberta|"+"CA:MB:Manitoba|"+"CA:AB:Alberta|"+"CA:BC:British Columbia|"+"CA:MB:Manitoba|"+"CA:NB:New Brunswick|"+"CA:NL:Newfoundland and Labrador|"+"CA:NS:Nova Scotia|"+"CA:NT:Northwest Territories|"+"CA:NU:Nunavut|"+"CA:ON:Ontario|"+"CA:PE:Prince Edward Island|"+"CA:QC:Quebec|"+"CA:SK:Saskatchewan|"+"CA:YT:Yukon Territory|"+"AU:AAT:Australian Antarctic Territory|"+"AU:ACT:Australian Capital Territory|"+"AU:NT:Northern Territory|"+"AU:NSW:New South Wales|"+"AU:QLD:Queensland|"+"AU:SA:South Australia|"+"AU:TAS:Tasmania|"+"AU:VIC:Victoria|"+"AU:WA:Western Australia|"+"BR:AC:Acre|"+"BR:AL:Alagoas|"+"BR:AM:Amazonas|"+"BR:AP:Amapa|"+"BR:BA:Baia|"+"BR:CE:Ceara|"+"BR:DF:Distrito Federal|"+"BR:ES:Espirito Santo|"+"BR:FN:Fernando de Noronha|"+"BR:GO:Goias|"+"BR:MA:Maranhao|"+"BR:MG:Minas Gerais|"+"BR:MS:Mato Grosso do Sul|"+"BR:MT:Mato Grosso|"+"BR:PA:Para|"+"BR:PB:Paraiba|"+"BR:PE:Pernambuco|"+"BR:PI:Piaui|"+"BR:PR:Parana|"+"BR:RJ:Rio de Janeiro|"+"BR:RN:Rio Grande do Norte|"+"BR:RO:Rondonia|"+"BR:RR:Roraima|"+"BR:RS:Rio Grande do Sul|"+"BR:SC:Santa Catarina|"+"BR:SE:Sergipe|"+"BR:SP:Sao Paulo|"+"BR:TO:Tocatins|"+"NL:DR:Drente|"+"NL:FL:Flevoland|"+"NL:FR:Friesland|"+"NL:GL:Gelderland|"+"NL:GR:Groningen|"+"NL:LB:Limburg|"+"NL:NB:Noord Brabant|"+"NL:NH:Noord Holland|"+"NL:OV:Overijssel|"+"NL:UT:Utrecht|"+"NL:ZH:Zuid Holland|"+"NL:ZL:Zeeland|"+"UK:AVON:Avon|"+"UK:BEDS:Bedfordshire|"+"UK:BERKS:Berkshire|"+"UK:BUCKS:Buckinghamshire|"+"UK:CAMBS:Cambridgeshire|"+"UK:CHESH:Cheshire|"+"UK:CLEVE:Cleveland|"+"UK:CORN:Cornwall|"+"UK:CUMB:Cumbria|"+"UK:DERBY:Derbyshire|"+"UK:DEVON:Devon|"+"UK:DORSET:Dorset|"+"UK:DURHAM:Durham|"+"UK:ESSEX:Essex|"+"UK:GLOUS:Gloucestershire|"+"UK:GLONDON:Greater London|"+"UK:GMANCH:Greater Manchester|"+"UK:HANTS:Hampshire|"+"UK:HERWOR:Hereford & Worcestershire|"+"UK:HERTS:Hertfordshire|"+"UK:HUMBER:Humberside|"+"UK:IOM:Isle of Man|"+"UK:IOW:Isle of Wight|"+"UK:KENT:Kent|"+"UK:LANCS:Lancashire|"+"UK:LEICS:Leicestershire|"+"UK:LINCS:Lincolnshire|"+"UK:MERSEY:Merseyside|"+"UK:NORF:Norfolk|"+"UK:NHANTS:Northamptonshire|"+"UK:NTHUMB:Northumberland|"+"UK:NOTTS:Nottinghamshire|"+"UK:OXON:Oxfordshire|"+"UK:SHROPS:Shropshire|"+"UK:SOM:Somerset|"+"UK:STAFFS:Staffordshire|"+"UK:SUFF:Suffolk|"+"UK:SURREY:Surrey|"+"UK:SUSS:Sussex|"+"UK:WARKS:Warwickshire|"+"UK:WMID:West Midlands|"+"UK:WILTS:Wiltshire|"+"UK:YORK:Yorkshire|"+"EI:CO ANTRIM:County Antrim|"+"EI:CO ARMAGH:County Armagh|"+"EI:CO DOWN:County Down|"+"EI:CO FERMANAGH:County Fermanagh|"+"EI:CO DERRY:County Londonderry|"+"EI:CO TYRONE:County Tyrone|"+"EI:CO CAVAN:County Cavan|"+"EI:CO DONEGAL:County Donegal|"+"EI:CO MONAGHAN:County Monaghan|"+"EI:CO DUBLIN:County Dublin|"+"EI:CO CARLOW:County Carlow|"+"EI:CO KILDARE:County Kildare|"+"EI:CO KILKENNY:County Kilkenny|"+"EI:CO LAOIS:County Laois|"+"EI:CO LONGFORD:County Longford|"+"EI:CO LOUTH:County Louth|"+"EI:CO MEATH:County Meath|"+"EI:CO OFFALY:County Offaly|"+"EI:CO WESTMEATH:County Westmeath|"+"EI:CO WEXFORD:County Wexford|"+"EI:CO WICKLOW:County Wicklow|"+"EI:CO GALWAY:County Galway|"+"EI:CO MAYO:County Mayo|"+"EI:CO LEITRIM:County Leitrim|"+"EI:CO ROSCOMMON:County Roscommon|"+"EI:CO SLIGO:County Sligo|"+"EI:CO CLARE:County Clare|"+"EI:CO CORK:County Cork|"+"EI:CO KERRY:County Kerry|"+"EI:CO LIMERICK:County Limerick|"+"EI:CO TIPPERARY:County Tipperary|"+"EI:CO WATERFORD:County Waterford|"+"";CountryState.CountryList="AF:Afghanistan|"+"AL:Albania|"+"DZ:Algeria|"+"AS:American Samoa|"+"AD:Andorra|"+"AO:Angola|"+"AI:Anguilla|"+"AQ:Antarctica|"+"AG:Antigua and Barbuda|"+"AR:Argentina|"+"AM:Armenia|"+"AW:Aruba|"+"AU:Australia|"+"AT:Austria|"+"AZ:Azerbaijan|"+"AP:Azores|"+"BS:Bahamas|"+"BH:Bahrain|"+"BD:Bangladesh|"+"BB:Barbados|"+"BY:Belarus|"+"BE:Belgium|"+"BZ:Belize|"+"BJ:Benin|"+"BM:Bermuda|"+"BT:Bhutan|"+"BO:Bolivia|"+"BA:Bosnia And Herzegowina|"+"XB:Bosnia-Herzegovina|"+"BW:Botswana|"+"BV:Bouvet Island|"+"BR:Brazil|"+"IO:British Indian Ocean Territory|"+"VG:British Virgin Islands|"+"BN:Brunei Darussalam|"+"BG:Bulgaria|"+"BF:Burkina Faso|"+"BI:Burundi|"+"KH:Cambodia|"+"CM:Cameroon|"+"CA:Canada|"+"CV:Cape Verde|"+"KY:Cayman Islands|"+"CF:Central African Republic|"+"TD:Chad|"+"CL:Chile|"+"CN:China|"+"CX:Christmas Island|"+"CC:Cocos (Keeling) Islands|"+"CO:Colombia|"+"KM:Comoros|"+"CG:Congo|"+"CD:Congo, The Democratic Republic Of|"+"CK:Cook Islands|"+"XE:Corsica|"+"CR:Costa Rica|"+"CI:Cote d' Ivoire (Ivory Coast)|"+"HR:Croatia|"+"CU:Cuba|"+"CY:Cyprus|"+"CZ:Czech Republic|"+"DK:Denmark|"+"DJ:Djibouti|"+"DM:Dominica|"+"DO:Dominican Republic|"+"TP:East Timor|"+"EC:Ecuador|"+"EG:Egypt|"+"SV:El Salvador|"+"GQ:Equatorial Guinea|"+"ER:Eritrea|"+"EE:Estonia|"+"ET:Ethiopia|"+"FK:Falkland Islands (Malvinas)|"+"FO:Faroe Islands|"+"FJ:Fiji|"+"FI:Finland|"+"FR:France (Includes Monaco)|"+"FX:France, Metropolitan|"+"GF:French Guiana|"+"PF:French Polynesia|"+"TA:French Polynesia (Tahiti)|"+"TF:French Southern Territories|"+"GA:Gabon|"+"GM:Gambia|"+"GE:Georgia|"+"DE:Germany|"+"GH:Ghana|"+"GI:Gibraltar|"+"GR:Greece|"+"GL:Greenland|"+"GD:Grenada|"+"GP:Guadeloupe|"+"GU:Guam|"+"GT:Guatemala|"+"GN:Guinea|"+"GW:Guinea-Bissau|"+"GY:Guyana|"+"HT:Haiti|"+"HM:Heard And McDonald Islands|"+"VA:Holy See (Vatican City State)|"+"HN:Honduras|"+"HK:Hong Kong|"+"HU:Hungary|"+"IS:Iceland|"+"IN:India|"+"ID:Indonesia|"+"IR:Iran|"+"IQ:Iraq|"+"IE:Ireland|"+"EI:Ireland (Eire)|"+"IL:Israel|"+"IT:Italy|"+"JM:Jamaica|"+"JP:Japan|"+"JO:Jordan|"+"KZ:Kazakhstan|"+"KE:Kenya|"+"KI:Kiribati|"+"KP:Korea, Democratic People's Repub|"+"KW:Kuwait|"+"KG:Kyrgyzstan|"+"LA:Laos|"+"LV:Latvia|"+"LB:Lebanon|"+"LS:Lesotho|"+"LR:Liberia|"+"LY:Libya|"+"LI:Liechtenstein|"+"LT:Lithuania|"+"LU:Luxembourg|"+"MO:Macao|"+"MK:Macedonia|"+"MG:Madagascar|"+"ME:Madeira Islands|"+"MW:Malawi|"+"MY:Malaysia|"+"MV:Maldives|"+"ML:Mali|"+"MT:Malta|"+"MH:Marshall Islands|"+"MQ:Martinique|"+"MR:Mauritania|"+"MU:Mauritius|"+"YT:Mayotte|"+"MX:Mexico|"+"FM:Micronesia, Federated States Of|"+"MD:Moldova, Republic Of|"+"MC:Monaco|"+"MN:Mongolia|"+"MS:Montserrat|"+"MA:Morocco|"+"MZ:Mozambique|"+"MM:Myanmar (Burma)|"+"NA:Namibia|"+"NR:Nauru|"+"NP:Nepal|"+"NL:Netherlands|"+"AN:Netherlands Antilles|"+"NC:New Caledonia|"+"NZ:New Zealand|"+"NI:Nicaragua|"+"NE:Niger|"+"NG:Nigeria|"+"NU:Niue|"+"NF:Norfolk Island|"+"MP:Northern Mariana Islands|"+"NO:Norway|"+"OM:Oman|"+"PK:Pakistan|"+"PW:Palau|"+"PS:Palestinian Territory, Occupied|"+"PA:Panama|"+"PG:Papua New Guinea|"+"PY:Paraguay|"+"PE:Peru|"+"PH:Philippines|"+"PN:Pitcairn|"+"PL:Poland|"+"PT:Portugal|"+"PR:Puerto Rico|"+"QA:Qatar|"+"RE:Reunion|"+"RO:Romania|"+"RU:Russian Federation|"+"RW:Rwanda|"+"KN:Saint Kitts And Nevis|"+"SM:San Marino|"+"ST:Sao Tome and Principe|"+"SA:Saudi Arabia|"+"SN:Senegal|"+"XS:Serbia-Montenegro|"+"SC:Seychelles|"+"SL:Sierra Leone|"+"SG:Singapore|"+"SK:Slovak Republic|"+"SI:Slovenia|"+"SB:Solomon Islands|"+"SO:Somalia|"+"ZA:South Africa|"+"GS:South Georgia And The South Sandwich Islands|"+"KR:South Korea|"+"ES:Spain|"+"LK:Sri Lanka|"+"NV:St. Christopher and Nevis|"+"SH:St. Helena|"+"LC:St. Lucia|"+"PM:St. Pierre and Miquelon|"+"VC:St. Vincent and the Grenadines|"+"SD:Sudan|"+"SR:Suriname|"+"SJ:Svalbard And Jan Mayen Islands|"+"SZ:Swaziland|"+"SE:Sweden|"+"CH:Switzerland|"+"SY:Syrian Arab Republic|"+"TW:Taiwan|"+"TJ:Tajikistan|"+"TZ:Tanzania|"+"TH:Thailand|"+"TG:Togo|"+"TK:Tokelau|"+"TO:Tonga|"+"TT:Trinidad and Tobago|"+"XU:Tristan da Cunha|"+"TN:Tunisia|"+"TR:Turkey|"+"TM:Turkmenistan|"+"TC:Turks and Caicos Islands|"+"TV:Tuvalu|"+"UG:Uganda|"+"UA:Ukraine|"+"AE:United Arab Emirates|"+"UK:United Kingdom|"+"GB:Great Britain|"+"US:United States|"+"UM:United States Minor Outlying Islands|"+"UY:Uruguay|"+"UZ:Uzbekistan|"+"VU:Vanuatu|"+"XV:Vatican City|"+"VE:Venezuela|"+"VN:Vietnam|"+"VI:Virgin Islands (U.S.)|"+"WF:Wallis and Furuna Islands|"+"EH:Western Sahara|"+"WS:Western Samoa|"+"YE:Yemen|"+"YU:Yugoslavia|"+"ZR:Zaire|"+"ZM:Zambia|"+"ZW:Zimbabwe|"+"";CountryState.TrimString=function(sInString){if(sInString){sInString=sInString.replace(/^\s+/g,"");return sInString.replace(/\s+$/g,"");}
return sInString;};CountryState.PopulateCountry=function(defaultCountry){if(CountryState.CountryValue!==""){defaultCountry=CountryState.CountryValue;}
var countryLineArray=CountryState.CountryList.split("|");var selObj=$(CountryState.CountryPickerId).get(0);selObj.options.length=0;selObj.options[0]=new Option("Select Country","");selObj.selectedIndex=0;var lineArray=null;var countryCode=null;var countryName=null;for(var loop=0;loop<countryLineArray.length;loop++){lineArray=countryLineArray[loop].split(":");if(lineArray!==""){countryCode=CountryState.TrimString(lineArray[0]);countryName=CountryState.TrimString(lineArray[1]);if((countryCode!=="")&&(countryName!=="")){selObj.options[loop+1]=new Option(countryName,countryCode);}
if(defaultCountry===countryCode){selObj.selectedIndex=loop+1;}}}};CountryState.PopulateState=function(){var stateSelect=$(CountryState.StatePickerId);var stateText=$(CountryState.StateTextId);var isSelect=(stateSelect.css("display")!=="none");var switchSelect=!isSelect;var foundState=false;var selObj=null;if(isSelect){selObj=stateSelect.get(0);for(var i=0;i<selObj.options.length;i++){selObj.options[i]=null;}
selObj.options.length=null;selObj.options[0]=new Option("Select State","");selObj.selectedIndex=0;}
var stateLineArray=CountryState.StateList.split("|");var optionCntr=1;var countryVal=$(CountryState.CountryPickerId).val();var lineArray=null;var countryCode=null;var stateCode=null;var stateName=null;for(var loop=0;loop<stateLineArray.length;loop++){lineArray=stateLineArray[loop].split(":");if(lineArray!==""){countryCode=CountryState.TrimString(lineArray[0]);stateCode=CountryState.TrimString(lineArray[1]);stateName=CountryState.TrimString(lineArray[2]);if((countryVal===countryCode)&&(countryCode!=="")){if(switchSelect){stateSelect.css("display","");stateText.css("display","none");selObj=stateSelect.get(0);selObj.options[0]=new Option("Select State","");selObj.selectedIndex=0;switchSelect=false;}
if((stateCode!=="")&&(stateName!=="")){selObj.options[optionCntr]=new Option(stateName,stateCode);}
if((stateCode===CountryState.StateValue)&&(countryCode===CountryState.CountryValue)){selObj.selectedIndex=optionCntr;}
foundState=true;optionCntr++;}}}
if(!foundState){stateText.css("display","");stateSelect.css("display","none");stateText.val(CountryState.StateValue);}};CountryState.InitCountry=function(country){CountryState.PopulateCountry(country);CountryState.PopulateState();};
Agnition.Zleek.UserProfile={};Agnition.Zleek.UserProfile.ProfileData=null;Agnition.CLEAR_FOLLOW_MESSAGE=true;var executingFollowRequest=false;Agnition.Zleek.UserProfile.DisplayProfileSummary=function(){var data=Agnition.Zleek.UserProfile.ProfileData;data.User.FullName=Agnition.HtmlEncode(data.User.FullName);document.title="Zleek - "+data.User.FullName+"'s Profile";$("#fullNameHeader").html(data.User.FullName);$("#avatarPhoto").attr("alt",data.User.FullName).attr("src",data.User.AvatarUrl);var profile=data.User.Profile;if(profile.Gender===null){profile.Gender=" ";}
var sb=new StringBuilder();if(profile.City!==null){sb.append(Agnition.HtmlEncode(profile.City));}
if(profile.State!==null){if(sb.length()>0){sb.append(", ");}
sb.append(Agnition.HtmlEncode(profile.State));}
if(profile.Country!==null){if(sb.length()>0){sb.append(", ");}
sb.append(Agnition.HtmlEncode(profile.Country));}
if(sb.length()>0){$("#userLocation").html("from <strong>"+sb.toString()+"<\/strong><br \/>");}
else{$("#userLocation").html("");}
sb.clear();Agnition.Zleek.UserProfile.DisplayPersonalData(profile.Personal);var now=new Date();data.User.CreateDate=Agnition.Serialization.GetJQueryDateAsLocalTime(data.User.CreateDate);data.User.LastUpdated=Agnition.Serialization.GetJQueryDateAsLocalTime(data.User.LastUpdated);data.User.Summary.LastUpdated=Agnition.Serialization.GetJQueryDateAsLocalTime(data.User.Summary.LastUpdated);if(data.User.CreateDate>now){data.User.CreateDate=now;}
if(data.User.LastUpdated>now){data.User.LastUpdated=now;}
if(data.User.Summary.LastUpdated>now){data.User.Summary.LastUpdated=now;}
profile.DateOfBirth=Agnition.Serialization.FixJQueryDate(profile.DateOfBirth);$("#userJoined").text(Agnition.Text.Date.GetLongDate(data.User.CreateDate));var sum=data.User.Summary;sb.appendFormat("created <strong>{0} album{1}<\/strong>",Agnition.Text.Numeric.GetFormatted(sum.TotalAlbums),sum.TotalAlbums===1?"":"s").appendFormat(" <span class=\"small light\">- last updated <strong>{0}<\/strong><\/span><br \/>",sum.LastUpdated>new Date()?"just now":Agnition.Text.Date.GetFriendlyDate(sum.LastUpdated)).appendFormat("<span class=\"small light\">viewed <strong>{0} times<\/strong>  / ",Agnition.Text.Numeric.GetFormatted(sum.TotalViews)).appendFormat("liked by <strong>{0} {1}<\/strong><\/span>",Agnition.Text.Numeric.GetFormatted(sum.TotalLiked),sum.TotalLiked===1?"person":"people");$("#userSummary").html(sb.toString());$("#profileFollowersLink").html("Followers ("+Agnition.Text.Numeric.GetFormatted(sum.TotalFollowers)+")");$("#profileFollowingLink").html("Following ("+Agnition.Text.Numeric.GetFormatted(sum.TotalFollowing)+")");sb.clear();};Agnition.Zleek.UserProfile.DisplayPersonalData=function(personalData){var aboutMe=null;if(personalData!==null){aboutMe=personalData.AboutMe;}
Agnition.Zleek.Web.UI.InitializeDisplayPanel($("#userAboutMeContainer"),$("#userAboutMe"),$("#userAboutMeMore"),aboutMe);};Agnition.Zleek.UserProfile.ToggleAboutMe=function(){var aboutMe=Agnition.Zleek.UserProfile.ProfileData.User.Profile.Personal.AboutMe;Agnition.Zleek.Web.UI.ToggleFullText($("#userAboutMe"),$("#userAboutMeMore"),aboutMe);};Agnition.Zleek.UserProfile.DisplayRecentAlbums=function(){Agnition.Zleek.UserProfile.DisplayAlbumSelection("#profileRecentAlbumsLink",recentAlbumsUrl);};Agnition.Zleek.UserProfile.DisplayPopularAlbums=function(){Agnition.Zleek.UserProfile.DisplayAlbumSelection("#profilePopularAlbumsLink",popularAlbumsUrl);};Agnition.Zleek.UserProfile.DisplayHotAlbums=function(){Agnition.Zleek.UserProfile.DisplayAlbumSelection("#profileHotAlbumsLink",hotAlbumsUrl);};Agnition.Zleek.UserProfile.DisplayFavoriteAlbums=function(){Agnition.Zleek.UserProfile.DisplayAlbumSelection("#profileFavoriteAlbumsLink",favoriteAlbumsUrl);};Agnition.Zleek.UserProfile.DisplayAlbumSelection=function(linkSelector,url){var selectedLink=$(linkSelector);if(selectedLink.hasClass("selected")){return;}
$("#profileAlbums li").removeClass("selected");selectedLink.addClass("selected");Agnition.BOOK_QUERY_URL=url.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);Agnition.Zleek.Web.UI.BookList.RenderPageData(1);};Agnition.Zleek.UserProfile.RequestFollow=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(requestFollowUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure you want to follow "+fullName+"?":null,"Issuing follow request...",fullName+" has been notified of your follow request","Error: Unable to follow "+fullName,function(){},function(){$("#requestFollowLink").css("display","none");});};Agnition.Zleek.UserProfile.Unfollow=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(unfollowUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure you want to stop following "+fullName+"?":null,"Issuing stop follow request...","You stopped following "+fullName,"Error: Unable to stop following "+fullName,function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetFollowing(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#unfollowUserLink").css("display","none");});};Agnition.Zleek.UserProfile.RemoveFollow=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(rejectFollowerUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure that you want to stop "+fullName+" from following you? They will be notified of your decision.":null,"Issuing remove follower request...",fullName+" was stopped from following you","Error: Unable to remove "+fullName+" as a follower",function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetFollowers(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#stopUserLink").css("display","none");});};Agnition.Zleek.UserProfile.AcceptFollow=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(acceptFollowerUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure that you want to allow "+fullName+" to follow you? They will be notified of your decision.":null,"Issuing accept follow request...",fullName+" is now following you","Error: Unable to accept "+fullName+" as a follower",function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetPendingFollowers(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#followRequestGroup").css("display","none");});};Agnition.Zleek.UserProfile.RejectFollow=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(rejectFollowerUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure that you want to reject "+fullName+"? They will be notified of your decision.":null,"Issuing reject follow request...",fullName+" was rejected from following you","Error: Unable to reject "+fullName+" as a follower",function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetPendingFollowers(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#followRequestGroup").css("display","none");});};Agnition.Zleek.UserProfile.Block=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(blockUserUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure you want to block "+fullName+"?":null,"Issuing block request...",fullName+"is blocked from following you","Error: Unable to block "+fullName,function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetPendingFollowers(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#followRequestGroup").css("display","none");});};Agnition.Zleek.UserProfile.Unblock=function(userName,fullName,prompt){if(Agnition.EXECUTING_REQUEST){return;}
if(!userName){userName=Agnition.Zleek.UserProfile.ProfileData.User.UserName;}
if(!fullName){fullName=Agnition.Zleek.UserProfile.ProfileData.User.FullName;}
Agnition.Zleek.UserProfile.IssueFollowRequest(unblockUserUrl.replace(/\|USERNAME\|/,userName),prompt?"Are you sure you want to unblock "+fullName+"?":null,"Issuing unblock request...",fullName+"is no longer blocked from following you","Error: Unable to unblock "+fullName,function(){Agnition.CLEAR_FOLLOW_MESSAGE=false;Agnition.Zleek.UserProfile.GetBlocked(1);Agnition.CLEAR_FOLLOW_MESSAGE=true;},function(){$("#unblockUserLink").css("display","none");});};Agnition.Zleek.UserProfile.GetProfileFollowers=function(pageNumber){var requestUrl=followerUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);followerRequest=new Agnition.Zleek.UserProfile.FollowData(false,null,null);followerRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetProfileFollowers,"#profileFollowersLink");};Agnition.Zleek.UserProfile.GetProfileFollowing=function(pageNumber){var requestUrl=followingUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);followingRequest=new Agnition.Zleek.UserProfile.FollowData(false,null,null);followingRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetProfileFollowing,"#profileFollowingLink");};Agnition.Zleek.UserProfile.ManageFollow=function(){$("#followEditor").modal({containerCss:{width:550,height:400},opacity:60,onOpen:Agnition.Zleek.Web.UI.DialogOpen,onClose:Agnition.Zleek.Web.UI.DialogClose});Agnition.Zleek.UserProfile.GetFollowers(1);};Agnition.Zleek.UserProfile.GetPendingFollowers=function(pageNumber){var requestUrl=pendingFollowersUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);if(isCurrentUserProfile){followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,Agnition.Zleek.UserProfile.FollowData.LinkRenderCallback=function(user,sb){sb.appendFormat("<span id=\"accept{0}\" title=\"Accept {1}\" class=\"btn allow followActionLink\">Accept<\/span>",user.UserName,user.FullName).appendFormat("<span id=\"reject{0}\" title=\"Reject {1}\" class=\"btn reject followActionLink\">Reject<\/span>",user.UserName,user.FullName).appendFormat("<span id=\"block{0}\" title=\"Block {1}\" class=\"btn block followActionLink\">Block<\/span>",user.UserName,user.FullName);},Agnition.Zleek.UserProfile.FollowData.LinksCompletedCallback=function(list){$("li .btn[id^='accept']",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(6);var fullName=source.title.substring(7);Agnition.Zleek.UserProfile.AcceptFollow(userName,fullName,false);e.preventDefault();return false;});});$("li .btn[id^='reject']",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(6);var fullName=source.title.substring(7);Agnition.Zleek.UserProfile.RejectFollow(userName,fullName,false);e.preventDefault();return false;});});$("li .btn[id^='block']",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(5);var fullName=source.title.substring(6);Agnition.Zleek.UserProfile.Block(userName,fullName,false);e.preventDefault();return false;});});});}
else{followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,null,null);}
followerRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetPendingFollowers,"#pendingFollowersLink");};Agnition.Zleek.UserProfile.GetFollowers=function(pageNumber){var requestUrl=followerUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);if(isCurrentUserProfile){followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,Agnition.Zleek.UserProfile.FollowData.LinkRenderCallback=function(user,sb){sb.appendFormat("<span id=\"remove{0}\" title=\"Remove {1}\" class=\"btn delete followActionLink\">Remove<\/span>",user.UserName,user.FullName);},Agnition.Zleek.UserProfile.FollowData.LinksCompletedCallback=function(list){$("li .btn[id^='remove']",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(6);var fullName=source.title.substring(7);Agnition.Zleek.UserProfile.RemoveFollow(userName,fullName,false);e.preventDefault();return false;});});});}
else{followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,null,null);}
followerRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetFollowers,"#followersLink");};Agnition.Zleek.UserProfile.GetFollowing=function(pageNumber){var requestUrl=followingUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);var followerRequest;if(isCurrentUserProfile){followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,Agnition.Zleek.UserProfile.FollowData.LinkRenderCallback=function(user,sb){sb.appendFormat("<span id=\"stop{0}\" title=\"Stop Following {1}\" class=\"btn unfollow followActionLink\">Stop Following<\/span>",user.UserName,user.FullName);},Agnition.Zleek.UserProfile.FollowData.LinksCompletedCallback=function(list){$("li .btn",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(4);var fullName=source.title.substring(15);Agnition.Zleek.UserProfile.Unfollow(userName,fullName,false);e.preventDefault();return false;});});});}
else{followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,null,null);}
followerRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetFollowing,"#followingLink");};Agnition.Zleek.UserProfile.GetBlocked=function(pageNumber){var requestUrl=blockedUrl.replace(/\|USERNAME\|/,Agnition.Zleek.UserProfile.ProfileData.User.UserName);var followerRequest;if(isCurrentUserProfile){followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,Agnition.Zleek.UserProfile.FollowData.LinkRenderCallback=function(user,sb){sb.appendFormat("<span id=\"unblock{0}\" title=\"Unblock {1}\" class=\"btn unblock followActionLink\">Unblock<\/span>",user.UserName,user.FullName);},Agnition.Zleek.UserProfile.FollowData.LinksCompletedCallback=function(list){$("li .btn",list).each(function(i){$(this).bind("click",function(e){var source=e.srcElement===undefined?e.target:e.srcElement;var userName=source.id.substring(7);var fullName=source.title.substring(8);Agnition.Zleek.UserProfile.Unblock(userName,fullName,false);e.preventDefault();return false;});});});}
else{followerRequest=new Agnition.Zleek.UserProfile.FollowData(true,null,null);}
followerRequest.Display(requestUrl,pageNumber,Agnition.Zleek.UserProfile.GetFollowing,"#blockedLink");};Agnition.Zleek.UserProfile.IssueFollowRequest=function(url,promptMessage,loadingMessage,successMessage,errorMessage,successCallback,promptSuccessCallback){if(promptMessage!==null){Agnition.Zleek.Web.UI.Prompt(promptMessage,function(){Agnition.Zleek.IssueExecuteRequest(url,loadingMessage,successMessage,errorMessage,"#profileFollowExecuting","#profileFollowSuccess","#profileFollowError",promptSuccessCallback);});}
else{Agnition.Zleek.IssueExecuteRequest(url,loadingMessage,successMessage,errorMessage,"#followEditorRequestExecuting","#followEditorRequestSuccess","#followEditorRequestError",successCallback);}};Agnition.Zleek.UserProfile.FollowData=function(inFollowEditor,renderCallback,completedCallback){this.__class=true;this.InFollowEditor=inFollowEditor;this.LinkRenderCallback=renderCallback;this.LinksCompletedCallback=completedCallback;var clientRenderCallback=null;var clientCompletedCallback=null;this.Display=function(requestUrl,pageNumber,callbackFunction,menuLinkSelector){if((pageNumber===null)||isNaN(pageNumber)||(pageNumber<=0)){pageNumber=1;}
clientRenderCallback=this.LinkRenderCallback;clientCompletedCallback=this.LinksCompletedCallback;var followHeaderSelector=this.InFollowEditor?"#followHeader":"#profileFollowerHeader";var followContainerSelector=this.InFollowEditor?"#followContainer":"#profileFollowContainer";var followListSelector=this.InFollowEditor?"#followList":"#profileFollowList";var followPagerSelector=this.InFollowEditor?"#followPager":"#profileFollowPager";var followLoadingSelector=this.InFollowEditor?"#followLoading":"#profileFollowLoading";var followLoadErrorSelector=this.InFollowEditor?"#followLoadError":"#profileFollowLoadError";var profileFollowMenuSelector=this.InFollowEditor?"#followMenu li":"#profileFollowMenu li";var pageSize=this.InFollowEditor?FOLLOWER_PAGE_SIZE:PROFILE_FOLLOWER_PAGE_SIZE;var maxRecords=this.InFollowEditor?FOLLOWER_MAX_RECORDS:PROFILE_FOLLOWER_MAX_RECORDS;var displayPages=this.InFollowEditor?FOLLOWER_DISPLAY_PAGES:PROFILE_FOLLOWER_DISPLAY_PAGES;$(followHeaderSelector).css("display","");$(followContainerSelector).css("display","none");$(followListSelector).html("");$(followPagerSelector).html("");$(followLoadingSelector).css("display","none");$(followLoadErrorSelector).css("display","none");$(profileFollowMenuSelector).removeClass("selected");$(menuLinkSelector).addClass("selected");if(Agnition.CLEAR_FOLLOW_MESSAGE){$("#followEditorRequestExecuting,#followEditorRequestSuccess,#followEditorRequestError").css("display","none");}
var request=new Agnition.Zleek.Web.Service.PagedDataRequest(requestUrl,pageSize,maxRecords);request.GetPage(pageNumber,function(){$(followLoadingSelector).css("display","");},function(data,statusText){var sb=new StringBuilder();var numUsers=data.Users.length;if(numUsers===0){$(followHeaderSelector).css("display","none");}
for(var i=0;i<numUsers;i++){var user=data.Users[i];user.LastUpdated=Agnition.Serialization.GetJQueryDateAsLocalTime(user.LastUpdated);var userProfileUrl=profileUrl.replace(/\|USERNAME\|/,user.UserName);sb.append("<li>").appendFormat("<img class=\"avatarThumbnail followImage\" src=\"{0}\" alt=\"{1}\" \/>",user.ThumbnailUrl,user.FullName).appendFormat("<h5><a class=\"followLink\" href=\"{0}\">{1}<\/a></h5><br />",userProfileUrl,user.FullName).appendFormat("<span class=\"small light\">{0} albums \/ last updated {1}<\/span>",Agnition.Text.Numeric.GetFormatted(user.Summary.TotalAlbums),Agnition.Text.Date.GetFriendlyDate(user.LastUpdated));if(clientRenderCallback!==null){clientRenderCallback(user,sb);}
sb.append("<\/li>");}
$(followContainerSelector).css("display","");$(followLoadErrorSelector).css("display","none");var list=$(followListSelector);list.html(sb.toString()).children().each(function(i){var url=$("a",this).attr("href");$(this).click(function(){document.location=url;});});sb.clear();if(clientCompletedCallback!==null){clientCompletedCallback(list);}
if(data.PageCount>1){$(followPagerSelector).pager({pageNumber:data.PageNumber,pageCount:data.PageCount,maxDisplayedPages:displayPages,buttonClickCallback:callbackFunction});}},function(request,statusText){Agnition.Zleek.LogError(request.status+": "+request.statusText);$(followContainerSelector).css("display","none");$(followLoadErrorSelector).css("display","");},function(statusText){$(followLoadingSelector).css("display","none");});};};
Agnition.Zleek.UserProfile.UploaderHost=null;Agnition.Zleek.UserProfile.Uploader=null;Agnition.Zleek.UserProfile.EditProfile=function(){Agnition.Zleek.UserProfile.LoadProfile();Agnition.Zleek.UserProfile.SelectBasic();$("#profileEditor").modal({containerCss:{width:550,height:500},opacity:60,onOpen:Agnition.Zleek.Web.UI.DialogOpen,onClose:Agnition.Zleek.Web.UI.DialogClose});};Agnition.Zleek.UserProfile.LoadProfile=function(){var userData=Agnition.Zleek.UserProfile.ProfileData.User;var editor=$("#profileDisplay");var fname=$("#firstName",editor);var lname=$("#lastName",editor);var city=$("#city",editor);var stateText=$("#stateText",editor);fname.val(Agnition.Zleek.GetValueForForm(userData.FirstName));lname.val(Agnition.Zleek.GetValueForForm(userData.LastName));city.val(Agnition.Zleek.GetValueForForm(userData.Profile.City));stateText.val(Agnition.Zleek.GetValueForForm(userData.Profile.State));if(fname.val().length>0){fname.removeClass("watermark");}else{fname.val("first");}
if(lname.val().length>0){lname.removeClass("watermark");}else{lname.val("last");}
if(city.val().length>0){city.removeClass("watermark");}else{city.val("city");}
if(stateText.val().length>0){stateText.removeClass("watermark");}else{stateText.val("state");}
$("input[name='gender'][value='"+userData.Profile.Gender+"']",editor).attr("checked","checked");$("#avatar",editor).attr("src",userData.AvatarUrl).attr("alt",userData.FullName);$("#avatarUploadContainer").html("");$("#emailAddress",editor).val(Agnition.Zleek.GetValueForForm(userData.EmailAddress));$("#birthDate",editor).val(Agnition.Zleek.GetValueForForm(userData.Profile.DateOfBirth));$("#aboutMe",editor).val(Agnition.Zleek.GetValueForForm(userData.Profile.Personal.AboutMe));CountryState.CountryPickerId="#country";CountryState.StatePickerId="#stateSelect";CountryState.StateTextId="#stateText";CountryState.StateValue=Agnition.Zleek.GetValueForForm(userData.Profile.State);CountryState.CountryValue=Agnition.Zleek.GetValueForForm(userData.Profile.Country);CountryState.InitCountry("US");};Agnition.Zleek.UserProfile.LoadUploader=function(){var userData=Agnition.Zleek.UserProfile.ProfileData.User;var initParamsSb=new StringBuilder().appendFormat("wf={0},u={1},width={2},height={3}",Agnition.Zleek.UploadServiceAddress,userData.UserName,325,204);var altHtmlSb=new StringBuilder();altHtmlSb.append("<a href=\"http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0\" style=\"text-decoration: none;\">").append("<img src=\"http://go2.microsoft.com/fwlink/?LinkID=108181\" alt=\"Get Microsoft Silverlight\" style=\"border-style: none\" \/>").append("<\/a>");var uploadContainer=$("#avatarUploadContainer").get(0);Silverlight.createObject(uploadXapAddress,uploadContainer,"slAvatarUpload",{width:"100%",height:"100%",background:"white",version:"4.0.50401.0",enablehtmlaccess:"true",autoUpgrade:"true",enableGPUAcceleration:"true",alt:altHtmlSb.toString(),splashScreenSource:splashScreenAddress},{onSourceDownloadProgressChanged:Agnition.Zleek.Silverlight.LoadProgressChanged,onLoad:Agnition.Zleek.UserProfile.UploaderLoaded},initParamsSb.toString());altHtmlSb.clear();};Agnition.Zleek.UserProfile.UploaderLoaded=function(plugIn,userContext,sender){if(plugIn===null){return;}
var content=plugIn.contentDocument.Content;Agnition.Zleek.UserProfile.UploaderHost=content;Agnition.Zleek.UserProfile.Uploader=content.ZleekUploader;content.ZleekUploader.addEventListener("UploadCompleted",Agnition.Zleek.UserProfile.UploadCompletedHandler);};Agnition.Zleek.UserProfile.UploadCompletedHandler=function(){var avatars=$("#avatar,#avatarPhoto");avatars.attr("src",Agnition.Zleek.UserProfile.ProfileData.User.AvatarUrl+"?"+(new Date()).getTime());};Agnition.Zleek.UserProfile.SelectBasic=function(){Agnition.Zleek.UserProfile.SelectProfileTab("#basicProfileLink","#basicProfileDisplay");};Agnition.Zleek.UserProfile.SelectDetailed=function(){Agnition.Zleek.UserProfile.SelectProfileTab("#detailedProfileLink","#detailedProfileDisplay");};Agnition.Zleek.UserProfile.SelectAbout=function(){Agnition.Zleek.UserProfile.SelectProfileTab("#aboutProfileLink","#aboutProfileDisplay");};Agnition.Zleek.UserProfile.SelectAccount=function(){Agnition.Zleek.UserProfile.SelectProfileTab("#accountProfileLink","#accountProfileDisplay");};Agnition.Zleek.UserProfile.SelectAvatar=function(){Agnition.Zleek.UserProfile.SelectProfileTab("#avatarProfileLink","#avatarProfileDisplay");Agnition.Zleek.UserProfile.LoadUploader();};Agnition.Zleek.UserProfile.SelectProfileTab=function(linkSelector,displaySelector){var selectedLink=$(linkSelector);if(selectedLink.hasClass("selected")){return;}
$("#profileTabs li").removeClass("selected");selectedLink.addClass("selected");$(".profileTab").css("display","none");$(displaySelector).css("display","block");};Agnition.Zleek.UserProfile.SaveProfile=function(){var editor=$("#profileDisplay");var firstName=$("#firstName").hasClass("watermark")?"":$("#firstName").val();var lastName=$("#lastName").hasClass("watermark")?"":$("#lastName").val();var emailAddress=$("#emailAddress",editor).val();var gender=$("input[name='gender']:checked",editor).val();var birthDate=$("#birthDate",editor).val();var city=$("#city").hasClass("watermark")?"":$("#city").val();var state="";if($("#stateSelect",editor).css("display")!=="none"){state=$("#stateSelect",editor).val();}
else{state=$("#stateText").hasClass("watermark")?"":$("#stateText").val();}
var country=$("#country",editor).val();var aboutMe=$("#aboutMe",editor).val();var oldPwdField=$("#oldPassword",editor);var newPwdField=$("#newPassword",editor);var repeatPwdField=$("#repeatPassword",editor);var oldPassword=oldPwdField.val();var newPassword=newPwdField.val();var repeatPassword=repeatPwdField.val();oldPwdField.val("");newPwdField.val("");repeatPwdField.val("");$("#basicErrorMessage,#detailErrorMessage,#accountErrorMessage,#errorMessage,.validator",editor).text("");$("#firstName,#lastName,#emailAddress,#birthDate,#city,#state,#country,#oldPassword,#newPassword,#repeatPassword",editor).removeClass("invalid");var basicValid=true;var detailValid=true;var accountValid=true;var changePassword=false;var basicErrorBuilder=new StringBuilder();var detailErrorBuilder=new StringBuilder();var accountErrorBuilder=new StringBuilder();if(!Agnition.Zleek.Validate(firstName.length!==0,"First Name is required.","#firstName","#firstNameValidator",basicErrorBuilder)){basicValid=false;}
else if(!Agnition.Zleek.Validate(Agnition.Zleek.RegularExpressions.Name.test(firstName),"First Name must be a valid name.","#firstName","#firstNameValidator",basicErrorBuilder)){basicValid=false;}
if(!Agnition.Zleek.Validate(lastName.length!==0,"Last Name is required.","#lastName","#lastNameValidator",basicErrorBuilder)){basicValid=false;}
else if(!Agnition.Zleek.Validate(Agnition.Zleek.RegularExpressions.Name.test(lastName),"Last Name must be a valid name.","#lastName","#lastNameValidator",basicErrorBuilder)){basicValid=false;}
if(!Agnition.Zleek.Validate(emailAddress.length!==0,"E-mail Address is required.","#emailAddress","#emailAddressValidator",accountErrorBuilder)){accountValid=false;}
else if(!Agnition.Zleek.Validate(Agnition.Zleek.RegularExpressions.EmailAddress.test(emailAddress),"E-mail Address must be a valid e-mail address.","#emailAddress","#emailAddressValidator",accountErrorBuilder)){accountValid=false;}
if(birthDate.length===0){birthDate=null;}
else{birthDate=new Date(Date.parse(birthDate));}
if(newPassword.length!==0){if(!Agnition.Zleek.Validate(oldPassword.length!==0,"Old Password is required.","#oldPassword","#oldPasswordValidator",accountErrorBuilder)){accountValid=false;}
if(!Agnition.Zleek.Validate(newPassword==repeatPassword,"New Password and Repeat Password must match.","#newPassword,#repeatPassword","#newPasswordValidator,#repeatPasswordValidator",accountErrorBuilder)){accountValid=false;}
changePassword=true;}
var hasError=!(basicValid&&detailValid&&accountValid);if(!basicValid){$("#basicErrorMessage").css("display","block").html(basicErrorBuilder.toString());Agnition.Zleek.UserProfile.SelectBasic();}
else if(!detailValid){$("#detailErrorMessage").css("display","block").html(detailErrorBuilder.toString());Agnition.Zleek.UserProfile.SelectDetailed();}
else if(!accountValid){$("#accountErrorMessage").css("display","block").html(accountErrorBuilder.toString());Agnition.Zleek.UserProfile.SelectAccount();}
if(hasError){basicErrorBuilder.clear();detailErrorBuilder.clear();accountErrorBuilder.clear();return;}
Agnition.Zleek.UserProfile.UpdateProfileData(firstName,lastName,emailAddress,gender,birthDate,city,state,country,aboutMe);if(changePassword){Agnition.Zleek.UserProfile.ChangePassword(oldPassword,newPassword);}};Agnition.Zleek.UserProfile.UpdateProfileData=function(firstName,lastName,emailAddress,gender,birthDate,city,state,country,aboutMe){var user=Agnition.Zleek.UserProfile.ProfileData.User;var userData=Agnition.Zleek.Clone(user);userData.FirstName=firstName;userData.LastName=lastName;userData.EmailAddress=emailAddress;userData.Profile.Gender=gender;userData.Profile.DateOfBirth=Agnition.Serialization.SerializeDate(birthDate);userData.Profile.City=city;userData.Profile.State=state;userData.Profile.ZipCode=null;userData.Profile.Country=country;userData.Profile.Personal.AboutMe=aboutMe;userData.CreateDate=Agnition.Serialization.SerializeDate(user.CreateDate);userData.LastUpdated=Agnition.Serialization.SerializeDate(user.LastUpdated);userData.Summary=null;$("#successMessage").css("display","none");$("#errorMessage").css("display","none").text("");$("#loadingMessage").css("display","block").text("Saving profile...");var request=new Agnition.Zleek.UserProfile.EditProfileRequest(userData,editProfileUrl.replace(/\|USERNAME\|/,userData.UserName));request.Update(function(data,statusText){Agnition.Zleek.Web.UI.SetUserLogin(data);Agnition.Zleek.UserProfile.ProfileData.User=data;Agnition.Zleek.UserProfile.DisplayProfileSummary();Agnition.Zleek.UserProfile.LoadProfile();$("#loadingMessage").css("display","none").text("");$("#successMessage").css("display","block").focus();},function(request,statusText){$("#loadingMessage").css("display","none").text("");$("#successMessage").css("display","none");if((request.status===400)&&(request.statusText.length>0)){$("#errorMessage").css("display","block").text(request.statusText).focus();}
else{Agnition.Zleek.LogError(request.status+": "+request.statusText);$("#errorMessage").css("display","block").text("Error: Unable to save profile.").focus();}});};Agnition.Zleek.UserProfile.EditProfileRequest=function(userData,editProfileUrl){this.__class=true;this.Url=editProfileUrl;this.UserData=userData;this.Update=function(successCallback,errorCallback){var jsonRequest=new Agnition.Net.WebRequest();jsonRequest.PutJson(this.Url,this.UserData,null,successCallback,errorCallback,null);};};Agnition.Zleek.UserProfile.ChangePassword=function(oldPassword,newPassword){$("#successMessage").css("display","none");$("#errorMessage").css("display","none").text("");$("#loadingMessage").css("display","block").text("Changing password...");var userData=Agnition.Zleek.UserProfile.ProfileData.User;var request=new Agnition.Zleek.UserProfile.PasswordChangeRequest(userData.UserName,oldPassword,newPassword);request.ChangePassword(function(userData,statusText){$("#loadingMessage").css("display","none").text("");$("#successMessage").css("display","block").focus();},function(request,statusText){$("#loadingMessage").css("display","none").text("");$("#successMessage").css("display","none");if((request.status===400)&&(request.statusText.length>0)){$("#errorMessage").css("display","block").text(request.statusText).focus();}
else if(request.status===401){$("#oldPasswordValidator").text("*");$("#oldPassword").addClass("invalid");$("#errorMessage").css("display","block").text("* Invalid Password").focus();}
else{Agnition.Zleek.LogError(request.status+": "+request.statusText);$("#errorMessage").css("display","block").text("Error: Unable to change password.").focus();}});};Agnition.Zleek.UserProfile.PasswordChangeRequestData=function(userName,newPassword,oldPasswordHash){this.__class=true;this.UserName=userName;this.NewPassword=newPassword;this.OldPasswordHash=oldPasswordHash;};Agnition.Zleek.UserProfile.PasswordChangeRequest=function(userName,oldPassword,newPassword){this.__class=true;this.ServiceAddress=Agnition.Zleek.UserServiceAddress;this.OldPassword=oldPassword;this.PasswordChangeData=new Agnition.Zleek.UserProfile.PasswordChangeRequestData(userName,newPassword,null);this.ChangePassword=function(successCallback,errorCallback){var pwdData=this.PasswordChangeData;var svcAddress=this.ServiceAddress;var oldPwd=this.OldPassword;var getLoginSalt=function(successCallback){var jsonRequest=new Agnition.Net.WebRequest();var url=svcAddress+"/User/"+escape(pwdData.UserName)+"/LoginData";jsonRequest.GetJson(url,null,successCallback,errorCallback,null);};var performPasswordChange=function(data,statusText){pwdData.OldPasswordHash=SHA256(SHA256(pwdData.UserName.toLowerCase()+"|"+oldPwd)+"|"+data.LoginSalt);var jsonRequest=new Agnition.Net.WebRequest();var url=svcAddress+"/ChangePassword";jsonRequest.PostJson(url,pwdData,null,successCallback,errorCallback,null);};getLoginSalt(performPasswordChange,errorCallback);};};
Agnition.Zleek.UserProfile.InitializeDisplay=function(){Agnition.Zleek.UserProfile.DisplayProfileSummary();Agnition.Zleek.UserProfile.DisplayRecentAlbums();Agnition.Zleek.UserProfile.GetProfileFollowers(1);};$(document).ready(function(){Agnition.Zleek.UserProfile.ProfileData=loadedUserData;Agnition.Zleek.UserProfile.InitializeDisplay();$("#editProfileLink").bind("click",Agnition.Zleek.UserProfile.EditProfile);$("#userAboutMeMore").bind("click",Agnition.Zleek.UserProfile.ToggleAboutMe);$("#manageFollowLink").bind("click",Agnition.Zleek.UserProfile.ManageFollow);$("#requestFollowLink").bind("click",function(){Agnition.Zleek.UserProfile.RequestFollow(null,null,true);});$("#unfollowUserLink").bind("click",function(){Agnition.Zleek.UserProfile.Unfollow(null,null,true);});$("#blockUserLink").bind("click",function(){Agnition.Zleek.UserProfile.Block(null,null,true);});$("#unblockUserLink").bind("click",function(){Agnition.Zleek.UserProfile.Unblock(null,null,true);});$("#stopUserLink").bind("click",function(){Agnition.Zleek.UserProfile.RemoveFollow(null,null,true);});$("#allowUserLink").bind("click",function(){Agnition.Zleek.UserProfile.AcceptFollow(null,null,true);});$("#rejectUserLink").bind("click",function(){Agnition.Zleek.UserProfile.RejectFollow(null,null,true);});$("#profileFollowersLink").bind("click",Agnition.Zleek.UserProfile.GetProfileFollowers);$("#profileFollowingLink").bind("click",Agnition.Zleek.UserProfile.GetProfileFollowing);$("#followersLink").bind("click",Agnition.Zleek.UserProfile.GetFollowers);$("#followingLink").bind("click",Agnition.Zleek.UserProfile.GetFollowing);$("#blockedLink").bind("click",Agnition.Zleek.UserProfile.GetBlocked);$("#pendingFollowersLink").bind("click",Agnition.Zleek.UserProfile.GetPendingFollowers);$("#profileRecentAlbumsLink").bind("click",Agnition.Zleek.UserProfile.DisplayRecentAlbums);$("#profilePopularAlbumsLink").bind("click",Agnition.Zleek.UserProfile.DisplayPopularAlbums);$("#profileHotAlbumsLink").bind("click",Agnition.Zleek.UserProfile.DisplayHotAlbums);$("#profileFavoriteAlbumsLink").bind("click",Agnition.Zleek.UserProfile.DisplayFavoriteAlbums);$("#basicProfileLink").bind("click",Agnition.Zleek.UserProfile.SelectBasic);$("#detailedProfileLink").bind("click",Agnition.Zleek.UserProfile.SelectDetailed);$("#accountProfileLink").bind("click",Agnition.Zleek.UserProfile.SelectAccount);$("#avatarProfileLink").bind("click",Agnition.Zleek.UserProfile.SelectAvatar);$("#saveProfile").bind("click",Agnition.Zleek.UserProfile.SaveProfile);$("#firstName").focus(function(){$(this).filter(function(){return($(this).val().length===0)||(($(this).val()=="first")&&($(this).hasClass("watermark")));}).removeClass("watermark").val("");});$("#firstName").blur(function(){$(this).filter(function(){return $(this).val().length===0;}).addClass("watermark").val("first");});$("#lastName").focus(function(){$(this).filter(function(){return($(this).val().length===0)||(($(this).val()=="last")&&($(this).hasClass("watermark")));}).removeClass("watermark").val("");});$("#lastName").blur(function(){$(this).filter(function(){return $(this).val().length===0;}).addClass("watermark").val("last");});$("#city").focus(function(){$(this).filter(function(){return($(this).val().length===0)||(($(this).val()=="city")&&($(this).hasClass("watermark")));}).removeClass("watermark").val("");});$("#city").blur(function(){$(this).filter(function(){return $(this).val().length===0;}).addClass("watermark").val("city");});$("#stateText").focus(function(){$(this).filter(function(){return($(this).val().length===0)||(($(this).val()=="state")&&($(this).hasClass("watermark")));}).removeClass("watermark").val("");});$("#stateText").blur(function(){$(this).filter(function(){return $(this).val().length===0;}).addClass("watermark").val("state");});$("#country").change(function(){CountryState.PopulateState();});$("#birthDate").datepicker({constrainInput:true,changeMonth:true,changeYear:true,hideIfNoPrevNext:true,dateFormat:"m/d/yy",minDate:"-130y",maxDate:"-2y"});});