// JavaScript Document

function checktxtemail()
 {
  a=new Array();
  s=document.book.txtemail.value;
  for(i=0; i<s.length; i++)
    {
     a[i]=s.charAt(i);
    }
   dot = s.indexOf(".");
   at   = s.indexOf("@");
   if (dot == -1 || at == -1)
    {
       document.book.txtemail.focus()
       alert ("Email id does not exist");
       return 1;
     }
       str1=s.substring(dot+1,s.length);
       str2=s.substring(at+1, dot);
       str3=s.substring(0,at);
       if((str2.length==0)||(str3.length==0))
          {
             document.book.txtemail.focus()     
             alert ("Invalid email id");
             return 1;
          }
         return 0;
     }
	 
	 
/*function checkphone()
{
  s=document.pkinfo.txtphone.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.pkinfo.txtphone.focus();
	         alert("Invalid Phone Number");
	         document.pkinfo.txtphone.value="";
	          return 1;
	         }
             }

return 0;
}*/


function checknop() //no of persons
{
  s=document.book.txtnop.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.book.txtnop.focus();
	         alert("Invalid Number of Persons");
	         document.book.txtnop.value="";
	          return 1;
	         }
             }

return 0;
}


/*function checknoc() //no of children
{
  s=document.pkinfo.txtnochild.value;
var z;
z=new Array();
for(j=0;j<s.length;j++)
                {
                  z[j]=s.charAt(j);
                  if((z[j]>='0')&&(z[j]<='9')||(z[j]=='-')&&(j==s.length-7)&&(j==4)&&count!=1)
                     {
	     if (z[j]=='-')
	       {
	           counter=1;
	         }
	       continue;
	     }
	     else
	      {
	         document.pkinfo.txtnochild.focus();
	         alert("Invalid Number of Children");
	         document.pkinfo.txtnochild.value="";
	          return 1;
	         }
             }

return 0;
}*/


function checkdot()
{
var z;
var s;
var ss;
    z=new Array();
    s=document.book.txtchkin.value
	ss=document.book.txtchkout.value
    if(s.value=="" || ss.value=="") //validity ?   TODO
      { 
           
           alert("Please fill in Date of Check in / Check Out!!");
           
           return 1;          
        }
        
return 0;
}



function checknames()
{
var z;
var s;
    z=new Array();
    s=document.book.txtname.value
    for(j=0; j<s.length; j++)
      { 
        z[j]=s.charAt(j);
        if(!( ( (z[j]>='a')&&(z[j]<='z') ) || ( (z[j]>='A')&&(z[j]<='Z') ) ||  (z[j]==' ')  ) )
          {
           document.book.txtname.focus();
           alert("Invalid Name");
           document.book.txtname.value="";
           return 1;          
          }
        }
return 0;
}


function checkem()
{
	var e=0	
	var f = document.forms[0];
	
	if(f.txtname.value==""  || f.txtchkin.value=="" || f.txtchkout.value=="" || f.txtnop.value==""  ||  f.txtemail.value==""  )
{
	alert("Please fill in the required information !!!");
	return;
}

if(checknames()==0  && checktxtemail()==0  && checkdot()==0 && checknop()==0) //date check pending
{
	
     document.book.submit();
	
}

}