var Mon3=new Array();
var Day3=new Array();
var D_Opt = new Array()

	Mon3 = ["Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"]
	Day3 = ['Vasárnap','Hétfő','Kedd','Szerda','Csütörtök','Péntek','Szombat']

function LengthOfMonth(Y, M) { // M=1..12 // OK in NS4? Mac?
	with (new Date(Y,M,1,12)) { setDate(0) ; return getDate() } }

function MonLen(Yr, Mo, Dy) { var Dol, K, DiM, NsI
	DiM = LengthOfMonth(+Yr.options[Yr.selectedIndex].text, Mo.selectedIndex+1)
	Dol = Dy.options.length
	if ( (NsI = Dy.selectedIndex) >= DiM ) NsI = DiM-1
// for (K=Dol	 ; K >DiM ; K--) Dy.options[K-1] = null
// for (K=Dol+1 ; K<=DiM ; K++) Dy.options[K-1] = new Option(K)
	for (K=Dol	 ; K >DiM ; K--){
		D_Opt[K] = Dy.options[K-1];
		Dy.options[K-1] = null;
	}
	for (K=Dol+1 ; K<=DiM ; K++) Dy.options[K-1] = D_Opt[K]
	Dy.selectedIndex = NsI }

function Lz(x) { return (x<0||x>=10?"":"0") + x /* local */ }

function DropReadYMD(Yr, Mo, Dy) {
	var Y = + Yr.options[Yr.selectedIndex].text
	var M = Mo.selectedIndex // 0..11
	var D = Dy.selectedIndex + 1
	return Y + '-' + Lz(M+1) + '-' + Lz(D) }

function InitYMDselector(Yr, Mo, Dy, Anni, Base, SetObj) { var J
	if (!Base) Base = new Date().getFullYear()
	for (J=0; J<Anni; J++) Yr.options[J] = new Option(Base+J)
	for (J=0;	J<12 ; J++) Mo.options[J] = new Option(Mon3[J],J+1)
	for (J=0;	J<31 ; J++) Dy.options[J] = new Option(J+1)
	if (SetObj) with (SetObj) {
		Yr.selectedIndex = getFullYear()-Base
		Mo.selectedIndex = getMonth()
		Dy.selectedIndex = getDate()-1 }
	else Yr.selectedIndex = Mo.selectedIndex = Dy.selectedIndex = 0
	MonLen(Yr, Mo, Dy) }

function init_datum(){
	if(document.forms['erdeklodesfoglalas']){
		var Now, YearSpan = 3,BaseYear = (Now = new Date()).getFullYear()
	
		with (document.forms['erdeklodesfoglalas']){
			InitYMDselector(ev1, ho1, nap1, YearSpan, BaseYear, Now);

			InitYMDselector(ev2, ho2, nap2, YearSpan, BaseYear, Now);
		}
	}
}

