(function ($) {
	$.extend({
		ogParent: function (parent, child) {
			var theParent = $(parent);
			var theChild = $(child);

			var childOptions = {};
			theChild.children('optgroup').each(function () {
				var optgroup = $(this);
				childOptions[optgroup.attr('label')] = optgroup.children('option');
			});

			theParent.change(function () {
				theChild.children().remove();
                var blankOpt = $('<option></option>');
				theChild.append(blankOpt);
				theChild.append(childOptions[$(this).find(':selected').text()]);
                blankOpt.attr('selected', 'selected');
			});

			theParent.change();
		}
	});
})(jQuery);

