function trimAll(sString){    	while (sString.substring(0,1) == ' '){        sString = sString.substring(1, sString.length);    }    	while (sString.substring(sString.length-1, sString.length) == ' '){        sString = sString.substring(0,sString.length-1);    }    	return sString;}		/* Function for email check. */	function echeck(str) {			var at="@";	var dot=".";			var lat=str.indexOf(at);			var lstr=str.length;			var ldot=str.indexOf(dot);			var lastdot=str.lastIndexOf(dot);		    			temp = (str.substring(lastdot+1,lstr));			if (str.indexOf(at)==-1){	  		return false;	}				if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){	  		return false;	}			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){	  		return false;	}			if (str.indexOf(at,(lat+1))!=-1){	  		return false;	}				if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){	  		return false;	}				if (str.indexOf(dot,(lat+2))==-1){	  		return false;	}				if (str.indexOf(" ")!=-1){	  		return false;	}	if(isNaN(temp))	{    		return true;  }  	else  {    return false;  } 			return true	;				}function registration_form_validation(){			var fname = document.getElementById('fname').value;				var lname = document.getElementById('lname').value;						/*var namep = document.getElementById('namep').value;*/				var street_address1 = document.getElementById('street_address1').value;				var street_address2 = document.getElementById('street_address2').value;				var city = document.getElementById('city').value;				var state = document.getElementById('state').value;				var postal_code = document.getElementById('postal_code').value;				var country = document.getElementById('country').value;				var phone_number = document.getElementById('phone_number').value;				var email = document.getElementById('email').value;  			var purchaser_phn = document.getElementById('purchaser_phn').value;  			var purchaser_address = document.getElementById('purchaser_address').value;  			var payment_method1 = document.getElementById('payment_method1').value;				var payment_method2 = document.getElementById('payment_method2').value;				var birthday_mm = document.getElementById('birth_month').value;				var birthday_dd = document.getElementById('birth_date').value;				var birthday_yyyy = document.getElementById('birth_year').value;				var agreement = document.getElementById('agreement');	 				var dt = birthday_mm+'/'+birthday_dd+'/'+birthday_yyyy;					var error_msg='';				/* check First name is blank or not */			if(trimAll(fname) == ''){	  error_msg += "Please enter your First Name.\n";	}					/* check Last name is blank or not */		if(trimAll(lname) == ''){	  error_msg += "Please enter your Last Name.\n";	}							/* check Preferred name is blank or not */				/* if(trimAll(namep) == ''){	  error_msg += "Please enter your Preferred Name.\n";	} */ 				/* check Street Address 1 is blank or not */		if(trimAll(street_address1) == ''){	  error_msg += "Please enter your Street Address 1.\n";	}						/* check City is blank or not */		if(trimAll(city) == ''){	  error_msg += "Please enter your City.\n";	}		   		/* check State is blank or not */		if(trimAll(state) == ''){  	  error_msg += "Please enter your State.\n";  	}				/* check Postal code is blank or not */			if(trimAll(postal_code) == ''){	  error_msg += "Please enter your Postal Code.\n";	}				/* check Country is blank or not */			if(trimAll(country) == ''){	  error_msg += "Please enter your Country.\n";	}						/* check Phone number is blank or not */		if(trimAll(phone_number) == ''){	  error_msg += "Please enter your Phone Number.\n";	}					/* check Email is blank or not */		if(trimAll(email) == ''){	  error_msg += "Please enter your Email.\n";	}				/* check Email format */		if(trimAll(email) != "") {	  if(echeck(email) != true)	  {		  error_msg += "Please enter your a valid Email.";	  }	}					if((trimAll(birthday_mm) == '') || (trimAll(birthday_mm) == 'MM')){	  error_msg += "Please select Month of Birth.\n";	}					if((trimAll(birthday_dd) == '') || (trimAll(birthday_dd) == 'DD')){	  error_msg += "Please select valid day.\n";	}					if((trimAll(birthday_yyyy) == '') || (trimAll(birthday_yyyy) == 'YYYY')){	  error_msg += "Please select valid year.\n";	}						/*if((document.registration_frm.for_someone[0].checked == false) 			&& (document.registration_frm.for_someone[1].checked == false)) {		error_msg += "Please confirm 'Are you purchasing this entry for someone else?'\n";	}*/	  /* check payment method is blank or not */			if((document.registration_frm.payment_method[0].checked == false) 			&& (document.registration_frm.payment_method[1].checked == false)) {		error_msg += "Please select the type of payment method.\n";	}				/* check Purchaser Telephone number is blank or not */			if(trimAll(purchaser_phn) == '') {	  error_msg += "Please enter Purchaser\'s Telephone Number.\n";	}    		/* check Purchaser Email Address is blank or not */			if(trimAll(purchaser_address) == '') {	  error_msg += "Please enter Purchaser\'s Email Address.\n";	}			/* check Email format */			if(trimAll(purchaser_address) != "") {	  		if(echeck(purchaser_address) != true)	  {		  		error_msg += "Please enter valid Purchaser\'s Email Address.";	  }	}									if(error_msg != ""){				alert (error_msg);				return false;	}			else{		return true;	}}