function loadMySharesComponents() {
	if (!AfianHandler.components['MySharesBaseMenu'].loaded) {
		loadComponentData('MySharesBaseMenu');
	}
	if (!AfianHandler.components['MySharesContextMenus'].loaded) {
		loadComponentData('MySharesContextMenus');
	}
}

function openMyShares() {
	loadMySharesComponents();
	focusOpened = false;
		for (var i = 0 ; i < AfianHandler.allTabs.length; i++) {
			if (AfianHandler.allTabs[i] != undefined) {
				if (AfianHandler.allTabs[i].section == 'myshares') {
					AfianHandler.allTabs[i].load();
					focusOpened = true;
					break;
				}
			}
		}
	if (!focusOpened) {
		MyShares = new Afian_Tab(AfianMessages['My Shares'], 'myshares@afian', 'images/icons/filetypes/small/folder-shared.gif');
		MyShares.viewMode = 'list';
		MyShares.section = 'myshares';
		MyShares.onload = MySharesOnLoad;
		MyShares.onselect = MySharesOnSelect;
		MyShares.baseMenu = 'MySharesBaseMenu';
		MyShares.detailHTML = AfianHandler.MySharesDetailsTemplate;
		MyShares.load();
		MyShares.MyShares_Browse();
	}
}

function MySharesOnSelect() {
	showfuncname = showMenu;
	hidefuncname = hideMenu;
if (AfianHandler.components['MySharesContextMenus'].loaded) {
	if (this.countSelected == 0) {
		hidefuncname('afian_myshares_context_dir');
		hidefuncname('afian_myshares_context_multiple');
	} else if (this.countSelected == 1) {
		showfuncname('afian_myshares_context_dir');
		hidefuncname('afian_myshares_context_multiple');
	} else {
		showfuncname('afian_myshares_context_multiple');
		hidefuncname('afian_myshares_context_dir');
	}
}
	MySharesStatusBar();
}

function MySharesOnLoad() {
	loadMySharesComponents();
	if (AfianHandler.activeTab == this) {
	AfianHandler.showBaseMenu('MySharesBaseMenu');
	AfianHandler.hideBaseMenu('MyFilesBaseMenu');
	AfianHandler.hideBaseMenu('TrashBaseMenu');
	AfianHandler.hideBaseMenu('SearchBaseMenu');
	AfianHandler.hideBaseMenu('BShareBaseMenu');
	AfianHandler.hideBaseMenu('BrowseZipBaseMenu');

	
		/*admin stuff*/
	AfianHandler.hideBaseMenu('AdmGroupsBaseMenu');
	AfianHandler.hideBaseMenu('AdmUsersBaseMenu');
	AfianHandler.hideBaseMenu('AdmLogsBaseMenu');
	
	if (activeMenu) {
		hideMenu(activeMenu);
	}
	AfianHandler.titleBar.innerHTML = this.title;
	MySharesStatusBar();
	toggleTreeByPath(this.basepath);
	}
}

function MySharesStatusBar() {
	tb = AfianHandler.activeTab;
	if (tb.countSelected == 0) {
		if (tb.countAll == 0) {
			if (tb.browsed) {
			AfianHandler.statusBar.innerHTML = AfianMessages['No shared folder'];
			} else {
			AfianHandler.statusBar.innerHTML = AfianMessages['Searching for shared folders...'];
			}
		} else {
			if (tb.countAll == 1) {
				AfianHandler.statusBar.innerHTML =  AfianMessages['One shared folder (%1)'].replace('%1', formatFileSize(tb.totalSize));
			} else {
				AfianHandler.statusBar.innerHTML =  AfianMessages['%1 shared folders (%2)'].replace('%1', tb.countAll).replace('%2', formatFileSize(tb.totalSize));
			}
		}
	} else if (tb.countSelected == 1) {
		AfianHandler.statusBar.innerHTML =  AfianMessages['One shared folder selected (%1)'].replace('%1', formatFileSize(tb.selSize));
	} else {
		AfianHandler.statusBar.innerHTML =  AfianMessages['%1 shared folders selected (%2)'].replace('%1', tb.countSelected).replace('%2', formatFileSize(tb.selSize));
	}
}


function MySharesOptions() {
	selected = AfianHandler.activeTab.selectedItem();
	popup(baseURL+'?file=share&path='+selected.extra+'&object='+selected.icon_title, 'share', '360', '514', 'no');
}

function MySharesUnshare() {
	tb = AfianHandler.activeTab;
	document.hiddenForm.action='?file=mysharesacting&act=unshare';
	document.hiddenForm.action += '&path='+tb.basepath;
	document.hiddenForm.action += '&tabid='+tb.id;
	document.hiddenForm.itemlist.value = '';
	fillHiddenFormItemList();
	document.hiddenForm.target = 'hifrm_'+tb.id;
	if (document.hiddenForm.itemlist.value.length > 1) {
	document.hiddenForm.submit();
	tb.unselectAll();
	tb.showHourGlass();
	}
}

function MySharesGoTo() {
	tb = AfianHandler.activeTab;
	selected = tb.selectedItem();
	path = selected.extra;
	title = AfianMessages['Locating folder..'];
	newTab = new Afian_Tab(title, path);
	newTab.section = 'myfiles';
	newTab.viewMode = 'icons';
	newTab.onload = MyFilesOnLoad;
	newTab.detailHTML = AfianHandler.MyFilesDetailsTemplate;
	newTab.load();
	newTab.MyFiles_Browse(encodeURIComponent(path));
	newTab.onselect = MyFilesOnSelect;
	tb.showHourGlass();
}