	$(document).ready(function(){
		OEP.insert("#insertProduct", "#primaryContent", "/product/product_insert");
		OEP.insert("#insertPage", "#primaryContent", "/pages/pages_insert");
		OEP.insert("#insertSection", "#primaryContent", "/section/section_insert");
		OEP.insert("#insertCategory", "#primaryContent", "/section/category_insert");
		OEP.update(".updateProduct", "#primaryContent", "/product/product_update/", "product_id");	
		OEP.update(".updateSection", "#primaryContent", "/section/section_update/", "section_id");	
		OEP.update(".updateCategory", "#primaryContent", "/section/category_update/", "category_id");	
		OEP.update(".updatePage", "#primaryContent", "/pages/pages_update/", "page_id");	
	});


	var OEP = {}
	
	OEP.insert = function( hook, editarea, loadfile) {
		$(hook).click(function() {
			$(editarea).fadeOut("slow", function(){
				$(this).load(loadfile, function() { 
					$(editarea).fadeIn("fast"); 
					OEP.helpme();
				});
			})
		return false;
		});
	}
	
	OEP.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"); 
					OEP.helpme();
				});
			})
		return false;
		});
	}
	
	
	OEP.helpme = function() {
		
		$(".helpMe").find("span").toggle(function() {
			$(this).next("p").show("slow");
		}, function() {
			$(this).next("p").hide("slow");	
		});
		
	}
