function ValidateFullNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (((keycode>46) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateNumeric(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<58) )  || (keycode==8)) { return true; }
	else return false;
}

function ValidateAlphaNumeric(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<58) ) || ((keycode>=64) && (keycode<=90) )  || (keycode==8) || (keycode==95) || ((keycode>=97) && (keycode<=122) )) 
	{ 
	return true; 
	}
	else 
	return false;
}

function ValidateAlpha(myfield,e)
{
    var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if ((keycode==32) || ((keycode>43) && (keycode<48)) || ((keycode>=65) && (keycode<=90) )  || (keycode==8) || ((keycode>=97) && (keycode<=122) )) { return true; }
	else return false;
}
function LTrim(str)
	{
		if (str==null){return null;}
		for(var i=0;str.charAt(i)==" ";i++);
		return str.substring(i,str.length);
	}
function RTrim(str)
	{
		if (str==null){return null;}
		for(var i=str.length-1;str.charAt(i)==" ";i--);
		return str.substring(0,i+1);
	}
function Trim(str){return LTrim(RTrim(str));}


function valid_member_login()
{
	with(document.frm1)
	
	{
					if(member_title.value==" ")
						{
							alert("Please select title")
							member_title.focus();
							return false;
						}
					if(Trim(member_first_name.value)=="")
						{
							alert("Please specify the first  name")
							member_first_name.focus();
							return false;
						}
					if(Trim(member_last_name.value)=="")
						{
							alert("Please specify the Last  name")
							member_last_name.focus();
							return false;
						}
					if(member_login_email.value=="")
						{
							alert("Please specify the email");
							member_login_email.focus();
							return false;
						}
					if(!echeck(member_login_email.value))
						{
							member_login_email.focus();
							return false;
						}
					if(conf_member_login_email.value!=member_login_email.value)
					{
							alert("Confirm email does not matched")
							member_login_email.focus();
							return false;
					}
					
					if(Trim(member_password.value)=="")
						{
							alert("Please specify the password")
							member_password.focus();
							return false;
						}
					if(member_password.value.length<6)
						{
							alert("Please password should minimum has 6 characters")
							member_password.focus();
							return false;
						}
					if(member_password.value!=conf_member_password.value)
						{
							alert("Confirm password does not matched")
							member_password.focus();
							return false;
						}
						
					if(Trim(member_houseno.value)=="")
						{
							alert("Please specify the house number")
							member_houseno.focus();
							return false;
						}
						
						if(Trim(member_address_1.value)=="")
						{
							alert("Please specify the Address")
							member_address_1.focus();
							return false;
						}
						if(Trim(member_address_2.value)=="")
						{
							alert("Please specify the Address")
							member_address_2.focus();
							return false;
						}
						if(Trim(member_city.value)=="")
						{
							alert("Please specify the city name")
							member_city.focus();
							return false;
						}
						if(Trim(txtstate.value)=="")
						{
							alert("Please specify the county/state")
							txtstate.focus();
							return false;
						}
						
						if(Trim(member_postcode.value)=="")
						{
							alert("Please specify the postcode")
							member_postcode.focus();
							return false;
						}
						if(Trim(member_telephone.value)=="")
						{
							alert("Please specify the telephone number")
							member_telephone.focus();
							return false;
						}
							
	}

}



function chk_valid_delivery()
{
	with(document.frm1)
	
	{
					if(txt_title.value==" ")
						{
							alert("Please select title")
							txt_title.focus();
							return false;
						}
					if(Trim(txt_first_name.value)=="")
						{
							alert("Please specify the first  name")
							txt_first_name.focus();
							return false;
						}
					if(Trim(txt_last_name.value)=="")
						{
							alert("Please specify the Last  name")
							txt_last_name.focus();
							return false;
						}
					if(Trim(txthouseno.value)=="")
						{
							alert("Please specify the House number");
							txthouseno.focus();
							return false;
						}
					if(Trim(txt_address1.value)=="")
						{
							alert("Please specify the Address 1");
							txt_address1.focus();
							return false;
						}
					if(Trim(txt_city.value)=="")
						{
							alert("Please specify the city name");
							txt_city.focus();
							return false;
						}							
					if(Trim(txt_county.value)=="")
						{
							alert("Please specify the country name");
							txt_county.focus();
							return false;
						}	
					if(Trim(txt_post_code.value)=="")
						{
							alert("Please specify the post code");
							txt_post_code.focus();
							return false;
						}	
					if(Trim(txt_phone.value)=="")
						{
							alert("Please specify the phone number");
							txt_phone.focus();
							return false;
						}	
												
					if(!echeck(txtemail.value))
						{
							txtemail.focus();
							return false;
						}
					
							
	}

}


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)
		{
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Sorry invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Sorry invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Sorry invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Sorry invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Sorry invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Sorry invalid E-mail ID")
		    return false;
		 }

 		 return true;
}



function chk_change_password()
{
	with(document.frm1)
	
	{
					 
					
					if(Trim(txt_current_password.value)=="")
						{
							alert("Please specify current password")
							txt_current_password.focus();
							return false;
						}				
					if(Trim(txt_new_password.value)=="")
						{
							alert("Please specify new password")
							txt_new_password.focus();
							return false;
						}

					if(txt_new_password.value.length<6)

						{
							alert("Password should have minimum 6 characters")
							txt_new_password.focus();
							return false;
						}
					if(Trim(txt_confirm_password.value)=="")
						{
							alert("Please specify the confirm password")
							txt_confirm_password.focus();
							return false;
						}
					if(txt_confirm_password.value!=txt_new_password.value)
						{
							alert("Confirm password does not metched")
							txt_confirm_password.focus();
							return false;
						}
						
												
	}

}





function valid_contact_us()
{
	with(document.frm1)
	{
				if(Trim(txt_first_name.value)=="")
						{
							alert("Please specify the first  name")
							txt_first_name.focus();
							return false;
						}
				if(Trim(txt_email.value)=="")
						{
							alert("Please specify the email")
							txt_email.focus();
							return false;
						}
				if(!echeck(txt_email.value))
						{
							txt_email.focus();
							return false;
						}
				if(Trim(txt_msg.value)=="")
						{
							alert("Please specify the message")
							txt_msg.focus();
							return false;
						}
				
	
	
	
	}
	
}


function valid_email_to_friend()
{
with(document.frmemail)
	{
	if(txt_to.value=="")
		{
		alert("Please specify email address");
		txt_to.focus();
		return false;
		}
	if(!echeck(txt_to.value))
		{
		txt_to.focus();
		return false;
		}
	if(txt_from.value=="")
		{
		alert("Please specify your email address");
		txt_from.focus();
		return false;
		}
	if(!echeck(txt_from.value))
		{
		txt_from.focus();
		return false;
		}
	}
}

function valid_trade()
{
with(document.frmtrade)
	{
	
	if(Trim(txt_title.value)=="")
		{
		alert("Please select title")
		txt_title.focus();
		return false;		
		}
	
	if(Trim(txt_first_name.value)=="")
		{
		alert("Please specify first name")
		txt_first_name.focus();
		return false;		
		}
	if(Trim(txt_last_name.value)=="")
		{
		alert("Please specify last name")
		txt_last_name.focus();
		return false;		
		}
	if(Trim(txt_com_name.value)=="")
		{
		alert("Please specify your company name")
		txt_com_name.focus();
		return false;		
		}
	if(Trim(txt_add1.value)=="")
		{
		alert("Please specify your address")
		txt_add1.focus();
		return false;		
		}
	if(Trim(txt_city.value)=="")
		{
		alert("Please specify your city/town")
		txt_city.focus();
		return false;		
		}
	if(Trim(txt_state.value)=="")
		{
		alert("Please specify your county/state")
		txt_state.focus();
		return false;		
		}
	if(Trim(txt_post.value)=="")
		{
		alert("Please specify your post code")
		txt_post.focus();
		return false;		
		}
	if(Trim(txt_email.value)=="")
		{
		alert("Please specify your email address")
		txt_email.focus();
		return false;		
		}
	if(!echeck(txt_email.value))
		{
		txt_email.focus();
		return false;
		}
	if(Trim(txt_phone.value)=="")
		{
		alert("Please specify your phone number")
		txt_phone.focus();
		return false;		
		}
	}
}



function validchangepassword()
{
	with(document.frmspassword)
			{
				if (txtpassword.value=="")
					{
					alert("Please specify the password");
					txtpassword.focus();
					return false;
					}
				if (txtnewpassword.value=="")
					{
					alert("Please specify the new password");
					txtnewpassword.focus();
					return false;
					}
				if (txtnewpassword.value.length<6)
					{
					alert("Password should have minimum 6 Characters");
					txtnewpassword.focus();
					return false;
					}				
				if (txtconfirmpassword.value=="")
					{
					alert("Please specify confirm password");
					txtconfirmpassword.focus();
					return false;
				}
				
				if(txtnewpassword.value!=txtconfirmpassword.value)
				{
					alert("Sorry password does not matched ");
					txtconfirmpassword.focus();
					return false;
				}
				
				
				
			}
return true;
}


function valid_email()
{
with(document.frmforgot)
	{
	if(!echeck(member_login_email.value))
		{
		member_login_email.focus();
		return false;
		}
	
	}

}


function valid_s_contect()
{
with(document.frm_show_contect)
	{
	if(!echeck(email.value))
		{
		email.focus();
		return false;
		}
	
	}

}

function chk_contact()
{
with(document.frm_contact)
	{
	if(txt_title.value==" ")
		{
		alert("Please select title")
		txt_title.focus();
		return false;	
		}
	if(txt_last_name.value=="")
		{
		alert("Please specify last name")
		txt_last_name.focus();
		return false;	
		}
	
	}

}

function chk_valid_email()
{
with(document.frmdefault)
	{
	if(!echeck(txt_email.value))
		{
		txt_email.focus();
		return false;
		}
	
	}

}

function valid_keyword()
{
with(document.frm_keword)
	{
	if(keyword.value=="")
		{
		alert("Please enter some keword to search");
		keyword.focus();
		return false;
		}
	
	}
}


function chk_feedback()
{
with(document.frm_feedback)
	{
	if(txt_name.value=="")
		{
		alert("Please enter your name");
		txt_name.focus();
		return false;
		}
	if(!echeck(txt_email.value))
		{
		txt_email.focus();
		return false;
		}
	if(txt_msg.value=="")
		{
		alert("Please enter some message");
		txt_msg.focus();
		return false;
		}

	}
}




