function dA(hour, min) {
   if(checkOptionsChange()==0) {
      window.document.forms[0].hour.value=hour;
      window.document.forms[0].min.value=min;
      if(arguments.length>2) {
			var resource=window.document.forms[0].resource;
			if(resource.type=='select-one') {
				resource.options[0].value=arguments[2];
				resource.selectedIndex=0;
			} else resource.value=arguments[2];
      }
      if(arguments.length>3) {
			var activity=window.document.forms[0].activity;
			if(activity.type=='select-one') {
				activity.options[0].value=arguments[3];
				activity.selectedIndex=0;
			} else activity.value=arguments[3];
      }
      makeAppointment();
   } else alert(optionsChanged);
}
function wA(year, month, date, hour, min) {
   if(checkOptionsChange()==0) {
      window.document.forms[0].year.value=year;
      window.document.forms[0].month.value=month;
      window.document.forms[0].day.value=date;
      window.document.forms[0].hour.value=hour;
      window.document.forms[0].min.value=min;
      if(arguments.length>5) {
			var resource=window.document.forms[0].resource;
			if(resource.type=='select-one') {
				resource.options[0].value=arguments[5];
				resource.selectedIndex=0;
			} else resource.value=arguments[5];
      }
      if(arguments.length>6) {
			var activity=window.document.forms[0].activity;
			if(activity.type=='select-one') {
				activity.options[0].value=arguments[6];
				activity.selectedIndex=0;
			} else activity.value=arguments[6];
      }
      makeAppointment();
   } else alert(optionsChanged);
}
function mA(date, hour, min, resourceId, activityId) {
   if(checkOptionsChange()==0) {
      window.document.forms[0].day.value=date;
      window.document.forms[0].hour.value=hour;
      window.document.forms[0].min.value=min;
		var resource=window.document.forms[0].resource;
		if(resource.type=='select-one') {
			resource.options[0].value=resourceId;
			resource.selectedIndex=0;
		} else resource.value=resourceId;
		var activity=window.document.forms[0].activity;
		if(activity.type=='select-one') {
			activity.options[0].value=activityId;
			activity.selectedIndex=0;
		} else activity.value=activityId;
      makeAppointment();
   } else alert(optionsChanged);
}
function makeAppointment(){
      window.document.forms[0].method.value='make';
      doNext();
}
function gD(year, month, day) {
   document.forms[0].year.value=year;
   document.forms[0].month.value=month;
   document.forms[0].day.value=day;
   document.forms[0].setDay.value=true;
   goDirect('ReceptionistManageAppointmentDaily');
}
function gC(year, month, day) {
	goDirect('ReceptionistManageAppointmentClient');
}
function getDayGrid(year, month, day) {
   setDate(month, day, year, 'daygrid');
}
function getWeekGrid(year, month, day) {
   setDate(month, day, year, 'weekgrid');
}
function getMonthGrid(year, month, day) {
   setDate(month, day, year, 'monthgrid');
}
function setDate(month, day, year) {
   window.document.forms[0].year.value=year;
   window.document.forms[0].month.value=month;
   window.document.forms[0].day.value=day;
   if(arguments.length>3) document.forms[0].grid.value=arguments[3];
   document.forms[0].method.value='modify';
   doSave();
}
function checkOptionsChange() {
   var changed=0;
	var regular=1==window.document.forms[0].apptGroupType.value;
   if(window.document.forms[0].copyOfProgram!=null&&
      window.document.forms[0].copyOfActivity!=null&&
      window.document.forms[0].copyOfResource!=null&&
      window.document.forms[0].copyOfDuration!=null&&
      window.document.forms[0].copyOfAttendees!=null) {
      if(checkChange(window.document.forms[0].program,   window.document.forms[0].copyOfProgram.value)!=0||
         checkChange(window.document.forms[0].activity,  window.document.forms[0].copyOfActivity.value)!=0||
         (regular&&checkChange(window.document.forms[0].resource,  window.document.forms[0].copyOfResource.value)!=0)||
         (regular&&checkChange(window.document.forms[0].duration,  window.document.forms[0].copyOfDuration.value)!=0)||
         checkChange(window.document.forms[0].attendees, window.document.forms[0].copyOfAttendees.value)!=0) changed=1;
   }
   return changed;
}
function checkChange(select, checkValue) {
   var index=0;
   var value;
   if(select.type=='select-one') {
      index=select.selectedIndex;
      if(index<0) index=0;
      value=select.options[index].value;
   } else value=select.value;
   return (value==checkValue) ? 0:1;
}
function waitList() {
   if(checkOptionsChange()==0) {
 		document.forms[0].method.value='waitList';
 		doGetDown(4);   
 	} else alert(optionsChanged);
}
