﻿// JScript File

function uselogin()
{

             if(document.form1.txt_user.value=="")
			{
				alert("Do not leave the Email-ID field blank");
				document.form1.txt_user.focus();
				return false;	
			}

						
			if(document.form1.txt_password.value=="")
			{
				alert("Do not leave the  PASSWORD field blank");
				document.form1.txt_password.focus();
				return false;	
			}
			return true;
}

function order_books()
{
            if(document.form1.txt_name.value=="")
			{
				alert("Do not leave the Firstname field blank");
				document.form1.txt_name.focus();
				return false;	
			}
			if(document.form1.txt_second.value=="")
			{
				alert("Do not leave the Lastname field blank");
				document.form1.txt_second.focus();
				return false;	
			}
			if(document.form1.txt_mail.value=="")
			{
				alert("Do not leave the Contact Mail Address field blank");
				document.form1.txt_mail.focus();
				return false;	
			}
			if(document.form1.txt_telphne.value=="")
			{
			
				alert("Do not leave the Telephone Number field blank");
				document.form1.txt_telphne.focus();
				return false;	
			}
			
			if(isNaN(document.form1.txt_telphne.value))
			{
			    alert("Enter Numerical Value ");
				document.form1.txt_telphne.focus();
				return false;
			}
			
			if(document.form1.txt_email.value=="")
			{
				alert("Do not leave the Email-ID field blank");
				document.form1.txt_email.focus();
				return false;	
			}
			else
			{			
			     var Emailid=document.form1.txt_email.value;
		       reEmail=new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
		        if(!reEmail.test(Emailid))
		        {
		        alert("Email Id is not valid.");
		        document.form1.txt_email.focus();
		        document.form1.txt_email.select();
			       return false;	
		        }
		    }
		    
		    if((document.form1.txt_email.value) != (document.form1.txt_confirm.value))
	        {
		     alert("The Email-ID & Confirm Email-ID need to be the same");
		     document.form1.txt_email.value="";
		     document.form1.txt_confirm.value="";
		     document.form1.txt_email.focus();
		     		     
		     return false;
	        }

	      if(document.form1.txt_parish.value=="")
			{
				alert("Do not leave the Parish field blank");
				document.form1.txt_parish.focus();
				return false;	
			}
			if(document.form1.txt_vicar.value=="")
			{
				alert("Do not leave the Vicar field blank");
				document.form1.txt_vicar.focus();
				return false;	
			}
			
			
	      

}

function ovbs_mailid()
{

           if(document.form1.txt_email.value=="")
			{
				alert("Do not leave the Email-ID field blank");
				document.form1.txt_email.focus();
				return false;	
			}
			else
			{			
			     var Emailid1=document.form1.txt_email.value;
		       reEmail=new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
		        if(!reEmail.test(Emailid1))
		        {
		        alert("Email Id is not valid.");
		        document.form1.txt_email.focus();
		        document.form1.txt_email.select();
			    return false;	
		        }
		  }

return true;
}

function forgotpassword()
{
           if(document.form1.txt_mail.value=="")
			{
				alert("Do not leave the Email-ID field blank");
				document.form1.txt_mail.focus();
				return false;	
			}
			else
			{			
			     var Emailid=document.form1.txt_mail.value;
		       reEmail=new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
		        if(!reEmail.test(Emailid))
		        {
		        alert("Email Id is not valid.");
		        document.form1.txt_mail.focus();
		        document.form1.txt_mail.select();
			    return false;	
		        }
		    }
}


function ovbs_registration()
{

             if(document.form1.txt_firstname.value=="")
			{
				alert("Do not leave the Firstname field blank");
				document.form1.txt_firstname.focus();
				return false;	
			}

						
			if(document.form1.txt_lastname.value=="")
			{
				alert("Do not leave the Lastname field blank");
				document.form1.txt_lastname.focus();
				return false;	
			}
			
												
			
	    	if(document.form1.txt_email.value=="")
			{
				alert("Do not leave the Email-ID field blank");
				document.form1.txt_email.focus();
				return false;	
			}
			else
			{			
			     var Emailid=document.form1.txt_email.value;
		       reEmail=new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
		        if(!reEmail.test(Emailid))
		        {
		        alert("Email Id is not valid.");
		        document.form1.txt_email.focus();
		        document.form1.txt_email.select();
			       return false;	
		        }
		    } 
		    
		    if(document.form1.txt_password.value=="")
			{
				alert("Do not leave the Password field blank");
				document.form1.txt_password.focus();
				return false;	
			}
			
			if(document.form1.txt_confirmpassword.value=="")
			{
				alert("Do not leave the RE-ENTER PASSWORD field blank");
				document.form1.txt_confirmpassword.focus();
				return false;	
			}
			
		   if((document.form1.txt_password.value) != (document.form1.txt_confirmpassword.value))
			
	       {
		     alert("The PASSWORD & RE-ENTERED PASSWORD need to be the same");
		     document.form1.txt_password.value="";
		     document.form1.txt_confirmpassword.value="";
		     document.form1.txt_password.focus();
		     		     
		     return false;
	      }
		    
			
			if(document.form1.txt_parish.value=="")
			{
				alert("Do not leave the Parish field blank");
				document.form1.txt_parish.focus();
				return false;	
			}
			
			if(document.form1.txt_city.value=="")
			{
				alert("Do not leave the City field blank");
				document.form1.txt_city.focus();
				return false;	
			}
				
				
				if(document.form1.txt_state.value=="")
			{
				alert("Do not leave the State field blank");
				document.form1.txt_state.focus();
				return false;	
			}
			
			if(document.form1.txt_country.value=="")
			{
				alert("Do not leave the Country field blank");
				document.form1.txt_country.focus();
				return false;	
			}
						
			if(document.form1.TextBox1.value=="")
			{
				alert("Enter Date");
				document.form1.TextBox1.focus();
				return false;	
			}
			
			if(document.form1.TextBox1.value!="")
			{
		var dob=document.form1.TextBox1.value;		
        document.form1.HiddenField1.value=document.form1.TextBox1.value;
            }
			
						
			
			return true;
}


  function grandtotal()
        {
            
          
            var grid = document.getElementById("gd_itemmaster");
           
             var btnvisible = document.getElementById("btn_orderbooks");
            
            
           btnvisible.style.visibility='hidden';
           
            //variable to contain the cell of the grid
            var cell,grandtotal=0,cval;
            var cell2,cell3;
            var k,x,M=2,p=5;
            var rowtotals,rowrecord;
             document.getElementById("lbl_gt").innerHTML=0;
            if (grid.rows.length > 0)
            {  
           
            
                //loop starts from 1. rows[0] points to the header.
                for (i=1; i<grid.rows.length; i++)
                {
                    //get the reference of first column
                    cell2 = grid.rows[i].cells[2];
                    cell = grid.rows[i].cells[3];
                  
                   
                    //loop according to the number of childNodes in the cell
                    for (j=0; j<cell.childNodes.length; j++)
                    {                                             
                               
                        if (cell.childNodes[j].type =="text")
                        {    
                         if(eval(M)<10) M="0"+M;
                         document.getElementById('gd_itemmaster_ctl'+M+'_amt').value=""; 
                       
                          
                              if (cell.childNodes[j].value!= "")
                              { 
                                     
                                    for (k=0; k<cell2.childNodes.length; k++)
                                    {        
                                         if(isNaN(cell.childNodes[j].value))
                                         {   
                                             p=6;
                                              cell.childNodes[j].value="";
                                               cell.childNodes[j].focus();
                                               btnvisible.style.visibility='hidden';
                                               alert("Enter Numerical Value");
                                           
                                             break;
                                         }
                                         
                                         else
                                         {     
                                              //if(eval(M)<10) M="0"+M;
                                              rowtotals=parseFloat(cell.childNodes[j].value)* parseFloat(cell2.childNodes[j].value);                                                               
                                               
                                              document.getElementById('gd_itemmaster_ctl'+M+'_amt').value=parseFloat(rowtotals);   
                                             
                                               document.form1.HiddenRowtotal.value+=parseFloat(rowtotals)+',';
                                              
                                               grandtotal =grandtotal+parseFloat(cell.childNodes[j].value)* parseFloat(cell2.childNodes[j].value);
                                                          
                                                 
                                               if(k >= 0)
                                               {  
                                                
                                               M=eval(M)+1;                                                      
                                                break;
                                               }  
                                          }
                                                                             
                                    }
                                     
                                                           
                              }
                             else if(cell.childNodes[j].value=="")
                                    {
                                       M=eval(M)+1;                                        
                                       break;
                                    } 
                               
                              
                                                        
                         }    
                         
                            
                    }    
                    
                    
                }
                
               // document.getElementById('Label1').value=grandtotal;             
              
            }
            
             if(grandtotal==0 ||grandtotal=="")
             {  
                 if(p==6)
                 {
                 }
                 else
                 {
                  p=5;
                  alert("Enter Quantity Required")
                 }
             
              return false;
             }
             else
             {
             //document.getElementById("tAmt").innerHTML =parseFloat(grandtotal);
             document.getElementById("lbl_gt").innerHTML =parseFloat(grandtotal);
             document.form1.HiddenField3.value=parseFloat(grandtotal);
             btnvisible.style.visibility='visible';
             return false;
             }
           return true;
            
            
        }

 
			

 function textmsg()
 {
   alert("haiiiiiiiiiiiiiiiii");
 }
 
 
 
 
 
 