﻿/// <reference name="MicrosoftAjax.js" />

Type.registerNamespace('WIS.Web.Server');

WIS.Web.Server.AccountProfile = function() {
	this._contentTarget = $get("dynamictarget");

	this._accountShownFilter = 10; // contacts & following
	this._typesShownFilter = 0; // common
	this._currentTabFilter = null; // home

	this._allTabs = null;
	this._resultFilters = null;
	this._accountTypeFilters = null;

	this._account = 0;

	this._filterPopulation = 10; // AccountFilters.ContactsAndFollowing
	this._filterItemType = 0; // DocumentTypes.Common
	this._filterCategory = 0; // All Categories
}

WIS.Web.Server.AccountProfile.prototype = {

	StartCompareWizard: function() {
		this._invokeCall("StartCompareWizard", { "account": this._account }, this._onWizardCallComplete, "Services/AccountProfileOtherService.asmx");
	},

	StartCompareWizardAgree: function() {
		this._invokeCall("StartCompareWizardAgree", { "account": this._account }, this._onWizardCallComplete, "Services/AccountProfileOtherService.asmx");
	},

	StartCompareWizardDisagree: function() {
		this._invokeCall("StartCompareWizardDisagree", { "account": this._account }, this._onWizardCallComplete, "Services/AccountProfileOtherService.asmx");
	},

	StartCompareWizardTopic: function(topic, agree) {
		var methodName;
		var jsonData = { "account": this._account, "topic": topic };
		if (agree == null) {
			methodName = "StartCompareWizardTopic";
		}
		else {
			methodName = "StartCompareWizardTopicAgree";
			jsonData["agree"] = agree;
		}
		this._invokeCall(methodName, jsonData, this._onWizardCallComplete, "Services/AccountProfileOtherService.asmx");
	},

	StartCompareWizardTopicAll: function(topic) {
		this._invokeCall("StartCompareWizardTopicAll", { "account": this._account, "topic": topic }, this._onWizardCallComplete, "Services/AccountProfileOtherService.asmx");
	},

	_onWizardCallComplete: function(rawResult, userContext, methodName) {
		var result = eval("(" + rawResult + ")");
		window.location.href = result.redirectURL;
	},

	MoreMessages: function(source, start, target) {
		source.style.display = 'none';
		var jsonData = {
			"start": start,
			"target": target
		}
		this._invokeCall("MoreMessages", jsonData, this._onMoreMessagesComplete, "Services/AccountProfileSelfService.asmx");
	},

	_onMoreMessagesComplete: function(rawResult, userContext, methodName) {
		var result = eval("(" + rawResult + ")");
		$get(result.target).innerHTML += result.rawHTML;
	},

	DisableSetting: function(value, source) {
		var jsonData = {
			"setting": value
		}
		this._invokeCall("DisableSetting", jsonData, this._onDisableSettingComplete, "Services/AccountProfileSelfService.asmx");
		$get(source).style.display = 'none';
	},

	_onDisableSettingComplete: function(rawResult, userContext, methodName) { },

	RemoveAccountFollow: function(source, id) {
		source.style.display = 'none';
		this._invokeCall('RemoveAccountFollow', { "id": id }, this._onDisableSettingComplete, "Services/AccountProfileSelfService.asmx");
	},

	RemoveReferencedFollow: function(source, id) {
		source.style.display = 'none';
		this._invokeCall('RemoveReferencedFollow', { "id": id }, this._onDisableSettingComplete, "Services/AccountProfileSelfService.asmx");
	},

	SetFilterDefaults: function(filterPopulation, filterItemType) {
		this._filterPopulation = filterPopulation;
		this._filterItemType = filterItemType;
	},

	/*****
	****/

	SearchTopics: function(account, textBoxID, targetID) {
		var searchValue = $get(textBoxID).value;
		if (searchValue != '') {
			var jsonData = {
				"text": searchValue,
				"account": account,
				"textBoxID": textBoxID,
				"target": targetID
			}
			this._invokeCall("SearchExistingTopics", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
		}
	},

	ConfirmAccountTopic: function(account, textBoxID) {
		var proposeValue = $get(textBoxID).value;
		if (proposeValue != '') {
			var jsonData = {
				"account": account,
				"proposeText": proposeValue
			}
			this._invokeCall("ConfirmAccountTopic", jsonData, this._onConfirmAccountTopicComplete, "Services/AccountProfileService.asmx");
		}
	},

	_onConfirmAccountTopicComplete: function(rawResult, userContext, methodName) {
		var result = eval("(" + rawResult + ")");
		window.location.href = result.redirectPath;
	},

	ShowFullBio: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowFullBio", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowContacts: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowContacts", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowFollowers: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowFollowers", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowFollowingReferenced: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowFollowingReferenced", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowFollowingAccounts: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowFollowingAccounts", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowAffiliated: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowAffiliated", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	ShowAboutIssues: function(account, activity, popup) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup
		}
		this._invokeCall("ShowAboutIssues", jsonData, this._onShowSurprisePopupComplete, "Services/AccountProfileService.asmx");
	},

	_onShowSurprisePopupComplete: function(result, userContext, methodName) {
		var actualResult = eval("(" + result + ")");

		var activity = $get(actualResult.activity);
		var popup = $get(actualResult.popup);

		popup.innerHTML = actualResult.rawHTML;
		activity.style.display = 'none';
		popup.style.display = '';
	},

	ShowSettingsEdit: function(account, activity, popup, basePath) {
		var jsonData = {
			"account": account,
			"activity": activity,
			"popup": popup,
			"basePath": basePath
		}
		this._invokeCall("ShowSettingsEdit", jsonData, this._onSettingsEditComplete, "Services/AccountProfileService.asmx");
	},

	_onSettingsEditComplete: function(result, userContext, methodName) {
		var actualResult = eval("(" + result + ")");

		var activity = $get(actualResult.activity);
		var popup = $get(actualResult.popup);

		popup.innerHTML = actualResult.rawHTML;
		activity.style.display = 'none';
		popup.style.display = '';

		/*
		var div = $get(actualResult.editorID);
		var fck = new FCKeditor("myFCKeditor");
		fck.BasePath = actualResult.basePath;
		div.innerHTML = fck.CreateHtml();
		if (actualResult.existingBio != null && actualResult.existingBio != '') {
		//oEditor.SetHTML(actualResult.existingBio);
		}*/
		var fck = new FCKeditor(actualResult.editorID);
		fck.BasePath = actualResult.basePath;
		fck.Height = 250;
		fck.ToolbarSet = 'wIs';
		fck.ReplaceTextarea();
	},

	SaveSettings: function(displayTextID, bioTextID) {
		var oEditor = FCKeditorAPI.GetInstance(bioTextID);

		var jsonData = {
			"displayName": $get(displayTextID).value,
			"bio": oEditor.GetHTML()
		}

		this._invokeCall("SaveSettings", jsonData, this._onSaveSettingsComplete, "Services/AccountProfileService.asmx");
	},

	_onSaveSettingsComplete: function(result, userContext, methodName) {
		window.location.href = window.location.href;
	},

	/*******************************
	Tabs
	*******************************/

	SelectHomeTab: function(source, target, tabPrefix, tabCount) {

		this._resetInternalFilters();

		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"target": target
		}
		this._invokeCall("SelectHome", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	SelectProfileTab: function(account, source, target, tabPrefix, tabCount) {

		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"account": account,
			"target": target
		}
		this._invokeCall("SelectProfile", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	SelectProfileTabUnregistered: function(account, source, target, tabPrefix, tabCount) {

		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"account": account,
			"target": target
		}
		this._invokeCall("SelectProfileUnregistered", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	SelectNotificationsTab: function(source, target, tabPrefix, tabCount) {
		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"target": target
		}
		this._invokeCall("SelectNotifications", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	SelectMessagesTab: function(source, target, tabPrefix, tabCount) {
		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"target": target
		}
		this._invokeCall("SelectMessages", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	SelectMessagesTabOther: function(source, account, target, tabPrefix, tabCount) {
		this._resetTabCss(source, tabPrefix, tabCount);
		var jsonData = {
			"accountID": account,
			"cursorID": 0,
			"target": target
		}
		this._invokeCall("SelectChatDiscussion", jsonData, this._onTargetedPopulate, "Services/AccountProfileService.asmx");
	},

	_resetTabCss: function(source, tabPrefix, tabCount) {
		tabPrefix = "aphometabs_filtertabs";
		tabCount = 5;
		for (var i = 0; i < tabCount; i++) {
			var e = $get(tabPrefix + "_" + i);
			if (e) {
				e.setAttribute("class", "");
				e.setAttribute("className", "");
			}
		}
		source.setAttribute("class", "selected");
		source.setAttribute("className", "selected");
	},

	/*******************************
	More
	*******************************/

	ShowHomeMore: function(source, cursor, target) {
		source.style.display = 'none';
		var jsonData = {
			"cursor": cursor,
			"population": this._filterPopulation,
			"itemType": this._filterItemType,
			"target": target
		}
		this._invokeCall("ShowHomeMore", jsonData, this._onHandleTargetedAppendProfileRequestComplete, "Services/AccountProfileService.asmx");
	},

	ShowProfileMore: function(source, account, cursor, target) {
		source.style.display = 'none';
		var jsonData = {
			"cursor": cursor,
			"account": account,
			"population": this._filterPopulation,
			"itemType": this._filterItemType,
			"target": target
		}
		this._invokeCall("ShowProfileMore", jsonData, this._onHandleTargetedAppendProfileRequestComplete, "Services/AccountProfileService.asmx");
	},

	ShowProfileMoreUnregistered: function(source, cursor, target) {
		source.style.display = 'none';
		var jsonData = {
			"cursor": cursor,
			"population": this._filterPopulation,
			"itemType": this._filterItemType,
			"target": target
		}
		this._invokeCall("ShowProfileMoreUnregistered", jsonData, this._onHandleTargetedAppendProfileRequestComplete, "Services/AccountProfileService.asmx");
	},

	/*******************************
	Filters
	*******************************/

	/* ---- home ---- */

	SelectPopulationFilter: function(filterValue, topic, targetID, currentID, currentText, behaviorID) {
		this._filterPopulation = filterValue;
		this.RefreshFilteredContent(targetID, currentID, currentText, behaviorID);
	},

	SelectItemTypeFilter: function(filterValue, topic, targetID, currentID, currentText, behaviorID) {
		this._filterItemType = filterValue;
		this.RefreshFilteredContent(targetID, currentID, currentText, behaviorID);
	},

	RefreshFilteredContent: function(targetID, currentID, currentText, behaviorID) {
		$get(currentID).innerHTML = currentText;
		var jsonData = {
			"population": this._filterPopulation,
			"itemType": this._filterItemType,
			"target": targetID,
			"behaviorID": behaviorID
		}
		this._invokeCall("FilterHomeContent", jsonData, this._onDropDownSelectComplete, "Services/AccountProfileService.asmx");
	},

	/* ---- profile ---- */

	SelectProfileItemTypeFilter: function(account, filterValue, topic, targetID, currentID, currentText, behaviorID) {
		$get(currentID).innerHTML = currentText;
		var jsonData = {
			"account": account,
			"itemType": filterValue,
			"target": targetID,
			"behaviorID": behaviorID
		}
		this._invokeCall("FilterProfileContent", jsonData, this._onDropDownSelectComplete, "Services/AccountProfileService.asmx");
	},

	SelectProfileItemTypeFilterUnregistered: function(account, filterValue, topic, targetID, currentID, currentText, behaviorID) {
		$get(currentID).innerHTML = currentText;
		var jsonData = {
			"account": account,
			"itemType": filterValue,
			"target": targetID,
			"behaviorID": behaviorID
		}
		this._invokeCall("FilterProfileContentUnregistered", jsonData, this._onDropDownSelectComplete, "Services/AccountProfileService.asmx");
	},

	_onDropDownSelectComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		$get(actualResult.target).innerHTML = actualResult.rawHTML;
		$get(actualResult.behaviorID).PopupControlBehavior.hidePopup();
	},

	_onTargetedPopulate: function(result, userContext, methodName) {
		var actualResult = eval("(" + result + ")");
		if (actualResult.rawHTML != null && actualResult.rawHTML != "") {
			$get(actualResult.target).innerHTML = actualResult.rawHTML;
		}
	},

	_resetInternalFilters: function() {
		this._filterPopulation = 10; // AccountFilters.ContactsAndFollowing
		this._filterItemType = 12; // DocumentTypes.Common
		this._filterCategory = 0; // All Categories
	},

	/*********************************************************************
	**
	** Initialization
	**
	*********************************************************************/

	Initialize: function(account) {
		this._account = account;
	},

	/* rating popup */

	EnsureRatingPopup: function(source, account, popupID) {
		if (!source.PopupControlBehavior) {
			var contextKey = "{" +
	            "\"account\":" + account +
            "}";
			var behavior = $create(
                AjaxControlToolkit.PopupControlBehavior,
                {
                	PopupControlID: popupID,
                	dynamicControlID: popupID,
                	dynamicContextKey: contextKey,
                	dynamicServicePath: 'Services/AjaxService.asmx',
                	dynamicServiceMethod: 'GetRatingPopup'
                },
                null, null, source
            );
		}
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Tab Selection
	//
	//////////////////////////////////////////////////////////////////////

	ClickTab: function(tabFilter) {

		this._unselectAllTabs();

		tabFilter.get_element().setAttribute("class", "selected");

		this._currentTabFilter = tabFilter;
		this._accountShownFilter = 3; // contacts & following
		this._typesShownFilter = 12; // common

		this._invokeRefreshRequest();
	},

	GetCurrentTab: function() {
		if (this._currentTabFilter == null) {
			this._currentTabFilter = this._allTabs[0];
		}
		return this._currentTabFilter;
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Member Initialization
	//
	//////////////////////////////////////////////////////////////////////

	AddTypeFilter: function(typeFilter) {
		if (this._resultFilters == null) {
			this._resultFilters = [];
			this._resultFilters[0] = typeFilter;
		}
		else {
			this._resultFilters[this._resultFilters.length] = typeFilter;
		}
	},

	AddAccountTypeFilter: function(accountTypeFilter) {
		if (this._accountTypeFilters == null) {
			this._accountTypeFilters = [];
			this._accountTypeFilters[0] = accountTypeFilter;
		}
		else {
			this._accountTypeFilters[this._accountTypeFilters.length] = accountTypeFilter;
		}
	},

	AddTabFilter: function(tabFilter) {
		if (this._allTabs == null) {
			this._allTabs = [];
			this._allTabs[0] = tabFilter;
		}
		else {
			this._allTabs[this._allTabs.length] = tabFilter;
		}
	},

	/*********************************************************************
	**
	** Flashy Dropdown
	**
	**********************************************************************/

	HookupFlashyDropDown: function(currentID, dropDownID) {
		var extendElement = $get(currentID);
		var popupElement = $get(dropDownID);

		/*
		var popupBehavior = $create(
		AjaxControlToolkit.PopupBehavior,
		{
		parentElement : extendElement,
		y : 10
		},
		null, null, popupElement
		);
		*/

		var ddBehavior = $create(
            AjaxControlToolkit.DropDownBehavior,
            {
            	dropDownControl: popupElement
            },
            null, null, extendElement
        );
		//ddBehavior.set_dropDownControl($get(dropDownID));
		//ddBehavior.set_dropDownControl(dropDownID);
		//ddBehavior.get_dropDownControl().innerHTML = $get(dropDownID).innerHTML;
	},

	/*********************************************************************
	**
	** Notifications
	**
	*********************************************************************/

	MarkNotifyDone: function(notifyID, container) {
		var e = $get(container);

		var animation = null;
		animation = new $AA.FadeAnimation(e, 0.2, 25, $AA.FadeEffect.FadeOut, 0, 1, Sys.Browser.InternetExplorer == Sys.Browser.agent);
		animation.play();
		setTimeout("$get('" + container + "').style.display = 'none';", 1000 * 0.2);

		var jsonData = {
			"notifyID": notifyID
		}
		this._invokeCall("MarkNotifyDone", jsonData, null);
	},


	MoreNotifications: function(sourceElement, cursorID, targetID, done) {
		sourceElement.style.display = "none";
		var e = $get(targetID);
		var jsonData = {
			"cursorID": cursorID,
			"targetID": targetID,
			"done": done
		}
		this._invokeCall("MoreNotifications", jsonData, this._onHandleTargetedAppendProfileRequestComplete);
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Filter Event Handling
	//
	//////////////////////////////////////////////////////////////////////

	FilterShownAccounts: function(accountType) {
		for (var i = 0; i < this._accountTypeFilters.length; i++) {
			this._accountTypeFilters[i].get_element().setAttribute("class", "");
			this._accountTypeFilters[i].get_element().setAttribute("className", "");
		}
		accountType.get_element().setAttribute("class", "selected");
		accountType.get_element().setAttribute("className", "selected");

		this._accountShownFilter = accountType.get_AccountFilterType();
		this._invokeRefreshRequest();
	},

	FilterShownAccountsTargeted: function(accountType, targetID, currentID, currentText) {
		$get(currentID).innerHTML = currentText;
		this._accountShownFilter = accountType;
		this._invokeTargetedRefreshRequest(targetID);
	},

	FilterType: function(resultType) {
		for (var i = 0; i < this._resultFilters.length; i++) {
			this._resultFilters[i].get_element().setAttribute("class", "");
			this._resultFilters[i].get_element().setAttribute("className", "");
		}
		resultType.get_element().setAttribute("class", "selected");
		resultType.get_element().setAttribute("className", "selected");

		this._typesShownFilter = resultType.get_ResultType();
		this._invokeRefreshRequest();
	},

	FilterTypeTargeted: function(resultType, targetID, currentID, currentText) {
		$get(currentID).innerHTML = currentText;
		this._typesShownFilter = resultType;
		this._invokeTargetedRefreshRequest(targetID);
	},

	FilterNotifications: function(sender, notifyType, targetID, otherID) {
		sender.setAttribute("class", "selected");
		sender.setAttribute("className", "selected");

		otherElement = $get(otherID);
		otherElement.setAttribute("class", "");
		otherElement.setAttribute("className", "");

		var jsonData = {
			"notifyType": notifyType,
			"target": targetID
		}
		this._invokeCall("FilterNotifications", jsonData, this._onHandleTargetedProfileRequestComplete, "Services/AccountProfileService.asmx");
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Show More (Full)
	//
	//////////////////////////////////////////////////////////////////////

	ShowMore: function(span, stamp) {
		var jsonData = {
			"accountShownFilterValue": this._accountShownFilter,
			"typesShownFilterValue": this._typesShownFilter,
			"currentTabFilterValue": this.GetCurrentTab().get_TabValue(),
			"account": this._account,
			"stamp": stamp
		}
		this._invokeCall("HandleAccountProfileRequest", jsonData, this._onShowMoreComplete);
		span.style.display = 'none';
	},

	_onShowMoreComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		this._contentTarget.innerHTML += actualResult.rawHTML;
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Show More (Individual type)
	//
	//////////////////////////////////////////////////////////////////////

	ShowMoreTyped: function(account, type, stamp, count, target) {
		var jsonData = {
			"account": account,
			"type": type,
			"stamp": stamp,
			"count": count,
			"target": target
		}
		this._invokeCall("HandleAPShowMoreTyped", jsonData, this._onShowMoreTypedComplete);
	},

	_onShowMoreTypedComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		var targetElement = $get(actualResult.target);
		if (targetElement) {
			targetElement.innerHTML = actualResult.rawHTML;
		}
	},

	/******
	** wall related
	*******/

	AddToWall: function(account) {
		var e = $get("global_discussion_text");
		if (e.value != null && e.value != "") {
			var jsonData = {
				"accountID": account,
				"text": e.value
			};
			$("#global_discussion_text_button").attr("disabled", "disabled");
			this._invokeCall("AddChatDiscussionMessage", jsonData, this._onAddMessageToWallComplete);
		}
	},

	AddToDiscussionWall: function(account) {
		var e = $get("global_discussion_text");
		if (e.value != null && e.value != "") {
			var jsonData = {
				"accountID": account,
				"text": e.value
			};
			$("#global_discussion_text_button").attr("disabled", "disabled");
			this._invokeCall("AddAccountDiscussionMessage", jsonData, this._onAddMessageToWallComplete);
		}
	},

	_onAddMessageToWallComplete: function(result, userContext, methodName) {
		$("#global_discussion_text_button").attr("disabled", "");
		$("#global_discussion_text").val("");
		var actualResult = eval("(" + result + ")");
		if (actualResult.rawHTML != null && actualResult.rawHTML != "") {
			var existingHTML = $get("the_target_area").innerHTML;
			$get("the_target_area").innerHTML = actualResult.rawHTML + existingHTML;
		}
	},

	/*********************************************************************
	**
	** Targeted Refresh
	**
	*********************************************************************/

	_invokeTargetedRefreshRequest: function(targetElementID) {
		var jsonData = {
			"accountShownFilterValue": this._accountShownFilter,
			"typesShownFilterValue": this._typesShownFilter,
			"currentTabFilterValue": this.GetCurrentTab().get_TabValue(),
			"account": this._account,
			"stamp": new Date().getTime(),
			"target": targetElementID
		}
		this._invokeCall("HandleTargetedAccountProfileRequest", jsonData, this._onHandleTargetedProfileRequestComplete);
	},

	_onHandleTargetedProfileRequestComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		$get(actualResult.target).innerHTML = actualResult.rawHTML;
	},

	_onHandleTargetedAppendProfileRequestComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		$get(actualResult.target).innerHTML += actualResult.rawHTML;
	},

	//////////////////////////////////////////////////////////////////////
	//
	// Global Refresh
	//
	//////////////////////////////////////////////////////////////////////

	_invokeRefreshRequest: function() {
		var jsonData = {
			"accountShownFilterValue": this._accountShownFilter,
			"typesShownFilterValue": this._typesShownFilter,
			"currentTabFilterValue": this.GetCurrentTab().get_TabValue(),
			"account": this._account,
			"stamp": new Date().getTime()
		}
		this._invokeCall("HandleAccountProfileRequest", jsonData, this._onHandleProfileRequestComplete);
	},

	_onHandleProfileRequestComplete: function(result, userContext, methodName) {
		actualResult = eval("(" + result + ")");
		this._contentTarget.innerHTML = actualResult.rawHTML;
		if (this.GetCurrentTab().get_TabValue() == 0) {
			eval(actualResult.hookupScript);
		}
	},

	_unselectAllTabs: function() {
		for (var i = 0; i < this._allTabs.length; i++) {
			this._allTabs[i].get_element().setAttribute("class", "");
		}
	},

	_invokeCall: function(methodname, data, formDelegate, servicePath) {
		if (!servicePath) {
			servicePath = "Services/AjaxService.asmx";
		}
		Sys.Net.WebServiceProxy.invoke(
            servicePath, methodname, false, data,
            Function.createDelegate(this, formDelegate)
        );
	},

	dispose: function() {
	}
}

WIS.Web.Server.AccountProfile.registerClass('WIS.Web.Server.AccountProfile', null, Sys.IDisposable);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();