
function formIsNumeric(v)
{
     v = v.replace(/\s+$|^\s*/gi, "");
     isNum = new RegExp ("[^0-9]");
     if (isNum.test(v))
	 {
          alert('Wrong');
     }
}

function CheckPhoneNumber(TheNumber) {
var valid = 1
var validchars = "0123456789()-+ "

var i = 0
if (TheNumber=="") {
// Return false if number is empty
valid = 0
	}
for (i =0; i <= TheNumber.length -1; i++) {
if (validdchars.indexOf(TheNumber.charAt(i)) == -1) {
// Note: Remove the comments from the following line to see this
// for loop in action.
// alert(TheNumber.charAt(i) + " is no good.")
valid = 0
} // End if statement
	} // End for loop
return valid
}



function frmNewUserValidation(theForm)
{
	var temp;
	var temp1;
	temp = theForm.Password.value;
	temp1 = theForm.RePassword.value;
	
	
	// Variable for birth Day 
	var tempday   = document.frmNewUser.cmbDayListing.value; 
	var tempmonth = document.frmNewUser.cmbMonthListing.value; 
	var tempyear  = document.frmNewUser.cmbYearListing.value;
	var leapyear  = tempyear % 4;
	//-- End 
	
	if(!theForm.UserName.value.length)
	{
		alert("Please enter the 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);
	}
	
// Checking of Birth Date 
	if  ((tempmonth == 0) || (tempday == 0) || (tempyear == 0)) 
	{
		alert("Please enter date of birth");
	    return false;
	}
				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("February has only 28 days!");
									return false;
								}
						}
			   }
	   
	 if ((tempmonth == 4 || tempmonth == 6 || tempmonth == 9 || tempmonth ==11) && tempday == 31)
	 {
		alert(" Invalid Date!");
		return false;
	 }
	 
// End of Birth Date
	
     	if ( ( /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/.test(theForm.txtPhone.value)))
    	{
     		//  do nothing
     	}
       	else
     	{
			alert("Invalid Phone Number");
			theForm.txtPhone.focus();
			return (false);
		}
	// For Checking Zip code in numbers
    // only allow numbers to be entered
	
		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 digit characters in the \"numbers\" field.");
		theForm.Zip.focus();
		return (false);
		}
	
		
	if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.EmailID.value))) 
  	{
		//  do nothing
  	}
  	else
  	{
		alert("Invalid E-mail Address! 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 the User 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;
	}
}

// For Contact_us.asp

function ContactUsValidation(theForm)
{
  if (!theForm.txtFName.value.length)
	{
	 alert("Enter Your First Name.");
	 theForm.txtFName.focus();
	 return(false)
	}
	if (!theForm.txtLName.value.length)
	{
	 alert("Enter Your Last Name");
	 theForm.txtLName.focus();
	 return(false)
	}	
    if (!theForm.txtVisitor_Name.value.length)
  {
            alert("Please enter E-mail address.")
			theForm.txtVisitor_Name.focus();
			return (false);
  }
  else
  {
	   if ((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.txtVisitor_Name.value))) 
		{
			//  do nothing
		}
	   else
		{
			alert("Invalid E-mail Address! Please re-enter.")
			theForm.txtVisitor_Name.focus();
			return (false);
		}
   } 
	if (!theForm.txtFeedback.value.length)
	{
	 alert("Enter Your Meaasage");
	 theForm.txtFeedback.focus();
	 return(false)
	}	
}

function Usr_News_List(theForm)
{
  if (!theForm.txtArticleKeyword.value.length)
  {
   alert("Enter Keyword for Search");
   theForm.txtArticleKeyword.focus();
   return(false)
  }
}


// for Add_Main_Cat_WLL  & Edit_main_Cat_WLL
function frmAdd_Main_Cat_WLL(theForm)
{
  if(!theForm.txtMain_Category_Name.value.length)
  {
   alert("Please enter the Link Name");
   theForm.txtMain_Category_Name.focus();
   return(false)
  }  
  if(!theForm.txtOrder_No.value.length)
  {
   alert("Please enter only digit in the field.");
   theForm.txtOrder_No.focus();
   return(false)
  }
  else
  {
        var checkOK = "0123456789";
		var checkStr = theForm.txtOrder_No.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 digit in the field.");
		theForm.txtOrder_No.focus();
		return (false);
		}
  }
  
}
// add main specialty

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);
	}
}