function isLeapYear(argYear) {
return ((argYear % 4 == 0) && (argYear % 100 != 0)) || (argYear % 400 == 0)
}
function daysInMonth(argMonth, argYear) {
switch (Number(argMonth)) {
case 1: // Jan
case 3: // Mar
case 5: // May
case 7: // Jul
case 8: // Aug
case 10: // Oct
case 12: // Dec
return 31;
break;
case 4: // Apr
case 6: // Jun
case 9: // Sep
case 11: // Nov
return 30;
break;
case 2: // Feb
if (isLeapYear(argYear))
return 29
else
return 28
break;
default:
return 0;
}
}
function checkair(progress) {
if (document.getElementById("fromcity").value==""){
	alert ("Kérjük adja meg az indulás helyét.");
return false;
}
if (document.getElementById("fromcity").value==" "){
	alert ("Kérjük adja meg az indulás helyét.");
return false;
}
if (document.getElementById("tocity").value==""){
	alert ("Kérjük adja meg az érkezés helyét.");
return false;
}
if (document.getElementById("tocity").value==" "){
	alert ("Kérjük adja meg az érkezés helyét.");
return false;
}
if ((document.afpForm1.numptc1.selectedIndex+document.afpForm1.numptc2.selectedIndex+document.afpForm1.numptc3.selectedIndex) == 0){
	alert ("Kérjük adja meg az utasok számát.");
return false;
}
if ((document.afpForm1.numptc1.selectedIndex+document.afpForm1.numptc2.selectedIndex+document.afpForm1.numptc3.selectedIndex) >= 10){
	alert ("Az összes utas száma maximum 9 lehet.");
return false;
}
if (document.afpForm1.numptc1.selectedIndex == 0 && document.afpForm1.numptc3.selectedIndex >= 1){
	alert ("Gyerekjegyet csak felnott kísérettel foglalhat.");
return false;
}

var outday=document.afpForm1.outday.selectedIndex + 1;
var outmonth=document.afpForm1.outmonth.selectedIndex;
var outyear=document.afpForm1.outyear.value;
var retday=document.afpForm1.retday.selectedIndex + 1;
var retmonth=document.afpForm1.retmonth.selectedIndex;
var retyear=document.afpForm1.retyear.value;

var calendar=new Date(); 
var nowday=calendar.getDate();
var nowmonth=calendar.getMonth();
var nowyear=calendar.getYear();

if(outyear==nowyear && outmonth<nowmonth){
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
else if(outyear==nowyear && outmonth==nowmonth && outday<nowday){
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
else if(outyear==nowyear && outmonth==nowmonth && outday-nowday<7){
alert ("Az indulás dátuma nem lehet közelebb a mai dátumhoz 7 nappal.");
return false;
}
else if(outyear==nowyear && outmonth==nowmonth+1 && outday<nowday-30+7){
alert ("Az indulás dátuma nem lehet közelebb a mai dátumhoz 7 nappal.");
return false;
}
if (outyear>retyear) {
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
if (outyear==retyear && outmonth>retmonth) {
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
else if(outyear==retyear && outmonth==retmonth && outday>retday){
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
else if(outyear==retyear && outmonth==retmonth && outday==retday){
document.afpForm1.retyear.value=parseFloat(outyear)+1;
}
if (outday > daysInMonth (outmonth+1,outyear)){
alert ("Az Ön által megjelölt indulás dátuma nem érvényes.");
return false;
}else if (retday > daysInMonth (retmonth+1,retyear)) {
alert ("Az Ön által megjelölt visszaút dátuma nem érvényes.");
return false;
}
return progress();
}

function checkhotel(progress) {
if (document.getElementById("hotcity").value==""){
	alert ("Kérjük adja meg a város nevét.");
return false;
}
if (document.getElementById("hotcity").value==" "){
	alert ("Kérjük adja meg a város nevét.");
return false;
}
var outday=document.afpForm3.cinday.selectedIndex + 1;
var outmonth=document.afpForm3.cinmonth.selectedIndex;
var outyear=document.afpForm3.cinyear.value;
var retday=document.afpForm3.cotday.selectedIndex + 1;
var retmonth=document.afpForm3.cotmonth.selectedIndex;
var retyear=document.afpForm3.cotyear.value;

var calendar=new Date(); 
var nowday=calendar.getDate();
var nowmonth=calendar.getMonth();
var nowyear=calendar.getYear();

if(outyear==nowyear && outmonth<nowmonth){
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
else if(outyear==nowyear && outmonth==nowmonth && outday<nowday){
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
else if(outyear==nowyear && outmonth==nowmonth && outday-nowday<7){
alert ("Az indulás dátuma nem lehet közelebb a mai dátumhoz 7 nappal.");
return false;
}
else if(outyear==nowyear && outmonth==nowmonth+1 && outday<nowday-30+7){
alert ("Az indulás dátuma nem lehet közelebb a mai dátumhoz 7 nappal.");
return false;
}
if (outyear>retyear) {
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
if (outyear==retyear && outmonth>retmonth) {
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
else if(outyear==retyear && outmonth==retmonth && outday>retday){
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
else if(outyear==retyear && outmonth==retmonth && outday==retday){
document.afpForm3.cotyear.value=parseFloat(outyear)+1;
}
if (outday > daysInMonth (outmonth+1,outyear)){
alert ("Az Ön által megjelölt indulás dátuma nem érvényes.");
return false;
}else if (retday > daysInMonth (retmonth+1,retyear)) {
alert ("Az Ön által megjelölt visszaút dátuma nem érvényes.");
return false;
}
return progress();
}

function changedate(formname){
if (formname=="air"){
if (document.afpForm1.outday.selectedIndex+7>=30){
	document.afpForm1.retday.selectedIndex=document.afpForm1.outday.selectedIndex-30+7;
	if (document.afpForm1.outmonth.selectedIndex>=11){
		document.afpForm1.retmonth.selectedIndex=0;
		document.afpForm1.retyear.value=parseFloat(document.afpForm1.outyear.value)+1;
	}else{
		document.afpForm1.retmonth.selectedIndex=document.afpForm1.outmonth.selectedIndex+1;
		document.afpForm1.retyear.value=document.afpForm1.outyear.value;
	}
}else{
	document.afpForm1.retmonth.selectedIndex=document.afpForm1.outmonth.selectedIndex;
	document.afpForm1.retday.selectedIndex=document.afpForm1.outday.selectedIndex+7;
	document.afpForm1.retyear.value=document.afpForm1.outyear.value;
}
}
else if (formname=="hotel"){
if (document.afpForm3.cinday.selectedIndex+7>=30){
	document.afpForm3.cotday.selectedIndex=document.afpForm3.cinday.selectedIndex-30+7;
	if (document.afpForm3.cinmonth.selectedIndex>=11){
		document.afpForm3.cotmonth.selectedIndex=0;
		document.afpForm3.cotyear.value=parseFloat(document.afpForm3.cinyear.value)+1;
	}else{
		document.afpForm3.cotmonth.selectedIndex=document.afpForm3.cinmonth.selectedIndex+1;
		document.afpForm3.cotyear.value=document.afpForm3.cinyear.value;
	}
}else{
	document.afpForm3.cotmonth.selectedIndex=document.afpForm3.cinmonth.selectedIndex;
	document.afpForm3.cotday.selectedIndex=document.afpForm3.cinday.selectedIndex+7;
	document.afpForm3.cotyear.value=document.afpForm3.cinyear.value;
}
}
}

