
/**************************************************************************************************
 * G L O B A L   C O N S T A N T
 **************************************************************************************************/

var imagePath='http://www.researchroles.northwestern.edu/assets/images/';


/**************************************************************************************************
 * F I L T E R   O P T I O N S
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The hideFilter method is similar to the hideContent procedure above. The difference is
 *  that this method needs to hide two sections not just one. The filter content section contains
 *  the filter option controls and the filter selection section which contains the filter buttons
 *  that are used to initiate the data retrieval.
 *
 *Parameter: An array of string values containing the clientID values of the controls that are
 *  used to show/hide the filter content section
 *
 *Date: 03/26/07
 **************************************************************************************************/
function hideFilter(filterTable) {

	try {
		var filterRows=findObject(filterTable).getElementsByTagName('tr');
		var titleCells=filterRows[0].getElementsByTagName('td');
		var filterImage=titleCells[0].getElementsByTagName('img');
		var filterLink=titleCells[0].getElementsByTagName('a');
		var filterCheck=filterLink[0].getElementsByTagName('input');
		
		var checked=(filterCheck[0].checked);

		if (checked==true) {
			filterImage[0].src=imagePath + 'down.gif'
			filterCheck[0].checked=false;
			filterRows[1].style.display='none'
			filterRows[2].style.display='none'
			
		} else {
			filterImage[0].src=imagePath + 'up.gif'
			filterCheck[0].checked=true;
			filterRows[1].style.display=''
			filterRows[2].style.display=''
		}
			
		return false;
		
	} catch(error) {
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the filter option change via server-side code
		return true;
		
	}
}

/**************************************************************************************************
 *Purpose: The changeFilter method is called when the user clicks one of the filter radio button
 *  controls to change the filter option. Upon firing of the event we make the appropriate filter
 *  section visible. In addition we make sure that the fiter content is expanded by calling the
 *  hideFilter function above;
 *
 *Parameters: 
 *	- contentControls: An array of clientID values that identify the container for the various
 *    filter options
 *	- displayControls: An array of string values containing the clientID values of the controls that 
 *    are used to show/hide the filter content section
 *  - selectedFilter: A numeric value indicatint which filter option is selected
 *
 *Date: 03/17/07
 **************************************************************************************************/
function changeFilter(filterTable, filterOption) {

	try {
		var filterRows=findObject(filterTable).getElementsByTagName('tr');
		var titleCells=filterRows[0].getElementsByTagName('td');
		var filterCells=filterRows[1].getElementsByTagName('td');
		var buttonCells=filterRows[2].getElementsByTagName('td');

		titleCells[0].attributes['colSpan'].value=String(filterOption+1);
		buttonCells[0].attributes['colSpan'].value=String(filterOption+1);

		var shown='', hidden='none', viewOption;
		
		switch (filterOption) {
			case 0:	//filter by process only
				filterCells[0].style.display=hidden;
				filterCells[1].style.display=hidden;
				
				viewOption=shown;
				
				break;

			case 1: //filter by single role
				filterCells[0].style.display=shown;
				filterCells[1].style.display=hidden;

				viewOption=shown;

				break;
			
			case 2: //filter by multiple role
				filterCells[0].style.display=shown;
				filterCells[1].style.display=shown;

				viewOption=hidden;

				break;
			
		} // end switch	

		var buttonInput=buttonCells[0].getElementsByTagName('input');
		var buttonLabel=buttonCells[0].getElementsByTagName('label');
		var buttonSpan=buttonCells[0].getElementsByTagName('span');
		
		//set the display style of all radio buttons
		for (j=0;j<buttonInput.length;j++) {
			if (buttonInput[j].type=='radio') {
				buttonInput[j].style.display=viewOption;
			}
		}

		//set the display style of all related labels
		for (k=0;k<buttonLabel.length;k++) {
			if (!(!buttonLabel[k].attributes['for'])) {
				buttonLabel[k].style.display=viewOption;
			}
		}
	
		//set the display style of all related spans
		for (m=0;m<buttonSpan.length;m++) {
			if (buttonSpan[m].getElementsByTagName('input').length>0) {
				buttonSpan[m].style.display=viewOption;
			}
		}


		var filterLink=titleCells[0].getElementsByTagName('a');
		var filterCheck=filterLink[0].getElementsByTagName('input');

		// make sure the filter content is visible
		if (filterCheck[0].checked==false) hideFilter(filterTable);
		
		
	} catch(error) {
	alert(error)
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the filter option change via server-side code
		submitForm(document.forms[0].id, 'filterOptions', filterOption);
		
	}

}


/**************************************************************************************************
 * P R O C E S S   F I L T E R
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The hideProcess method is used to show or hide the subprocess check box control that
 *  are associated with the process whose anchor control was clicked. All subprocess check box
 *  controls are contained within a DIV control and we changed the display property of the style
 *  object to 'block' to show the subprocess items or to 'none' to hide the information.
 *
 *Parameters:
 *	- contentName: The name of the DIV control that contains the subprocess check box controls to
 *    shown or hidden
 *	- anchorName: The name of the anchor control which contains the image control that displays
 *    the plus or sign image and the check box control which determines whether the content is
 *    displayed or not
 *
 *Date: 03/29/07
 **************************************************************************************************/
function hideProcess(contentName, anchorName) {

	var contentControl=findObject(contentName);
	var anchorControl=findObject(anchorName);

	if ((!contentControl) || (!anchorControl)) {
		// well that's not good - we cannot find the objects we need to find so
		// we return true to fire the anchor click event in order to make sure
		// that the properties are changed via server-side code
		return true;
	}
	
	try {
		var imageControl=anchorControl.getElementsByTagName('img');
		var checkControl=anchorControl.getElementsByTagName('input');
		
		//toggle the checked property of the check box control
		checkControl[0].checked=!checkControl[0].checked;

		if (checkControl[0].checked==true) {
			imageControl[0].src=imagePath + 'minus.gif';
			contentControl.style.display='block';
		} else {
			imageControl[0].src=imagePath + 'plus.gif';
			contentControl.style.display='none';
		} 
		
		// at this point we know that everything went okay and we return false to
		// prevent the anchor click event from firing
		return false;
			
	} catch (error) {
		// oops... something went wrong so we return true to make sure the anchor
		// click event fires so that the properties can be changed on the server
		return true;
			
	} // end try...catch
	
}

/**************************************************************************************************
 *Purpose: The clickProcess method handles the onClick event of the process check box controls 
 *  to make sure all subprocess check boxes have the same value as the related process check 
 *  which fired the click event.
 *
 *Parameters:
 *	- containerName: The name of DIV control that contains all subprocess check box controls
 *	- checkName: The name of the process check box control which controls whether the related 
 *    subprocess check box controls are checked or not
 *
 *Date: 03/02/07
 **************************************************************************************************/
function clickProcess(containerName, checkName) {

	try {
		var subprocessDiv=findObject(containerName);
		var processCheck=findObject(checkName);
		
		var elements=subprocessDiv.getElementsByTagName('input');
		var checked=processCheck.checked;
		
		for(i=0; i<elements.length;i++) {
			elements[i].checked=checked;
		} // end for loop
			
	} catch(error) {
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the process clicked event via server-side code
		submitForm(document.forms[0].id, 'processClicked', checkName);
	
	}

}

/**************************************************************************************************
 *Purpose: The clickSubprocess method handles the onClick event of the various subprocess check
 *  box controls to automatically select or deselect the related parent process check box based
 *  on the status of the subprocess check boxes. 
 *
 *  The related parent process check box will be checked if at least one of the subporcess box is 
 *  checked or unchecked if no subprocess items are selected.
 *
 *Parameters:
 *	- containerName: The name of DIV control that contains all subprocess check box controls
 *	- checkName: The name of the process check box control that is adjusted based on the status
 *    of the related subprocess check box controls
 *
 *Date: 03/02/07
 **************************************************************************************************/
function clickSubprocess(containerName, checkName) {

	try {
		var subprocessDiv=findObject(containerName);
		var processCheck=findObject(checkName);
		
		var elements=subprocessDiv.getElementsByTagName('input');
		
		for(i=0; i<elements.length;i++) {
			if (elements[i].checked==true) {
				processCheck.checked=true;
				
				//there was at least one checked subprocess which means that we no
				//longer have to check any other controls
				return true;
				
			} // end if
			
		} // end for-loop
		
		//if we get to this point we know that none of the subprocess check boxes are 
		//selected and we uncheck the related process box
		processCheck.checked=false;
			
	
	} catch(error) {
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the process clicked event via server-side code
		submitForm(document.forms[0].id, 'subprocessClicked', checkName);
	
	}

}

/**************************************************************************************************
 *Purpose: The processCheck function handles the onClick event of the Check All and Uncheck All 
 *  anchor controls at the bottom of the Process Filter control. Upon firing of the event we loop 
 *  through the passedin process check box names, retrieve the related check box object, set the 
 *  checked value based on the passed in checked parameter, and then call the click method to fire 
 *  the onClick event. 
 *
 *  Note that we set the checked value to the opposite of the passed in parameter value because 
 *  calling the click() method toggles the value back.
 *
 *Parameters:
 *	- process: String containing the client ID values (id attributes) of the process check box
 *    control. The names are separated by the pipe (|) character
 *	- checked: Value indicating whether to check or clear the check box controls
 *
 *Date: 03/02/07
 **************************************************************************************************/
function selectProcess(processChecks, processDivs, checked) {

	try {
		// loop through all the process check boxes in the passed in array of check
		// box names and change the checked value as needed
		for (i=0; i<processChecks.length;i++) {
			findObject(processChecks[i]).checked=checked;
		}
		
		for (j=0; j<processDivs.length;j++) {
			// get all check box controls contained within the currently processed
			// subprocess Div control		
			var subprocesses=findObject(processDivs[j]).getElementsByTagName('input');
		   
			for (k=0;k<subprocesses.length;k++) {
				subprocesses[k].checked=checked;	
			}
		}
		
		return false;
	
	} catch(error) {
		// oops... something went wrong so we return true to make sure the anchor
		// click event fires so that the check box can be set on the server
		return true;
		
	}
	
}


/**************************************************************************************************
 * R O L E   F I L T E R
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The selectLevels function is a simple function that is used to select or deselect the 
 *   responsibility level boxes corresponding to the names in the passed in checkboxes array.
 *
 *Parameters:
 *	- parentContainer: Parent DIV control that contains all boxes to be checked or unchecked
 *    deselected
 *	- checked: Value indicating whether to check or clear the check box controls
 *
 *Date: 03/30/07
 **************************************************************************************************/
function selectLevels(parentContainer, checked) {

	try {
		var checkControls=findObject(parentContainer).getElementsByTagName('input');

		for (i=0;i<checkControls.length;i++) {
			checkControls[i].checked=checked;
		}
		
		// at this point we know that the controls were successfully checked or
		// unchecked and we need to cancel the click event so we return false
		return false;
	
	} catch(error) {
		// let the ServerClick event handler of the roleFilter control handle the
		// selection of the various level check boxes if an error occurs
		return true;
		
	}

}



/**************************************************************************************************
 * S I D E   M E N U   O P T I O N S
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The hideMenus method is used to expand or collapse the content section of the key and 
 *   menu user controls based on the value of the menuCheck input check box control that resides
 *   on the parent form of the two user controls.
 *
 *Parameters: 
 *  - menuCheck: The name of the input check box control that controls whether the key and menu
 *    user control content is visible or not
 *  - keyTable: The name of the table that holds the key control content
 *  - menuTable: The name of the table that holds the menu control content
 *
 *Date: 04/24/07
 **************************************************************************************************/
function hideMenus(menuCheck, keyTable, menuTable) {

	var menuRows=findObject(menuTable).getElementsByTagName('tr');
	var keyRows=findObject(keyTable).getElementsByTagName('tr');
	var displayCheck=findObject(menuCheck);

	if ((!menuRows) || (!keyRows) || (!displayCheck)) {return true}
		
	try {
		//find the display related controls for the menu control
		var menuHeaderCells=menuRows[0].getElementsByTagName('td');
		var menuFooterCells=menuRows[2].getElementsByTagName('td');
		var menuHeaderLink=menuHeaderCells[0].getElementsByTagName('a')[0];
		var menuFooterLink=menuFooterCells[0].getElementsByTagName('a')[0];
		var menuHeaderImage=menuHeaderLink.getElementsByTagName('img')[0];
		var menuFooterImage=menuFooterLink.getElementsByTagName('img')[0];
		var menuContent=menuHeaderCells[1];

		//find the display related controls for the key control
		var keyHeaderCells=keyRows[0].getElementsByTagName('td');
		var keyFooterCells=keyRows[2].getElementsByTagName('td');
		var keyHeaderLink=keyHeaderCells[0].getElementsByTagName('a')[0];
		var keyFooterLink=keyFooterCells[0].getElementsByTagName('a')[0];
		var keyHeaderImage=keyHeaderLink.getElementsByTagName('img')[0];
		var keyFooterImage=keyFooterLink.getElementsByTagName('img')[0];
		var keyContent=keyHeaderCells[1];

		if (displayCheck.checked==true) {
			menuHeaderImage.src=imagePath + 'right.gif'
			menuFooterImage.src=imagePath + 'right.gif'
			keyHeaderImage.src=imagePath + 'right.gif'
			keyFooterImage.src=imagePath + 'right.gif'
			
			menuContent.style.display='none'
			keyContent.style.display='none'
			
			displayCheck.checked=false;
			
		} else {
			menuHeaderImage.src=imagePath + 'left.gif'
			menuFooterImage.src=imagePath + 'left.gif'
			keyHeaderImage.src=imagePath + 'left.gif'
			keyFooterImage.src=imagePath + 'left.gif'
			
			menuContent.style.display=''
			keyContent.style.display=''
			
			displayCheck.checked=true;
		}
			
		return false;
		
	} catch(error) {
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the filter option change via server-side code
		return true;
		
	}
}


function hideMenu(menuTable) {
		
	try {
		var menuRows=findObject(menuTable).getElementsByTagName('tr');
		var headerCells=menuRows[0].getElementsByTagName('td');
		var footerCells=menuRows[2].getElementsByTagName('td');
		var contentCell=headerCells[1];

		var headerLink=headerCells[0].getElementsByTagName('a')[0];
		var footerLink=footerCells[0].getElementsByTagName('a')[0];

		var headerImage=headerLink.getElementsByTagName('img')[0];
		var footerImage=footerLink.getElementsByTagName('img')[0];
		var displayCheck=headerLink.getElementsByTagName('input')[0];

		if (displayCheck.checked==true) {
			headerImage.src=imagePath + 'right.gif'
			footerImage.src=imagePath + 'right.gif'
			displayCheck.checked=false;
			contentCell.style.display='none'
			
		} else {
			headerImage.src=imagePath + 'left.gif'
			footerImage.src=imagePath + 'left.gif'
			displayCheck.checked=true;
			contentCell.style.display=''
		}
			
		return false;
		
	} catch(error) {
		// an error has occurred so we initiate a postback by submitting the
		// form to handle the filter option change via server-side code
		return false;
		
	}
}


/**************************************************************************************************
 * P R O C E S S   F I L T E R
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The expandLevels method is used to show or hide the subprocess check box control that
 *  are associated with the process whose anchor control was clicked. All subprocess check box
 *  controls are contained within a DIV control and we changed the display property of the style
 *  object to 'block' to show the subprocess items or to 'none' to hide the information.
 *
 *Parameters:
 *	- contentName: The name of the DIV control that contains the subprocess check box controls to
 *    shown or hidden
 *	- anchorName: The name of the anchor control which contains the image control that displays
 *    the plus or sign image and the check box control which determines whether the content is
 *    displayed or not
 *
 *Date: 03/29/07
 **************************************************************************************************/
function expandLevels(contentName, expandAll) {
	
	var contentControl=findObject(contentName);
	
	if ((!contentControl)) {
		// well that's not good - we cannot find the objects we need to find so
		// we return true to fire the anchor click event in order to make sure
		// that the properties are changed via server-side code
		return true;
	}
	
	try {
		var imageSource=(expandAll==true)?imagePath + 'minus.gif':imagePath + 'plus.gif';
		var displayStyle=(expandAll==true)?'':'none';
		
		var contentDivs=contentControl.getElementsByTagName('div');
		
		for (i=0;i<contentDivs.length;i++) {
			if (contentDivs[i].className=='levelDiv') {
				contentDivs[i].style.display=displayStyle;
			}
		}

		var imageParent=contentControl.getElementsByTagName('h2');
		
		for (j=0;j<imageParent.length;j++) {
			var processAnchor=imageParent[j].getElementsByTagName('a')[0];
			var processImage=processAnchor.getElementsByTagName('img')[0];
			var processCheck=processAnchor.getElementsByTagName('input')[0];
			
			processImage.src=imageSource;
			processCheck.checked=expandAll;
		}
		
		
		// at this point we know that everything went okay and we return false to
		// prevent the anchor click event from firing
		return false;
			
	} catch (error) {
		// oops... something went wrong so we return true to make sure the anchor
		// click event fires so that the properties can be changed on the server
		return true;
			
	} // end try...catch

}


/**************************************************************************************************
 *Purpose: The expandTasks method handles the click event of the expand and collapse all anchor
 *  controls which can be used to show or hide all task rows when the roles and responsibility
 *  information is displayed in table format.
 *
 *Parameters:
 *	- tableName: The name of the table that contains the roles and responsibilities information
 *	- expandAll: Value indicating whether to expand or collapse all process task related rows
 *
 *Date: 05/01/07
 **************************************************************************************************/
function expandTasks(tableName, expandAll) {

	var imageSource=(expandAll==true)?imagePath + 'minus.gif':imagePath + 'plus.gif';
	var displayStyle=(expandAll==true)?'':'none';
	
	try {
		var processRows=findObject(tableName).getElementsByTagName('tr');
	
		// Loop through all the rows in the table identified by the passed in table name
		for (i=0;i<processRows.length;i++) {
		
			if (processRows[i].className=='subprocessRow') {
				// The subprocess rows contain the display link and all related controls which
				// handle the display of the related task rows
				var processAnchor=processRows[i].getElementsByTagName('a')[0];
				var processImage=processAnchor.getElementsByTagName('img')[0];
				var processCheck=processAnchor.getElementsByTagName('input')[0];
			
				processImage.src=imageSource;
				processCheck.checked=expandAll;
				
			} else {
				// All rows with a "pid" attribute are task rows and need to be hidden or 
				// shown depending on the passed in expandAll parameter
				if (!(!processRows[i].attributes['pid'])) {
					processRows[i].style.display=displayStyle;
					
					var detailRow=processRows[i+1];
					
					// we need to reset the display properties of the task detail row if the row
					// that follows the current row is a detail row
					if (!(!detailRow) && (detailRow.className=='detailRow')) {
					
						if (processCheck.checked==false) {
							// if the task rows should be hidden we can simply hide the related task
							// detail row 
							detailRow.style.display='none';
							
						} else {
							// here is where it gets a little more complicated - we have to restore the 
							// task detail row detail if the task rows are shown based on whether the
							// related task anchor was clicked
							var displayCell=processRows[i].getElementsByTagName('td')[1];
							var displayAnchor=displayCell.getElementsByTagName('a');

							if (displayAnchor.length==1) {
								var taskCheck=displayAnchor[0].getElementsByTagName('input');
								
								if (taskCheck.length==1) {
									(taskCheck[0].checked==true)?detailRow.style.display='':detailRow.style.display='none';
								}
							}				
						}
					
						// at this point we know that the next row is a task detail row and we do not
						// need to process the detail row anymore
						++i;
					}
					
				} else {
					// the last row we need to deal with is the empty row which is displayed if 
					// there are no tasks for the current subprocess section
					if (processRows[i].className=='emptyRow') {
						processRows[i].style.display=displayStyle;
					}
		
				} // end if (pid attribute check)
			
			} // end if (className==subprocessRow check)
			
		} // end loop
		
		return false;
			
	} catch(e) {
		return true;
		
	}
	
}

/**************************************************************************************************
 *Purpose: The hideTask method is used to show or hide the task rows associated with a subprocess.
 *  In addition to setting the display properties for the various task rows we also need to format 
 *  the related detail row if there is a detail row. 
 *
 *  We know which task rows are affected based on the passed in processID parameter value and the
 *  pid attribute attached to each task row.
 *
 *Parameters:
 *	- processID: The ID that identifies the current process. This value will be needed to 
 *    determine which rows are affected
 *	- anchorName: The name of the anchor control which contains the image control that displays
 *    the plus or sign image and the check box control which determines whether the content is
 *    displayed or not
 *
 *Date: 04/12/07
 **************************************************************************************************/
function hideTask(processID, tableName, anchorName) {

	var processTable=findObject(tableName);
	var processAnchor=findObject(anchorName);
	var plusImage=imagePath + 'plus.gif';
	var minusImage=imagePath + 'minus.gif'
	
	// something ain't right - we cannot find the reference to the parent task table
	// and/or the anchor control that fired the click event
	if ((!processTable) || (!processAnchor)) return true;
	
	try {
		var processImage=processAnchor.getElementsByTagName('img')[0];
		var processCheck=processAnchor.getElementsByTagName('input')[0];
		var processRows=processTable.getElementsByTagName('tr');
		
		// toggle the checked property of the check box control and the change the
		// corresponding src property of the related image control
		processCheck.checked=!processCheck.checked;
		(processCheck.checked==true)?processImage.src=minusImage:processImage.src=plusImage;
		
		for (j=0; j<processRows.length; j++) {
			// find the pid attribute which is used to associated task rows with the related
			// subprocess 
			var processAttribute=processRows[j].attributes['pid'];
				
			if (!(!processAttribute) && (processAttribute.value==processID)) {
				// changing the visibility of task rows is simple - we just change the display
				// property depending on the visible flag value
				(processCheck.checked==true)?processRows[j].style.display='':processRows[j].style.display='none';

				// we need to reset the display properties of the task detail row if the row
				// that follows the current row is a detail row
				var detailRow=processRows[j+1];
				
				if (!(!detailRow) && (detailRow.className=='detailRow')) {
				
					if (processCheck.checked==false) {
						// if the task rows should be hidden we can simply hide the related task
						// detail row 
						detailRow.style.display='none';
						
					} else {
						// here is where it gets a little more complicated - we have to restore the 
						// task detail row detail if the task rows are shown based on whether the
						// related task anchor was clicked
						var displayCell=processRows[j].getElementsByTagName('td')[1];
						var displayAnchor=displayCell.getElementsByTagName('a');

						if (displayAnchor.length==1) {
							var taskCheck=displayAnchor[0].getElementsByTagName('input');
							
							if (taskCheck.length==1) {
								(taskCheck[0].checked==true)?detailRow.style.display='':detailRow.style.display='none';
							}
						}				
					}
				
					// at this point we know that the next row is a task detail row and we do not
					// need to process the detail row anymore
					++j;
				}
				
			}	// end if 
			
		}	// end for loop
	
		return false;
		
	} catch (error) {
		return true;
	
	}
	
}


/**************************************************************************************************
 *Purpose: The hideEmpty method is used to show or hide the row that is displayed underneath the
 *  subprocess row if there are not tasks for a particular subprocess.
 *
 *Parameters:
 *	- rowName: The ID that identifies the row to be shown or hidden (the row that contains the 
 *    'No tasks' message)
 *	- anchorName: The name of the anchor control which contains the image control that displays
 *    the plus or sign image and the check box which determines whether the content is displayed 
 *
 *Date: 04/13/07
 **************************************************************************************************/
function hideEmpty(rowName, anchorName) {

	var processAnchor=findObject(anchorName);
	var processRow=findObject(rowName);

	// something ain't right - we cannot find the reference to the empty row and/or 
	// the anchor control that fired the click event
	if ((!processRow) || (!processAnchor)) return true;
	
	try {
		var processImage=processAnchor.getElementsByTagName('img')[0];
		var processCheck=processAnchor.getElementsByTagName('input')[0];
		
		// toggle the checked property of the check box control and the change the
		// corresponding src property of the related image control
		processCheck.checked=!processCheck.checked;
		
		if (processCheck.checked==true) {
			processImage.src=imagePath + 'minus.gif';
			processRow.style.display='';
		} else {
			processImage.src=imagePath + 'plus.gif';
			processRow.style.display='none';
		}
			
		return false;
		
	} catch (error) {
		return true;
	
	}
	
}


/**************************************************************************************************
 *Purpose: The hideDetail method is used to show or hide the detail row associated with a task row.
 *  The hideDetail method is called from the onClick event of the task anchor control next to the
 *  task row for which we are to expand or collapse the detail section. 
 *
 *Parameters:
 *	- rowName: The name of the table row that contains the task detail information which means 
 *    the name of the row to be shown or hidden
 *	- anchorName: The name of the anchor control which contains the image control that displays
 *    the plus or sign image and the check box which determines whether the content is displayed 
 *
 *Date: 04/13/07
 **************************************************************************************************/
function hideDetail(rowName, anchorName) {

	var detailAnchor=findObject(anchorName);
	var detailRow=findObject(rowName);
	
	// We cannot retrieve the reference to the anchor and/or the detail row controls
	// in which case we return true to fire the server click event 
	if ((!detailAnchor) || (!detailRow)) return true;
	
	try {
		var taskImage=detailAnchor.getElementsByTagName('img')[0];
		var taskCheck=detailAnchor.getElementsByTagName('input')[0];
		
		//toggle the checked property of the check box control
		taskCheck.checked=!taskCheck.checked;

		if (taskCheck.checked==true) {
			taskImage.src=imagePath + 'minus.gif';
			detailRow.style.display='';
		} else {
			taskImage.src=imagePath + 'plus.gif';
			detailRow.style.display='none';
		} 
		
		// at this point we know that everything went okay and we return false to
		// prevent the anchor click event from firing
		return false;		
	
	} catch(error) {
		return true;
		
	} // end try..catch
	
}


/**************************************************************************************************
 *Purpose: The passwordHandler method is used to intercept the enter key when clicked from the
 *  netID or the password text box. We need to do that to avoid firing the Apply Filter submit 
 *  and instead fire the click event of the login button.
 *
 *Parameter: The name of the button whose click event should be fired.
 *
 *Date: 04/25/07
 **************************************************************************************************/
function passwordHandler(buttonName) {

	var buttonControl=findObject(buttonName);
	
	if (!(!buttonControl)) {	
		if (event.keyCode==13) {
			event.returnValue=false;
			event.cancel=true;
			
			buttonControl.click();
		}
		
	}
}


/**************************************************************************************************
 * S U B M I T   F O R M
 **************************************************************************************************/

/**************************************************************************************************
 *Purpose: The submitForm function is used to manually force a postback of the passed in form.
 *  Before reloading the form we set the hidden __EVENTTARGET and __EVENTARGUMENT values which
 *  are part of the .NET page framework. The __EVENTTARGET and __EVENTARGUMENT values are used
 *  by the form that handles the postback to determine what actions to take, if any.
 *
 *Parameters:
 *	- formName: The name of the form to be reloaded
 *	- target: The value for the __EVENTTARGET field
 *	- argument: The value for the __EVENTARGUMENT field
 *
 *Date: 03/26/07
 **************************************************************************************************/
function submitForm(formName, target, argument) {

	var theForm=findObject(formName);

	if (!(!theForm)) {
		theForm.__EVENTTARGET.value=target;
		theForm.__EVENTARGUMENT.value=argument;
			
		// we submit the form to force a postback if we cannot retrieve the reference
		// to any one of the filter radio buttons. This allows us to change the filter 
		// option settings using server side code	
		theForm.submit();
	}

}
