function sign_up_for(day){
		var mydate=new Date()
		var myday=mydate.getDay()         //0=sun; 1=mon; 2=tue ...
		var mytoday=mydate.getDate()    //1 to 31
		var mymonth=mydate.getMonth()+1 //0=jan; 1=feb; 2=mar... to 11=dec
		var myyear=mydate.getYear()
	}

var mm=""; var dd=""; var yyyy=""; 
function charAtDate(xdate) //returns mm, dd, yyyy
			{
		var i=0;
		mm = xdate.charAt(i);		i=i+1;
		if (xdate.charAt(i) == "/"){	i=i+1;}else{mm = mm + xdate.charAt(i); i=i+2;}

		dd = xdate.charAt(i); i=i+1;
		if (xdate.charAt(i) == "/"){	i=i+1;}else{dd = dd + xdate.charAt(i); i=i+2;}
		
		yyyy = xdate.charAt(i); i=i+1;
		yyyy = yyyy + xdate.charAt(i);		i=i+1;
		yyyy = yyyy + xdate.charAt(i);		i=i+1;
		yyyy = yyyy + xdate.charAt(i);		
		return mm, dd, yyyy;
	}

function check_class_date_begun(i){
			mm=""; dd=""; yyyy=""; x=0;

			//the value of the element containt the index number of the class array record
			x = document.wb.wb_class_day[i].value;
			charAtDate(wb_schedule_Array[x][4]); //returns mm, dd, yyyy

			var class_date=new Date(yyyy,mm-1,dd); //converting charAtDate var to date format
			var today_date=new Date(); 

		  if (class_date < today_date){
				  return true;
			}else{
					return false;}
}

//===============for schedule ==========================================
function wb_class_day_checked(valor){
			for (i=0; i < document.wb.wb_class_day.length; i++)
			{
				 document.wb.wb_class_day[i].checked= valor;
//			   class_style_color(i,"non");
			}
	}

function wb_class_day_disabled(valor){
			chk_wbe=false;
			chk_wbs=false;
			any=false;

			for (i=0; i < document.wb.wb_class_day.length; i++)
			{
						//validating if class date is begun to disable checkbox
						begun = false;
						begun = check_class_date_begun(i) //return true or false

						//validating if date of the class is begun to disable checkbox
						if (begun==true){
								document.wb.wb_class_day[i].disabled="disabled";
			          class_style_color(i,"off");
								}else{
												 any=true;
												 document.wb.wb_class_day[i].disabled="";
			                   class_style_color(i,"non");
						}//end if begun
			}//end for
      
			if (any == false)
			{
					var msg = "";
					wb_class_day_checked('');
					//clean_sheet_reminder();

				  msg = '<font color="red">' +
						       'Sorry!, No WATER BAPTISM DAY are currently on the calendar <br>' +
									 'or  they have already begun! <br>Please check again later<br>' +
						       'or  call our MEMBERSHIP DEPARTMENT office at (732) 727-9500 x 1405. <br><br>' +
					         'Thank you..!' +
									 '</font>';

					if (document.all)
							document.all.error_msg.innerHTML=msg
					else 
							if (document.getElementById)
									document.getElementById("error_msg").innerHTML= msg
		//					else
		//			        document.write(list)

			}

	}

//validate if any classes checked, if yes then fill out or update the reminder sheet information
function check_wb_class_day(t){
			
		//clean_sheet_reminder();

				for (i=0; i < document.wb.wb_class_day.length; i++)
				{
					   class_style_color(i,"non");
							x = document.wb.wb_class_day[i].value;
							if (document.wb.wb_class_day[i].checked)
								{
								   class_style_color(i,"on");
								   fill_out_sheet_reminder(x);
						 }else{
									if (document.wb.wb_class_day[i].disabled)
										{
											 class_style_color(i,"off");
									   }else{
											 class_style_color(i,"non");
										 }
						 }
				}//end for

//			t.focus(); 
}

//=====================================================================
function transform_wb_day(day){
		if (day=='Sun'){day='Sunday'};
		if (day=='Mon'){day='Monday'};
		if (day=='Tue'){day='Tuesday'};
		if (day=='Wed'){day='Wednesday'};
		if (day=='Thu'){day='Thursday'};
		if (day=='Fri'){day='Friday'};
		if (day=='Sat'){day='Saturday'};
		return day;
}

function class_style_color(i,color){
	if (color=="on"){
				 field1[i].style.color="red";
				 field3[i].style.color="red";
				 field4[i].style.color="red";
				 field5[i].style.color="red";
	}

	if (color=="non"){
				 field1[i].style.color="";
				 field3[i].style.color="";
				 field4[i].style.color="";
				 field5[i].style.color="";
	}

	if (color=="off"){
				 field1[i].style.color="silver";
				 field3[i].style.color="silver";
				 field4[i].style.color="silver";
				 field5[i].style.color="silver";
	}
		
}

function clean_sheet_reminder(){
				document.wb.sign_up_for_wb_class.value='';
				document.wb.sign_up_for_wb_day.value='';
				document.wb.sign_up_for_wb_time.value='';
				document.wb.sign_up_for_wb_date.value='';
				document.wb.sign_up_for_wb_room.value='';
}

function fill_out_sheet_reminder(i){
			
				document.wb.sign_up_for_wb_class.value = wb_schedule_Array[x][1];
				document.wb.sign_up_for_wb_day.value   = transform_wb_day(wb_schedule_Array[x][3]);
				document.wb.sign_up_for_wb_time.value   = wb_schedule_Array[x][5];
				document.wb.sign_up_for_wb_date.value   = wb_schedule_Array[x][4];
				document.wb.sign_up_for_wb_room.value   = wb_schedule_Array[x][6];

}
