
function validate(form,bool)
	{
		var err_alert = 0;
		err_string = "";
		var t = document.frmBase.domain;
		var dot = t.value.lastIndexOf('.');
		var sp = t.value.indexOf(' ');
		var ln = t.value.length - 1;
		
		if((bool !=1) && (bool !=2))
			{
				/*if((document.frmBase.COUNTRY_NAME.value == 'USA') || (document.frmBase.COUNTRY_NAME.selectedIndex == 0))
					{
						if((document.frmBase.state.value =='') && (document.frmBase.city.value ==''))
							{
								err_string = err_string + '*You must enter a city or state to search in the USA.\n';
								err_alert = 2;
							}
					}*/
				if(document.frmBase.lastname.value=='')
						{
								err_string = err_string + '*You must enter at least a last name to search our records.\n';
								err_alert = 2;
						}
				else if(document.frmBase.lastname.value !='')
					{
						if((document.frmBase.lastname.value !='') && (document.frmBase.lastname.value.length < 2))
								{
									err_string = err_string + '*Please enter at least 2 characters for the last name.\n';
									err_alert = 2;
								}
							counter=0;
							var tmpstr = document.frmBase.lastname.value;
							for(x=0;x<document.frmBase.lastname.value.length;x++)
								{
									var strValidChar = "qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP";
									if (strValidChar.indexOf(tmpstr.charAt(x)) != -1)
									{}
									
									else
										{
											if(counter != 1)
												{
													err_string = err_string + '*Please enter valid characters for a last name (a - z).\n';
													err_alert = 2;
												}
											else
												{
													err_string = '*Please enter valid characters for a last name (a - z).\n';
													err_alert = 2;
												}
										}
									counter = 1;
								}
						}
						
						
				/*else if((document.frmBase.COUNTRY_NAME.value != '') || (document.frmBase.COUNTRY_NAME.selectedIndex != 0))
					{
						if((document.frmBase.state.value !='') || (document.frmBase.city.value !=''))
							{
								if((document.frmBase.lastname.value !='') && (document.frmBase.lastname.value.length < 2))
									{
				 						err_string = err_string + '*Please enter at least 2 characters for the last name.\n';
										err_alert = 2;
									}
							}
					}*/
				
				
				/*if((document.frmBase.firstname.value !='') && (document.frmBase.firstname.value.length < 2))
					{
						err_string = err_string + '*You must enter at least 2 charachters for the firstname field.\n'
						err_alert = 2;
					}*/
			}
			
		if(bool == 1)
			{
				if((document.frmBase.domain.value !='') && ((dot <= 1) || (dot == ln) || (sp != -1)))
					{
						err_string = err_string + 'Please enter a valid domain to search our records.\n';
						err_alert = 1;
					}
				if(document.frmBase.domain.value != '')
							{
							counter=0;
							var tmpstr = document.frmBase.domain.value;
							for(x=0;x<document.frmBase.domain.value.length;x++)
								{
									var strValidChar = "qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP_1234567890.";
									if (strValidChar.indexOf(tmpstr.charAt(x)) != -1)
									{}
									
									else
										{
											if(counter != 1)
												{
													err_string = err_string + '*Please enter a valid domain.\n';
													err_alert = 1;
												}
											else
												{
													err_string = '*Please enter a valid domain.\n';
													err_alert = 1;
												}
										}
									counter = 1;
								}
							}
				if(document.frmBase.domain.value =='')
					{
						err_string = err_string + 'In order to search by email, you must provide at least a domain.\n';
						err_alert =1;
					}
				if(document.frmBase.email.value != '')
							{
							counter=0;
							var tmpstr = document.frmBase.email.value;
							for(x=0;x<document.frmBase.email.value.length;x++)
								{
									var strValidChar = "-qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP_1234567890.";
									if (strValidChar.indexOf(tmpstr.charAt(x)) != -1)
									{}
									
									else
										{
											if(counter != 1)
												{
													err_string = err_string + '*No special characters allowed in first field(email account name).\n';
													err_alert = 1;
												}
											else
												{
													err_string = '*No special characters allowed in in first field(email account name).\n';
													err_alert = 1;
												}
										}
									counter = 1;
								}
							}
			} 
			
		if(bool == 2)
			{
				if((document.frmBase.username.value == '') || (document.frmBase.username.value.length > 20) || (document.frmBase.username.value == null))
						{
							err_string = err_string + '*Please enter a username.\n';
							err_alert = 1;
						}
					else if(document.frmBase.username.value != '') 
						{
						var tmpStr = document.frmBase.username.value
						firstVar = tmpStr.charAt(0)
						if((firstVar/firstVar) == 1)
							{
							err_string = err_string + '*The first letter of your username cannot be a number.\n';
							err_alert = 1;
							}
							counter=0;
							for(x=0;x<document.frmBase.username.value.length;x++)
								{
									var strValidChar = "qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP_1234567890";
									if (strValidChar.indexOf(tmpStr.charAt(x)) != -1)
									{}
									
									else
										{
											if(counter != 1)
												{
													err_string = err_string + '*No white space(s), special characters, or quotes allowed in usernames\n';
													err_alert = 1;
												}
											else
												{
													err_string = '*No white space(s), special characters, or quotes allowed in usernames\n';
													err_alert = 1;
												}
										}
									counter = 1;
								}
						tmpStrCheck = document.frmBase.username.value
							tmpStrCheckLen = document.frmBase.username.value.length
							tmpStrChar1 = tmpStrCheck.charAt(tmpStrCheckLen - 2)
							tmpStrChar2 = tmpStrCheck.charAt(tmpStrCheckLen - 1)
							if (tmpStrChar1 == 'i' && tmpStrChar2 == 'k')
								{
									err_string = err_string + '*The username cannot contain the letters "ik" at the end of it.\n';
									err_alert = 1;
								}
						}
			}


		
		
	if (err_alert == 1)
		{
			alert(err_string);
		}
	if (err_alert == 2)
		{
			alert(err_string);
		}
	if(err_alert == 0)
		{ 
			if((bool !=1) && (bool !=2))
				{
					document.frmBase.action='http://dcs.net2phone.com/consumer/commcenter/SearchResults.asp';
					document.frmBase.submit(form);
				}
			else if(bool == 1)
				{
					document.frmBase.action='http://dcs.net2phone.com/consumer/commcenter/SearchResults.asp?filter=E';
					document.frmBase.submit(form);
				}
			else
				{
					document.frmBase.action='http://dcs.net2phone.com/consumer/commcenter/SearchResults.asp?filter=U';
					document.frmBase.submit(form);
				}
		}
                               
	}
