<!--

// Function to check if a field string is empty
	
	function isEmptyField(srcField) {
		srcText = srcField.value;
		srcText = srcText.replace(/^\s+/g, '').replace(/\s+$/g, '');
		if(srcText == "") {
			srcField.value = "";
			return true;
		} else return false;
	}

// header search form

	var initialSearchText = "Quick search";

	function enterHeaderSearchText(srcField) {
		if(srcField.value == initialSearchText) srcField.value = "";
	}

	function exitHeaderSearchText(srcField) {
		if(isEmptyField(srcField)) srcField.value = initialSearchText;
	}

	function checkSearchForm() {
		srcField = document.getElementById("headerSearchText");
		if(isEmptyField(srcField) || srcField.value == initialSearchText) {
			alert("You need to enter something to search for!");
			return false;
		} else return true;
	}

// Print function

	function printPage() {
		if(window.print) {
			window.print();
		} else {
			alert("Your browser does not support the javascript 'print' function.\nPlease use your operating system's print menu to print this page.")
		}
		return false;
	}
	
	
// Image size checking + resizing

	function checkImageSize(srcImage,maxWidth,maxHeight) {
		if(document.images) {
			getWidth = srcImage.width;
			getHeight = srcImage.height;
			if(getWidth>maxWidth || getHeight>maxHeight) {
				widthVariance = maxWidth/getWidth;
				heightVariance = maxHeight/getHeight;
				if(widthVariance<=heightVariance) scalePercentage = getWidth/maxWidth;
				else scalePercentage = getHeight/maxHeight;
				srcImage.width = getWidth/scalePercentage;
				srcImage.height = getHeight/scalePercentage;
			}
		}
	}
	
	
// Email address validation
		
	function isValidEmail(src) {
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(src);
	}

//-->

