﻿jQuery.fn.ValidEmail = function (email) {
	var re = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
	return email.match(re) == null ? true : false;
}

// function to restrict a textbox to only numeric characters, backspace, arrows, and tab
jQuery.fn.ForceNumericOnly = function () {
	return this.each(function () {
		$(this).keydown(function (event) {
			if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)) // 0-9 or numpad 0-9 
				return;
			else {
				if (event.keyCode != 8 && event.keyCode != 46 && event.keyCode != 37 && event.keyCode != 39 && event.keyCode != 9) // not esc, del, left or right, and tab
				{
					event.preventDefault();
				}
			}
			// else the key should be handled normally 
		});
	})
};

// For any image requiring a change on mouseover, use this function and assign "MouseoverImage" CSS class to the image.
jQuery(function () {
	$(".MouseOverImage").hover(
    function () { this.src = this.src.replace("_off", "_over"); },
    function () { this.src = this.src.replace("_over", "_off"); }
);
});
