tinyMCE.init({
	mode : "textareas",
	editor_selector : "richtext",
	theme : "advanced",
	width : "820",
	theme_advanced_resize_horizontal : false,
	plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",
	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true
});

$(document).ready(function() {

	$('#searchplaces').keyup(function() {
		var query = $('#searchplaces').val();
		$.post("/views/search", { query: query },
		  function(data){
		  	$('#search_results').html(data);
		  });
	});
	
	$('#views_table').tableDnD({
		onDrop: function(table, row) {
			$.ajax({
				type: "POST",
				url: "/manage/sort_views",
				data: $.tableDnD.serialize()
			});
		}
	});

	$('#menu_table').tableDnD({
		onDrop: function(table, row) {
			$.ajax({
				type: "POST",
				url: "/manage/sort_menu",
				data: $.tableDnD.serialize()
			});
		}
	});

	$('#sidebar_table').tableDnD({
		onDrop: function(table, row) {
			$.ajax({
				type: "POST",
				url: "/manage/sort_sidebar",
				data: $.tableDnD.serialize()
			});
		}
	});

	jQuery('ul.sf-menu').superfish();
	
	$.post("/ajax/tpl", { type:"header" }, function(data){ $('#header_right').html(data); });

});

function showMap(str) {
	alert(str);
}