<!--
var phoneFormat = "(999)999-9999";
var phoneFormatDisplay = "(___)___-____";


function hov(loc,cls){
   if(loc.className) {
      loc.className=cls;
   }
}

function printNewDonorChecklist(thisObj, thisEvent) {
	window.print();
}

function showNewDonorPrintView() {
    var mywindow;

	mywindow = window.open('/EasyScheduler/newDonorChecklist.go', "_blank", 'width=900,height=400');
	
	// Pop the window to the front
    if (mywindow && mywindow.focus) 
    	mywindow.focus();
    
	return false;
}

function underDev() {
   alert("Under Development...");
   return false;
}


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 deletePhoneItem(item){
	var num = parseInt(item.id.charAt(item.id.length - 1));
	//shift phones up
	for(i = num+1;i <= displayedPhoneCount; i++){
		document.getElementById("formDonorProfile:phone"  + (i - 1)).value = 
			document.getElementById("formDonorProfile:phone"  + i).value;
		document.getElementById("formDonorProfile:phoneType"  + (i - 1)).selectedIndex = 
			document.getElementById("formDonorProfile:phoneType"  + i).selectedIndex;
	}
	return deleteLastPhoneItem();
}

function deleteLastPhoneItem(){
	if(displayedPhoneCount < 3){
		//only erase
		document.getElementById("formDonorProfile:phone" + displayedPhoneCount).value = '';
		document.getElementById("formDonorProfile:phoneType" + displayedPhoneCount).selectedIndex = -1;
	}else{
		//hide
		document.getElementById("lblPhone" + displayedPhoneCount).style.display = 'none';	
		document.getElementById("pgPhone" + displayedPhoneCount).style.display = 'none';	
		displayedPhoneCount--;
		displayAddPhoneItem();
	}
}

function deleteSchedulePreferenceItem(item){
	var num = parseInt(item.id.charAt(item.id.length - 1));
	//alert('The value of num is: ' + num);
	//shift schedule preferences up
	for(i = num+1;i <= displayedSchedulePreferenceCount; i++){
		//alert('dayOfTheWeek' + (i - 1));
		//alert('formSchedulePreference:dayOfTheWeek' + (i - 1) + ' = ' + document.getElementById("formSchedulePreference:dayOfTheWeek"  + (i - 1)).selectedIndex);
		document.getElementById("formSchedulePreference:dayOfTheWeek"  + (i - 1)).selectedIndex = 
			document.getElementById("formSchedulePreference:dayOfTheWeek"  + i).selectedIndex;
		document.getElementById("formSchedulePreference:startTime"  + (i - 1)).selectedIndex = 
			document.getElementById("formSchedulePreference:startTime"  + i).selectedIndex;
		document.getElementById("formSchedulePreference:endTime"  + (i - 1)).selectedIndex = 
			document.getElementById("formSchedulePreference:endTime"  + i).selectedIndex;
	}
	return deleteLastSchedulePreferenceItem();
}

function deleteLastSchedulePreferenceItem(){
	if(displayedPhoneCount < 3){
		//only erase
		document.getElementById("formSchedulePreference:dayOfTheWeek" + displayedSchedulePreferenceCount).selectedIndex = -1;
		document.getElementById("formSchedulePreference:startTime" + displayedSchedulePreferenceCount).selectedIndex = -1;
		document.getElementById("formSchedulePreference:endTime" + displayedSchedulePreferenceCount).selectedIndex = -1;
	}else{
		//hide
		document.getElementById("addDay" + displayedSchedulePreferenceCount).style.display = 'none';	
		displayedSchedulePreferenceCount--;
		//displayAddPhoneItem();
	}
}

function addDayItem(component) {
	var compId = parseInt(component);
	document.getElementById("addDay" + compId).style.display = 'block';
	document.getElementById("addDayLink" + (compId)).style.display = 'inline';
	document.getElementById("addDayLink" + (compId - 1)).style.display = 'none';	  		

	return false;
}

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)
	}
}
//-->