	$(document).ready(function() {
		$("a.blank").attr("target", "_blank");
		$("input.cancel").click(function() {
			history.go(-1);
		});
		
		/* Reorder Pages */
		$(".pages_sortable tbody").sortable({
			helper: fixHelper,
			tolerance: 'pointer',
			stop: function(event, ui) { 
				var children = $(this).sortable('toArray');
				$.post('/admin/page/reorder/', { records: children });
				var ctr = 2;
				$(this).children().each(function() {
					$(this).removeClass('gry');
					if (ctr++ % 2) {
						$(this).addClass('gry');
					}
				});
			}
		}).disableSelection();
		
	});
	
	// Return a helper with preserved width of cells
	var fixHelper = function(e, ui) {
		ui.children().each(function() {
			$(this).width($(this).width());
		});
		return ui;
	};
	