﻿// JScript File
function mil(str)
 {
  var t = str.split(':')
  var hh = parseInt(t[0],10);
  var mm = parseInt(t[1],10)
  hh += (str.toLowerCase().indexOf('pm')!=-1)?12:0;
  var d = new Date(2007,0,1,hh,mm,00); // just a date not around daylightsaving
  return d.getTime();
}
function Validate1(Hid1,varMsg)
{    
    //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
     var varCurrentDate =new Date(getMYDate());
     var v1=Hid1.value;
     var calDate1 =new Date(Hid1.value);
    // var d1=new Date(calDate1);

     if(v1 =="")
      {
       //alert("Please select start date and end date");                
       //alert("PLEASE SELECT DATES");   
           
       //Assigning alert content
       AlertText.innerText="Please Select Dates";
       AlertText.textContent="Please Select Dates";
       
       //Show Modal Popup
       PopUpAlert.show();
       return false;
      }
      if(calDate1 =="")
      {
       //alert("Start date is Lower than current date");       
        AlertText.innerText="Start date is Lower than current date";
       AlertText.textContent="Start date is Lower than current date";
       PopUpAlert.show();
       return false;
      }
     if(calDate1 < varCurrentDate)
     {
      //alert(varMsg);     
        AlertText.innerText=varMsg;
        AlertText.textContent=varMsg;
        PopUpAlert.show();
        return false;
     }
     return true; 
 }

 function ValidateDates(Hid1,Hid2,varMsg)
 {    
    //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
     var varCurrentDate = new Date(getMYDate());
     var date1=Hid1.value;
      var date2=Hid2.value;
     var calDate1 =new Date(Hid1.value);
     var calDate2 =new Date(Hid2.value);
     if(date1=="")
     {
        AlertText.innerText="Please Select Start Date";
        AlertText.textContent="Please Select Start Date";
        PopUpAlert.show();
        return false;
     }
     else if(date2=="")
     {
        AlertText.innerText="Please Select End Date";
        AlertText.textContent="Please Select End Date";
        PopUpAlert.show();
        return false;
     }
     else if(date1=="" && date2=="") //|| (calDate2 == calDate1))
     {
      //alert('Please select start date and end date');
      //alert('PLEASE SELECT DATES');
       //Assigning alert content
       AlertText.innerText="Please Select Dates";
       AlertText.textContent="Please Select Dates";
      PopUpAlert.show();
      return false;
     }    
     
    if(calDate2 < calDate1) //|| (calDate2 == calDate1))
     {             
      //alert(varMsg);
      AlertText.innerText=varMsg;
      AlertText.textContent=varMsg;
      PopUpAlert.show();
      return false;
     } 
        
     return true;
  }
    
 function getMYDate()
  {
    
    
    var d = new Date();
    var curr_date = d.getDate();
    var curr_month = d.getMonth()+1;
    var curr_year = d.getFullYear();
    var  varDate = curr_month + "/" + curr_date + "/" + curr_year;
    return varDate;
  }
   function ValidateChecktime()
   {
     //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
     //Assigning alert content
    AlertText.innerText="PLEASE SELECT TIMES";
    AlertText.textContent="PLEASE SELECT TIMES";
    var a1=0;
    var b1=document.getElementById('ctl00_ContentPlaceHolder1_HiddenFieldfortime').value;
    
      if(b1 !="")
        {
         a1=parseInt(0)+parseInt(b1)
        }
         if(a1==0)
         {
         // alert('Please select StartTime and EndTime');
         
         // alert('PLEASE SELECT TIMES');
          
          
           
           //Show Modal Popup
           PopUpAlert.show();
          return false;
         }
     return true;
   }
  
 function DateValidation()
   {  
   //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
      //Commented next 8 lines on 19th March 2009 to allow booking time slot before current date
      //if(Validate1(document.getElementById('ctl00_ContentPlaceHolder1_Hid2'),"Match can not be scheduled before the current date")== false)
      //{
      // return false;
      //}
      //if(Validate1(document.getElementById('ctl00_ContentPlaceHolder1_Hid3'),"Match can not be scheduled before the current date")== false)
      //{
       //return false;
      //}
      
      if(ValidateDates(document.getElementById('ctl00_ContentPlaceHolder1_Hid2'),document.getElementById('ctl00_ContentPlaceHolder1_Hid3'),"The End date must be greater than Start date")== false)
      {
       return false;
      }
      if(ValidateChecktime()== false)
      {
       return false;
      }
      //var ChkAll=document.getElementById('ctl00_ContentPlaceHolder1_chkalldates');
      var ChkAll = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldAll');
      var ChkWeekdays = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldWeekdays');
      var ChkWeekend = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldWeekend');
      var ChkMon = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldMon');
      var ChkTue = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldTue');
      var ChkWed = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldWed');
      var ChkThu = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldThu');
      var ChkFri = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldFri');
      var ChkSat = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldSat');
      var ChkSun = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldSun');
      
      if(ChkAll!=null)
      {
         if(ChkAll.value=="1" )
         { 
           if(Timecheckalldates("End time must be later than Start time.")==false )
            {
              return false;
            }
         }        
       }  
      if(ChkWeekdays!=null)
      {
          if(ChkWeekdays.value=="1")
          {           
           if(TimecheckallWeekDays("End time must be later than Start time.")==false )
            {
              return false;
            }
          }
       }          
       if(ChkWeekend!=null)
       {
          if(ChkWeekend.value=="1")
          { 
             
               if(TimecheckallWeekEndDays("End time must be later than Start time.")==false )
                {
                  return false;
                }
          }
       }
       if(ChkMon!=null)
         { 
              if(ChkMon.value=="1")
              {
               if(Timecheck("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
         }
         if(ChkTue!=null)
         {
         
             if(ChkTue.value=="1")
              {
               if(TimecheckTuesday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
         }
         if(ChkWed!=null)
         {                
             if(ChkWed.value=="1")
              {
               if(TimecheckWednesday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
          }
         if(ChkThu!=null)
         {          
             if(ChkThu.value=="1")
              {
               if(TimecheckThursday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
         }
         if(ChkFri!=null)
         {
              if(ChkFri.value=="1")
              {
               if(TimecheckFriday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
          }
         if(ChkSat!=null)
         {
              if(ChkSat.value=="1")
              {
               if(TimecheckSaturday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }
         }
         if(ChkSun!=null)
         {          
            if(ChkSun.value=="1")
              {
               if(TimecheckSunday("End time must be later than Start time.")==false )
                {
                  return false;
                }
              }          
         }     
      
      return true;   
   }
   
   function Timecheckalldates(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllDates5').value;
        //Modified by Mandeep.. 24th Oct, 2008 --- Ex: 12 pm - 7 pm should be NO ERROR. Same as 12 am - 7 am. 
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
     if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
   
    //return true;   
  }  
   
   
  function TimecheckallWeekDays(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDays5').value;
        //Modified by Mandeep.. 24th Oct, 2008 --- Ex: 12 pm - 7 pm should be NO ERROR. Same as 12 am - 7 am. 
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
     if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
   
    //return true;   
  } 
   
  function TimecheckallWeekEndDays(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDays5').value;
        //Modified by Mandeep.. 24th Oct, 2008 --- Ex: 12 pm - 7 pm should be NO ERROR. Same as 12 am - 7 am. 
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
     if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
   
    //return true;   
  } 
   
     
  
    function TimecheckSunday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySunday5').value;
        //Modified by Mandeep.. 24th Oct, 2008 --- Ex: 12 pm - 7 pm should be NO ERROR. Same as 12 am - 7 am. 
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
     if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
   
    //return true;   
  }
   
   function TimecheckSaturday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEverySaturday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
    //return true;   
  }
   
   
function TimecheckFriday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryFriday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
    else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
    //return true;   
  }
   
   
   function TimecheckThursday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryThursday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
    //return true;   
  }
  
 function TimecheckWednesday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryWednesday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
   // return true;   
  }
  
   function TimecheckTuesday(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday1').value);
    var min1 =parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday4').value);
    var min2 =parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryTuesday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
    //return true;   
  }
  
  function Timecheck(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday6').value;
    
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday2').value;
    time1 =((hh1+hr1)*60)+min1;    
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday4').value);   
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlEveryMonday5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
     if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    }
    
     if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
  
    
   else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="am")
    {       
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;      
    }     
     else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;     
     PopUpAlert.show();
     return false;     
    }
        
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
     return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
     //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
     AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
     PopUpAlert.show();
     return false;     
    }
   
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
     AlertText.innerText=varMsg;
     AlertText.textContent=varMsg;
     PopUpAlert.show();
     return false;
    }
    //return true;   
  }
  
  function DateValidation1()
  {           
      if(Validate1(document.getElementById('ctl00_ContentPlaceHolder1_Hidden1'),"Match can not be scheduled before the current date")== false)
      {
       return false;
      }
      if(Validate1(document.getElementById('ctl00_ContentPlaceHolder1_Hidden4'),"Match can not be scheduled before the current date")== false)
      {
       return false;
      }
      if(ValidateDates(document.getElementById('ctl00_ContentPlaceHolder1_Hidden1'),document.getElementById('ctl00_ContentPlaceHolder1_Hidden4'),"The End date must be greater than Start date")== false)
      {
       return false;
      }
      
//       var SingleSelect=document.getElementById('ctl00_ContentPlaceHolder1_chkallstart1');
//      
//      if(SingleSelect != null)
//       {       
//        if(document.getElementById('ctl00_ContentPlaceHolder1_chkallstart1').checked)
//          {
//           if(TimecheckforConsuCheckAll("End time must be later than Start time.")==false )
//            {
//              return false;
//            }
//          }
//       
//      else
//       {
//             if(TimecheckCossu("End time must be later than Start time.")==false )
//              {
//                return false;
//              }
//       }
//     }
      if(TimecheckCossu("End time must be later than Start time.")==false )
              {
                return false;
              }
       return true;
  }
  
//  function ValidateDates3(Hiden,varMsg)
// {    
//     var varCurrentDate = new Date(getMYDate());
//     var calDate1 =  new Date(Hiden.value);
//    
//     if(varCurrentDate > calDate1)
//     {
//      alert(varMsg);
//      return false;
//     }    
//     return true;
//  }
//  
//    function DateValidation2()
//  {           
//      if(ValidateDates3(document.getElementById('ctl00_ContentPlaceHolder1_Hidclnd1'),"The Selected date must be greater than Current date")== false)
//      {
//       return false;
//      }
//  
//      
//       return true;
//  }
  
  function TimecheckforConsuCheckAll(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddltimestart1').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddltimeend1').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlhrstart1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlminstart1').value);
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlhrend1').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlminend1').value);
    //Modified by Mandeep.. 24th Oct, 2008 --- Ex: 12 pm - 7 pm should be NO ERROR. Same as 12 am - 7 am. 
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
    //----------End Modification------------
  if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
     time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
   if(PM1=='PM' && PM2=='AM')
    {
        //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;
    }
     else  if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")))
    {     
     return true;     
    }
     else if((PM1.toLowerCase()=="pm" )&& ((hh2 >="12") && (PM2.toLowerCase()=="pm")))
    {
        //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;     
    }
     else if((time2 < time1)||(time2 == time1))
    {
        //alert(varMsg);
        AlertText.innerText=varMsg;
        AlertText.textContent=varMsg;
        PopUpAlert.show();
        return false;     
    }
    return true;   
  }
  
   function TimecheckCossu(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var count = document.getElementById('ctl00_ContentPlaceHolder1_HiddenFieldDatediff').value;
    count= parseInt(count)+parseInt(3);
    var i;
    for(i=2;i<count; i++)
     {
        if(i<10)
          {
            var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp3').value;
            var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp6').value;
            if(PM1.toLowerCase()=="pm")
            {hr1=12;}
            if(PM2.toLowerCase()=="pm")
            {hr2=12;}
            var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp1').value);
            var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp2').value);
            var minS = document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp2').value;
            time1 =((hh1+hr1)*60)+min1;
            var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp4').value);
            var min2 =parseInt(document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp5').value);
            var minE = document.getElementById('ctl00_ContentPlaceHolder1_grd_ctl0'+ i +'_drp5').value;
            
            var ST = hh1 + ":" + minS + " " + PM1;
            var ET = hh2 + ":" + minE + " " + PM2;    
            var dtStart = new Date("1/1/2007 " + ST);
            var dtEnd = new Date("1/1/2007 " + ET);
            difference_in_milliseconds = dtEnd - dtStart;
            
            if((PM2.toLowerCase()=="am")&& (hh2 =="12"))
            {
               time2 = 0;
            }
            else
            {
               time2 =((hh2+hr2)*60)+min2;
            } 
            if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
            {
                return true;
            }
            else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
            {
                return true;
            }
          
            
           else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
            {
                return true;
            }
            else if(PM1=='PM' && PM2=='AM')
            {       
                AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                PopUpAlert.show();
                return false;      
            }     
             else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
            {
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;     
             PopUpAlert.show();
             return false;     
            }
                
            else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
            {     
             return true;     
            }
            else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
            {
             //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
             AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             PopUpAlert.show();
             return false;     
            }
           
            //else if((time2 < time1)||(time2 == time1))
            else if (difference_in_milliseconds <= 0 )
            {     
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;
             PopUpAlert.show();
             return false;
            }
          }
          else
          {
           if(i<12)
           {
               var PM_1 = document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp3').value;
                var PM_2 = document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp6').value;
                if(PM_1.toLowerCase()=="pm")
                {hr_1=12;}
                if(PM_2.toLowerCase()=="pm")
                {hr_2=12;}
                var hh_1 = parseInt(document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp1').value);
                var min_1 = parseInt(document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp2').value);
                var min_S = document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp2').value;
                time_1 =((hh_1+hr_1)*60)+min_1;
                var hh_2=parseInt(document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp4').value);
                var min_2 = parseInt(document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp5').value);
                var min_E = document.gET_1ElementById('ctl00_ContentPlaceHolder1_grd_ctl'+ i +'_drp5').value;
                
                var ST_1 = hh_1 + ":" + min_S + " " + PM_1;
                var ET_1 = hh_2 + ":" + min_E + " " + PM_2;    
                var dtSTart_1 = new Date("1/1/2007 " + ST_1);
                var dtEnd_1 = new Date("1/1/2007 " + ET_1);
                difference_in_milliseconds_1 = dtEnd_1 - dtSTart_1;
                if((PM_2.toLowerCase()=="am" )&& (hh_2 =="12"))
                {
                   time_2 = 0;
                }
                else
                {
                   time_2 =((hh_2+hr_2)*60)+min_2;
                } 
                if((hh_1=="12" && hh_2<hh_1 && PM_1.toLowerCase()=="am" && PM_2.toLowerCase()=="am") )
                {
                    return true;
                }
                else if(hh_1=="12" && hh_2<hh_1 && PM_1.toLowerCase()=="pm" && PM_2.toLowerCase()=="pm")
                {
                    return true;
                }              
                
               else if((PM_2.toLowerCase()=="am") && (PM_1.toLowerCase()=="pm")&& (hh_2 =="12") && (hh_1 <"12") && (min_2 =="0"))
                {
                    return true;
                }
                else if(PM_1=='PM' && PM_2=='AM')
                {       
                    AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                    AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                    PopUpAlert.show();
                    return false;      
                }     
                 else if((PM_1.toLowerCase()=="am" ) && (PM_2.toLowerCase()=="am") && (hh_1>hh_2)  )
                {
                 AlertText.innerText=varMsg;
                 AlertText.textContent=varMsg;     
                 PopUpAlert.show();
                 return false;     
                }
                    
                else if(((PM_1.toLowerCase()=="am") && (PM_2.toLowerCase()=="am"))&& ((hh_1 =="12") && (hh_2 <"12" || min_2 >="1")) )
                {     
                 return true;     
                }
                else if((PM_1.toLowerCase()=="pm" ) && (PM_2.toLowerCase()=="pm") && (hh_1<"12") && (hh_2 =="12") && (min_2>="0"))
                {
                 //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
                 AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                 AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                 PopUpAlert.show();
                 return false;     
                }
               
                //else if((time_2 < time_1)||(time_2 == time_1))
                else if (difference_in_milliseconds_1 <= 0 )
                {     
                 AlertText.innerText=varMsg;
                 AlertText.textContent=varMsg;
                 PopUpAlert.show();
                 return false;
                }
              }  
          } 
      }
    
    return true;   
  }
  
  function CheckCurDate()
  {
    if(Validate1(document.getElementById('ctl00_ContentPlaceHolder1_Hidclnd1'),"Match can not be scheduled before the current date")== false)
      {
       return false;
      }
  }
  
 function DateValidation2()
  {   
      var ChkAll = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldAllFS');
      var ChkWeekdays = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldWeekdaysFS');
      var ChkWeekend = document.getElementById('ctl00_ContentPlaceHolder1_HidFieldWeekendFS');        
         
      if(ChkAll!=null)
      {  
        if(ChkAll.value=="1")
        {
            if(TimecheckforFreestyleCheckAll("End time must be later than Start time.")==false )
            {
                return false;
            }
        }
      }
      
      if(ChkWeekdays!=null)
      {
        if(ChkWeekdays.value=="1")
        {
            if(TimecheckforFreestyleCheckAllWeekdays("End time must be later than Start time.")==false )
            {
                return false;
            }
        }
      }
      
      if(ChkWeekend!=null)
      {
        if(ChkWeekend.value=="1")
        {
            if(TimecheckforFreestyleCheckAllWeekenddays("End time must be later than Start time.")==false )
            {
                return false;
            }
        }
      }
//      var FreeSingleSelect=document.getElementById('ctl00_ContentPlaceHolder1_chksingle');
//      var FreeSingleSelect1=document.getElementById('ctl00_ContentPlaceHolder1_chkAllWeekdaysFS');
//      var FreeSingleSelect2=document.getElementById('ctl00_ContentPlaceHolder1_chkAllWeekenddaysFS');
//      if(FreeSingleSelect != null)
//       {       
//            if(document.getElementById('ctl00_ContentPlaceHolder1_chksingle').checked)
//              {
//               if(TimecheckforFreestyleCheckAll("End time must be later than Start time.")==false )
//                {
//                  return false;
//                }
//              }            
//              
//       }  
//       
//      
//      if(FreeSingleSelect1 != null)
//       {       
//            if(document.getElementById('ctl00_ContentPlaceHolder1_chkAllWeekdaysFS').checked)
//              {
//               if(TimecheckforFreestyleCheckAllWeekdays("End time must be later than Start time.")==false )
//                {
//                  return false;
//                }
//              }
//       }  
//      
//     if(FreeSingleSelect2 != null)
//       {       
//            if(document.getElementById('ctl00_ContentPlaceHolder1_chkAllWeekenddaysFS').checked)
//              {
//               if(TimecheckforFreestyleCheckAllWeekenddays("End time must be later than Start time.")==false )
//                {
//                  return false;
//                }
//              }
//       }
//     if(ChkAll!=null && ChkWeekdays!=null && ChkWeekend!=null)
//     {
//        if(ChkAll=="" && ChkWeekdays=="" && ChkWeekend=="")
//        {
//        alert("chk grid");
//            if(TimecheckFreestyle("End time must be later than Start time.")==false )
//            {
//                return false;
//            }
//        }
//     }
//     else
//     {
     
            if(TimecheckFreestyle("End time must be later than Start time.")==false )
            {
                return false;
            }
    // }
        
                   
   return true;
  }
  
  
 function TimecheckFreestyle(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;   
    var countfrrstyle = document.getElementById('ctl00_ContentPlaceHolder1_Hiddenforfrestylevalue').value;
    countfrrstyle= parseInt(countfrrstyle)+parseInt(3);
    var i; 
    for(i=2;i<countfrrstyle; i++)
     {        
          
            var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp9').value;
            var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp12').value;
            if(PM1.toLowerCase()=="pm")
            {hr1=12;}
            if(PM2.toLowerCase()=="pm")
            {hr2=12;}
            var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp7').value);
            var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp8').value);
            var minS = document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp8').value;
            time1 =((hh1+hr1)*60)+min1;
            var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp10').value);
            var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp11').value);
            var minE = document.getElementById('ctl00_ContentPlaceHolder1_GridView1_ctl0'+ i +'_drp11').value;
            
            var ST = hh1 + ":" + minS + " " + PM1;
            var ET = hh2 + ":" + minE + " " + PM2;    
            var dtStart = new Date("1/1/2007 " + ST);
            var dtEnd = new Date("1/1/2007 " + ET);
            difference_in_milliseconds = dtEnd - dtStart;
            
            if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
            {
              time2 = 0;
            }
            else
            {
              time2 =((hh2+hr2)*60)+min2;
            } 
            if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
            {
                return true;
            }
            else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
            {
                return true;
            }
          
            
           else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
            {
                return true;
            }
            else if(PM1=='PM' && PM2=='AM')
            {       
                AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                PopUpAlert.show();
                return false;      
            }     
             else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
            {
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;     
             PopUpAlert.show();
             return false;     
            }
                
            else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
            {     
             return true;     
            }
            else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
            {
             //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
             AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             PopUpAlert.show();
             return false;     
            }
           
            //else if((time2 < time1)||(time2 == time1))
            else if (difference_in_milliseconds <= 0 )
            {     
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;
             PopUpAlert.show();
             return false;
            }
      }
    
    return true;   
  }
  
  
  function TimecheckforFreestyleCheckAll(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddltimestart2').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddltimeend2').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlhrstart2').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlminstart2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlminstart2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlhrend2').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlminend2').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlminend2').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
      time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
              
                
    else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
         AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         PopUpAlert.show();
         return false;      
    }     
    else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
        AlertText.innerText=varMsg;
        AlertText.textContent=varMsg;     
        PopUpAlert.show();
        return false;     
    }
                    
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
        return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
        //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;     
    }
               
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
         AlertText.innerText=varMsg;
         AlertText.textContent=varMsg;
         PopUpAlert.show();
         return false;
    }
    //return true;   
  }
  
  function TimecheckforFreestyleCheckAllWeekdays(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekDaysFS5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
      time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
              
                
    else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
         AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         PopUpAlert.show();
         return false;      
    }     
    else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
        AlertText.innerText=varMsg;
        AlertText.textContent=varMsg;     
        PopUpAlert.show();
        return false;     
    }
                    
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
        return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
        //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;     
    }
               
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
         AlertText.innerText=varMsg;
         AlertText.textContent=varMsg;
         PopUpAlert.show();
         return false;
    }
    //return true;   
  }
  
  function TimecheckforFreestyleCheckAllWeekenddays(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;
    var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS3').value;
    var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS6').value;
    if(PM1.toLowerCase()=="pm")
    {hr1=12;}
    if(PM2.toLowerCase()=="pm")
    {hr2=12;}
    var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS1').value);
    var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS2').value);
    var minS = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS2').value;
    time1 =((hh1+hr1)*60)+min1;
    var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS4').value);
    var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS5').value);
    var minE = document.getElementById('ctl00_ContentPlaceHolder1_ddlAllWeekendDaysFS5').value;
    
    var ST = hh1 + ":" + minS + " " + PM1;
    var ET = hh2 + ":" + minE + " " + PM2;    
    var dtStart = new Date("1/1/2007 " + ST);
    var dtEnd = new Date("1/1/2007 " + ET);
    difference_in_milliseconds = dtEnd - dtStart;
    
    if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
    {
      time2 = 0;
    }
    else
    {
      time2 =((hh2+hr2)*60)+min2;
    } 
    if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
    {
        return true;
    }
    else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
    {
        return true;
    }
              
                
    else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
    {
        return true;
    }
    else if(PM1=='PM' && PM2=='AM')
    {       
         AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
         PopUpAlert.show();
         return false;      
    }     
    else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
    {
        AlertText.innerText=varMsg;
        AlertText.textContent=varMsg;     
        PopUpAlert.show();
        return false;     
    }
                    
    else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
    {     
        return true;     
    }
    else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
    {
        //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
        AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
        PopUpAlert.show();
        return false;     
    }
               
    //else if((time2 < time1)||(time2 == time1))
    else if (difference_in_milliseconds <= 0 )
    {     
         AlertText.innerText=varMsg;
         AlertText.textContent=varMsg;
         PopUpAlert.show();
         return false;
    }
    //return true;   
  }
//Function for view by dates for location management tabs
 function CheckDateSelection()
  {
    if(ValidateDateSelection(document.getElementById('ctl00_ContentPlaceHolder1_HiddenField1'))== false)
      {
       return false;
      }
  }
function ValidateDateSelection(Hid1)
{    
    //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
     var varCurrentDate =new Date(getMYDate());
     var v1=Hid1.value;
     var calDate1 =new Date(Hid1.value);    

     if(v1 =="")
      {    
       //Assigning alert content
       AlertText.innerText="SELECT A DATE FIRST";
       AlertText.textContent="SELECT A DATE FIRST";       
       //Show Modal Popup
       PopUpAlert.show();
       return false;
      }
      return true;
}
  
 function CheckDateSelection1()
  {
    if(ValidateDateSelection1(document.getElementById('ctl00_ContentPlaceHolder1_HiddenField11'))== false)
      {
       return false;
      }
  }
function ValidateDateSelection1(Hid11)
{    
    //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert1');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText1');
    
     var varCurrentDate =new Date(getMYDate());
     var v1=Hid11.value;
     var calDate1 =new Date(Hid11.value);    

     if(v1 =="")
      {    
       //Assigning alert content
       AlertText.innerText="SELECT A DATE FIRST";
       AlertText.textContent="SELECT A DATE FIRST";       
       //Show Modal Popup
       PopUpAlert.show();
       return false;
      }
      return true;
}
 function CheckDateSelection2()
  {
    if(ValidateDateSelection2(document.getElementById('ctl00_ContentPlaceHolder1_HiddenField112'))== false)
      {
       return false;
      }
  }
function ValidateDateSelection2(Hid112)
{    
    //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert12');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText12');
    
     var varCurrentDate =new Date(getMYDate());
     var v1=Hid112.value;
     var calDate1 =new Date(Hid112.value);    

     if(v1 =="")
      {    
       //Assigning alert content
       AlertText.innerText="SELECT A DATE FIRST";
       AlertText.textContent="SELECT A DATE FIRST";       
       //Show Modal Popup
       PopUpAlert.show();
       return false;
      }
      return true;
}

//validations for edit section free style for loc i manage tab
//and program that use my location tab
 function DateValidationEdit()
  {    
     if(TimecheckFreestyleEdit("End time must be later than Start time.")==false )
       {
        return false;
       }               
   return true;
  }
  
  
 function TimecheckFreestyleEdit(varMsg)
  {
  //Find Modal popup from page
    var PopUpAlert=$find('MPopAlert');
    //find alert text label from page
    var AlertText=document.getElementById('ctl00_ContentPlaceHolder1_lblAlertText');
    
    var time1,time2;
    var hr1=0;
    var hr2 = 0;   
    var countfrrstyle = document.getElementById('ctl00_ContentPlaceHolder1_Hiddenforfrestylevalue').value;
    countfrrstyle= parseInt(countfrrstyle)+parseInt(3);
    var i;   
    //for(i=2;i<countfrrstyle; i++)
    // {        
          
            var PM1 = document.getElementById('ctl00_ContentPlaceHolder1_drp9').value;
            var PM2 = document.getElementById('ctl00_ContentPlaceHolder1_drp12').value;
            if(PM1.toLowerCase()=="pm")
            {hr1=12;}
            if(PM2.toLowerCase()=="pm")
            {hr2=12;}
            var hh1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_drp7').value);
            var min1 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_drp8').value);
            var minS = document.getElementById('ctl00_ContentPlaceHolder1_drp8').value;
            time1 =((hh1+hr1)*60)+min1;
            var hh2=parseInt(document.getElementById('ctl00_ContentPlaceHolder1_drp10').value);
            var min2 = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_drp11').value);
            var minE = document.getElementById('ctl00_ContentPlaceHolder1_drp11').value;
            
            var ST = hh1 + ":" + minS + " " + PM1;
            var ET = hh2 + ":" + minE + " " + PM2;    
            var dtStart = new Date("1/1/2007 " + ST);
            var dtEnd = new Date("1/1/2007 " + ET);
            difference_in_milliseconds = dtEnd - dtStart;
            
            if((PM2.toLowerCase()=="am" )&& (hh2 =="12"))
            {
              time2 = 0;
            }
            else
            {
              time2 =((hh2+hr2)*60)+min2;
            } 
            if((hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="am" && PM2.toLowerCase()=="am") )
            {
                return true;
            }
            else if(hh1=="12" && hh2<hh1 && PM1.toLowerCase()=="pm" && PM2.toLowerCase()=="pm")
            {
                return true;
            }
          
            
           else if((PM2.toLowerCase()=="am") && (PM1.toLowerCase()=="pm")&& (hh2 =="12") && (hh1 <"12") && (min2 =="0"))
            {
                return true;
            }
            else if(PM1=='PM' && PM2=='AM')
            {       
                AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
                PopUpAlert.show();
                return false;      
            }     
             else if((PM1.toLowerCase()=="am" ) && (PM2.toLowerCase()=="am") && (hh1>hh2)  )
            {
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;     
             PopUpAlert.show();
             return false;     
            }
                
            else if(((PM1.toLowerCase()=="am") && (PM2.toLowerCase()=="am"))&& ((hh1 =="12") && (hh2 <"12" || min2 >="1")) )
            {     
             return true;     
            }
            else if((PM1.toLowerCase()=="pm" ) && (PM2.toLowerCase()=="pm") && (hh1<"12") && (hh2 =="12") && (min2>="0"))
            {
             //alert("Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.");
             AlertText.innerText="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             AlertText.textContent="Sorry, this time slot crosses midnight and takes place on two different dates. Please do one date at a time.";
             PopUpAlert.show();
             return false;     
            }
           
            //else if((time2 < time1)||(time2 == time1))
            else if (difference_in_milliseconds <= 0 )
            {     
             AlertText.innerText=varMsg;
             AlertText.textContent=varMsg;
             PopUpAlert.show();
             return false;
            }
      //}
    
    return true;   
  }