// JavaScript Document
function verify_forgot_password()
{
	if(Trim(document.frmforgotpassword.forgot_email.value) == "")
	{
		alert("Please Enter Email!");
		document.frmforgotpassword.forgot_email.focus();
		return false;
	}
	if(Trim(document.frmforgotpassword.forgot_email.value) != "")
	{
		if(!isEmail(document.frmforgotpassword.forgot_email.value))
		{
			alert("Please Enter valid Email!");
			document.frmforgotpassword.forgot_email.select();
			document.frmforgotpassword.forgot_email.focus();
			return false;
		}
	}
	
	document.frmforgotpassword.hid_action.value = 'FORGOTPASSWORD';
    return true;				

}
function check_login()
{
   	if(Trim(document.frmlogin.login_email.value) == "")
	{
		alert("Please Enter Email!");
		document.frmlogin.login_email.focus();

		return false;
	}
	if(Trim(document.frmlogin.login_email.value) != "")
	{
		if(!isEmail(document.frmlogin.login_email.value))
		{
			alert("Please Enter valid Email!");
			document.frmlogin.login_email.select();
			document.frmlogin.login_email.focus();
			return false;
		}
	}
	if(Trim(document.frmlogin.login_password.value) == "")
	{
		alert("Please Enter Password!");
		document.frmlogin.login_password.focus();
	
		return false;
	}

	document.frmlogin.hid_action_login.value = 'LOGIN';
	return true;
}
function enabledisabletr(acctypeposted)
{
    if(acctypeposted == 'Dealer')
	{
		document.getElementById('trdealer').style.display = 'inline';
		document.getElementById('trdealer').style.display = 'table-row';
	}
	else if(acctypeposted == 'Private')
	{
		document.getElementById('trdealer').style.display = 'none';
	}
}
function verify_update_member()
{

	var myOption = -1;
		
	for (var i=document.frmupdatemember.accounttype.length-1; i > -1; i--) 
	{
	  if (document.frmupdatemember.accounttype[i].checked) 
	  {
		   myOption = i; 
		   i = -1;
	  }
	}
	if (myOption == -1) 
	{
	  alert("Please Select Account Type!");
	  document.frmupdatemember.accounttype[0].focus();
	  return false;
	}

	var acc_type_value;		

    for (var i=0 ; i<document.frmupdatemember.accounttype.length ; i++)
	{
	  if (document.frmupdatemember.accounttype[i].checked)
	  {
			acc_type_value = document.frmupdatemember.accounttype[i].value;
	  }
	} 
	if(acc_type_value == "Dealer")
	{
		if(Trim(document.frmupdatemember.txt_dealername.value) == "")
		{	
		    alert("Please Enter Dealer/Company Name!");
			document.frmupdatemember.txt_dealername.value = "";
			document.frmupdatemember.txt_dealername.focus();
			return false;	
		}
	}
	if(Trim(document.frmupdatemember.txt_fname.value) == "")
	{
		alert("Please Enter First Name!");
		document.frmupdatemember.txt_fname.value = "";
		document.frmupdatemember.txt_fname.focus();
		return false;
	}
	if(document.frmupdatemember.txt_fname.value != "")
	{
	    if(!isAlphabetic(document.frmupdatemember.txt_fname.value))
		{
			 alert("Please Enter only Alphabetic value for First Name!");
			 document.frmupdatemember.txt_fname.select();
			 
			 return false;
		 }	
	}
	if(Trim(document.frmupdatemember.txt_lname.value) == "")
	{
		alert("Please Enter Last Name!");
		document.frmupdatemember.txt_lname.value = "";
		document.frmupdatemember.txt_lname.focus();
		return false;
	}
	
	if(document.frmupdatemember.txt_lname.value != "")
	{
	    if(!isAlphabetic(document.frmupdatemember.txt_lname.value))
		{
			 alert("Please Enter only Alphabetic value for Last Name!");
			 document.frmupdatemember.txt_lname.select();
			
			 return false;
		 }
	}
	if(Trim(document.frmupdatemember.txt_address.value) == "")
	{
		alert("Please Enter Address!");
		document.frmupdatemember.txt_address.focus();
		return false;
	}	
	/*if(Trim(document.frmupdatemember.phone1.value) == "")
	{
		alert("Please Enter Phone!");
		document.frmupdatemember.phone1.focus();
		return false;
	}*/
	/*if(Trim(document.frmupdatemember.phone1.value) != "")
	{
		if(isNaN(Trim(document.frmupdatemember.phone1.value)) == true)
		{
			alert("First block of Phone should be in numbers only!");
			document.frmupdatemember.phone1.select();
			document.frmupdatemember.phone1.focus();
			return false;
		}
		if(Trim(document.frmupdatemember.phone1.value).length < 3)
		{
		    alert("First block of Phone field must be 3 digits!");
		    document.frmupdatemember.phone1.focus();
		    return false;
		}
	}
	if(Trim(document.frmupdatemember.phone2.value) == "")
	{
		alert("Second block of Phone field must be 7 digits!");
		document.frmupdatemember.phone2.focus();
		return false;
	}
	if(Trim(document.frmupdatemember.phone2.value) != "")
	{
		if(isNaN(Trim(document.frmupdatemember.phone2.value)) == true)
		{
			alert("Second block of Phone should be in numbers only!");
			document.frmupdatemember.phone2.select();
			document.frmupdatemember.phone2.focus();
			return false;
		}
		if(Trim(document.frmupdatemember.phone2.value).length < 7)
		{
		    alert("Second block of Phone field must be 7 digits!");
		    document.frmupdatemember.phone2.focus();
		    return false;
		 }
	}*/
	if(Trim(document.frmupdatemember.phone1.value) != "")
	{
		if(isNaN(Trim(document.frmupdatemember.phone1.value)) == true)
		{
			alert("Phone should be in numbers only!");
			document.frmupdatemember.phone1.select();
			document.frmupdatemember.phone1.focus();
			return false;
		}
	}
	/*if(Trim(document.frmupdatemember.phone3.value) == "" && Trim(document.frmupdatemember.phone4.value) != "")
	{
		if(Trim(document.frmupdatemember.phone3.value).length < 3)
		{
		   alert("First block of Alternate Phone field must be 3 digits!");
		   document.frmupdatemember.phone3.focus();
		   return false;
		}
	}
	
	if(Trim(document.frmupdatemember.phone3.value) != "" && Trim(document.frmupdatemember.phone4.value) == "")
	{
		if(isNaN(Trim(document.frmupdatemember.phone3.value)) == true)
		{
			alert("First block of Alternate Phone should be in numbers only!");
			document.frmupdatemember.phone3.select();
			document.frmupdatemember.phone3.focus();
			return false;
		}
		else if(Trim(document.frmupdatemember.phone3.value).length < 3)
		{
		   alert("First block of Alternate Phone field must be 3 digits!");
		   document.frmupdatemember.phone3.focus();
		   return false;
		}
		else
		{
		   alert("Second block of Alternate Phone field must be 7 digits!");
		   document.frmupdatemember.phone4.focus();
	   	   return false;
		}
	}
	if(Trim(document.frmupdatemember.phone3.value) != "")
	{

		if(isNaN(Trim(document.frmupdatemember.phone3.value)) == true)
		{
			alert("First block of Alternate Phone should be in numbers only!");
			document.frmupdatemember.phone3.select();
			document.frmupdatemember.phone3.focus();
			return false;
		}
		else if(Trim(document.frmupdatemember.phone3.value).length < 3)
		{
		    alert("First block of Alternate Phone field must be 3 digits!");
		    document.frmupdatemember.phone3.focus();
		    return false;
		 }
	}	
	if(Trim(document.frmupdatemember.phone4.value) != "")
	{

		if(isNaN(Trim(document.frmupdatemember.phone4.value)) == true)
		{
			alert("Second block of Alternate Phone should be in numbers only!");
			document.frmupdatemember.phone4.select();
			document.frmupdatemember.phone4.focus();
			return false;
		}
		else if(Trim(document.frmupdatemember.phone4.value).length < 7)
		{
		    alert("Second block of Alternate Phone field must be 7 digits!");
		    document.frmupdatemember.phone4.focus();
		    return false;
		 }
	}*/
	if(Trim(document.frmupdatemember.phone3.value) != "")
	{
		if(isNaN(Trim(document.frmupdatemember.phone3.value)) == true)
		{
			alert("Alternate Phone should be in numbers only!");
			document.frmupdatemember.phone3.select();
			document.frmupdatemember.phone3.focus();
			return false;
		}
	}
	if(Trim(document.frmupdatemember.txt_address.value) == "")
	{
		alert("Please Enter Address!");
		document.frmupdatemember.txt_address.focus();
		return false;
	}	
	if(Trim(document.frmupdatemember.txt_email.value) == "")
	{
		alert("Please Enter Email!");
		document.frmupdatemember.txt_email.focus();
		return false;
	}	
	if(Trim(document.frmupdatemember.txt_email.value) != "")
	{
		if(!isEmail(document.frmupdatemember.txt_email.value))
		{
			alert("Please Enter valid Email!");
			document.frmupdatemember.txt_email.select();
			document.frmupdatemember.txt_email.focus();
			return false;
		}	
	}
	if(Trim(document.frmupdatemember.txt_password.value) == "")
	{
		alert("Please Enter Password!");
		document.frmupdatemember.txt_password.focus();
		return false;
	}
	if(Trim(document.frmupdatemember.txt_confirm_password.value) == "")
	{
		alert("Please Enter Confirm Password!");
		document.frmupdatemember.txt_confirm_password.focus();
		return false;
	}
	if(Trim(document.frmupdatemember.txt_password.value) != Trim(document.frmupdatemember.txt_confirm_password.value))
	{
		alert("Password and Confirm Password do not match!");
		document.frmupdatemember.txt_password.value = "";
		document.frmupdatemember.txt_confirm_password.value = "";
		document.frmupdatemember.txt_password.focus();
		return false;
	}
	if(document.frmupdatemember.terms_conditions.checked == false)
	{
		alert("Please agree to the Terms and Conditions to Continue!");
		document.frmupdatemember.terms_conditions.focus();
		return false;
	}	
	
	document.frmupdatemember.hid_action.value = 'UPDATE';
    return true;				
}
function verify_regi()
{

	var myOption = -1;
		
	for (var i=document.frmregistration.accounttype.length-1; i > -1; i--) 
	{
	  if (document.frmregistration.accounttype[i].checked) 
	  {
		   myOption = i; 
		   i = -1;
	  }
	}
	if (myOption == -1) 
	{
	  alert("Please Select Account Type!");
	  document.frmregistration.accounttype[0].focus();
	  return false;
	}

	var acc_type_value;		

    for (var i=0 ; i<document.frmregistration.accounttype.length ; i++)
	{
	  if (document.frmregistration.accounttype[i].checked)
	  {
			acc_type_value = document.frmregistration.accounttype[i].value;
	  }
	} 
	if(acc_type_value == "Dealer")
	{
		if(Trim(document.frmregistration.txt_dealername.value) == "")
		{	
		    alert("Please Enter Dealer/Company Name!");
			document.frmregistration.txt_dealername.value = "";
			document.frmregistration.txt_dealername.focus();
			return false;	
		}
	}
	if(Trim(document.frmregistration.txt_fname.value) == "")
	{
		alert("Please Enter First Name!");
		document.frmregistration.txt_fname.value = "";
		document.frmregistration.txt_fname.focus();
		return false;
	}
	if(document.frmregistration.txt_fname.value != "")
	{
	    if(!isAlphabetic(document.frmregistration.txt_fname.value))
		{
			 alert("Please Enter only Alphabetic value for First Name!");
			 document.frmregistration.txt_fname.select();
			 
			 return false;
		 }	
	}
	if(Trim(document.frmregistration.txt_lname.value) == "")
	{
		alert("Please Enter Last Name!");
		document.frmregistration.txt_lname.value = "";
		document.frmregistration.txt_lname.focus();
		return false;
	}
	
	if(document.frmregistration.txt_lname.value != "")
	{
	    if(!isAlphabetic(document.frmregistration.txt_lname.value))
		{
			 alert("Please Enter only Alphabetic value for Last Name!");
			 document.frmregistration.txt_lname.select();
			
			 return false;
		 }
	}
	if(Trim(document.frmregistration.txt_address.value) == "")
	{
		alert("Please Enter Address!");
		document.frmregistration.txt_address.focus();
		return false;
	}	
	/*if(Trim(document.frmregistration.phone1.value) == "")
	{
		alert("Please Enter Phone!");
		document.frmregistration.phone1.focus();
		return false;
	}
	if(Trim(document.frmregistration.phone1.value) != "")
	{
		if(isNaN(Trim(document.frmregistration.phone1.value)) == true)
		{
			alert("First block of Phone should be in numbers only!");
			document.frmregistration.phone1.select();
			document.frmregistration.phone1.focus();
			return false;
		}
		if(Trim(document.frmregistration.phone1.value).length < 3)
		{
		    alert("First block of Phone field must be 3 digits!");
		    document.frmregistration.phone1.focus();
		    return false;
		}
	}*/
	if(Trim(document.frmregistration.phone1.value) != "")
	{
		if(isNaN(Trim(document.frmregistration.phone1.value)) == true)
		{
			alert("Phone should be in numbers only!");
			document.frmregistration.phone1.select();
			document.frmregistration.phone1.focus();
			return false;
		}
	}
	/*if(Trim(document.frmregistration.phone2.value) == "")
	{
		alert("Second block of Phone field must be 7 digits!");
		document.frmregistration.phone2.focus();
		return false;
	}
	if(Trim(document.frmregistration.phone2.value) != "")
	{
		if(isNaN(Trim(document.frmregistration.phone2.value)) == true)
		{
			alert("Second block of Phone should be in numbers only!");
			document.frmregistration.phone2.select();
			document.frmregistration.phone2.focus();
			return false;
		}
		if(Trim(document.frmregistration.phone2.value).length < 7)
		{
		    alert("Second block of Phone field must be 7 digits!");
		    document.frmregistration.phone2.focus();
		    return false;
		 }
	}*/
	/*if(Trim(document.frmregistration.phone3.value) == "" && Trim(document.frmregistration.phone4.value) != "")
	{
		if(Trim(document.frmregistration.phone3.value).length < 3)
		{
		   alert("First block of Alternate Phone field must be 3 digits!");
		   document.frmregistration.phone3.focus();
		   return false;
		}
	}
	
	if(Trim(document.frmregistration.phone3.value) != "" && Trim(document.frmregistration.phone4.value) == "")
	{
		if(isNaN(Trim(document.frmregistration.phone3.value)) == true)
		{
			alert("First block of Alternate Phone should be in numbers only!");
			document.frmregistration.phone3.select();
			document.frmregistration.phone3.focus();
			return false;
		}
		else if(Trim(document.frmregistration.phone3.value).length < 3)
		{
		   alert("First block of Alternate Phone field must be 3 digits!");
		   document.frmregistration.phone3.focus();
		   return false;
		}
		else
		{
		   alert("Second block of Alternate Phone field must be 7 digits!");
		   document.frmregistration.phone4.focus();
	   	   return false;
		}
	}
	if(Trim(document.frmregistration.phone3.value) != "")
	{

		if(isNaN(Trim(document.frmregistration.phone3.value)) == true)
		{
			alert("First block of Alternate Phone should be in numbers only!");
			document.frmregistration.phone3.select();
			document.frmregistration.phone3.focus();
			return false;
		}
		else if(Trim(document.frmregistration.phone3.value).length < 3)
		{
		    alert("First block of Alternate Phone field must be 3 digits!");
		    document.frmregistration.phone3.focus();
		    return false;
		 }
	}	
	if(Trim(document.frmregistration.phone4.value) != "")
	{

		if(isNaN(Trim(document.frmregistration.phone4.value)) == true)
		{
			alert("Second block of Alternate Phone should be in numbers only!");
			document.frmregistration.phone4.select();
			document.frmregistration.phone4.focus();
			return false;
		}
		else if(Trim(document.frmregistration.phone4.value).length < 7)
		{
		    alert("Second block of Alternate Phone field must be 7 digits!");
		    document.frmregistration.phone4.focus();
		    return false;
		 }
	}*/
	
	if(Trim(document.frmregistration.phone3.value) != "")
	{

		if(isNaN(Trim(document.frmregistration.phone3.value)) == true)
		{
			alert("Alternate Phone should be in numbers only!");
			document.frmregistration.phone3.select();
			document.frmregistration.phone3.focus();
			return false;
		}
	}	
	
	if(Trim(document.frmregistration.txt_address.value) == "")
	{
		alert("Please Enter Address!");
		document.frmregistration.txt_address.focus();
		return false;
	}	
	if(Trim(document.frmregistration.txt_email.value) == "")
	{
		alert("Please Enter Email!");
		document.frmregistration.txt_email.focus();
		return false;
	}	
	if(Trim(document.frmregistration.txt_email.value) != "")
	{
		if(!isEmail(document.frmregistration.txt_email.value))
		{
			alert("Please Enter valid Email!");
			document.frmregistration.txt_email.select();
			document.frmregistration.txt_email.focus();
			return false;
		}	
	}
	if(Trim(document.frmregistration.txt_password.value) == "")
	{
		alert("Please Enter Password!");
		document.frmregistration.txt_password.focus();
		return false;
	}
	if(Trim(document.frmregistration.txt_confirm_password.value) == "")
	{
		alert("Please Enter Confirm Password!");
		document.frmregistration.txt_confirm_password.focus();
		return false;
	}
	if(Trim(document.frmregistration.txt_password.value) != Trim(document.frmregistration.txt_confirm_password.value))
	{
		alert("Password and Confirm Password do not match!");
		document.frmregistration.txt_password.value = "";
		document.frmregistration.txt_confirm_password.value = "";
		document.frmregistration.txt_password.focus();
		return false;
	}
	if(document.frmregistration.terms_conditions.checked == false)
	{
		alert("Please agree to the Terms and Conditions to Continue!");
		document.frmregistration.terms_conditions.focus();
		return false;
	}	
	
	document.frmregistration.hid_action.value = 'ADD';
    return true;				
}
function enabledealer()
{
	document.getElementById('trdealer').style.display = 'inline';
	document.getElementById('trdealer').style.display = 'table-row';
}
function disabledealer()
{
 	document.getElementById('trdealer').style.display = 'none';
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) 
{
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) 
	{
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	
	function containsElement(arr, ele) 
	{
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
		  found = true;
		else
		  index++;
	
	 return found;
	}
	
	function getIndex(input) 
	{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		  if (input.form[i] == input)
			 index = i;
		  else i++;
		
	 return index;
	}
  return true;
}
	
