function do_access(t, p) {
	if(t !== '1') alert('Access Denied');
	else tb_show("Permissions", "./includes/admintools/access.php?t="+t+"&width=350&height=100&p="+encodeURIComponent(p));
}

function access_it(type, confir, page) {
	if(type !== '1') alert('Access Denied');
	else {
		var selection = document.getElementById('access_type').value;
		if(trim(selection) == '') alert('Please select something');
		else {
			tb_show('Permissions updated', './includes/admintools/do_access.php?width=350&height=100&type='+type+'&confir='+encodeURIComponent(confir)+'&access='+selection+'&page='+encodeURIComponent(page));	
			setTimeout("tb_remove()", 2000);
		}
	}
}

function refresh_page() {
	window.location.reload(false);	
}


//0.9 Admin Tools

//Menus:
function hide_menu(type, id, confir, ajax_loading, confirmed) {
	if(type !== '1') alert('Access Denied');
	else {
		if(confirm(confir)) {
			document.getElementById('menu_'+id).innerHTML = ajax_loading;
			doAjax('./includes/admintools/hidemenu.php', 'type='+type+'&id='+id, 'show_reply', 'post', '', 

'menu_'+id);
			alert(confirmed);
			document.getElementById('menu_'+id+'_header').style.display = 'none';
			setTimeout("hidemenuaccess('"+id+"')", 3000);
		}
	}
}
function show_menu(type, id, confir, ajax_loading, confirmed) {
	if(type !== '1') alert('Access Denied');
	else {
		if(confirm(confir)) {
			document.getElementById('menu_'+id).innerHTML = ajax_loading;
			doAjax('./includes/admintools/showmenu.php', 'type='+type+'&id='+id, 'show_reply', 'post', '', 

'menu_'+id);
			alert(confirmed);
			document.getElementById('menu_'+id+'_header').style.display = 'none';
			setTimeout("hidemenuaccess('"+id+"')", 3000);
		}
	}
}

function access_menu(type, id, ajax_loading, confirmed) {
	if(type !== '1') alert('Access Denied');
	else {
		document.getElementById('menu_'+id+'_preheader').innerHTML = ajax_loading;
		doAjax('./includes/admintools/viewmenu.php', 'type='+type+'&id='+id+'&confir='+confirmed, 'show_reply', 'post', 

'', 'menu_'+id+'_preheader');
	}
}

function hidemenuaccess(id) {
	document.getElementById('menu_'+id+'_preheader').innerHTML = '&nbsp;';
}

function domenuaccess(type, ajax_loading, confir, id) {
	if(type !== '1') alert('Access Denied');
	else {
		var selection = document.getElementById('access_type').value;
		if(trim(selection) == '') alert('ERROR: NO SELECTION VALUE');
		else {
			document.getElementById('menu_'+id+'_preheader').innerHTML = ajax_loading;
			doAjax('./includes/admintools/domenuaccess.php', 

'type='+type+'&id='+id+'&confir='+confir+'&access='+selection, 'show_reply', 'post', '', 'menu_'+id+'_preheader');
			setTimeout("hidemenuaccess('"+id+"')", 3000);
		}
	}
}

//Two functions are needed to avoid JS errors
function add_menu_1(type, side) {
	if(type !== '1') alert('Access Denied');
	else tb_show("Add Menu", "./includes/admintools/addmenutemp.php?type="+type+"&side="+side+"&width=300&height=250");
}

function add_menu_2(type, side) {
	if(type !== '1') alert('Access Denied');
	else tb_show("Add Menu", "./includes/admintools/addmenutemp.php?type="+type+"&side="+side+"&width=300&height=250");
}

function addmenu(type, side, confir, notice, needall, both) {
	if(type !== '1') alert('Access Denied');
	else {
		var name = document.getElementById('menuname_'+side).value;
		var file1 = document.getElementById('file_'+side).value;
		var file2 = document.getElementById('file2_'+side).value;
		if(name == '' || (file1 == 'noselect' && file2 == 'noselect')) alert(needall);
		else if(file1 !== 'noselect' && file2 !== 'noselect') alert(both);
		else {
			if(file1 == 'noselect') {
				var file = file2;
				var custom = 'true';
			} else {
				var file = file1;
				var custom = 'false';
			}
			doAjax('./includes/admintools/doaddmenu.php', 

'type='+type+'&side='+side+'&custom='+custom+'&confir='+confir+'&name='+name+'&file='+file, 'show_reply', 'post', '', 

'newmenus_'+side);
			alert(notice);
			tb_remove();
		}
	}
}

if(!self.setFocus) {
	function setFocus() {
		var text = document.getElementById('otatfpowered');
		if(text) {
			var inner = text.innerHTML;
			if(inner.toLowerCase() !== "<a href='http://www.1024cms.com' target='_blank'>powered by 1024 cms</a>" && inner.toLowerCase() !== '<a href="http://www.1024cms.com" target="_blank">powered by 1024 cms</a>' && inner.toLowerCase() !== '<a href="http://www.1024cms.com" target=_blank>powered by 1024 cms</a>') {
				alert('Copywrite notice changed. This system runs on 1024 CMS.\n\n http://www.1024cms.com');
				alert(inner.toLowerCase());
			}
		} else alert('Copywrite notice removed. This system runs on 1024 CMS.\n\n http://www.1024cms.com');
	}
}