var GMTDHRADMIN = {};

$(document).ready(function() {
	GMTDHRADMIN.helpme();
GMTDHRADMIN.update(".SWFieldset", "#primaryContent", "/editpages/editpage/", "pid");
	GMTDHRADMIN.showAdminMenu();
});

GMTDHRADMIN.create = function( hook, editarea, loadfile) {
	$(hook).click(function() {
		$(editarea).fadeOut("slow", function(){
			$(this).load(loadfile, function() { 
				$(editarea).fadeIn("fast"); 
				GMTDHRADMIN.helpme();
			});
		});
	return false;
	});
};

GMTDHRADMIN.update = function(hook, editarea, loadfile, updatekey ) {
	$(hook).click(function() { 
		var updateItem = $(this).attr("id").split("-")[1];
		$(editarea).fadeOut("slow", function(){
			$(this).load(loadfile+updateItem, { updatekey: updateItem  } , function() { 
				$(editarea).fadeIn("fast"); 
				GMTDHRADMIN.helpme();
			});
		});
	return false;
	});
};

GMTDHRADMIN.helpme = function() {
	
	$(".helpMe").find("span").toggle(function() {
		$(this).next("p").show("slow");
	}, function() {
		$(this).next("p").hide("slow");	
	});
	
};

GMTDHRADMIN.showAdminMenu = function() {
	$("#editorMenu>h3").toggle(function() {
		$("#adminLinks").slideDown("slow");
	}, function(){
		$("#adminLinks").slideUp("slow");
	});
};