<!--
// the date selector script//////////////////////////////////////
// author: jef vratny - 01-01-01
/////////////////////////////////////////////////////////////////
// You may freely use, modify and distribute this script so long 
// as you leave this header intact. Don't take credit for work 
// you didn't do, it's bad karma and not nice. Sorry about the 
// weird var names, I was in a stange mood when I wrote this. 
// but this is "freeware" and I'm not going to go back and change 
// them unless I have a good reason to.
/////////////////////////////////////////////////////////////////

var mdy = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30);
var mdyShort = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28);
var mdyShortLeap = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
var mdyLong = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
var myLeap = new Array(2000,2004,2008,2012,2016,2020,2024,2028,2032,2036,2040,2044,2052,2056,2060,2064);
var myMonths = new Array('Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień');
var myMonthsEN = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var myDaze = new Array(mdyLong,mdyShortLeap,mdyShort,mdy);
var showyrs = 5;

var Today = new Date();
var Year = Today.getFullYear();
if(Year <= 99) { Year += 1900; }

var startyr = Year; // set this to the first year you want this to use (ie 1999)
var oldSortDate = "";// this is the date you want displayed, otherwise todays date is shown

// find out the date, if you want to pass in a time stamp, this is where you would evaluate it
if(oldSortDate){
oldSortDate = Math.abs(oldSortDate);
ud = new Date(oldSortDate);
}else{
ud = new Date();
}
// change the date to milliseconds
chud = ud.getTime();
chud2 = ud.getTime();

function JV_dateMaker(t){
var milDate= new Date(t);
//takes a date in millisecond format and builds a range selector element set
	var ly = 0;//decide if it is a leapyear or not
	var mll = myLeap.length;
		if(document.layers){var yr = milDate.getYear()+1900;}//endif
		if(document.all){var yr = milDate.getYear();}//endif

		for(y=0;y<mll;y++){
			if(yr == myLeap[y]){ ly = 1;}//endif
			}//endfor
//decide which option set to populate dates with.
	var modaze = "";
		if(milDate.getMonth() == 1 && ly == 1){
			modaze = 1;
			}//endif
		else if(milDate.getMonth() == 1 && ly == 0){
			modaze = 2;
			}//end elseif
		else if(milDate.getMonth() == (3 || 5 || 8 || 10)){
			modaze = 3;
			}//end elseif
		else{
			modaze = 0;
			}//endelse

	var vint = myDaze[modaze];

//build out the month options
	document.form.ma.length = myMonths.length;
		for(iggy=0;iggy<myMonths.length;iggy++){
			document.form.ma.options[iggy].text = myMonths[iggy];
			document.form.ma.options[iggy].value = iggy;

		}//endfor

//buildout the year options starting with last year
//selecting specified year, and showing 5 more
		for(q=0;q<vint.length;q++){
			document.form.da.options.length = vint.length;
			// build out the date option for the first date selector
			document.form.da.options[q].text = vint[q];
			document.form.da.options[q].value = vint[q];
			
			if(q==(milDate.getDate() - 1)){
				document.form.da.selectedIndex = q;
				}//endif
			}//endfor

	document.form.ma.selectedIndex = milDate.getMonth();
//set the year options
	var rip = startyr;
	document.form.ya.options.length = showyrs;

		for(wink=0;wink<showyrs;wink++){
			document.form.ya.options[wink].text = wink + rip;
			document.form.ya.options[wink].value = wink + rip;
		}//endfor

//set the year
		for(laz=0;laz<showyrs;laz++){
			if(document.layers){var miyr=(milDate.getYear() + 1900);}//endif
			if(document.all){var miyr=milDate.getYear();}//endif
			if(document.form.ya.options[laz].value==miyr){
				document.form.ya.selectedIndex = laz;
				}//endif		
		}//endfor

}//endfunction






function JV_dateMaker2(t){
var milDate= new Date(t);
//takes a date in millisecond format and builds a range selector element set
	var ly = 0;//decide if it is a leapyear or not
	var mll = myLeap.length;
		if(document.layers){var yr = milDate.getYear()+1900;}//endif
		if(document.all){var yr = milDate.getYear();}//endif

		for(y=0;y<mll;y++){
			if(yr == myLeap[y]){ ly = 1;}//endif
			}//endfor
//decide which option set to populate dates with.
	var modaze = "";
		if(milDate.getMonth() == 1 && ly == 1){
			modaze = 1;
			}//endif
		else if(milDate.getMonth() == 1 && ly == 0){
			modaze = 2;
			}//end elseif
		else if(milDate.getMonth() == (3 || 5 || 8 || 10)){
			modaze = 3;
			}//end elseif
		else{
			modaze = 0;
			}//endelse

	var vint = myDaze[modaze];

//build out the month options
	document.form.ma2.length = myMonths.length;
		for(iggy=0;iggy<myMonths.length;iggy++){
			document.form.ma2.options[iggy].text = myMonths[iggy];
			document.form.ma2.options[iggy].value = iggy;

		}//endfor

//buildout the year options starting with last year
//selecting specified year, and showing 5 more
		for(q=0;q<vint.length;q++){
			document.form.da2.options.length = vint.length;
			// build out the date option for the first date selector
			document.form.da2.options[q].text = vint[q];
			document.form.da2.options[q].value = vint[q];
			
			if(q==(milDate.getDate() - 1)){
				document.form.da2.selectedIndex = q;
				}//endif
			}//endfor

	document.form.ma2.selectedIndex = milDate.getMonth();

//set the year options
	var rip = startyr;
	document.form.ya2.options.length = showyrs;

		for(wink=0;wink<showyrs;wink++){
			document.form.ya2.options[wink].text = wink + rip;
			document.form.ya2.options[wink].value = wink + rip;
		}//endfor

//set the year
		for(laz=0;laz<showyrs;laz++){
			if(document.layers){var miyr=(milDate.getYear() + 1900);}//endif
			if(document.all){var miyr=milDate.getYear();}//endif
			if(document.form.ya2.options[laz].value==miyr){
				document.form.ya2.selectedIndex = laz;
				}//endif		
		}//endfor

}//endfunction










function changeSelect(sm){
	//alert('changeSelect');

	var its = sm.form.elements["da"].options[sm.form.elements["da"].selectedIndex].value + ' ';

	var mond = myMonthsEN[sm.form.elements["ma"].options[sm.form.elements["ma"].selectedIndex].value] + ' ';

	var dey = sm.form.elements["ya"].options[sm.form.elements["ya"].selectedIndex].value + ' ';


	var blues = mond + ' ' +its+ ', '+dey;
	var shin = Date.parse(blues);

	var knee = new Date(shin);
	var tib = knee.getTime();
	chud = tib;
	var tensor=0;
	init(); 
}



function changeSelect2(sm){
	//alert('changeSelect');

	var its = sm.form.elements["da2"].options[sm.form.elements["da2"].selectedIndex].value + ' ';

	var mond = myMonthsEN[sm.form.elements["ma2"].options[sm.form.elements["ma2"].selectedIndex].value] + ' ';

	var dey = sm.form.elements["ya2"].options[sm.form.elements["ya2"].selectedIndex].value + ' ';


	var blues = mond + ' ' +its+ ', '+dey;
	var shin = Date.parse(blues);

	var knee = new Date(shin);
	var tib = knee.getTime();
	chud2 = tib;
	var tensor=0;
	init2(); 
}

function dateCalc(){
		var kink = chud;
		jnd = new Date(kink);
}

function dateCalc2(){
		var kink = chud2;
		jnd2 = new Date(kink);
}


function init(){
	dateCalc();
	JV_dateMaker(jnd);
	this.window.focus();
}

function init2(){
	dateCalc2();
	JV_dateMaker2(jnd2);
	this.window.focus();
}

//-->