	usedDays = new Array();
	var cellHighlight = "#cccccc";
	var cellPlain = "#ffffff";
	var hrefHighlight = "#663300";
	var hrefPlain = "#663300";
	var allMonths = new Array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var nowDate = new Date();
	var nowYear = nowDate.getFullYear();
	var nowMonth = nowDate.getMonth();
	var nowDayOfMonth = nowDate.getDate();
	var previousElement = new Object();
	var inUseYear = nowYear;
	var inUseMonth = nowMonth+1;
	var inUseDay = nowDayOfMonth;
	var loadedYear = nowYear;
	var loadedMonth = nowMonth+1;
	var loadedDay = nowDayOfMonth;
	var matchOnLoad = false;
	var maxDays = -1;
	var minDays = -1;
	var varWeeks = 0;
	var inUseDate = nowYear + '-' + inUseMonth + '-' + nowDayOfMonth;
	var currentDate = inUseDate;
	var currentMonth = inUseMonth;
	var currentYear = nowYear;
	var highLightToday = "";
	phpSelf = "../main/";
	function captureEvent (event) {
		if (event.srcElement) {
			tag = event.srcElement;
		}
		else {
			tag = event.target;
		}
		if ((tag.tagName == "BODY") || (tag.tagName == "HTML")) {
			hideLayer("c1");
		}
		else {
			hide = true;
			loop = true;
			//if (!isNaN(tag.id)) {
				if ((tag.id == "t_arrival_date") || (tag.id == "t_departure_date") || (tag.id == 'c1')) {
					hide = false;
					loop = false;
				}
				else if (tag.id.substr(0, 2) == "t_") {
					loop = false;
					hide = true;
				}
			//}
			if (loop) {
				while (loop) {
					if (!parentOf(tag)) {
						loop = false;
						break;
					}
					else {
						tag = parentOf(tag);
						//if (!isNaN(tag.id)) {
							if ((tag.id == "t_arrival_date") || (tag.id == "t_departure_date") || (tag.id == 'c1')) {
								hide = false;
								loop = false;
								break;
							}
						//}
					}
				}
			}
			if (hide) {
				hideLayer("c1");
			}
		}
	}
	function getCoordinates (name) {
		x = new Array();
		i = Layr(name);
		j = Layr(name.substr(1, name.length - 1));
		h = 0;
		o = 7;
		if (i.y) {
			x[0] = i.y + h;
			x[1] = i.x;
		}
		else {
			x[0] = parseInt(i.offsetTop) + h;
			x[1] = parseInt(i.offsetLeft);
			x[1] = parseInt(j.offsetWidth);

			if (!window.attachEvent) {
				x[1] += o;
			}
			if (i.parentElement) {
				i = i.parentElement;
			}
			else {
				i = i.parentNode;
			}
			while(i != null){
				x[0] += parseInt(i.offsetTop);
				x[1] += parseInt(i.offsetLeft);
				i = i.offsetParent;
			}
		}
		return x;
	}
	function Layr (name) {
		if (document.getElementById) {
			return document.getElementById(name);
		}
		if (document.all) {
			return document.all[name];
		}
		if (document.layers) {
			if (document.layers[name]) {
				return document.layers[name];
			}
		}
	}
	function frameLayr (name) {
		if (parent.document.frames) {
			return parent.document.frames[name];
		}
		else {
			return parent.frames[name];
		}
	}
	function showLayer (name) {
		layerShow = Layr(name);
		if (layerShow) {
			layerShow.style.visibility = '';
			layerShow.style.display = '';
		}
	}
	function hideLayer (name) {
		layerShow = Layr(name);
		if (layerShow) {
			layerShow.style.visibility = 'hidden';
			layerShow.style.display = 'none';
		}
	}
	function parentOf (element) {
		if (element.parentElement) {
			return element.parentElement;
		}
		else {
			return element.parentNode;
		}
	}
	function setTxtValue (txtValue) {
		Layr("txtField").value = txtValue;
		txtPrevious = Layr(txtValue).value;
		if (txtPrevious.length == 10) {
			setMonth = txtPrevious.substr(5, 2);
			setYear = txtPrevious.substr(0, 4);
			if (setMonth.substr(0, 1) == "0") {
				setMonth = setMonth.substr(1, 1);
			}
			document.calendarForm.calendarMonth.selectedIndex = parseInt(setMonth)-1;
			for (i=0; i<document.calendarForm.calendarYear.options.length; i++) {
				if (document.calendarForm.calendarYear.options[i].value == parseInt(setYear)) {
					document.calendarForm.calendarYear.selectedIndex = i;
					break;
				}
			}
			updateCalendar (txtPrevious.substr(0, 4), txtPrevious.substr(5, 2));
			highLightName = Layr("_c_" + txtValue).value;
			gL(0);
			if (highLightName.length > 0) {
				highLight = Layr(highLightName);
				highLight.style.color = hrefPlain;
				parentOf(highLight).style.background = cellHighlight;
				previousElement = highLight;
				inUseDate = inUseYear + '-' + inUseMonth + '-' + highLight.innerHTML;
			}
		}
		else {
			updateCalendar (nowYear, nowMonth);
			gL(0);
			if (highLightToday.length > 0) {
				highLight = Layr(highLightToday);
				highLight.style.color = hrefPlain;
				parentOf(highLight).style.background = cellHighlight;
				previousElement = highLight;
				inUseDate = inUseYear + '-' + inUseMonth + '-' + highLight.innerHTML;
			}
		}
	}
	function setHighlight (txtName) {
		txtValue = Layr("txtField").value;
		if (txtValue != "") {
			Layr("_c_" + txtValue).value = txtName;
		}
	}
	function loadTxtValue (loadYear, loadMonth, loadDay) {
		txtValue = Layr("txtField").value;
		if (txtValue != "") {
			txtLayer = Layr(txtValue);
			if (txtLayer) {
				loadedYear = parseInt(loadYear);
				loadedMonth = parseInt(loadMonth);
				loadedDay = parseInt(loadDay);
				if (loadedMonth < 10) {
					loadedMonth = "0" + loadedMonth;
				}
				if (loadedDay < 10) {
					loadedDay = "0" + loadedDay;
				}
				if (loadedMonth.length > 2) {
					loadedMonth = loadedMonth.substr(1, 2);
				}
				if (loadedDay.length > 2) {
					loadedDay = loadedDay.substr(1, 2);
				}
				txtLayer.value = loadedYear + '-' + loadedMonth + '-' + loadedDay;
				//locationHref = phpSelf + '?u=' + document.calendarForm.u.value + '&d=' + loadYear + '-' + loadMonth + '-' + loadDay;
				//frameLayr("frameMain").location.href = locationHref;
			}
			hideLayer("c1");
		}
	}
	function loadCurrent () {
		document.calendarForm.calendarMonth.options[nowMonth].selected = true;
		for (i = 0; i < document.calendarForm.calendarYear.length; i++) {
			if (document.calendarForm.calendarYear.options[i].value == nowYear) {
				document.calendarForm.calendarYear.options[i].selected = true;
			}
		}
		eL();
		setPrevNext();
	}
	function hL (highLight) {
		if (parentOf(highLight).style.background != cellHighlight) {
			highLight.style.color = hrefHighlight;
		}
		window.status = allMonths[inUseMonth] + ' ' + highLight.innerHTML + ', ' + inUseYear;
	}
	function uL (highLight) {
		if (parentOf(highLight).style.background != cellHighlight) {
			highLight.style.color = hrefPlain;
		}
		window.status = '';
	}
	function cL (highLight) {
		sK = false;
		if (parseInt(inUseYear) == parseInt(nowYear)) {
			if (parseInt(inUseMonth) == (parseInt(nowMonth)) + 1) {
				if (parseInt(highLight.innerHTML) < parseInt(nowDayOfMonth)) {
					sK = true;
				}
			}
		}
		if (!sK) {
			if (highLight.innerHTML.length > 0) {
				gL(0);
				highLight.style.color = hrefPlain;
				parentOf(highLight).style.background = cellHighlight;
				previousElement = highLight;
				inUseDate = inUseYear + '-' + inUseMonth + '-' + highLight.innerHTML;
				setHighlight(highLight.id);
				loadTxtValue (inUseYear, inUseMonth, highLight.innerHTML);
				if (inUseDate == currentDate) {
					hideLayer("tDiv");
				}
				else {
					showLayer("tDiv");
				}
				eL();
			}
		}
		return false;
	}
	function eL () {
		if (!isNaN(usedDays[inUseDate])) {
			if (usedDays[inUseDate] == 1) {
				showLayer("exDiv");
			}
			else {
				hideLayer("exDiv");
			}
		}
		else {
			hideLayer("exDiv");
		}
	}
	function gL (colorValue) {
		window.status = '';
		if (previousElement.innerHTML.length > 0) {
			parentOf(previousElement).style.background = cellPlain;
		}
	}
	function cM (cD) {
		cfM = document.calendarForm.calendarMonth;
		cfY = document.calendarForm.calendarYear;
		yearOf = parseInt(inUseYear);
		monthOf = parseInt(inUseMonth);
		if (cD == 2) {
			if (parseInt(cfM.selectedIndex) + parseInt(cfY.selectedIndex) == 13) {
			}
			else {
				monthOf += 1;
				if (monthOf >= 13) {
					monthOf = 1;
					yearOf += 1;
					cfM.selectedIndex = 0;
					cfY.selectedIndex = parseInt(cfY.selectedIndex)+1;
				}
				else {
					cfM.selectedIndex = parseInt(cfM.selectedIndex)+1;
				}
			}
		}
		else {
			if (parseInt(cfM.selectedIndex) + parseInt(cfY.selectedIndex) == 0) {
			}
			else {
				monthOf -= 1;
				if (monthOf == 0) {
					monthOf = 12;
					yearOf -= 1;
					cfM.selectedIndex = 11;
					cfY.selectedIndex = parseInt(cfY.selectedIndex)-1;
				}
				else {
					cfM.selectedIndex = parseInt(cfM.selectedIndex)-1;
				}
			}
		}
		inUseYear = yearOf;
		inUseMonth = monthOf;
		updateCalendar (yearOf, monthOf);
	}
	function calendarDaysIn (monthOf, yearOf) {
		var	calendarPrevDate = new Date(yearOf, monthOf, 0);
		return calendarPrevDate.getDate();
	}
	function buildCalendar (yearOf, monthOf) {
		var buildMonth = new Array();
		var calendarDate = new Date(yearOf, monthOf-1, 1);
		var dayOfFirst = calendarDate.getDay();
		var daysInMonth = calendarDaysIn(monthOf, yearOf);
		var varDate = 1;
		var i, d, w;
		buildMonth[0] = new Array("S", "M", "T", "W", "T", "F", "S");
		for (d = 1; d < 7; d++) {
			buildMonth[d] = new Array(7);
		}
		for (d = dayOfFirst; d < 7; d++) {
			buildMonth[1][d] = varDate;
			varDate++;
		}
		varWeeks = 0;
		for (w = 2; w < 7; w++) {
			for (d = 0; d < 7; d++) {
				buildMonth[w][d] = "";
				if (varDate <= daysInMonth) {
					buildMonth[w][d] = varDate;
					varDate++;
					varWeeks = w+1;
				}
			}
		}
		return buildMonth;
	}
	function drawMonths () {
		var monthsHTML = "";
		for (m = 1; m < allMonths.length; m++) {
			monthsHTML += '<option value="' + m + '">' + allMonths[m] + '<' + '/option>';
		}
		document.write(monthsHTML);
	}
	function drawYears () {
		var yearsHTML = "";
		for (y = nowYear; y < nowYear+3; y++) {
			x = " " + y;
			yearsHTML += '<option value="' + y + '">' + x.substr(3, 2) + '<' + '/option>';
		}
		document.write(yearsHTML);
	}
	function drawCalendar (yearOf, monthOf) {
		var tableHTML = "";
		var selectedMonth = buildCalendar(yearOf, monthOf);
		var match = false;
		var matchw = "";
		var matchd = "";
		matchid = 0;
		tableHTML += '<table cellpadding="3" cellspacing="1" border="0" align="center" bgcolor="#adadad" width="100%">';
		tableHTML += '<input type="hidden" id="txtField" name="txtField" value="">';
		tableHTML += '<tr>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][0] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][1] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][2] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][3] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][4] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][5] + '<' + '/b><' + '/td>';
		tableHTML += '<td align="right" bgcolor="#cccccc"><b>' + selectedMonth[0][6] + '<' + '/b><' + '/td>';
		tableHTML += '<' + '/tr>';
		minDays = -1;
		maxDays = -1;
		for (w = 1; w < 7; w++) {
			tableHTML += '<tr id="w' + w + '"';
			if (w == 6) {
				if (isNaN(selectedMonth[w][0])) {
					tableHTML += ' style="visibility: hidden; display: none;"';
				}
				else if (selectedMonth[w][0].length < 1) {
					tableHTML += ' style="visibility: hidden; display: none;"';
				}
			}
			tableHTML += '>';
			for (d = 0; d < 7; d++) {
				tableHTML += '<td align="right"';
				dYid = ((7*w)+d)-7;
				if (!isNaN(selectedMonth[w][d])) {
					r = selectedMonth[w][d];
					sK = false;
					if (parseInt(yearOf) == parseInt(nowYear)) {
						if (parseInt(monthOf) == (parseInt(nowMonth)) + 1) {
							if (parseInt(r) < parseInt(nowDayOfMonth)) {
								sK = true;
							}
						}
					}
					if (r != "") {
						if (minDays < 0) {
							minDays = dYid;
						}
						maxDays = dYid;
					}
					hrefString = yearOf + '-' + monthOf + '-' + r;
					if (r.length == 1) {
						padValue = "&nbsp;";
					}
					else {
						padValue = "";
					}
					if (hrefString == inUseDate) {
						tableHTML += ' bgcolor="' + cellHighlight + '"';
						matchw = w;
						matchd = d;
						matchid = dYid;
						match = true;
						highLightToday = "dY" + dYid;
					}
					else {
						tableHTML += ' bgcolor="#ffffff"';
					}
					if (!sK) {
						tableHTML += ' onClick="return cL(Layr(\'dY' + dYid + '\'));"><font onMouseOver="hL(this);" onMouseOut="uL(this);" onClick="return cL(this);" id="dY' + dYid + '" style="cursor: hand; text-decoration: underline;">' + padValue + r + '<' + '/font>';
					}
					else {
						tableHTML += ' onClick="return cL(Layr(\'dY' + dYid + '\'));"><font onMouseOver="hL(this);" onMouseOut="uL(this);" onClick="return cL(this);" id="dY' + dYid + '" style="cursor: text; text-decoration: none;">' + padValue + r + '<' + '/font>';
					}
				}
				else {
					hrefString = yearOf + '-' + monthOf;
					tableHTML += ' bgcolor="#ffffff" onClick="return cL(Layr(\'dY' + dYid + '\'));"><font onMouseOver="hL(this);" onMouseOut="uL(this);" onClick="return cL(this);" id="dY' + dYid + '" style="cursor: text; text-decoration: none;"><' + '/font>';
				}
				tableHTML += '<' + '/td>';
			}
			tableHTML += '<' + '/tr>';
		}
		tableHTML += '<' + '/table>';
		document.write(tableHTML);
		if (match) {
			setPreviousOnLoad(matchw, matchd);
		}
		//loadTxtValue (inUseYear, inUseMonth, inUseDay);
	}
	function setPreviousOnLoad (w, d) {
		dYid = ((7*w)+d)-7;
		previousElement = Layr("dY" + dYid);
	}
	function setPrevNext () {
		if (parseInt(document.calendarForm.calendarMonth.selectedIndex) + parseInt(document.calendarForm.calendarYear.selectedIndex) == 0) {
			document.calendarForm.mP.disabled = true;
		}
		else {
			ccY = document.calendarForm.calendarYear.options[document.calendarForm.calendarYear.selectedIndex].value;
			if (parseInt(nowYear) == parseInt(ccY)) {
				ccM = document.calendarForm.calendarMonth.options[document.calendarForm.calendarMonth.selectedIndex].value;
				ccM = parseInt(ccM) - 1;
				if (parseInt(ccM) > parseInt(nowMonth)) {
					document.calendarForm.mP.disabled = false;
				}
				else {
					document.calendarForm.mP.disabled = true;
				}
			}
			else {
				document.calendarForm.mP.disabled = false;
			}
		}
		if (parseInt(document.calendarForm.calendarMonth.selectedIndex) + parseInt(document.calendarForm.calendarYear.selectedIndex) == 13) {
			document.calendarForm.mN.disabled = true;
		}
		else {
			document.calendarForm.mN.disabled = false;
		}
	}
	function updateCalendar (yearOf, monthOf) {
		if (monthOf.length == 2) {
			if (monthOf.substr(0, 1) == "0") {
				monthOf = monthOf.substr(1, 1);
			}
		}
		if (parseInt(yearOf) == parseInt(nowYear)) {
			if (parseInt(monthOf) <= parseInt(nowMonth)) {
				document.calendarForm.calendarMonth.selectedIndex = parseInt(nowMonth);
				monthOf = parseInt(nowMonth) + 1;
			}
		}
		inUseMonth = monthOf;
		inUseYear = yearOf;
		setPrevNext();
		selectedMonth = buildCalendar(yearOf, monthOf);
		gL(1);
		document.calendarForm.calendarSelected.value = "";
		rowSix = Layr("w6");
		if (isNaN(selectedMonth[6][0])) {
			rowSix.style.visibility = 'hidden';
			rowSix.style.display = 'none';
		}
		else if (selectedMonth[6][0].length < 1) {
			rowSix.style.visibility = 'hidden';
			rowSix.style.display = 'none';
		}
		else {
			rowSix.style.visibility = '';
			rowSix.style.display = '';
		}
		for (w = 1; w < 7; w++) {
			for (d = 0; d < 7; d++) {
				dYid = ((7*w)+d)-7;
				hrefTag = Layr("dY" + dYid);
				hK = false;
				if (isNaN(selectedMonth[w][d])) {
					hK = true;
				}
				else if (selectedMonth[w][d].length == 0) {
					hK = true;
				}
				else {
					sK = false;
					if (parseInt(yearOf) == parseInt(nowYear)) {
						if (parseInt(monthOf) == (parseInt(nowMonth)) + 1) {
							if (parseInt(selectedMonth[w][d]) < parseInt(nowDayOfMonth)) {
								sK = true;
							}
						}
					}
					if (!sK) {
						hrefString = yearOf + '-' + monthOf + '-' + selectedMonth[w][d];
						if (selectedMonth[w][d].length == 1) {
							padValue = "&nbsp;";
						}
						else {
							padValue = "";
						}
						if (hrefString == inUseDate) {
							gL(0);
							hrefTag.style.color = hrefPlain;
							parentOf(hrefTag).style.background = cellHighlight;
							previousElement = hrefTag;
						}
						else {
							parentOf(hrefTag).style.background = cellPlain;
						}
						parentOf(hrefTag).style.textDecoration = "underline";
						parentOf(hrefTag).style.cursor = "hand";
						hrefTag.innerHTML = padValue + selectedMonth[w][d];
					}
					else {
						parentOf(hrefTag).style.background = cellPlain;
						parentOf(hrefTag).style.textDecoration = "none";
						parentOf(hrefTag).style.cursor = "text";
						hrefString = yearOf + '-' + monthOf;
						hrefTag.innerHTML = padValue + selectedMonth[w][d];
					}
				}
				if (hK) {
					parentOf(hrefTag).style.background = cellPlain;
					parentOf(hrefTag).style.textDecoration = "none";
					parentOf(hrefTag).style.cursor = "text";
					hrefString = yearOf + '-' + monthOf;
					hrefTag.innerHTML = "";
				}
			}
		}
	}