// JavaScript Document
document.write('<style type="text/css">\n')
if (document.getElementById)
document.write('.billcontent{display:none;\n'+'filter:progid:DXImageTransform.Microsoft.'+billboardeffects[filterid]+'}\n')
else if (hidecontent_from_legacy)
document.write('#contentwrapper{display:none;}')
document.write('</style>\n')

sdvig=new Array(120,160,171,201,237,304);
d_max=new Array(31,30,31,31,30); // последние дни месяца
mm=new Array("января","февраля","марта","апреля","Мая&lsquo;(05)","Июня&lsquo;(06)","Июля&lsquo;(07)","Августа&lsquo;(08)","Сентября&lsquo;(09)","Октября&lsquo;(10)","ноября","декабря");
monday = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

per=new Array();
per[0]=new Array('тип<br>номера','01.05<br>09.06','10.06<br>20.06','21.06<br>20.07','21.07<br>25.08','26.08<br>10.09','25&nbsp;августа<br>09&nbsp;сентября','10&nbsp;сентября<br>30&nbsp;октября');
per[1]=new Array('2мест.<br>1комн.',370,780,1020,1150,880);
per[2]=new Array('4мест.<br>2комн.',340,740,960,1080,840);

knom=new Array(2,4); // количество мест в номере

var a1=new Array(""," один"," два"," три"," четыре"," пять"," шесть"," семь"," восемь"," девять")
var a2=new Array(""," десять"," одиннадцать"," двенадцать"," тринадцать"," четырнадцать"," пятнадцать"," шестнадцать"," семнадцать"," восемнадцать"," девятнадцать")
var a3=new Array(""," двадцать"," тридцать"," сорок"," пятьдесят"," шестьдесят"," семьдесят"," восемьдесят"," девяносто")
var a4=new Array(""," сто"," двести"," триста"," четыреста"," пятьсот"," шестьсот"," семьсот"," восемьсот"," девятьсот")
var a5=new Array(" тысяч"," одна тысяча"," две тысячи"," три тысячи"," четыре тысячи"," пять тысяч"," шесть тысяч"," семь тысяч"," восемь тысяч"," девять тысяч")

n=new Array();

var dpm='нет';
var nom=1;
var t_ind=1;

// Функция вывода о не введеной информации.
function chk_frm() {
	msg ="";
	if(document.all.Name.value=="") 	{msg+="\n\nВаше имя"}
	if(!document.all.SurName.value) 	{msg+="\n\nВашу фамилию"}
	if(!document.all.EMail.value) 	{msg+="\n\nАдрес электронной почты"}
	if(document.all.summa.value==0) 	{msg+="\n\nРассчет проживания не произведен"}
	if(msg!="")
	{
	alert("Пожалуйста, укажите:"+msg);
	return false;
	}
	else
	{
	a=String(Math.random());
	document.all.ncount.value=a.substring(2,6); // номер счета
	document.all.mbeg.value=mm[m_b-1]; // название месяца начала
	document.all.mend.value=mm[m_e-1]; //  название месяца окончания
	document.all.nom.value=per[nom][0].substring(6,32); //  категория номера
	document.all.dpm.value=dpm; //  доп. место
	
	}
	return true;
}


function chk_mes()
{
 m=j1+ref_day(); 	// отобразили количество дней проживания
 d=new Array();
 j=1;
 zz='';
for (i=0; i<365; i++)
{
	sp='tot'+nom+j;
	d[i]=parseInt(document.all[sp].value) //per[nom][j];  в массив года записали цену из таблички цены первого элемента
    if (i==sdvig[j-0]) // если достигли следующего периода (Сдвигает расчет на ячейкку в периоде)
	if (j<=per[1].length-2) 
	j++; //сдвинулись в табличке на один шаг вправо
}
 l=0;
 e=j1;
for (i=j1; i<m; i++) 
 {
	l=l+d[e]; // к 0 прибавили цену периода
	e++;
	if (e>=365)
	e=1;
 }
l=Math.ceil(l);
document.all.summa.value=l;
document.all.psumma.value=Math.ceil(l/5);
document.all.tsumma.value=nom_txt(Math.ceil(l/5));
}



function dop(a) //увеличиваем цену номера на половину основного места
{
dp="dp"+a;
dp=document.all[dp].checked; // проверили, выбрано ли доп. место
a=(a==4)?3:a;
for (i=2;i<per[1].length;i++)
{
s='tot'+a+i;
d=parseInt(document.all[s].value);
d2=per[a][i]/knom[a-1]/2
d2=Math.ceil(d2);
document.all[s].value=(dp)?parseInt(d+d2):parseInt(d-d2); // если установлен переключатель - прибавили половину, иначе отняли
}
dpm=(dp)?'да':'нет'; // доп. место для формы
clr_sum();	// очистили сумму в контейнере
}


function ch_nom(a) // сменили номер
{
cls_class('txtb3')
fn='dp'+t_ind;
as=per[t_ind][1]
if (as=='x'){
document.all[fn].disabled=true;
document.all.dp4.disabled=true;
}
fn='dp'+a;
as=per[a][1]
if (as=='x'){
document.all[fn].disabled=false;
if (a==3)
document.all.dp4.disabled=false;
}
t_ind=a;
for (i=1;i<per[1].length;i++)
{
s='tot'+a+i;
//alert(s)
document.getElementById(s).className = 'txtb4';
nom=a;
clr_sum();	// очистили сумму в контейнере
}
}

function cls_class(icl) // изменили цвет строки под курсором
{
for (j=1;j<per.length;j++)
{
for (i=1;i<per[1].length;i++)
{
s='tot'+j+i;
document.getElementById(s).className = icl;
}
}
}
function clr_sum()
{
document.all.summa.value=0;
}




function s_o() //вывод таблицы
{
document.write('<table>');
for (i=0;i<per.length;i++)
{
tcl=(i%2==0)?'txtb5':'txtb2'; // цвет строки - четная-нечетная
document.write('<tr class="'+tcl+'">');
tx=(i==1)?'txtb4':'txtb3'; // цвет активной строки
ch2=(i==1)?'checked':''; // установка первого радиобаттона в ON
t_ds=(i==1)?'':'disabled'; // установка первого элмента visible
ch1=(i!=0)?'<input name="radiobutton" type="radio" value='+i+' "+ch2+" onClick="ch_nom('+i+')"'+ch2+'>':'&nbsp;';
document.write('<td align="center">'+ch1+'</td>'); // нарисовали радиобаттон


for (j=0; j<per[1].length;j++)
{
as=per[i][j];
rt=isFinite(as); // если число, то рисуем цену
if (rt)
as='<input name="tot"'+i+j+' type="text" id="tot'+i+j+'" value="'+per[i][j]+'" size="3" class="'+tx+'" align="right" readonly>';
//alert('tot'+i+j)
document.write('<td align="center">'+as+'</td>');
}
document.write('</tr>');
}
document.write('</table>');
}


function nom_txt(b)
{
if (b<10)
str=x1(b)
if (b>=10 && b<20)
str=x2(b)
if (b>=20 && b<100)
str=x10(b)
if (b>=100 && b<1000)
str=x100(b)
if (b>=1000 && b<10000)
str=x1000(b)
if (b>=10000)
str=x10000(b)
return str;
}

function x1(a){
return ' '+a1[a]
}
function x2(a){
return ' '+a2[a-9]
}
function x10(a){
s1=Number(String(a).substring(2,1))
d1=Number(String(a).substring(0,1))-1
return a3[d1]+x1(s1)
}
function x100(a){
d2=Number(String(a).substring(0,1))
s2=Number(String(a).substring(3,1))
if (s2<10)
s2=x1(s2)
if (s2>=10 && s2<20)
s2=x2(s2)
if (s2>=20)
s2=x10(s2)
return a4[d2]+s2
}
function x1000(a){
d3=Number(String(a).substring(0,1))
s3=Number(String(a).substring(4,1))
if (s3<10)
s3=x1(s3)
if (s3>=10 && s3<20)
s3=x2(s3)
if (s3>=20 && s3<100)
s3=x10(s3)
if (s3>=100 && s3<1000)
s3=x100(s3)
return a5[d3]+s3
}
function x10000(a){
d4=Number(String(a).substring(0,2))
d5=Number(String(a).substring(0,1))
d6=Number(String(a).substring(1,2))
s4=Number(String(a).substring(2,5))
if (s4<10)
s4=x1(s4)
if (s4>=10 && s4<20)
s4=x2(s4)
if (s4>=20 && s4<100)
s4=x10(s4)
if (s4>=100 && s4<1000)
s4=x100(s4)
d4=(d4<20)?x2(d4)+" тысяч"+s4:d7=a3[d5-1]+a5[d6]+s4
return d4
}
