/* Выбрать в select-е одни option по value */
function select_choice(name, value)
{
	var sel = document.getElementById(name);
	
	/* Очистка */
	for(var i=0;i<sel.options.length;i++) 
	{sel.options[i].selected = false;}
			
	/* Выбрать */
	for(var i=0;i<sel.options.length;i++) 
	{
		if(sel.options[i].value == value)
		{sel.options[i].selected = true;}
	}			
}

/* Создание слоев и элементов */

		/* Создание слоя */
		function create_div(parent_id, id, class_n)
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement('div');
    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('name', id );    		
    		x_dp.setAttribute('class', class_n );
    		x_parent.appendChild(x_dp);			
			return true;
		}	

		/* Создание span */
		function create_span(parent_id, id, class_n)
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement('span');
    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('name', id );       		
    		x_dp.setAttribute('class', class_n );
    		x_parent.appendChild(x_dp);			
			return true;
		}	

		/* Создание ссылки */
		function create_a(parent_id, id, href, class_n, onclick_n)
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement('a');
    		x_dp.setAttribute('href', href );
    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('class', class_n );
    		
    		x_dp.setAttribute('onclick', onclick_n );    
    		
    		x_parent.appendChild(x_dp);			
			return true;
		}
		
		/* Создание ссылки */
		function create_radio(parent_id, id, class_n, onclick_n)
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement('input');
    		
            x_dp.type = "radio";

    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('name', 'radiocover_'+id );    		            
	   		x_dp.setAttribute('class', class_n );
    		
    		x_dp.setAttribute('onclick', onclick_n );    
    		
    		x_parent.appendChild(x_dp);			
			return true;
		}			
		
		/* Создание img */
		function create_img(parent_id, id, src, class_n )
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement('img');
    		x_dp.setAttribute('src', src );
    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('class', class_n );
    		
    		x_parent.appendChild(x_dp);			
			return true;
		}	
		
		/* Создание произвольного элемента */
		function create_tag(parent_id, tag, id, class_n)
		{
			var x_parent = document.getElementById(parent_id);
    		var x_dp = document.createElement(tag);
    		x_dp.setAttribute('id', id );
    		x_dp.setAttribute('name', id );    		
    		x_dp.setAttribute('class', class_n );
    		x_parent.appendChild(x_dp);			
			return true;
		}		

		
/* Транслит */
var abc1 = new Array();
abc1[' '] = '_';
abc1['а'] = 'a';
abc1['б'] = 'b';
abc1['в'] = 'v';
abc1['г'] = 'g';
abc1['д'] = 'd';
abc1['е'] = 'e';
abc1['ё'] = 'jo';
abc1['ж'] = 'zh';
abc1['з'] = 'z';
abc1['и'] = 'i';
abc1['й'] = 'j';
abc1['к'] = 'k';
abc1['л'] = 'l';
abc1['м'] = 'm';
abc1['н'] = 'n';
abc1['о'] = 'o';
abc1['п'] = 'p';
abc1['р'] = 'r';
abc1['с'] = 's';
abc1['т'] = 't';
abc1['у'] = 'u';
abc1['ф'] = 'f';
abc1['х'] = 'h';
abc1['ц'] = 'c';
abc1['ч'] = 'ch';
abc1['ш'] = 'sh';
abc1['щ'] = 'w';
abc1['ъ'] = '';
abc1['ы'] = 'y';
abc1['ь'] = '';
abc1['э'] = 'je';
abc1['ю'] = 'ju';
abc1['я'] = 'ja';
abc1['А'] = 'A';
abc1['Б'] = 'B';
abc1['В'] = 'V';
abc1['Г'] = 'G';
abc1['Д'] = 'D';
abc1['Е'] = 'E';
abc1['Ё'] = 'Jo';
abc1['Ж'] = 'Zh';
abc1['З'] = 'Z';
abc1['И'] = 'I';
abc1['Й'] = 'J';
abc1['К'] = 'K';
abc1['Л'] = 'L';
abc1['М'] = 'M';
abc1['Н'] = 'N';
abc1['О'] = 'O';
abc1['П'] = 'P';
abc1['Р'] = 'R';
abc1['С'] = 'S';
abc1['Т'] = 'T';
abc1['У'] = 'U';
abc1['Ф'] = 'F';
abc1['Х'] = 'H';
abc1['Ц'] = 'C';
abc1['Ч'] = 'Ch';
abc1['Ш'] = 'Sh';
abc1['Щ'] = 'W';
abc1['Ъ'] = '';
abc1['Ы'] = 'Y';
abc1['Ь'] = '';
abc1['Э'] = 'Je';
abc1['Ю'] = 'Ju';
abc1['Я'] = 'Ja';
abc1['.'] = '_';

function translatesymbol(symb)
{
	var reg = /^[0-9a-z_]+$/i;
	return ((abc1[symb] && abc1[symb] != 'undefined')?abc1[symb]:(reg.test(symb) ? symb : ''));
}

function doTranslate(In, Out) 
{
	var limitTranslate = 126;
	var textar = document.getElementById(In).value;
	textar = textar.toLowerCase();
	//alert(textar);
	var ret = '';
	limit = limitTranslate > textar.length ? textar.length : limitTranslate;
	if (textar) 
	{
		for (i=0; i<limit; i++) 
		{
			ret  += translatesymbol(textar.charAt(i));
		}
		document.getElementById(Out).value = ret; 
	}
}		
