function replaceAll(strFind, strReplace, strSubject){
    index = strSubject.indexOf(strFind);
    
    while(index != -1){
        strSubject = strSubject.replace(strFind, strReplace);
        index = strSubject.indexOf(strFind);
    }
    
    return strSubject;
}



function translate(){

	var area = document.getElementById('msgArea');

	var oldString = area.value;

	

	ch1 = new Array( 'Я', 'я', 'Ю', 'ю', 'Э', 'э', 'Ч', 'ч', 'Ш', 'ш', 'Щ', 'щ',  'Й',  'й', 'Ж', 'ж', 'Ё', 'ё','А','а','Б','б','В','в','Г','г','Д','д','Е','е','З','з','И','и','К','к','Л','л','М','м','Н','н','О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Ц','ц','ъ','Ы','ы', 'ь');

	ch2 = new Array('JA','ja','JU','ju','JE','je','CH','ch','SH','sh','XH','xh','I\'','i\'','ZH','zh','JO','jo','A','a','B','b','V','v','G','g','D','d','E','e','Z','z','I','i','K','k','L','l','M','m','N','n','O','o','P','p','R','r','S','s','T','t','U','u','F','f','H','h','C','c','`','Y','y','\'');

	

	for(a=0;a<ch1.length;a++){

		oldString = replaceAll(ch2[a], ch1[a], oldString);

	}

	

	area.value = oldString;

}

function openAlphabet ()
{
	window.open('http://kollekcioner.lv/forum/translit_alphabet.php', 'TrnAlph', 'width=1280, height=100, status=no, scroolbars=yes, menubar=no, toolbar=no, location=no, resizable=no,');
}
