
/*
	purpose:
		used in the control panel
	page:
		/admin/photo/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPhotoForm(theform)
{
	var thumbnail_value="";
	var image_value="";
	
	if (!IsWordNumberSpecial(theform.photoname.value))
	{
		alert("Please enter a valid Photo Name.");
		theform.photoname.focus();
		return false;
	}
	
	if (!IsDescription(theform.photodescription.value))
	{
		alert("Please enter some valid Photo Description.");
		theform.photodescription.focus();
		return false;
	}

	
	/*
	//if we are supposed to upload an thumbnail
	if (theform.uploadthumbnail.value == 1)
	{
		thumbnail_value=theform.photothumbnailfile_file.value;
		
		if (!IsImageExtension(thumbnail_value.substring(thumbnail_value.lastIndexOf("."),thumbnail_value.length)))
		{
			alert("Please select an thumbnail file for uploading (must be .jpg or .gif).");
			theform.photothumbnailfile_file.focus();
			return false;
		}
	}
	*/
	
	//if we are supposed to upload an image
	if (theform.uploadimage.value == 1)
	{
	 	image_value=theform.photoimagefile_file.value;
		
		if (!IsImageExtension(image_value.substring(image_value.lastIndexOf("."),image_value.length)))
		{
			alert("Please select an image file for uploading (must be .jpg or .gif).");
			theform.photoimagefile_file.focus();
			return false;
		}
	}
						
	return true;
}


/*
	purpose:
		used in the control panel
	page:
		/admin/gallery/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckGalleryForm(theform)
{

	if (!IsWordNumberSpecial(theform.galleryname.value))
	{
		alert("Please enter a valid photo gallery name.");
		theform.galleryname.focus();
		return false;
	}

	
	if (!IsDescription(theform.gallerydescription.value))
	{
		alert("Please enter valid photo gallery description.");
		theform.gallerydescription.focus();
		return false;
	}
	
	
	return true;
}


/*
	purpose:
		used in the front of the site for reservation lookup
	page:
		/admin/whatsnew/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckWhatsNewForm(theform)
{
	
	if (!IsWordNumberSpecial(theform.whatsnewtext.value))
	{
		alert("Please enter a value for this Whats New item.");
		theform.whatsnewtext.focus();
		return false;
	}
	
	
	if (!CheckDate(theform,'whatsnewstartdate','Whats New Start Date'))
		return false;

	if (!CheckDate(theform,'whatsnewenddate','Whats New End Date'))
		return false;

		
	
	
	return true;
}


/*
	purpose:
		used in the front of the site for reservation lookup
	page:
		/admin/reservation/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckReservationForm(theform)
{
	if (!CheckDate(theform,'checkindate','Check-In Date'))
		return false;
	
	
	return true;
}

/*
	purpose:
		used in the front of the site for reservation lookup
	page:
		/admin/reservation/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function SetCheckinDate(theform,themonth,theday,theyear)
{
	
	//select the proper check in date date
	theform.checkindate_month[themonth-1].selected=true;
	theform.checkindate_day[theday-1].selected=true;
	
	//find the year
	for (var i=0;i<theform.checkindate_year.length; i++)
	{
		if (theform.checkindate_year[i].value == theyear)
			theform.checkindate_year[i].selected=true;	
	}

}


/*
	purpose:
		used in the control panel search lookkup pages
	page:
		/admin/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function SetSearchCategory(theform)
{
	theform.search_category.value=document.form_search_category.reservation_certificate[document.form_search_category.reservation_certificate.selectedIndex].value;
}


/*
	purpose:
		used in the control panel search lookkup pages
	page:
		/admin/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchPhone(theform)
{
	//check 
	if (!IsPhone(theform.phonenumber.value))
	{
		alert("Please enter the phone number. I.e. xxx-xxx-xxxx OR xxx-xxx-xxxx ext xxx");
		theform.phonenumber.focus();
		return false;
	}
	
	SetSearchCategory(theform);
	
	return true;
}

/*
	purpose:
		used in the control panel search lookkup pages
	page:
		/admin/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchEmail(theform)
{
	//check 
	if (!IsEmail(theform.emailaddress.value))
	{
		alert("Please enter the email address.");
		theform.emailaddress.focus();
		return false;
	}
	
	SetSearchCategory(theform);
	
	return true;
}

/*
	purpose:
		used in the control panel search lookkup pages
	page:
		/admin/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchOrder(theform)
{
	//check 
	if (!IsOrderNumber(theform.ordernumber.value))
	{
		alert("Please enter the order number.");
		theform.ordernumber.focus();
		return false;
	}
	
	SetSearchCategory(theform);
	
	return true;
}


/*
	purpose:
		used in the control panel search lookkup pages
	page:
		/admin/search/module_viewall.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckSearchName(theform)
{
	//check if the values are blank
	if ((theform.firstname.value.length <=0) && (theform.lastname.value.length <=0))
	{
		alert("Please enter a first name and/or last name.");
		theform.firstname.focus();
		return false
	}
	
	//if the person has entered a firstname
	if (theform.firstname.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.firstname.value))
		{
			alert("Please enter a valid first name.");
			theform.firstname.focus();
			return false;
		}
	}
	
	//if the person has entered a lastname	
	if (theform.lastname.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.lastname.value))
		{
			alert("Please enter a valid last name.");
			theform.lastname.focus();
			return false;
		}
	}
	
	SetSearchCategory(theform);
	
	return true;
}


/*
	purpose:
		used in the admin area for the inventory change module
	page:
		/admin/inventorychange/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function SetActiveInventoryItem(theform,theid,theitemid)
{
	//var temp_string="inventory_"+theid;
	var temp_string2="left_inner_div_"+theid;
	var temp_string3="inventory_allocated_"+theid;
	var temp_string4="middle_inner_div_"+theid;
	var temp_string5="right_inner_div_"+theid;
	var old_id=parseInt(theform.last_active_inventory_id.value);
	var temp_string_old,temp_string_old2,temp_string_old3,temp_string_old4,temp_string_old5;
	var current_item_bg_color=document.getElementById(temp_string4).style.backgroundColor;
	var current_rate_bg_color=document.getElementById(temp_string5).style.backgroundColor;
	var old_item_bg_color=theform.last_item_bg_color.value;
	var old_rate_bg_color=theform.last_rate_bg_color.value;
	var inventory_type="room";
	
	
	//set the hidden value
	theform.active_inventory_id.value=theid;
	theform.active_inventory_item_id.value=theitemid;
	theform.last_item_bg_color.value=current_item_bg_color;
	theform.last_rate_bg_color.value=current_rate_bg_color;
	
	//set background color
	//document.getElementById(temp_string).style.backgroundColor="#eeeeee";
	document.getElementById(temp_string2).style.backgroundColor="#eeeeee";
	document.getElementById(temp_string3).style.backgroundColor="#eeeeee";
	document.getElementById(temp_string4).style.backgroundColor="#eeeeee";	
	document.getElementById(temp_string5).style.backgroundColor="#eeeeee";	
	
	if (!isNaN(old_id))
	{
		//make sure the old_id isn't the same as the new id
		if (old_id != theid)
		{
			//temp_string_old="inventory_"+old_id;
			temp_string_old2="left_inner_div_"+old_id;
			temp_string_old3="inventory_allocated_"+old_id;
			temp_string_old4="middle_inner_div_"+old_id;
			temp_string_old5="right_inner_div_"+old_id;
		
			//turn off old background color
			//document.getElementById(temp_string_old).style.backgroundColor="cccccc";
			document.getElementById(temp_string_old2).style.backgroundColor="#cccccc";
			document.getElementById(temp_string_old3).style.backgroundColor="#cccccc";
			document.getElementById(temp_string_old4).style.backgroundColor=old_item_bg_color;
			document.getElementById(temp_string_old5).style.backgroundColor=old_rate_bg_color;
		}
	}
	
	//set the new 'old' hidden value
	theform.last_active_inventory_id.value=theid;
}



/*
	purpose:
		used in the admin area for the inventory change module
	page:
		/admin/inventorychange/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function InventoryChangeUpdate(theform)
{
	var new_quantity=parseInt(theform.amount.value);
	var temp_inventory_id=parseInt(theform.active_inventory_id.value);
	var temp_room_booked=parseInt(eval("theform.hidden_inventory_room_booked_"+temp_inventory_id+".value"));
	var temp_package_booked=parseInt(eval("theform.hidden_inventory_package_booked_"+temp_inventory_id+".value"));
	var temp_allocated=parseInt(eval("theform.hidden_inventory_allocated_"+temp_inventory_id+".value"));
	var temp_max_quantity=parseInt(eval("theform.hidden_inventory_max_"+temp_inventory_id+".value"));
	var bContinue=true;
	var temp_string="inventory_allocated_"+temp_inventory_id;
	var temp_booked=temp_room_booked+temp_package_booked;
	
	if ((!isNaN(new_quantity)) && (!isNaN(temp_inventory_id)))
	{
		//ensure the new value is not greater then total available
		if (new_quantity > temp_max_quantity)
		{
			alert("Sorry, that number exceeds the maximum quantity (" + temp_max_quantity + ") for this day.");
			theform.amount.value="";
			theform.amount.focus();
			bContinue=false;
		}
		
		if (bContinue)
		{
			//check to make sure the value isn't less then total booked
			if (new_quantity < temp_booked)
			{	
				alert("Sorry, that number is less then the amount already booked (" + temp_booked + ") for this day.");
				theform.amount.value="";
				theform.amount.focus();
				bContinue=false;
			}
			
			if (bContinue)
			{
				//set the new allocated value
				eval("theform.hidden_inventory_allocated_"+temp_inventory_id+".value=new_quantity");
				
				//write the new value to the calendar
				document.getElementById(temp_string).innerHTML="&nbsp;-&nbsp;"+new_quantity+",<strong>"+temp_room_booked+"</strong>,<strong>"+temp_package_booked+"</strong>&nbsp;";
			}
		}
	}
}


/*
	purpose:
		used in the admin area for the inventorysetup module
	page:
		/admin/inventorysetup/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckInventoryDay(theform)
{
	var bFindDay=false;
	var rateIndex=theform.rateid.selectedIndex+1;
	var dayList=eval("theform.hiddenday_"+rateIndex+".value");
	var total_room=eval("theform.hiddenroom_"+rateIndex+".value");
	
	/*
	if (dayList.lastIndexOf(",") >= 0)
		dayList=dayList.split(",");
	
	*/
	
	dayList=dayList.split(",");
	
	//looping over checkbox days
	for (var j=0; j<theform.inventoryrulenight.length; j++)
	{		
		//looping over hidden field values
		for (var i=0; i<dayList.length; i++)
		{
			if (dayList[i] == theform.inventoryrulenight[j].value)
				bFindDay=true;			
		}
		
		//if we didn't find the current day in availability list
		if (!bFindDay) 
		{
			theform.inventoryrulenight[j].checked=false;
			theform.inventoryrulenight[j].disabled=true;
		}
		else
		{
			theform.inventoryrulenight[j].disabled=false;
		}
		
		//reset value
		bFindDay=false;	
	}
	
	//popuplate the quantity select box
	BuildSelect(theform,total_room);
}

/*
	purpose:
		used in the admin area for the inventorysetup module
	page:
		/admin/inventorysetup/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function BuildSelect(theform,thetotal)
{
	//reset select box (empty all elements)
	theform.inventoryrulequantity.options.length = 0;
	
	//build new values
	for(i=0;i<thetotal;i++)
	{

		new_option = new Option(i+1,i+1,null,null);
		theform.inventoryrulequantity.options[i] = new_option;
	}
}



/*
	purpose:
		used in the admin area for the addon module
	page:
		/admin/addon/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminCertificateForm(theform)
{
	if (!IsWordNumberSpecial(theform.certificatename.value))
	{
		alert("Please enter the certificate name.");
		theform.certificatename.focus();
		return false;
	}
	
	if (!IsPrice(theform.certificateprice.value))
	{
		alert("Please enter the price in the format XX.XX.");
		theform.certificateprice.focus();
		return false;
	}
	
	if (!IsPrice(theform.certificateservicecharge.value))
	{
		alert("Please enter the sercice charge in the format XX.XX.");
		theform.certificateservicecharge.focus();
		return false;
	}
	
	if (!IsPrice(theform.certificateshippingprice.value))
	{
		alert("Please enter the shipping price in the format XX.XX.");
		theform.certificateshippingprice.focus();
		return false;
	}
	
	return true;
}

/*
	purpose:
		used in the admin area for the event module
	page:
		/admin/event/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminEventForm(theform)
{
	if (!IsWordNumberSpecial(theform.eventname.value))
	{
		alert("Please enter the event name.");
		theform.eventname.focus();
		return false;
	}
	
	if (!IsDescription(theform.eventdescription.value))
	{
		alert("Please enter the event description.");
		theform.eventdescription.focus();
		return false;
	}
	
	if (!CheckDate(theform,'eventdate','Event Date'))
		return false;
		
	return true;
}


/*
	purpose:
		used in the admin area for the addon module
	page:
		/admin/addon/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminAddonForm(theform)
{
	if (!IsWordNumberSpecial(theform.addonname.value))
	{
		alert("Please enter the addon name.");
		theform.addonname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.addondescription.value))
	{
		alert("Please enter the addon deescription.");
		theform.addondescription.focus();
		return false;
	}
	
	if (!IsPrice(theform.addonprice.value))
	{
		alert("Please enter the price in the format XX.XX.");
		theform.addonprice.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the admin area for the colorcode module
	page:
		/admin/colorcode/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminColorCodeForm(theform)
{
	if (!IsWordNumberSpecial(theform.colorcodename.value))
	{
		alert("Please enter the color code name.");
		theform.colorcodename.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.colorcodeshortname.value))
	{
		alert("Please enter the color code short name.");
		theform.colorcodeshortname.focus();
		return false;
	}
	
	if (theform.colorcodehexvalue.value.length != 6)
	{
		alert("Please enter a valid hex value of 6 characters.");
		theform.colorcodehexvalue.focus();
		return false;
	}
		
	return true;
}



/*
	purpose:
		used in the admin area for the exchangerate module
	page:
		/admin/exchangerate/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckAdminExchangeRateForm(theform)
{
	if (!IsWordNumberSpecial(theform.exchangeratename.value))
	{
		alert("Please enter the exchange rate name.");
		theform.exchangeratename.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.exchangerateshortform.value))
	{
		alert("Please enter the exchange rate short name.");
		theform.exchangerateshortform.focus();
		return false;
	}
	
	if (!IsPrice(theform.exchangeratevalue.value))
	{
		alert("Please enter the exchange rate in the format XX.XX.");
		theform.exchangeratevalue.focus();
		return false;
	}
		
	return true;
}





/*
	purpose:
		used in the admin area for the addon module
	page:
		/admin/inventorysetup/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckAdminInventorySetupForm(theform)
{
	var day_checked=false;
	
	if (!IsWordNumberSpecial(theform.inventoryrulename.value))
	{
		alert("Please enter the inventory setup name.");
		theform.inventoryrulename.focus();
		return false;
	}
	
	if (theform.inventoryruledescription.value.length > 0)
	{
		if (!IsWordNumberSpecial(theform.inventoryruledescription.value))
		{
			alert("Please enter the description.");
			theform.inventoryruledescription.focus();
			return false;
		}
	}
	
	if (!CheckDate(theform,'inventoryrulestartdate','Start Date'))
		return false;

	if (!CheckDate(theform,'inventoryruleenddate','End Date'))
		return false;
		
	//looping over checkbox days
	for (var j=0; j<theform.inventoryrulenight.length; j++)
	{		
		if (theform.inventoryrulenight[j].checked)
			day_checked=true;
	}
	
	//make sure they selected at least one day
	if (!day_checked)
	{
		alert("Please select at least one day.");
		//theform.inventoryrulenight[0].focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the admin area for the addon module
	page:
		/admin/addon/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/
function CheckAddonForm(theform)
{
	if (!IsWordNumberSpecial(theform.addonname.value))
	{
		alert("Please enter the addon name.");
		theform.addonname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.addondescription.value))
	{
		alert("Please enter the package description.");
		theform.addondescription.focus();
		return false;
	}
	
	if (!IsPrice(theform.addonprice.value))
	{
		alert("Please enter the addon price.");
		theform.addonprice.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.addonpricelabel.value))
	{
		alert("Please enter the price label.");
		theform.addonpricelabel.focus();
		return false;
	}
	
	if (theform.addonminguest.value > theform.addonmaxguest.value) {
		alert("The Minimum Guests must be less than the Maximum Guests.");
		theform.addonminguest.focus();
		return false;
	}
		
	return true;
}



/*
	purpose:
		used in the admin area for the package module
	page:
		/admin/package/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckPackageForm(theform)
{
	if (!IsWordNumberSpecial(theform.packagename.value))
	{
		alert("Please enter the package name.");
		theform.packagename.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.packagetagline.value))
	{
		alert("Please the package tagline.");
		theform.packagetagline.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.packagedescription.value))
	{
		alert("Please the package description.");
		theform.packagedescription.focus();
		return false;
	}
	
	if (!IsPrice(theform.packageprice.value))
	{
		alert("Please enter the package price.");
		theform.packageprice.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.packagepricelabel.value))
	{
		alert("Please the package price description.");
		theform.packagepricelabel.focus();
		return false;
	}
		
	return true;
}



/*
	purpose:
		used in the admin area for the roomtype module
	page:
		/admin/roomtype/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckRoomTypeForm(theform)
{
	if (!IsWordNumberSpecial(theform.roomtypename.value))
	{
		alert("Please enter the room type name.");
		theform.roomtypename.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.roomtypeshortdescription.value))
	{
		alert("Please the room type short description.");
		theform.roomtypeshortdescription.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.roomtypedescription.value))
	{
		alert("Please the room type description.");
		theform.roomtypedescription.focus();
		return false;
	}
		
	return true;
}



/*
	purpose:
		used in the admin area for the amenity module
	page:
		/admin/amenity/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminAmenityForm(theform)
{
	if (!IsWordNumberSpecial(theform.amenityname.value))
	{
		alert("Please enter an amenity name.");
		theform.amenityname.focus();
		return false;
	}
	
	if (!IsDescription(theform.amenitydescription.value))
	{
		alert("Please enter an amenity description.");
		theform.amenitydescription.focus();
		return false;
	}
	
	return true;
}


/*
	purpose:
		used in the admin area for the guestcomment module
	page:
		/admin/guestcomment/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminGuestCommentForm(theform)
{
	if (!IsWordNumberSpecial(theform.guestcommentfirstname.value))
	{
		alert("Please enter your first name.");
		theform.guestcommentfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.guestcommentlastname.value))
	{
		alert("Please enter your last name.");
		theform.guestcommentlastname.focus();
		return false;
	}
	
		
	if (!IsWordNumberSpecial(theform.guestcommentcity.value))
	{
		alert("Please enter your city.");
		theform.guestcommentcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}
	
	if (!IsPhone(theform.guestcommentphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.guestcommentphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.guestcommentemail.value))
	{
		alert("Please enter a valid email address.");

		theform.guestcommentemail.focus();
		return false;
	}
	
		
	if (!CheckDate(theform,'guestcommentcheckindate','Check-In Date'))
		return false;

	if (!CheckDate(theform,'guestcommentcheckoutdate','Check-Out Date'))
		return false;
		
	return true;
}


/*
	purpose:
		used in the admin area for the package restriction module
	page:
		/admin/packagerestriction/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminPackageRestrictionForm(theform)
{
	if (!IsWordNumberSpecial(theform.packagerestrictionname.value))
	{
		alert("Please enter the restriction name.");
		theform.packagerestrictionname.focus();
		return false;
	}
	
	if (theform.packagerestrictiondescription.value.length > 0)
	{
		if (!IsDescription(theform.packagerestrictiondescription.value))
		{
			alert("Please enter the restriction description.");
			theform.packagerestrictiondescription.focus();
			return false;
		}
	}
		
	return true;
}


/*
	purpose:
		used in the admin area for the rate module
	page:
		/admin/rate/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminRateForm(theform)
{
	var is_checked=0;
	var min_night_booking=theform.rateminnight[theform.rateminnight.selectedIndex].value;
	var min_days_of_week=0;
	var bMinDaysMet=true;
	var bSearchingForMatch=0;
	
	
	
	if (!IsWordNumberSpecial(theform.ratename.value))
	{
		alert("Please enter the rate name.");
		theform.ratename.focus();
		return false;
	}
	
	if (theform.ratedescription.value.length > 0)
	{
		if (!IsDescription(theform.ratedescription.value))
		{
			alert("Please enter the rate description.");
			theform.ratedescription.focus();
			return false;
		}
	}
		
		
	if (!CheckDate(theform,'ratestartdate','Start Date'))
		return false;

	if (!CheckDate(theform,'rateenddate','End Date'))
		return false;
	
	if (!IsPrice(theform.rateprice.value))
	{
		alert("Please enter the rate price.");
		theform.rateprice.focus();
		return false;
	}
	
	//ensure one day is checked
	for (var i=0;i<theform.ratenight.length; i++)
	{
		if (theform.ratenight[i].checked)
			is_checked++;
	}
	
	if (is_checked == 0)
	{
		alert("Please select the days of the week for this rate.");
		theform.ratenight[0].focus();
		return false;
	}
	else
	{
		//check to see if we meet minimum night bookings
		for (var i=0;i<theform.ratenight.length; i++)
		{
			if (bMinDaysMet)
			{
				if (theform.ratenight[i].checked)
				{
					
					min_days_of_week++;
					
					//if last time through loop, final check
					if (i == (theform.ratenight.length-1))
					{
						if (min_days_of_week > 0)
						{
							if (min_days_of_week >= min_night_booking)
								min_days_of_week=0;
							else
								bMinDaysMet=false;
						}
					}	
				}
				else
				{
					if (min_days_of_week > 0)
					{
						if (min_days_of_week >= min_night_booking)
							min_days_of_week=0;
						else
							bMinDaysMet=false;

					}
				}
			}
		}
	}
	
	//if we are searchning for a match that means we havne't met the requirements
	if (!bMinDaysMet)
	{
		alert("The days selected do not meet the minimum back to back booking requirements.");
		theform.ratenight[0].focus();
		return false;
	}

	return true;
}


/*
	purpose:
		used in the admin area for the rate type module
	page:
		/admin/ratetype/module_edit.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckAdminRateTypeForm(theform)
{
	if (!IsWordNumberSpecial(theform.ratetypename.value))
	{
		alert("Please enter the rate type name.");
		theform.ratetypename.focus();
		return false;
	}
	
	if (theform.ratetypedescription.value.length > 0)
	{
		if (!IsDescription(theform.ratetypedescription.value))
		{
			alert("Please enter the rate type description.");
			theform.ratetypedescription.focus();
			return false;
		}
	}
		
		
	if (!CheckDate(theform,'ratetypestartdate','Start Date'))
		return false;

	if (!CheckDate(theform,'ratetypeenddate','End Date'))
		return false;
		
	return true;
}


/*
	purpose:
		used in the contact page
	page:
		/acclaim/guest_comment_form.cfm.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckGuestComments(theform)
{
	if (!IsWordNumberSpecial(theform.guestcommentfirstname.value))
	{
		alert("Please enter your first name.");
		theform.guestcommentfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.guestcommentlastname.value))
	{
		alert("Please enter your last name.");
		theform.guestcommentlastname.focus();
		return false;
	}
	
		
	if (!IsWordNumberSpecial(theform.guestcommentcity.value))
	{
		alert("Please enter your city.");
		theform.guestcommentcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}
	
	if (!IsPhone(theform.guestcommentphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.guestcommentphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.guestcommentemail.value))
	{
		alert("Please enter a valid email address.");
		theform.guestcommentemail.focus();
		return false;
	}
	
		
	if (!CheckDate(theform,'guestcommentcheckindate','Check-In Date'))
		return false;

	if (!CheckDate(theform,'guestcommentcheckoutdate','Check-Out Date'))
		return false;
		
	return true;
}


/*
	purpose:
		used in the contact page
	page:
		/contact/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckContactForm(theform)
{
	if (!IsWordNumberSpecial(theform.contactfirstname.value))
	{
		alert("Please enter your first name.");
		theform.contactfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactlastname.value))
	{
		alert("Please enter your last name.");
		theform.contactlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactaddress.value))
	{
		alert("Please enter your address.");
		theform.contactaddress.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactcity.value))
	{
		alert("Please enter your city.");
		theform.contactcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactpostal.value))
	{
		alert("Please enter your postal/zip code.");
		theform.contactpostal.focus();
		return false;
	}

	if (!IsPhone(theform.contactphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.contactphone.focus();
		return false;
	}
	
	if (!IsEmail(theform.contactemail.value))
	{
		alert("Please enter a valid email address.");
		theform.contactemail.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.contactmessage.value))
	{
		alert("Please enter a message.");
		theform.contactmessage.focus();
		return false;
	}

	return true;
}



/*
	purpose:
		used in the control panel
	page:
		all /module_setorder.cfm pages
	Parameters:
		theform - object reference to the form being passed
*/
function CheckDisplayOrderForm(theform)
{
	if (theform.orderlist.value <= 0)
	{
		alert("The order has not changed, no update required.");
		return false;
	}

	return true;
}


/*
	purpose:
		used in the contact page for mailing list
	page:
		/contact/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckMailingListForm(theform)
{
	if (!IsWordNumberSpecial(theform.mailinglistfirstname.value))
	{
		alert("Please enter your first name.");
		theform.mailinglistfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.mailinglistlastname.value))
	{
		alert("Please enter your last name.");
		theform.mailinglistlastname.focus();
		return false;
	}
	
	if (!IsEmail(theform.mailinglistemail.value))
	{
		alert("Please enter a valid email address.");
		theform.mailinglistemail.focus();
		return false;
	}
	
	if (theform.mailinglistemail.value != theform.mailinglistemailconfirm.value)
	{
		alert("Your email address and confirmation email address do not match.");
		theform.mailinglistemailconfirm.focus();
		return false;
	}

	return true;
}



/*
	purpose:
		used in the schedule pickup page
	page:
		/pickup/index.cfm
	Parameters:
		theform - object reference to the form being passed
*/

function CheckGuestCommentForm(theform)
{
	if (!IsWordNumberSpecial(theform.guestcommentfirstname.value))
	{
		alert("Please enter your first name.");
		theform.guestcommentfirstname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.guestcommentlastname.value))
	{
		alert("Please enter your last name.");
		theform.guestcommentlastname.focus();
		return false;
	}
	
	if (!IsWordNumberSpecial(theform.guestcommentcity.value))
	{
		alert("Please enter your city.");
		theform.guestcommentcity.focus();
		return false;
	}
	
	if (theform.stateid[theform.stateid.selectedIndex].value == "")
	{
		alert("Please select a valid state/province.");
		theform.stateid.focus();
		return false;
	}
	
	if (theform.countryid[theform.countryid.selectedIndex].value == "")
	{
		alert("Please select a valid country.");
		theform.countryid.focus();
		return false;
	}	
	
	if (!IsPhone(theform.guestcommentphone.value))
	{
		alert("Please enter a valid phone number.");
		theform.guestcommentphone.focus();
		return false;
	}
		
	if (!IsEmail(theform.guestcommentemail.value))
	{
		alert("Please enter a valid email address.");
		theform.guestcommentemail.focus();
		return false;
	}
	
	if (!CheckInDate(theform,"checkindate","Check-In Date"))
		return false;
		
	if (!CheckOutDate(theform,"checkoutdate","Check-Out Date"))
	return false;
		
	if (!IsEmail(theform.guestcommentmessage.value))
	{
		alert("Please enter your comments.");
		theform.guestcommentmessage.focus();
		return false;
	}
	
	theform.submit();
	//return true;
}


/*
	purpose:
		used in the control panel
	page:
		main control panel login page
	Parameters:
		theform - object reference to the form being passed
*/
function CheckLoginForm(theform)
{

	if (!IsUsername(theform.username.value))
	{
		alert("Please enter a valid username. (MIN. 5 characters)");
		theform.username.focus();
		return false;
	}

	if (!IsPassword(theform.password.value))
	{
		alert("Please enter a valid password. (MIN. 5 characters)");
		theform.password.focus();
		return false;
	}

	return true;
}


