function setDefaultDate(aform,offset)
{
//	offset = 6;
	listStartYear = 2004;

	date = new Date();
	date.setDate(date.getDate() + offset);
	dToCheck = date.getDate();
	mToCheck = date.getMonth()+1;
	yToCheck = date.getFullYear();
	setSelectValue(aform.CheckinDateDay, dToCheck);
	setSelectValue(aform.CheckinDateMonth, mToCheck);
	setSelectValue(aform.CheckinDateYear, yToCheck);
	setOutDate(aform);
}

function setOutDate(aform)
{
	offsetCheckout = 2;

	dToCheck = parseInt(aform.CheckinDateDay.options[aform.CheckinDateDay.selectedIndex].value,10);
	mToCheck = parseInt(aform.CheckinDateMonth.options[aform.CheckinDateMonth.selectedIndex].value,10);
	yToCheck = parseInt(aform.CheckinDateYear.options[aform.CheckinDateYear.selectedIndex].value,10);
	date = new Date(yToCheck, mToCheck-1, dToCheck);
	date.setDate(date.getDate() + offsetCheckout);

	dToCheck = parseInt(aform.CheckoutDateDay.options[aform.CheckoutDateDay.selectedIndex].value,10);
	mToCheck = parseInt(aform.CheckoutDateMonth.options[aform.CheckoutDateMonth.selectedIndex].value,10);
	yToCheck = parseInt(aform.CheckoutDateYear.options[aform.CheckoutDateYear.selectedIndex].value,10);

    if (!isNaN(dToCheck) && !isNaN(mToCheck) && !isNaN(yToCheck))
    {
        oldOutDate = new Date(yToCheck, mToCheck-1, dToCheck);

        if (oldOutDate.valueOf() < date.valueOf())
        {
            dToCheck = date.getDate();
            mToCheck = date.getMonth()+1;
            yToCheck = date.getFullYear();
            setSelectValue(aform.CheckoutDateDay, dToCheck);
            setSelectValue(aform.CheckoutDateMonth, mToCheck);
            setSelectValue(aform.CheckoutDateYear, yToCheck);
        }
    }
    else
    {
        dToCheck = date.getDate();
        mToCheck = date.getMonth()+1;
        yToCheck = date.getFullYear();
        setSelectValue(aform.CheckoutDateDay, dToCheck);
        setSelectValue(aform.CheckoutDateMonth, mToCheck);
        setSelectValue(aform.CheckoutDateYear, yToCheck);
    }
}
/*function setOutDate(aform)
{
	offsetCheckout = 2;
	dToCheck = aform.CheckinDateDay.options[aform.CheckinDateDay.selectedIndex].value;
	mToCheck = aform.CheckinDateMonth.options[aform.CheckinDateMonth.selectedIndex].value;
	yToCheck = aform.CheckinDateYear.options[aform.CheckinDateYear.selectedIndex].value;
	date = new Date(yToCheck, mToCheck-1, dToCheck);
	date.setDate(date.getDate() + offsetCheckout);
	dToCheck = date.getDate();
	mToCheck = date.getMonth()+1;
	yToCheck = date.getFullYear();
	setSelectValue(aform.CheckoutDateDay, dToCheck);
	setSelectValue(aform.CheckoutDateMonth, mToCheck);
	setSelectValue(aform.CheckoutDateYear, yToCheck);
}*/

function setSelectValue(obj, val)
{
	for (var i = 0; i < obj.options.length; i++) {
		if (obj.options[i].value == val)
		{
			obj.selectedIndex = i;
			break;
		}
	}
}

function validateDate(aform)
{
	var obj;
	sd = parseInt(aform.CheckinDateDay.options[aform.CheckinDateDay.selectedIndex].value,10);
	sm = parseInt(aform.CheckinDateMonth.options[aform.CheckinDateMonth.selectedIndex].value,10);
	sy = parseInt(aform.CheckinDateYear.options[aform.CheckinDateYear.selectedIndex].value,10);
	indate = new Date(sy, sm-1, sd);

	ed = parseInt(aform.CheckoutDateDay.options[aform.CheckoutDateDay.selectedIndex].value,10);
	em = parseInt(aform.CheckoutDateMonth.options[aform.CheckoutDateMonth.selectedIndex].value,10);
	ey = parseInt(aform.CheckoutDateYear.options[aform.CheckoutDateYear.selectedIndex].value,10);
	odate = new Date(ey, em-1, ed)
	
	if ( odate <= indate ) {
		alert("Invalid check-out date.");
		return false;
	}

	cdate = new Date();
	if ( indate < cdate ) {
		alert("Invalid check-in date.");
		return false;
	}
	if ( aform.CityCode.value == '' )
	{
		alert("Please select your city");
		return false;
	}

	if ( aform.SingleRooms.selectedIndex == 0 && aform.TwinRooms.selectedIndex == 0 && aform.DoubleRooms.selectedIndex == 0 && aform.TripleRooms.selectedIndex == 0 )
	{
		alert("At lease one room must be specified");
		return false;
	}

	return true;
}
