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.mb.mb_class_day[i].value;
			charAtDate(mb_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 mb_class_day_checked(valor){
			for (i=0; i < document.mb.mb_class_day.length; i++)
			{
				 document.mb.mb_class_day[i].checked= valor;
//			   class_style_color(i,"non");
			}
			return;
	}

function mb_class_day_disabled(valor){
			chk_mbe=false;
			chk_mbs=false;
			any=false;

			for (i=0; i < document.mb.mb_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.mb.mb_class_day[i].disabled="disabled";
			          class_style_color(i,"off");
								}else{
												 any=true;
												 document.mb.mb_class_day[i].disabled="";
			                   class_style_color(i,"non");
						}//end if begun
			}//end for
      
			if (any == false)
			{
					var msg = "";
					mb_class_day_checked('');
					//clean_sheet_reminder();
				  msg = '<font color="red">' +
						       'Sorry!, No MEMBERSHIP CLASSES 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_mb_class_day(t){
			
		//clean_sheet_reminder();

				for (i=0; i < document.mb.mb_class_day.length; i++)
				{
					   class_style_color(i,"non");
							x = document.mb.mb_class_day[i].value;
							if (document.mb.mb_class_day[i].checked)
								{
								   class_style_color(i,"on");
								   fill_out_sheet_reminder(x);
						 }else{
									if (document.mb.mb_class_day[i].disabled)
										{
											 class_style_color(i,"off");
									   }else{
											 class_style_color(i,"non");
										 }
						 }
				}//end for

//			t.focus(); 
}

//=====================================================================
function transform_mb_days_s(day){
		if (day=='Sun'){day='Domingos'};
		if (day=='Mon'){day='Lunes'};
		if (day=='Tue'){day='Martes'};
		if (day=='Wed'){day='Miercoles'};
		if (day=='Thu'){day='Jueves'};
		if (day=='Fri'){day='Viernes'};
		if (day=='Sat'){day='Sabados'};
		return day;
}
function transform_mb_days(day){
		if (day=='Sun'){day='Sundays'};
		if (day=='Mon'){day='Mondays'};
		if (day=='Tue'){day='Tuesdays'};
		if (day=='Wed'){day='Wednesdays'};
		if (day=='Thu'){day='Thursdays'};
		if (day=='Fri'){day='Fridays'};
		if (day=='Sat'){day='Saturdays'};
		return day;
}
function transform_mb_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.mb.sign_up_for_mb_class.value='';
				document.mb.sign_up_for_mb_day.value='';
				document.mb.sign_up_for_mb_time.value='';
				document.mb.sign_up_for_mb_date.value='';
				document.mb.sign_up_for_mb_room.value='';
}

function fill_out_sheet_reminder(i){
			var x3 = (i)*1 + 2;  //calculating x3 until the 3rd lesson 
			var y = (i)*1;
			var list = "";
			
			for (x=y; x <= x3 ; x++)
			{
				        if (mb_schedule_Array[x][2] == "1")
				        {
									document.mb.sign_up_for_mb_class.value = mb_schedule_Array[x][1];
				        }
								list += '<div>';
								list += 'Lesson <B>' + mb_schedule_Array[x][2] +'</B>.&nbsp;' ;
								list += '<input type="text" class=inputs name=sign_up_for_mb_day  size="10" readonly value="' + transform_mb_day(mb_schedule_Array[x][3]) +'">&nbsp;<B>AT</B>&nbsp;';
								list += '<input type="text" class=inputs name=sign_up_for_mb_time  size="8"    readonly value="' + mb_schedule_Array[x][5] +'">&nbsp;<B>ON</B>&nbsp;';
								list += '<input type="text" class=inputs name=sign_up_for_mb_date  size="10" readonly value="' + mb_schedule_Array[x][4] +'">&nbsp;<B>IN</B>&nbsp;';
								list += '<input type="text" class=inputs name=sign_up_for_mb_room  size="10" readonly value="' + mb_schedule_Array[x][6] +'">&nbsp;<B>ROOM</B>&nbsp;';
								list += '</div>';
			}
								list += '<HR>';

			if (document.all)
			    document.all.lessons_schedule.innerHTML=list
			else 
				  if (document.getElementById)
			        document.getElementById("lessons_schedule").innerHTML= list
//					else
//			        document.write(list)

}
