/*****************************************************************************
**  
**  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
    */
    var Frm             = document.forms[iForm];
    var Browser         = new IXBrowser();
    var iBrowserType    = Browser.GetBrowserType();
    var bOk             = TRUE;

    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) 
{
    /*
    **
    ** [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
    */
    var Frm             = document.forms[iForm];
    var Browser         = new IXBrowser();
    var iBrowserType    = Browser.GetBrowserType();
	/*
	** 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 )
{
	var clickItText;
	var tuples;
	var className="";
	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);
				}				
			}
		}
	}
}

/*
***************************************************************************
** 
** 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 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  = "name";
	this.m_iSortNdx        = -1;
}

ISortHtmlTableData.prototype.SetSortColumn        = ISortHtmlTableData_SetSortColumn;
ISortHtmlTableData.prototype.SortTable            = ISortHtmlTableData_SortTableData;
ISortHtmlTableData.prototype.GetSortColumnNdx     = ISortHtmlTableData_GetSortColumnNdx;
ISortHtmlTableData.prototype.GetDefaultColumnName = ISortHtmlTableData_GetDefaultColumnName;
ISortHtmlTableData.prototype.ArraySortFunction    = ISortHtmlTableData_ArraySortFunction;
ISortHtmlTableData.prototype.LinkTableHdr2Sort    = ISortHtmlTableData_LinkTableHdr2Sort;

/*
** 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";

/*
******************************************************************
**
** FUNCTION: DocumentSorter 
**
** DESCRIPTION: Sort documents in document tables
**
*/
function DocumentSorter()
{
	var strDTableClass = "nfyitabledlist";
	ApplyTableSortingByClass(strDTableClass, false);
}

/*
******************************************************************
**
** 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
    */
    while(i < iLength)
    {
        if(tables[i].className.toLowerCase() == strClassname)
        {
            oSorter.LinkTableHdr2Sort(tables[i]);
            oSorter.SortTable(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())
        {
            /*
            ** Save the cell index
            */
            this.m_iSortNdx = iDataCell;
            g_iSortHtmlTableData_ColumnNdx = this.m_iSortNdx;
            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_SortTableData 
**
** DESCRIPTION: Generic Table data sorting routine
**
*/
function ISortHtmlTableData_SortTableData(table, strSortOnColumn, bAsc, bAlert)
{ 
    /*
    ** Locals
    */
    var rows         = table.getElementsByTagName("tr");
    var iRow         = 0;
    var iTableRows   = rows.length;
    var newRows      = new Array();

	/*
	** Set our sort direction
	*/
	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);
	    }
        */
        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*/)
			{
				/*
				** Yes, then it is sortable
				*/
				cell.onclick      = OnTableDataSorterEvent;
				cell.style.cursor = "default";
				cell.title        = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;
				cell.setAttribute(SORT_ATTR, SORT_ASC);
			}

			/*
			** Increment the counter
			*/
			iCell++;
		}
	}
}

/*
*********************************************************************************
**
** FUNCTION: TableDataSorterEvent
**
**
*/
function OnTableDataSorterEvent()
{
    /*
    ** Locals
    */
    var _this   = event.srcElement;
    var table   = _this.parentNode;
    var bDone   = false;
    var bAsc    = true;
    var oSorter = new ISortHtmlTableData();

    /*
    ** 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)
    {
		/*
		** Determine sort direction
		*/
		strDir = _this.getAttribute(SORT_ATTR);
		if(strDir.toLowerCase() == SORT_ASC)
		{
			_this.setAttribute(SORT_ATTR, SORT_DESC);
			_this.title = STR_TOOLTIP_CLICK2SORT + STR_DESCENDING;
			bAsc = true;
		}
		else
		{
			_this.setAttribute(SORT_ATTR, SORT_ASC);
			_this.title = STR_TOOLTIP_CLICK2SORT + STR_ASCENDING;
			bAsc = false;
		}

		/*
		** Do the sort
		*/
        oSorter.SortTable(table, _this.childNodes[0].nodeValue, bAsc, true);
    }
    else
    {
        alert("Unable to find parent table to sort.")
    }
}

/*
** this variable will be set for screen not having the left
** side saved search frame.
*/
g_NoSavedSearchFrame = false;

function ProcessDivResize()
{			
	var iFrameHeight	= 200;
	var iFrameWidth		= 200;
	var divScrollable   = document.getElementById("ScrollableDiv");
	
	/*
	** 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 = (document.body.clientWidth-15)
	}
	else
	{				
		iFrameWidth = (document.body.clientWidth - 200);
	}
	iFrameHeight = (document.body.clientHeight - 150)*0.75;
	
	if(0 <= iFrameHeight)
	{
		divScrollable.style.height = iFrameHeight + "px";
		divScrollable.style.width  = iFrameWidth + "px";	
	}
	
	//window.status= document.body.clientWidth + ',' + document.body.clientHeight;
}

g_bottomFrame = false;

var g_bFriendly = true;
function TogglePrinterFriendlyDiv()
{
	var divScrollable   = document.getElementById("ScrollableDiv");
	
	if(g_bFriendly)
	{
		divScrollable.style.overflow = "visible";
	}
	else
	{
		divScrollable.style.overflow = "auto";
	}
	
	g_bFriendly=!g_bFriendly;
}

function ProcessFrameDivResize()
{			
	var iFrameHeight	= 200;
	var iFrameWidth		= 200;
	var divScrollable   = document.getElementById("ScrollableDiv");
	
	/*
	** to disable the scrollable div and display full text.
	*/
	/*
	if(disable == true)
	{
		document.all["ScrollableDiv"].style.overflow= "visible";				
	}*/

	iFrameWidth = (document.body.clientWidth);
	if(g_bottomFrame)
	{
		iFrameHeight = (document.body.clientHeight - 33);
	}
	else
	{
		iFrameHeight = (document.body.clientHeight - 33);
	}
	
	if(0 <= iFrameHeight)
	{
		divScrollable.style.height = iFrameHeight + "px";
		divScrollable.style.width  = iFrameWidth + "px";	
	}
	
	//window.status= document.body.clientWidth + ',' + document.body.clientHeight;
}

/*
** Filter Member List Constants
*/
var SORT_NAME       = "SortName";
var SORT_DEPT       = "SortDept";

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;
	
	/*
	** 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";
		}
	}
		
	/*
	** 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)  
{	
	/*
	** temporary fix to select a document to clipboard that has a major revision
	*/	
	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.
*/
function HighLightLastDocRow()
{
	/*
	** get the cookie value of LastVisitedDocRow, which is the checkbox id
	** of the last opened document row.
	*/
	var checkBoxElement = document.getElementById(GetCookie("LastVisitedDocRow"));		
	if(checkBoxElement)
	{
		/*
		** change the color style of the row to the LastVisitedSytle(lightyellow).
		*/		
		ChangeColorStyleOfLastDocRow(checkBoxElement);
	}
}

function HighLightRowAndOpenDoc(srcElement, sDocURL)
{
	tableRowElement = srcElement.parentElement.parentElement;				
	
	if(tableRowElement.childNodes.length)
	{
		var chkBox = tableRowElement.childNodes(0);								
		if(chkBox.childNodes.length > 0 && chkBox.childNodes(0).type == "checkbox")
		{	
			
			RestoreColorStyleOfLastDocRow();
			SetCookie("LastVisitedDocRow",chkBox.childNodes(0).id,"");
			ChangeColorStyleOfLastDocRow(srcElement);
			/*
			** if shift key is pressed then do not change the location.
			*/
			if(!window.event.shiftKey)
			{
				//document.location = sDocURL;		
			}
		}
	}
}
/*
** changes the color the row of the sent element with the selectstyle color
** used to highlight the row
*/
function ChangeColorStyleOfLastDocRow(srcElement)
{
	tableRowElement = srcElement.parentElement.parentElement;
	if(tableRowElement.tagName == "TR")
	{		
		tableRowElement.setAttribute("className","LastVisitedStyle",0)			
	}					
}
/*
** Restores the color the row of the sent element with the NFyiTrDListRow color
** used for document row.
*/
function RestoreColorStyleOfLastDocRow()
{
	var srcElement = document.getElementById(GetCookie("LastVisitedDocRow"));		
	if(srcElement)
	{
		tableRowElement = srcElement.parentElement.parentElement;
		if(tableRowElement.tagName == "TR")
		{		
			/*
			** set the className to NFyiTrDListRow
			*/
			tableRowElement.setAttribute("className","NFyiTrDListRow",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))
	//{  
		
	//}
}