
function my_validate_form() 
{
	if(document.getElementById("question_1").value.length == 0) 
	{
		alert("Please make sure you fill up the form correctly.");
		temp = document.getElementById("question_1").name;
		eval("document.main_form."+temp+".focus()");
		return false;
	}
	
	temp = document.getElementById("question_1").name;
	if(eval("check_email(document.main_form."+temp+".value)") == false) 
	{
		alert("Please enter a valid email address.");
		eval("document.main_form."+temp+".focus()");
		return false;
	}
	/*	
	temp = document.getElementById("question_1").name;
	temp2 = eval("remove_newlines_and_trim_spaces(document.main_form."+temp+".value)");
	temp3 = eval("document.main_form."+temp);
	temp3.value = temp2;
	document.main_form.submit();*/
	return true;
}


function remove_newlines(inputString) {
			rExp = /\r\n|\r/g;
			result = inputString.replace(rExp, " ");
			return result;
		}
		function trim_spaces(inputString) {
			if (typeof inputString != "string") {
				return inputString;
			}
			var retValue = inputString;
			var ch = retValue.substring(0, 1);
			while (ch == " ") { 
				retValue = retValue.substring(1, retValue.length);
				ch = retValue.substring(0, 1);
			}
			ch = retValue.substring(retValue.length-1, retValue.length);
			while (ch == " ") { 
				retValue = retValue.substring(0, retValue.length-1);
				ch = retValue.substring(retValue.length-1, retValue.length);
			}
			while (retValue.indexOf("  ") != -1) { 
				retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
			}
			return retValue; 
		}
		function remove_newlines_and_trim_spaces(inputString) {
			if (typeof inputString != "string") {
				rExp = /\r\n|\r/g;
				result = inputString.replace(rExp, " ");
				return result;
			}
			var retValue = inputString;
			var ch = retValue.substring(0, 1);
			while (ch == " ") { 
				retValue = retValue.substring(1, retValue.length);
				ch = retValue.substring(0, 1);
			}
			ch = retValue.substring(retValue.length-1, retValue.length);
			while (ch == " ") { 
				retValue = retValue.substring(0, retValue.length-1);
				ch = retValue.substring(retValue.length-1, retValue.length);
			}
			while (retValue.indexOf("  ") != -1) { 
				retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
			}
			rExp = /\r\n|\r/g;
			result = retValue.replace(rExp, " ");
			return result; 
		}
		function check_email(inputString)
		{
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			if (!filter.test(inputString)) {
				return false;
			}
			return true;
		}
		function check_digit(inputString) {
			isPrice = /^\d+\.{0,1}\d*$/;
			return isPrice.test(inputString);
		}


		function check_currency(inputString) {
			isCurrency = /^\$\d+\.{0,1}\d*$/;
			return isCurrency.test(inputString);
		}
		function check_word_only(inputString) {
			isAlphaNumeric = /^[A-Za-z0-9]*$/;
			return isAlphaNumeric.test(inputString);
		}