
function nwindowlogout()
{
	nwindow=window.open("Logout.asp","","scrollbars=no,titlebar=no,Width=360,Height=250,resizeable=no,directories=no,alwaysRaised=yes");
}
function vali(s)
{
	var check=0;
	var len = s.length
 	for (var i=0;i<len;++i)
	{
	  if(s.charCodeAt(i)<65 || s.charCodeAt(i)>122)
 	  {
		check=1;
		if (s.charCodeAt(i)>=48 || s.charCodeAt(i)<=57)
		{
			check=0;
		}
		if (s.charCodeAt(i)==32)
		{
			check=1;
		}
	  }
	  else
	  {
		check=0;
	  }
	  if (check==1)
	  {
		return true;
	  }
	}
	return false;
}

function check()
{
	if (document.myform.Username.value=="")
	{
		alert("Please enter login name");
		document.myform.Username.focus();
		return false;
	}
	if(vali(document.myform.Username.value))
	{
		alert("Please choose a valid user id");
		document.myform.Username.focus();
		return false;
	}
	if(document.myform.Username.value.length<3)
	{
		 alert("The Username field should be between 3 and 15 characters");
		 document.myform.Username.focus();
		 return false;
	}
	if (!isNaN(document.myform.Username.value))
	{
		alert("Username can't be numeric");
		document.myform.Username.focus();
		document.myform.Username.select();
		return false;
	}
	if (document.myform.Password.value == "")
	{
		alert("Please choose a valid Password");
		document.myform.Password.focus();
		return false;
	}
	if(vali(document.myform.Password.value))
	{
		alert("Please choose a valid Password");
		document.myform.Password.focus();
		return false;
	}
	if (document.myform.Name.value=="")
	{
		alert("Please enter business name");
		document.myform.Name.focus();
		return false;
	}
	if (document.myform.Zip.value=="")
	{
		alert("Please enter zip code");
		document.myform.Zip.focus();
		return false;
	}
	var checkZip = "0123456789";
	var checkStr1 = myform.Zip.value;
	var allValid1 = true;
	for (i = 0;  i < checkStr1.length;  i++)
	{
		ch = checkStr1.charAt(i);
		for (j = 0;  j < checkZip.length;  j++)
			if (ch == checkZip.charAt(j))
				break;
			if (j == checkZip.length)
			{
				allValid1 = false;
				break;
			}
	}
	if (!allValid1)
	{
	  alert("Please enter only nymber in Zip");
	  myform.Zip.focus();
	  return (false);
	}

	var checkOK = "0123456789--,+() \t\r\n\f";
	var checkStr = myform.Phone.value;
	var allValid = true;
	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 (!allValid)
	{
	  alert("Please enter valid Phone no");
	  myform.Phone.focus();
	  return (false);
	}

	var str=document.myform.Email.value
	if (document.myform.Email.value.indexOf("@") == 0)
	{
	alert("Invalid Email: Email cannot start with @ ");
	document.myform.Email.focus();
	document.myform.Email.select();
	return(false);
	}
	if (document.myform.Email.value.indexOf("@",1) == -1)
	{
		alert("Please enter your preferred Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return(false);
	}
	if (document.myform.Email.value.indexOf(".") == 0)
	{
		alert("Please enter your proper Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return(false);
	}
	if (document.myform.Email.value.indexOf(".",1) == -1)
	{
		alert("Please enter your preferred Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return(false);
	}
	var posat=str.indexOf("@");
	var posdot=str.indexOf(".");
	var rposdot=str.lastIndexOf(".");
	if(rposdot==posdot)
	if((posdot < posat) || (posdot-posat < 3))
	{
		alert("Please enter your proper Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return false;
	}
	if(str.charAt(str.length-1)==".")
	{
		alert("Please enter your proper Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return false;
	}
	if(str.charAt(str.length-1)=="@")
	{
		alert("Please enter your proper Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return false;
	}
	var j=0;
	for( var i=0;i<str.length;i++)
	{
		if(str.charAt(i) == "@")
		j++;
	}
	if(j > 1)
	{
		alert("Please enter your proper Email address");
		document.myform.Email.focus();
		document.myform.Email.select();
		return false;
	}
	return true;
}

