function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
  // otherwise, update 'characters left' counter
  else
    countfield.value = maxlimit - field.value.length;
}

function submitAgency() {
   if (document.myForm.siteID) {document.myForm.siteID.options[0].selected=true;}
   if (document.myForm.classID) {document.myForm.classID.options[0].selected=true;}
   if (document.myForm.studentID) {document.myForm.studentID.options[0].selected=true;}
	if (document.VolunteerReport) {  
		document.myForm.HSParent.value = document.VolunteerReport.HSParent.options[document.VolunteerReport.HSParent.selectedIndex].value;
		document.myForm.tbTestRcvd.value  = document.VolunteerReport.tbTestRcvd.options[document.VolunteerReport.tbTestRcvd.selectedIndex].value;
		document.myForm.results.value  = document.VolunteerReport.results.options[document.VolunteerReport.results.selectedIndex].value;
		document.myForm.volunteerType.value  = document.VolunteerReport.volunteerType.options[document.VolunteerReport.volunteerType.selectedIndex].value;
	}
   document.myForm.submit();
}

function submitSite() {
   if (document.myForm.classID) {document.myForm.classID.options[0].selected=true;}
   if (document.myForm.studentID) {document.myForm.studentID.options[0].selected=true;}
	if (document.VolunteerReport) {  
		document.myForm.HSParent.value = document.VolunteerReport.HSParent.options[document.VolunteerReport.HSParent.selectedIndex].value;
		document.myForm.tbTestRcvd.value  = document.VolunteerReport.tbTestRcvd.options[document.VolunteerReport.tbTestRcvd.selectedIndex].value;
		document.myForm.results.value  = document.VolunteerReport.results.options[document.VolunteerReport.results.selectedIndex].value;
		document.myForm.volunteerType.value  = document.VolunteerReport.volunteerType.options[document.VolunteerReport.volunteerType.selectedIndex].value;
	}
   document.myForm.submit();
}

function submitClass() {
   if (document.myForm.studentID) {document.myForm.studentID.options[0].selected=true;}
   document.myForm.submit();
}

function submitStudent() {
   document.myForm.submit();
}

function goTo(inputForm){
   inputForm.submit();
} 

function getPage(obj, skip) {
   obj.skip.value = skip;
   obj.submit();
} 

function isValidDate(formName, fieldName) {

   var isValid = 1;
   var re = new RegExp("[^0-9]");
   var str = eval('document.' + formName + '.' + fieldName + '.value');
   var arr = str.split("-");
   var month = arr[0];
   var day   = arr[1];
   var year  = arr[2];
   if (arr.length != 3) {
       isValid = 0;
   } else if (year < 1900 || year > 2030) {
       isValid = 0;
   } else if (day == '00' || month == '00' || year == '0000') {
       isValid = 0;
   } else if (month.length != 2 || re.test(month) || month > 12) {
       isValid = 0;
   } else if (day.length != 2 || re.test(day) || day > 31) {
       isValid = 0;
   } else if (year.length != 4 || re.test(year)) {
       isValid = 0;
   } else if (month == 2) { 
       if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { 
           if (day > 29)
               isValid = 0;
       } else {
           if (day > 28)
               isValid = 0;
       }

   } else if (month == 4 || month == 6 || month == 9 || month == 11) {
       if (day > 30)
           isValid = 0;
   } 
   if (!isValid) {
      return false;
   } else {
      return true;
   }
}

function getLastDayOfTheMonth(myDate) {
    
   var arr = myDate.split("-");
   var month = arr[0];
   var day   = arr[1];
   var year  = arr[2];

   if (month == '02') {
      if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
          return 29;
      } else {
          return 28;
      }
   } else if (month == '04' || month == '06' || month == '09' || month == '11') {      
       return 30;
   } else {
       return 31;
   }
}

function popUpWindow() {
 
   var popUpWin = window.open('', 'page', 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1,width=660,height=600');
   popUpWin.focus();   
   document.report.submit();

}

function newWindow() {
    var popwin = window.open('','popup', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=800,height=400');
    popwin.focus();
}

function popUpWin(url) {

        var features = "toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=660,height=400";
        var makepopUpWin = window.open(url,'pop',features);
if (window.focus) {makepopUpWin.focus()}

// to call this popup simply have an href similar to the one below this line
// <a href="javascript:popUpWin('YOUR DESIRED URL')"; return false;>NAME OF YOUR LINK</a>

}


function popUpWinHelp(url) {

        var features = "width=700,height=500, scrollbars=yes, menubar=no, resizable=yes, status=no, toolbar=no";
        var makepopUpWin = window.open(url,'pop',features);
if (window.focus) {makepopUpWin.focus()}

// to call this popup simply have an href similar to the one below this line
// <a href="javascript:popUpWinHelp('YOUR DESIRED URL')"; return false;>NAME OF YOUR LINK</a>

}


function FormatDate(formName, fieldName){
    var input = eval('document.' + formName + '.' + fieldName + '.value');

    if (input)  {
        input = input.replace(/[^0-9]/g, '');
        regExp = /^\d{8}/;
        if (input.match(regExp)) {
            one = input.substring(0, 2);
            two = input.substring(2, 4);
            three = input.substring(4, 8);

            input = one + '-' + two + '-' + three;
            eval('document.' + formName + '.' + fieldName + '.value=' + '"' + input + '"');
            if (isValidDate(formName, fieldName) == false) {
                alert('Invalid Date.' );
                eval('document.' + formName + '.' + fieldName + '.value=""');
                eval('document.' + formName + '.' + fieldName + '.focus()');
                eval('document.' + formName + '.' + fieldName + '.select()');
            }
        } else {
            alert('Date format must be mm-dd-yyyy' );
            eval('document.' + formName + '.' + fieldName + '.value=""');
            eval('document.' + formName + '.' + fieldName + '.focus()');
            eval('document.' + formName + '.' + fieldName + '.select()');
        }
    }
}

function ChicagoFormatSSN(formName, fieldName){
    var input = eval('document.' + formName + '.' + fieldName + '.value');
    if (input) {
        input = input.replace(/[^0-9a-z]/ig, '');
        regExp = /^.{9}/;
        if (input.match(regExp)) {
            one = input.substring(0, 3);
            two = input.substring(3, 5);
            three = input.substring(5, 9);

            input = one + '-' + two + '-' + three;
            eval('document.' + formName + '.' + fieldName + '.value=' + '"' + input + '"');
        } else {
            alert('Social Security Format must be ???-??-????' );
            eval('document.' + formName + '.' + fieldName + '.value="000-00-0000"');
            eval('document.' + formName + '.' + fieldName + '.focus()');
        }
    }
}


function FormatSSN(formName, fieldName){
    var input = eval('document.' + formName + '.' + fieldName + '.value');
    if (input) {
        input = input.replace(/[^0-9]/g, '');
        regExp = /^\d{9}/;
        if (input.match(regExp)) {
            one = input.substring(0, 3);
            two = input.substring(3, 5);
            three = input.substring(5, 9);

            input = one + '-' + two + '-' + three;
            eval('document.' + formName + '.' + fieldName + '.value=' + '"' + input + '"');
        } else {
            alert('Social Security Format must be ddd-dd-dddd' );
            //eval('document.' + formName + '.' + fieldName + '.value="000-00-0000"');
            eval('document.' + formName + '.' + fieldName + '.value=""');
            eval('document.' + formName + '.' + fieldName + '.focus()');
        }
    }
}

function FormatPhone(formName, fieldName){
    var input = eval('document.' + formName + '.' + fieldName + '.value');
    if (input) {
        input = input.replace(/[^0-9]/g, '');
        regExp = /^\d{10}/;
        if (input.match(regExp)) {
            one = input.substring(0, 3);
            two = input.substring(3, 6);
            three = input.substring(6, 10);

            input = '(' + one + ')' + '-' + two + '-' + three;
            eval('document.' + formName + '.' + fieldName + '.value=' + '"' + input + '"');
        } else {
            alert('Phone Format must be (ddd)-ddd-dddd' );
            eval('document.' + formName + '.' + fieldName + '.value=""');
            eval('document.' + formName + '.' + fieldName + '.focus()');
        }
    }
}

function PrintMessage(printMode) {
  if(printMode == 'L'){
      alert("Please set your printer settings to landscape.  Also for the best result set your printer left and right margins to 0.25 inches.");
  } else {
      alert("For the best result set your printer left and right margins to 0.25 inches, top and bottom margins to 0.2 inches.");
  }
}

function requiredFields(formName, fieldName, warning) {
    if (!eval('document.'+formName+'.'+fieldName+'.value')) {
         alert('Warning: '+warning+'.');
         eval('document.'+formName+'.'+fieldName+'.focus()');
    } else {
         eval('document.'+formName+'.submit()');
    }

}


function isValidEmailAddress(email) {
    var res = 1;
    var ndx = email.search(/@/); 
    if (ndx > 0) {
        var name = email.substring(0, ndx);
        var rest = email.substring(ndx+1); 
        var idx = rest.search(/\.[a-z]+$/);
        if (idx > 0) { 
            var domain = rest.substring(0, idx);
            var ext    = rest.substring(idx+1);
            if (domain.match(/[^a-z0-9._-]/i)) {
               res = 0;
            } else if (ext.match(/[^a-z0-9-]/i) || ext.length > 4 || ext.length < 2) {
               res = 0
            } 
        } else { 
            res = 0;
        }
    } else {
        res = 0;
    }
    return res; 
}


function checkRegularExpr(formName,fieldName, string, message){
    var mainString = eval('document.' + formName + '.' + fieldName + '.value');

    if(mainString){
       var re = new RegExp(""+string+"");
       var foundArray = re.exec(mainString);
       if(!foundArray){
           alert("Please "+message+"!");
           eval('document.' + formName + '.' + fieldName + '.focus()');
           return false;
       }
    }
}


function displayPage(destination) {
    window.location = destination;
}

function checkNumeric(formName, fieldName, message) {
    var validDecimal = new RegExp("[^0-9]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry != '' && validDecimal.test(entry)) {
        alert('Field ' + message + ' should contain only digits.');
        eval('document.' + formName + '.' + fieldName + '.value=""' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    }
}


function checkDecimal(formName, fieldName, message) {
    var validDecimal = new RegExp("[^0-9\.]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry != '' && validDecimal.test(entry)) {
        alert('Field ' + message + ' should contain numerical value.');
        eval('document.' + formName + '.' + fieldName + '.value=""' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    }
}

function checkAlpha(formName, fieldName, message) {
    var validDecimal = new RegExp("[^a-zA-Z]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry != '' && validDecimal.test(entry)) {
        alert('Field ' + message + ' should contain letters only.');
        eval('document.' + formName + '.' + fieldName + '.value=""' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    }
}
 
function checkInteger(formName, fieldName, message) {
    var validDecimal = new RegExp("[^0-9]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry != '' && validDecimal.test(entry)) {
        alert('Field ' + message + ' should contain numerical value.');
        eval('document.' + formName + '.' + fieldName + '.value="0"' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    }
}

function checkNaturalNumber(formName, fieldName, message) {
    var validDecimal = new RegExp("[^0-9]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry == 0 || (entry != '' && validDecimal.test(entry))) {
        alert('Field ' + message + ' should contain numerical value.');
        eval('document.' + formName + '.' + fieldName + '.value="1"' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    }
}

function Format15Min(formName, fieldName) {
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    time  = entry.split(":");
    min   = time[1]; 
    if ( !min || min == '00'||min == '15' || min == '30' || min == '45') {
        //correct input  
    } else {
        alert('Minute interval should be 0, 15, 30, 45');
        eval('document.' + formName + '.' + fieldName + '.value=""' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );

    }
}

function FormatHour(formName, fieldName) {
    var validHour = new RegExp("[^0-9:]");
    var entry    = eval('document.' + formName + '.' + fieldName + '.value');
    if (entry != '' && validHour.test(entry)) {
        alert('The field format must be hh:mm');
        eval('document.' + formName + '.' + fieldName + '.value=""' );
        eval('document.' + formName + '.' + fieldName + '.focus()' );
    } else {      
         time  = entry.split(":");
         hours = time[0];
         min   = time[1];

         if ( min == '1'||min == '2' || min == '3' || min == '4' || min == '5') {
              min = min+'0';
         }
         if ( min == '6'||min == '7' || min == '8' || min == '9') {
              min = '0'+min;
         }
    
         if(hours>24) {
             hours='00';
         }
         if(min>60) {
             min='00';
         }

         if(min || hours) {
             if(!min) {
                 min='00';
             }
             if(!hours) {
                 hours='00';
             }
             entry = hours+':'+min;
             eval('document.' + formName + '.' + fieldName + '.value=entry');
         }
    } 
}

function getRandom(number) {
    return Math.floor(Math.random() * number);
}

function getRandomSSN() {
    arr = new Array(26);
    alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for (var i = 0; i < arr.length; i++) {
       arr[i] = alpha.substring(i, i+1);
    }
    chars  = arr[getRandom(26)] + arr[getRandom(26)] + arr[getRandom(26)];
    digits = getRandom(10000000) + '';
    ssn = chars + '-' + digits.substring(0,2) + '-' + digits.substring(2,6);
    return ssn;
}

function validFutureDate(d, countToday) {

    var arr = d.split("-");
    var month = arr[0];
    var day   = arr[1];
    var year  = arr[2];

    var mydate = year + month + day;

    var today = new Date();
    var month = today.getMonth() + 1;
    var day   = today.getDate();
    var year  = today.getYear();
    if (navigator.appName == "Netscape")
        year = 1900 + year + '';
    else
        year = year + '';
       
    if (month < 10)
        month = '0' + month;

    if (day < 10)
        day = '0' + day;

    var currDate = year + month + day;
    if (countToday == 0) {
        if (parseInt(mydate) <= parseInt(currDate)) {
            return false;
        }
    } else {
        if (parseInt(mydate) < parseInt(currDate)) {
            return false;
        }
    }
    return true;
}

function compareDates(date1, date2) {
    var arr1 = date1.split("-");
    var str1 = arr1[2] + arr1[0] + arr1[1];

    var arr2 = date2.split("-");
    var str2 = arr2[2] + arr2[0] + arr2[1];
    if (parseInt(str1) < parseInt(str2)) {
        return true; 
    } else {
        return false;
    } 
}


function isDateFirstOfMonth(date1) {
    var arr = date1.split("-");
    if (arr[1] != '01') {
        return false; 
    } else {
        return true; 
    }  
}

function displayTMPFiltering(status) {
    if (status) {
        document.getElementById('TMP_additionalFiltering').style.display='block';
        document.getElementById('IMG_additionalFiltering').style.display='none';
    } else {
        document.getElementById('TMP_additionalFiltering').style.display='none';
        document.getElementById('IMG_additionalFiltering').style.display='block';
    }

}


function hideprintshow(page_orientation){

	hps();             // hide
	if ( page_orientation == 'L' ){
     PrintMessage(page_orientation);
	}
	window.print();  // print
  var t=setTimeout("hps();",1000); // show after 5 seconds
	                                // timing issue

}

//
// items in display_print will toggle on while suppress_print will toggle off
// misc1-4 and disp1-4 can be used for anything
function hps() {
  suppress_print = new Array('filtersection', 'prev', 'next', 'bottom', 'print', 'misc1', 'misc2', 'misc3', 'misc4');
  display_print = new Array('showfilter', 'disp1', 'disp2', 'disp3', 'disp4');

	// hide/show items
  for (var i=0; i < suppress_print.length; i++) {
    try { 
		  if ( document.getElementById(suppress_print[i]).style.display != 'none' ){
		    document.getElementById(suppress_print[i]).style.display = 'none' ;
			} else {
		    document.getElementById(suppress_print[i]).style.display = '' ;
	
			}
		} catch(e) {}
  }
  for (var i=0; i < display_print.length; i++) {
    try {
//		  if ( document.getElementById(display_print[i]).style.display != 'none' ){
			if ( document.getElementById(display_print[i]).style.display == 'none' ){
                    document.getElementById(display_print[i]).style.display = 'none' ;

			} else {
//		    document.getElementById(display_print[i]).style.display = '' ;
		    document.getElementById(display_print[i]).style.display = 'block' ;
			}
		} catch(e) {}
  }
}

function togglehideshow(list) {
    splitString = list.split(":");
		var len     = splitString.length;

		for(var i=0;i<len;i++){
      var selObj = document.getElementById(splitString[i]);
      try {
	      if ( selObj.style.display != 'none' ){
		      selObj.style.display = 'none' ;
		    } else {
		      selObj.style.display = '' ;
		    }
	    } catch(e) {}
		}
}

function show(list) {
  splitString = list.split(":");
	var len     = splitString.length;

	for(var i=0;i<len;i++){
    var selObj = document.getElementById(splitString[i]);
    try {
      selObj.style.display = '' ;
	  } catch(e) {}
	}
}

function hide(list) {
  splitString = list.split(":");
	var len     = splitString.length;

	for(var i=0;i<len;i++){
    var selObj = document.getElementById(splitString[i]);
    try {
      selObj.style.display = 'none' ;
	  } catch(e) {}
	}
}


function submitform(frm) {
  frm.submit();
}

function submitformByName(form_name) {
  var frm = eval('document.'+form_name);
  frm.submit();
}

//
// You must pass the form name as a text field.  It seems that you can't
//  include this.form in the javascript function call on an anchor link.
//

function nextprevious(form_name, skip_value) {
  var frm = eval('document.'+form_name);
  frm.skip.value = skip_value;
  frm.submit();
}

function submitafterassign(form_name, list) {
  var frm = eval('document.'+form_name);

  var splitString = list.split(":");
	var len         = splitString.length;

	for(var i=0;i<len;i++){
    var splitString2 = splitString[i].split("=");
    var selObj = eval('document.'+form_name+'.'+splitString2[0]+'.value="'+splitString2[1]+'"');
	}
  frm.submit();
}

function switch_view(sh){

  var showid = 'show_' + sh;
  var editid = 'edit_' + sh;
  try
  {
      document.getElementById(showid).style.display = 'none' ;
  } catch(e) {}

  try
  {
    document.getElementById(editid).style.display = 'block' ;
  } catch(e) {}

}


/*
   Function: load_time_drop_downs

   Loads a drop down menu with time selections in increments of 10 minutes up to 50 min.
	 The 1st - last (+50 min) elements are created within the function.
	 Example: load_time_drop_downs(this, '08:00pm') will return an option list with 08:00pm selected
	 
	 <SELECT id="fieldID" name="fieldName" onfocus="load_time_drop_downs(this, '08:00pm')" onmouseover="load_time_drop_downs(this, '08:00pm')" > 
	 	 <option value="[+ $field_value +]">[+ $field_value +]</option>
	 </select>

   Parameters:

      selObj - Select form element. ie; this
      selection - a time to initally select.

   Returns:

		Loads an option List of drop down menu with time selections and makes an initial selection.

*/
function load_time_drop_downs(selObj, selection){
  array_hours = new Array('06', '07', '08', '09', '10', '11', '12', '01', '02', '03', '04', '05', '06', '07', '08', '09');
	array_minutes=new Array('00', '10', '20', '30', '40', '50');
	array_ampm = new Array('am', 'pm');
  var stime = selection ;
  var opt_i = 0;
  var ampm = 0;

	var x = selObj.options.length - 1 ;

	if ( x > 0 ){
	  return;
	}

  if (selection == '' ){
      selObj.options[opt_i] = new Option(stime, stime, true, true);
  } else {
      selObj.options[opt_i] = new Option(stime, stime);
      opt_i++;
      selObj.options[opt_i] = new Option('','');
  }
  opt_i++;

  for (var i=0; i < array_hours.length; i++) {
    for (var h=0; h < array_minutes.length; h++) {
      if (i >= 6 ){
        ampm = 1;
      }
      stime = array_hours[i] + ':' + array_minutes[h] + array_ampm[ampm];
      try
      {
        if (stime == selection ){
          selObj.options[opt_i] = new Option(stime, stime, true, true);
        } else {
          selObj.options[opt_i] = new Option(stime, stime);
        }
        opt_i++;
      } catch(e) {}
    }
  }
}


function js_pause(milliseconds)
{
    var now = new Date();
    var exitTime = now.getTime() + milliseconds;

    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}

var executeReminder = new Array();
var executeReminderDate = new Array();
var reminderLength = 0;

function emailReminder(caldate, title, message, address1, address2, visible, thesystem) {
	reminderLength++;

	executeReminderDate.push('eval("' + caldate + '")');

	executeReminder.push('var win'+ reminderLength + ' = window.open(\'/processes/emailReminder.epl?reminderDate=\' + eval("' + caldate + '") + \'&reminderTitle=' + escape(title) + '&reminderEmailAddress1=' + escape(address1) + '&reminderEmailAddress2=' + escape(address2)  + '&reminderMessage=' + escape(message) +'&thesystem='+thesystem+'\',\'reminder' + reminderLength +'\',\'height=460,width=520,scrollbars=yes,resizable=yes\'); win' + reminderLength + '.focus();');

	if (visible == 1) {
	    document.write('<a href="#" onclick="window.open(\'/processes/emailReminder.epl?reminderDate=' + escape(caldate) + '&reminderTitle=' + escape(title) + '&reminderEmailAddress1=' + escape(address1) + '&reminderEmailAddress2=' + escape(address2)  + '&reminderMessage=' + escape(message) +'&thesystem='+thesystem+'\',\'reminder' + reminderLength +'\',\'height=460,width=520,scrollbars=yes,resizable=yes\'); return false;"><img src="/images/mail.gif" border=0></a>');
	}

	return;
}

var ReqFields = new Array();
var ReqFieldsConditional = new Array();

function addRequiredField (formName,fieldName, message)
{
	ReqFields.push(new Array(formName,fieldName,message));
}

function addConditionalRequiredField (theexpression, formName,fieldName, message)
{
	ReqFieldsConditional.push(new Array(theexpression,formName,fieldName,message));
}

function validateForm(formElement) {
    var error = 0;
    var firstTime = 0;
    var answer = false;

    for (var rf = 0; rf < ReqFields.length; rf++) {
	var fieldvalue = eval(ReqFields[rf][0] + '.' +  ReqFields[rf][1] + '.value');

	if (!fieldvalue) {
	    alert(ReqFields[rf][2]);
	    eval( ReqFields[rf][0] + "."  + ReqFields[rf][1] + '.focus()');
	    error=1;
	}
    }

    for (var rf2=0;rf2<ReqFieldsConditional.length;rf2++) {
	var expres = eval(ReqFieldsConditional[rf2][0]);
	if (expres) {
	    var fieldvalue2 = eval(ReqFieldsConditional[rf2][1] + '.' +  ReqFieldsConditional[rf2][2] + '.value');

	    if (!fieldvalue2) {
		alert(ReqFieldsConditional[rf2][3]);
		eval( ReqFieldsConditional[rf2][1] + "."  + ReqFieldsConditional[rf2][2] + '.focus()');
		error=1;
	    }
	}
    }

    if (error == 0) {
	if (executeReminder.length > 0) {
	    for (var ex = 0; ex < executeReminder.length; ex++) {
		var execu = executeReminder.shift();
		var execu2 = executeReminderDate.shift();
		var erd = window.eval(execu2);
		if (typeof erd == "undefined" ||
		    erd == "undefined" ||
		    erd == '' ||
		    erd == 'undef' ||
		    erd.indexOf("-") == -1) {
		    ;
		}
		else {
		    if (firstTime == 0) {
			answer = confirm("Would you like to set an email reminder?");
			firstTime = 1;
		    }
		    if (answer) {
			window.eval(execu);
			js_pause(25);
		    }
		}
	    }
	}
	formElement.submit();
    }
    if (error == 1) { return false; } else { return true; }
}

// To include a page, invoke ajaxinclude("afile.htm") in the BODY of page
// Included file MUST be from the same domain as the page displaying it.

var rootdomain = "http://" + window.location.hostname;

function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously 
page_request.send(null)
//alert( writecontent(page_request));
return writecontent(page_request);
}

function writecontent(page_request){
  if (window.location.href.indexOf("http")==-1 || page_request.status==200)
  return(page_request.responseText)
}

function genPDF() {
    var IE4;
    var IE5;
    var IE6;
    var IE7;

    IE4 = (navigator.appVersion.indexOf('MSIE 4.') == -1) ? false : true;
    IE5 = (navigator.appVersion.indexOf('MSIE 5.') == -1) ? false : true;
    IE6 = (navigator.appVersion.indexOf('MSIE 6.') == -1) ? false : true;
    IE7 = (navigator.appVersion.indexOf('MSIE 7.') == -1) ? false : true;

    document.pdfgen.content.value = document.getElementById('pdf').innerHTML;
    document.pdfgen.submit();

    return;
}

function printPDFWidget(filename, savetoserver, thetitle) {
    var towhere;

    if (savetoserver) {
        savetoserver = 1;
        towhere = 'a PDF Copy';
    }
    else {
       savetoserver = 0;
       towhere = " PDF to My Computer";
    }

    document.write('<form name="pdfgen" id="pdfgen" action="/processes/genpdfweb.pl" method="POST"><input type="hidden" name="thetitle" value="' + thetitle + '"> <input type="hidden" name="content" value=""><input type="hidden" name="filename" value="' + filename + '"> <input type="hidden" name="savetoserver" value="' + savetoserver + '"><table><tr><td align="center"><input type="image" src="/images/pdfdoc.gif" border=0 onclick="genPDF();"></td></tr><tr><td align="center">Save '+ towhere +'</td></tr></table></form>');

    return;
}

var offsetfromedge=5     //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array()   //array to cache corresponding clearinterval pointers

function dockit(el, duration){
this.source=document.all? document.all[el] : document.getElementById(el);
this.source.height=this.source.offsetHeight;
this.docheight=truebody().clientHeight;
this.duration=duration;
this.pagetop=0;
this.elementoffset=this.getOffsetY();
dockarray[dockarray.length]=this;
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;
eval(dynexpress);
}

dockit.prototype.getOffsetY=function(){
var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
totaloffset+=parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function dockornot(obj){
obj.pagetop=truebody().scrollTop;
if (obj.pagetop>obj.elementoffset) //detect upper offset
obj.source.style.top=obj.pagetop-obj.elementoffset+offsetfromedge+"px";
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset
obj.source.style.top=obj.pagetop+obj.docheight-obj.source.height-obj.elementoffset-offsetfromedge+"px";
else
obj.source.style.top=0;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

