<html>
<head>
<title>Layout Mistakes Fixer</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<script language="JavaScript">
<!--//
function getfixes()
{var obj = document.getElementById("text_field");
if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Opera") == -1)
{var sel = document.selection.createRange();
if (sel.text)
sel.text = fix_layout(sel.text);
else
obj.value = fix_layout(obj.value);
}
else
if (navigator.userAgent.indexOf("Gecko") != -1)
{if (obj.selectionStart != obj.selectionEnd)
{var before_sel = obj.value.substring(0, obj.selectionStart);
var string_sel = fix_layout(obj.value.substring(obj.selectionStart, obj.selectionEnd));
var after_sel = obj.value.substring(obj.selectionEnd, obj.value.length);
obj.value = before_sel + string_sel + after_sel;
}
else
obj.value = fix_layout(obj.value);
}
else
if (window.opera)
{obj.value = fix_layout(obj.value);
}
}
function fix_layout(txt)
{var layoutEn = new Array("`","q","w","e","r","t","y","u","i","o","p","\\[","\\]","a","s","d","f","g","h","j","k","l",";","'","z","x","c","v","b","n","m","\,","\\.","\\/","~","Q","W","E","R","T","Y","U","I","O","P","\\{","\\}","A","S","D","F","G","H","J","K","L",":","\"","Z","X","C","V","B","N","M","<",">","\\?","\\|","@","#","\\$","\\^","&");
var layoutRu = new Array("ё","й","ц","у","к","е","н","г","ш","щ","з","х","ъ","ф","ы","в","а","п","р","о","л","д","ж","э","я","ч","с","м","и","т","ь","б","ю",".","Ё","Й","Ц","У","К","Е","Н","Г","Ш","Щ","З","Х","Ъ","Ф","Ы","В","А","П","Р","О","Л","Д","Ж","Э","Я","Ч","С","М","И","Т","Ь","Б","Ю","\,","/","\"","№",";",":","?");
var re = "";
for(var i=0;i<layoutEn.length;i++)
{re = new RegExp(layoutEn[i], "g");
txt = txt.replace(re,layoutRu[i]);
}
return txt;
}
//-->
</script>
</head>
<body>
<input type="button" onclick="getfixes()" value="фикс раскладки">
<br><br>
<textarea id="text_field" cols="60" rows="7"></textarea>
</body>
</html>