var number=0;
var name="";
var date=0;
var time=new Date();
var today=time.getDate();
var hour="";
var month=time.getMonth();
var speak= new Array(
"The appointment time is not available, please select another time and try again",
"The time is reserved, press reset and select a different appointment time",
"All of the attorneys are already scheduled, select another time and check availability",
"The staff are busy at this time, try an early afternoon appointment time",
"The consultation time is taken, if you are having trouble with the scheduler call 619-645-5228")


Feb1 = new Array(6,7,13,14,20,21,27,28);
Feb2 = new Array(1,2,3,4,5,8,9,10,11,12,15,16,17,18,19,22,23,24,25,26);
Mar1 = new Array(1,7,8,14,15,21,22,28,29);
Mar2 = new Array(2,3,4,5,6,9,10,11,12,13,16,17,18,19,20,23,24,25,26,27,30,31);
Apr1 = new Array(4,5,11,12,18,19,25,26);
Apr2 = new Array(1,2,3,6,7,8,9,10,13,14,15,16,17,20,21,22,23,24,27,28,29,30);
May1 = new Array(1,2,8,9,15,16,22,23,29,30);
May2 = new Array(3,4,5,6,7,10,11,12,13,14,17,18,19,20,21,24,25,26,27,28);
June1= new Array(5,6,12,13,19,20,26,27);
June2= new Array(1,2,3,4,7,8,9,10,11,14,15,16,17,18,21,22,23,24,25,28,29,30);
July1= new Array(4,5,11,12,18,19,25,26);
July2= new Array(1,2,3,6,7,8,9,10,13,14,15,16,17,20,21,22,23,24,27,28,29,30,31);
August1= new Array(1,2,8,9,15,16,22,23,29,30);
August2= new Array(3,4,5,6,7,10,11,12,13,14,17,18,19,20,21,24,25,26,27,28,31);
September1= new Array(5,6,12,13,19,20,26,27);
September2= new Array(1,2,3,4,7,8,9,10,11,14,15,16,17,18,21,22,23,24,25,28,29,30);
October1= new Array(3,4,10,11,17,18,24,25,31);
October2= new Array(1,2,5,6,7,8,9,12,13,14,15,16,19,20,21,22,23,26,27,28,29,30);
November1= new Array(1,7,8,14,15,21,22,28,29);
November2= new Array(2,3,4,5,6,9,10,11,12,13,16,17,18,19,20,23,24,25,26,27,30);
December1= new Array(5,6,12,13,19,20,26,27);
December2= new Array(1,2,3,4,7,8,9,10,11,14,15,16,17,18,21,22,23,24,25,28,29,30,31);
January1= new Array(2,3,9,10,16,17,23,24,30,31);
January2= new Array(1,4,5,6,7,8,11,12,13,14,15,18,19,20,21,22,25,26,27,28,29);

function CheckAvailability(){
number=Math.floor(Math.random()*2)+1;
name=document.theform.Box1.value;
date=document.theform.Box2.value;
hour=document.theform.Box3.value;
var hour1=hour.charAt(0);

if(name=="March")
for(i=0; i<9;++i)
if(date==Mar1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="March")
for(i=0; i<22;++i)
if(date==Mar2[i]&&number==2)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==Mar2[i]&&number!=2)
document.theform.sorted.value="The Appointment time is not available.Please select another time and try again, or press reset. ";

if(name=="April")
for(i=0; i<8;++i)
if(date==Apr1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="April")
for(i=0; i<22;++i)
if(date==Apr2[i]&&number==2)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==Apr2[i]&&number!=2)
document.theform.sorted.value="The Appointment time is not available.Please select another time and try again, or press reset. ";

if(name=="May")
for(i=0; i<10;++i)
if(date==May1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="May")
for(i=0; i<20;++i)
if(date<today&&month==4)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==4)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==May2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==May2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==May2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];





if(name=="June")
for(i=0; i<8;++i)
if(date==June1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="June")
for(i=0; i<22;++i)
if(date<today&&month==5)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==5)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==June2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==June2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==June2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];



if(name=="July")
for(i=0; i<8;++i)
if(date==July1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="July")
for(i=0; i<23;++i)
if(date<today&&month==6)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==6)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==July2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==July2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==July2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="August")
for(i=0; i<10;++i)
if(date==August1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="August")
for(i=0; i<21;++i)
if(date<today&&month==7)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==7)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==August2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==August2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==August2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="September")
for(i=0; i<8;++i)
if(date==September1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="September")
for(i=0; i<22;++i)
if(date<today&&month==8)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==8)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==September2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==September2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==September2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="October")
for(i=0; i<9;++i)
if(date==October1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="October")
for(i=0; i<22;++i)
if(date<today&&month==9)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==9)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==October2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==October2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==September2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="November")
for(i=0; i<9;++i)
if(date==November1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="November")
for(i=0; i<21;++i)
if(date<today&&month==10)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==10)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==November2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==November2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==November2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];



if(name=="December")
for(i=0; i<8;++i)
if(date==December1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="December")
for(i=0; i<23;++i)
if(date<today&&month==11)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==11)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==December2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==December2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==December2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="January")
for(i=0; i<10;++i)
if(date==January1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="January")
for(i=0; i<21;++i)
if(date<today&&month==0)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==0)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==January2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==January2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date!=today&&date==January2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*4)];

if(name=="February")
for(i=0; i<8;++i)
if(date==Feb1[i])
document.theform.sorted.value="The Appointment time is not available. Please choose a weekday ";
if(name=="February")
for(i=0; i<20;++i)
if(date<today&&month==1)
document.theform.sorted.value="You can't go back in time ";
else if(date==today&&month==1)
document.theform.sorted.value="The Appointment time is not available. The date cannot be the same as today. Press reset to try again ";
else if(date==Feb2[i]&&number==2&&hour1!=9)
document.theform.sorted.value="The Appointment time is available.If you are sure this is the time you want enter the information below and click confirm. Further e-mail instructions will follow  ";
else if(date==Feb2[i]&&number!=2&&hour1!=9)
document.theform.sorted.value=speak[Math.floor(Math.random()*5)];
else if(hour1==9&&date!=today&&date==Feb2[i])
document.theform.sorted.value=speak[Math.floor(Math.random()*5)];
else if(hour1==9&&date==today)
document.theform.sorted.value=speak[Math.floor(Math.random()*5)];



}
