
var InputfieldPageName = {
	sanitize: function(name) {

		// replace leading and trailing whitespace 
		name = jQuery.trim(name);

		var srch;
		for(srch in config.InputfieldPageName.replacements) {
			var repl = config.InputfieldPageName.replacements[srch];
			if(name.indexOf(srch) > -1) {
				var re = new RegExp(srch, 'g'); 
				name = name.replace(re, repl); 
			}
		}
	
		name = name.toLowerCase();  

		// replace invalid with dash
		name = name.replace(/[^-_.a-z0-9 ]/g, '-');
	
		// convert whitespace to dash
		name = name.replace(/\s+/g, '-') 
	
		// convert multiple dashes or dots to single
		name = name.replace(/--+/g, '-'); 
	
		// convert multiple dots to single
		name = name.replace(/\.\.+/g, '.'); 
	
		// remove ugly combinations next to each other
		name = name.replace(/(\.-|-\.)/g, '-'); 
	
		// remove leading or trailing dashes, underscores and dots
		name = name.replace(/(^[-_.]+|[-_.]+$)/g, ''); 

		// make sure it's not too long
		if(name.length > 128) name = name.substring(0, 128); 
	
		return name;
	},

	updatePreview: function($t, value) {
		$t.parent('p').siblings(".InputfieldPageNameURL").children("strong").text((value.length > 0 ? value + '/' : ''))
	}
};

jQuery(document).ready(function($) {

	$(".InputfieldPageName").find("input[type=text]").keyup(function() {
		var value = InputfieldPageName.sanitize($(this).val());
		InputfieldPageName.updatePreview($(this), value); 
		
	}).blur(function() {
		var value = InputfieldPageName.sanitize($(this).val());
		$(this).val(value); 
		InputfieldPageName.updatePreview($(this), value); 
	}).keyup();
}); 

@@ -123,16 +123,47 @@
 m(name);
+%0A%09%09name = name.toLowerCase();  
 %0A%0A%09%09var 
@@ -402,41 +402,8 @@
 %0A%09%09%7D
-%0A%09%0A%09%09name = name.toLowerCase();  
 %0A%0A%09%09

Update InputfieldPageName to fix issue #79 regarding replacement of uppercase cyrillic chars