/*****************************************************************************
**  
**  MODULE NAME:    netfyi.js
**  
**  DESCRIPTION:    
**      NetFYI JavaScript APIs
**  
**  REVISION HISTORY:
**      DATE        NAME    REASON
**      ----------------------------------------------------------------------
**      09-14-2000     DWD  Initial Creation.
**  
**  NOTES:
**      Copyright 2000, Identitech, Inc., All Rights Reserved.
*/

/*
** Constants
**
** Browser Manufacturer (and version, if applicable)
*/
var BR_MICROSOFT = 0x000000001;
var BR_NETSCAPE4 = 0x000000002;
var BR_NETSCAPE6 = 0x000000004;

/*
** Browser flavor (palm/pocketpc/etc)
*/
var PT_POCKETIE  = 0x000000001;

/*
** C Standard true/false;
*/
var FALSE        = 0;
var TRUE         = 1;


/*
***************************************************************************
** 
** FUNCTION: IXBrowser
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: (None)
** 
** RETURN VALUES: (function)
** 
** NOTES: 
*/
function IXBrowser()
{
    /*
    ** Call global function to update the global variable
    */
    CheckBrowserTypeVersion(window.navigator);

    /*
    ** Global Browser Type/Version Variables
    */
    this.m_iBrowserTypeVer   = GetBrowserType();
    
    /*
    ** If equal, then it's a palm top we understand.
    */
    this.m_bPalmTopBrowser   = g_iBrowserPalmTop == PT_POCKETIE; // || PT_PALMMOZZILA
}

/*
** IXBrowser Method Prototypes
*/
IXBrowser.prototype.GetBrowserType    = XBrowser_GetBrowserType;
IXBrowser.prototype.IsPalmTopBrowser  = XBrowser_IsPalmTopBrowser;
IXBrowser.prototype.GetHTMLImgElement = XBrowser_GetHTMLImgElement;
IXBrowser.prototype.SetElementStyle   = XBrowser_SetElementStyle;


/*
***************************************************************************
** 
** FUNCTION: XBrowser_GetBrowserType
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: (None)
** 
** RETURN VALUES: (function)
** 
** NOTES: 
*/
function XBrowser_GetBrowserType()
{
    return this.m_iBrowserTypeVer;
}

/*
***************************************************************************
** 
** FUNCTION: XBrowser_IsPalmTopBrowser
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: 
** 
** RETURN VALUES: (true or false )
** 
** NOTES: 
*/
function XBrowser_IsPalmTopBrowser()
{
	return this.m_bPalmTopBrowser;
}


/*
***************************************************************************
** 
** FUNCTION: XBrowser_GetHTMLImgElement
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: 
**  (String)    strImgId
** 
** RETURN VALUES: (HTMLImgElement)
** 
** NOTES: 
*/
function XBrowser_GetHTMLImgElement(strImgId)
{
    /*
    ** Local Variables
    */
    var img    = null;
    var brType = this.GetBrowserType();

    /*
    ** Do browser specific fetch of the image
    */
    switch(brType)
    {
        case(BR_MICROSOFT):
        {
		    /*
		    ** The Microsoft way
            */
		    img = document.images[strImgId];
        }
        break;

        default:
        {
            /*
            ** The W3C DOM1 way
            */
		    img = document.images.namedItem(strImgId);
        }
        break;
    }

    /*
    ** Return
    */
    return img;
}


/*
***************************************************************************
** 
** FUNCTION: XBrowser_SetElementStyle
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: 
**  (HTMLElement)    element
**  (String)    strProperty
**  (String)    strValue
** 
** RETURN VALUES: (function)
** 
** NOTES: 
*/
function XBrowser_SetElementStyle(element, strProperty, strValue)
{
    /*
    ** Local Variables
    */
    var brType             = this.GetBrowserType();
    var bUseMsSetAttribute = false;

    /*
    ** Do browser specific fetch of the image
    */
    switch(brType)
    {
        case(BR_MICROSOFT):
        {
            /*
            ** Fixup the property name for microsoft
            */
            strProperty = strProperty.replace("-", "");
            if(bUseMsSetAttribute)
            {
		        /*
		        ** The Microsoft way, almost the same as W3C...
                */
                element.style.setAttribute(strProperty, strValue, 0);
            }
            else
            {
                /*
                ** Local Variables
                */
                var  strCode = "element.style.";

                /*
                ** Build the code and evaluate it
                */
                strCode += strProperty;
                strCode += " = \"" + strValue + "\";";
                eval(strCode);
            }
        }
        break;

        default:
        {
            /*
            ** The W3C DOM1 way
            */
            btn.style.setProperty(strProperty, strValue, "important");
        }
        break;
    }
}

/*
** Global Browser Type/Version Variables
*/
var g_iBrowserTypeVer = 0;
var g_iBrowserPalmTop = 0;

/*
***************************************************************************
** 
** FUNCTION: GetBrowserType
** 
** DESCRIPTION: 
** 
** 
** PARAMETERS: (None)
** 
** RETURN VALUES: (function)
** 
** NOTES: 
*/
function GetBrowserType()
{
	return g_iBrowserTypeVer;
}

/*
***************************************************************************
** 
** FUNCTION: CheckBrowserTypeVersion
** 
** DESCRIPTION: 
**    Sets global Browser Type/Version variables
** 
** PARAMETERS: 
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function CheckBrowserTypeVersion(oNav)
{
	/*
	** Check the Browser Type / Version
	*/
	if(oNav.appName == "Netscape")
	{
        if(-1 != oNav.appVersion.indexOf("4."))
        {
            /*
            ** Netscape 4.xx uses this way of setting form fields
            */
			g_iBrowserTypeVer = BR_NETSCAPE4;
        }
		else
        {
            /*
            ** While, Netscape 6 (pre-release) uses this way of setting form fields
            */
			g_iBrowserTypeVer = BR_NETSCAPE6;
        }
	}
	else if(oNav.appName == "Microsoft Internet Explorer")
	{
        /*
        ** Microsoft seems to be pretty consistent
        */
		g_iBrowserTypeVer = BR_MICROSOFT;
	}
	else if(oNav.appName == "Microsoft Pocket Internet Explorer")
	{
        /*
        ** Microsoft seems to be pretty consistent
        */
		g_iBrowserTypeVer = BR_MICROSOFT;
		g_iBrowserPalmTop = PT_POCKETIE;
	}	
	else
	{
		/*
		** Unknown Browser...
		*/
		confirm("Browser Type Unsupported: " + oNav.appName);
	}
}

/*
***************************************************************************
** 
** FUNCTION: SetFormValue
** 
** DESCRIPTION:
** 
** 
** PARAMETERS: 
**     iForm          - Form #
**     sName          - Name of Element
**     sNewAction     - Value to set Element Value to
** 
** 
** NOTES:
** 
*/
function SetFormValue(iForm, sName, sNewAction)
{
    /*
    ** Local Vars
    */
    Frm = getCurrentPanelClipBoardForm(iForm);
    //var Frm             = document.forms[iForm];
    var Browser         = new IXBrowser();
    var iBrowserType    = Browser.GetBrowserType();
    var bOk             = TRUE;    
    if(!Frm)
    {
		Frm             = document.forms[iForm];
	}
	/*var docLocation = String(unescape(document.location));
	var index = docLocation.indexOf("DOCUMENTVIEW=");
	alert(index);
	rightString = docLocation.substring(index+String("DOCUMENTVIEW=").length,docLocation.length);
	alert(rightString);
	index = rightString.indexOf("&");
	leftString = rightString.substring(0,index);
	alert(leftString);
	*/
    switch(iBrowserType)
    {
        case BR_NETSCAPE4:
        {
            /*
            ** Local Variables
            */
            var     bDone   = 0;
            var     i       = 0;

            while(!bDone)
            {
                if(Frm.elements[i].name == sName)
                {
                    bDone = 1;
                    Frm.elements[i].value = sNewAction;
                }
                else
                {
                    bDone = (i++ == Frm.elements.length);
                }
            }
        }
        break;

        case BR_NETSCAPE6:
            /*
            ** While, Netscape 6.2 uses this way of setting form fields
            */
            Frm.elements[sName].value = sNewAction;
        break;

        case BR_MICROSOFT:
            /*
            ** Microsoft seems to be pretty consistent
            */
            Frm.elements(sName).value = sNewAction;
        break;
        
        default:
            bOk = FALSE;
        break;
    } 

    return bOk;
}


/*
***************************************************************************
** 
** FUNCTION: UpdateMethod
** 
** DESCRIPTION: 
**		Updates the NetFYI METHOD parameter in form[0] of the current 
**    HTML page to the specified method.
** 
** PARAMETERS: 
**  (String)    sNewMethod
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function UpdateMethod(sNewMethod)
{
    SetFormValue(0, "METHOD", sNewMethod);
}

/*
***************************************************************************
** 
** FUNCTION: UpdatePage
** 
** DESCRIPTION: 
**		Updates the NetFYI Page parameter in form[0] of the current 
**    HTML page to the specified method.
** 
** PARAMETERS: 
**  (String)    sNewPage
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function UpdatePage(sNewPage)
{
    SetFormValue(0, "Page", sNewPage);
}

/*
***************************************************************************
** 
** FUNCTION: OpenPublicFormList
** 
** DESCRIPTION: 
** 
** PARAMETERS: 
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function OpenPublicFormList(url) 
{
	//SetCookie(USERID,	objForm.elements[USERID].value);
    /*
    **
    ** [Fixes PQS-51312] (Cannot resize and access forms that are past the available view.)
    */
    window.open(url, "PublicFormList", "screenX=90,screenY=150,width=600,height=350,resizable=yes,scrollbars=yes,menubar=no,location=no,status=no");
}

/*
***************************************************************************
** 
** FUNCTION: OpenPreconfiguredFormList
** 
** DESCRIPTION: 
** 
** PARAMETERS: 
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function OpenPreconfiguredFormList(url) 
{
    /*
    **
    ** [Fixes PQS-51312] (Cannot resize and access forms that are past the available view.)
    */
    window.open(url, "UserFormList", "screenX=90,screenY=150,width=600,height=350,resizable=yes,scrollbars=yes,menubar=no,location=no,status=no");
}

/*
***************************************************************************
** 
** FUNCTION: OpenPublicFormStatusInput
** 
** DESCRIPTION: 
** 
** PARAMETERS: 
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function OpenPublicFormStatusInput(url) 
{    
    window.open(url, "PublicFormStatus", "screenX=90,screenY=150,width=600,height=350,resizable=yes,scrollbars=yes,menubar=no,location=no,status=no");
}

/*
***************************************************************************
** 
** FUNCTION: PreformAction
** 
** DESCRIPTION: 
** 
** PARAMETERS: iForm       - The Form Number to work with
**             sNewAction  - The Action to Preform
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
function PreformAction(iForm, sNewAction)
{
    /*
    ** Local Vars
    */  
    /*
    ** if in frames mode, the tab implementation will have separate form 
    ** for each tab.
    */
    var Frm = getCurrentPanelClipBoardForm(iForm); 
    //var Frm             = document.forms[iForm];
    var Browser         = new IXBrowser();
    var iBrowserType    = Browser.GetBrowserType();    
    /*
    ** if we didn't get the form, then get our regural form
    */
    if(!Frm)
    {
		var Frm             = document.forms[iForm];		
	}
	/*if(!Frm)
	{
		alert('operation not allowed!');	
		return;
	}*/
	if(Frm)
	{
		/*
		** if ViewClipboard docs was selected from doc list
		*/
		if(sNewAction != "VIEWDOCS")
		{
			Frm.target = "_top";
		}
		else
		{
			Frm.target = "_self";
		}	
	}
	/*
	** PQS-52824 if its delete operation,get the confirmation from the user
	*/
	if(sNewAction == "DELETE")
	{
		/*
		** display the confirmation dialog.
		*/
		if(confirm(STR_CONFIRM_DELETE_SELECTED_ITEMS))
		{
			if(SetFormValue(iForm, "ACTION", sNewAction))
			{
				/*
				** Now Submit the form
				*/
				Frm.submit();
			}
		}		
	}
	else if( sNewAction == "MOVE" )
	{
		/*
		** display the confirmation dialog.
		*/
		
		SetFormValue(iForm, "ACTION", sNewAction)
		ShowMoveConfirmation(iForm);
	}
	else
	{
		if(SetFormValue(iForm, "ACTION", sNewAction))
		{
			
			/*
			** Now Submit the form
			*/
			Frm.submit();
		}
	}
}

function ShowMoveConfirmation(iForm)
{
	var iWidth	= 420;
	var iHeight	= 200;
	var iLeft	= ( ( screen.availWidth - iWidth ) / 2 );
	var iTop	= ( ( screen.availHeight - iHeight ) / 2 );

	var strConfig	= "width=" + iWidth + "," +
			  "height=" + iHeight + "," +
			  "left=" + iLeft + "," +
			  "top=" + iTop + "," + 
			  "scrollbars=no,toolbars=no,addressbar=no";

	var objWin = window.open( "", "MoveConfirmWindow", strConfig );
	
	objWin.document.write(	"<html>" );
	objWin.document.write(		"<head>" );
	objWin.document.write(			"<title>" + STR_CONFIRM_MOVE_SELECTED_ITEMS_TITLE + "</title>" );
	objWin.document.write(			"<link rel='stylesheet' href='/NetFYI/netfyi.css' type='text/css' />" );
	objWin.document.write(		"</head>" );
	objWin.document.write(		"<body>" );
	objWin.document.write(		"<form name='frmConfirm'>" );
	objWin.document.write(		"<br />" );
	objWin.document.write(		"<table border='0' cellpadding='5' cellspacing='0'>" );
	objWin.document.write(			"<tr>" );
	objWin.document.write(				"<td colspan='2' class='NFyiTdContentBody'>" + STR_CONFIRM_MOVE_SELECTED_ITEMS + "<br /></td>" );
	objWin.document.write(			"</tr>" );
	objWin.document.write(			"<tr>" );
	objWin.document.write(				"<td width='50%' align='center'><input type='button' value='" + STR_CONFIRM_MOVE_SELECTED_ITEMS_OK + "' onClick='window.opener.document.forms[\"" + iForm + "\"].submit();window.close();' accesskey='o' title='Alt+O' /></td>" );
	objWin.document.write(				"<td width='50%' align='center'><input type='button' value='" + STR_CONFIRM_MOVE_SELECTED_ITEMS_CANCEL + "' onClick='window.close();' accesskey='c' title='Alt+C' name='cmdCancel' /></td>" );
	objWin.document.write(			"</tr>" );
	objWin.document.write(		"</table>" );
	objWin.document.write(		"<script>" );
	objWin.document.write(		"document.forms[0].cmdCancel.focus();" );
	objWin.document.write(		"</script>" );
	objWin.document.write(		"</form>" );
	objWin.document.write(		"</body>" );
	objWin.document.write(	"</html>" );
}

/*
***************************************************************************
** 
** FUNCTION: SelectCheckBoxes
** 
** DESCRIPTION: 
**	Selects all checkboxes in a given form.
** 
** PARAMETERS: strFormID	- The id of the form to use
**             bChecked		- true to check, false to un-check
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/
	
function SelectCheckBoxes( strFormID, bChecked,bNoFix )
{
	var clickItText;
	var tuples;
	var className="";	


	if(window.parent.frames.DocList1)
	{		
		frameDoc = window.parent.frames.DocList.document;
		divElements = frameDoc.getElementsByTagName("div");		
		for(iDiv = 0;iDiv < divElements.length; iDiv++)
		{			
			divElement = divElements(iDiv);
			//alert(divElement.id);
			if(divElement.id == "ScrollableDiv1")
			{		
				ScrlDivElements = divElement.getElementsByTagName("div");		
				for(iScrlDiv = 0;iScrlDiv < ScrlDivElements.length; iScrlDiv++)
				{		
					ScrlDivElement = ScrlDivElements(iScrlDiv);
					//alert(ScrlDivElement.id.substr( 0, 5 ));
					if(ScrlDivElement.id.substr( 0, 5 )== "panel")
					{
						//childNode = divElement.children(iScrlDiv);
						//alert(childNode.tagName);
						//if(divElement.id.substr( ix, 2 )
						formsElements = ScrlDivElement.getElementsByTagName("form");
						for(iForms=0;iForms < formsElements.length; iForms++)
						{
							clipForm = formsElements(iForms);
							if( clipForm.id == strFormID )
							{			
								for( var ix = 0,iy = 0 ; ix < clipForm.elements.length ; ix++ )
								{			
									if( "checkbox" == clipForm.elements[ix].type.toLowerCase()  )
									{				
										clipForm.elements[ix].checked = bChecked;				
										/*
										** get the onclick function text and parse the className parameter from it.
										*/
										clickItText = String(clipForm.elements[ix].getAttribute("onclick",0));
										if(clickItText != null)
										{
											tuples = clickItText.split("'");
											className = tuples[1];
											/*
											** call the click it function to select or unselect the item.
											*/											
											clickIt(clipForm.elements[ix],className,bNoFix);
										}				
									}
								}
							}
						}	
					}
				}	
			}
		}	
	}
	if( document.forms[strFormID] )
	{			
		for( var ix = 0,iy = 0 ; ix < document.forms[strFormID].elements.length ; ix++ )
		{			
			if( "checkbox" == document.forms[strFormID].elements[ix].type.toLowerCase()  )
			{				
				document.forms[strFormID].elements[ix].checked = bChecked;				
				/*
				** get the onclick function text and parse the className parameter from it.
				*/
				clickItText = String(document.forms[strFormID].elements[ix].getAttribute("onclick",0));
				if(clickItText != null)
				{
					tuples = clickItText.split("'");
					className = tuples[1];
					/*
					** call the click it function to select or unselect the item.
					*/
					clickIt(document.forms[strFormID].elements[ix],className,bNoFix);
				}				
			}
		}
	}
}
/*
** gets the current selected tab's clipboard form
*/
function getCurrentPanelClipBoardForm(strFormID)
{	
	clipForm = null;
	bDone = false;
	/*
	** check to see if we are in frames mode.
	*/
	if(window.parent.frames.DocList && window.name ==  window.parent.frames.DocList.name)
	{
		/*
		** all the tabs documents are embedded in panel1(panel+N) div
		*/
		panelId = 	'panel' + currentPanel;		
		frameDoc = window.parent.frames.DocList.document;
		/*
		** get all the divs
		*/
		divElements = frameDoc.getElementsByTagName("div");		
		for(iDiv = 0;iDiv < divElements.length; iDiv++)
		{			
			divElement = divElements(iDiv);	
			if(divElement.id == "ScrollableDiv")
			{		
				/*
				** panel divs are inside the scrollable divs
				*/
				ScrlDivElements = divElement.getElementsByTagName("div");		
				for(iScrlDiv = 0;iScrlDiv < ScrlDivElements.length && !bDone; iScrlDiv++)
				{		
					ScrlDivElement = ScrlDivElements(iScrlDiv);	
					/*
					** if the name match then get the form element from it.
					*/									
					if(ScrlDivElement.id == panelId)
					{						
						formsElements = ScrlDivElement.getElementsByTagName("form");						
						for(iForms=0;iForms < formsElements.length && !bDone; iForms++)
						{
							//clipForm = formsElements(iForms);
							if( formsElements(iForms).id == strFormID )
						{
								clipForm = formsElements(iForms);
								bDone=true;
							}
						}
					}
				}
			}			
		}
	}	
	return clipForm;
}

function addSelectedItemsToClipForm(strFormID)
{
	currentPanelClipBoardForm = getCurrentPanelClipBoardForm(strFormID);	
	if(currentPanelClipBoardForm)
	{			
		frameDoc = window.parent.frames.DocList.document;
		divElements = frameDoc.getElementsByTagName("div");		
		for(iDiv = 0;iDiv < divElements.length; iDiv++)
		{			
			divElement = divElements(iDiv);			
			if(divElement.id == "ScrollableDiv")
			{		
				ScrlDivElements = divElement.getElementsByTagName("div");		
				for(iScrlDiv = 0;iScrlDiv < ScrlDivElements.length; iScrlDiv++)
				{		
					ScrlDivElement = ScrlDivElements(iScrlDiv);
					//alert(ScrlDivElement.id.substr( 0, 5 ));
					
					if(ScrlDivElement.id.substr( 0, 5 )== "panel")
					{						
						formsElements = ScrlDivElement.getElementsByTagName("form");
						for(iForms=0;iForms < formsElements.length; iForms++)
						{
							clipForm = formsElements(iForms);
							if( clipForm.id == strFormID )
							{			
								for( var ix = 0,iy = 0 ; ix < clipForm.elements.length ; ix++ )
								{			
									if( "checkbox" == clipForm.elements[ix].type.toLowerCase()  )
									{				
										if(clipForm.elements[ix].checked)
										{
											hiddenInputField = createHiddenFormField(clipForm.elements[ix].id);
											/*
											** set the value to "on" so that it will be selected to clipboard.
											*/
											hiddenInputField.value = "on";
											currentPanelClipBoardForm.appendChild(hiddenInputField);
										}
									}
								}
							}
						}	
					}
				}	
			}
		}	
	}
}

function createHiddenFormField(sFieldID)
{
	var DOMATTR_HIDDEN   = "text";
	
	/*
	** Create a new field
	*/	
	vNewField = document.createElement("input");		
	
	/*
	** set Type to Hidden.
	*/
	vNewField.type  = DOMATTR_HIDDEN;

	/*
	** set the id and name.
	*/		
	vNewField.id   = sFieldID;
	vNewField.name = sFieldID;		
	return vNewField;
}

/*
** selects/unselects the clipboard checkboxes in frames mode.
*/
function SelectCheckBoxesInDocFrame( strFormID, bChecked )
{	
	//clipForm = getCurrentPanelClipBoardForm(strFormID);
	var clickItText;
	var tuples;
	var className="";	
	/*
	** check if we are in frames mode.	
	*/
	if(window.parent.frames.DocList)
	{		
		/*
		** get the document
		*/
		frameDoc = window.parent.frames.DocList.document;
		divElements = frameDoc.getElementsByTagName("div");		
		for(iDiv = 0;iDiv < divElements.length; iDiv++)
		{			
			divElement = divElements(iDiv);
			//alert(divElement.id);
			if(divElement.id == "ScrollableDiv")
			{		
				ScrlDivElements = divElement.getElementsByTagName("div");		
				for(iScrlDiv = 0;iScrlDiv < ScrlDivElements.length; iScrlDiv++)
				{		
					ScrlDivElement = ScrlDivElements(iScrlDiv);
					//alert(ScrlDivElement.id.substr( 0, 5 ));
					
					if(ScrlDivElement.id.substr( 0, 5 )== "panel")
					{
						//childNode = divElement.children(iScrlDiv);
						//alert(childNode.tagName);
						//if(divElement.id.substr( ix, 2 )
						formsElements = ScrlDivElement.getElementsByTagName("form");
						for(iForms=0;iForms < formsElements.length; iForms++)
						{
							clipForm = formsElements(iForms);
							if( clipForm.id == strFormID )
							{			
								for( var ix = 0,iy = 0 ; ix < clipForm.elements.length ; ix++ )
								{			
									if( "checkbox" == clipForm.elements[ix].type.toLowerCase()  )
									{				
										clipForm.elements[ix].checked = bChecked;				
										/*
										** get the onclick function text and parse the className parameter from it.
										*/
										clickItText = String(clipForm.elements[ix].getAttribute("onclick",0));
										if(clickItText != null)
										{
											tuples = clickItText.split("'");
											className = tuples[1];
											/*
											** call the click it function to select or unselect the item.
											*/
											clickIt(clipForm.elements[ix],className);
										}				
									}
								}
							}
						}	
					}
				}	
			}
		}	
	}		
}

/*
***************************************************************************
** 
** FUNCTION: ShowNewWindow
** 
** DESCRIPTION: 
**	Opens a new window via javascript.
** 
** PARAMETERS: strURL	- The URL to be displayed in the new window
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/

function ShowNewWindow( strURL )
{
	window.open( strURL );
}

/*
***************************************************************************
** 
** FUNCTION: getRealPos
** 
** DESCRIPTION: 
**	Returns the absolute position of an element by adding the it's
**	relative offset to that of all of it's parents.
** 
** PARAMETERS:	objElement	- The HTML element in question
**		strOffset	- The required offset, either Left or Top
** 
** RETURN VALUES: (void)
** 
** NOTES: 
*/

function getRealPos(objElement,strOffset,objFrame)
{
	iPos = 0
	
	if( objFrame != null )
	{
		iPos += getRealPos(objFrame,strOffset,null);
	}
	
	while( objElement != null )
	{
	 	iPos += objElement[ "offset" + strOffset ];
		objElement = objElement.offsetParent;
	}
	
	return iPos;
}

/*
***************************************************************************
** 
** FUNCTION: FixComboBoxes
** 
** DESCRIPTION: 
**	Hides all combo boxes on a page that collide with the 2 drop-down
**	navigational menus.
** 
** PARAMETERS:	nHidden	- The the combo boxes be hidden or shown
** 
** RETURN VALUES: (void)
** 
** NOTES: 
**	This depends on the combo boxes being nested inside of a div to
**	get the correct positions.  Only works in NS 6+ and IE
*/

function FixComboBoxes( bHidden )
{
	var arrMenus = [ document.getElementById( "HM_Menu1" ), document.getElementById( "HM_Menu2" ) ];
	var arrFrames = new Array();
	
	/*
	** Add the base window to the frames array
	*/
	
	arrFrames[arrFrames.length] = window;
	
	/*
	** Add all of the IFrames to the frames array
	*/

	for( ix = 0 ; ix < window.frames.length ; ix++ )
	{
		arrFrames[window.frames.length] = window.frames[ix];
	}

	for( iFrameIndex = 0 ; iFrameIndex < arrFrames.length ; iFrameIndex++ )
	{
		var arrCombos = arrFrames[iFrameIndex].document.getElementsByTagName( "select" );

		/*
		** Loop through each combo box
		*/

		for( ix = 0; ix < arrCombos.length; ix++ )
		{
			var objDiv = arrCombos[ix].parentNode;

			/*
			** Loop through each menu
			*/

			for( iy = 0 ; iy < arrMenus.length ; iy++ )
			{
				/*
				** Only hide if the menu is visible
				*/

				if( arrMenus[iy].style.visibility == "visible" )
				{
					/*
					** Get the menu positions
					*/

					var iMenuLeft	= arrMenus[iy].style.pixelLeft;
					var iMenuRight	= iMenuLeft + arrMenus[iy].offsetWidth;
					var iMenuTop	= arrMenus[iy].style.pixelTop;
					var iMenuBottom	= iMenuTop + arrMenus[iy].offsetHeight;

					/*
					** Get the combo box positions
					*/
					
					var iComboLeft		= getRealPos(objDiv,"Left",arrFrames[iFrameIndex].frameElement);
					var iComboRight		= iComboLeft + objDiv.offsetWidth;
					var iComboTop		= getRealPos(objDiv,"Top",arrFrames[iFrameIndex].frameElement);
					var iComboBottom	= iComboTop + objDiv.offsetHeight;

					/*
					** Test for collision
					*/

					var bHOverlap = ( ( ( iComboLeft >= iMenuLeft ) && ( iComboLeft <= iMenuRight ) ) || ( ( iComboRight >= iMenuLeft ) && ( iComboRight <= iMenuRight ) ) );
					var bVOverlap = ( ( ( iComboTop >= iMenuTop ) && ( iComboTop <= iMenuBottom ) ) || ( ( iComboBottom >= iMenuTop ) && ( iComboBottom <= iMenuBottom ) ) );

					/*
					** If collision is both horizontal and vertical then the combo box should be hidden.
					*/

					if( bHOverlap && bVOverlap )
					{ 
						objDiv.style.visibility = ( bHidden ? "hidden" : "visible" );
					}
				}
				else
				{
					if( ! bHidden )
					{
						objDiv.style.visibility = ( bHidden ? "hidden" : "visible" );
					}
				}
			}
		}
	}
}

function updateWorkListDisplay(comboBox,URL)
{

    /*
    ** Get the selected Index of the comboBox
    */
    var index = comboBox.options.selectedIndex

    /*
    ** get the Folder View value of the selected Index.
    */
    var strValue = comboBox.options[index].text

    /*
    ** encode the value, to replace the spaces.
    */
    strValue = escape(strValue) 

    /*
    ** Add the name to the url.
    */      
    URL = URL+strValue;     

    /*
    ** open the url in the same window.
		** since this is embeded in iframe of ViewWorklist, so 
		** use parent.parent.location.
		** 
    */			
    window.location.href = URL
}

function updateDocThumbDisplay(comboBox,URL)
{

    /*
    ** Get the selected Index of the comboBox
    */
    var index = comboBox.options.selectedIndex

    /*
    ** get the Folder View value of the selected Index.
    */
    var strValue = comboBox.options[index].text

    /*
    ** encode the value, to replace the spaces.
    */
    strValue = escape(strValue) 

    /*
    ** Add the name to the url.
    */      
    URL = URL+strValue;     
	
    /*
    ** open the url in the same window.
		** since this is embeded in iframe of ViewWorklist, so 
		** use parent.parent.location.
		** 
    */			
    window.location.href = URL
}


function FadeImg( strImgID, iOpacity, iOffset, iDirection, iDelayMS )
{
	if( iOpacity == 0 || iOpacity == 100 )
	{
		iDirection *= -1;
	}

	var strFunky	= "FadeImg('" + strImgID + "'," + ( iOpacity + ( iOffset * iDirection ) ) + "," + iOffset + "," + iDirection + "," + iDelayMS + ");";
	var objElement	= document.getElementById( strImgID );

	try
	{
		if( objElement.style.MozOpacity )
		{
			objElement.style.MozOpacity = parseFloat(iOpacity/100);
			setTimeout( strFunky, iDelayMS );
		}
		else if( objElement.filters )
		{
			objElement.filters.item('DXImageTransform.Microsoft.Alpha').opacity = iOpacity;
			setTimeout( strFunky, iDelayMS );
		}
	}
	catch(errorObject)
	{
	}
}

function ModifyElement( strElementID, strDisplay )
{
	var arrElements	= document.getElementsByName( strElementID );

	/*
	** Make sure we found at least one element
	*/

	if( arrElements != null )
	{
		if( arrElements.length > 0 )
		{
			/*
			** Loop through each element and show/hide it
			*/

			for( var ix = 0 ; ix < arrElements.length ; ix++ )
			{
				arrElements[ix].style.display = strDisplay;
			}
		}
	}
}

function DoSubmitWithProgress( strFormname )
{
	try
	{
		setTimeout( "FadeImg('ProgressImg1',80,20,-1,200);", 100 );
		setTimeout( "FadeImg('ProgressImg2',80,20,-1,200);", 200 );
		setTimeout( "FadeImg('ProgressImg3',80,20,-1,200);", 300 );
		setTimeout( "FadeImg('ProgressImg4',80,20,-1,200);", 400 );
		setTimeout( "FadeImg('ProgressImg5',80,20,-1,200);", 500 );

		ModifyElement( "divSearch", "none" );
		ModifyElement( "divProgress", "block" );
	}
	catch( objException )
	{
	}
	
	setTimeout( "document.forms['" + strFormname + "'].submit();", 200 );
}

function GetFormattedDate(strFormat,strDate)
{
    /*
    ** Local Variables
    */
	var		strOutput		= "";		// the formatted output string
	var		iVal			= 0;
	var		arrFormatTokens;			// array of format tokens
	var		objDate 		= new Date( strDate );

	/*
	** get the array of tokens
	*/
	arrFormatTokens = TokenizeFormat( strFormat );

	/*
	** loop through each token
	*/
	for( var ix = 0 ; ix < arrFormatTokens.length ; ix++ )
	{
		if( arrFormatTokens[ix] == "%C" )
		{
			// Century
			strOutput += objDate.getFullYear();
		}
		else if( arrFormatTokens[ix] == "%Y" )
		{
			// 2 Digit Year
			/*
			** getYear function is based on year 1900.. So if the return is greater than 99, we need to subtract 100s
			** until the year becomes a two digit number..If the year is in 1800s or before, the return wud be -ve, 
			** in which case we have to add 100 until the return becomes +ve.  This condition wud never occur for 
			** this function where we are getting the current date (unless of course if time starts running backword 
			** some day..). Anyways that condition is also handled here, just to be on the safer side, for the sake 
			** of cut pasters..
			*/
			iVal = objDate.getYear();

			while ( (iVal > 99 ) || (iVal < 0) )
			{
				if (iVal > 99)
				{
					iVal -= 100;
				}
				else
				{
					iVal += 100;
				}
			} // End of while loop

			/*
			** Now we need to check if the year is less than 10.. in which case we need to add a zero first.
			*/
			if (iVal < 10)
			{
				strOutput += "0";
			}

			/*
			** Now add the actual date
			*/
			strOutput += String(iVal);
		}
		else if( arrFormatTokens[ix] == "%M" )
		{
			// Month
			/*
			** The return of getMonth is a zero based index .. So add one
			*/			
			strOutput += ( ( objDate.getMonth()+1 ) < 10 ? "0" + String(objDate.getMonth()+1) : String(objDate.getMonth()+1) );
		}
		else if( arrFormatTokens[ix] == "%D" )
		{
			// Day
			strOutput += ( objDate.getDate() < 10 ? "0" + String(objDate.getDate()) : String(objDate.getDate()) );
		}
		else if( arrFormatTokens[ix] == "%J" )
		{
			// FYI Julian Date: No of days since 1901 Jan 1
			/*
			** Parse routine will return the no of milliseconds since 1970
			*/
			var dwOffset = Date.parse("Jan 01, 1900"); // This value is a negative value
			var dwToday = Date.parse(String(objDate));

			/*
			** Total millisecs since 1900 is the sum.. So subtract the first val from the second so tat 
			** these will get added up
			*/
			var dwFYIJulian = dwToday - dwOffset;

			/*
			** Convert this value into days
			*/
			var lFYIJulian = dwFYIJulian / (1000 * 60 * 60 * 24 )
   
			/*
			** Well i hope this is the Julian date corresponding to today
			*/
			strOutput += String(Math.floor(lFYIJulian));

		}
		else if( arrFormatTokens[ix] == "%j" )
		{
			// Actual astronomical Julian Date
			/*
			** The below added conversion routine is not mine.. 
			** Courtesy : http://wwwmacho.mcmaster.ca/JAVA/JD.html
			*/
			var iYear	= objDate.getFullYear();
			var iMonth	= objDate.getMonth() + 1;
			var iDate	= objDate.getDate();
			var iHour	= objDate.getHours();
			var iMin	= objDate.getMinutes();
			var iSec	= objDate.getSeconds();

			var iExtra	= 100.0 * iYear + iMonth - 190002.5;
			var iRJD	= 367.0 * iYear;
			
			iRJD -= Math.floor( 7.0 * ( iYear + Math.floor( (iMonth + 9.0) / 12.0)) / 4.0 );

			iRJD += Math.floor( 275.0 * iMonth/9.0 ) ;
		    iRJD += iDate;
		    iRJD += (iHour + (iMin + iSec/60.0) /60.0) /24.0
		    iRJD += 1721013.5;
		    iRJD -= 0.5 * iExtra/Math.abs(iExtra)
		    iRJD += 0.5;
   
			/*
			** Well i hope this is the Julian date corresponding to today
			*/
			strOutput += String(iRJD);

		}
		else
		{
			// Literal Character
			strOutput += arrFormatTokens[ix];
		}
	}

	/*
	** Return
	*/
	return strOutput;
}

/*****************************************************************************
**
**  FUNCTION NAME:	TokenizeFormat
**
**  DESCRIPTION:	Tokenizes a format string into an array of tokens
**
**  PARAMETERS:
**	String		strFormat	- the date/time format to be tokenized
**
**  RETURN VALUE (array):
**	- An array of strings where each element represents a token in the format
**	  string.  Tokens are either format characters (prefaced by a "%") or
**	  literals.
**
*/
function TokenizeFormat( strFormat )
{
    /*
    ** Local Variables
    */
	var arrTokens = new Array();	// empty array to be filled with tokens

	/*
	** loop through each character in the string
	*/
	for( var ix = 0 ; ix < strFormat.length ; ix++ )
	{
		/*
		** is it a format character or a literal
		*/
		if( strFormat.charAt(ix) != "%" )
		{
			/*
			** append literal token to the array
			*/
			arrTokens[arrTokens.length] = strFormat.charAt(ix);
		}
		else
		{
			/*
			** append format token to the array
			*/
			arrTokens[arrTokens.length] = strFormat.substr( ix, 2 );

			/*
			** increment counter because we used two characters for the token
			*/
			ix++;
		}
	}

	/*
	** Return the array of tokens
	*/
	return arrTokens;
}

/*
******************************************************************
**
** INTERFACE: ISortHtmlTableData 
**
** DESCRIPTION: Sort data in html tables
**
*/
function ISortHtmlTableData()
{
	this.m_strDefaultSort  = "NoSortByDefault";
	this.m_iSortNdx        = -1;
}

ISortHtmlTableData.prototype.SetSortColumn        = ISortHtmlTableData_SetSortColumn;
ISortHtmlTableData.prototype.SetFixedTblSortColumn= ISortHtmlTableData_SetFixedTblSortColumn;
ISortHtmlTableData.prototype.SortTable            = ISortHtmlTableData_SortTableData;
ISortHtmlTableData.prototype.SortFixedTable       = ISortHtmlTableData_SortFixedTableData;
ISortHtmlTableData.prototype.GetSortColumnNdx     = ISortHtmlTableData_GetSortColumnNdx;
ISortHtmlTableData.prototype.GetDefaultColumnName = ISortHtmlTableData_GetDefaultColumnName;
ISortHtmlTableData.prototype.ArraySortFunction    = ISortHtmlTableData_ArraySortFunction;

ISortHtmlTableData.prototype.LinkTableHdr2Sort    = ISortHtmlTableData_LinkTableHdr2Sort;
ISortHtmlTableData.prototype.LinkFixedTableHdr2Sort = ISortHtmlTableData_LinkFixedTableHdr2Sort;

ISortHtmlTableData.prototype.GetColumnIndex       = ISortHtmlTableData_GetColumnIndex;
ISortHtmlTableData.prototype.GetFixedTblColumnIndex = ISortHtmlTableData_GetFixedTblColumnIndex;

//ISortHtmlTableData.prototype.SetSecondSortColumn  = ISortHtmlTableData_SetSecondSortColumn;
//ISortHtmlTableData.prototype.GetSecondColumnName  = ISortHtmlTableData_GetSecondColumnName;
//ISortHtmlTableData.prototype.GetSecondSortColumnNdx     = ISortHtmlTableData_GetSecondSortColumnNdx;

/*
** Global version of the m_iSortNdx, needed in the ArraySortFunction, cause
** we don't have an instance context.
*/
var g_iSortHtmlTableData_ColumnNdx = -1;
var g_bSortHtmlTableData_Ascending = true;
var SORT_DESC                      = "desc";
var SORT_ASC                       = "asc";
var SORT_ATTR                      = "SortDir";
var g_NativeSortOrder = false;
/*
******************************************************************
**
** FUNCTION: DocumentSorter 
**
** DESCRIPTION: Sort documents in document tables
**
*/
function DocumentSorter()
{
	/*
	** if sort option is selected in the search screen, then 
	** client side document sorting is disabled
	*/
	if(false == g_NativeSortOrder)
	{
		/*
		** apply sorting for document class.
		*/
		var strDTableClass = "nfyitabledlist";
		ApplyTableSortingByClass(strDTableClass, false);	
		
		/*
		** if in fixed column mode
		*/
		var strDTableClass = "nfyitablefixedcoldlist";
		ApplyFixedTableSortingByClass(strDTableClass, false);	
	}
}

/*
** folder sorting is only possible in frames mode.
*/
function FolderSorter()
{
	/*
	** if sort option is selected in the search screen, then 
	** client side folder sorting is disabled
	*/
	if(false == g_NativeSortOrder)
	{
		var strFTableClass = "nfyitableflist";	
		ApplyTableSortingByClass(strFTableClass, false);
		
		strFTableClass = "nfyitablefixedcolflist";	
		ApplyFixedTableSortingByClass(strFTableClass, false);
	}
}


/* sort2D - sort a two-dimensional array by a given column and direction
	arguments:
		arIn - a two-dimentional array
		intPrimary - the first column to sort by
		intSecondary - the second column to sort by (use false or an empty string to sort only by primary)
		boolDirection - the direction to sort (1/true = ascending, 0/false = decending)
	returns:
		a copy of arIn, sorted as specified */		
function sort2D(arIn, intPrimary, intSecondary, boolPrimDirection, boolSecondDirection)
 {
	/*
    ** Locals
    */
	for(var i=0; i< arIn.length; i++)
	{
		for(var j=i+1; j< arIn.length; j++)
		{
		
			var cells1  = arIn[i].getElementsByTagName("td");
			var cells2  = arIn[j].getElementsByTagName("td");
			var cell1   = null;
			var cell2   = null;
			var strArg1 = null;
			var strArg2 = null;
			
			var cellsec1   = null;
			var cellsec2   = null;
			var strArgsec1 = null;
			var strArgsec2 = null;
			var boolSwitchRows = false;

			/*
			** Find the cells innerText for the rows, very carefully, incase 
			** there is a bug in the code that creates the array we are sorting..
			*/
			if(cells1.length)
			{
				cell1		= cells1[intPrimary];
				if(-1 != intSecondary)
				{
					cellsec1	= cells1[intSecondary];
				}
			}
			if(cells2.length)
			{
				cell2		= cells2[intPrimary];
				if(-1 != intSecondary)
				{
					cellsec2    = cells2[intSecondary];
				}
			}
		    
			if(null == cell1)
			{
				alert("cell1 is null during sort.");
			}
			else
			{
				strArg1 = String(cell1.innerText);
				if(-1 != intSecondary)
				{
					strsecArg1 = String (cellsec1.innerText);
				}
			}
			if(null == cell2)
			{
				alert("cell2 is null during sort.");
			}
			else
			{
				strArg2 = String (cell2.innerText);
				if(-1 != intSecondary)
				{
					strsecArg2 = String (cellsec2.innerText);
				}
			}
			
			if(boolPrimDirection && (strArg1.toLowerCase() > strArg2.toLowerCase()))
			{ 
				boolSwitchRows = true; 
			}
			if(!boolPrimDirection && (strArg1.toLowerCase() < strArg2.toLowerCase()))
			{ 
				boolSwitchRows = true; 
			}
				
			if(-1 != intSecondary && (strArg1 == strArg2)) 
			{
				if((boolSecondDirection) && (strsecArg1.toLowerCase() > strsecArg2.toLowerCase())) { boolSwitchRows = true; }
				if((!boolSecondDirection) && (strsecArg1.toLowerCase() < strsecArg2.toLowerCase())) { boolSwitchRows = true; }
			}
			if(boolSwitchRows) 
			{
				var arTemp = arIn[j];
				arIn[j] = arIn[i];
				arIn[i] = arTemp;
			}
		}
	}
	return(arIn);
}

/*
******************************************************************
**
** FUNCTION: ApplyTableSortingByClass 
**
** DESCRIPTION: Sort documents in document tables
**
*/
function ApplyTableSortingByClass(strClassname, bDebug)
{
    /*
    ** Local Variables
    */
    var tables         = document.getElementsByTagName("table");
    var i              = 0;
    var iLength        = tables.length;
    var oSorter        = new ISortHtmlTableData();

    /*
    ** Loop through the tables and find the table with the given className
    */
    while(i < iLength)
    {	
		if(tables[i].className.toLowerCase() == strClassname)
        {	
			/*
			** if the table has rows then set it to sortable
			*/			
			if(tables[i].rows.length)
			{	
				oSorter.LinkTableHdr2Sort(tables[i]);
				oSorter.SortTable(tables[i], null, true, bDebug);
			}			
        }

        /*
        ** Increment the counter
        */
        i++;
    }
}

function ApplyFixedTableSortingByClass(strClassname, bDebug)
{
    /*
    ** Local Variables
    */
    var tables         = document.getElementsByTagName("table");
    var i              = 0;
    var iLength        = tables.length;
    var oSorter        = new ISortHtmlTableData();
	
    /*
    ** Loop through the tables
    */
    while(i < iLength)
    {	
		if(tables[i].className.toLowerCase() == strClassname)
        {	
			/*
			** if the table has rows then set it to sortable
			*/			
			if(tables[i].rows.length)
			{	
				oSorter.LinkFixedTableHdr2Sort(tables[i]);
				oSorter.SortFixedTable(tables[i], null, true, bDebug);
			}			
        }

        /*
        ** Increment the counter
        */
        i++;
    }
}
/*
******************************************************************
**
** FUNCTION: ISortHtmlTableData_GetSortColumnNdx 
**
** DESCRIPTION: Get the index of the sort column in the table
**
*/
function ISortHtmlTableData_GetSortColumnNdx()
{
	return this.m_iSortNdx;
}

/*
******************************************************************
**
** FUNCTION: ISortHtmlTableData_GetDefaultColumnName 
**
** DESCRIPTION: Get the text name of the sort column in the table
**
*/
function ISortHtmlTableData_GetDefaultColumnName()
{
	return this.m_strDefaultSort;
}

/*
******************************************************************
**
** FUNCTION: SetSortNdxGlobal 
**
** DESCRIPTION: Find the cell with the specified text
**
*/
function ISortHtmlTableData_SetSortColumn(hdrRow, strSortOnColumn)
{
    /*
    ** 
    */
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var iDataCell = 0;
    var iInc      = 0;
    var bDone     = false;
    var Val       = null;
	
    /*
    ** Loop to find the index of the sort column
    */
    while(iCell < iRowCells && !bDone)
    {
        /*
        ** Get the value of the cell
        */
        Val = cells[iCell].childNodes[0].nodeValue;
        
        /*
        ** If this is the sort column
        */
        ///if(null != Val && Val.toLowerCase() == strSortOnColumn.toLowerCase())
        if(null != Val && Val == strSortOnColumn)
        {
            /*
            ** Save the cell index
            */
            this.m_iSortNdx = iCell;
            //this.m_iSortNdx = iDataCell;           
			/*
			** if the user clicked on the primary again after selecting the secondary
			*/            
            if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdx && (g_iSort_PrimaryColumnNdx == this.m_iSortNdx))
            {	
				if(g_bSort_PrimaryAscending)
				{
					g_bSort_PrimaryAscending = false;
				}
				else
				{
					g_bSort_PrimaryAscending = true;
				}
				
            }
            else
            {
				if(-1 == g_iSort_PrimaryColumnNdx)
				{
					g_iSort_PrimaryColumnNdx = this.m_iSortNdx;
					g_iSort_PrimaryDataColumnNdx = iDataCell;
				}
				else
				{
					/*
					** check if the user has clicked on the primary index column.
					*/
					if(g_iSort_PrimaryColumnNdx != this.m_iSortNdx)
					{
						g_iSort_SecondColumnNdx = this.m_iSortNdx;
						g_iSort_SecondDataColumnNdx = iDataCell;
					}
				}
			}            
            g_iSortHtmlTableData_ColumnNdx = iDataCell;
            bDone = true;                            
        }
        else
        {
			/*
			** Figure out the data column increment for this cell.
			*/
			iInc = cells[iCell].colSpan;
			//alert(Val + ": " + iInc);
        }
        
        /*
        ** Increment the counter
        */
        iDataCell = iDataCell + iInc;
        iCell++;
    }

    /*
    ** Return 
    */
    return this.m_iSortNdx;
}

function ISortHtmlTableData_SetFixedTblSortColumn(hdrRow, strSortOnColumn)
{
    /*
    ** 
    */
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var iDataCell = 0;
    var iInc      = 0;
    var bDone     = false;
    var Val       = null;
    var strSortOnColumnX;
	
	if(0 == strSortOnColumn.indexOf('[x] '))
	{
		strSortOnColumnX = strSortOnColumn.substr(4,strSortOnColumn.length);
	}
	
    /*
    ** Loop to find the index of the sort column
    */
    while(iCell < iRowCells && !bDone)
    {
        /*
        ** Get the value of the cell
        */
        if(cells[iCell].childNodes[0].childNodes.length)
        {
			Val = cells[iCell].childNodes[0].childNodes[0].innerText;			
		}
		
        /*
        ** If this is the sort column
        */
        ///if(null != Val && Val.toLowerCase() == strSortOnColumn.toLowerCase())
        if(null != Val && ( Val == strSortOnColumnX || Val == strSortOnColumn))
        {	
            /*
            ** Save the cell index
            */
            this.m_iSortNdx = iCell;
            //this.m_iSortNdx = iDataCell;           
			/*
			** if the user clicked on the primary again after selecting the secondary
			*/            
            if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdx && (g_iSort_PrimaryColumnNdx == this.m_iSortNdx))
            {	
				if(g_bSort_PrimaryAscending)
				{
					g_bSort_PrimaryAscending = false;
				}
				else
				{
					g_bSort_PrimaryAscending = true;
				}
				
            }
            else
            {
				if(-1 == g_iSort_PrimaryColumnNdx)
				{
					g_iSort_PrimaryColumnNdx = this.m_iSortNdx;
					g_iSort_PrimaryDataColumnNdx = iDataCell;
				}
				else
				{
					/*
					** check if the user has clicked on the primary index column.
					*/
					if(g_iSort_PrimaryColumnNdx != this.m_iSortNdx)
					{
						g_iSort_SecondColumnNdx = this.m_iSortNdx;
						g_iSort_SecondDataColumnNdx = iDataCell;
					}
				}
			}            
            g_iSortHtmlTableData_ColumnNdx = iDataCell;
            bDone = true;                            
        }
        else
        {
			/*
			** Figure out the data column increment for this cell.
			*/
			iInc = cells[iCell].colSpan;
			//alert(Val + ": " + iInc);
        }
        
        /*
        ** Increment the counter
        */
        iDataCell = iDataCell + iInc;
        iCell++;
    }

    /*
    ** Return 
    */
    return this.m_iSortNdx;
}

function ISortHtmlTableData_GetColumnIndex(hdrRow, strSortOnColumn)
{
    /*
    ** 
    */
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var iDataCell = 0;
    var iInc      = 0;
    var bDone     = false;
    var Val       = null;
    var iColIndex = -1;

    /*
    ** Loop to find the index of the sort column
    */
    while(iCell < iRowCells && !bDone)
    {
        /*
        ** Get the value of the cell
        */
        Val = cells[iCell].childNodes[0].nodeValue;
        
        /*
        ** If this is the sort column
        */
        ///if(null != Val && Val.toLowerCase() == strSortOnColumn.toLowerCase())
        if(null != Val && Val == strSortOnColumn)
        {
            /*
            ** Save the cell index
            */
            iColIndex = iCell;            
            bDone = true;                            
        }
        else
        {
			/*
			** Figure out the data column increment for this cell.
			*/
			iInc = cells[iCell].colSpan;
			//alert(Val + ": " + iInc);
        }
        
        /*
        ** Increment the counter
        */
        iDataCell = iDataCell + iInc;
        iCell++;
    }

    /*
    ** Return 
    */
    return iColIndex;
}

function ISortHtmlTableData_GetFixedTblColumnIndex(hdrRow, strSortOnColumn)
{
    /*
    ** 
    */
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var iDataCell = 0;
    var iInc      = 0;
    var bDone     = false;
    var Val       = null;
    var iColIndex = -1;
	var strSortOnColumnX;
	if(0 == strSortOnColumn.indexOf('[x] '))
	{
		strSortOnColumnX = strSortOnColumn.substr(4,strSortOnColumn.length);
	}
    /*
    ** Loop to find the index of the sort column
    */
    while(iCell < iRowCells && !bDone)
    {
        /*
        ** Get the value of the cell
        */
        //Val = cells[iCell].childNodes[0].nodeValue;
        if(cells[iCell].childNodes[0].childNodes.length)
        {
			Val = cells[iCell].childNodes[0].childNodes[0].innerText;			
		}
        
        /*
        ** If this is the sort column
        */
        ///if(null != Val && Val.toLowerCase() == strSortOnColumn.toLowerCase())
        if(null != Val && ( Val == strSortOnColumnX || Val == strSortOnColumn))
        {
            /*
            ** Save the cell index
            */
            iColIndex = iCell;                        
            bDone = true;                            
        }
        else
        {
			/*
			** Figure out the data column increment for this cell.
			*/
			iInc = cells[iCell].colSpan;
			//alert(Val + ": " + iInc);
        }
        
        /*
        ** Increment the counter
        */
        iDataCell = iDataCell + iInc;
        iCell++;
    }

    /*
    ** Return 
    */
    return iColIndex;
}
/*
** removes the sorting options.
*/
function resetSortColumn(_this)
{		
	/*
	** Loop to find the TABLE element
	*/
	var bDone = false;
	var table = _this;
	while(!bDone)
	{		
		if(table.nodeName.toLowerCase() == "table")
		{
			bDone = true;
		}
		else
		{
			/*
			** Go up to the next parent
			*/
			table = table.parentNode;
		}
	}
	
	//table = _this.parentNode.parentNode.parentNode;
	
	
	//alert(g_iSort_PrimaryColumnNdx + ',' + g_iSort_SecondColumnNdx);
	var hdrRows   = table.getElementsByTagName("tr");
	var cells     = hdrRows[0].getElementsByTagName("th");
	
	if(-1 != g_iSort_SecondColumnNdx)
	{
		if(cells[g_iSort_SecondColumnNdx].childNodes.length == 3)		
		{
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
		}
		else
		if(cells[g_iSort_SecondColumnNdx].childNodes.length == 2)
		{
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
		}
	}
	if(-1 != g_iSort_PrimaryColumnNdx)
	{ 
		if(cells[g_iSort_PrimaryColumnNdx].childNodes.length == 3)		
		{
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
		}
		else
		if(cells[g_iSort_PrimaryColumnNdx].childNodes.length == 2)		
		{
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
		}
	}
	
	/*
	** remove the sort icons from the down table.
	*/
	if(g_DocsFrameMode)
	{					
		downTable = document.all['DownTbl'+currentPanel];
		if(downTable)
		{
			resetDownTblSortColumn('DownTbl'+currentPanel);		
			if(document.all['upTbl'])
			{
				document.all['upTbl'].style.width = document.all['DownTbl'+currentPanel].offsetWidth;
			}
			
		}
		//strFixedTblBody += currentPanel;
	}
	else
	if(document.all['DownTbl'])
	{
		resetDownTblSortColumn('DownTbl');
	}
	
	g_primarySortColumn = null;
	g_secondSortColumn  = null;
	g_iSort_PrimaryColumnNdx = -1;
	g_iSort_SecondColumnNdx  = -1;
	g_bSort_PrimaryAscending = -1;
	g_bSort_SecondAscending  = -1;	
	
}

function resetFixedTableSortColumn(_this)
{		
	/*
	** Loop to find the TABLE element
	*/
	var bDone = false;
	var table = _this;
	while(!bDone)
	{		
		if(table.nodeName.toLowerCase() == "table")
		{
			bDone = true;
		}
		else
		{
			/*
			** Go up to the next parent
			*/
			table = table.parentNode;
		}
	}
	
	//table = _this.parentNode.parentNode.parentNode;
	
	
	//alert(g_iSort_PrimaryColumnNdx + ',' + g_iSort_SecondColumnNdx);
	var hdrRows   = table.getElementsByTagName("tr");
	var cells     = hdrRows[0].getElementsByTagName("th");
	
	if(-1 != g_iSort_SecondColumnNdx)
	{	
		if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 3)		
		{	
			/*
			** remove the sort icon
			*/
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
		else
		if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
		{
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
	}
	if(-1 != g_iSort_PrimaryColumnNdx)
	{ 
		if(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].childNodes.length == 3)				
		{
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
		else
		if(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
		{
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
	}
	
	/*
	** remove the sort icons from the down table.
	*/
	if(g_DocsFrameMode)
	{					
		downTable = document.all['DownTbl'+currentPanel];
		if(downTable)
		{
			resetDownTblSortColumn('DownTbl'+currentPanel);		
			if(document.all['upTbl'])
			{
				document.all['upTbl'].style.width = document.all['DownTbl'+currentPanel].offsetWidth;
			}
			
		}
		//strFixedTblBody += currentPanel;
	}
	else
	if(document.all['DownTbl'])
	{
		resetDownTblFixedTableSortColumn('DownTbl');
	}
	
	g_primarySortColumn = null;
	g_secondSortColumn  = null;
	g_iSort_PrimaryColumnNdx = -1;
	g_iSort_SecondColumnNdx  = -1;
	g_bSort_PrimaryAscending = -1;
	g_bSort_SecondAscending  = -1;	
	
}

/*
** remove the sort icons from the down table.
*/
function resetDownTblSortColumn(sTableId)
{		
	/*
	** Loop to find the TABLE element
	*/	
	var bDone = false;
	var table = document.all[sTableId];
	
	//alert(g_iSort_PrimaryColumnNdx + ',' + g_iSort_SecondColumnNdx);
	var hdrRows   = table.getElementsByTagName("tr");
	var cells     = hdrRows[0].getElementsByTagName("th");
	if(-1 != g_iSort_SecondColumnNdx)
	{
		if(cells[g_iSort_SecondColumnNdx].childNodes.length == 3)		
		{
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
		}
		else
		if(cells[g_iSort_SecondColumnNdx].childNodes.length == 2)
		{
			cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
		}
	}
	if(-1 != g_iSort_PrimaryColumnNdx)
	{ 
		if(cells[g_iSort_PrimaryColumnNdx].childNodes.length == 3)		
		{
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
		}
		else
		if(cells[g_iSort_PrimaryColumnNdx].childNodes.length == 2)		
		{
			cells[g_iSort_PrimaryColumnNdx].removeChild(cells[g_iSort_PrimaryColumnNdx].lastChild);
		}
	}
}

function resetDownTblFixedTableSortColumn(sTableId)
{		
	/*
	** Loop to find the TABLE element
	*/	
	var bDone = false;
	var table = document.all[sTableId];
	
	//alert(g_iSort_PrimaryColumnNdx + ',' + g_iSort_SecondColumnNdx);
	var hdrRows   = table.getElementsByTagName("tr");
	var cells     = hdrRows[0].getElementsByTagName("th");
	if(-1 != g_iSort_SecondColumnNdx)
	{
		if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 3)		
		{	
			/*
			** remove the sort icon
			*/
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
		else
		if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
		{
			cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
	}
	if(-1 != g_iSort_PrimaryColumnNdx)
	{ 
		if(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].childNodes.length == 3)				
		{
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
		else
		if(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
		{
			cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_PrimaryColumnNdx].childNodes[0].childNodes[0].firstChild);
		}
	}
}
/*
******************************************************************
**
** FUNCTION: ISortHtmlTableData_SortTableData 
**
** DESCRIPTION: Generic Table data sorting routine
**
*/
var g_primarySortColumn = null;
var g_secondSortColumn  = null;
var g_iSort_PrimaryColumnNdx = -1;
var g_iSort_SecondColumnNdx  = -1;
var g_iSort_SecondColumnNdxDownTbl = -1;
var g_bSort_PrimaryAscending = -1;
var g_bSort_SecondAscending  = -1;
/*
** if the column span is more than 1, then header col count 
** and data col count will not match, so have a separate data col index,
** and use it when sorting the sort2d fn.
*/
var g_iSort_PrimaryDataColumnNdx = -1; 
var g_iSort_SecondDataColumnNdx  = -1;

function ISortHtmlTableData_SortTableData(table, strSortOnColumn, bAsc, bAlert)
{ 
    /*
    ** Locals
    */
    var rows         = table.getElementsByTagName("tr");
    var iRow         = 0;
    var iTableRows   = rows.length;
    var newRows      = new Array();
	var twoDimSort   = false;
	var intPrimary	 = 0;
	var intSecondary = 0;
		
	/*if(null == g_primarySortColumn)
	{
		g_primarySortColumn = strSortOnColumn;
	}
	else	
	{	
		intPrimary  = g_iSortHtmlTableData_ColumnNdx;		
		twoDimSort	= true;
	}*/
	
	/*if(null == g_primarySortColumn)
	{
		g_primarySortColumn = strSortOnColumn;
	}
	else
	{
		g_SecondSortColumn = strSortOnColumn;	
	}*/
	
	/*
	** Set our sort direction
	*/
	if(-1 == g_bSort_PrimaryAscending)
	{
		g_bSort_PrimaryAscending = bAsc;
	}
	else
	{
		g_bSort_SecondAscending = bAsc;
	}
	g_bSortHtmlTableData_Ascending = bAsc;

    /*
    ** Set the sort column index global
    */
    if(null == strSortOnColumn)
    {
	    strSortOnColumn = this.GetDefaultColumnName();
	}
	
	this.SetSortColumn(rows[0], strSortOnColumn);

    /*
    ** Did we get a good sort field?
    */
    if(-1 == this.GetSortColumnNdx())
    {
        /*
        ** Nope
        */
		if(bAlert)
		{
            alert("Unable to locate sort field '" + strSortOnColumn + "' in table.");
		}
    }
    else
    {
        /*
        ** Locals
        */
        var nodeTBody    = table.getElementsByTagName("tbody");
        var nodeTHead    = table.getElementsByTagName("thead");
        var nodeList     = null;
        var nodeParent   = null;
        var iLeastRowNdx = 0;

        /*
        ** Is there a THEAD in this table?
        */
        if(null != nodeTHead)
        {
            /*
            ** If so, then the data rows go to zero
            */
            iLeastRowNdx = 0;
        }
        else
        {
            /*
            ** If not, then the data rows go to one, and the zeroth row is headers...
            */
            iLeastRowNdx = 1;
        }

        /*
        ** Is there a TBODY in this table?
        */
        if(null != nodeTBody[0])
        {
            /*
            ** If so, then we need the tbody's child nodes
            */
            nodeList   = nodeTBody[0].childNodes;
            nodeParent = nodeTBody[0];

        }
        else
        {
            /*
            ** If not, use the standard children
            */
            nodeList   = table.childNodes;
            nodeParent = table;
        }

        /*
        ** DEBUG
        */
        //alert("nodeList[0]: " + nodeList[0].nodeName + ", nodeParent: " + nodeParent.nodeName + ", iLeastRowNdx: " + iLeastRowNdx);

        /*
        ** Yes, Delete the old rows
        */
        iRow = nodeList.length;
        while(iRow > iLeastRowNdx)
        {
            /*
            ** Remove the row
            */
            var row = null;

            /*
            ** IE tends to put a TBODY in automatically, so childNodes aren't actually
            ** the childs that appear in the HTML
            */
            row = nodeList[iRow - 1];

            /*
            ** Add the row to our new array to be sorted
            */
            hdrCells = row.getElementsByTagName("th");
            if(null != hdrCells && 0 < hdrCells.length)
            {
                /*
                ** Skip this row
                */
            }
            else
            {
                row = nodeParent.removeChild(row);
                newRows.push(row);
            }

            /*
            ** Increment the row counter
            */
            iRow--;
        }

        /*
        ** Sort the rows
        if(bAlert)
        {
	        var strNdx  = " g_iSortHtmlTableData_ColumnNdx equals " + g_iSortHtmlTableData_ColumnNdx;
	        alert(strNdx);
	    }
        */
        if(-1 != g_iSort_SecondColumnNdx)
        {
			/*intSecondary		= g_iSortHtmlTableData_ColumnNdx;
			var boolDirection	= g_iSortHtmlTableData_ColumnNdx;
			newRows = sort2D(newRows, intPrimary, intSecondary, boolPrimDirection, boolSecondDirection);
			//newRows.sort(this.ArraySortFunction);
			*/
			intPrimary				= g_iSort_PrimaryDataColumnNdx
			intSecondary			= g_iSort_SecondDataColumnNdx;
			var boolPrimDirection	= g_bSort_PrimaryAscending;
			var boolSecondDirection	= g_bSort_SecondAscending;			
			newRows = sort2D(newRows, intPrimary, intSecondary, boolPrimDirection, boolSecondDirection);
        }
        else
        {			
			newRows.sort(this.ArraySortFunction);
		}		

        /*
        ** Loop to...
        */
        iRow = 0;
        while(iRow < newRows.length)
        {
            /*
            ** Add the row
            */
            nodeParent.appendChild(newRows[iRow]);
            //newRows[iRow].style.backgroundColor = "yellow";

            /*
            ** Increment the row counter
            */
            iRow++;
        }
    }
}

function ISortHtmlTableData_SortFixedTableData(table, strSortOnColumn, bAsc, bAlert)
{ 
    /*
    ** Locals
    */
    var rows         = table.getElementsByTagName("tr");
    var iRow         = 0;
    var iTableRows   = rows.length;
    var newRows      = new Array();
	var twoDimSort   = false;
	var intPrimary	 = 0;
	var intSecondary = 0;
		
	/*if(null == g_primarySortColumn)
	{
		g_primarySortColumn = strSortOnColumn;
	}
	else	
	{	
		intPrimary  = g_iSortHtmlTableData_ColumnNdx;		
		twoDimSort	= true;
	}*/
	
	/*if(null == g_primarySortColumn)
	{
		g_primarySortColumn = strSortOnColumn;
	}
	else
	{
		g_SecondSortColumn = strSortOnColumn;	
	}*/
	
	/*
	** Set our sort direction
	*/
	if(-1 == g_bSort_PrimaryAscending)
	{
		g_bSort_PrimaryAscending = bAsc;
	}
	else
	{
		g_bSort_SecondAscending = bAsc;
	}
	g_bSortHtmlTableData_Ascending = bAsc;

    /*
    ** Set the sort column index global
    */
    if(null == strSortOnColumn)
    {
	    strSortOnColumn = this.GetDefaultColumnName();
	}
	
	this.SetFixedTblSortColumn(rows[0], strSortOnColumn);
	
    /*
    ** Did we get a good sort field?
    */
    if(-1 == this.GetSortColumnNdx())
    {
        /*
        ** Nope
        */
		if(bAlert)
		{
            alert("Unable to locate sort field '" + strSortOnColumn + "' in table.");
		}
    }
    else
    {
        /*
        ** Locals
        */
        var nodeTBody    = table.getElementsByTagName("tbody");
        var nodeTHead    = table.getElementsByTagName("thead");
        var nodeList     = null;
        var nodeParent   = null;
        var iLeastRowNdx = 0;

        /*
        ** Is there a THEAD in this table?
        */
        if(null != nodeTHead)
        {
            /*
            ** If so, then the data rows go to zero
            */
            iLeastRowNdx = 0;
        }
        else
        {
            /*
            ** If not, then the data rows go to one, and the zeroth row is headers...
            */
            iLeastRowNdx = 1;
        }

        /*
        ** Is there a TBODY in this table?
        */
        if(null != nodeTBody[0])
        {
            /*
            ** If so, then we need the tbody's child nodes
            */
            nodeList   = nodeTBody[0].childNodes;
            nodeParent = nodeTBody[0];

        }
        else
        {
            /*
            ** If not, use the standard children
            */
            nodeList   = table.childNodes;
            nodeParent = table;
        }

        /*
        ** DEBUG
        */
        //alert("nodeList[0]: " + nodeList[0].nodeName + ", nodeParent: " + nodeParent.nodeName + ", iLeastRowNdx: " + iLeastRowNdx);

        /*
        ** Yes, Delete the old rows
        */
        iRow = nodeList.length;
        
        while(iRow > iLeastRowNdx)
        {
            /*
            ** Remove the row
            */
            var row = null;

            /*
            ** IE tends to put a TBODY in automatically, so childNodes aren't actually
            ** the childs that appear in the HTML
            */
            row = nodeList[iRow - 1];

            /*
            ** Add the row to our new array to be sorted
            */
            hdrCells = row.getElementsByTagName("th");
         
            if(null != hdrCells && 0 < hdrCells.length)
            {
                /*
                ** Skip this row
                */
            }
            else
            {
                row = nodeParent.removeChild(row);
                newRows.push(row);
            }

            /*
            ** Increment the row counter
            */
            iRow--;
        }
		
        /*
        ** Sort the rows
        if(bAlert)
        {
	        var strNdx  = " g_iSortHtmlTableData_ColumnNdx equals " + g_iSortHtmlTableData_ColumnNdx;
	        alert(strNdx);
	    }
        */
        if(-1 != g_iSort_SecondColumnNdx)
        {
			/*intSecondary		= g_iSortHtmlTableData_ColumnNdx;
			var boolDirection	= g_iSortHtmlTableData_ColumnNdx;
			newRows = sort2D(newRows, intPrimary, intSecondary, boolPrimDirection, boolSecondDirection);
			//newRows.sort(this.ArraySortFunction);
			*/
			intPrimary				= g_iSort_PrimaryDataColumnNdx
			intSecondary			= g_iSort_SecondDataColumnNdx;
			var boolPrimDirection	= g_bSort_PrimaryAscending;
			var boolSecondDirection	= g_bSort_SecondAscending;			
			newRows = sort2D(newRows, intPrimary, intSecondary, boolPrimDirection, boolSecondDirection);
        }
        else
        {			
			newRows.sort(this.ArraySortFunction);
		}		

        /*
        ** Loop to...
        */
        iRow = 0;
        while(iRow < newRows.length)
        {
            /*
            ** Add the row
            */
            nodeParent.appendChild(newRows[iRow]);
            //newRows[iRow].style.backgroundColor = "yellow";

            /*
            ** Increment the row counter
            */
            iRow++;
        }
    }
}
/*
*********************************************************************************
**
** FUNCTION: SortDocument
**
**
*/
function ISortHtmlTableData_ArraySortFunction(arg1, arg2)
{
	if(null == arg1 || null == arg2)
	{
		alert("An argument is null: " + arg1 + "," + arg2);
	}
	
    /*
    ** Locals
    */
    var cells1  = arg1.getElementsByTagName("td");
    var cells2  = arg2.getElementsByTagName("td");
    var cell1   = null;
    var cell2   = null;
    var strArg1 = null;
    var strArg2 = null;

    /*
    ** Find the cells innerText for the rows, very carefully, incase 
    ** there is a bug in the code that creates the array we are sorting..
    */
    if(cells1.length)
    {
        cell1   = cells1[g_iSortHtmlTableData_ColumnNdx];
    }
    if(cells2.length)
    {
        cell2   = cells2[g_iSortHtmlTableData_ColumnNdx];
    }
    
    if(null == cell1)
    {
		alert("cell1 is null during sort.");
    }
    else
    {
        strArg1 = cell1.innerText;
    }
    if(null == cell2)
    {
		alert("cell2 is null during sort.");
    }
    else
    {
        strArg2 = cell2.innerText;
    }
    
	/*
    ** If we got good data, then 
    */
    if(null != strArg1 && null != strArg2)
    {
        /*
        ** Determine the sort order
        */
        if(strArg1 < strArg2)
        {
            //alert(strArg1 + " < " + strArg2);
            return g_bSortHtmlTableData_Ascending ? -1 : 1;
        }
        if(strArg1 > strArg2)
        {
            //alert(strArg1 + " > " + strArg2);
            return g_bSortHtmlTableData_Ascending ? 1 : -1;
        }
        if(strArg1 == strArg2)
        {
            //alert(strArg1 + " == " + strArg2);
            return 0;
        }
    }
    else
    {
        /*
        ** Otherwise fail gracefully
        */
        return 0;
    }
}

/*
*********************************************************************************
**
** FUNCTION: SortDocument
**
**
*/
function ISortHtmlTableData_LinkTableHdr2Sort(table)
{
    /*
    ** 
    */
    var hdrRow    = table.rows[0];    
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var xBrowser  = new IXBrowser();
    
	/*
	** For Microsoft Browsers, add header links to the table
	*/
    if(BR_MICROSOFT == xBrowser.GetBrowserType())
    {
		/*
		** Loop to find the index of the sort column
		*/
		while(iCell < iRowCells)
		{
			/*
			** Get the value of the cell
			*/
			cell              = cells[iCell];
			
			/*
			** Does the cell have children?
			*/
			if((0 < cell.childNodes.length && cell.childNodes[0].nodeType == 3 /*Text Node*/) ||
				(0 < cell.childNodes.length && cell.childNodes[0].nodeType == 1 && cell.childNodes[0].tagName.toLowerCase() == "span" /*Text Node*/))
			{
				/*
				** Yes, then it is sortable
				*/
				cell.onclick      = OnTableDataSorterEvent;				
				cell.style.cursor = "hand";
				cell.title        = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;				
				cell.setAttribute(SORT_ATTR, SORT_ASC);				
				//alert(cell.childNodes[0].nodeType + "," + cell.childNodes[0].tagName + "," + cell.childNodes.length);
				//alert(cell.title);
				//cell.innerHTML = cell.innerHTML + "[x]";
			}

			/*
			** Increment the counter
			*/
			iCell++;
		}
	}
}

function ISortHtmlTableData_LinkFixedTableHdr2Sort(table)
{
    /*
    ** 
    */
    var hdrRow    = table.rows[0];    
    var cells     = hdrRow.getElementsByTagName("th");
    var iRowCells = cells.length;
    var iCell     = 0;
    var xBrowser  = new IXBrowser();
    
	/*
	** For Microsoft Browsers, add header links to the table
	*/
    if(BR_MICROSOFT == xBrowser.GetBrowserType())
    {
		/*
		** Loop to find the index of the sort column
		*/
		while(iCell < iRowCells)
		{
			/*
			** Get the value of the cell
			*/
			cell              = cells[iCell];
			
			/*
			** Does the cell have children?
			*/			
			if(0 < cell.childNodes.length && cell.childNodes[0].nodeType == 1 && cell.childNodes[0].tagName.toLowerCase() == "span" /*span Node*/)
			{
				/*
				** Yes, then it is sortable
				*/
				cell.onclick      = OnFixedTableDataSorterEvent;				
				cell.style.cursor = "hand";
				cell.title        = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;				
				cell.setAttribute(SORT_ATTR, SORT_ASC);				
				//alert(cell.childNodes[0].nodeType + "," + cell.childNodes[0].tagName + "," + cell.childNodes.length);
				//alert(cell.title);
				//cell.innerHTML = cell.innerHTML + "[x]";
			}

			/*
			** Increment the counter
			*/
			iCell++;
		}
	}
}
/*
*********************************************************************************
**
** FUNCTION: TableDataSorterEvent
** if it is a fixed header column table, then you need to have folder list 
** table id = DownTbl
**
*/
function OnTableDataSorterEvent()
{
    /*
    ** Locals
    */
    var _this   = event.srcElement;
    var table   = _this.parentNode;
    var bDone   = false;
    var bAsc    = true;
    var oSorter = new ISortHtmlTableData();
    var downTable = null;
    var strFixedTblBody = 'FixedTblBody';
	
	/*
	** if the user clicked on [x] hyperlink do nothing..
	*/
	if("A" != _this.tagName)
	{
		/*
		** Loop to find the TABLE element
		*/
		while(!bDone && null != table)
		{
			if(table.nodeName.toLowerCase() == "table")
			{
				bDone = true;
			}
			else
			{
				/*
				** Go up to the next parent
				*/
				table = table.parentNode;
			}
		}
		/*
		** Sort the table on the specified column
		*/
		if(bDone)
		{
			/*
			** check it the table id is upTbl, which is the fixed header table
			** on the top of DownTbl. so, we have to adjust the columns of DownTbl.
			*/
			if("upTbl" == table.id)
			{
				if(g_DocsFrameMode)
				{					
					downTable = document.all['DownTbl'+currentPanel];
					strFixedTblBody += currentPanel;
				}
				else
				{
					/*
					** get the DownTbl, which is the one that has all the data rows
					*/
					downTable = document.all['DownTbl'];
				}
			}	
			
			bDone = false;
			while(!bDone && null != _this)
			{
				/*
				** Determine sort direction
				*/
				if("TH" != _this.tagName)
				{	
					_this = _this.parentNode;								
				}			
				else
				{
					bDone = true;
				}
			}			
			if(null == _this)
			{
				alert('could not find header column, returning without sorting..');
				return;
			}
			/*
			** if primary and secondary are already selected then move the secondary to the new column.
			*/			
			if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdx)
			{	
				var hdrRows   = table.getElementsByTagName("tr");
				var cells     = hdrRows[0].getElementsByTagName("th");				
				
				if(cells[g_iSort_SecondColumnNdx].childNodes.length == 2)		
				{	
					/*
					** remove the sort icon
					*/
					cells[g_iSort_SecondColumnNdx].removeChild(cells[g_iSort_SecondColumnNdx].lastChild);
				}
			}
		   
			strDir = _this.getAttribute(SORT_ATTR);		
			if(strDir.toLowerCase() == SORT_ASC)
			{
				//alert(_this.childNodes.length);
				if(_this.childNodes.length == 3)
				{
					_this.removeChild(_this.lastChild);
					_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";
				}
				else
				if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
				{
					_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";					
				}
				else
				{
					_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />";					
				}
				
				_this.setAttribute(SORT_ATTR, SORT_DESC);
				_this.title = STR_TOOLTIP_CLICK2SORT + STR_DESCENDING;			
				bAsc = true;							
			}
			else
			{
				if(_this.childNodes.length == 3)
				{
					_this.removeChild(_this.lastChild);
					_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";					
				}
				else
				if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
				{
					_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";										
				}
				else
				{
					_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />";					
				}
				_this.setAttribute(SORT_ATTR, SORT_ASC);
				_this.title = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;
				bAsc = false;				
			}
			
			/*
			** if downTable is found then we need to sort Downtable, because UpTbl has only
			** the header and does not have the body.
			*/
			if(downTable)
			{
				table = downTable;
				/*
				** store the second col index, because it will change, after calling
				** sortTable, use this index to adjust the downtable.
				*/
				g_iSort_SecondColumnNdxDownTbl = g_iSort_SecondColumnNdx;
			}
			/*
			** Do the sort
			*/
			oSorter.SortTable(table, _this.childNodes[0].nodeValue, bAsc, true);
			/*
			** now add the icons to the downTable so that the column sizes match with 
			** the UpTbl.
			*/
			if(downTable)
			{
				AdjustDownTable(downTable,_this.childNodes[0].nodeValue);								
				if(g_DocsFrameMode)
				{
					if(document.all['upTbl'])
					{
						document.all['upTbl'].style.width = document.all[strFixedTblBody].offsetWidth;
					}
				}
			}
			
		}
		else
		{
			alert("Unable to find parent table to sort.")
		}
	}
	
}

function OnFixedTableDataSorterEvent()
{
    /*
    ** Locals
    */
    var _this   = event.srcElement;
    var table   = _this.parentNode;
    var bDone   = false;
    var bAsc    = true;
    var oSorter = new ISortHtmlTableData();
    var downTable = null;
    var strFixedTblBody = 'FixedTblBody';
	
	/*
	** if the user clicked on [x] hyperlink do nothing..
	*/
	if("A" != _this.tagName)
	{
		/*
		** Loop to find the TABLE element
		*/
		while(!bDone && null != table)
		{
			if(table.nodeName.toLowerCase() == "table")
			{
				bDone = true;
			}
			else
			{
				/*
				** Go up to the next parent
				*/
				table = table.parentNode;
			}
		}
		/*
		** Sort the table on the specified column
		*/
		if(bDone)
		{
			/*
			** check it the table id is upTbl, which is the fixed header table
			** on the top of DownTbl. so, we have to adjust the columns of DownTbl.
			*/
			if("upTbl" == table.id)
			{
				if(g_DocsFrameMode)
				{					
					downTable = document.all['DownTbl'+currentPanel];
					strFixedTblBody += currentPanel;
				}
				else
				{
					/*
					** get the DownTbl, which is the one that has all the data rows
					*/
					downTable = document.all['DownTbl'];
				}
			}	
			
			bDone = false;
			while(!bDone && null != _this)
			{
				/*
				** Determine sort direction
				*/
				if("TH" != _this.tagName)
				{	
					_this = _this.parentNode;								
				}			
				else
				{
					bDone = true;
				}
			}			
			if(null == _this)
			{
				alert('could not find header column, returning without sorting..');
				return;
			}
			
			/*
			** if primary and secondary are already selected then move the secondary to the new column.
			*/			
			if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdx)
			{	
				var hdrRows   = table.getElementsByTagName("tr");
				var cells     = hdrRows[0].getElementsByTagName("th");				
				
				if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
				{	
					/*
					** remove the sort icon
					*/
					cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
				}
			}
		   
			strDir = _this.getAttribute(SORT_ATTR);					
			if(strDir.toLowerCase() == SORT_ASC)
			{			
				if(_this.childNodes[0].childNodes[0].childNodes.length == 3)		
				{	
					/*
					** remove the sort icon and [x]
					*/
					_this.childNodes[0].childNodes[0].removeChild(_this.childNodes[0].childNodes[0].firstChild);
					_this.childNodes[0].childNodes[0].removeChild(_this.childNodes[0].childNodes[0].firstChild);				
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
				}
				//alert(_this.childNodes.length + _this.innerHTML + "," + _this.innerText);
				/*if(_this.childNodes.length == 3)
				{
					_this.removeChild(_this.lastChild);
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
					
				}*/
				else
				if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
				{
					//alert(_this.childNodes[0].childNodes[0].innerHTML);
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";					
				}
				else
				{
					_this.childNodes[0].childNodes[0].innerHTML =  "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + _this.childNodes[0].childNodes[0].innerText;
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />";					
				}
				
				_this.setAttribute(SORT_ATTR, SORT_DESC);
				_this.title = STR_TOOLTIP_CLICK2SORT + STR_DESCENDING;			
				bAsc = true;							
			}
			else
			{					
				if(_this.childNodes[0].childNodes[0].childNodes.length == 3)		
				{	
					/*
					** remove the sort icon and [x]
					*/
					_this.childNodes[0].childNodes[0].removeChild(_this.childNodes[0].childNodes[0].firstChild);
					_this.childNodes[0].childNodes[0].removeChild(_this.childNodes[0].childNodes[0].firstChild);					
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
				}			
				/*if(_this.childNodes.length == 3)
				{
					_this.removeChild(_this.lastChild);
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";					
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
				}*/
				else
				if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
				{
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";										
					_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
				}
				else
				{
					//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />";					
					_this.childNodes[0].childNodes[0].innerHTML =  "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + _this.childNodes[0].childNodes[0].innerText;
				}
				_this.setAttribute(SORT_ATTR, SORT_ASC);
				_this.title = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;
				bAsc = false;				
			}
			
			/*
			** if downTable is found then we need to sort Downtable, because UpTbl has only
			** the header and does not have the body.
			*/
			if(downTable)
			{
				table = downTable;
				/*
				** store the second col index, because it will change, after calling
				** sortTable, use this index to adjust the downtable.
				*/
				g_iSort_SecondColumnNdxDownTbl = g_iSort_SecondColumnNdx;
			}
			/*
			** Do the sort
			*/
			
			oSorter.SortFixedTable(table, _this.childNodes[0].childNodes[0].innerText, bAsc, true);
			/*
			** now add the icons to the downTable so that the column sizes match with 
			** the UpTbl.
			*/
			if(downTable)
			{
				AdjustDownFixedTable(downTable,_this.childNodes[0].childNodes[0].innerText);								
				if(g_DocsFrameMode)
				{
					if(document.all['upTbl'])
					{
						document.all['upTbl'].style.width = document.all[strFixedTblBody].offsetWidth;
					}
				}
			}
			
		}
		else
		{
			alert("Unable to find parent table to sort.")
		}
	}
	
}
/*
** just a void function, called when user clicks on [x] hyperlink 
** on the sort column.
*/
function voidReturn()
{	
  
}

function AdjustDownTable(downTable, strColumnText)
{
	var oSorter = new ISortHtmlTableData();	
	var _this = null;	
	if(downTable)
	{		
		var hdrRows   = downTable.getElementsByTagName("tr");
		var cells     = hdrRows[0].getElementsByTagName("th");				
		
		index = oSorter.GetColumnIndex(hdrRows[0], strColumnText);		
		_this = cells[index];	
			
		/*
		** if primary and secondary are already selected then move the secondary to the new column.
		*/
		if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdxDownTbl)
		{	
			var hdrRows   = downTable.getElementsByTagName("tr");
			var cells     = hdrRows[0].getElementsByTagName("th");			
			
			if(cells[g_iSort_SecondColumnNdxDownTbl].childNodes.length == 2)		
			{
				/*
				** remove the sort icon
				*/
				cells[g_iSort_SecondColumnNdxDownTbl].removeChild(cells[g_iSort_SecondColumnNdxDownTbl].lastChild);
			}
		}
	}
	
	strDir = _this.getAttribute(SORT_ATTR);				
	if(strDir.toLowerCase() == SORT_ASC)
	{
		if(_this.childNodes.length == 3)
		{	
			_this.removeChild(_this.lastChild);
			_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";			
		}
		else
		if(-1 == g_iSort_SecondColumnNdx)
		{	
			_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";
		}
		else
		{	
			_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />";
		}
		
		bAsc = true;
		_this.setAttribute(SORT_ATTR, SORT_DESC);
		_this.title = STR_TOOLTIP_CLICK2SORT + STR_DESCENDING;			
	}
	else
	{
		if(_this.childNodes.length == 3)
		{
			_this.removeChild(_this.lastChild);
			_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";
		}
		else
		if(-1 == g_iSort_SecondColumnNdx)
		{
			_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";					
		}
		else
		{
			_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />";
		}
		bAsc = false;		
		_this.setAttribute(SORT_ATTR, SORT_ASC);
		_this.title = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;			
	}
}

function AdjustDownFixedTable(downTable, strColumnText)
{

	var oSorter = new ISortHtmlTableData();	
	var _this = null;	
	if(downTable)
	{		
		var hdrRows   = downTable.getElementsByTagName("tr");
		var cells     = hdrRows[0].getElementsByTagName("th");				
		
		index = oSorter.GetFixedTblColumnIndex(hdrRows[0], strColumnText);		
		_this = cells[index];		
		bDone = false;
		while(!bDone && null != _this)
		{
	
			/*
			** Determine sort direction
			*/
			if("TH" != _this.tagName)
			{	
				_this = _this.parentNode;								
			}			
			else
			{
				bDone = true;
			}
		}			
		if(null == _this)
		{
			alert('could not find header column, returning without sorting..');
			return;
		}
		/*
		** if primary and secondary are already selected then move the secondary to the new column.
		*/
		//alert(g_iSort_PrimaryColumnNdx + ',' + g_iSort_SecondColumnNdxDownTbl);
		if(-1 != g_iSort_PrimaryColumnNdx && -1 != g_iSort_SecondColumnNdxDownTbl)
		{	
			var hdrRows   = downTable.getElementsByTagName("tr");
			var cells     = hdrRows[0].getElementsByTagName("th");						
			if(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].childNodes.length == 2)		
			{	
				/*
				** remove the sort icon
				*/
				cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].removeChild(cells[g_iSort_SecondColumnNdx].childNodes[0].childNodes[0].firstChild);
			}
		}
	}
	if(1)
		return;
	strDir = _this.getAttribute(SORT_ATTR);
				
	if(strDir.toLowerCase() == SORT_ASC)
	{
		//alert(_this.childNodes.length + _this.innerHTML + "," + _this.innerText);
		if(_this.childNodes.length == 3)
		{
			_this.removeChild(_this.lastChild);
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";
			_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
		}
		else
		if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
		{
			//alert(_this.childNodes[0].childNodes[0].innerHTML);
			_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\" >[x] </a>";					
		}
		else
		{
			_this.childNodes[0].childNodes[0].innerHTML =  "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + _this.childNodes[0].childNodes[0].innerText;
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortUp.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />";					
		}
		
		_this.setAttribute(SORT_ATTR, SORT_DESC);
		_this.title = STR_TOOLTIP_CLICK2SORT + STR_DESCENDING;			
		bAsc = true;							
	}
	else
	{
		if(_this.childNodes.length == 3)
		{
			_this.removeChild(_this.lastChild);
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";					
			_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
		}
		else
		if(-1 == g_iSort_PrimaryColumnNdx && -1 == g_iSort_SecondColumnNdx)
		{
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetSortColumn(this);\">[x] </a>";										
			_this.childNodes[0].childNodes[0].innerHTML = "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + "<a href=\"javascript:voidReturn();\" title='remove sorting' onclick=\"javascript:resetFixedTableSortColumn(this);\" >[x] </a>" + _this.childNodes[0].childNodes[0].innerText;
		}
		else
		{
			//_this.innerHTML = _this.innerText + "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_ASCENDING + "' border='0' />";					
			_this.childNodes[0].childNodes[0].innerHTML =  "<img src='../Image/SortDown.gif' alt='" + STR_TOOLTIP_CLICK2SORT + STR_DESCENDING + "' border='0' />" + _this.childNodes[0].childNodes[0].innerText;
		}
		_this.setAttribute(SORT_ATTR, SORT_ASC);
		_this.title = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;
		bAsc = false;				
	}
	
}
/*
** this variable will be set for screen not having the left
** side saved search frame.
*/
g_NoSavedSearchFrame = false;
g_NoMenuFrame		 = false;

function ProcessDivResize()
{			
	var iFrameHeight	= 200;
	var iFrameWidth		= 200;
	var divScrollable   = document.getElementById("ScrollableDiv");
	var Browser			= new IXBrowser();
	var iBrowserType	= Browser.GetBrowserType();
	var iClientHeight;
	var iClientWidth;
	var divFixedTblContainer = document.getElementById("divFixedTblContainer");
	
	switch(iBrowserType)
	{
		case BR_MICROSOFT:
			iClientHeight = document.body.clientHeight;
			iClientWidth  = document.body.clientWidth;
			break;
		case BR_NETSCAPE6:					
			iClientHeight = window.innerHeight;
			iClientWidth  = window.innerWidth;			
			break;
		default:
			alert('unsupported browser');
			break;
	}		
	
	/*
	** to disable the scrollable div and display full text.
	*/
	/*
	if(disable == true)
	{
		document.all["ScrollableDiv"].style.overflow= "visible";				
	}*/
	
	/*
	** no saved search frame
	*/	
	if(g_NoSavedSearchFrame == true)
	{
		iFrameWidth = (iClientWidth-25)
	}
	else
	{				
		iFrameWidth = (iClientWidth - 200);
	}
	if(g_NoMenuFrame)
	{
		iFrameHeight = (iClientHeight)*0.80;
	}
	else
	{
		/*if(window.screen.height == 768)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 600)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 864)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 720)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 960)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 1024)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 1200)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		if(window.screen.height == 900)
		{
			iFrameHeight = (iClientHeight - 220)
		}
		else
		{
			iFrameHeight = (iClientHeight - 150)*0.75;
		}*/
		iFrameHeight = (iClientHeight - 220);
	}
	
	/*
	** [PSK 02-Sep-2006] [PQS37PK336]
	** Added not null validation for html objects.
	*/
	if(null != divScrollable && null != divFixedTblContainer)
	{
	    if(0 < iFrameHeight)
	    {
		    divScrollable.style.height = iFrameHeight + "px";				
	    }
	    if(0 < iFrameWidth)
	    {
		    divScrollable.style.width  = iFrameWidth + "px";			
    		
		    /*
		    ** set the size of the fixed table header div, -20.5 is for the scrollbar space.
		    */
		    if(divFixedTblContainer && (16 < iFrameWidth))
		    {			
			    //divFixedTblContainer.style.width  = (iFrameWidth-20.5) + "px";			
			    divFixedTblContainer.style.width  = (iFrameWidth-16) + "px";			
		    }
	    }
    }
	
	/*if(0 == divScrollable.scrollHeight)
	{
		divFixedTblContainer.style.visibility = "hidden";	
		//divFixedTblContainer.style.width = "100%";
	}
	else
	{
		divFixedTblContainer.style.visibility = "visible";		
	}*/
	
}

g_bottomFrame = false;

var g_bFriendly = true;
function TogglePrinterFriendlyDiv()
{
	var divScrollable   = document.getElementById("ScrollableDiv");
	var divFixedTblContainer = document.getElementById("divFixedTblContainer");
	
	if(g_bFriendly)
	{
		divScrollable.style.overflow = "visible";
		if(divFixedTblContainer)
		{
			divFixedTblContainer.style.visibility = "hidden"
		}
		//alert(parent.style.overflow);
		//alert(document.style.overflow);
	}
	else
	{
		divScrollable.style.overflow = "auto";
		if(divFixedTblContainer)
		{
			divFixedTblContainer.style.visibility = "visible"
		}
	}
	
	g_bFriendly=!g_bFriendly;
}

function ProcessFrameDivResize()
{			
	var iFrameHeight	= 200;
	var iFrameWidth		= 200;
	
	var divScrollable			= document.getElementById("ScrollableDiv");
	var divFixedTblContainer	= document.getElementById("divFixedTblContainer");
	var divTabsDiv				= document.getElementById("TabsDiv");
	
	var Browser			= new IXBrowser();
	var iBrowserType	= Browser.GetBrowserType();
	var iClientHeight;
	var iClientWidth;
	var extraPadding = 0;
	/*
	** extra padding because of the tabs height
	*/
	if(divTabsDiv)
	{
		extraPadding = 30;
	}
	/*
	** to disable the scrollable div and display full text.
	*/
	/*
	if(disable == true)
	{
		document.all["ScrollableDiv"].style.overflow= "visible";				
	}*/

	switch(iBrowserType)
	{
		case BR_MICROSOFT:
			iClientHeight = document.body.clientHeight;
			iClientWidth  = document.body.clientWidth;
			break;
		case BR_NETSCAPE6:					
			iClientHeight = window.innerHeight;
			iClientWidth  = window.innerWidth;			
			break;
		default:
			alert('unsupported browser');
			break;
	}	
	iFrameWidth = (iClientWidth);
	if(g_bottomFrame)
	{
		iFrameHeight = (iClientHeight - 33-extraPadding);
	}
	else
	{
		iFrameHeight = (iClientHeight - 33-extraPadding);
	}
	
	if(0 < iFrameHeight)
	{
		divScrollable.style.height = iFrameHeight + "px";	
	}
	
	if(0 < iFrameWidth)
	{
		divScrollable.style.width  = iFrameWidth + "px";	
		/*
		** set the size of the fixed table header div, -20.5 is for the scrollbar space.
		*/
		if(divFixedTblContainer && (18 < iFrameWidth))
		{			
			divFixedTblContainer.style.width  = (iFrameWidth-18) + "px";			
		}		
	}
	if(divTabsDiv && document.all['upTbl'])
	{
		cloneFrameDocListHeader(currentPanel);
	}	
	if(divTabsDiv)
	{ 
		checkScrollButtonsVisibility();
	}
	//window.status= document.body.clientWidth + ',' + document.body.clientHeight;
}

/*
** Filter Member List Constants
*/
var SORT_NAME       = "SortName";
var SORT_DEPT       = "SortDept";
var ESCL_SORT_NAME	= "EsclSortName";
var ESCL_SORT_DEPT	= "EsclSortDept";

function FilterMemberLists()
{
	var objForm    = document.forms[FORM_SORTUSERS];
	var oProcTypes = g_formCollaborate.elements("PROCTYPE");
	var i          = 0;

	/*
	** Send the ProcessType/RequestType/ClosureType, so
	** the user doesn't have to reselect.
	*/
	while(i < oProcTypes.length)
	{
		if(oProcTypes[i].checked)
		{			
			objForm.PROCTYPE.value 	= oProcTypes[i].value;
		}
		
		i++;
	}
		
	objForm.REQTYPE.value			= g_formCollaborate.REQTYPE.value;
	objForm.CLOSEID.value			= g_formCollaborate.CLOSEID.value;
	
	/*
	** Org/Dept selection
	*/
	objForm.ORGANIZATION.value	    = g_formCollaborate.ORGANIZATION.value;
	objForm.DEPARTMENT.value    	= g_formCollaborate.DEPARTMENT.value;
	
	/*
	** User list sorting
	*/
	objForm.SortBy.value	        = g_formCollaborate.elements("Sort By")[0].checked ? SORT_NAME : SORT_DEPT;
	
	objForm.ESCL_NOTIFYBY.value			= g_formCollaborate.ESCL_NOTIFYBY.value;
	objForm.ESCL_ORGANIZATION.value	    = g_formCollaborate.ESCL_ORGANIZATION.value;
	objForm.ESCL_DEPARTMENT.value    	= g_formCollaborate.ESCL_DEPARTMENT.value;
	objForm.EsclSortBy.value	        = g_formCollaborate.elements("Escl Sort By")[0].checked ? ESCL_SORT_NAME : ESCL_SORT_DEPT;
	/*
	** Roles/Workgroups checkbox
	*/
	if(g_formCollaborate.WIS_ShowRolesWorkgroups.checked)
	{
		objForm.WIS_ShowRolesWorkgroups.value =  "1";
	}
	else
	{
		objForm.WIS_ShowRolesWorkgroups.value = "0";
	}
	
	/*
	** Advanced Flow Properties checkbox
	*/
	if(null != g_formCollaborate.WIS_ShowAdvancedFlowProperties)
	{
		if(g_formCollaborate.WIS_ShowAdvancedFlowProperties.checked)
		{
			objForm.WIS_ShowAdvancedFlowProperties.value =  "1";
		}
		else
		{
			objForm.WIS_ShowAdvancedFlowProperties.value = "0";
		}
	}
	
	objForm.PRIORITY.value		= g_formCollaborate.PRIORITY.options(g_formCollaborate.PRIORITY.selectedIndex).text;		
	objForm.DATE.value			= g_formCollaborate.DATE.options(g_formCollaborate.DATE.selectedIndex).text;	
	objForm.DATEOVERRIDE.value	= g_formCollaborate.DATEOVERRIDE.value;	
	if(g_formCollaborate.SUBAUTH)
	{
		objForm.SUBAUTH.value		= g_formCollaborate.SUBAUTH.options(g_formCollaborate.SUBAUTH.selectedIndex).text;	
	}
	objForm.TASKMEMO.value		= g_formCollaborate.TASKMEMO.value;	
	if(objForm.FLDMEMO && g_formCollaborate.FLDMEMO)
	{
		objForm.FLDMEMO.value		= g_formCollaborate.FLDMEMO.value;	
	}
	
	if(objForm.COMMENT_SUBJ && g_formCollaborate.COMMENT_SUBJ)
	{
		objForm.COMMENT_SUBJ.value		= g_formCollaborate.COMMENT_SUBJ.value;	
	}
	if(objForm.COMMENT_MSG && g_formCollaborate.COMMENT_MSG)
	{
		objForm.COMMENT_MSG.value		= g_formCollaborate.COMMENT_MSG.value;	
	}
		
	
	if(null != g_formCollaborate.SENDMAIL)
	{
		if(g_formCollaborate.SENDMAIL.checked)
		{
			objForm.SENDMAIL.value =  "1";
		}
		else
		{
			objForm.SENDMAIL.value = "0";
		}	
	}
	if(null != g_formCollaborate.CLOSEITEM)
	{
		if(g_formCollaborate.CLOSEITEM.checked)
		{
			objForm.CLOSEITEM.value =  "1";
		}
		else
		{
			objForm.CLOSEITEM.value = "0";
		}	
	}
	
	/*
	** Submit!
	*/
	objForm.submit();
}

function FilterMemberListsEx()
{
	CopyFormAndSubmit(FORM_COLLABORATE);
}


function CopyFormAndSubmit(strSrcForm, strMethod)
{
	/*
	** Local Variables
	*/
	var strNewSearch = "";
	var strValue     = "";
	var oSrcItem     = null;
	var i            = 0;
	
	var oLoc         = window.location;
	var strSearch    = oLoc.search;
	var aTuples      = strSearch.split("&");
	var aMethod      = aTuples[0].split("=");
	var strMethod    = aMethod[1];
	
	var frmSrc       = document.forms[strSrcForm];
	var aSrcItems    = frmSrc.elements;
	
	/*
	** Loop through the items
	*/	
	while(i < aSrcItems.length)
	{
		oSrcItem = aSrcItems.item(i);
		if(null == oSrcItem)
		{
			alert(i + " not found in source form!");
		}
		
		/*
		** Copy the data
		*/
		if(null     != oSrcItem)
		{
			strValue  = "";
			if("METHOD" == oSrcItem.name)
			{
				strValue = strMethod;
			}
			else if("input" == oSrcItem.tagName.toLowerCase())
			{
				if("checkbox" == oSrcItem.type.toLowerCase())
				{
					if(oSrcItem.checked)
					{
						strValue = oSrcItem.value;
						if(0 == strValue.length)
						{
							strValue = F_ON;
						}
					}
				}
				else if("radio" == oSrcItem.type.toLowerCase())
				{
					if(oSrcItem.checked)
					{
						strValue = oSrcItem.value;
					}
				}
				else
				{
					strValue = oSrcItem.value;
				}
			}
			else if("select" == oSrcItem.tagName.toLowerCase())
			{
				if(-1 != oSrcItem.selectedIndex)
				{
					var oOption = oSrcItem.options(oSrcItem.selectedIndex);
					strValue = oOption.value;
					if(0 == strValue.length)
					{
						strValue = oOption.innerText;
					}
				}
			}

			/*
			** Concat the value
			*/	
			if(undefined != strValue && 
			   null      != strValue &&
			   0 < strValue.length)
			{
				strNewSearch += oSrcItem.name;
				strNewSearch += "=";
				strNewSearch += encodeURIComponent(strValue);
				strNewSearch += "&";
			}
		}
		
		/*
		** Increment
		*/
		i++;
	}
	
	/*
	** Submit the destination form
	*/
	var strUrl = oLoc.protocol + "//" + oLoc.host + oLoc.pathname + "?" + strNewSearch;
	alert(strUrl);
	oLoc.replace(strUrl);
}

/*
** ShowRolesWorkgroups constants
*/
var CSS_TROWHIDDEN                          = "NFyiTrHidden";
var CSS_TROWVISIBLE                         = "NFyiTrVisible";
var ID_WORKGROUPS                           = "TR_WORKGROUPS";
var ID_ROLES                                = "TR_ROLES";
var ID_ADVANCEDFLOWPROPS1                   = "TR_ADVANCEDFLOWPROPS1";
var ID_ADVANCEDFLOWPROPS2                   = "TR_ADVANCEDFLOWPROPS2";
var FORM_COLLABORATE                        = "NETFYI_FORM_COLLABORATE";
var FORM_SORTUSERS                          = "NETFYI_FORM_SORTUSERS"
var FORM_EMAILINFO                          = "NETFYI_FORM_EMAILINFO"
var F_ON                                    = "ON";
var g_formCollaborate                       = null;
var g_bSubProcTmpl_ShowingRolesWorkgroups   = false;
var g_bAdHocTmpl_ShowingAdvancedFlowProps   = false;

/*
******************************************************************
**
** FUNCTION: InitAdHocProc 
**
** DESCRIPTION: [PSK] PQS-55241
** There are two checkboxes in this form that shows/hides other fields.  This function checks the current status
** of the check boxes, and shows/hides the fields accordingly.  Invokes onload event of the page.  
**
** Previously if the check box is "Checked" (which means the hidden fields are displayed), and when you navigate to 
** another button and returns to this page, the fields were still hidden even though the checkbox was CHECKED.
** This function was added to fix this issue.
*/
function InitAdHocProc()
{
	/*
	** Locals
	*/
	var aRows      = null;
	
	/*
	** SHOW HIDE Roles workgroups, get the status
	*/
	g_bSubProcTmpl_ShowingRolesWorkgroups = document.forms[FORM_COLLABORATE].WIS_ShowRolesWorkgroups.checked;
	
	/*
	** Get the fields that has to be shown/hidden
	*/
	aRows = new Array();
	aRows[0] = document.getElementById(ID_ROLES);
	aRows[1] = document.getElementById(ID_WORKGROUPS);			
	
	/*
	** I am using the exisitng function ShowHideTableRows which toggles the visilbility. Hence passing in 
	** the NOT value of g_bSubProcTmpl_ShowingRolesWorkgroups, so that the visibility will be set according to our check.
	*/
	ShowHideTableRows(aRows, !g_bSubProcTmpl_ShowingRolesWorkgroups);
	
	/*
	** Follow the same process for the Advanced Properties. First get the current status.
	*/
	g_bAdHocTmpl_ShowingAdvancedFlowProps = document.forms[FORM_COLLABORATE].WIS_ShowAdvancedFlowProperties.checked;
	
	/*
	** Get the fields.
	*/
	aRows = new Array();
	aRows[0] = document.getElementById(ID_ADVANCEDFLOWPROPS1);
	aRows[1] = document.getElementById(ID_ADVANCEDFLOWPROPS2);			
	ShowHideTableRows(aRows, !g_bAdHocTmpl_ShowingAdvancedFlowProps);
}

function ShowRolesWorkgroups()
{
	var i          = 0;
	var aRows      = new Array();
		aRows[i++] = document.getElementById(ID_ROLES);
		aRows[i++] = document.getElementById(ID_WORKGROUPS);			
		
	g_bSubProcTmpl_ShowingRolesWorkgroups = ShowHideTableRows(aRows, 
	                                                          g_bSubProcTmpl_ShowingRolesWorkgroups);
}

function ShowAdvancedFlowProps()
{	
	var i          = 0;
	var aRows      = new Array();
		aRows[i++] = document.getElementById(ID_ADVANCEDFLOWPROPS1);
		aRows[i++] = document.getElementById(ID_ADVANCEDFLOWPROPS2);			
		
	g_bAdHocTmpl_ShowingAdvancedFlowProps = ShowHideTableRows(aRows, 
	                                                          g_bAdHocTmpl_ShowingAdvancedFlowProps);
}

function ShowHideTableRows(arrayRows, bShowing)
{
	var i        = 0;
	var strClass = CSS_TROWHIDDEN;

	/*
	** If not currently showing
	** then set the CSS class to visible
	*/
	if(!bShowing)
	{
		strClass = CSS_TROWVISIBLE
	}
	
	/*
	** Loop though the rows
	*/
	while(i < arrayRows.length)
	{
		if(null != arrayRows[i])
		{
			arrayRows[i].className = strClass;
		}
		
		/*
		** Increment the counter
		*/
		i++;
	}

	/*
	** Toggle the flag
	*/	
	bShowing = !bShowing;

	/*
	** Return
	*/
	return bShowing;
}

var ID_RETURNCOUNT  = "ID_RETURNCOUNT";
var F_PARENT_PARENT = 2;
var F_PARENT        = 1;
var F_SELF          = 0;
function SfReturnCount_Update(eSpanLocation, strTxt)
{
	/*
	** Local Variables
	*/
	var parentDoc     = null;
	var spanItemCount = null;
	var txtNode       = null;
	
	/*
	** Depends on the location
	*/
	switch(eSpanLocation)
	{
		case(F_PARENT_PARENT):
		{
			parentDoc     = window.parent.parent.document;	
		}
		break;
	
		case(F_PARENT):
		{
			parentDoc     = window.parent.document;	
		}
		break;

		default:		
		case(F_SELF):
		{
			parentDoc     = window.document;	
		}
		break;
	}

	/*
	** Get and make the nodes in the proper frame
	*/
	if(null != parentDoc)
	{
		spanItemCount = parentDoc.getElementById(ID_RETURNCOUNT);
		txtNode       = parentDoc.createTextNode(strTxt);
	}

	/*
	** Get ready to set the return count
	*/
	if(null == spanItemCount)
	{
		/*
		** No place to put the Return Count
		*/
	}
	else
	{
		/*
		** Remove old children (that may be present due
		** to worklist autorefresh, or user clicked 'Refresh All' button
		*/
		if(spanItemCount.hasChildNodes())
		{
			var iItem  = 0;
			var iCount = spanItemCount.childNodes.length;
			while(iItem < iCount)
			{
				spanItemCount.removeChild(spanItemCount.lastChild);
				iItem++;
			}
		}
		
		spanItemCount.appendChild(txtNode);
	}
}


/*
** used to select the row of the folder/document/worklist.
*/
function clickIt(srcElement,cssClassName,bNoFix)  
{	
	/*
	** PQS37PK116
	*/
	
	if(true != bNoFix)
	{
		if(srcElement.checked)
		{
			srcElement.id = srcElement.id + ';fix0';
			srcElement.name = srcElement.name + ';fix0';		
		}
		else
		{
			varFix = srcElement.id.split(";fix0");
			if(varFix.length > 1)
			{
				srcElement.id = varFix[0];			
				srcElement.name = varFix[0];	
			}
		}
	}
	tableRowElement = srcElement.parentElement.parentElement;				
	if(tableRowElement.tagName == "TR")
	{					
		if(tableRowElement.getAttribute("className",0) == "NFyiTrFListRowAlt" || 
			(tableRowElement.getAttribute("className",0) == "NFyiTrFListRow") ||
			(tableRowElement.getAttribute("className",0) == "NFyiTrDListRow") ||
			(tableRowElement.getAttribute("className",0) == "HiliteStyle"))						
		{
			var backgroundColor = ("<!--NETFYI_HILITE_COLOR-->");
			backgroundColor = backgroundColor.toLowerCase();
			/*
			** if its while color then disable the hightlighting.
			*/
			if(backgroundColor != "#ffffff")
			{
				if(srcElement.checked)
				{							
					tableRowElement.setAttribute("className","HiliteStyle",0)											
				}
				else
				{							
					tableRowElement.setAttribute("className",cssClassName,0)											
				}
				//if(tableRowElement.style.background == backgroundColor)
				/*if(tableRowElement.getAttribute("className",0) == "HiliteStyle")
				{						
					tableRowElement.setAttribute("className",cssClassName,0)					
				}
				else
				{					
					//tableRowElement.style.background= "<!--NETFYI_HILITE_COLOR-->"
					tableRowElement.setAttribute("className","HiliteStyle",0)
				}*/					
			}
		}
	}				
}		
/*
** called when you double click on the window.
** This function is used to select the folder/document from the 
** list to highlight the row.
*/
function dblClickOnBody()
{
	tableRowElement = window.event.srcElement.parentElement;
	/*
	** check if the user clicked on a table column and the parent is a table row with Alt Key pressed.
	*/				
	if(window.event.srcElement.tagName=="TD" && tableRowElement.tagName == "TR" && window.event.altKey == true)
	{			
		/*
		** check if the user clicked on the folder/document list
		*/
		if(tableRowElement.childNodes.length)
		{
			var chkBox = tableRowElement.childNodes(0);		
			/*
			** if clicked on the list then the first item would be a checkbox of clipboard selection.
			*/				
			if(chkBox.childNodes.length > 0 && chkBox.childNodes(0).type == "checkbox")
			{					
				/*
				** imitate onclick of the checkbox to highlight the row.
				*/
				chkBox.childNodes(0).click();				
				return;
			}
		}
	}		
	window.event.returnValue = true;
}

function SetCookie(sName, sValue, sExpires)
{		
	/*
	** set the passed in info as the document cookie.
	*/
	document.cookie = sName + "=" + escape(sValue) + sExpires;
	//+ ";	expires=Mon, 31 Dec 1999 23:59:59 UTC;";
}

/*
** Retrieve the value of the cookie with the specified name.
*/
function GetCookie(sName)
{
	/*
	** cookies are separated by semicolons
	*/
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		/*
		** a name/value pair (a crumb) is separated by an equal sign
		*/
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		{
			return unescape(aCrumb[1]);
		}
	}

	/*
	** a cookie with the requested name does not exist
	*/
	return null;
}
/*
** called from the onload if the folder/worklist
** this fn is called to highlight the document row, which was last opened.
*/
var g_onLoadfunction = null;
var g_LastDocOpenPanelNum = null;
var g_DocCentricSearch	  = false;
/*
** called from showpanel
*/
function HighLightLastDocRowInFrameMode(cLifeCycle,panelNum, sStyle)
{
	var strCookieName;
	var checkBoxElement; 	
	
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedDocRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedDocRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedDocRow";		
	}
	
	downTable = document.all['DownTbl'+panelNum];
	if(downTable)	
	{
		checkBoxElement = downTable.all[GetCookie(strCookieName)];		
	}
	if(checkBoxElement)
	{
		/*
		** change the color style of the row to the LastVisitedSytle(lightyellow).
		*/				
		if(sStyle)
		{
			ChangeColorStyleOfLastRow(checkBoxElement,sStyle);
		}
		else
		{
			g_LastDocOpenPanelNum = currentPanel;			
			ChangeColorStyleOfLastRow(checkBoxElement,"LastVisitedStyle");
		}
	}		
}

function GetLastHighLightDocRow(cLifeCycle)
{		
	
	var strCookieName;
	
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedDocRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedDocRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedDocRow";		
	}
	
	/*
	** get the cookie value of LastVisitedDocRow, which is the checkbox id
	** of the last opened document row.
	*/
	//var checkBoxElement = document.getElementById(GetCookie("LastVisitedDocRow"));
	var checkBoxElement; 	
	if(document.all['upTbl'])
	{		
		var downTable = null;
		var oObject = document.all.item("NonFrameDocDownTbl");
		if(oObject == null && g_DocCentricSearch)
		{
			oObject = document.all.item("DownTbl");		
		}
		if (oObject != null)
		{		
			if (oObject.length != null)
			{				
				for (i = 0; i < oObject.length; i++)
				{
					downTable = oObject(i);					
					checkBoxElement = downTable.all[GetCookie(strCookieName)];						
				}
				downTable = null;
			}
			/*else
			{
				alert(oObject.tagName);
				downTable = oObject;
			}*/
		} 
		
		//downTable = document.all['NonFrameDocDownTbl'];		
		if(null == downTable)
		{
			downTable = document.all['DownTbl'];
		}					
		if(downTable)	
		{
			checkBoxElement = downTable.all[GetCookie(strCookieName)];		
		}
	}
	else
	{
		checkBoxElement = document.getElementById(GetCookie(strCookieName));		
	}
	
	return checkBoxElement;
}
function HighLightLastDocRow(cLifeCycle)
{		
	if(g_onLoadfunction != null)
	{
		var fnString = "function";
		g_onLoadfunction = g_onLoadfunction.toString();
		var sLoadfn = g_onLoadfunction.substring(fnString.length,g_onLoadfunction.length);	
		eval(sLoadfn);
	}
	var strCookieName;
	
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedDocRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedDocRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedDocRow";		
	}
	
	/*
	** get the cookie value of LastVisitedDocRow, which is the checkbox id
	** of the last opened document row.
	*/
	//var checkBoxElement = document.getElementById(GetCookie("LastVisitedDocRow"));
	var checkBoxElement; 	
	if(document.all['upTbl'])
	{		
		var downTable = null;
		var oObject = document.all.item("NonFrameDocDownTbl");
		if(oObject == null && g_DocCentricSearch)
		{
			oObject = document.all.item("DownTbl");		
		}
		if (oObject != null)
		{		
			if (oObject.length != null)
			{				
				for (i = 0; i < oObject.length; i++)
				{
					downTable = oObject(i);					
					checkBoxElement = downTable.all[GetCookie(strCookieName)];
					if(checkBoxElement)
					{
						/*
						** change the color style of the row to the LastVisitedSytle(lightyellow).
						*/								
						ChangeColorStyleOfLastRow(checkBoxElement,"LastVisitedStyle");
					}	
				}
				downTable = null;
				checkBoxElement = null;
			}
			/*else
			{
				alert(oObject.tagName);
				downTable = oObject;
			}*/
		} 
		
		//downTable = document.all['NonFrameDocDownTbl'];		
		if(null == downTable)
		{
			downTable = document.all['DownTbl'];
		}					
		if(downTable)	
		{
			checkBoxElement = downTable.all[GetCookie(strCookieName)];		
		}
	}
	else
	{
		checkBoxElement = document.getElementById(GetCookie(strCookieName));		
	}
	
	if(checkBoxElement)
	{
		/*
		** change the color style of the row to the LastVisitedSytle(lightyellow).
		*/		
		//ChangeColorStyleOfLastFoldRow(checkBoxElement);
		ChangeColorStyleOfLastRow(checkBoxElement,"LastVisitedStyle");
	}	
	HighLightLastFoldRow(cLifeCycle);
}

function HighLightRowAndOpenDoc(srcElement, sDocURL,cLifeCycle)
{
	var strCookieName;
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedDocRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedDocRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedDocRow";		
	}
	tableRowElement = srcElement.parentElement.parentElement;				
	
	if(tableRowElement.childNodes.length)
	{
		var chkBox = tableRowElement.childNodes(0);								
		if(chkBox.childNodes.length > 0 && chkBox.childNodes(0).type == "checkbox")
		{	
			/*
			** if called from doc frames mode
			*/
			if(g_DocsFrameMode)
			{
				if(g_LastDocOpenPanelNum)
				{
					/*
					** if doc is already opened
					*/
					HighLightLastDocRowInFrameMode(cLifeCycle,g_LastDocOpenPanelNum,"NFyiTrDListRow");
					g_LastDocOpenPanelNum = currentPanel;
				}
				else
				{
					/*
					** assign the current panel num.
					*/ 
					g_LastDocOpenPanelNum = currentPanel;
				}
			
			}
			else
			{		
				var	lastCheckBoxElement = GetLastHighLightDocRow(cLifeCycle);
				if(lastCheckBoxElement)
				{
					tableRowElement = lastCheckBoxElement.parentElement.parentElement;		
					RestoreColorStyleOfLastRow(tableRowElement,"NFyiTrDListRow");
				}
			}
			SetCookie(strCookieName,chkBox.childNodes(0).id,"");
			ChangeColorStyleOfLastRow(srcElement,"LastVisitedStyle");
			/*
			** if shift key is pressed then do not change the location.
			*/
			if(!window.event.shiftKey)
			{
				/*
				** No need to set the location
				*/
				//document.location = sDocURL;		
			}
		}
	}
}
var lastFoldRowElement = null;
var lastFoldRowElementClass = null;

function HighLightLastFoldRow(cLifeCycle)
{			
	/*if(g_onLoadfunction != null)
	{
		var fnString = "function";
		g_onLoadfunction = g_onLoadfunction.toString();
		var sLoadfn = g_onLoadfunction.substring(fnString.length,g_onLoadfunction.length);	
		eval(sLoadfn);
	}*/
	/*
	** get the cookie value of LastVisitedDocRow, which is the checkbox id
	** of the last opened document row.
	*/
	
	// Get the currently selected WKEY
	var iWKey = 0;
	var bIsWL = false;
	
	if (document.forms['NETFYI_FORM_REFRESH'] && document.forms['NETFYI_FORM_REFRESH'].SelWKey != null)
	{		
		iWKey = document.forms['NETFYI_FORM_REFRESH'].SelWKey.value;
		bIsWL = true;
	}
	else
	{
		if(document.forms['NETFYI_FORM_REFRESH'] && document.forms['NETFYI_FORM_REFRESH'].SelFKey)
		{
			iWKey = document.forms['NETFYI_FORM_REFRESH'].SelFKey.value;
		}
	}
	/*if(0 == iWKey)
	{
		if (document.forms['NETFYI_FORM_REFRESH'] && document.forms['NETFYI_FORM_REFRESH'].WKey != null)
		{		
			iWKey = document.forms['NETFYI_FORM_REFRESH'].WKey.value;
			bIsWL = true;
		}
		else
		{
			if(document.forms['NETFYI_FORM_REFRESH'] && document.forms['NETFYI_FORM_REFRESH'].FKey)
			{
				iWKey = document.forms['NETFYI_FORM_REFRESH'].FKey.value;
			}
		}
	}*/
	//alert(iWKey);
	// If the WKEY is not null and a value greater than zero		
	if(null != iWKey && iWKey > 0)
	{		
		// Next find the row in the folder table
		var anc = document.anchors(iWKey);		
		if(null != anc)
		{
			//navigate to the desired anchor
			
			if (bIsWL)
			{
				if(anc.length)
				{	
					anc[1].scrollIntoView(false);
					anc[1].parentNode.parentNode.focus();
					anc[1].parentNode.focus();
				}
				else
				{
					anc.scrollIntoView(true);
					anc.parentNode.parentNode.focus();
					anc.parentNode.focus();
				}
			}
			else
			{
				if(anc.length)
				{	
					anc[1].scrollIntoView(false);
					anc[1].parentNode.parentNode.focus();
					anc[1].parentNode.focus();
				}
				else
				{
					anc.scrollIntoView(true);
					anc.parentNode.parentNode.focus();
					anc.parentNode.focus();
				}
			}
			
			//DEBUG STATEMENT
			//alert(anc.parentNode.parentNode.tagName);
			
			// Highlight the row for greater visibility.
			//anc.parentNode.parentNode.style.backgroundColor = "#D1FFD1";									
		}
	}
	
	var strCookieName;
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedFoldRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedFoldRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedFoldRow";		
	}
	
	var checkBoxElement; 	
	if(document.all['upTbl'])
	{
		downTable = document.all['NonFrameDownTbl'];		
		if(null == downTable)
		{			
			/*var oObject = document.all.item("DownTbl");
			alert(oObject.length);*/
			downTable = document.all['DownTbl'];
		}
		if(downTable)
		{
			checkBoxElement = downTable.all[GetCookie(strCookieName)];		
		}
	}
	else
	{
		checkBoxElement = document.getElementById(GetCookie(strCookieName));
	}
	
	if(checkBoxElement)
	{
		var tableRowElement = checkBoxElement.parentElement.parentElement;				
		lastFoldRowElement = tableRowElement;
		lastFoldRowElementClass = lastFoldRowElement.className;
		
		/*
		** change the color style of the row to the LastVisitedSytle(lightyellow).
		*/		
		//ChangeColorStyleOfLastFoldRow(checkBoxElement);
		ChangeColorStyleOfLastRow(checkBoxElement,"FoldLastVisitedStyle");
	}
}
function HighLightRowAndOpenFold(srcElement, sFoldURL, cLifeCycle)
{	
	var strCookieName;
	if(cLifeCycle == 'L')
	{
		strCookieName = "LibLastVisitedFoldRow";	
	}
	else
	if(cLifeCycle == 'W')
	{
		strCookieName = "MgmtLastVisitedFoldRow";	
	}
	else
	{
		strCookieName = "InBoxLastVisitedFoldRow";		
	}
	tableRowElement = srcElement.parentElement.parentElement;				
	
	if(lastFoldRowElement)
	{
		RestoreColorStyleOfLastRow(lastFoldRowElement,lastFoldRowElementClass);
		lastFoldRowElement = tableRowElement;
		lastFoldRowElementClass = lastFoldRowElement.className;
	}
	else
	{	
		lastFoldRowElement = tableRowElement;
		lastFoldRowElementClass = lastFoldRowElement.className;
	}
	if(tableRowElement.childNodes.length)
	{
		var chkBox = tableRowElement.childNodes(0);								
		if(chkBox.childNodes.length > 0 && chkBox.childNodes(0).type == "checkbox")
		{	
			RestoreColorStyleOfLastRow(tableRowElement,"NFyiTrFListRow");		
			SetCookie(strCookieName,chkBox.childNodes(0).id,"");
			ChangeColorStyleOfLastRow(srcElement,"FoldLastVisitedStyle");
			/*
			** if shift key is pressed then do not change the location.
			*/
			if(!window.event.shiftKey)
			{
				/*
				** No need to set the location
				*/
				//document.location = sDocURL;		
			}
		}
	}
}
/*
** changes the color the row of the sent element with the selectstyle color
** used to highlight the row
*/
function ChangeColorStyleOfLastRow(srcElement, sStyle)
{		
	tableRowElement = srcElement.parentElement.parentElement;
	if(tableRowElement.tagName == "TR")
	{	
		tableRowElement.setAttribute("className",sStyle,0);		
	}					
}
/*
** Restores the color the row of the sent element with the NFyiTrDListRow color
** used for document row.
*/
function RestoreColorStyleOfLastRow(tableRowElement, sStyle)
{		
	if(tableRowElement)
	{
	
		//tableRowElement = tableRowElement.parentElement.parentElement;
		if(tableRowElement.tagName == "TR")
		{		
			/*
			** set the className to NFyiTrDListRow
			*/
			tableRowElement.setAttribute("className",sStyle,0);
		}					
	}
}
/*
** not used for now..
*/
function clickItReadonly()  
{		
	tableRowElement = window.event.srcElement.parentElement;		
	if(window.event.srcElement.tagName=="TD" && tableRowElement.tagName == "TR" && window.event.altKey == true)
	{			
		if(tableRowElement.getAttribute("className",0) == "NFyiTrFListRowAlt" || 
			(tableRowElement.getAttribute("className",0) == "NFyiTrFListRow") ||
			(tableRowElement.getAttribute("className",0) == "NFyiTrDListRow"))
		{
			var backgroundColor = ("<!--NETFYI_HILITE_COLOR-->");
			backgroundColor = backgroundColor.toLowerCase();
			if(tableRowElement.style.background == backgroundColor)
			{				
				//tableRowElement.style.background= tableRowElement.style.foreground
				//tableRowElement.style.foreground= "<!--NETFYI_HILITE_COLOR-->"				
				//tableRowElement.style.background = null
				
				tableRowElement.style.background = "";
				//tableRowElement.setAttribute("className","NFyiTrFListRowAlt",0)
				
				
			}
			else
			{					
				/*//alert(tableRowElement.getAttribute("className",0))
				if(tableRowElement.getAttribute("className",0) == "NFyiTrFListRowAlt")
				{					
					tableRowElement.setAttribute("className","NFyiTrFListRow", 0) 				
				}*/
				//tableRowElement.style.foreground= parentElement.style.background

				//tableRowElement.style.background= "<!--NETFYI_HILITE_COLOR-->"
				tableRowElement.style.background= "0xffd3ff"
			}
		}
	}		
	window.event.returnValue = true; 		
	//if ((window.event.srcElement.tagName) && ("A" + window.event.shiftKey))
	//{  
		
	//}
}

var g_LeftFrameShow;
function fnToggleLeftFrameScrollableDivMode()
{			
	fnToggleLeftFrame();
	ProcessDivResize();	
}
function fnSetToggleLeftFrame()
{
	g_LeftFrameShow = GetCookie("NetFYILeftFrame");	
	if(g_LeftFrameShow == null || g_LeftFrameShow == "visible")
	{
		g_LeftFrameShow = "hiddden";	
	}
	else
	{
		g_LeftFrameShow = "visible";
	}
	SetCookie("NetFYILeftFrame",g_LeftFrameShow,"");	
	fnToggleLeftFrame();
}
function fnToggleLeftFrame()
{	
	g_LeftFrameShow = GetCookie("NetFYILeftFrame");
	
	if(g_LeftFrameShow == null)
	{
		g_LeftFrameShow = "visible";	
	}	
	if(g_LeftFrameShow == "visible")
	{					
		document.getElementById("leftFrameHideDiv").style.visibility="visible";
		document.getElementById("leftFrameDiv").style.visibility="hidden";	
		document.getElementById("leftFrameDiv").style.position="absolute";	

		SetCookie("NetFYILeftFrame","hidden","");	
		g_NoSavedSearchFrame = true;				
	}
	else
	{
		document.getElementById("leftFrameHideDiv").style.visibility="hidden";
		document.getElementById("leftFrameDiv").style.visibility="visible";					
		document.getElementById("leftFrameDiv").style.position="static";				
		SetCookie("NetFYILeftFrame","visible","");	
		g_NoSavedSearchFrame = false;			
	}
}

function fnToggleLeftFrameInFramesMode()
{		
	fnToggleLeftFrame();
}
function HidePropertiesFrame()
{
	if(document.body && document.body.cols)
	{
		document.body.cols =  "100%,*";	
	}
}	

function HidePropertiesFrameAndRefresh()
{
	if(document.body && document.body.cols)
	{
		document.body.cols =  "100%,*";	
		FolderList.document.location = FolderList.document.location;
		DocList.document.location = DocList.document.location;
	}
	
}
function ShowPropertiesFrame(lifeCycle)
{

  if(document.body && document.body.cols)
  {
	var foldDocPropPaneCookie = "foldDocPropPaneCookie"+lifeCycle;
	var CookieVal = GetCookie(foldDocPropPaneCookie);	
	if(CookieVal && CookieVal.length)
	{	
		var ColWidths = "*,";
		ColWidths += CookieVal+"px";
		document.body.cols =  ColWidths;
	}			
	else
	{
		document.body.cols =  "50%,*";
	}
  }
  
}

function changeDocumentView( objComboBox, sUrl)
{
	if(-1 != objComboBox.selectedIndex)
	{
		var oOption = objComboBox.options(objComboBox.selectedIndex);
		strValue = oOption.value;
		if(0 == strValue.length)
		{
			strValue = oOption.innerText;
		}
		sUrl = sUrl +strValue;
		document.location = sUrl;
	}
	
}

/*
** function that clones the real header and changes 
** the original IDs (for not duplicate any IDs).
** close the tbody in the code..
*/
function cloneLibraryHeader()
{	
	if(document.all['FixedTblHead'])
	{
		/*
		** clone table head and the table body
		*/	
		var tableHead = document.all['FixedTblHead'].cloneNode(true);
		
		var tableBody = document.all['FixedTblBody'].cloneNode(true);
		
		/*
		** get the # of table columns
		*/
		var colCount = document.all['FixedTblHead'].rows(0).cells.length;
		
		/*
		** rename the columns so that there are no duplicates.
		*/
		document.all['hCLIPITEM'].id	= 'headCLIPITEM';
		document.all['hFOLDER'].id		= 'headFOLDER';
		document.all['hFOLDERINFO'].id	= 'headFOLDERINFO';
		document.all['hCOMMENTS'].id	= 'headCOMMENTS';
		document.all['hLOCKSTATUS'].id	= 'headLOCKSTATUS';
		/*
		** rename the body id.
		*/
		document.all['FixedTblBody'].id= 'headFixedTblBody';
		/*
		** hide the cloned body
		*/
		//tableBody.style.visibility="hidden";
		
		//document.all['headFixedTblBody'].style.visibility="hidden";
		
		/*
		**	rename the remaining column to avoid duplicates.
		*/
		for (var j = 5; j < colCount; j++)
		{	
			document.all['h'+j].id = 'head'+j;
		}
		/*
		** rename the table id.
		*/
		document.all['FixedTblHead'].id = "FixedTblHead4hidden";
			
		/*var divScrollable   = document.getElementById("ScrollableDiv");
		
		if(divScrollable)
		{
			if(0 == divScrollable.scrollHeight)
			{
				divFixedTblContainer.style.visibility = "hidden";	
				//divFixedTblContainer.style.width = "100%";
			}
			else
			{
				divFixedTblContainer.style.visibility = "visible";		
			}	
		}*/
		/*	
		** add the cloned table head and body to the fixed table, so that
		** they are always visible when scrolled.
		*/
		document.all['upTbl'].appendChild (tableHead);	
		document.all['upTbl'].appendChild (tableBody);
		
		/*document.all['upTbl'].width = document.all['FixedTblHead'].offsetWidth;
		document.all['upTbl'].style.width = document.all['FixedTblHead'].offsetWidth;	
		synchronizeHeader (colCount);
		*/
	}
}

/*
** function that clones the real header and changes 
** the original IDs (for not duplicate any IDs).
** close the tbody in the code..
*/
function cloneMgmtHeader()
{	
	if(document.all['FixedTblHead'])
	{
		/*
		** clone table head and the table body
		*/	
		var tableHead = document.all['FixedTblHead'].cloneNode(true);
		
		var tableBody = document.all['FixedTblBody'].cloneNode(true);
		
		/*
		** get the # of table columns
		*/
		var colCount = document.all['FixedTblHead'].rows(0).cells.length;
		
		/*
		** rename the columns so that there are no duplicates.
		*/
		document.all['hCLIPITEM'].id	= 'headCLIPITEM';
		document.all['hWI_INFO'].id		= 'headWI_INFO';
		document.all['hWI_INFO2'].id	= 'headWI_INFO2';
		document.all['hWI_DUEDATE'].id	= 'headWI_DUEDATE';
		document.all['hWI_TASKNAME'].id	= 'headWI_TASKNAME';
		document.all['hFOLDER'].id		= 'headFOLDER';
		document.all['hFOLDERINFO'].id	= 'headFOLDERINFO';
		document.all['hCOMMENTS'].id	= 'headCOMMENTS';
		document.all['hLOCKSTATUS'].id	= 'headLOCKSTATUS';
		
		/*
		** rename the body id.
		*/
		document.all['FixedTblBody'].id= 'headFixedTblBody';
		/*
		** hide the cloned body
		*/
		tableBody.style.visibility="hidden";
		
		//document.all['headFixedTblBody'].style.visibility="hidden";
		//alert(colCount);
		/*
		**	rename the remaining column to avoid duplicates.
		*/
		for (var j = 9; j < colCount; j++)
		{	
			document.all['h'+j].id = 'head'+j;
		}
		/*
		** rename the table id.
		*/
		document.all['FixedTblHead'].id = "FixedTblHead4hidden";
			
		/*	
		** add the cloned table head and body to the fixed table, so that
		** they are always visible when scrolled.
		*/
		document.all['upTbl'].appendChild (tableHead);	
		document.all['upTbl'].appendChild (tableBody);

		/*var divScrollable   = document.getElementById("ScrollableDiv");
		if(divScrollable)
		{
			if(0 == divScrollable.scrollHeight)
			{
				divFixedTblContainer.style.visibility = "hidden";	
				//divFixedTblContainer.style.width = "100%";
			}
			else
			{
				divFixedTblContainer.style.visibility = "visible";		
			}	
		}*/
		
		/*document.all['upTbl'].width = document.all['FixedTblHead4hidden'].offsetWidth;
		document.all['upTbl'].style.width = document.all['FixedTblHead'].offsetWidth;	
		synchronizeHeader (colCount);
		*/
	}
}

/*
** function that clones the real header and changes 
** the original IDs (for not duplicate any IDs).
** close the tbody in the code..
*/
function cloneWorkListHeader()
{	
	if(document.all['FixedTblHead'])
	{
		/*
		** clone table head and the table body
		*/	
		var tableHead = document.all['FixedTblHead'].cloneNode(true);
		
		var tableBody = document.all['FixedTblBody'].cloneNode(true);
		
		/*
		** get the # of table columns
		*/
		var colCount = document.all['FixedTblHead'].rows(0).cells.length;
		
		/*
		** rename the columns so that there are no duplicates.
		*/
		document.all['hCLIPITEM'].id	= 'headCLIPITEM';
		document.all['hWI_ITEM'].id		= 'headWI_ITEM';
		document.all['hWI_ITEM1'].id	= 'headWI_ITEM1';
		document.all['hWI_ITEM2'].id	= 'headWI_ITEM2';
		document.all['hWI_ITEM3'].id	= 'headWI_ITEM3';
		document.all['hWI_ITEM4'].id	= 'headWI_ITEM4';
		document.all['hFOLDER'].id		= 'headFOLDER';
		document.all['hFOLDER1'].id		= 'headFOLDER1';
		document.all['hFOLDER2'].id		= 'headFOLDER2';
		
		/*
		** rename the body id.
		*/
		document.all['FixedTblBody'].id= 'headFixedTblBody';
		/*
		** hide the cloned body
		*/
		tableBody.style.visibility="hidden";
		//alert(colCount);
		//document.all['headFixedTblBody'].style.visibility="hidden";
		
		/*
		**	rename the remaining column to avoid duplicates.
		*/
		for (var j = 10; j <= colCount; j++)
		{	
			document.all['h'+j].id = 'head'+j;
		}
		/*
		** rename the table id.
		*/
		document.all['FixedTblHead'].id = "FixedTblHead4hidden";
			
		/*	
		** add the cloned table head and body to the fixed table, so that
		** they are always visible when scrolled.
		*/
		document.all['upTbl'].appendChild (tableHead);	
		document.all['upTbl'].appendChild (tableBody);
		
		/*document.all['upTbl'].width = document.all['FixedTblHead'].offsetWidth;
		document.all['upTbl'].style.width = document.all['FixedTblHead'].offsetWidth;	
		synchronizeHeader (colCount);
		*/
	}
}

function cloneFrameDocListHeaderOld(panelNum)
{	
	/*
	** clone table head and the table body
	*/	
	var strFixedTblHead = 'FixedTblHead'+panelNum;
	var strFixedTblBody = 'FixedTblBody'+panelNum;
	var strheadFixedTblBody = 'headFixedTblBody' +panelNum;
	var strheadFixedTblHead = 'headFixedTblBody'+panelNum;
	var strFixedTblHead4hidden = 'FixedTblHead4hidden' + panelNum;
	
	var tableHead = document.all[strFixedTblHead].cloneNode(true);
	
	var tableBody = document.all[strFixedTblBody].cloneNode(true);
	//alert(document.all['upTbl'].children.length);		
	for(i = 0; i < document.all['upTbl'].children.length; i++)
	{
		//alert(document.all['upTbl'].children[i].tagName);		
		//alert(document.all['upTbl'].children[i].id);		
		//document.all['upTbl'].removeChild(document.all['upTbl'].children[i]);
	}
	/*
	** get the # of table columns
	*/
	var colCount = document.all[strFixedTblHead].rows(0).cells.length;
	
	/*
	** rename the columns so that there are no duplicates.
	*/
	document.all['hDOC_CLIPITEM'].id	= 'headDOC_CLIPITEM';
	/*
	** rename the body id.
	*/
	document.all[strFixedTblBody].id= strheadFixedTblBody;
	/*
	** hide the cloned body
	*/
	tableBody.style.visibility="hidden";
	
	//document.all['headFixedTblBody'].style.visibility="hidden";
	//alert(colCount);
	/*
	**	rename the remaining column to avoid duplicates.
	*/
	for (var j = 1; j < colCount-1; j++)
	{	
		document.all['hDoc'+j].id = 'head'+j;
	}
	/*
	** rename the table id.
	*/
	
	document.all[strFixedTblHead].id = strFixedTblHead4hidden;
		
	/*	
	** add the cloned table head and body to the fixed table, so that
	** they are always visible when scrolled.
	*/
	//alert(document.all['upTbl'].children.length);		
	for(i = 0; i < document.all['upTbl'].children.length; i++)
	{
		//alert(document.all['upTbl'].children[i].tagName);		
		//alert(document.all['upTbl'].children[i].id);		
		document.all['upTbl'].removeChild(document.all['upTbl'].children[i]);
	}
	//alert(document.all['upTbl'].children.length);	
	//alert(document.all['upTbl'].children[0].tagName);		
	//alert(document.all['upTbl'].children[0].id);			
	document.all['upTbl'].appendChild (tableHead);	
	document.all['upTbl'].appendChild (tableBody);

	/*var divScrollable   = document.getElementById("ScrollableDiv");
	if(divScrollable)
	{
		if(0 == divScrollable.scrollHeight)
		{
			divFixedTblContainer.style.visibility = "hidden";	
			//divFixedTblContainer.style.width = "100%";
		}
		else
		{
			divFixedTblContainer.style.visibility = "visible";		
		}	
	}*/
	//alert(strheadFixedTblBody);
	document.all['upTbl'].style.width = document.all[strheadFixedTblBody].offsetWidth;
	//alert(document.all[strheadFixedTblBody].offsetWidth);
	
	
	/*document.all['upTbl'].width = document.all[strFixedTblHead].offsetWidth;
	document.all['upTbl'].style.width = document.all[strFixedTblHead].offsetWidth;	
	synchronizeHeader (colCount);
	*/
}
/*
** this variable is set to true in FrameDocResults.tmpl
*/
var g_DocsFrameMode = false;
function cloneFrameDocListHeader(panelNum)
{		
	if(document.all['FixedTblHead'+panelNum])
	{
		/*
		** clone table head and the table body
		*/	
		var strFixedTblHead = 'FixedTblHead'+panelNum;
		var strFixedTblBody = 'FixedTblBody'+panelNum;
		var strheadFixedTblBody = 'headFixedTblBody' +panelNum;
		var strheadFixedTblHead = 'headFixedTblBody'+panelNum;
		var strFixedTblHead4hidden = 'FixedTblHead4hidden' + panelNum;
		/*
		** in thumbnail mode, header will not be there..
		*/
		if(document.all[strFixedTblHead])
		{
			var tableHead = document.all[strFixedTblHead].cloneNode(true);
			
			var tableBody = document.all[strFixedTblBody].cloneNode(true);
			
			/*
			** get the # of table columns
			*/
			var colCount = document.all[strFixedTblHead].rows(0).cells.length;
			
			var tableRec = tableHead.children[0];
			//alert(tableRec.children[0].id);
			/*
			** rename the columns so that there are no duplicates.
			*/
			///document.all['hDOC_CLIPITEM'].id	= 'headDOC_CLIPITEM';
			tableRec.children['hDOC_CLIPITEM'].id	= 'headDOC_CLIPITEM';
			/*
			** rename the body id.
			*/
			//document.all[strFixedTblBody].id= strheadFixedTblBody;
			
			tableBody.id = strheadFixedTblBody;
			/*
			** hide the cloned body
			*/
			tableBody.style.visibility="hidden";
			
			/*
			**	rename the remaining column to avoid duplicates.
			*/
			for (var j = 1; j < colCount-1; j++)
			{	
				//document.all['hDoc'+j].id = 'head'+j;
				tableRec.children['hDoc'+j].id	= 'head'+j;
			}
			/*
			** rename the table id.
			*/
			
			//document.all[strFixedTblHead].id = strFixedTblHead4hidden;
			
			tableHead.id =	strFixedTblHead4hidden;
			
			/*	
			** add the cloned table head and body to the fixed table, so that
			** they are always visible when scrolled.
			*/	
			document.all['upTbl'].appendChild (tableHead);	
			document.all['upTbl'].appendChild (tableBody);
				
			for(i = 0; i < document.all['upTbl'].children.length; i++)
			{	
				if(document.all['upTbl'].children[i].id != strheadFixedTblBody && document.all['upTbl'].children[i].id != strFixedTblHead4hidden)
				{	
					document.all['upTbl'].removeChild(document.all['upTbl'].children[i]);
					i--;
				}
			}	
			document.all['upTbl'].style.width = document.all[strFixedTblBody].offsetWidth;	
		}
		DocumentSorter();
	}
}

function cloneDocCentricListHeader()
{		
	var panelNum = '';
	if(document.all['FixedTblHead'])
	{
		/*
		** clone table head and the table body
		*/	
		var strFixedTblHead = 'FixedTblHead'+panelNum;
		var strFixedTblBody = 'FixedTblBody'+panelNum;
		var strheadFixedTblBody = 'headFixedTblBody' +panelNum;
		var strheadFixedTblHead = 'headFixedTblBody'+panelNum;
		var strFixedTblHead4hidden = 'FixedTblHead4hidden' + panelNum;
		/*
		** in thumbnail mode, header will not be there..
		*/
		if(document.all[strFixedTblHead])
		{
			var tableHead = document.all[strFixedTblHead].cloneNode(true);
			
			var tableBody = document.all[strFixedTblBody].cloneNode(true);
			
			/*
			** get the # of table columns
			*/
			var colCount = document.all[strFixedTblHead].rows(0).cells.length;
			
			var tableRec = tableHead.children[0];
			//alert(tableRec.children[0].id);
			/*
			** rename the columns so that there are no duplicates.
			*/
			///document.all['hDOC_CLIPITEM'].id	= 'headDOC_CLIPITEM';
			tableRec.children['hDOC_CLIPITEM'].id	= 'headDOC_CLIPITEM';
			/*
			** rename the body id.
			*/
			//document.all[strFixedTblBody].id= strheadFixedTblBody;
			
			tableBody.id = strheadFixedTblBody;
			/*
			** hide the cloned body
			*/
			tableBody.style.visibility="hidden";
			
			/*
			**	rename the remaining column to avoid duplicates.
			*/
			for (var j = 1; j < colCount-1; j++)
			{	
				//document.all['hDoc'+j].id = 'head'+j;
				tableRec.children['hDoc'+j].id	= 'head'+j;
			}
			/*
			** rename the table id.
			*/
			
			//document.all[strFixedTblHead].id = strFixedTblHead4hidden;
			
			tableHead.id =	strFixedTblHead4hidden;
			
			/*	
			** add the cloned table head and body to the fixed table, so that
			** they are always visible when scrolled.
			*/	
			document.all['upTbl'].appendChild (tableHead);	
			document.all['upTbl'].appendChild (tableBody);
				
			for(i = 0; i < document.all['upTbl'].children.length; i++)
			{	
				if(document.all['upTbl'].children[i].id != strheadFixedTblBody && document.all['upTbl'].children[i].id != strFixedTblHead4hidden)
				{	
					document.all['upTbl'].removeChild(document.all['upTbl'].children[i]);
					i--;
				}
			}	
			document.all['upTbl'].style.width = document.all[strFixedTblBody].offsetWidth;	
		}		
	}
}

function scrollFixedTblHeader()
{
	if(document.getElementById("divFixedTblContainer"))
	{
		//document.getElementById("divFixedTblContainer").style.visibility = "visible";		
		document.getElementById("divFixedTblContainer").scrollLeft = window.event.srcElement.scrollLeft;
	}
}



function RemoveSortIcons(panelNum)
{
    /*
    ** Locals
    */    
    var table   = document.all['UpTbl'];
    var bDone   = false;
    var bAsc    = true;    
    var downTable = null;
    var strFixedTblBody = 'FixedTblBody';
	
	/*if("upTbl" == table.id)
	{
		if(g_DocsFrameMode)
		{					
			downTable = document.all['DownTbl'+panelNum];
			strFixedTblBody += panelNum;
		}
		else
		{
			downTable = document.all['DownTbl'];
		}
	}*/				
	
	if(panelNum && document.all['FixedTblHead'+panelNum])
	{
		/*
		** clone table head and the table body
		*/	
		var strFixedTblHead = 'FixedTblHead'+panelNum;
		var strFixedTblHead4hidden = 'FixedTblHead4hidden' + panelNum;
		/*
		** in thumbnail mode, header will not be there..
		*/
		if(document.all[strFixedTblHead])
		{
			var tableHead = document.all[strFixedTblHead];
			
			/*
			** get the # of table columns
			*/
			var colCount = tableHead.rows(0).cells.length;
			
			var tableRec = tableHead.children[0];
			
			/*
			**	rename the remaining column to avoid duplicates.
			*/
			for (var j = 1; j < colCount-1; j++)
			{		
				var childNodeTH = tableRec.children['hDoc'+j]
				if(childNodeTH.childNodes.length > 2)
				{
					childNodeTH.removeChild(childNodeTH.lastChild);
					childNodeTH.removeChild(childNodeTH.lastChild);
				}
				else
				if(childNodeTH.childNodes.length > 1)
				{
					childNodeTH.removeChild(childNodeTH.lastChild);
				}
			}				
			//document.all['upTbl'].style.width = document.all[strFixedTblBody].offsetWidth;	
		}		
	}		
	g_primarySortColumn = null;
	g_secondSortColumn  = null;
	g_iSort_PrimaryColumnNdx = -1;
	g_iSort_SecondColumnNdx  = -1;
	g_iSort_SecondColumnNdxDownTbl = -1;
	g_bSort_PrimaryAscending = -1;
	g_bSort_SecondAscending  = -1;	
	g_iSort_PrimaryDataColumnNdx = -1; 
	g_iSort_SecondDataColumnNdx  = -1;
	
}

function CanShowModalDialog()
{
    /*
    ** Locals
    */    
    var appName = navigator.appName.toUpperCase();
    var appVer  = null;
    var iIndex  = -1;
    var fVer	= 0;

    if(-1 == appName.indexOf("MICROSOFT INTERNET EXPLORER"))
    {
        return false;
    }

    appVer = navigator.appVersion;
    iIndex = appVer.indexOf("(");

    if(-1 != iIndex)
    {
        appVer = appVer.substring(0,iIndex);
    }

    fVer = parseFloat(appVer);

    return (4 <= fVer);
}

function OpenHitViewer(strHitViewUrl)
{
    /*
    ** Locals
    */    
    var sFeatures  = "";
    var bShowDlg   = false;
    var hitViewWnd = null;

    /*
    ** [PSK 31-March-2007]
    ** Currently, HitView is not to be shown as a dialog.
    ** bShowDlg = CanShowModalDialog();
    */

    if(bShowDlg)
    {
        sFeatures  = "dialogHeight:400px; dialogWidth:800px; resizable:no; center:yes;";
        hitViewWnd = window.showModalDialog(strHitViewUrl,null,sFeatures);
    }
    else
    {
        sFeatures  = "directories=no,height=640,width=800,toolbar=no,menubar=no,scrollbars=no,top=1";
        hitViewWnd = window.open(strHitViewUrl,"_hitViewWnd",sFeatures);
        hitViewWnd.focus();
    }
}

