/* swap stylesheet */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/* validate contact us enquiry form */
function validateContactUs(oForm) {
	var bValid = true;

	//check for security code
	if (oForm.code.value.length < 4) {
		alert('Please enter the security code');
		return false;
	}

	//check email
	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address');
		return false;
	}

	//check normal form
	if (oForm.name.value == '' ||
		oForm.email.value == '' ||
		oForm.telephone.value == '' ||
		oForm.otherInfo.value == '') {
		bValid = false;
	}

	//return correctly
	if (bValid == false) {
		alert('Please fill out all fields');
		return false;
	}

	return true;
}

/* validate the email field */
function validateEmail(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) { return false; }
		else { return true; }
	}
}

			var initialsubj="This may interest you - Hereford Osteopaths"
			var initialmsg="Hi:\n You may want to check out this site: "+window.location
			var good;
			function checkEmailAddress(field) {
			
			var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
			if (goodEmail) {
			good = true;
			}
			else {
			alert('Please enter a valid address.');
			field.focus();
			field.select();
			good = false;
			   }
			}
			u = window.location;
			function mailThisUrl() {
			good = false
			checkEmailAddress(document.eMailer.email);
			if (good) {
			
			window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+initialmsg
			   }
			}


