// JavaScript Document

function savePage(){
	
	var xHtmlBody;
	xHtmlBody = oPage.getXHTMLBody();
	document.forms[0].onsubmit();
	document.forms[0].submit();
	
}

function resizeEditorHeight(){	
	
	var userScreenY;
	userScreenY = document.body.clientHeight;	
	yOffset = "60"	
	newEditorHeight = userScreenY - yOffset + "px";
	oPage.height = newEditorHeight;	
	eval("idAreaoPage").style.height = oPage.height;

}
function make_tree_sortable(){	
	//This will eventually fix the bug of when a new page is created it isn't sortable unless refreshed.
	//More research to follow...
	Sortable.create("tree_nodes", {onUpdate:function(){new Ajax.Request('/pages/sort/167', {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Highlight("tree_nodes",{});}, parameters:Sortable.serialize("tree_nodes")})}})
}
function getNumPages(){
	var someNodeList = $('tree_nodes').getElementsByTagName('li');
	var nodes = $A(someNodeList);
	return nodes.length;
}

function node_added() {

	var node = $('tree_nodes').lastChild;
	//new Effect.Highlight(node, {duration:2, queue:'end'});
	new Effect.Highlight(node, {startcolor:'#fff6a6', endcolor:'#eeeeee', duration:2, queue:'end'})
	//new Effect.Pulsate(node, {duration:3, queue:'end'});
	Element.hide('spinner');
	$('form-submit-button').disabled = false;
	$('name').value = '';
	Field.focus('name');
	//make_tree_sortable();
	//Element.hide('no-pages-yet');
	//alert(getNumPages());
}
function node_loading() {
	$('form-submit-button').disabled = true;
	Element.show('spinner');
	
}
function file_uploading() {
	$('form-upload-button').disabled = true;
	Element.show('spinner2');	
}