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 checkLogin()
{
	with (window.document.clientLogin) {
		if (isEmpty(username, 'Please Enter your username')) {
			return false;
		} else if (isEmpty(pwd, 'Please Enter your password')) {
			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;
}

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

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;
 }

