function f_block (id) {document.getElementById(id).style.display='block'}
function f_none (id) {document.getElementById(id).style.display='none'}

function changeColor(obj,color) {
	document.getElementById(obj).style.backgroundColor = color;
}

function new_window(name, link) {
	if (name == "popup") {
		newWindow = window.open( link, "popup", "scrollbars=1, location=0, menubar=0, resizable=1, width=650, height=500, top=10, left=20" );
	}
}

function togglePopup(popup_id) {
	if(document.getElementById(popup_id).style.display == 'none') {
		document.getElementById(popup_id).style.display = 'block';
	}
	else {
		document.getElementById(popup_id).style.display = 'none';
	}
}

// ----
var sep="x", ofset=13;

function mmDecode(arg) {
	var count=0, result="", ch="";
	var pattern=new RegExp("^([0-9]+"+sep+")+$");
	if (!arg.match(pattern)) return "wrong email";
	while (count <= arg.length-1) {
		while (arg.charAt(count) != sep) ch=ch+arg.charAt(count++);
		result=result+String.fromCharCode(ch-ofset);
		ch="";
		count++;
	}
	return "mailto:"+result;
}

/* используется для переключения закладок:
 * на главной: главное | популярное | сюжеты
 * на остальных: Статьи | Профили | Проекты | Точки | Обзоры
 */
function mark(num, tnum, notecounter) {
	var num_name = num;
	var tnum_name = tnum;
	var re = /([^\d]+)/;
	var num_name = num_name.match(re);
	var tnum_name = tnum_name.match(re);

	for (i=1; i<=notecounter; i++)
		document.getElementById(num_name[0] + i).className="ZakladkaPassive";
	document.getElementById(tnum_name[0] + 0).innerHTML=document.getElementById(tnum).innerHTML;
	document.getElementById(num).className="ZakladkaActive";
}

/* используется для переключения закладок:
 * на остальных: Live.CNews | Games
 */
function marksmall(num, tnum, notecounter) {
	var num_name = num;
	var tnum_name = tnum;
	var re = /([^\d]+)/;
	var num_name = num_name.match(re);
	var tnum_name = tnum_name.match(re);

	for (i=1; i<=notecounter; i++)
		document.getElementById(num_name[0] + i).className="ZakladkaPassiveSmall";
	document.getElementById(tnum_name[0] + 0).innerHTML=document.getElementById(tnum).innerHTML;
	document.getElementById(num).className="ZakladkaActiveSmall";
}

/*  Функция для проверки формы опроса  
 *
 */
function check_poll_form(frm)
{
	el=frm.choice;
	ok=false;
	for (i=0; i<el.length; i++)
		if (el[i].checked)
		{	if (el[i].attributes)
			{	for (j=0; j<el[i].attributes.length; j++)
				{
					if (el[i].attributes[j].nodeName=='finput' && document.getElementById(el[i].attributes[j].nodeValue).value=='')
					{
						alert('Заполните, пожалуйста, поле "Другое"!');
						document.getElementById(el[i].attributes[j].nodeValue).focus();
						return false;
						break;
					}
				}
			}
			ok=true;
			break;
		}
	if (!ok)
	{	alert('Выберите, пожалуйста, вариант ответа!');
		return false;
	}
   return true;
}
