// JavaScript Document
	
	function getBrowser () {
		if (navigator.appName.indexOf('Netscape') != -1) {
			return 'ns';
		}
		else if (navigator.appName.indexOf('Microsoft Internet Explorer') != -1) {
			return 'msie';
		}
		else if (navigator.appName.indexOf('Opera') != -1) {
			return 'op';
		}
	}
	
	function fGetMonthFromShortMonth(monthshort) {
	
		var month=new Array(12);
			month['Jan']="January";
			month['Feb']="February";
			month['Mar']="March";
			month['Apr']="April";
			month['May']="May";
			month['Jun']="June";
			month['Jul']="July";
			month['Aug']="August";
			month['Sep']="September";
			month['Oct']="October";
			month['Nov']="November";
			month['Dec']="December";
		
		return month[monthshort];
		
	}
	
	function fGetMonthFromNumber(monthshort) {
	
		var month=new Array(12);
			month[1]="January";
			month[2]="February";
			month[3]="March";
			month[4]="April";
			month[5]="May";
			month[6]="June";
			month[7]="July";
			month[8]="August";
			month[9]="September";
			month[10]="October";
			month[11]="November";
			month[12]="December";
		
		return month[monthshort];
		
	}
	
	function fSetCurrentDate (arrdep) {
			
			var t = new Date();
			var currentDay = t.getDate();
			var currentMonth = t.getMonth() + 1;
			var currentYear = t.getFullYear();
			
			if (arrdep=='arrival') {
				
				oDay = document.getElementById('day_a');
				oMonth = document.getElementById('month_a');
				oYear = document.getElementById('year_a');
				
			} else {
			
				oDay = document.getElementById('day_d');
				oMonth = document.getElementById('month_d');
				oYear = document.getElementById('year_d');
			
			}
			
			oDay.value = currentDay + 1; 
			oMonth.value = fGetMonthFromNumber(currentMonth); 
			oYear.value = currentYear;
			
			return;
			
		}
		
	
		function fCountCheckOut(day_a, month_a, year_a, nights) {
		
			var t = new Date();
			var month_a = month_a.substr(0,3);
			var utime_a = Date.parse(month_a+" "+day_a+", "+year_a);
			
			var utime_n = nights * 86400000;
			
			t.setTime(Math.round(utime_a+utime_n));
			var utime_d = String(t);
			
			day_d = utime_d.substr(8,2);
			month_d = utime_d.substr(4,3);
			year_d = utime_d.substr(11,4);
			
			
			if (getBrowser()=='msie') {
				
				year_d = utime_d.substr(29,4);
				
				if (utime_d.length<33) {
					day_d = utime_d.substr(7,2);
					year_d = utime_d.substr(28,4);
				}
				
			}
			
			oDay = document.getElementById('day_d');
			oMonth = document.getElementById('month_d');
			oYear = document.getElementById('year_d');
			
			oDay.value = Math.round(day_d);
			oMonth.value = fGetMonthFromShortMonth(month_d);
			oYear.value = year_d;
			
			oSelectNights = document.getElementById('nights');
			oSelectNights.style.color = "#000000";
			
			return;
			
		}
		
		function fCountNights(day_a, month_a, year_a, day_d, month_d, year_d) {
			
			var t = new Date();
			var utime = t.getTime();
			var month_d = month_d.substr(0,3);
			var utime_a = Date.parse(month_a+" "+day_a+", "+year_a);
			var utime_d = Date.parse(month_d+" "+day_d+", "+year_d);
			
			if ((utime_a-utime)<0) {
				
				alert('Zadané datum příjezdu je mimo platný rozsah !\nDate of arrival is out of valid range !');
				
				fSetCurrentDate('arrival');				
			
			} else if ((utime_d-utime)<0) {
			
				alert('Zadané datum odjezdu je mimo platný rozsah !\nDate of departure is out of valid range !');
				
				fSetCurrentDate('depart');	
			
			} else {
			
				if ((utime_d-utime_a)<0) {
				
					oSelectNights = document.getElementById('nights');
					oSelectNights.value = 0;
					oSelectNights.style.color = "#ff0000";
					
				} else {
					
					oSelectNights = document.getElementById('nights');
					oSelectNights.style.color = "#000000";
					oSelectNights.value = (utime_d-utime_a)/86400000;
	
				}
			
			}
			
			return;
			
		}
		
		function fHotelOnOff() {
			
			oOption = document.getElementById("hotel");
			
			if (oOption.value=='No accommodation needed') {
			
				document.getElementById("room").disabled = true;
				document.getElementById("sharing").disabled = true;
			
			} else {
				
				document.getElementById("room").disabled = false;
				document.getElementById("sharing").disabled = false;
			
			}

			return;
		}
			
		function fRoomOnOff() {
			
			oOption = document.getElementById("room");
			
			if (oOption.value=='Single') {
			
				document.getElementById("sharing").disabled = true;
			
			} else {
				
				document.getElementById("sharing").disabled = false;
			
			}
			
			return;
			
		}