	function validate_this(formname) {
	         the_error = '';
		 testform = eval("document."+formname);
		 for(i=0;i<testform.elements.length;i++) {
		 	if((testform.elements[i].value.search(/^R/)!=-1)&&(testform.elements[i].name.search(/^q/i)!=-1)) {
                                testanswer = testform.elements[i].name.replace(/q/,"a");
                                the_question = testform.elements[i].value.replace(/^.*:::/,"");
                                tmp_type = testform.elements[i].value.replace(/:::.*/,"");
                                answer_type = tmp_type.replace(/^R,/,"");
		 		answer_name = testform.elements[testanswer].name;
		 		not_found = 0;
		 		if((answer_type=="T")||(answer_type=="A")||(answer_type=="O")) {
                       if(testform.elements[testanswer].value=='') {
					  not_found++;
                       }
		 		}
				

		 		else if(answer_type=="R") {
		 		     checkbox_test = 0;
		 		     for(j=0;j<testform.elements[testanswer].length;j++) {
					  if(testform.elements[testanswer][j].checked) {
					        checkbox_test++;
					  }
		 		     }
		 		     if(checkbox_test==0) {
		 		          not_found++;
		 		     }
		 		}
		 		else if(answer_type=="S") {
		 		     if(testform.elements[testanswer].options[testform.elements[testanswer].options.selectedIndex].value=='') {
					  not_found++;
		 		     }
		 		}
		 		else if(answer_type=="M") {
		 		     select_test = 0;
		 		     for(j=0;j<testform.elements[testanswer].options.length;j++) {
					  if(testform.elements[testanswer].options[j].selected) {
					        select_test++;
					  }
		 		     }
		 		     if(select_test==0) {
		 		          not_found++;
		 		     }
		 		}
		 		else if(answer_type=="C") {
		 		     checkbox_test = 0; checkbox_values = '';
		 		     for(j=0;j<testform.elements[testanswer].length;j++) {
					  if(testform.elements[testanswer][j].checked) {
					        checkbox_test++;
					        checkbox_values += testform.elements[testanswer][j].value+",";
					  }
		 		     }
		 		     if(checkbox_test==0) {
		 		          not_found++;
		 		     }
		 		     else {
				     	all_answers = checkbox_values.substr(0,checkbox_values.length-1);
		 		     	for(j=0;j<testform.elements[testanswer].length;j++) {
 						testform.elements[testanswer][j].value = all_answers;
				      	}
		 		     }
		 		}
		 		if(not_found>0) {
					if(the_question=="adarea") {the_question="Area Code";}
					if(the_question=="adphone") {the_question="Phone Number";}
					if(the_question=="Email Address") {the_question="Invalid Email Address";}
				the_error += the_question+"\n";
				}
		 	}
		 	else if((testform.elements[i].value.search(/,C/)!=-1)&&(testform.elements[i].name.search(/^q/i)!=-1)) {
                                testanswer = testform.elements[i].name.replace(/q/,"a");
                                the_question = testform.elements[i].value.replace(/^.*:::/,"");
                                tmp_type = testform.elements[i].value.replace(/:::.*/,"");
                                answer_type = tmp_type.replace(/^R,/,"");
		 		answer_name = testform.elements[testanswer].name;
				 checkbox_test = 0; checkbox_values = '';
				 for(j=0;j<testform.elements[testanswer].length;j++) {
				 	if(testform.elements[testanswer][j].checked) {
						checkbox_test++;
					        checkbox_values += testform.elements[testanswer][j].value+",";
					}
		 		     }
		 		     if(checkbox_test>0) {
				     	all_answers = checkbox_values.substr(0,checkbox_values.length-1);
		 		     	for(j=0;j<testform.elements[testanswer].length;j++) {
 						testform.elements[testanswer][j].value = all_answers;
				      	}
		 		     }
	 		}

		 }
		 if(!check_email(testform.a4.value)){
			alert("You have entered an invalid email.");
			testform.a4.focus(); 
			if(document.all || document.getElementByID){
				testform.a4.style.background = "yellow";
			}
			return false;
		}
		 if(the_error!='') {
		      alert("Please provide the following:\n"+the_error);
                      return false;
                 }
                 else {
                      return true;
                 }
		if (Warranty.a13.value.length > 2048) {
			alert('Your input has been truncated! There is a limit of 2048 characters.');
			Warranty.a13.focus()
			 return false;
		} 
		return true
	}


function textLimit(field, maxlen) {
		if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
		alert('Your input has been truncated! There is a limit of 2048 characters.');
		} 
}

	function check_email(e) {
		ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

		for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
		return (false);
		}	
		} 

		if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
		return (-1);		
		} 

		}

	}
		