function MM_validateForm() 
{ 
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	var focusitem ='';
	j=0;
	//	/^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)$/;
	var regEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var regBlank = /[^\s]/;
	//var regAlphaNum = /^([a-zA-Z0-9_]+)$/;
	var regAlphaNum = /^([a-zA-Z0-9-/_ :;#!@\n\r.,$*&%?^~`=+(){}\[\]\"\'\\]+)$/;
	var regDate = /^([0-9_]+-[0-9][0-9]+-[0-9][0-9]+)$/;
	
	//alert (MM_validateForm.arguments[1].name);
	//alert("sss--->"+document.forms[""+args[0]].elements[""+args[0]].value);
	for (i=1; i<(args.length-2); i+=3) 
	{	
		mesg=args[i+1];
		test=args[i+2]; 
		val=document.forms[""+args[0]].elements[""+args[i]];
			
		    if (val) 
		{	nm=mesg; 
			
			val = val.value;
			//if ((val=val.value)!="") 
			if(regBlank.test(val))
			{
				if(test.indexOf('isEqual')!=-1)
				{
					result = trim(val);
				if(result.length==0){
				errors += '- '+nm+' is required.\n'; 
				}else{
					equal_obj_val = test.substring(8,test.indexOf(":"));
					mesg_string =test.substring((test.indexOf(":")+1));
					if(val != document.forms[""+args[0]].elements[""+equal_obj_val].value)
					{
						errors+='- '+nm+' must be same to '+mesg_string+'.\n';
					}
				}
				}
				else if(test.indexOf('isAlphaNum')!=-1)
				{
				result = trim(val);
				if(result.length==0){
				errors += '- '+nm+' is required.\n'; 
				}else{
					if(!regAlphaNum.test(val))
					{
						errors+='- '+nm+': Only Alpha Numeric and "_ , . - ! @ # () {} [] " coma,  single cots and Chars Allowed.\n';
					}
				}
				}
				else if (test.indexOf('isDate')!=-1) 
				{ 
					p=val.indexOf('-');
			        
					if (p != 4 )
					{
						errors+='- '+nm+' must contain Valid Date YYYY-MM-DD.\n';
		
					}
					else if(!regDate.test(val))
					{
						errors+='- '+nm+' must contain Valid Date YYYY-MM-DD.\n';
					}
			     }
				else if (test.indexOf('isEmail')!=-1) 
				{ 
					p=val.indexOf('@');
					s=val.indexOf('.');
			        if (p<1 || p==(val.length-1))
					{
						errors+='- '+nm+' must contain an e-mail Address.\n';
		
					}
					//else if(s<p || s==(val.length-1))
					else if(!regEmail.test(val))
					{
						errors+='- '+nm+' must contain a valid e-mail Address.\n';
					}
			     }
				else if (test.indexOf('isUrl')!=-1) 
				{ 
					p=val.indexOf('http://');
					s=val.indexOf('.');
			        if (p<0 || p==(val.length-1))
					{
						errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
		
					}
					else if(s<p || s==(val.length-1))
					{
						errors+='- '+nm+' must be valid URL e.g. http://www.abc.com\n';
					}
			     }else if (test.indexOf('isChar')!=-1) 
				 { 
					var first_char;
					first_char= val.charAt(0);
					if(first_char==0||first_char==1||first_char==2||first_char==3||first_char==4||first_char==5||first_char==6||first_char==7||first_char==8||first_char==9){
					 errors+='- '+nm+' must starts with  a char.\n';
					}
			     }
	   			 else if (test!='R') 
				 {
				 result = trim(val);
					if(result.length==0){
					errors += '- '+nm+' is required.\n'; 
					}
				    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) 
					{ num = parseFloat(val);
						p=test.indexOf(':');
						min=test.substring(8,p); 
						max=test.substring(p+1);
						if (num<min || max<num) 
						errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					} 
					if (val.indexOf('-') != -1) 
					{ 
						errors+='- '+nm+' must contain a number without dashes sign.\n';
					} 
					if (val.indexOf('+') != -1) 
					{ 
						errors+='- '+nm+' must contain a number without plus sign.\n';
					}	
					

					
				}else if (test.charAt(0)=='R')
				{
				result = trim(val);
				if(result.length==0){
				errors += '- '+nm+' is required.\n'; 
				}
				} 
				/*else if (test.charAt(0)=='R')
				{
				result = trim(val);
				if(result.length==0){
				errors += '- '+nm+' Im sorry, the monthly contribution must be at least $30.00. Please re-enter a monthly amount.\n'; 
				}
				} */
			}
			else if (test.charAt(0) == 'R'){
				errors += '- '+nm+' is required.\n'; 
			} /*else if(document.getElementById("amount1").value < 30){
						errors+='- Im sorry, the monthly contribution\n   must be at least $30.00.\n   Please re-enter a monthly amount.\n';
		//alert(document.getElementById("amount1").value);return false;
	}*/
		}
		if(errors !="")
		{	if(j<=0)
			{
				
				focusitem = document.forms[""+args[0]].elements[""+args[i]];
				j++;
			}	
			
		}
	} 
	
//return errors;
if(document.getElementById("amount1").value < 30){
						errors+='- Im sorry, the monthly contribution\n   must be at least $30.00.\n   Please re-enter a monthly amount.\n';
						//focusitem = document.getElementById("amount1");
		//alert(document.getElementById("amount1").value);return false;
	} 
  if (errors)
  {
	alert('The following error(s) occurred:\n\n'+errors);
	if(focusitem!='') {
		focusitem.focus();
	}
	return false;
   }
   else
	return true;

//  document.MM_returnValue = (errors == '');
	
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

//CODE FOR RECURRENCE STUFF



function chk_guestbook_form(formname)
{ 
	//if(document.guestbookname.gst_country.value!="213" && document.guestbookname.otherstate.value=="")
	if(document.guestbookname.gst_country.value!="213")
	{
	   if(MM_validateForm(formname,'gst_firstname','First Name','RisAlphaNum','gst_lastname','Last Name','RisAlphaNum','gst_email','Email','RisEmail', 'gst_city', 'City', 'RisAlphaNum', 'gst_comment','Comment','RisAlphaNum','gst_postal_address','Address','RisAlphaNum'))
	{

		return true;
		
	} else {

		return false;
		
	}
	}else	
	{
	if(MM_validateForm(formname,'gst_firstname','First Name','RisAlphaNum','gst_lastname','Last Name','RisAlphaNum','gst_email','Email','RisEmail', 'gst_state','State','R', 'gst_city', 'City', 'RisAlphaNum','gst_comment','Comment','RisAlphaNum','gst_postal_address','Address','RisAlphaNum'))
	{

		return true;
		
	} else {

		return false;
		
	}
	
}
}

function chkformsub(formname)
{ 
	if(MM_validateForm(formname,'sub_email','Email','RisEmail'))
	{

		return true;
		
	} else {

		return false;
		
	}
}

function chkprayerform(formname)
{
	if(MM_validateForm(formname,'prayerer_name','Name','RisAlphaNum','prayerer_email','Email','RisEmail','prayerer_description','Prayer Request','RisAlphaNum','month','Month','R','day','Day','R','year','Year','R'))
	{

		return true;
		
	} else {

		return false;
		
	}
}

function chkcontactform(formname)
{
  	
	//if(document.contactform.cnt_country.value!="213" && document.contactform.otherstate.value=="")
	if(document.contactform.cnt_country.value!="213")
	{
		if(MM_validateForm(formname,'name','Name','RisAlphaNum','email','Email','RisEmail','address1','Postal Address','RisAlphaNum','city','City','RisAlphaNum','zipecode','Zip  code','RisNaN','cnt_country','Country','R','comments','Feedback','RisAlphaNum'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	}	
	
	if(MM_validateForm(formname,'name','Name','RisAlphaNum','email','Email','RisEmail','address1','Postal Address','RisAlphaNum','cnt_state','State','R','city','City','RisAlphaNum','zipecode','Zip  code','RisNaN','cnt_country','Country','R','comments','Feedback','RisAlphaNum'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	 
}
function chkdonateform(formname)
{
  	//if(document.donateform.country.value!="213" && document.donateform.otherstate.value=="")
	if(document.donateform.country.value!="213")
	{
	    if(MM_validateForm(formname,'amount','Amount','RisNaN','name_on_card','Name on card','RisAlphaNum','credit_card_no','Credit card no','RisNaN','expiry_month','Expiry month','R','expiry_year','Expiry year','R','name','Name','RisAlphaNum','address','Address','RisAlphaNum','city','City','RisAlphaNum','zip','Zip  code','RisNaN','email','Email','RisEmail'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	}else	
	{
	if(MM_validateForm(formname,'amount','Amount','RisNaN','name_on_card','Name on card','RisAlphaNum','credit_card_no','Credit card no','RisNaN','expiry_month','Expiry month','R','expiry_year','Expiry year','R','name','Name','RisAlphaNum','address','Address','RisAlphaNum','state','State','R','city','City','RisAlphaNum','zip','Zip  code','RisNaN','email','Email','RisEmail'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	} 
}
function sistercontactform(formname)
{
//if(document.contactform.country.value!="213" && document.contactform.otherstate.value=="")
if(document.contactform.country.value!="213")
	{
	   if(MM_validateForm(formname,'name','Name','RisAlphaNum','address','Address','RisAlphaNum','city','City','RisAlphaNum','zip','Zip code','RisNaN','phone','Phone','RisAlphaNum','email','Email','RisEmail','comments','Comment','isAlphaNum','name_on_card','Name on card','RisAlphaNum','credit_card_no','credit card no','R'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	}else	
	{	if(MM_validateForm(formname,'name','Name','RisAlphaNum','address','Address','RisAlphaNum','state','State','RisAlphaNum','city','City','RisAlphaNum','zip','Zip code','RisNaN','phone','Phone','RisAlphaNum','email','Email','RisEmail' ,'comments','Comment','isAlphaNum','name_on_card','Name on card','RisAlphaNum','credit_card_no','credit card no','R'))
	{

		return true;
		
	} else {

		return false;
		
	}
}
}
function purificationcontactform(formname)
{
//if(document.contactform.cnt_country.value!="213" && document.contactform.otherstate.value=="")
if(document.contactform.cnt_country.value!="213")
	{
	    if(MM_validateForm(formname,'name','Name','RisAlphaNum','address','Address','RisAlphaNum','city','City','RisAlphaNum','zip','Zip code','R','home_phone','Phone','RisAlphaNum','email','Email','RisEmail','name_on_card','Name on card','RisAlphaNum','credit_card_no','Credit card no','RisNaN','expiry_month','Expiry month','R','expiry_year','Expiry year','R'))
	{

		return true;
		
	} else {

		return false;
		
	}
	}else	
	{	if(MM_validateForm(formname,'name','Name','RisAlphaNum','address','Address','RisAlphaNum','state','State','R','city','City','RisAlphaNum','zip','Zip code','R','home_phone','Phone','RisAlphaNum', 'email','Email','RisEmail','name_on_card','Name on card','RisAlphaNum','credit_card_no','Credit card no','RisNaN','expiry_month','Expiry month','R','expiry_year','Expiry year','R'))
	{

		return true;
		
	} else {

		return false;
		
	}
}
}
function chk_regfome(formname)
{
	//if(document.bookingform.book_org_county.value!="213" && document.bookingform.otherstate.value=="")
	if(document.bookingform.book_org_county.value!="213")
	{
	    ///if(MM_validateForm(formname,'book_name','Name','R','book_email','Email','RisEmail','book_day_phone','book day phone','R','book_city','City','R','book_zip_code','Zip Code','R','Book_church_org','Church Organizor','R','book_type_service','Service','R','book_org_street_address','Street address','R','book_org_city','Organizor City','R','book_org_county','County','R','book_org_zip','Zip code','RisNaN','month','Month','R','day','Day','R','year','Year','R'))
	if(MM_validateForm(formname,'book_name','Name','RisAlphaNum','book_email','Email','RisEmail','book_day_phone','book day phone','RisAlphaNum','book_city','City','RisAlphaNum','book_zip_code','Zip Code','RisNaN','Book_church_org','Church Organizor','R','book_type_service','Service','R','book_org_street_address','Street address','RisAlphaNum','book_org_city','Organizor City','RisAlphaNum','book_org_county','County','R','book_org_zip','Zip code','RisNaN'))

	
	{


		return true;
		
	} else {

		return false;
		
	}
	}else	
	{
	///if(MM_validateForm(formname,'book_name','Name','R','book_email','Email','RisEmail','book_day_phone','book day phone','R','book_city','City','R','book_zip_code','Zip Code','R','Book_church_org','Church Organizor','R','book_type_service','Service','R','book_org_street_address','Street address','R','book_org_city','Organizor City','R','book_org_county','County','R','book_org_zip','Zip code','RisNaN','book_org_state','State Organizor','R','month','Month','R','day','Day','R','year','Year','R'))
	if(MM_validateForm(formname,'book_name','Name','RisAlphaNum','book_email','Email','RisEmail','book_day_phone','book day phone','RisAlphaNum','book_city','City','RisAlphaNum','book_zip_code','Zip Code','R','Book_church_org','Church Organizor','RisAlphaNum','book_type_service','Service','R','book_org_street_address','Street address','RisAlphaNum','book_org_city','Organizor City','RisAlphaNum','book_org_county','County','R','book_org_zip','Zip code','RisNaN'))
	
	{

		return true;
		
	} else {

		return false;
		
	}
}
}

function chkconfform(formname)
{
	//if(document.confrenceform.country.value!="213" && document.confrenceform.otherstate.value=="")
	if(document.confrenceform.country.value!="213")
	{
	    if(MM_validateForm(formname,'no_of_attendee','Number of Attendee','R','name','Name','RisAlphaNum','city','City','RisAlphaNum','zip','Zip code','RisNaN','email','Email','RisEmail'))
	{

		return true;
		
	} else {

		return false;
		
	} 
	}else	
	{
	if(MM_validateForm(formname,'no_of_attendee','Number of Attendee','R','name','Name','RisAlphaNum','state','State','R','city','City','RisAlphaNum','zip','Zip code','RisNaN','email','Email','RisEmail'))
	{

		return true;
		
	} else {

		return false;
		
	}
}
}

// forum validation functions


function chk_frmpost(formname)
{
	if(MM_validateForm(formname,'confirmation_number','Confirmation Number' , 'R', 'f_cat_id', 'Category', 'R', 'topic_title', 'Title', 'RisAlphaNum'))
	{
		return true;
		
	} else {

		return false;
		
	} 
	
}