function NewUserValidation(theForm)
{
	var tempday   = document.frmNewUser.cmbDayListing.value; 
	var tempmonth = document.frmNewUser.cmbMonthListing.value; 
	var tempyear  = document.frmNewUser.cmbYearListing.value;
	var leapyear  = tempyear % 4;
	var temp;
	var temp1;
	temp = theForm.Password.value;
	temp1 = theForm.RePassword.value;
	if (tempmonth == 2)
	{
		if (leapyear  == 0)
		  	{
	      		if (tempday > 29)
            		{
			 		alert("February has only 29 days in a leap year!");
					return false;
              		}
        	}
     	else
        	{
        		if (tempday > 28)
             		{
				 		alert("Invalid Date");
						return false;
            		}
         	}
   }
	 if ((tempmonth == 4 || tempmonth == 6 || tempmonth == 9 || tempmonth ==11) && tempday == 31)
	 {
		alert("Invalid Date");
		return false;
	 }

	if(!theForm.UserName.value.length)
	{
		alert("Please enter a valid User Id");
		theForm.UserName.focus();
		return (false);
	}
	if(!theForm.Password.value.length)
	{
		alert("Please enter the Password");
		theForm.Password.focus();
		return (false);
	}
	if(temp1 != temp)
	{
		alert("Password mismatch");
		theForm.RePassword.focus();
		return(false);
	}
	if(!theForm.LastName.value.length)
	{
		alert("Please enter your last name");
		theForm.LastName.focus();
		return (false);
	}
	if(!theForm.FirstName.value.length)
	{
		alert("Please enter your first name");
		theForm.FirstName.focus();
		return (false);
	}
	if(!theForm.Address.value.length)
	{
		alert("Please enter your postal address");
		theForm.Address.focus();
		return (false);
	}
	if(!theForm.City.value.length)
	{
		alert("Please enter your native city");
		theForm.City.focus();
		return (false);
	}
	var checkOK = "0123456789";
	var checkStr = theForm.Zip.value;
	var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	 {
	   ch = checkStr.charAt(i);
	   for (j = 0;  j < checkOK.length;  j++)
	   if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		if (ch != ",")
		allNum += ch;
		}
		if (!allValid)
		{
		alert("Please enter only numeric characters in the Zip field.");
		theForm.Zip.focus();
		return (false);
		}
	if(theForm.Zip.value.length < 5 | theForm.Zip.value.length > 5)
	{
		alert("Zip code should contain only 5 numeric digits");
		theForm.Zip.focus();
		return false;
	}
	if ( ( /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/.test(theForm.txtPhone.value)))
	{
		//  do nothing
	}
	else
	{
		alert("Invalid Phone Number");
		theForm.txtPhone.focus();
		return (false);
	}
	if(!theForm.Fax.value.length)
	{
		// do nothing
	}
	else
		{
			if ( ( /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/.test(theForm.Fax.value)))
				{
					//  do nothing
				}
			else
				{
					alert("Invalid Fax Number");
					theForm.Fax.focus();
					return (false);
				}
		}
		if(!theForm.EmailID.value.length)
		{
		}
		else
		{
	if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.EmailID.value))) 
  	{
		//  do nothing
  	}
  	else
  	{
		alert("Invalid E-mail Id! Please re-enter.")
		theForm.EmailID.focus();
		return (false);
  	}
	}
	
	fnSubmit2();
}

function frmMainSpecialtyValidation(theForm)
{
	if(!theForm.txtSpecialty_Name.value.length)
	{
		alert("Please enter the main speciality name");
		theForm.txtSpecialty_Name.focus();
		return (false);
	}
	if(!theForm.txtOrder_No.value.length)
	{
		alert("Please enter the Order number");
		theForm.txtOrder_No.focus();
		return (false);
	}
}

function LoginValidation(theForm)
{
	if(!theForm.txtUser_Name.value.length)
		{
			alert("Please enter your Login Id");
			theForm.txtUser_Name.focus();
			return(false);
		}
	if(!theForm.txtPassword.value.length)
		{
			alert("Password field is blank");
			theForm.txtPassword.focus();
			return(false);
		}
}

function weblinkvalidator(theForm)
{
	if(!theForm.txtweb_link_Name.value.length)
	{
		alert("Please enter a valid Web Link name");
		theForm.txtweb_link_Name.focus();
		return false;
	}
	if(!theForm.txtweb_link.value.length)
	{
		alert("Please enter a valid Web Link");
		theForm.txtweb_link.focus();
		return false;
	}
	if(!theForm.txtDescription.value.length)
	{
		alert("Please enter a short description");
		theForm.txtDescription.focus();
		return false;
	}
}

function contactusvalidation(theForm)
{
	if(!theForm.txtVisitor_Name.value.length)
		{
			alert("Enter your name please");
			theForm.txtVisitor_Name.focus();
			return false;
		}
	
	if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.txtVisitor_Email.value))) 
  	{
		//  do nothing
  	}
  	else
  	{
		alert("Invalid E-mail Id!")
		theForm.txtVisitor_Email.focus();
		return (false);
  	}
	
	if(!theForm.txtFeedback.value.length)
		{
			alert("Enter your suggestion/feedback please");
			theForm.txtFeedback.focus();
			return false;
		}
}

