function resetForm(frm){
	frm.reset();
	return false;
}	

function checkRegister()
{  
	with (window.document.frmRegister) {
		if (isEmpty(name, 'Please Enter your Full Name')) {
			return false;
		} else if (isSymbol(name, 'Name field must contain from 3 to 50 characters', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(name, 'Please enter valid Name')){
					return false;	
		} else if (isEmpty(comp_agency, 'Please Enter your Company/Agency Name')) {
			return false;
		} else if (isSymbol(comp_agency, 'Company/Agency Name field must contain from 3 to 30 characters', 3, 30)) {
			return false;	
		}  else if (isEmpty(address, ' Please Enter your address')) {
			return false;
		} else if (isEmpty(phone, 'Please Enter your Phone')) {
			return false;
		} else if (isEmpty(username, 'Please Enter your username')) {
			return false;
		} else if (isSymbol(username, 'username field must contain from 5 to 10 characters', 5, 10)) {
			return false;		
		}  else if (isEmpty(email, 'Please Enter your email id')) {
			return false;
		} else if(checkValidEmail(email, 'Invalid E-mail ID')){
					return false;		
		}  else if (isEmpty(reemail, 'Please enter same mail id in Retype Email Field')) {
			return false;
		} else if(email.value!=reemail.value){
			  alert("Email and Retype Email is not matching");
  				reemail.focus();
  				return false;
		}else {
			return true;
		}
	}
}


function checkIndivisual()
{  
	with (window.document.frmIndivisual) {
		
		/*if (isEmpty(uname, 'Please Enter Member Username.')) {
			return false;
		} else if (isSymbol(uname, 'Username must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		}  else if (isEmpty(pwd, 'Please Enter your Password.')) {
			return false;
		} else if (isSymbol(pwd, 'Password must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		} else if (isEmpty(cpwd, 'Please enter Password in Confirm Password Field.')) {
			return false;	
		} else if(pwd.value!=cpwd.value){
			  alert("password is not matching");
  				cpwd.focus();
  				return false;	
		}*/ 
		if (isEmpty(name, 'Please Enter Primary Member Name.')) {
			return false;
		} else if (isSymbol(name, 'Primary Member Name field must contain from 3 to 50 characters.', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(name, 'Please enter valid Primary Member Name.')){
					return false;
		} else if (isEmpty(age, 'Please Enter Primary Member Age.')) {
			return false;
		} else if (isInt(age, 'Please enter valid Primary Member Age(Age between 1 - 99).')){
					return false;			
		} else if (isEmpty(phone, 'Please Enter your Primary Phone Number.')) {
			return false;
		} else if (isSymbol(phone, 'Primary Phone Number must contain from 10 to 15 characters', 10, 15)) {
			return false;
		}  else if (isEmpty(email, 'Please Enter Primary email id.')) {
			return false;
		} else if(checkValidEmail(email, 'Invalid Primary E-mail ID.')){
					return false;		
		}  else if (isEmpty(bill_add, ' Please Enter your Primary Billing Address.')) {
			return false;
		}  else if (isEmpty(ship_add, ' Please Enter your Shipping Address.')) {
			return false;
		}else {
			return true;
		}
	}
}

function checkIndivisualEdit()
{  
	with (window.document.frmIndivisual) {
		
		if (isEmpty(uname, 'Please Enter Member Username.')) {
			return false;
		} else if (isSymbol(uname, 'Username must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		}  else if (isEmpty(pwd, 'Please Enter your Password.')) {
			return false;
		} else if (isSymbol(pwd, 'Password must contain from 5 to 10 characters.', 5, 10)) {
			return false;		
		} else if (isEmpty(name, 'Please Enter Primary Member Name.')) {
			return false;
		} else if (isSymbol(name, 'Primary Member Name field must contain from 3 to 50 characters.', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(name, 'Please enter valid Primary Member Name.')){
					return false;
		} else if (isEmpty(age, 'Please Enter Primary Member Age.')) {
			return false;
		} else if (isInt(age, 'Please enter valid Primary Member Age(Age between 1 - 99).')){
					return false;			
		} else if (isEmpty(phone, 'Please Enter your Primary Phone Number.')) {
			return false;
		} else if (isSymbol(phone, 'Primary Phone Number must contain from 10 to 15 characters', 10, 15)) {
			return false;
		}  else if (isEmpty(email, 'Please Enter Primary email id.')) {
			return false;
		} else if(checkValidEmail(email, 'Invalid Primary E-mail ID.')){
					return false;		
		}  else if (isEmpty(bill_add, ' Please Enter your Primary Billing Address.')) {
			return false;
		}  else if (isEmpty(ship_add, ' Please Enter your Shipping Address.')) {
			return false;
		} else if (isEmpty(pname, 'Please Enter Primary Member Name: First and Last.')) {
			return false;
		} else if (isSymbol(pname, 'Primary Member Name: First and Last field must contain from 5 to 50 characters.', 5, 50)) {
			return false;	
		}else {
			return true;
		}
	}
}

function checkCorporate()
{  
	with (window.document.frmCorporate) {
		
		/*if (isEmpty(uname, 'Please Enter Member Username.')) {
			return false;
		} else if (isSymbol(uname, 'Username must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		}  else if (isEmpty(pwd, 'Please Enter your Password.')) {
			return false;
		} else if (isSymbol(pwd, 'Password must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		} else if (isEmpty(cpwd, 'Please enter Password in Confirm Password Field.')) {
			return false;	
		} else if(pwd.value!=cpwd.value){
			  alert("password is not matching");
  				cpwd.focus();
  				return false;}*/
		if (isEmpty(compnm, 'Please Enter Company Name.')) {
			return false;
		} else if (isSymbol(compnm, 'Company Name must contain from 3 to 50 characters.', 3, 50)) {
			return false;		
		} else if (isEmpty(pcname, 'Please Enter Responsible Party(Primary Contact) Name.')) {
			return false;
		} else if (isSymbol(pcname, 'Responsible Party(Primary Contact) Name must contain from 3 to 50 characters.', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(pcname, 'Please enter valid Responsible Party (Primary Contact) Name.')){
					return false;
		} else if (isEmpty(title, 'Please Enter Title.')) {
			return false;
		/*} else if (isSymbol(title, 'Title must contain from 3 to 20 characters.', 3, 20)) {
			return false;
		} else if (isEmpty(pay_opt, 'Please Select Preferred Payment Option.')) {
			return false;*/	
		} else if (isEmpty(mphone, 'Please Enter your Mobile Phone Number.')) {
			return false;
		} else if (isSymbol(mphone, 'Mobile Phone Number must contain from 10 to 15 characters', 10, 15)) {
			return false;
		}  else if (isEmpty(email, 'Please Enter Primary email id.')) {
			return false;
		} else if(checkValidEmail(email, 'Invalid Primary E-mail ID.')){
					return false;		
		}  else if (isEmpty(st_add, ' Please Enter your Street Address.')) {
			return false;
		}  else if (isEmpty(csz, 'Please Enter your City,State,Zip.')) {
			return false;
		}else {
			return true;
		}
	}
}

function checkCorporateEdit()
{  
	with (window.document.frmCorporate) {
		
		if (isEmpty(uname, 'Please Enter Member Username.')) {
			return false;
		} else if (isSymbol(uname, 'Username must contain from 5 to 10 characters.', 5, 10)) {
			return false;
		}  else if (isEmpty(pwd, 'Please Enter your Password.')) {
			return false;
		} else if (isSymbol(pwd, 'Password must contain from 5 to 10 characters.', 5, 10)) {
			return false;		
		} else if (isEmpty(compnm, 'Please Enter Company Name.')) {
			return false;
		} else if (isSymbol(compnm, 'Company Name must contain from 3 to 50 characters.', 3, 50)) {
			return false;		
		} else if (isEmpty(pcname, 'Please Enter Responsible Party(Primary Contact) Name.')) {
			return false;
		} else if (isSymbol(pcname, 'Responsible Party(Primary Contact) Name must contain from 3 to 50 characters.', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(pcname, 'Please enter valid Responsible Party (Primary Contact) Name.')){
					return false;
		} else if (isEmpty(title, 'Please Enter Title.')) {
			return false;		
		} else if (isEmpty(mphone, 'Please Enter your Mobile Phone Number.')) {
			return false;
		} else if (isSymbol(mphone, 'Mobile Phone Number must contain from 10 to 15 characters', 10, 15)) {
			return false;
		}  else if (isEmpty(email, 'Please Enter Primary email id.')) {
			return false;
		} else if(checkValidEmail(email, 'Invalid Primary E-mail ID.')){
					return false;		
		}  else if (isEmpty(st_add, ' Please Enter your Street Address.')) {
			return false;
		}  else if (isEmpty(csz, 'Please Enter your City,State,Zip.')) {
			return false;
		}else {
			return true;
		}
	}
}

function checkHippa()
{  
	with (window.document.frmHippaAutho) {		
		if (isEmpty(pname, 'Please Enter Primary Member Name.')) {
			return false;
		} else if (isSymbol(pname, 'Primary Member Name field must contain from 3 to 50 characters.', 3, 50)) {
			return false;
		} else if(checkSpecialCharacter(pname, 'Please enter valid Primary Member Name.')){
					return false;			
		}else {
			return true;
		}
	}
}

function checkLogin()
{
	with (window.document.frmLogin) {
		if (isEmpty(username, 'Please Enter your username')) {
			return false;
		} else if (isEmpty(pwd, 'Please Enter your password')) {
			return false;		
		}else {
			return true;
		}
	}
}


function validatePayment()
{
	with (window.document.frmPayment) {
		if (isEmpty(card, 'Please Select your Credit Card Type.')) {
			return false;
		} else if (isEmpty(card_no, 'Please Enter your Credit Card Number.')) {
			return false;	
		} else if (isEmpty(exp_month, 'Please Select your Credit Card Expiration Month.')) {
			return false;	
		} else if (isEmpty(exp_year, 'Please Select your Credit Card Expiration Year.')) {
			return false;			
		}else {
			return true;
		}
	}
}

function forgotPassword()
{
	with (window.document.frmPassword) {
		if (isEmpty(username, 'Please Enter your username.')) {
			return false;
		} else if (isEmpty(email, 'Please Enter your Email.')) {
			return false;		
		}else {
			return true;
		}
	}
}

function isRadio(formElement, message) {
	
	_isCheck = true;
	
	for (var i=0; i<formElement.length; i++)  
	{  
		
		if (formElement[i].checked==true) {  
			_isCheck = false; 
			break;  
		}  
	} 
	if(_isCheck) 
	{
		alert(message); 		
	}
	
	return _isCheck ; 
}


//---------------------check valid name(Abhay)----------------------
function checkSpecialCharacter(formElement, message)
{
	//alert(message);
	formElement.value = trim(formElement.value);
	var strLength = formElement.value.length;
	_checkSpecialCharacter = false;
	var iChars = "*|,\":<>[]{}`\';()@&$#%?.0123456789";
		for (var i = 0; i < strLength; i++) 
		{
			if (iChars.indexOf(formElement.value.charAt(i)) != -1)
			{
				_checkSpecialCharacter = true;
			}
		}
		if(_checkSpecialCharacter == true)
		{
			alert(message);
			formElement.focus();
		}
return _checkSpecialCharacter;
}

//-------------------------------------------------------------------
//---------------------check valid discount(Uday)----------------------
function checkSpecialCharacter1(formElement, message)
{
	
	formElement.value = trim(formElement.value);
	alert(formElement.value);
	var strLength = formElement.value.length;
	_checkSpecialCharacter = false;
	var iChars = "*|,\":<>[]{}`\';()@&$#%?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for (var i = 0; i < strLength; i++) 
		{
			if (iChars.indexOf(formElement.value.charAt(i)) != -1)
			{
				_checkSpecialCharacter = true;
			}
		}
		if(_checkSpecialCharacter == true)
		{
			alert(message);
			formElement.focus();
		}
return _checkSpecialCharacter;
}

//-------------------------------------------------------------------

//---------------------check valid age(uday)----------------------
function isInt(formElement, message)
{
	
	formElement.value = trim(formElement.value);
	_checkSpecialCharacter = false;	
	var age = parseInt(formElement.value);
	
	if(isNaN(age))
	{
		_checkSpecialCharacter = true;
		alert(message);
		formElement.focus();
	}		
	else if ((age<1) || (age>99))
	{
		_checkSpecialCharacter = true;
		alert(message);
		formElement.focus();
	}
	return _checkSpecialCharacter;
}

//-------------------------------------------------------------------

function isEmpty(formElement, message) {
	
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}



function isCheck(formElement, message) {
	//alert(formElement);
	//alert(message);
	formElement.value = trim(formElement.value);
	
	_isCheck = false;
	//alert(formElement.checked);
	if (formElement.checked == false) {
		_isCheck = true;
		alert(message);
		formElement.focus();
	}
	
	
	//alert(_isCheck);
	return _isCheck;
}

function isSymbol(formElement, message, fromNumber, toNumber) {
	
	formElement.value = trim(formElement.value);
	var strLength = formElement.value.length;
	
	_isLength = false;
	if (strLength<fromNumber || strLength>toNumber) {
		_isLength = true;
		alert(message);
		formElement.focus();
	}
	
	return _isLength;
}


function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}



//---------------------check valid email(Uday)----------------------
function checkValidEmail(formElement, message)
{
	//alert(message);
	formElement.value = trim(formElement.value);
	_checkEmail = false;
	if(echeck(formElement.value)==false)
	   {
		  _checkEmail = true;
		  alert(message);
		  formElement.focus();  
	   }
    return _checkEmail;
}

//-------------------------------------------------------------------


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		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
		 }

 		 return true					
	}

function checkConfirmEmail(formElement1, formElement2, message){
	
	formElement1.value = trim(formElement1.value);
	formElement2.value = trim(formElement2.value);
	_checkEmail = false;
	if(formElement1.value!=formElement2.value)
	   {
		  _checkEmail = true;
		  alert(message);
		  formElement2.focus();  
	   }
    return _checkEmail;
 }

function my_function(id)
{
	
	if(id==2)
	{
	  if(document.getElementById('package_qnty' + id).value=='')
	  {
	     alert("Select Team Doctor's Memberships As A Gift for Individuals and/or Families quantity");
		 return false;
	  }
	  else
	  	document.frmCart_id.submit();
		return true;
	}
	else
		document.frmCart_id.submit();
		return true;
}

