<!--
var phoneFormat = "(999)999-9999";
var phoneFormatDisplay = "(___)___-____";
var ezsTimeoutID = "";   //Added by Reddy Guda to manage timeout
var ezsTimeoutWarningID ="";

function hov(loc,cls){
   if(loc.className) {
      loc.className=cls;
   }
}

function confirmChangeModalPanelLeftBar() {
	javascript:Richfaces.showModalPanel('rescheduleApptModalLeftBar');
}

function showCancelModalPanel(appointmentDateTimeDisplay, donorHasAppointments) {
	if (donorHasAppointments == 'false') {
		javascript:Richfaces.showModalPanel('appointmentAlreadyCancelledModal');
	} else {		
		document.getElementById("a4jIncludeQuickScheduleDonorModal:cancelModalForm:cancelAppointmentDateTime").innerHTML = appointmentDateTimeDisplay;	
		javascript:Richfaces.showModalPanel('cancelConfirmationModal');
	 }
}

function showQuickScheduleDonorModal(appointmentDateTimeDisplay, scheduleAllowed) {
	if (scheduleAllowed == "N") {
		javascript:Richfaces.hideModalPanel('scheduleConfirmationModal');
		javascript:Richfaces.showModalPanel('donorQuickScheduleNotAllowedModal');
	} else {
		javascript:Richfaces.hideModalPanel('donorQuickScheduleNotAllowedModal');
		document.getElementById("frmMyAppointmentsCalendar:a4jIncludeQuickScheduleDonorModal:scheduleAppointmentDateTime").innerHTML = appointmentDateTimeDisplay;	
		javascript:Richfaces.showModalPanel('scheduleConfirmationModal');		
	}
}

function printNewDonorChecklist(thisObj, thisEvent) {
	window.print();
}

function showNewDonorPrintView() {
    var mywindow;

    PopupCenter("/EasyScheduler/newDonorChecklist.go", "_blank", 650, 500)
	//mywindow = window.open("/EasyScheduler/newDonorChecklist.go", "_blank", "width=650,height=500");
	
	// Pop the window to the front
    if (mywindow && mywindow.focus) 
    	mywindow.focus();
    
	return false;
}

function PopupCenter(pageURL, title,w,h) {
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 

function underDev() {
   alert("Under Development...");
   return false;
}

function openNewWindow(page, name, title) {	
	popup = window.open(name, title,'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes');
	win=window.history.go(-page);
}

function showReportCriteriaPage(page) {				
	win=window.history.go(-page);
}

function preparePrinting()
{						
	var t=setTimeout("printReport()",500);										
}

function printReport()
{  					
	win=window.print();			
	var r=setTimeout("pageRedirect()",500);			
}

function pageRedirect()
{  		
	win=window.history.go(0);
	clearTimeout(r);
	clearTimeout(t);
}	

var displayedPhoneCount = 2;
var maxDisplayedPhoneCount = 5; 
var displayedSchedulePreferenceCount = 2;
function addPhoneItem() {
		
	if (document.getElementById("msgPhone" + displayedPhoneCount) != null) {
		alert(document.getElementById("msgPhone" + (displayedPhoneCount)));	
	}
	
	document.getElementById("addPhoneLink" + displayedPhoneCount).style.display = 'none';
	displayedPhoneCount++;
	document.getElementById("lblPhone" + displayedPhoneCount).style.display = 'block';	
	document.getElementById("pgPhone" + displayedPhoneCount).style.display = 'block';
	
	if(document.getElementById("formDonorProfile:phone" + displayedPhoneCount).value != ''){
		displayAddPhoneItem();
	}
	
	if (document.getElementById("msgPhone" + displayedPhoneCount) != null) {
		document.getElementById("msgPhone" + displayedPhoneCount).style.display = 'block';		
	}
	return false;	
}

function displayAddPhoneItem() {
	if(displayedPhoneCount < maxDisplayedPhoneCount){
		document.getElementById("addPhoneLink" + displayedPhoneCount).style.display = 'block';
	}
	return false;
}

function clearPhoneRow(item) {
	var num = parseInt(item.id.charAt(item.id.length - 1));
	document.getElementById('phone' + num).value="";
	document.getElementById('phoneType' + num).selectedIndex = 0;
}

function schedulePreferenceOnLoad() {
	var obj;

   	for (num=3; num<=maxDisplayedPhoneCount; num++) {
	  	var startObj = document.getElementById("formSchedulePreference:startTime" + num);
	  	
		if (startObj.value != "" && startObj.value != " ") {
			addDayItem();
		}
   }
}
  

function profileOnLoad() {   

    for (num=3; num<=maxDisplayedPhoneCount; num++) {
       var obj = document.getElementById("formDonorProfile:phone" + num);
       	if (obj.value != "" && obj.value != phoneFormatDisplay) {
			addPhoneItem();
	    }       
    }

    // Add masking
    var fieldsRequirePhoneFormat = ["formDonorProfile:phone1",  
    								"formDonorProfile:phone2",    	 
    								"formDonorProfile:phone3",    	 
    								"formDonorProfile:phone4",    	 
    								"formDonorProfile:phone5"];
    								
	maskPhoneFormat(fieldsRequirePhoneFormat);
}

function maskPhoneFormat(arrFields) {
   for (var i=0; i<arrFields.length; i++) {	 
	    var obj = document.getElementById(arrFields[i]);	
	    if (obj == undefined || obj == null) {
	       continue;
	    }
    	obj.mask=phoneFormat;  
   }
}

function emergencyContactOnLoad() {   
    var fieldsRequirePhoneFormat = ["formEmergencyContact:phone"];  
	maskPhoneFormat(fieldsRequirePhoneFormat);    
}	

function centerHoursOnLoad(){
    // Add masking
    var phone1Elem = document.getElementById("form1:phone1");
    if(phone1Elem != null){
      phone1Elem.mask = phoneFormat;
    }
}
/** Checking/unchecking a family of checkboxes 
in a form (formId)
with common id (familyChkBoxId)
by clicking on a main one (this). */
function setAllChecked(mainBox, formId, familyChkBoxId){
	var theForm = document.getElementById(formId);
	for(i = 0; i < theForm.elements.length; i++){
		var elem = theForm.elements[i];
		var elemId = elem.id.substring(elem.id.lastIndexOf(":") + 1);
		//alert(elem.id + ", " + elemId + ", " + familyChkBoxId);
		if(elem.type=="checkbox"  && elemId==familyChkBoxId){
			elem.checked = !mainBox.checked;
		}
	}
}

/* updating excluded dates in body-appointmentsSetup.jsp */
function appt_updateDateExclusion(chkBox, textAreaId, dateId){
	var textArea = document.getElementById(textAreaId);
	var date = document.getElementById(dateId).value;
	var text = textArea.value;
	if(!chkBox.checked && text.indexOf(date) == -1){
		if(text != ""){
			text += "; ";
		}
		text += date;
		textArea.value = text;
	}
}

function isValidCharacterForPhoneNumber(e) {
	var keynum;
	var keychar;
	var numCheck;
	
	if(window.event) { // IE
		keynum = e.keyCode;
	} else if(e.which) { // Netscape/Firefox/Opera
		keynum = e.which;
	}
	//if shift key is pressed to enter characters such as #, (, and )
	if(e.shiftKey) {
		return false;
	}
	// clear entry when backspace (8), delete (46) or del (110) is pressed
	if(keynum == 8 || keynum == 46 || keynum == 110){
		e.srcElement.value = "";
		return true;
	}
		  
	// accept tab (9), end (35), home (36), arrow keys (37, 38, 39, 40)
	if(keynum == 9 || (keynum >= 35 && keynum <= 40)){
		return true;
	}
		  
	if((keynum >= 96 && keynum <= 105) || (keynum >=48 && keynum <= 57)){
		return true;
	}		  
	//keychar = String.fromCharCode(keynum);
	//numCheck = /\d/;
	//return numCheck.test(keychar);
	return false;
}
		
function formatPhoneNumber(e) {
	var elem = e
	if(elem.value.length == 3){
		elem.value = '(' + elem.value + ')';
	}else if(elem.value.length == 8){
		elem.value = elem.value + '-';
	}else if(elem.value.length > 13){
		elem.value = elem.value.substring(0,13)
	}
}

//Added by Reddy Guda to manage time out
//This method starts the timer... pass a value in seconds and call in the body on load of all parent pages/layouts.
function startTimeoutClock(aSeconds){
	if (aSeconds > 1) {
		//alert("Setting Time out to  " + aSeconds + " seconds" );
		ezsTimeoutWarningID = window.setTimeout("Richfaces.showModalPanel('timeoutModal')", (aSeconds-300) * 1000);
		ezsTimeoutID = window.setTimeout(ezsSessionTimeout, aSeconds * 1000);
	}
}

//this is to reset the timer when ajax calls are made or if you consider any activity as a request post to keep the session alive
function resetTimeoutClock(aSeconds){
//	alert("Reseting time out to " + aSeconds + " seconds" );
	window.clearTimeout(ezsTimeoutWarningID);
	window.clearTimeout(ezsTimeoutID);
	ezsTimeoutWarningID = window.setTimeout("Richfaces.showModalPanel('timeoutModal')", (aSeconds-300) * 1000);
	ezsTimeoutID = window.setTimeout(ezsSessionTimeout, aSeconds * 1000);
}

//this will be executed when the page times out.. replace the alert with the proper redirect to the sessionTimeout.go url
function ezsSessionTimeout(){
//	alert("Your session has timed out...Please login again");
	window.location = "sessionExpired.go";
}

function openPasswordModal()
{	
	javascript:Richfaces.showModalPanel('changePasswordModal', {top: 170, left: 370});	
	return false;
}
function openForcedPasswordModal() {	
	javascript:Richfaces.showModalPanel('changePasswordForcedModal', {top: 170, left: 370});		
	return false;
}
function closePasswordModal(validData)
{	
	if (validData == "Y"){					
		javascript:Richfaces.hideModalPanel('changePasswordModal'); 							
	}
	return false;
}
function closeForcedPasswordModal(validData)
{	
	if (validData == "Y"){		
		javascript:Richfaces.hideModalPanel('changePasswordForcedModal'); 							
	}
	return false;
}
function openPasswordMessageModal(validData)
{	
	if (validData == "Y"){					
		javascript:Richfaces.showModalPanel('displayPasswordMessageModal'); 							
	}
	return false;
}
function showInformSchedulePreferenceModal(show) {	
	javascript:Richfaces.hideModalPanel('displayPasswordMessageModal');
	if (show == "Y") {								
		javascript:Richfaces.showModalPanel('informSchedulePreferenceAfterChangePwdModal');
	} 
}
function showErrorModal(errorMessage) {
	if (errorMessage == "") {
		javascript:Richfaces.hideModalPanel('quickPhysicalModal'); javascript:Richfaces.hideModalPanel('modalPanel');
	} else {
		javascript:Richfaces.showModalPanel('displayErrorModal');
	}
}
function showConfirmDonorSchedule(scheduleAllowed, overrideAllowed) {
	if (scheduleAllowed == "N") {
		if (overrideAllowed == "Y") {
			javascript:Richfaces.hideModalPanel('findDonorModal');
			javascript:Richfaces.showModalPanel('findDonorDeferralOverideScheduledModal');
		} else {
			javascript:Richfaces.hideModalPanel('findDonorModal');
			javascript:Richfaces.showModalPanel('findDonorAlreadyScheduledModal');
		}
	} else {
		javascript:Richfaces.hideModalPanel('findDonorModal');
		javascript:Richfaces.showModalPanel('findDonorConfirmationModal');
	}
}
function showCongratulationModal(scheduleAllowed) {
	if (scheduleAllowed == 'true') {								
		javascript:Richfaces.showModalPanel('finishProfileModal');
	} else {					
		javascript:Richfaces.hideModalPanel('finishProfileModal');					
	}
}

function showScheduleDonorModal(scheduleAllowed, overrideAllowed) {
	if (scheduleAllowed == "N") {
		if (overrideAllowed == "Y") {
			javascript:Richfaces.showModalPanel('overrideApptConfirmationModal');
		} else {
			javascript:Richfaces.showModalPanel('donorScheduleNotAllowedModal');
		}
	} else {
		javascript:Richfaces.showModalPanel('scheduleDonorConfirmationModal');
	}
}

function validateNumberOfChildren(){
	var elemHasChildren = document.findDonorModalForm["findDonorModalForm:radio1"];
	var elemNumChildren = document.getElementById("findDonorModalForm:donorResultNumberOfChildren");
	if(elemHasChildren && elemHasChildren[0].checked == true && elemNumChildren.value == 0){
		alert('Please enter the number of children for which you will need child care');
		return false;
	}else{
	    return true;
	}
}

function resetFindDonorForm()
{
	document.getElementById('findDonorModalForm:findDonorSearchLastName').value="";
	document.getElementById('findDonorModalForm:findDonorSearchFirstName').value="";
	document.getElementById('findDonorModalForm:findDonorSearchPhoneNumber').value="";
	document.getElementById('findDonorModalForm:findDonorSearchPDN').value="";
}

function resetAuthenticationForm()
{
	document.getElementById('findDonorUserAuthenticationModalForm:deferralOverridePin').value="";
	document.getElementById('findDonorUserAuthenticationModalForm:deferralOverridePassword').value="";
}

function showAuthentication(authentication)
{		
	if (authentication == "failed"){
		//alert('Invalid User ID or Password! Please Try Again. ');
		javascript:Richfaces.showModalPanel('displayErrorModal');
		javascript:resetAuthenticationForm();
		javascript:Richfaces.showModalPanel('findDonorUserAuthenticationModal'); 
		return false;		
	}else{
		javascript:Richfaces.hideModalPanel('findDonorUserAuthenticationModal'); 
		javascript:Richfaces.hideModalPanel('findDonorModal');
		return false;
	}	
}

function resetUploadTextbox(textBoxName, displayMode) {
  var obj = document.getElementById('frmUploadCenterImages:' + textBoxName);
  
  if (displayMode == 'block') {
  	obj.value="";  	
  	document.getElementById('frmUploadCenterImages:btnCenterImageUploadNew').style.display = "none";
  } else {
  	document.getElementById('frmUploadCenterImages:btnCenterImageUploadNew').style.display = "block";
  }
  
  	obj.style.display = displayMode;	 

    document.getElementById('frmUploadCenterImages:btnCenterImageUploadSave').style.display = displayMode;
  	document.getElementById('frmUploadCenterImages:btnCenterImageUploadSaveAdd').style.display = displayMode;
  	document.getElementById('frmUploadCenterImages:btnCenterImageUploadCancel').style.display = displayMode;   	     
}

function clearURL(objName) {
	document.getElementById('frmUploadPromoImages:' + objName).value = "";
}

function confirmBeforeSave() {
	var returnValue; 
	returnValue = confirm('Note that changing the donation or physical interval can result in existing appointment slots being deleted and/or existing appointments being canceled. Select OK to continue or Cancel to abort'); 
	return returnValue;
}

function enableFields() {
	document.getElementById('setupScheduleForm:donationInterval').disabled = false;
	document.getElementById('setupScheduleForm:physicalInterval').disabled = false;
	document.getElementById('setupScheduleForm:playroomInterval').disabled = false;
	document.getElementById('setupScheduleForm:donationDuration').disabled = false;
	document.getElementById('setupScheduleForm:physicalDuration').disabled = false;
	document.getElementById('setupScheduleForm:daysInAdvanceDonation').disabled = false;
	document.getElementById('setupScheduleForm:daysInAdvancePhysical').disabled = false;
	document.getElementById('setupScheduleForm:donationsBaseDefault').disabled = false;
	document.getElementById('setupScheduleForm:physicalsBaseDefault').disabled = false;
	document.getElementById('setupScheduleForm:playroomBaseDefault').disabled = false;
}

function disableFields() {
	if(document.getElementById('setupScheduleForm:effectiveFromInputDate').value == ''){
		document.getElementById('setupScheduleForm:donationInterval').disabled = true;
		document.getElementById('setupScheduleForm:physicalInterval').disabled = true;
		document.getElementById('setupScheduleForm:playroomInterval').disabled = true;
		document.getElementById('setupScheduleForm:donationDuration').disabled = true;
		document.getElementById('setupScheduleForm:physicalDuration').disabled = true;
		document.getElementById('setupScheduleForm:daysInAdvanceDonation').disabled = true;
		document.getElementById('setupScheduleForm:daysInAdvancePhysical').disabled = true;
		document.getElementById('setupScheduleForm:donationsBaseDefault').disabled = true;
		document.getElementById('setupScheduleForm:physicalsBaseDefault').disabled = true;
		document.getElementById('setupScheduleForm:playroomBaseDefault').disabled = true;
	}
}

function wait_to_open_window() {					
	var t=setTimeout("open_report_window()",6000);				
}	
		
function open_report_window() {	
	var w=1000;
	var h=700;
	var t=0;
	var l=0;									
	win=window.open('appointmentsMadeByRpt-viewer.xhtml','overrideReport','scrollbars=yes, width='+w+', height='+h+', top='+t+', left='+l);
	win=window.history.go(0);
	clearTimeout(t);				
}	

function resetForm() {
	document.getElementById('findDonorForm:txtLastName').value="";
	document.getElementById('findDonorForm:txtFirstName').value="";
	document.getElementById('findDonorForm:txtPDN').value="";
	document.getElementById('findDonorForm:txtPhoneNumber').value="";
}

function showTempPassword()
{						
	javascript:Richfaces.showModalPanel('displayMessageModal');					
	return false;
}

function closeModal(validData)
{	
	document.getElementById('changeUserIdForm:txtNewEmailAddress').value="";
	document.getElementById('changeUserIdForm:txtConfirmEmailAddress').value="";
	if (validData == "Y"){			
		javascript:Richfaces.hideModalPanel('changeUserIdModal'); 
	}
	return false;
}

function showUserIDStaffChangedMessage(message)
{
	if (message != ""){					
		javascript:Richfaces.showModalPanel('displayGlobalMessageModal');								
	}else{
		javascript:Richfaces.hideModalPanel('displayGlobalMessageModal'); 
	}
	return false;
}

function closeModal(validData)
{	
	if (validData == "Y"){					
		javascript:Richfaces.hideModalPanel('changeUserIdModal'); 							
	}
	return false;
}

function showUserIDDonorChangedMessage(message)
{
	if (message != ""){			
		javascript:Richfaces.showModalPanel('displayDonorGlobalMessageModal');								
	}else{
		javascript:Richfaces.hideModalPanel('displayDonorGlobalMessageModal'); 
	}
	return false;
}

function wait_to_open_window()
{					
	var t=setTimeout("open_report_window()",6000);				
}

function open_report_window()
{	
	var w=1000;
	var h=700;
	var t=0;
	var l=0;									
	win=window.open('potentialDonorRpt-viewer.xhtml','overrideReport','scrollbars=yes, width='+w+', height='+h+', top='+t+', left='+l);
	win=window.history.go(0);
	clearTimeout(t);				
}

function completeProfileDelete(validData)
{	
	javascript:Richfaces.hideModalPanel('confirmDeleteProfileModal'); 	
	if (validData == "Y"){					
		javascript:Richfaces.showModalPanel('profileDeleteCompleteModal'); 							
	}
	return false;
}

function showPlayroomUsageChangeModal(showOverride) {
	javascript:Richfaces.hideModalPanel('rescheduleApptConfirmationModal');
	if (showOverride == "Y") {								
		javascript:Richfaces.showModalPanel('changePlayroomOverrideModal');
	} else {					
		javascript:Richfaces.showModalPanel('changePlayroomSuccessModal');				
	}
}
//-->
