function editThread(id) {

	if(document.getElementById('update_thread_'+id))
		return;

	var threadC = document.getElementById('threadC_'+id);
	if(!threadC)
		return;
	var content = threadC.innerHTML;
	threadC.innerHTML = '';
	var ta = document.createElement('textarea');
		ta.id = 'editThread_'+id;
		ta.setAttribute('oldContent', content);
		ta.value = content;
	var update = document.createElement('input');
		update.id = 'update_thread_'+id;
		update.setAttribute('type', 'button');
		update.value = 'Update';
		update.onclick = function() {
			var threadC = document.getElementById('threadC_'+this.id.split('_')[2]);
			var ta = document.getElementById('editThread_'+this.id.split('_')[2]);
			var params = new Array();
				params['id'] = this.id.split('_')[2];
				params['content'] = escape(FCKeditorAPI.GetInstance('editThread_'+params['id']).GetData());
			doRequest('http://www.collectionstation.com/tools/updateGroupThread', function(res) {
				if(!res.responseXML) {
					alert(res.responseText);
					return;
				}
				if(res.responseXML.documentElement.firstChild.nodeValue == 'Failure'){
					alert('Unfortunately we were unable to submit your changes!');
					threadC.innerHTML = ta.getAttribute('oldContent');
				} else {
					threadC.innerHTML = FCKeditorAPI.GetInstance('editThread_'+params['id']).GetData();
				}
			}, params);
		};
	var cancel = document.createElement('input');
		cancel.id = 'cancel_thread_'+id;
		cancel.setAttribute('type', 'button');
		cancel.value = 'Cancel';
		cancel.onclick = function() {
			var threadC = document.getElementById('threadC_'+this.id.split('_')[2]);
			var ta = document.getElementById('editThread_'+this.id.split('_')[2]);
			threadC.innerHTML = ta.getAttribute('oldContent');
		};

	threadC.appendChild(ta);
	threadC.appendChild(document.createElement('BR'));
	threadC.appendChild(update);
	threadC.appendChild(cancel);

	
	var oFCKeditor = new FCKeditor( 'editThread_'+id ) ;
	oFCKeditor.BasePath	= 'http://www.collectionstation.com/resources/javascript/fckeditor/' ;
	oFCKeditor.ToolbarSet = 'CS_Default';
	oFCKeditor.ReplaceTextarea() ;

}

function nl2br(text){
	return text.replace(/\n/g, "<br />");
}

function validate() {

	var sel = document.getElementById('threadOptions');
	if(sel.options[sel.selectedIndex].value == 'del')
		return confirm('Are you sure?');

	return true;

}
function load() {

	/*var menu_link = document.getElementById('threadoptions');
	var menu_content = document.getElementById('thread_options_menu');
		menu_content.setAttribute('inMenu', false);
		menu_link.onclick = function() {
			menu_content.style.display = 'block';
			menu_content.firstChild.focus();
		}
		menu_content.onblur = function() {
			this.style.display = 'none';
		}
		menu_content.onmouseout = function() {
			this.setAttribute('inMenu', true);
		}
		menu_content.onmouseover = function() {
			this.setAttribute('inMenu', false);
		}*/
	dropdowncontent.init("notificationMenuLink", "left-bottom", 500, 'click')

}

function initTinyMCE() {
	tinyMCE_GZ.init({
		plugins : 'style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,'+ 
			'searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras',
		themes : 'simple,advanced',
		languages : 'en',
		disk_cache : true,
		debug : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "mceEditor",
		theme : "advanced",
		plugins : "inlinepopups,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
		theme_advanced_buttons1 : "fontselect,fontsizeselect,forecolor,separator,emotions,separator,undo,redo,seperator,styleselect",
		theme_advanced_buttons2 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,indent,outdent,separator,link,unlink,separator,removeformat,cleanup",
		theme_advanced_buttons3 : "",
		theme_advanced_styles : "Quote=block_text",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		width : '371px',
		extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
	});
}