<!--
function addOption(selectbox, text, value) {
	var optn = document.createElement("option");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function getElement(elementName) {
	if (document.getElementById) {
		element = document.getElementById(elementName);
	} else if (document.all) {
		element = document.all[elementName];
	} else {
		element = false;
	}
	return element;
}

function clearTextBox(inputBox, textString, cssClass) {
	if (inputBox) {
		if (!textString || inputBox.value == textString) {
			inputBox.value = '';
		}
		if (cssClass) {
			inputBox.className = cssClass;
		}
	}
	return true;
}

function setTextBox(inputBox, textString, cssClass) {
	if (inputBox) {
		if (inputBox.value == '') {
			inputBox.value = textString;
			if (cssClass) {
				inputBox.className = cssClass;
			}
		}
	}

	return true;
}

String.prototype.pad = function(char,count) {
	var resultString = this + '';
	while(resultString.length < count) {
		resultString = char + resultString;
	}
	return resultString;
}

function updateDaySelector(monthElement, dayElement, yearElement) {
	var selectedDay = dayElement.selectedIndex;
	var selectedMonth = monthElement.options[monthElement.selectedIndex].value;
	var selectedYear = yearElement.options[yearElement.selectedIndex].value;
	var daysInSelectedMonth = 32 - new Date(selectedYear, selectedMonth - 1, 32).getDate();

	dayElement.options.length = 0;
	for (var c = 1; c <= daysInSelectedMonth; c++) {
		var theOption = document.createElement('option');
		theOption.text = c;
		theOption.value = c;
		dayElement.options.add(theOption);
	}

	if (dayElement.options.length - 1 < selectedDay) {
		selectedDay = dayElement.options.length - 1;
	}
	dayElement.selectedIndex = selectedDay;

	updateNumberOfDays();
}

function updateNumberOfDays() {
	var fromDateD = document.getElementById('durationfrom_d');
	var fromDateM = document.getElementById('durationfrom_m');
	var fromDateY = document.getElementById('durationfrom_y');
	var toDateD = document.getElementById('durationto_d');
	var toDateM = document.getElementById('durationto_m');
	var toDateY = document.getElementById('durationto_y');

	fromDateD = fromDateD.options[fromDateD.selectedIndex].value;
	fromDateM = fromDateM.options[fromDateM.selectedIndex].value - 1;
	fromDateY = fromDateY.options[fromDateY.selectedIndex].value;

	toDateD = toDateD.options[toDateD.selectedIndex].value;
	toDateM = toDateM.options[toDateM.selectedIndex].value - 1;
	toDateY = toDateY.options[toDateY.selectedIndex].value;

	var fromDateStamp = Date.UTC(fromDateY, fromDateM, fromDateD) / 1000;
	var toDateStamp = Date.UTC(toDateY, toDateM, toDateD) / 1000;

	if (toDateStamp > fromDateStamp) {
		var numDays = Math.ceil((toDateStamp - fromDateStamp) / 86400);
		document.getElementById('numdays').innerHTML = numDays;
		document.getElementById('additionalinfofromdate').value = fromDateD.pad("0", 2) + '/' + String(Number(fromDateM + 1)).pad("0", 2) + '/' + fromDateY;
		document.getElementById('additionalinfotodate').value = toDateD.pad("0", 2) + '/' + String(Number(toDateM + 1)).pad("0", 2) + '/' + toDateY;
		document.getElementById('additionalinfonumdays').value = numDays;
	}

}

function updateDurationFor() {
	var fromDateD = document.getElementById('durationfrom_d');
	var fromDateM = document.getElementById('durationfrom_m');
	var fromDateY = document.getElementById('durationfrom_y');
	var toDateD = document.getElementById('durationto_d');
	var toDateM = document.getElementById('durationto_m');
	var toDateY = document.getElementById('durationto_y');
	var numEl = document.getElementById('durationfor_num');
	var periodEl = document.getElementById('durationfor_period');
	var numDaysBox = document.getElementById('numdays');

	fromDateD = fromDateD.options[fromDateD.selectedIndex].value;
	fromDateM = fromDateM.options[fromDateM.selectedIndex].value - 1;
	fromDateY = fromDateY.options[fromDateY.selectedIndex].value;

	var fromDateStamp = Date.UTC(fromDateY, fromDateM, fromDateD) / 1000;
	var numDays = Math.ceil(numEl.options[numEl.selectedIndex].value * periodEl.options[periodEl.selectedIndex].value);
	var toDateStamp = fromDateStamp + (numDays * 86400);
	var toDate = new Date(toDateStamp * 1000);

	for (var c = 0; c < toDateD.options.length; c++) {
		if (toDateD.options[c].value == toDate.getDate()) {
			toDateD.selectedIndex = c;
		}
	}
	for (var c = 0; c < toDateM.options.length; c++) {
		if (toDateM.options[c].value - 1 == toDate.getMonth()) {
			toDateM.selectedIndex = c;
		}
	}
	for (var c = 0; c < toDateY.options.length; c++) {
		if (toDateY.options[c].value == toDate.getFullYear()) {
			toDateY.selectedIndex = c;
		}
	}
	numDaysBox.value = numDays;

	updateNumberOfDays();

}
//-->
