// Copyright (c) 2009 Krionix, vladimir@3dnews.ru, http://forum.3DNews.ru
var d = document;

function norm(nn){
	if (nn<=9) return "0"+nn; else return nn;
}

function mygetdate(pdatetime){
	pdatetime=new Date(pdatetime*1000);
	document.write(norm(pdatetime.getDate())+"-"+norm(pdatetime.getMonth()+1)+"-"+pdatetime.getFullYear()+" <font id=time>"+norm(pdatetime.getHours())+":"+norm(pdatetime.getMinutes())+"</font>");
}

function showconfig (u_id) {
	window.open('/misc2.php?s=&do=getconfig&userid='+u_id, 'config', 'dependent=0,scrollbars=yes,width=400,height=500,left=200,top=50,channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,status=0,toolbar=0', 'launcher');
}

var t_table1 = "abvgdezijklmnoprstufhxy'`eqcCABVGDEZIJKLMNOPRSTUFHX'YEQ";
var w_table1 = "àáâãäåçèéêëìíîïðñòóôõõûüúýýöÖÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÕÜÛÝÝ";
var t_table2 = "yozhtschshyujuyajaYOZHTSCHSHYUYAYoZhTsChShYuYajoJoJOxhXhJuJa";
var w_table2 = "¸æö÷øþþÿÿ¨ÆÖ×ØÞß¨ÆÖ×ØÞß¸¨¨ùÙÞß";
var t_table3 = "SCHsch";
var w_table3 = "Ùù";


function translit(id) {
	var selection = vB_Editor[id].get_selection();
	if (selection === false)
	{
		return false;
	}
	else
	{
		str = new String(selection);
	}
	
//	if (vB_Editor[QR_EditorID].wysiwyg_mode) {

	var len = str.length;
	var new_str = "";
	pr = 0;
	for (i=0; i<len; i++) {
		if(i<=len-1) f=0;

		str_i = str.substr(i,1);
		if ((str_i == '<')||(str_i == '[')) pr = 1;
		if ((str_i == '>')||(str_i == ']')) {
			pr = 0;
			new_str += str_i;
			continue;
		}
		if (pr == 1) {
			new_str += str_i;
			continue;
		}

			for(j=0; j<w_table3.length; j++) 
				if(str.substr(i,3)==t_table3.substr(j*3,3)) {
					new_str+= w_table3.charAt(j);
					i+=2;f=1;
					break;
				}
			if (f) continue;
			for(j=0; j<w_table2.length; j++) 
				if(str.substr(i,2)==t_table2.substr(j*2,2)) {
					new_str+= w_table2.charAt(j);
					i+=1;f=1;
					break;
				}
			if (f) continue;
			var c = str.substr(i,1);
			var pos = t_table1.indexOf(c);
			if(pos<0) new_str += c;	else new_str += w_table1.charAt(pos);
	}
	vB_Editor[id].insert_text(new_str , (selection ? true : false));
	return false;
}

