function get()
{
	byID('get').style.display = 'block';
}

function prolong()
{
	byID('prolong').style.display = 'block';
}

function rules()
{
	window.open('/?rules', 'rules',
	'width=400,height=300,scrollbars=1,resizable=1');
}

function srules()
{
	window.open('?srules', 'rules',
	'width=400,height=300,scrollbars=1,resizable=1');
}

function contacts()
{
	window.open('/?contacts', 'contacts',
	'width=400,height=200,scrollbars=1,resizable=1');
}

function restore()
{
	mail = byID('mail').value;
	
	if (mailSane(mail)) {
		call('restore', mail);
	} else {
		alert('Неверный адрес!');
	}
}

function callback(ready, ok, reply)
{
	if (ready && ok)
	{
		var f = false;
		try { f = checked(reply); } catch(e) {}
		if (!f) try { f = fcallback(reply); } catch(e) {}
		if (!f) alert(reply);
	}
}

function dayspfx(days)
{
	if (days > 10 && days < 20) return 'дней';
	var l = days.charAt(days.length - 1);
	if (l == 1) return 'день';
	if (l > 1 && l < 5) return 'дня';
	return 'дней';
}

function setPhone()
{
	var s = byID('opsos').value.split('|');
	byID('phone').innerHTML = s[0];
	try { byID('phone2').innerHTML = s[0]; } catch (e) {}
	try { byID('days').innerHTML = s[1] + ' ' + dayspfx(s[1]); } catch (e) {}
	
}

function setPhoneP()
{
	var s = byID('opsosp').value.split('|');
	byID('phonep').innerHTML = s[0];
}

try {
	setPhone();
	setPhoneP();
	sortSelect(byID('opsos'), defaultop);
	sortSelect(byID('opsosp'), defaultop);
} catch (e) {}
