sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function newwin(lnk) {
	window.open(lnk.href, 'newwindow','toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');
	return false;
}

function twochar(item) {
	if(item.length < 2) { return "0" + item; }
	else if(item.length > 2) { return item.substring(0); }
	else { return item; }
}

function setdate(frm) {
	with(frm) {
		// Parse each variable into an integer
		var month = parseInt(datemonth.value);
		var days = parseInt(dateday.value);
		var years = parseInt(dateyear.value);
		var nights = parseInt(number_Nights.value);
		
		// Set the caps on a per month basis
		if(month == '02') { var cap = 28; }
		else if(month == '04' || month == '07' || month == '09' || month == '11') { var cap = 30; }
		else { cap = 31; }
		
		// Calculate the total number of days
		var total = days + nights;
		
		// If the booked days are greater than the month can contain
		if((days + nights) > cap) {
			// The day is too late - increment the month
			if((month + 1) > 12) {
				// The month is 13 so increment the year & set the days
				month = 1;
				days = total - cap;
				years = years + 1;
			} else {
				// Increment the month & set the days
				month = month + 1;
				days = total - cap;
			}
		} else {
			// Set the days as the total stayed
			days = total;
		}
		
		// Set the full check in & check out dates
		checkInFullDate.value = twochar(datemonth.value) + '/' + twochar(dateday.value) + '/' + twochar(dateyear.value);
		checkOutFullDate.value = twochar(month.toString()) + '/' + twochar(days.toString()) + '/' + twochar(years.toString());
	}
}


function chkF(field,alerttxt,reject){
	with (field) {
		if (value==null||value==""||value==reject){
			alert(alerttxt);
			return false
		} else { return true }
	}
}

function chkE(field,alerttxt){
	with (field){
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
			  {alert(alerttxt);return false}
		else {return true}
	}
}

function offersform(thisForm) {
	with (thisForm){
		if (chkE(emailOffers,"Sorry that isn't a valid Email Address")==false){
			emailOffers.focus();
			return false
		}
	}
}