﻿function ValidateLoginForm()
    {  
    var dept=document.getElementById('ddldept');
    if(dept.value == "--Select--")
    {
            alert("Please select department");
            dept.focus();
            return false;
    }
      
    
    var password=document.getElementById('txtpassword');
    if(password.value.length <= 0 || password.value == " " )
    {
        alert("Please enter your password");
        password.focus();
        return false;
    }
  }
  //---------------------------------------
  function validateSeacrhForm()
  {
        var dept=document.getElementById('ddldept');
        var dist=document.getElementById('ddldistrict');
    if(dept.value == "--Select--" && dept.value == "--Select--")
    {
            alert("Please select atleast one option: Department or District");
            dept.focus();
            return false;
    }    
    
  }
  //----------------------------------------
  function statusmsg(msg)
    {
            window.status = msg;
    }    
    
    
function validateDate(date,month,year)
{

if(year.value!='-1' && eval(year.value%4)!=0) 
 {      
   if(month.value!='-1') 
    { 
      if(month.value==4 || month.value==6 || month.value==9 || month.value==11) 
       { 
         if(date.value!='-1' && date.value>30)
          {
            alert('Select Valid Date !');
            date.value='-1';
          } 
       } 
     if(month.value==2) 
       { 
         if(date.value!='-1' && date.value>28)
           { 
             alert('Select Valid Date !');
             date.value='-1';
           } 
       } 
    } 
 } 


if(year.value!='-1' && eval(year.value%4)==0) 
 { 
   if(month.value!='-1') 
     { 
       if(month.value==4 || month.value==6 || month.value==9 || month.value==11) 
         { 
           if(date.value!='-1' && date.value>30)
             { 
              alert('Select Valid Date !');
              date.value='-1';
             } 
         } 
           if(month.value==2) 
              { 
               if(date.value!='-1' && date.value>29)
                  { 
           	     alert('Select Valid Date !');
           	     date.value='-1';
         	      } 
      	      } 
      } 
  } //if year
}//function 

function Integer()
{
    if(event.keyCode >= 48 && event.keyCode <= 57)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function ValidateUploadForm()
{

    var dist=document.getElementById('ddldistrict');
    if(dist.selectedIndex <= 0)
    {
    
        alert("Please select district");
        dist.style.backgroundColor='#ffe0cc';
        dist.focus();
        return false;
    }
    
    var email=document.getElementById('txtemail');
    if(email.value.length > 0)
    {
        if (email.value.indexOf("@", 0) < 0)
            {
                alert("Invalid email id");
                email.style.backgroundColor='#ffe0cc';
                email.focus();
                return false;
            }
        if (email.value.indexOf(".", 0) < 0)
            {
                alert("Invalid email id");
                email.style.backgroundColor='#ffe0cc';
                email.focus();
                return false;
            }
    }        
    
    var date1=document.getElementById('ddlDay1');
    var month1=document.getElementById('ddlMonth1');
    var year1=document.getElementById('ddlYear1'); 
    
   if(date1.selectedIndex <=0)
    {
         alert("Please select day");
         date1.style.backgroundColor='#ffe0cc';
         date1.focus();
         return false;
    }
    
    if(month1.selectedIndex <= 0 )
    {
         alert("Please select month");
         month1.style.backgroundColor='#ffe0cc';
         month1.focus();
         return false;
    }
    
    if(year1.selectedIndex <=0)
    {
         alert("Please select year");
         year1.style.backgroundColor='#ffe0cc';
         year1.focus();
         return false;
    }   
    
//    var h1=document.getElementById('ddlH1');
//    var m1=document.getElementById('ddlM1');
//    
//   if(h1.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h1.style.backgroundColor='#ffe0cc';
//         h1.focus();
//         return false;
//    }
//    
//    if(m1.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m1.style.backgroundColor='#ffe0cc';
//         m1.focus();
//         return false;
//    }
    
    //---------------    
    
    
//    var date2=document.getElementById('ddlDay2');
//    var month2=document.getElementById('ddlMonth2');
//    var year2=document.getElementById('ddlYear2'); 

//       if(date2.selectedIndex <=0)
//        {
//             alert("Please select day");
//             date2.style.backgroundColor='#ffe0cc';
//             date2.focus();
//             return false;
//        }
//        
//        if(month2.selectedIndex <= 0 )
//        {
//             alert("Please select month");
//             month2.style.backgroundColor='#ffe0cc';
//             month2.focus();
//             return false;
//        }
//        
//        if(year2.selectedIndex <=0)
//        {
//             alert("Please select year");
//             year2.style.backgroundColor='#ffe0cc';
//             year2.focus();
//             return false;
//        }   

//    var h2=document.getElementById('ddlH2');
//    var m2=document.getElementById('ddlM2');
//    
//   if(h2.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h2.style.backgroundColor='#ffe0cc';
//         h2.focus();
//         return false;
//    }
//    
//    if(m2.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m2.style.backgroundColor='#ffe0cc';
//         m2.focus();
//         return false;
//    }
    
    //----------------
    
    var date3=document.getElementById('ddlDay3');
    var month3=document.getElementById('ddlMonth3');
    var year3=document.getElementById('ddlYear3'); 
    
   if(date3.selectedIndex <=0)
    {
         alert("Please select day");
         date3.style.backgroundColor='#ffe0cc';
         date3.focus();
         return false;
    }
    
    if(month3.selectedIndex <= 0 )
    {
         alert("Please select month");
         month3.style.backgroundColor='#ffe0cc';
         month3.focus();
         return false;
    }
    
    if(year3.selectedIndex <=0)
    {
         alert("Please select year");
         year3.style.backgroundColor='#ffe0cc';
         year3.focus();
         return false;
    }   
    
//    var h3=document.getElementById('ddlH3');
//    var m3=document.getElementById('ddlM3');
//    
//   if(h3.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h3.style.backgroundColor='#ffe0cc';
//         h3.focus();
//         return false;
//    }
//    
//    if(m3.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m3.style.backgroundColor='#ffe0cc';
//         m3.focus();
//         return false;
//    }
    
    //----------------
    
//   var date4=document.getElementById('ddlDay4');
//    var month4=document.getElementById('ddlMonth4');
//    var year4=document.getElementById('ddlYear4'); 
//    
//   if(date4.selectedIndex <=0)
//    {
//         alert("Please select day");
//         date4.style.backgroundColor='#ffe0cc';
//         date4.focus();
//         return false;
//    }
//    
//    if(month4.selectedIndex <= 0 )
//    {
//         alert("Please select month");
//         month4.style.backgroundColor='#ffe0cc';
//         month4.focus();
//         return false;
//    }
//    
//    if(year4.selectedIndex <=0)
//    {
//         alert("Please select year");
//         year4.style.backgroundColor='#ffe0cc';
//         year4.focus();
//         return false;
//    }   

//    var h4=document.getElementById('ddlH4');
//    var m4=document.getElementById('ddlM4');
//    
//   if(h4.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h4.style.backgroundColor='#ffe0cc';
//         h4.focus();
//         return false;
//    }
//    
//    if(m4.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m4.style.backgroundColor='#ffe0cc';
//         m4.focus();
//         return false;
//    }
    
    //----------------
    var fileupload = document.getElementById('FileUpload1');
    if(fileupload.value.length <= 0 || fileupload.value == " " )
    {
         alert("Please select file to upload");
         fileupload.style.backgroundColor='#ffe0cc';
         fileupload.focus();
         return false;
    }
   //check for file type
     var validfileext=new Array(".pdf",".PDF");
     var tenfile = document.getElementById('FileUpload1').value;
     var totallen=tenfile.length;
     var pos=tenfile.indexOf(".")
     var allowSubmit = false;
     var ext=tenfile.substring(pos,totallen);
    for (var i = 0; i < validfileext.length; i++) 
        {
            //check to see if it's the proper extension
            if (validfileext[i] == ext) 
            { 
                //it's the proper extension
                allowSubmit = true;                 
                //return true;
            }
        }
        if (allowSubmit == false)
        {
            alert('Please select pdf file to upload');
            document.getElementById('FileUpload1').style.backgroundColor='#ffe0cc';
            document.getElementById('FileUpload1').focus();
            return false;
        }

    var fileupload2 = document.getElementById('FileUpload2');
    if(fileupload2.value.length >0 )
    {
      //check for file type
     var validfileext=new Array(".pdf",".PDF");
     var tenfile = document.getElementById('FileUpload2').value;
     var totallen=tenfile.length;
     var pos=tenfile.indexOf(".")
     var allowSubmit = false;
     var ext=tenfile.substring(pos,totallen);
    for (var i = 0; i < validfileext.length; i++) 
        {
            //check to see if it's the proper extension
            if (validfileext[i] == ext) 
            { 
                //it's the proper extension
                allowSubmit = true;                 
                return true;
            }
        }
        if (allowSubmit == false)
        {
            alert('Please select pdf file to upload');
            document.getElementById('FileUpload2').style.backgroundColor='#ffe0cc';
            document.getElementById('FileUpload2').focus();
            return false;
        }
        else
        {
            return true
        }    
    }         
}

function ValidateUpdateForm()
{
        var dist=document.getElementById('ddldistrict');
    if(dist.selectedIndex <= 0)
    {
    
        alert("Please select district");
        dist.style.backgroundColor='#ffe0cc';
        dist.focus();
        return false;
    }
    
    var email=document.getElementById('txtemail');
    if(email.value.length > 0)
    {
        if (email.value.indexOf("@", 0) < 0)
            {
                alert("Invalid email id");
                email.style.backgroundColor='#ffe0cc';
                email.focus();
                return false;
            }
        if (email.value.indexOf(".", 0) < 0)
            {
                alert("Invalid email id");
                email.style.backgroundColor='#ffe0cc';
                email.focus();
                return false;
            }
    }        
    
       var date1=document.getElementById('ddlDay1');
    var month1=document.getElementById('ddlMonth1');
    var year1=document.getElementById('ddlYear1'); 
    
   if(date1.selectedIndex <=0)
    {
         alert("Please select day");
         date1.style.backgroundColor='#ffe0cc';
         date1.focus();
         return false;
    }
    
    if(month1.selectedIndex <= 0 )
    {
         alert("Please select month");
         month1.style.backgroundColor='#ffe0cc';
         month1.focus();
         return false;
    }
    
    if(year1.selectedIndex <=0)
    {
         alert("Please select year");
         year1.style.backgroundColor='#ffe0cc';
         year1.focus();
         return false;
    }   
    
//    var h1=document.getElementById('ddlH1');
//    var m1=document.getElementById('ddlM1');
//    
//   if(h1.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h1.style.backgroundColor='#ffe0cc';
//         h1.focus();
//         return false;
//    }
//    
//    if(m1.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m1.style.backgroundColor='#ffe0cc';
//         m1.focus();
//         return false;
//    }
    
    //---------------
    
    
    
//    var date2=document.getElementById('ddlDay2');
//    var month2=document.getElementById('ddlMonth2');
//    var year2=document.getElementById('ddlYear2'); 
//    
//   if(date2.selectedIndex <=0)
//    {
//         alert("Please select day");
//         date2.style.backgroundColor='#ffe0cc';
//         date2.focus();
//         return false;
//    }
//    
//    if(month2.selectedIndex <= 0 )
//    {
//         alert("Please select month");
//         month2.style.backgroundColor='#ffe0cc';
//         month2.focus();
//         return false;
//    }
//    
//    if(year2.selectedIndex <=0)
//    {
//         alert("Please select year");
//         year2.style.backgroundColor='#ffe0cc';
//         year2.focus();
//         return false;
//    }   
    
//    var h2=document.getElementById('ddlH2');
//    var m2=document.getElementById('ddlM2');
//    
//   if(h2.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h2.style.backgroundColor='#ffe0cc';
//         h2.focus();
//         return false;
//    }
//    
//    if(m2.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m2.style.backgroundColor='#ffe0cc';
//         m2.focus();
//         return false;
//    }
    
    //----------------
    
    var date3=document.getElementById('ddlDay3');
    var month3=document.getElementById('ddlMonth3');
    var year3=document.getElementById('ddlYear3'); 
    
   if(date3.selectedIndex <=0)
    {
         alert("Please select day");
         date3.style.backgroundColor='#ffe0cc';
         date3.focus();
         return false;
    }
    
    if(month3.selectedIndex <= 0 )
    {
         alert("Please select month");
         month3.style.backgroundColor='#ffe0cc';
         month3.focus();
         return false;
    }
    
    if(year3.selectedIndex <=0)
    {
         alert("Please select year");
         year3.style.backgroundColor='#ffe0cc';
         year3.focus();
         return false;
    }   
    
//    var h3=document.getElementById('ddlH3');
//    var m3=document.getElementById('ddlM3');
//    
//   if(h3.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h3.style.backgroundColor='#ffe0cc';
//         h3.focus();
//         return false;
//    }
//    
//    if(m3.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m3.style.backgroundColor='#ffe0cc';
//         m3.focus();
//         return false;
//    }
    
    //----------------
    
//   var date4=document.getElementById('ddlDay4');
//    var month4=document.getElementById('ddlMonth4');
//    var year4=document.getElementById('ddlYear4'); 
//    
//   if(date4.selectedIndex <=0)
//    {
//         alert("Please select day");
//         date4.style.backgroundColor='#ffe0cc';
//         date4.focus();
//         return false;
//    }
//    
//    if(month4.selectedIndex <= 0 )
//    {
//         alert("Please select month");
//         month4.style.backgroundColor='#ffe0cc';
//         month4.focus();
//         return false;
//    }
//    
//    if(year4.selectedIndex <=0)
//    {
//         alert("Please select year");
//         year4.style.backgroundColor='#ffe0cc';
//         year4.focus();
//         return false;
//    }   

//     var h4=document.getElementById('ddlH4');
//    var m4=document.getElementById('ddlM4');
//    
//   if(h4.selectedIndex <=0)
//    {
//         alert("Please select hour");
//         h4.style.backgroundColor='#ffe0cc';
//         h4.focus();
//         return false;
//    }
//    
//    if(m4.selectedIndex <= 0 )
//    {
//         alert("Please select minute");
//         m4.style.backgroundColor='#ffe0cc';
//         m4.focus();
//         return false;
//    }    
}
function ValidateFileType()
{

var fileupload = document.getElementById('FileUpload1');
    if(fileupload.value.length <= 0 || fileupload.value == " " )
    {
         alert("Please select file to upload");
         fileupload.style.backgroundColor='#ffe0cc';
         fileupload.focus();
         return false;
    }
   //check for file type
     var validfileext=new Array(".pdf",".PDF");
     var tenfile = document.getElementById('FileUpload1').value;
     var totallen=tenfile.length;
     var pos=tenfile.indexOf(".")
     var allowSubmit = false;
     var ext=tenfile.substring(pos,totallen);
    for (var i = 0; i < validfileext.length; i++) 
        {
            //check to see if it's the proper extension
            if (validfileext[i] == ext) 
            { 
                //it's the proper extension
                allowSubmit = true;                 
                //return true;
            }
        }
        if (allowSubmit == false)
        {
            alert('Please select pdf file to upload');
            document.getElementById('FileUpload1').style.backgroundColor='#ffe0cc';
            document.getElementById('FileUpload1').focus();
            return false;
        }

    var fileupload2 = document.getElementById('FileUpload2');
    if(fileupload2.value.length >0 )
    {
      //check for file type
     var validfileext=new Array(".pdf",".PDF");
     var tenfile = document.getElementById('FileUpload2').value;
     var totallen=tenfile.length;
     var pos=tenfile.indexOf(".")
     var allowSubmit = false;
     var ext=tenfile.substring(pos,totallen);
    for (var i = 0; i < validfileext.length; i++) 
        {
            //check to see if it's the proper extension
            if (validfileext[i] == ext) 
            { 
                //it's the proper extension
                allowSubmit = true;                 
                return true;
            }
        }
        if (allowSubmit == false)
        {
            alert('Please select pdf file to upload');
            document.getElementById('FileUpload2').style.backgroundColor='#ffe0cc';
            document.getElementById('FileUpload2').focus();
            return false;
        }
        else
        {
            return true
        }    
    }         

}
