	
	function setCurrentDate()
	{
		var currentDate = new Date();
		var currDay = currentDate.getDate();
		var currMonth = currentDate.getMonth();
		var currYear = currentDate.getFullYear();
		
		
	
	}
	function getDate(d) 
	{
		var currDay = d.getDate();
		var currMonth = d.getMonth()+1;
		var currYear = d.getFullYear();
		
		if(currDay < 10) { currDay = "0" + currDay; }
		if(currMonth < 10) { currMonth = "0" + currMonth; }
		
		var dateStr = currDay + "/" + currMonth + "/" + currYear;

		return dateStr;
	}
	
	function setDate() 
	{
		var checkin = concatDate();
		var days = document.getElementById('afday').selectedIndex + 1;
		var display = document.getElementById('dateLabel');

		var b = checkin.split("/");
		
		if(!b[0]) b[0] = 1;
		if(!b[1]) b[1] = 1;
		if(!b[2]) b[2] = 2009;
		
		var i, k;
		
		for(k = 0; k < 2; k++)
		{
			for(i = 0; i < 10; i++)
			{
				if(b[k] == "0" + i)
				{
					b[k] = i;
				}
			}
		}
		
		var newcheckin = new Date(eval(b[2]), eval(b[1]) - 1 , eval(b[0]) + eval(days)); 
		var newDate = getDate(newcheckin);
		
		display.innerHTML = newDate;
		document.getElementById("checkoutDate").value = newDate;
		document.getElementById("checkInDate").value = checkin;
		
	}
	
	function concatDate()
	{
		var day = document.getElementById('chinday').value;
		var month = document.getElementById('chinmonth').value;
		var year = document.getElementById('chinyear').value;
		
		var dateStr = day + "/" + month + "/" + year;
		
		return dateStr;
		
	}
	
	function validateField(day, month, year, splitDate, _date)
	{
		if(splitDate)
		{
			var b = _date.split("/");
			
			validateField(b[0], b[1], b[2], false, null);
		}
		else
		{
			if(day.length < 2 || day.length > 2 || day == '' || isNaN(day))
			{
				return false;
			}
				
			if(month.length < 2 || month.length > 2 || month == '' || isNaN(month))
			{
				return false;
			}
				
			if(year.length < 4 || year.length > 4 || year == '' || isNaN(year))
			{
				return false;
			}
				
			return true;
		}
		
		return true;
	}
	
	function checkFormInputs() 
	{
		var cityField = document.getElementById("destination_city").value;
		var day = document.getElementById('chinday').value;
		var month = document.getElementById('chinmonth').value;
		var year = document.getElementById('chinyear').value;
		var cout = document.getElementById("checkoutDate").value;
		var cin = document.getElementById("checkInDate").value;
		var days = document.getElementById('afday').selectedIndex;
		
		if(cityField == '')
		{
			alert("City can not be empty!");
			return false;
		}
		if(!validateField(day, month, year, false, null)) 
		{
			alert("Invalid date!");
			return false;
		}
		if(!validateField(null, null, null, true, cout)) 
		{
			alert("Invalid date!");
			return false;
		}
		if(!validateField(null, null, null, true, cin)) 
		{
			alert("Invalid date!");
			return false;
		}
		if(days.length < 1 || days.length > 2 || isNaN(days))
		{
			alert("Invalid day!");
			return false;
		}
		
		return true;
		
	}
