
function cal()
{
// CHECK THAT ALL USER DATA IS FILLED IN
if (document.vacationreq.month.value=="")
	{alert("Enter Month");return;}
if (document.vacationreq.day.value=="")
	{alert("Enter Day");return;}
if (document.vacationreq.year.value=="")
	{alert("Enter Year");return;}
if (document.vacationreq.nights.value=="")
	{alert("Enter # of Nights");return;}

var daily_index=new Array(4);

daily_index[1]={ratea:275,rateb:100,rateweek:1000,min:2};
daily_index[2]={ratea:225,rateb:100,rateweek:900,min:2};
daily_index[3]={ratea:350,rateb:200,rateweek:1600,min:3};
daily_index[4]={ratea:0,rateb:0,rateweek:2000,min:7};

var month=parseFloat(document.vacationreq.month.value);
var day=parseFloat(document.vacationreq.day.value);
var year=parseFloat(document.vacationreq.year.value);
var nights=parseFloat(document.vacationreq.nights.value);


var av = document.getElementById("av");
var rr = document.getElementById("rr");
var co =document.getElementById("co");

var rent=0;

// CLEAR USER OUTPUTS
rr.innerHTML = "";
co.innerHTML = "";


// CHECK IF YEAR IS 2007 or 2008
if (year<2010)
	{co.innerHTML = "You have entered an incorrect year.";return;}
if (year>2011)
	{co.innerHTML = "Rates are not yet available for this year.";return;}
// CHECK FOR VALID MONTH
if (month>12 || month<1)
	{co.innerHTML = "You have entered an incorrect month.";return;}
// CHECK FOR VALID DAY
if (day>31)
	{co.innerHTML = "You have entered an incorrect day.";return;}
	
// CALCULATE RENTAL SEASON
if (month==1 || month==2 || month==3 || month==9 || month==10 || month==11 || month==12 || (month==4 && day<3) || (month==8 && day>27))
{season=1;}
else if ((month==4 && day>2) || (month==5 && day<22))
{season=2;}
else if ((month==5 && day>21) || (month==6 && day<19))
{season=3;}
else
{season=4;}

// CHECK FOR VALID NUMBER OF NIGHTS
if (nights<daily_index[season].min)
	{co.innerHTML = "Sorry, you have not meet the minimum stay for this season.";return;}
else if (nights>7)
	{co.innerHTML = "Please contact me by phone or email for stays longer than one week.";return;}
// CHECK FOR SUMMER WEEKLY MINIMUM
else if (season==4 && nights<7)
	{co.innerHTML = "We only rent weekly during the summer season.";return;}
else if (season==3 && nights<3)
	{co.innerHTML = "We only rent a minimum of 3 nights during the early summer season.";return;}
else if (nights<2)
	{co.innerHTML = "Sorry we to not take one night stays.";return;}

//CALCULATE RATE

if (nights==7) //Calculate Rates
	{rent=0;
	rent=daily_index[season].rateweek;}
else if (nights==6)
	{rent=0;
	rent=daily_index[season].ratea+daily_index[season].ratea+daily_index[season].rateb+daily_index[season].rateb+daily_index[season].rateb+daily_index[season].rateb;}
else if (nights==5)
	{rent=0;
	rent=daily_index[season].ratea+daily_index[season].ratea+daily_index[season].rateb+daily_index[season].rateb+daily_index[season].rateb;}
else if (nights==4)
	{rent=0;
	rent=daily_index[season].ratea+daily_index[season].ratea+daily_index[season].rateb+daily_index[season].rateb;}
else if (nights==3)
	{rent=0;
	rent=daily_index[season].ratea+daily_index[season].ratea+daily_index[season].rateb;}
else if (nights==2)
	{rent=0;
	rent=daily_index[season].ratea+daily_index[season].ratea;}

//PRINT USER OUTPUTS
if (season==4)
	{co.innerHTML = "We rent Friday to Friday in the summer season.  Please contact me by phone or email to request a rental contract.";}
else
	{co.innerHTML = "Please contact me by phone or email to request a rental contract.";}
rr.innerHTML = rent;

}


