//function requestPostUpdate() {
//	postsAJAX.sendRequest("/ajax/forum.rhtml", "p=posts&id="+topic_id);
//}

//function requestPostUpdateRev() {
//	postsAJAX.sendRequest("/ajax/forum.rhtml", "p=revposts&id="+topic_id);
//}

function updatePosts() {
	if (postsAJAX.http.readyState == 4) {
		reloadPage();
		//posts = document.getElementById("posts");
		//if (postsAJAX.http.responseText != "") {
			//posts.innerHTML = posts.innerHTML + postsAJAX.http.responseText;
			//FB.XFBML.Host.parseDomTree();
		//}
	}
}

//function show_newpost() {
//	newpost = document.getElementById("newpost");
//	newpost.style.display = "table-cell";
//}

//function hide_newpost() {
	//newpost = document.getElementById("newpost");
	//newpost.style.display = "none";
//}

//function post_blur(post) {
//	if (post.value == "") {
//		post.rows = 1;
//		var postbut = document.getElementById("postbut");
//		postbut.style.display = "none";
//	}
//}

//function post_focus(post) {
//	post.rows = 12;
//	var postbut = document.getElementById("postbut");
//	postbut.style.display = "inline";
//}

function submit_newpost() {
	//Use XMLHttpRequest to send post.
	var content = document.getElementById("postcontent");
	var topic_id = document.getElementById("topic_id");
	postsAJAX.sendRequest("/ajax/forum.rhtml", "p=newpost&id="+topic_id.value + "&content=" + content.value);
	//content.value = "";
	//content.rows = 1;
	//var postbut = document.getElementById("postbut");
	//postbut.style.display = "none";
	//hide_newpost();

	//var actionlinks = [{"text": "Read Post", "href": window.location.href}];
	//FB.Connect.streamPublish('Posted a reply on Warwick-Mountains',null,actionlinks);
}

function add_topic() {
	//Use XMLHttpRequest to send post.
	var content = document.getElementById("topictitle");
	var pcontent = document.getElementById("postcontent");
	var fid = document.getElementById("fid");
	var fbpub = document.getElementById("fbpublish");
	postsAJAX.sendRequest("/ajax/forum.rhtml", "p=newtopic&name="+content.value+"&fid="+fid.value+"&content="+pcontent.value);
	
	if (fbpub.checked) {
		var message = '';
		var attachment = {
			'name': content.value,
			'href': 'http://www.warwick-mountains.co.uk/index.rhtml?p=forum', 'caption': '{*actor*} posted on the Warwick Mountains forum.',
		};
		var action_links = [{ 'text': 'View Post', 'href': 'http://www.warwick-mountains.co.uk/index.rhtml?p=forum'}];
		FB.Connect.streamPublish(message, attachment, action_links, null, "Anything to add?", null, true, null);
	}
}

var postsAJAX = new WMAjaxObject(updatePosts);
