
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function getDateNow()
{
var now = new Date();
var e = now.getDate();
d = e + ' ';
var month = new Array(13);
month[1] = "січня";
month[2] = "лютого";
month[3] = "березня";
month[4] = "квітня";
month[5] = "травня";
month[6] = "червня";
month[7] = "липня";
month[8] = "серпня";
month[9] = "вересня";
month[10] = "жовтня";
month[11] = "листопада";
month[12] = "грудня";
var day = new Array(7);
day[0]= "неділя";
day[1]= "понеділок";
day[2]= "вівторок";
day[3]= "середа";
day[4]= "четвер";
day[5]= "п'ятниця";
day[6]= "субота";
nday=day[now .getDay()]
nmonths =month[ (now.getMonth() + 1)];
d += nmonths + ', ' +nday ;
return 'Сьогодні ' + d+'  ' ;
}

//Time town
//---------
var times = new Array(96);
times[0] = "0:00";
times[1] = "0:15";
times[2] = "0:30";
times[3] = "0:45";
times[4] = "1:00";
times[5] = "1:15";
times[6] = "1:30";
times[7] = "1:45";
times[8] = "2:00";
times[9] = "2:15";
times[10] = "2:30";
times[11] = "2:45";
times[12] = "3:00";
times[13] = "3:15";
times[14] = "3:30";
times[15] = "3:45";
times[16] = "4:00";
times[17] = "4:15";
times[18] = "4:30";
times[19] = "4:45";
times[20] = "5:00";
times[21] = "5:15";
times[22] = "5:30";
times[23] = "5:45";
times[24] = "6:00";
times[25] = "6:15";
times[26] = "6:30";
times[27] = "6:45";
times[28] = "7:00";
times[29] = "7:15";
times[30] = "7:30";
times[31] = "7:45";
times[32] = "8:00";
times[33] = "8:15";
times[34] = "8:30";
times[35] = "8:45";
times[36] = "9:00";
times[37] = "9:15";
times[38] = "9:30";
times[39] = "9:45";
times[40] = "10:00";
times[41] = "10:15";
times[42] = "10:30";
times[43] = "10:45";
times[44] = "11:00";
times[45] = "11:15";
times[46] = "11:30";
times[47] = "11:45";
times[48] = "12:00";
times[49] = "12:15";
times[50] = "12:30";
times[51] = "12:45";
times[52] = "13:00";
times[53] = "13:15";
times[54] = "13:30";
times[55] = "13:45";
times[56] = "14:00";
times[57] = "14:15";
times[58] = "14:30";
times[59] = "14:45";
times[60] = "15:00";
times[61] = "15:15";
times[62] = "15:30";
times[63] = "15:45";
times[64] = "16:00";
times[65] = "16:15";
times[66] = "16:30";
times[67] = "16:45";
times[68] = "17:00";
times[69] = "17:15";
times[70] = "17:30";
times[71] = "17:45";
times[72] = "18:00";
times[73] = "18:15";
times[74] = "18:30";
times[75] = "18:45";
times[76] = "18:00";
times[77] = "19:15";
times[78] = "19:30";
times[79] = "19:45";
times[80] = "20:00";
times[81] = "20:15";
times[82] = "20:30";
times[83] = "20:45";
times[84] = "21:00";
times[85] = "21:15";
times[86] = "21:30";
times[87] = "21:45";
times[88] = "22:00";
times[89] = "22:15";
times[90] = "22:30";
times[91] = "22:45";
times[92] = "23:00";
times[93] = "23:15";
times[94] = "23:30";
times[95] = "23:45";
times[96] = "42:00";

function CTime(form)
{
var day = ', цього дня';
var baseCityTime = 30 * parseInt(form.timeChoice.options[form.timeChoice.selectedIndex].value);
var offset = parseInt(form.firstCity.options[form.firstCity.selectedIndex].value ) -
parseInt(form.secondCity.options[form.secondCity.selectedIndex].value);
var selectedCityTime = (baseCityTime - offset) / 30;
var targetTime = parseInt(form.timeChoice.options[form.timeChoice.selectedIndex].value ) +
selectedCityTime;

if (selectedCityTime < 0)
{
selectedCityTime = 48 + selectedCityTime;
day = ', попереднього дня';
}

else if (selectedCityTime > 47)
{
selectedCityTime = selectedCityTime - 48;
day = ', наступного дня';
}

if (selectedCityTime < 0)
selectedCityTime=selectedCityTime * -1;

form.time.value = times[selectedCityTime * 2] + day;

return false;
}


var WeekTitles=new Array('Нд','Пн','Вт','Ср','Чт','Пт','Ст')
function showallweektitles(){
var i, answer=" <tr>\n"
for(i=0;i<WeekTitles.length;i++) answer+=" <th CLASS=\"calendar\">"+WeekTitles[i]+"</th>\n"
answer+=" </tr>\n"
return answer
}
function calendar_show(m, d, y){
var sdate= new Date(m+'/1/'+y);
var mdate= new Date(m+'/'+d+'/'+y);
var todaydate= new Date();
var days=dayonmonth(m,y)
var iday=0, day, answer=''
answer+='<table border=0 CLASS="calendar">'
answer+=' <tr CLASS="calendar">'
answer+=' <th CLASS="calendar" colspan=7>'
answer+=' <table width="100%" border=0 cellpadding=0 cellspacing=0 height="100%">'
answer+=' <tr CLASS="calendar">'
answer+=' <td align="left"><b>Календар</b></td>'
answer+=' <td align="right">'+d+'.'+m+'.'+y+'</td>'
answer+=' </tr>'
answer+=' </table>'
answer+=' </th>'
answer+=' </tr>'
answer+=' <tr CLASS="calendar">'
answer+=' <th colspan=7>'
answer+='<table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%">'
answer+=' <tr CLASS="calendar">'
answer+=' <td width="25%"><table onClick="calendar_move(\'-\',\'y\','+m+','+d+','+y+')" CLASS="calendar_button_0_1" onMouseOver="this.className=\'calendar_button_1_1\'" onMouseOut="this.className=\'calendar_button_0_1\'" border=0 cellpadding=0 cellspacing=0 width="100%" height="100%"><tr CLASS="calendar"><td><<</td></tr></table></td>'
answer+=' <td width="25%"><table onClick="calendar_move(\'-\',\'m\','+m+','+d+','+y+')" CLASS="calendar_button_0_2" onMouseOver="this.className=\'calendar_button_1_2\'" onMouseOut="this.className=\'calendar_button_0_2\'" border=0 cellpadding=0 cellspacing=0 width="100%" height="100%"><tr CLASS="calendar"><td><</td></tr></table></td>'
answer+=' <td width="25%"><table onClick="calendar_move(\'+\',\'m\','+m+','+d+','+y+')" CLASS="calendar_button_0_2" onMouseOver="this.className=\'calendar_button_1_2\'" onMouseOut="this.className=\'calendar_button_0_2\'" border=0 cellpadding=0 cellspacing=0 width="100%" height="100%"><tr CLASS="calendar"><td>></td></tr></table></td>'
answer+=' <td width="25%"><table onClick="calendar_move(\'+\',\'y\','+m+','+d+','+y+')" CLASS="calendar_button_0_1" onMouseOver="this.className=\'calendar_button_1_1\'" onMouseOut="this.className=\'calendar_button_0_1\'" border=0 cellpadding=0 cellspacing=0 width="100%" height="100%"><tr CLASS="calendar"><td>>></td></tr></table></td>'
answer+=' </tr>'
answer+='</table>'
answer+=' </th>'
answer+=' </tr>'
answer+=' <tr>'
answer+=showallweektitles()
for(day=0;day<sdate.getDay();day++){
iday++
answer+=" <td></td>"
}
for(day=1;day<=days;day++){
iday++
if((todaydate.getMonth()+1)==m && todaydate.getDate()==day && todaydate.getFullYear()==y)
answer+=" <td onClick=\"form2.qwe.value='"+m+"/"+day+"/"+y+"';\" CLASS=\"calendar_today\"><table onMouseOver=\"this.className='calendar_active'\" onMouseOut=\"this.className=''\" border=0 cellpadding=0 cellspacing=0 width=\"100%\" height=\"100%\"><tr CLASS=\"calendar\"><td><a href=\"\">"+day+"</a></td></tr></table></td>"
else
answer+=" <td onClick=\"form2.qwe.value='"+m+"/"+day+"/"+y+"';\" CLASS=\"calendar\"><table onMouseOver=\"this.className='calendar_active'\" onMouseOut=\"this.className=''\" border=0 cellpadding=0 cellspacing=0 width=\"100%\" height=\"100%\"><tr CLASS=\"calendar\"><td><a href=\"\">"+day+"</a></td></tr></table></td>"
if(iday==7){
answer+="</tr><tr>"
iday=0
}
}
answer+=" </tr>"
answer+='</table>'
//self.calendar.innerHTML=answer
document.all.calendar.innerHTML=answer
}
function dayonmonth(m, y){ // Функция, для определения количества дней в месяце
var answer
if(m!=2){ // Если не "Февраль"
var date1=new Date(m+'/31/'+y)
var mm=(m<12)?(m+1):1;
var yy=(m<12)?y:(y+1);
var date2=new Date(mm+'/1/'+yy)
answer=(date1.getDay()==date2.getDay())?'30':'31';
}else{
var date1=new Date(m+'/29/'+y)
var mm=(m<12)?(m+1):1;
var yy=(m<12)?y:(y+1);
var date2=new Date(mm+'/1/'+yy)
answer=(date1.getDay()==date2.getDay())?'28':'29';
}
return answer
}
function calendar_move(to, index, m, d, y){
switch(to){
case('-'):
switch(index){
case('m'):
if(m>1){
m--
}else{
m=1
y--
}
break
case('d'):
var mm=(m>1)?--m:1
var yy=(m>1)?y:--y
var days=dayonmonth(mm, yy)
if(d>1){
d--
}else{
d=days
m=mm
y=yy
}
break
case('y'):
y--
break
}
break
case('+'):
switch(index){
case('m'):
if(m<12){
m++
}else{
m=1
y++
}
break
case('d'):
var mm=(m<12)?++m:1
var yy=(m<12)?y:++y
var days=dayonmonth(m, y)
if(d<days){
d++
}else{
d=1
m=mm
y=yy
}
break
case('y'):
y++
break
}
break
}
calendar_show(m, d, y)
}

