function gEl(id){return document.getElementById(id)}	
//выставляем переменные времени

var today = new Date();
var tomorrow=new Date(today.getTime()+(1000*60*60*24));
var aftertomorrow=new Date(today.getTime()+(1000*60*60*24*2));
var d=today.getDate();
var m=today.getMonth();
var y=today.getFullYear();
var td=tomorrow.getDate();
var tm=tomorrow.getMonth();
var atd=aftertomorrow.getDate();
var atm=aftertomorrow.getMonth();


//проверка на выбор обратного билета
function confirmobr(){
	var bck = gEl('backchk');
	if (bck.checked){
		document.forms["web"].submit();
		return true;
    } else {
            if (confirm("Нужен ли вам обратный билет?")){
                alert("Пожалуйста выберите дату обратного вылета.");
				bck.checked = !bck.checked;
                checkback();
                return false;
            } else{
                    document.forms["web"].submit();
                    return true;
                }
        }
	
	return false;
}

//блокировка обратной даты (надо проверить)
function blc(s){
	d=gEl(s);
	d.style.display=(gEl("chb").checked)?"block":"none";
}

////блокировка обратной даты
function checkback(){
	var inDate  = gEl('indate');
	var inMonth = gEl('inmonth');
	if (inDate.disabled == true && inMonth.disabled == true){
		inDate.disabled = false;
		inMonth.disabled = false;
	} else{
		inDate.disabled = true;
		inMonth.disabled = true;
	}
}

//выставление начальной даты	
function dayselection(){
	var outDay = gEl('outdate');
	var outMonth = gEl('outmonth');
	var inDate  = gEl('indate');
	var inMonth = gEl('inmonth');
	outDay.selectedIndex=td-1;
	outMonth.selectedIndex=tm;
	inDate.selectedIndex=atd-1;
	inMonth.selectedIndex=atm;
}	

//проверка на колличество дней в месяце
function dayselect(id){
	var outDay = gEl('outdate');
	var inDate  = gEl('indate');
	var form = gEl(id);
	var dt;
	if (id == 'inmonth')dt=inDate;
	else dt = outDay;
	if ((form.selectedIndex) < m){
		var year=y+1;
	}
	else{
		year=y;
	}
	var dayCount = 32 - new Date(year, form.selectedIndex, 32).getDate();
	for (var bg=27;bg<dt.length;bg++){
		if (bg>=dayCount)dt.options[bg].disabled= 'disabled';
		else dt.options[bg].disabled= '';
	}
	if (dt.selectedIndex>=dayCount)dt.selectedIndex=dayCount-1;
}		


function gorodarr(cod, gor){
	cod=document.f1.gmap_sel_city.id;
	gor=document.f1.gmap_sel_city.value;
	zdep.setComboValue(cod);
	zdep.setComboText(gor);
}

function goroddep(cod, gor){
	cod=document.f1.gmap_sel_city.id;
	gor=document.f1.gmap_sel_city.value;
	zarr.setComboValue(cod);
	zarr.setComboText(gor);
}

function gmap(napr, patch){
	allcity=window.open(patch+".php?route="+napr, "maparrdep", "left=0,top=0,width=740,height=530,resizable=0,scrollbars=1,status=1");
}
//открытие каллендаря
function nw(t){
	newWindow=window.open("/forma/calown.htm","cal"+t,"width=311,height=209,resizable=0,scrollbars=0");
	void(0)
}

