﻿var sPop = null;
var postSubmited = false;
var smdiv = new Array();

var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function ctlent(event, clickactive) {
	if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83) && $('postsubmit')) {
		if(in_array($('postsubmit').name, ['topicsubmit', 'replysubmit', 'editsubmit', 'pmsubmit']) && !validate($('postform'))) {
			return;
		}
		postSubmited = true;
		if(!isUndefined(clickactive) && clickactive) {
			$('postsubmit').click();
			$('postsubmit').disabled = true;
		} else {
			$('postsubmit').disabled = true;
			$('postform').submit();
		}
	}
}

function storeCaret(textEl){
	if(textEl.createTextRange){
		textEl.caretPos = document.selection.createRange().duplicate();
	}
}

function checkall(form, prefix, checkall) {
	var checkall = checkall ? checkall : 'chkall';
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
			e.checked = form.elements[checkall].checked;
		}
	}
}

function arraypop(a) {
	if(typeof a != 'object' || !a.length) {
		return null;
	} else {
		var response = a[a.length - 1];
		a.length--;
		return response;
	}
}

function arraypush(a, value) {
	a[a.length] = value;
	return a.length;
}


function findtags(parentobj, tag) {
	if(!isUndefined(parentobj.getElementsByTagName)) {
		return parentobj.getElementsByTagName(tag);
	} else if(parentobj.all && parentobj.all.tags) {
		return parentobj.all.tags(tag);
	} else {
		return null;
	}
}

function copycode(obj) {
	if(is_ie && obj.style.display != 'none') {
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
	}
}

function attachimg(obj, action, text) {
	if(action == 'load') {
		if(obj.width > screen.width * 0.7) {
			obj.resized = true;
			obj.width = screen.width * 0.7;
			obj.alt = text;
		}
		obj.onload = null;
	} else if(action == 'mouseover') {
		if(obj.resized) {
			obj.style.cursor = 'pointer';
		}
	} else if(action == 'click') {
		if(!obj.resized) {
			return false;
		} else {
			window.open(text);
		}
	}
}

function attachimginfo(obj, infoobj, show, event) {
	var left_offset = obj.offsetLeft;
	var top_offset = obj.offsetTop;
	var width_offset = obj.offsetWidth;
	var height_offset = obj.offsetHeight;
	while ((obj = obj.offsetParent) != null) {
		left_offset += obj.offsetLeft;
		top_offset += obj.offsetTop;
	}
	if(show) {
		$(infoobj).style.position = 'absolute';
		$(infoobj).style.left = left_offset + 3;
		$(infoobj).style.top = height_offset < 40 ? top_offset + height_offset : top_offset + 3;
		$(infoobj).style.display = '';
	} else {
		if(is_ie) {
			$(infoobj).style.display = 'none';
			return;
		} else {
			var mousex = document.body.scrollLeft + event.clientX;
			var mousey = document.body.scrollTop + event.clientY;
			if(mousex < left_offset || mousex > left_offset + width_offset || mousey < top_offset || mousey > top_offset + height_offset) {
				$(infoobj).style.display = 'none';
			}
		}
	}
}

function setcopy(text, alertmsg){
	if(is_ie) {
		clipboardData.setData('Text', text);
		alert(alertmsg);
	} else {
		prompt('Please press "Ctrl+C" to copy this text', text);
	}
}

function toggle_collapse(objname, unfolded) {
	if(isUndefined(unfolded)) {
		var unfolded = 1;
	}
	var obj = $(objname);
	var oldstatus = obj.style.display;
	var collapsed = getcookie('discuz_collapse');
	var cookie_start = collapsed ? collapsed.indexOf(objname) : -1;
	var cookie_end = cookie_start + objname.length + 1;

	obj.style.display = oldstatus == 'none' ? '' : 'none';
	collapsed = cookie_start != -1 && ((unfolded && oldstatus == 'none') || (!unfolded && oldstatus == '')) ?
			collapsed.substring(0, cookie_start) + collapsed.substring(cookie_end, collapsed.length) : (
			cookie_start == -1 && ((unfolded && oldstatus == '') || (!unfolded && oldstatus == 'none')) ?
			collapsed + objname + ' ' : collapsed);

	setcookie('discuz_collapse', collapsed, (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));

	if(img = $(objname + '_img')) {
		var img_regexp = new RegExp((oldstatus == 'none' ? '_yes' : '_no') + '\\.gif$');
		var img_re = oldstatus == 'none' ? '_no.gif' : '_yes.gif';
		img.src = img.src.replace(img_regexp, img_re);
	}
	if(symbol = $(objname + '_symbol')) {
		symbol.innerHTML = symbol.innerHTML == '+' ? '-' : '+';
	}
}

function imgzoom(o) {
	if(event.ctrlKey) {
		var zoom = parseInt(o.style.zoom, 10) || 100;
		zoom -= event.wheelDelta / 12;
		if(zoom > 0) {
			o.style.zoom = zoom + '%';
		}
		return false;
	} else {
		return true;
	}
}

function getcookie(name) {
	var cookie_start = document.cookie.indexOf(name);
	var cookie_end = document.cookie.indexOf(";", cookie_start);
	return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}

function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {
	var expires = new Date();
	expires.setTime(expires.getTime() + seconds);
	document.cookie = escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '/')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
}

function AddText(txt) {
	obj = $('postform').message;
	selection = document.selection;
	checkFocus();
	if(!isUndefined(obj.selectionStart)) {
		var opn = obj.selectionStart + 0;
		obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
	} else if(selection && selection.createRange) {
		var sel = selection.createRange();
		sel.text = txt;
		sel.moveStart('character', -strlen(txt));
	} else {
		obj.value += txt;
	}
}

function insertAtCaret(textEl, text){
	if(textEl.createTextRange && textEl.caretPos){
		var caretPos = textEl.caretPos;
		caretPos.text += caretPos.text.charAt(caretPos.text.length - 2)	== ' ' ? text +	' ' : text;
	} else if(textEl) {
		textEl.value +=	text;
	} else {
		textEl.value = text;
	}
}

function checkFocus() {
	var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('postform').message : editwin;
	if(!obj.hasfocus) {
		obj.focus();
	}
}

function setCaretAtEnd() {
	var obj = typeof wysiwyg == 'undefined' || !wysiwyg ? $('postform').message : editwin;
	if(typeof wysiwyg != 'undefined' && wysiwyg) {
		if(is_moz || is_opera) {

		} else {
			var sel = editdoc.selection.createRange();
			sel.moveStart('character', strlen(getEditorContents()));
			sel.select();
		}
	} else {
		if(obj.createTextRange)  {
			var sel = obj.createTextRange();
			sel.moveStart('character', strlen(obj.value));
			sel.collapse();
			sel.select();
		}
	}
}

function strlen(str) {
	return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}

function mb_strlen(str) {
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1;
	}
	return len;
}

function insertSmiley(smilieid) {
	checkFocus();
	var src = $('smilie_' + smilieid).src;
	var code = $('smilie_' + smilieid).pop;
	if(typeof wysiwyg != 'undefined' && wysiwyg && allowsmilies && (!$('smileyoff') || $('smileyoff').checked == false)) {
		if(is_moz) {
			applyFormat('InsertImage', false, src);
			var smilies = findtags(editdoc.body, 'img');
			for(var i = 0; i < smilies.length; i++) {
				if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) {
					smilies[i].setAttribute('smilieid', smilieid);
					smilies[i].setAttribute('border', "0");
				}
			}
		} else {
			insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
		}
	} else {
		code += ' ';
		AddText(code);
	}
}

function smileyMenu(ctrl) {
	ctrl.style.cursor = 'pointer';
	if(ctrl.alt) {
		ctrl.pop = ctrl.alt;
		ctrl.alt = '';
	}
	if(ctrl.title) {
		ctrl.lw = ctrl.title;
		ctrl.title = '';
	}
	if(!smdiv[ctrl.id]) {
		smdiv[ctrl.id] = document.createElement('div');
		smdiv[ctrl.id].id = ctrl.id + '_menu';
		smdiv[ctrl.id].style.display = 'none';
		smdiv[ctrl.id].className = 'popupmenu_popup';
		document.body.appendChild(smdiv[ctrl.id]);
	}
	smdiv[ctrl.id].innerHTML = '<table style="width: 60px;height: 60px;text-align: center;vertical-align: middle" class="altbg2"><tr><td><img src="' + ctrl.src + '" border="0" width="' + ctrl.lw + '" /></td></tr></table>';
	showMenu(ctrl.id, 0, 0, 1, 0);
}

function announcement() {
	$('announcement').innerHTML = '<marquee style="margin: 0px 8px" direction="right" scrollamount="2" scrolldelay="1" onMouseOver="this.stop();" onMouseOut="this.start();">' +
		$('announcement').innerHTML + '</marquee>';
	$('announcement').style.display = 'block';
}

function $(id) {
	return document.getElementById(id);
}

function in_array(needle, haystack) {
	if(typeof needle == 'string') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}
///-------
document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { direction:rtl; font-family: {FONT}; color:#333333; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 15px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=90)}");

document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");
function showPopupText(event) {
        if(event.srcElement) o = event.srcElement; else o = event.target;
        if(!o) {
                return;
        }
        MouseX = event.clientX;
        MouseY = event.clientY;
        if(o.alt != null && o.alt != '') {
                o.pop = o.alt;
                o.alt = '';
        }
        if(o.title != null && o.title != '') {
                o.pop = o.title;
                o.title = '';
        }
        if(o.pop != sPop) {
                sPop = o.pop;
                if(sPop == null || sPop == '') {
                        $('popLayer').style.visibility = "hidden";
                } else {
                        popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
                        $('popLayer').style.visibility = "visible";
                        showIt();
                }
        }
}

function showIt() {
        $('popLayer').className = popStyle;
        $('popLayer').innerHTML = sPop.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br>");
        var popWidth = $('popLayer').clientWidth;
        var popHeight = $('popLayer').clientHeight;
        var popLeftAdjust = MouseX + 12 + popWidth > document.body.clientWidth ? -popWidth - 24 : 0;
        var popTopAdjust = MouseY + 12 + popHeight > document.body.clientHeight ? -popHeight - 24 : 0;
        $('popLayer').style.left = (MouseX + 12 + document.body.scrollLeft + popLeftAdjust) + 'px';
        $('popLayer').style.top = (MouseY + 12 + document.body.scrollTop + popTopAdjust) + 'px';
}

if(!document.onmouseover) {
        document.onmouseover = function(e) {
                var event = e ? e : window.event;
                showPopupText(event);
        };
}
///------
function saveData(data, del) {
	if(!data && isUndefined(del)) {
		return;
	}
	if(typeof wysiwyg != 'undefined' && typeof editorid != 'undefined' && typeof bbinsert != 'undefined' && bbinsert && $(editorid + '_mode') && $(editorid + '_mode').value == 1) {
		data = html2bbcode(data);
	}
	if(is_ie) {
		try {
			var oXMLDoc = textobj.XMLDocument;
			var root = oXMLDoc.firstChild;
			if(root.childNodes.length > 0) {
				root.removeChild(root.firstChild);
			}
			var node = oXMLDoc.createNode(1, 'POST', '');
			var oTimeNow = new Date();
			oTimeNow.setHours(oTimeNow.getHours() + 24);
			textobj.expires = oTimeNow.toUTCString();
			node.setAttribute('message', data);
			oXMLDoc.documentElement.appendChild(node);
			textobj.save('Discuz!');
		} catch(e) {}
	} else if(window.sessionStorage) {
		try {
			sessionStorage.setItem('Discuz!', data);
		} catch(e) {}
	}
}

function loadData() {
	var message = '';
	if(is_ie) {
		try {
			textobj.load('Discuz!');
			var oXMLDoc = textobj.XMLDocument;
			var nodes = oXMLDoc.documentElement.childNodes;
			message = nodes.item(nodes.length - 1).getAttribute('message');
		} catch(e) {}
	} else if(window.sessionStorage) {
		try {
			message = sessionStorage.getItem('Discuz!');
		} catch(e) {}
	}

	if(in_array((message = trim(message)), ['', 'null', 'false', null, false])) {
		alert(lang['post_autosave_none']);
		return;
	}
	if((typeof wysiwyg == 'undefined' || !wysiwyg ? textobj.value : editdoc.body.innerHTML) == '' || confirm(lang['post_autosave_confirm'])) {
		if(typeof wysiwyg == 'undefined' || !wysiwyg) {
			textobj.value = message;
		} else {
			editdoc.body.innerHTML = bbcode2html(message);
		}
	}
}

function deleteData() {
	if(is_ie) {
		saveData('', 'delete');
	} else if(window.sessionStorage) {
		try {
			sessionStorage.removeItem('Discuz!');
		} catch(e) {}
	}
}

function updateseccode(width, height) {
	$('seccodeimage').innerHTML = '<img id="seccode" onclick="updateseccode(' + width + ', '+ height + ')" width="' + width + '" height="' + height + '" src="seccode.php?update=' + Math.random() + '" class="absmiddle" alt="" />';
}

function signature(obj) {
	if(obj.style.maxHeightIE != '') {
		var height = (obj.scrollHeight > parseInt(obj.style.maxHeightIE)) ? obj.style.maxHeightIE : obj.scrollHeight;
		if(obj.innerHTML.indexOf('<IMG ') == -1) {
			obj.style.maxHeightIE = '';
		}
		return height;
	}
}

function trim(str) {
	return (str + '').replace(/(\s+)$/g, '').replace(/^\s+/g, '');
}

function fetchCheckbox(cbn) {
	return $(cbn) && $(cbn).checked == true ? 1 : 0;
}

function parseurl(str, mode) {
	str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!]*)+\.(jpg|gif|png|bmp))/ig, mode == 'html' ? '$1<img src="$2" border="0">' : '$1[img]$2[/img]');
	str = str.replace(/([^>=\]"'\/]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k):\/\/)|www\.)([\w\-]+\.)*[\w\-\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
	str = str.replace(/([^\w>=\]:"']|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
	return str;
}

function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function addbookmark(url, site){
	if(is_ie) {
		window.external.addFavorite(url, site);
	} else {
		alert('Please press "Ctrl+D" to add bookmark');
	}
}

function doane(event) {
	e = event ? event : window.event ;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else {
		e.stopPropagation();
		e.preventDefault();
	}
}
////////////////////////////////////
var Kazak_OBJ="message,subject,subject,nickname,srchmem,nicknamenew,secanswer,location,dkreason,locationnew,bio,q,bionew,signature,signaturenew,signew,srchtxt,polloptions,reason,phrase,qt,newdescription,attachdesc[],attachdesc,newdescription,descriptionnew[1],descriptionnew[2],descriptionnew[3],message,descriptionnew[4],activitycity,activityclass,activityplace,activitycitynew,activityclassnew,activityplacenew,wysiwyg,sa,note,name,classnew,newclass,addname,title_obverse,title_reversed,content,title,keyword,attachdescnew,cstatusnew,answernew,transfermessage,to,newbuddy,newdescription,msgto,srchuname,username,answer,regmessage,settingsnew[bbname],settingsnew,settingsnew[closedreason],settingsnew[censoruser],settingsnew[welcomemsgtitle],settingsnew[welcomemsgtxt],settingsnew[bbrulestxt],settingsnew[threadsticky],settingsnew[pluginjsmenu],settingsnew[modreasons],settingsnew[extcredits],newquestion[],newanswer[],newcat,newforum,namenew,newmoderator,descriptionnew,rulesnew,newdescription,username,reason,newtitle,grouptitlenew,ranktitlenew,users,keywords,newfind,newreplace,addcensors,newsubject,newmessage,newdisplayorder,newurl,polloption,tousername,polloption[*]";
///////////////////////////////////
var u_imu=1;
var uyOBJs;
var ua = navigator.userAgent.toLowerCase();
var u_isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)) ;
var u_isGecko = (ua.indexOf("gecko") != -1 && ua.indexOf("safari") == -1) ;
var u_isMaxthon = ((ua.indexOf("msie") != -1) && (ua.indexOf("maxthon") != -1)) ;
uyOBJs=Kazak_OBJ.split(",");
window.onload=init_jaryan;
function init_jaryan(){
	var uInObjs=document.getElementsByTagName("input");
	var uTeObjs=document.getElementsByTagName("textarea");
	if(uInObjs.length>0){
	    for(var i=1;i<=uInObjs.length;i++){
	        if(uInObjs[i-1].type.toLowerCase()=="text"){
	            var uy_barmu=false;
	            for(var j=1;j<=uyOBJs.length;j++){
	                if((uInObjs[i-1].id==uyOBJs[j-1] || uInObjs[i-1].name==uyOBJs[j-1]) && uyOBJs[j-1]!=""){ 
	                    uy_barmu=true;break;}
	            }
	            if(uy_barmu) uInObjs[i-1].onkeypress=Harp;
	        }
	    }
	}
	
	if(uTeObjs.length>0){
	    for(var i=1;i<=uTeObjs.length;i++){
	        	var uy_barmu=false;
	            for(var j=1;j<=uyOBJs.length;j++){
	                if((uTeObjs[i-1].id==uyOBJs[j-1] || uTeObjs[i-1].name==uyOBJs[j-1]) && uyOBJs[j-1]!=""){ 
	                    uy_barmu=true;break;}
	            }
	        if(uy_barmu) uTeObjs[i-1].onkeypress=Harp;
	    }
	}
}
function Harp(e){
    var uObj=this;//event.srcElement;
    var uEvent,Kc;
    if(u_isGecko){
        uEvent=e;
        Kc=uEvent.which;
    }else{
        uEvent=window.event;
        Kc=uEvent.keyCode;
    }
    if(u_isMaxthon){//HOT keys for Maxthon
        if (Kc==2){u_imu=!u_imu;return false;} //Control+B
        else if(Kc==10){uObj.style.direction=uObj.style.direction!="ltr"?"ltr":"rtl"} //Control+J     
        else if(Kc==21){//Contrl+U
            var rng=document.selection.createRange();
            if(clipboardData.getData("Text")!=null)rng.text=ulTouy(clipboardData.getData("Text"));
            return false;
        }
    }
    else if(u_isIE){// HOT keys for IE
        if (Kc==20) {uObj.style.direction=(uObj.style.direction=="ltr")?"rtl":"ltr";return false;}//Cotrol+T
        else if(Kc==11) {u_imu=(u_imu)?0:1;return false;}//Control+K
        else if(Kc==21){//Control+U
            var rng=document.selection.createRange();
            if(clipboardData.getData("Text")!=null)rng.text=ulTouy(clipboardData.getData("Text"));
        }
    }
    else if(u_isGecko){
        if (uEvent.ctrlKey && (Kc==116 || Kc==84)) {uObj.style.direction=uObj.style.direction!="ltr"?"ltr":"rtl";return false;}// Control+T
        else if(uEvent.ctrlKey && (Kc==75 || Kc==107)) {u_imu=!u_imu;return false;}//Control+K
    }
    if (u_imu){
    if (Kc==63) Kc=1567;//("?")
    else if (Kc==44) Kc=1548;//(",")
    else if (Kc==59) Kc=1563;//(";")
    else if (Kc==40) Kc=0x29;//(")")
    else if (Kc==41) Kc=0x28;//("(")
    else if (Kc==91) Kc=0x5d;//("]")
    else if (Kc==93) Kc=0x5b;//("[")
    else if (Kc==123) Kc=0x7d;//("}")
    else if (Kc==125) Kc=0x7b;//("{")
    else if (Kc==62) Kc=0x00AB;//(">")
    else if (Kc==60) Kc=0x00BB;//("<")
    else if (Kc==81) Kc=0x00BB;//[Q=«]
    else if (Kc==87) Kc=0x00AB;//[W=»]
    else if (Kc==109 ||Kc==77) Kc=1605;//(m yaki M)
    else if (Kc==110 ||Kc==78) Kc=1606;//(n yaki N)
    else if (Kc==98  ||Kc==66) Kc=1576;//(b yaki B)
    else if (Kc==118 ||Kc==86) Kc=1734;//(v yaki V)
    else if (Kc==99  ||Kc==67) Kc=1593;//(c yaki C)
    else if (Kc==120 ||Kc==88) Kc=1588;//(x yaki X)
    else if (Kc==122 ||Kc==90) Kc=1586;//(z yaki Z)
    else if (Kc==97  ||Kc==65) Kc=1726;//(a yaki A)
    else if (Kc==115 ||Kc==83) Kc=1587;//(s yaki S)
    else if (Kc==100) Kc=1583;//("d")
    else if (Kc==68 ) Kc=1583;//("D")
    else if (Kc==102) Kc=1575;//("f")
    else if (Kc==70 ) Kc=1601;//("F")
    else if (Kc==103) Kc=1749;//("g")
    else if (Kc==71 ) Kc=1711;//("G")
    else if (Kc==104) Kc=1609;//("h")
    else if (Kc==72 ) Kc=1581;//("H")
    else if (Kc==106) Kc=1602;//("j")
    else if (Kc==74 ) Kc=1580;//("J")
    else if (Kc==107) Kc=1603;//("k")
    else if (Kc==75 ) Kc=1734;//("K")
    else if (Kc==108 ||Kc==76) Kc=1604;//(l uaki L)
    else if (Kc==113) Kc=1670;//(q)
    else if (Kc==119) Kc=1739;//(w)
    else if (Kc==101 ||Kc==69) Kc=1569;//("e yaki E")
    else if (Kc==114 ||Kc==82) Kc=1585;//(r yaki R)
    else if (Kc==116) Kc=1578;//("t")
    else if (Kc==84) Kc=1600;//("T")
    else if (Kc==121 ||Kc==89) Kc=1610;//(y yaki Y)
    else if (Kc==117 ||Kc==85) Kc=1735;//(u yaki U)
    else if (Kc==105 ||Kc==73) Kc=1709;//(i yaki I)
    else if (Kc==111 ||Kc==79) Kc=1608;//(o yaki O)
    else if (Kc==112 ||Kc==80) Kc=1662;//(p yaki P)
    else Kc=0;
    if (Kc!=0 && !uEvent.ctrlKey){
        if (u_isIE || u_isMaxthon){
            window.event.keyCode=Kc;    
        }
        else if(u_isGecko){
            var selstart = uObj.selectionStart ;
            var selend   = uObj.selectionEnd ;
            var insStr = String.fromCharCode ( Kc ) ;
            uObj.value = uObj.value.substring (0, selstart) + insStr + uObj.value.substr ( selend ) ;
            uObj.setSelectionRange(selstart + insStr.length, selstart + insStr.length );
            return false;            
        }
    }
  }
}
function ulTouy(uStr){
var uText=" " + uStr.toLowerCase();
uText=uText.replace(/ ё/g," يو");
//uText=uText.replace(/ Ё/g," يو");
uText=uText.replace(/ ө/g," ءو");
//uText=uText.replace(/ Ө/g," ءو");
uText=uText.replace(/ ү/g," ءۇ");
//uText=uText.replace(/ Ү/g," ءۇ");
uText=uText.replace(/ ц/g," تس");
//uText=uText.replace(/ Ц/g," تس");
uText=uText.replace(/ щ/g," شش");
//uText=uText.replace(/ Щ/g," شش");
uText=uText.replace(/ э/g," يو");
//uText=uText.replace(/ Ю/g," يو");
uText=uText.replace(/ я/g," يا");
//uText=uText.replace(/ Я/g," يا");
uText=uText.replace(/а/g,"ا");
uText=uText.replace(/А/g,"ا");
uText=uText.replace(/ә/g,"ا");
uText=uText.replace(/Ә/g,"ا");
uText=uText.replace(/б/g,"ب");
uText=uText.replace(/Б/g,"ب");
uText=uText.replace(/в/g,"ۆ");
uText=uText.replace(/В/g,"ۆ");
uText=uText.replace(/г/g,"گ");
uText=uText.replace(/Г/g,"گ");
uText=uText.replace(/д/g,"د");
uText=uText.replace(/Д/g,"د");
uText=uText.replace(/е/g,"ە");
uText=uText.replace(/Е/g,"ە");
uText=uText.replace(/ж/g,"ج");
uText=uText.replace(/Ж/g,"ج");
uText=uText.replace(/з/g,"ز");
uText=uText.replace(/З/g,"ز");
uText=uText.replace(/і/g,"ى");
uText=uText.replace(/І/g,"ى");
uText=uText.replace(/й/g,"ي");
uText=uText.replace(/Й/g,"ي");
uText=uText.replace(/и/g,"ي");
uText=uText.replace(/И/g,"ي");
uText=uText.replace(/к/g,"ك");
uText=uText.replace(/К/g,"ك");
uText=uText.replace(/л/g,"ل");
uText=uText.replace(/Л/g,"ل");
uText=uText.replace(/м/g,"م");
uText=uText.replace(/М/g,"م");
uText=uText.replace(/н/g,"ن");
uText=uText.replace(/Н/g,"ن");
uText=uText.replace(/о/g,"و");
uText=uText.replace(/О/g,"و");
uText=uText.replace(/п/g,"پ");
uText=uText.replace(/П/g,"پ");
uText=uText.replace(/р/g,"ر");
uText=uText.replace(/Р/g,"ر");
uText=uText.replace(/с/g,"س");
uText=uText.replace(/С/g,"س");
uText=uText.replace(/т/g,"ت");
uText=uText.replace(/Т/g,"ت");
uText=uText.replace(/ұ/g,"ۇ");
uText=uText.replace(/Ұ/g,"ۇ");
uText=uText.replace(/ф/g,"ف");
uText=uText.replace(/Ф/g,"ف");
uText=uText.replace(/һ/g,"ھ");
uText=uText.replace(/Һ/g,"ھ");
uText=uText.replace(/ч/g,"چ");
uText=uText.replace(/Ч/g,"چ");
uText=uText.replace(/ш/g,"ش");
uText=uText.replace(/Ш/g,"ش");
uText=uText.replace(/ь/g," ");
uText=uText.replace(/ъ/g," ");
uText=uText.replace(/ы/g,"ى");
uText=uText.replace(/Ы/g,"ى");
uText=uText.replace(/қ/g,"ق");
uText=uText.replace(/Қ/g,"ق");
uText=uText.replace(/у/g,"ۋ");
uText=uText.replace(/У/g,"ۋ");
uText=uText.replace(/х/g,"ح");
uText=uText.replace(/Х/g,"ح");
uText=uText.replace(/ғ/g,"ع");
uText=uText.replace(/Ғ/g,"ع");
uText=uText.replace(/ң/g,"ڭ");
uText=uText.replace(/Ң/g,"ڭ");
uText=uText.replace(/i/g,"ى");
//uText=uText.replace(/,/g,"،");
//uText=uText.replace(/?/g,"؟");
//uText=uText.replace(/;/g,"؛");
return uText;
}