﻿
$(document).ready(function() {
$("#aboutUsImage").bind("mousedown", Disableclick);

$("#EMDMCLogo").bind("mousedown", Disableclick);



});

function Disableclick(e) {
    if (event.button == 2) {
        alert('Sorry! you can\'t download logo. ');

    }
}

$(document ).ready(function (){
try {

        //Get relational path of URL
        var pathname = window.location.pathname;
        //Get Only page(in many pages we are passing query string so get length from .aspx extension
        var pageName = pathname.substr(pathname.lastIndexOf("/")+1,pathname.lastIndexOf(".aspx")+1);
        //Get Page name without extension(Exclude aspx extension
        pageName = pageName.substr(0,pageName.lastIndexOf(".aspx"));
        //Get element Name turn page name as li item name
        pageName = "#li"+pageName.toLowerCase();
        $(pageName).addClass('selected');
   }
catch (e) {

}
});

///Author:  Amrik
///Purpose: Used in CustomValidator to validate date, with leap year

function ClientValidate(sender, arguments)
       {        
  try
 {      //Set defalut value fo flag false. //In any step goes success then change its value
        var flag = false ;
        //Get Current Date    
        var d=new Date();
        var day=d.getDate();
        var month=d.getMonth() + 1;
        var year=d.getFullYear();
        var today = month + "/" + day + "/" +year
        var controlClientID;
        var validationType ="OTHER";//For check we have to check expiry date or others
       //Get Entred Date
        controlClientID = sender.Date;
        var EntredDate
           if(controlClientID.indexOf('EXPIRYDATECHECK') == -1)//Other Dates
           {
           EntredDate  =  document.getElementById(sender.Date).value;
           }
           else{//Expiry Date
           //Remove check string from control id
            controlClientID = controlClientID.replace("EXPIRYDATECHECK","")
            validationType = "EXPIRYDATECHECK";
            EntredDate  =  document.getElementById(controlClientID).value;
             }
       
       //German date contains . insted of /
       var indexOfPoint = EntredDate.indexOf('.');
       var indexOfHypen = EntredDate.indexOf('-'); //IE 8 give - seprator
       var indexOfFFdSlash = EntredDate.indexOf('/'); 
       
        //Split value
        
        if( indexOfPoint != -1)
        {
        var  splitDate = EntredDate.split('.');
        flag = true ;
        }
        else if( indexOfHypen != -1)                //If date is German
        {
        var  splitDate = EntredDate.split('-'); 
        flag = true ;    //IE 8 give - seprator
        }
        else if( indexOfFFdSlash != -1)             //If date is english
        {
        var  splitDate = EntredDate.split('/');
        flag = true ;
        }
     
      
       if(!flag)//If date is not with correct seprator
        {
         arguments.IsValid = false;
         return false;
        }
       
        // Get Selected Date
       
      switch (splitDate[0].toLowerCase()) //Get the date in mm/dd/yyyy format
      {
      //en
   case 'jan': EntredDate = '1' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es
   case 'ene': EntredDate = '1' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de
   case 'jan': EntredDate = '1' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr
   case 'janv.': EntredDate = '1' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //******************************************************************************
    //en
   case 'feb': EntredDate = '2' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es
   case 'feb': EntredDate = '2' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de
   case 'Feb': EntredDate = '2' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr
   case 'févr.': EntredDate = '2' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //******************************************************************************
    //en
   case 'mar': EntredDate = '3'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'mar': EntredDate = '3'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'Mrz': EntredDate = '3' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'mars': EntredDate = '3' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //******************************************************************************
    //en
   case 'apr': EntredDate = '4'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'abr': EntredDate = '4'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'Apr': EntredDate = '4'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'avr.': EntredDate ='4' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //******************************************************************************
    //en
   case 'may': EntredDate = '5'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'may': EntredDate = '5'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'mai': EntredDate = '5'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'mai': EntredDate =  '5' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //******************************************************************************
    //en
   case 'jun': EntredDate = '6'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'jun': EntredDate = '6'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'jun': EntredDate = '6'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'juin': EntredDate ='6' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   
    //******************************************************************************
    //en
   case 'jul': EntredDate = '7'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'jul': EntredDate = '7'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'jul': EntredDate = '7'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'juil.': EntredDate= '7' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //******************************************************************************
    //en
   case 'aug': EntredDate = '8'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'ago': EntredDate = '8'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'aug': EntredDate = '8'+ "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'août': EntredDate ='8' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //******************************************************************************
    //en
   case 'sep': EntredDate =   '9'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                       
   case 'sep': EntredDate =   '9'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                      
   case 'sep': EntredDate =   '9'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                      
   case 'sept.': EntredDate =  '9'  + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //******************************************************************************
    //en
   case 'oct': EntredDate = '10' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'oct': EntredDate = '10' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'okt': EntredDate = '10' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'oct.': EntredDate = '10' + "/" + splitDate[1] + "/" + splitDate[2]; break;

 //******************************************************************************
    //en
   case 'nov': EntredDate = '11' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es                     
   case 'nov': EntredDate = '11' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de                    
   case 'nov': EntredDate = '11' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr                    
   case 'nov.': EntredDate = '11' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   
   //******************************************************************************
    //en
   case 'dec': EntredDate = '12' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   //es
   case 'dic': EntredDate = '12' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //de
   case 'dez': EntredDate = '12' + "/" + splitDate[1] + "/" + splitDate[2]; break;
    //fr
   case 'déc.': EntredDate = '12' + "/" + splitDate[1] + "/" + splitDate[2]; break;
   
   default :  flag = true ;


}
//var DOB = EntredDate;
   
 if (EntredDate.value != ""){
 if(!flag)//If entred month is wrong
 {
  arguments.IsValid = false;
  return false;;
 }

// valid date format for exp (mm/dd/yyyy )
//This R.E used for validate date with leap year
  var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;        
  if(EntredDate.match(RegExPattern) == null)//If entred date is not matched then show message
        {
         arguments.IsValid = false;
          return false;//show error message
        }
      
 //Campare date
         if(validationType == "OTHER")//Other type date
         {
                if((Date.parse(EntredDate) > Date.parse(today)))// Check if date is greater than current date 
                {
                arguments.IsValid = false;
                return false;
                }
                else{
                 arguments.IsValid = true;
                 return true;
                }
          }
          /* EXPIRY DATE MAY ME GREATER/LESS THEN OR EQL TO CURRENT DATE
           * SO ONLY CHECK IS IT VALID DATE OR NOT
          else if(validationType == "EXPIRYDATECHECK")//date is for expiry check
          {
           if((Date.parse(EntredDate) < Date.parse(today)))// Check if date is Less than current date 
                {
                arguments.IsValid = false;
                return false;
                }
                else{
                 arguments.IsValid = true;
                 return true;
                }
          }
          */
        }
           }//end of try
    catch(e)
    {
   
     
    }
 }