		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);
		}

		function highlight(field, is_error) {
			style_name = "no_error";
			if (parseInt(is_error)==1) {
				style_name = "error";
			}
			field.setAttribute((document.all ? "className" : "class"),style_name); 
			return true;
		}
  function validate_form() {
					 	var error_count = 0;
					 	var error_questions = "";
					 	var set_focus_field_id = "";
					 
								if(document.getElementById("question_1")) {
									highlight(document.getElementById("question_1"), "0");
								}
					if(document.getElementById("question_1").value.length == 0) {
						highlight(document.getElementById("question_1"),"1");
						error_questions += "Answer can not be empty for Email Address\n"; 
						temp = document.getElementById("question_1").name;
						if (set_focus_field_id.length == 0) {
							set_focus_field_id = "question_1";	
						}
						error_count++;
					}
				
						temp = document.getElementById("question_1").name;
						if(document.getElementById("question_1").value.length>0  && eval("check_email(document.main_form."+temp+".value)") == false) {
							error_questions += "Invalid email for Email Address\n"; 
							if (set_focus_field_id.length == 0) {
								set_focus_field_id = "question_1";	
							}
							highlight(document.getElementById("question_1"),"1");
							error_count++;
						}
					
					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;
				 
								if(document.getElementById("question_2")) {
									highlight(document.getElementById("question_2"), "0");
								}
					if(document.getElementById("question_2").value.length == 0) {
						highlight(document.getElementById("question_2"),"1");
						error_questions += "Answer can not be empty for Title\n"; 
						temp = document.getElementById("question_2").name;
						if (set_focus_field_id.length == 0) {
							set_focus_field_id = "question_2";	
						}
						error_count++;
					}
				 
								if(document.getElementById("question_3")) {
									highlight(document.getElementById("question_3"), "0");
								}
					if(document.getElementById("question_3").value.length == 0) {
						highlight(document.getElementById("question_3"),"1");
						error_questions += "Answer can not be empty for First Name\n"; 
						temp = document.getElementById("question_3").name;
						if (set_focus_field_id.length == 0) {
							set_focus_field_id = "question_3";	
						}
						error_count++;
					}
				 
								if(document.getElementById("question_4")) {
									highlight(document.getElementById("question_4"), "0");
								}
					if(document.getElementById("question_4").value.length == 0) {
						highlight(document.getElementById("question_4"),"1");
						error_questions += "Answer can not be empty for Surname\n"; 
						temp = document.getElementById("question_4").name;
						if (set_focus_field_id.length == 0) {
							set_focus_field_id = "question_4";	
						}
						error_count++;
					}
				 
								if(document.getElementById("question_5")) {
									highlight(document.getElementById("question_5"), "0");
								}
			if (error_count > 0) {
				if (set_focus_field_id.length>0 && document.getElementById(set_focus_field_id)) {
					eval(document.getElementById(set_focus_field_id).focus());
				}
				alert ("Please fill the form correctly\n\n"+error_questions);
				return false;
			}
				document.main_form.submit();
}