// validate email field and use jquery to display simple error reponses
function validateEmail(emailAddress, responseSelector) {
	if (emailAddress == "") {
		//$(responseSelector).display = 'block';
		$(responseSelector).html("<p>You must enter an email address.</p>");
		return false;
	}
	var atpos=emailAddress.indexOf("@");
	var dotpos=emailAddress.lastIndexOf(".");
	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailAddress.length) {
		//$(responseSelector).display = 'block';
		$(responseSelector).html("<p>'" + emailAddress + "' is not a valid e-mail address. Try again.</p>");
		return false;
	} else {
		return true;
	}
} // validateEmail

// setViewportPositionAndShow
function setViewportPositionAndShow(elementSelector) {
	$(elementSelector).css({
		top:	getPageScroll()[1] + (getPageHeight() / 10),
		left:	$(window).width() / 2 - 205
	}).show();
}
	
// getPageScroll() by quirksmode.com
function getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
	  yScroll = self.pageYOffset;
	  xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
	  yScroll = document.documentElement.scrollTop;
	  xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
	  yScroll = document.body.scrollTop;
	  xScroll = document.body.scrollLeft;
	}
	return new Array(xScroll,yScroll)
}

// Adapted from getPageSize() by quirksmode.com
function getPageHeight() {
	var windowHeight
	if (self.innerHeight) {	// all except Explorer
	  windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	  windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
	  windowHeight = document.body.clientHeight;
	}
	return windowHeight
}



