function checarData() {
	var dayIn = document.getElementById("dayIn").value;
	var monthIn = document.getElementById("monthIn").value;
	var yearIn = document.getElementById("yearIn").value;
	var dayOut = document.getElementById("dayOut").value;
	var monthOut = document.getElementById("monthOut").value;
	var yearOut = document.getElementById("yearOut").value;

	var inY = document.forms[0].mydateInY.value;
	var inM = document.forms[0].mydateInM.value;
	var inD = document.forms[0].mydateInD.value

	var outY = document.forms[0].mydateOutY.value;
	var outM = document.forms[0].mydateOutM.value;
	var outD = document.forms[0].mydateOutD.value;

	var data_inicio = new Date(inY, inM, inD);
	var data_fim = new Date(outY, outM, outD);
	var data_hoje = new Date();

	var dias_diferenca_inicio = (data_inicio-data_hoje)/86400000;
	var dias_diferenca = (data_fim-data_inicio)/86400000;

	if(dias_diferenca_inicio < 2) {
		alert("Check-in dates within 48 hours need to be confirmed. Please call ViaFloripa at 1-800-957-8845 for more information")
	}

	if (dias_diferenca < 4) {

		document.forms[0].mydateOutD.selectedIndex = dayOut;
		document.forms[0].mydateInD.selectedIndex = dayIn;
		document.forms[0].mydateOutY.selectedIndex = yearOut;
		document.forms[0].mydateInY.selectedIndex = yearIn;
		document.forms[0].mydateOutM.selectedIndex = monthOut;
		document.forms[0].mydateInM.selectedIndex = monthIn;
		alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
		return false;


/*	if (document.forms[0].mydateOutY.value < document.forms[0].mydateInY.value) {
		document.forms[0].mydateOutD.selectedIndex = dayOut;
		document.forms[0].mydateInD.selectedIndex = dayIn;
		document.forms[0].mydateOutY.selectedIndex = yearOut;
		document.forms[0].mydateInY.selectedIndex = yearIn;
		document.forms[0].mydateOutM.selectedIndex = monthOut;
		document.forms[0].mydateInM.selectedIndex = monthIn;
		alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
		return false;
	} else if (document.forms[0].mydateOutY.value == document.forms[0].mydateInY.value && document.forms[0].mydateOutM.value < document.forms[0].mydateInM.value) {
		document.forms[0].mydateOutD.selectedIndex = dayOut;
		document.forms[0].mydateInD.selectedIndex = dayIn;
		document.forms[0].mydateOutY.selectedIndex = yearOut;
		document.forms[0].mydateInY.selectedIndex = yearIn;
		document.forms[0].mydateOutM.selectedIndex = monthOut;
		document.forms[0].mydateInM.selectedIndex = monthIn;
		alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
		return false;
	} else if (document.forms[0].mydateOutY.value == document.forms[0].mydateInY.value && document.forms[0].mydateOutM.value == document.forms[0].mydateInM.value && document.forms[0].mydateOutD.value < (eval(document.forms[0].mydateInD.value) +4) ) {
		document.forms[0].mydateOutD.selectedIndex = dayOut;
		document.forms[0].mydateInD.selectedIndex = dayIn;
		document.forms[0].mydateOutY.selectedIndex = yearOut;
		document.forms[0].mydateInY.selectedIndex = yearIn;
		document.forms[0].mydateOutM.selectedIndex = monthOut;
		document.forms[0].mydateInM.selectedIndex = monthIn;
		alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
		return false;
*/	} else {
               return true;
        }
        /*
        var dayIn = document.forms[0].mydateInD.selectedIndex;
	var dayOut = document.forms[0].mydateOutD.selectedIndex;
	var yearIn = document.forms[0].mydateInY.selectedIndex;
	var yearOut = document.forms[0].mydateOutY.selectedIndex;
	var monthIn = document.forms[0].mydateInM.selectedIndex;
	var monthOut = document.forms[0].mydateOutM.selectedIndex;
	document.getElementById("dayIn").value = eval(dayIn);
	document.getElementById("dayOut").value = eval(dayOut);
	document.getElementById("yearIn").value = eval(yearIn);
	document.getElementById("yearOut").value = eval(yearOut);
	document.getElementById("monthIn").value = eval(monthIn);
	document.getElementById("monthOut").value = eval(monthOut);
	*/
}
function dsInput( objName, formName, datein ) {
	/* Properties */
	this.objName 		= objName;
	this.today          = new Date();
	if(datein == ''){
	 this.date           = this.today.getDate();
     this.month          = this.today.getMonth()+1;
	 this.year           = this.today.getFullYear();}
	else {
	var teste = datein.substr(8,2);
 	 this.date           = eval(datein.substr(8,2));
	 this.month          = datein.substr(5,2);
	 this.year           = eval(datein.substr(0,4));}
	//if(this.year < 2000) this.year += 1900; //for Netscape
	this.yearComboRange = 5;
	this.formName 		= arguments[1] ? arguments[1] : 'none';
	this.dayObj			= '';
	this.monthObj		= '';
	this.yearObj		= '';
	this.monthNames		= new Array( '','January','February','March','April','May','June','July','August','September','October','November','December' );


	/* Public Methods */
	this.setToToday			= ds_setToToday;
	this.adjustDaysInMonth 	= ds_adjustDaysInMonth;
	this.setDate			= ds_setDate;
	this.setDateParts		= ds_setDateParts;
	this.getSelYear			= ds_getYear;
	this.getSelMonth		= ds_getMonth;
	this.getSelDay			= ds_getDay;

	/* Private Methods */
	this._initOptions		= ds_initOptions;
	this._writeYearOptions 	= ds_writeYearOptions;
	this._writeMonthOptions = ds_writeMonthOptions;
	this._writeDayOptions 	= ds_writeDayOptions;
	this._getDaysInMonth	= ds_getDaysInMonth;

	/* Constructor Code */
	if( this.formName == 'none' ) {
		this.dayObj = eval("document.forms[0]." + this.objName + "D");
		this.monthObj = eval("document.forms[0]." + this.objName + "M");
		this.yearObj = eval("document.forms[0]." + this.objName + "Y");
	} else {
		this.dayObj = eval("document." + this.formName + "." + this.objName + "D");
		this.monthObj = eval("document." + this.formName + "." + this.objName + "M");
		this.yearObj = eval("document." + this.formName + "." + this.objName + "Y");
	}
	this._initOptions();
	this.setToToday();
	this.adjustDaysInMonth();
}

/* Class Methods */

/**
* Set the date boxes to today's date
*/
function ds_setToToday() {
	this.setDateParts( this.year, this.month, this.date );
}
/**
* Set the date boxes to specific date
* @param string dateStr 'YYYYMMDD'
*/
function ds_setDate( dateStr ) {
	var y, m, d;
	y = dateStr.substr(0,4);
	m = dateStr.substr(4,2);
	d = dateStr.substr(6,2);
	this.setDateParts( y, m, d );
}
/**
* Set the date boxes to today's date
* @param integer year
* @param integer month
* @param integer day
*/
function ds_setDateParts( year, month, date ) {
	this.dayObj[date-1].selected = true;
	this.monthObj[month-1].selected = true;
	for( i=0; i < this.yearObj.length; i++ ) {
		if( this.yearObj[i].value == year )
			this.yearObj[i].selected = true;
	}
	this.adjustDaysInMonth();
}


function ds_getYear() {
	return this.yearObj[this.yearObj.selectedIndex].value;
}

function ds_getMonth() {
	return this.monthObj[this.monthObj.selectedIndex].value;
}

function ds_getDay() {
	return this.dayObj[this.dayObj.selectedIndex].value;
}


/**
* Adjust the 'days' box according to the
* current month and year
*/
function ds_adjustDaysInMonth() {
	Month = this.monthObj[this.monthObj.selectedIndex].value;
	//alert( Month );
	Year = this.yearObj[this.yearObj.selectedIndex].value;
	//alert( Year);

	DaysForThisSelection = this._getDaysInMonth(Month, Year);
	PrevDaysInSelection = this.dayObj.length;

	if (PrevDaysInSelection > DaysForThisSelection) {
		for (i=0; i<(PrevDaysInSelection-DaysForThisSelection); i++) {
			this.dayObj.options[this.dayObj.options.length - 1] = null
		}
	}
	if (DaysForThisSelection > PrevDaysInSelection) {
		var prevLastDay = this.dayObj.options.length;
		for( i = prevLastDay+1; i <= DaysForThisSelection; i++ ) {
			var newOption = new Option( i, i );
			var optionsColl = this.dayObj.options;
			optionsColl[optionsColl.length] = newOption;
		}
	}
	if (this.dayObj.selectedIndex < 0)
		this.dayObj.selectedIndex == 0;
}

/* Private Methods */

function ds_initOptions() {
	this._writeYearOptions();
	this._writeMonthOptions();
	this._writeDayOptions();
}

function ds_getDaysInMonth( m, y ) {
	monthdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	if (m != 2) {
		return monthdays[m];
	} else {
		return ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0 ? 29 : 28);
	}
}

function ds_writeYearOptions() {
//	for( i=(this.year-this.yearComboRange); i<=(this.year+this.yearComboRange); i++ ) {
	for( i=(this.year); i<=(this.year+this.yearComboRange); i++ ) {
		var newOption = new Option( i, i );
		var optionsColl = this.yearObj.options;
		optionsColl[optionsColl.length] = newOption;
	}
}

function ds_writeMonthOptions() {
	for( i=1; i <= 12; i++ ) {
		var newOption = new Option( this.monthNames[i], i );
		var optionsColl = this.monthObj.options;
		optionsColl[optionsColl.length] = newOption;
	}
}

function ds_writeDayOptions() {
	for( i=1; i <= 31; i++ ) {
		var newOption = new Option( i, i );
		var optionsColl = this.dayObj.options;
		optionsColl[optionsColl.length] = newOption;
	}
}
/*function checarData2() {

	var outY = document.forms[0].mydateOutY.value;
	var inY = document.forms[0].mydateInY.value;
	var outM = document.forms[0].mydateOutM.value;
	var inM = document.forms[0].mydateInM.value;
	var outD = document.forms[0].mydateOutD.value;
	var inD = document.forms[0].mydateInD.value


	if (outY < inY) { // ano de saida anterior ao ano de entrada
		alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
		return false;
	} else
		 if ((outY = inY)&(outM < inM)) {  // mes de saida anterior ao mes de entrada
			alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
			return false;
		} else
			if ((outM = inM)&(outD < (eval(inD) +4))) { // dia de saida anterior a 4 dias depois da entrada
				alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
				return false;
			} else {
               		return true;
        		}

}*/
function checarData2() {
	var inY = document.forms[0].mydateInY.value;
	var inM = document.forms[0].mydateInM.value;
	var inD = document.forms[0].mydateInD.value

	var outY = document.forms[0].mydateOutY.value;
	var outM = document.forms[0].mydateOutM.value;
	var outD = document.forms[0].mydateOutD.value;

	var outM = outM.replace("1", "Jan");
	var outM = outM.replace("2", "Feb");
	var outM = outM.replace("3", "Mar");
	var outM = outM.replace("4", "Apr");
	var outM = outM.replace("5", "Mai");
	var outM = outM.replace("6", "Jun");
	var outM = outM.replace("7", "Jul");
	var outM = outM.replace("8", "Aug");
	var outM = outM.replace("9", "Sep");
	var outM = outM.replace("10", "Oct");
	var outM = outM.replace("11", "Nov");
	var outM = outM.replace("12", "Dec");

	var inM = inM.replace("1", "Jan");
	var inM = inM.replace("2", "Feb");
	var inM = inM.replace("3", "Mar");
	var inM = inM.replace("4", "Apr");
	var inM = inM.replace("5", "Mai");
	var inM = inM.replace("6", "Jun");
	var inM = inM.replace("7", "Jul");
	var inM = inM.replace("8", "Aug");
	var inM = inM.replace("9", "Sep");
	var inM = inM.replace("10", "Oct");
	var inM = inM.replace("11", "Nov");
	var inM = inM.replace("12", "Dec");

	var data_inicio = new Date(inM + ' ' + inD + ', ' + inY + ' 00:00:00');
	var data_fim = new Date(outM + ' ' + outD + ', ' + outY + ' 00:00:00');
	var data_hoje = new Date();

	var dias_diferenca = (data_fim-data_inicio)/86400000;
	var dias_diferenca_inicio = (data_inicio-data_hoje)/86400000;

	if(dias_diferenca_inicio < 1) {
		alert("Check-in dates within 48 hours need to be confirmed. Please call ViaFloripa at 1-800-957-8845 for more information")
	}
	else {
		if (dias_diferenca < 4) { // ano de saida anterior ao ano de entrada
			alert("Minimum 4 night stay required!\n\nFor less than 4 nights please call us direct to confirm availability.\nToll Free: 1-800 957-8845 or (905) 370-0275");
			return false;
		} else {
			return true;
		}
	}
}