var ru_monthes = new Array("","января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря");
var dim = new Array( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
var  dt = new Date();
var this_year = dt.getFullYear();

function $( id ) { 
	return document.getElementById( id ); 
}
function trim( str ) { return str.replace(/^\s+|\s+$/img, ""); }

function checkTimetableForm( form ) {
	if( form.originCityName.selectedIndex == 0 ) {
		alert('Выберите, откуда хотите улететь');
		form.originCityName.focus();
	} else if( form.destinationCityName.selectedIndex == 0 ) {
		alert('Выберите, где хотите приземлиться');
		form.destinationCityName.focus();
	} else if( form.destinationCityName.selectedIndex == form.originCityName.selectedIndex ) {
		alert('Проще обойти вокруг аэропорта пешком, чем деньги тратить на рейс "' + form.destinationCityName.options[form.destinationCityName.selectedIndex].text + '-' + form.originCityName.options[form.originCityName.selectedIndex].text + '"' );
		form.destinationCityName.focus();
	} else {
		form.fromDate1.value = form.dep_day.options[form.dep_day.selectedIndex].value + "." + form.dep_month.options[form.dep_month.selectedIndex].value + "." + this_year;
		form.toDate1.value = form.dep_day.options[form.dep_day.selectedIndex].value + "." + form.dep_month.options[form.dep_month.selectedIndex].value + "." + this_year;
		form.fromDate2.value = form.arr_day.options[form.arr_day.selectedIndex].value + "." + form.arr_month.options[form.arr_month.selectedIndex].value + "." + this_year;
		form.toDate2.value = form.arr_day.options[form.arr_day.selectedIndex].value + "." + form.arr_month.options[form.arr_month.selectedIndex].value + "." + this_year;
		return true;
	}
	return false;
}

function makeDayList( list, days, currentDay ) {
	list.options.length = 0;
	currentDay = parseInt(currentDay);
	if( currentDay>days ) currentDay = days;
	for( i=0; i<days; i++ ) {
		var day = (i+1);
		if(day<10) day = "0" + day;
		var opt = new Option( day, day, ( currentDay == i+1 ) );
		list.options[i] = opt;
	}
}
function makeMonthList( list, currentMonth ) {
	list.options.length = 0;
	for( i=0; i<12; i++ ) {
		var month = (i+1);
		if( month<10 ) month = "0" + month;
		var opt = new Option( ru_monthes[i+1], month, ( currentMonth == i+1 ) );
		list.options[i] = opt;
	}
}


