function MM_validateForm() { //v4.0
  	if (document.getElementById){
    	var i,p,q,nm,name,test,num,min,max,val,errors='',args=MM_validateForm.arguments;
    	var controls, IsOK, IsErr;
    
		for (i=0; i<(args.length-2); i+=3) { 
			test=args[i+2]; 
			val = document.getElementById(args[i]);
			if (val) 
			{
				controls = new Array(); 
				controls[0] = val;
			}
			else
			{
				controls = document.getElementsByName(args[i]);
			}
   
			IsOK = 0;
			IsErr = 0;
			for (c=0; c < controls.length; c++)
			{
     			val = controls[c];
				//regular value
				if (val) { 
					nm=val.name;
					if ((val = val.value) != "") 
					{
						//alert(nm + ' ' + test);
						//email value
						if (test.indexOf('isEmail') != -1) { p=val.indexOf('@');
		          			//email value output
							if (p < 1 || p == (val.length - 1)) 
							{
								IsErr++;
								errors+='- '+nm+' must contain an e-mail address.\n';
							}
							else
							{
								IsOK++;	
							}							
		        		} 
		        		else if (test=='R')
		        		{
		        			IsOK++;  //Everything is OK		        			
		        		}
		        		else if(test=='1')
		        		{
		        			//alert('hi');
		        			if(document.getElementsByName(args[i])[c].checked)
		        			{
		        				IsOK++;
		        			}
		        			else
		        			{
		        				IsErr++;
		        			}       			
		        		}
						else if(test == 'RisNum') 
						{ 
							num = parseFloat(val);
		          			//number value output
							if (isNaN(val)) 
							{
								errors+='- '+nm+' must contain a number.\n';
								IsErr++;
							}
							else
							{
								IsOK++;								
							}
						}
						else if (test.indexOf('inRange') != -1) //range value
						{ 
							num = parseFloat(val);
							p=test.indexOf(':');
		            		min=test.substring(8,p); 
		            		max=test.substring(p+1);
		            		//range value output
							if (!isNaN(val) && (num < min || max < num)) 
							{
								IsErr++;
								errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
							}
							else
							{
								isOK++;												
							}							
		      			}//end of range value 
					} 
					else if (test.charAt(0) == 'R')
					{
						IsErr++;
						errors += '- '+nm+' is required.\n'; 	
					}
					
					 /*
					else if (test=='B') 
						{ 
							var total="";
							for(var i=0; i < document.frm_add_subscribe_1.productinterest.length; i++){
								if(document.frm_add_subscribe_1.productinterest[i].checked)
								{
									total = total + document.frm_add_subscribe_1.productinterest[i].value;
								}
							}
							if (total == "")
							{
								errors += '- Productinterest is required.\n'; 
							}
							errors += '- Productinterest is required.\n';
						} */
				}//end of regular value
				//alert(nm + '('+ test +')=' + IsOK + '/' + IsErr);
	    
    		}//end second for
    		
    		//Check Aggrigates such as checkboxes and radio buttons.
			if (test.charAt(0) == '1')
			{
				//alert(test + ' ' + IsOK + '/' + IsErr);
				if (IsOK < 1)
				{
					errors += '- '+nm+' must have at least one selection.\n'; 							
				}
			}
			else if (test == 'All')
			{
				if (IsErr > 0)
				{
					errors += '- '+nm+' must have at all selected.\n'; 			
				}				
			}

		}//end of for 
		
		if (errors) alert('The following error(s) occurred:\n'+errors);
    
		document.MM_returnValue = (errors == '');
	}//end of if
}//end of function
