﻿function ModulePrintPage() {
  lochref = '' + this.location;
	if (lochref.indexOf('?') > 0) {
		lochref = '?' + lochref.substring((lochref.indexOf('?')) + 1);
	} else {
		lochref = '';
	}

	w_width = 790;
	w_height = 500;
	if (screen) {
		w_left = (screen.availWidth - w_width)/2;
		w_top = ((screen.availHeight - w_height)/2)-20;
	}
	theWindowParam = 'width='+w_width+',height='+w_height+',left='+w_left+',top='+w_top+',status=no,resizable=no,scrollbars=yes';

	fparam = 'print_mod.php'+lochref;
  window.showPrintWindow = open(fparam, 'showPrintWindow', theWindowParam);
	setTimeout('if(showPrintWindow&&!showPrintWindow.closed)showPrintWindow.focus()',100);
}

function ValidateForm_Appointment_General(theForm) {
  var app_full_name = theForm.app_full_name.value;   
  var app_contact_phone = theForm.app_contact_phone.value;   
	var app_contact_email = theForm.app_contact_email.value;
  var department = theForm.dep_id.value;   
  var app_preferred_date = theForm.app_preferred_date.value;   
  var app_preferred_time = theForm.app_preferred_time.value;   
  var app_alternative_date = theForm.app_alternative_date.value;   
  var app_alternative_time = theForm.app_alternative_time.value;   

  if (!app_full_name)	{
    alert("You must enter your full name.");
    return false;
	} else if ((!app_contact_phone)&&(!app_contact_email)) {
		alert("You must enter your phone number or your email address.");
		return false;
	} else if ((app_contact_email)&&((app_contact_email.indexOf('@') == -1) || (app_contact_email.indexOf('.') == -1))) {
		alert("Wrong email format.");
		return false;
	} else if (!department) {
		alert("You must select department.");
		return false;
	} else if ((!app_preferred_date)||(!app_preferred_time)) {
		alert("You must enter preferred appointment date and time.");
		return false;
	} else if ((!app_alternative_date)||(!app_alternative_time)) {
		alert("You must enter alternative available date and time.");
		return false;
	} else {
		return true;
	}
}

function changeFieldValue(theField,theValue) {
	theValue = String (theValue);

	document.getElementById(theField).value = theValue;

}

function changeCheckboxValue(theField, theValue) {
	if (theValue == 'Y') {
		theField.value = 'N';
	} else {
		theField.value = 'Y';
	}
}
