	function movePage(pageId, way) {

		var pageLi = $('page' + pageId).parentNode;
		var otherLi = false;
		
		var list = pageLi.parentNode;
		var allElements = list.getElementsByTagName("li");
		for (var i = 0; i < allElements.length; i++) {
			element = allElements[i];
			if (element == pageLi) {
				if ((way == "up") && (i != 0))
					otherLi = allElements[i - 1];
				else if ((way == "down") && (i != allElements.length - 1))
					otherLi = allElements[i + 1];
			}
		}
		
		if (otherLi != false) {
			var otherId = otherLi.getElementsByTagName("input")[0].value;
		
			var ajaxurl = "jscript/managepages/managepages.php?action=move&way=" + way + "&id=" + pageId + "&otherId=" + otherId;
			var ajax = new Request({url: ajaxurl, method: "get"});
			ajax.send();
			
			if ((!window.attachEvent) || (window.XMLHttpRequest)) {
				if ((pageLi.getSize()) && (otherLi.getSize())) {
					var pageLiSize = pageLi.getSize();
					var otherLiSize = otherLi.getSize();
					var pageLiHeight = parseInt(pageLiSize.y) + (parseInt(pageLi.getStyle("marginTop").replace("px", "")) / 2) + (parseInt(pageLi.getStyle("marginBottom").replace("px", "")) / 2);
					var otherLiHeight = parseInt(otherLiSize.y) + (parseInt(otherLi.getStyle("marginTop").replace("px", "")) / 2) + (parseInt(otherLi.getStyle("marginBottom").replace("px", "")) / 2);
								
					if (way == "up") {
						var pageLiTop = otherLiHeight * (-1);
						var otherLiTop = pageLiHeight;
					} else {
						var pageLiTop = otherLiHeight;
						var otherLiTop = pageLiHeight * (-1);
					}
				
					if ((pageLiTop) && (otherLiTop)) {
						var pageFx = new Fx.Morph(pageLi, {duration: 1000});
						var otherFx = new Fx.Morph(otherLi, {duration: 1200});
					
						pageFx.start({
							'top': pageLiTop
						});
					
						otherFx.start({
							'top': otherLiTop
						}).chain(function() {
							switchPageLiContent(pageLi, otherLi);
						});
					} else {
						switchPageLiContent(pageLi, otherLi);
					}
				} else {
					switchPageLiContent(pageLi, otherLi);
				}
			} else {
				switchPageLiContent(pageLi, otherLi);
			}
		}
	}
	
	function switchPageLiContent(pageLi, otherLi) {
		pageLi.style.top = "0px";
		otherLi.style.top = "0px";
		
		pageLi.appendChild(otherLi.getElementsByTagName("div")[0]);
		otherLi.appendChild(pageLi.getElementsByTagName("div")[0]);
	}
	
	function deletePage(pageId) {
		if (confirm(lang_pages_confirmdelete)) {
			var ajaxurl = "jscript/managepages/managepages.php?action=delete&id=" + pageId;
			var ajax = new Request({url: ajaxurl, method: "get"});
			ajax.send();
		
			var pageLi = $('page' + pageId).parentNode;
			var pageFx = new Fx.Morph(pageLi, {duration: 1200});
			pageFx.start({
				'opacity': 0
			}).chain(function() {
				pageLi.parentNode.removeChild(pageLi);
			});
		}
	}