/*********************************************************************/
/*                                                                   */
/* IBM Confidential                                                  */
/*                                                                   */
/* OCO Source Materials                                              */
/*                                                                   */
/* Copyright IBM Corp. 2005, 2007                                    */
/*                                                                   */
/* The source code for this program is not published or otherwise    */
/* divested of its trade secrets, irrespective of what has been      */
/* deposited with the U.S. Copyright Office.                         */
/*                                                                   */
/*********************************************************************/

//-------------------------------------------------------------
//  Quickplace common folder display functions
//-------------------------------------------------------------

var h_F_ExpansionParms			= new Array("&ExpandView","&CollapseView","&Expand=","&Collapse=");

var h_F_STATE_EXPANDED			= 0;
var h_F_STATE_COLLAPSED			= 1;
var h_F_STATE_NEXPANDED			= 2;
var h_F_STATE_NCOLLAPSED		= 3;

var h_F_ExpansionState			= h_F_STATE_EXPANDED;	// Default
var h_F_DocNumSelected			= "";	// E.g., "3.3.1"
var h_F_ShowHideResponsesURL	= "";
var h_F_NoExpandCollapseURL	= "";	// No Expand or Collapse param

// Set vars indicating whether folder contents are expanded or collapsed,
// and at which document number, if any.
function FolderSetExpansionState()
{
	var loc = location.href;
	var arg = "";
	var l=m=n=-1;

	// Get which parm if any, and parm's length
	h_F_ExpansionState = h_F_STATE_EXPANDED;
	for (var i=0; i<h_F_ExpansionParms.length; i++) {
		 if ((m=loc.indexOf(h_F_ExpansionParms[i])) != -1) {
			  l=h_F_ExpansionParms[i].length;
			  h_F_ExpansionState = i;
			  break;
		 }
	}
	n = m+l;

	if (h_F_ExpansionState == h_F_STATE_NEXPANDED ||
		 h_F_ExpansionState == h_F_STATE_NCOLLAPSED) {
		// Currently showing SOME responses:
		// skip num arg
		for (var c=''; n<loc.length; n++) {
			if (((c=loc.charAt(n))<'0' || c>'9') && c!='.')
				break;
			else
				arg += c;
		}
		// strip &Expand=a.b.c from URL and add &CollapseView
		h_F_ShowHideResponsesURL = loc.substring(0, m) + loc.substring(n) + h_F_ExpansionParms[h_F_STATE_COLLAPSED];
		h_F_NoExpandCollapseURL = loc.substring(0, m) + loc.substring(n);
	}
	else if (h_F_ExpansionState == h_F_STATE_COLLAPSED) {
		// currently hiding ALL responses strip &CollapseView from URL
		h_F_ShowHideResponsesURL = loc.substring(0, m) + loc.substring(n);
		h_F_NoExpandCollapseURL = loc.substring(0, m) + loc.substring(n);
	}
	else {
		// currently showing ALL responses
		h_F_ShowHideResponsesURL = loc + h_F_ExpansionParms[h_F_STATE_COLLAPSED];
		h_F_NoExpandCollapseURL = loc;
	}

	h_F_DocNumSelected = arg;
}


//------------------------------------------------------------------------------------
// GENERATE INDENTS AND EXPAND/COLLAPSE THREADS IN FOLDER

// # of Doc children on level [i]
var aChOnLev = new Array(0,0);

// Indent & Expand image tags
var fIndentImgTag = '<img style="width:18px;height:18px;vertical-align:middle;'
	+ '" src="/qphtml/html/common/treenode_%s.gif"/>';
var fIndentImgTagBg = '<img style="width:18px;height:18px;vertical-align:middle;'
	+ 'background-image:url(/qphtml/html/common/treenode_grid_%g.gif);'
	+ '" src="/qphtml/html/common/treenode_%s.gif"/>';
var fTwistyImgTag = '<img style="width:18px;height:18px;vertical-align:middle;'
	+ 'background-image:url(/qphtml/html/common/treenode_grid_%g.gif);'
	+ '" src="/qphtml/html/common/treenode_expand_%s.gif"'
	+ ' onmouseover="this.style.cursor=\'default\';"'
	+ ' onclick="javascript:fDoTwist(\'%n\',%b);"/>';

function fIndentImg(src, bg)
{
	return (bg ? fIndentImgTagBg.replace(/%s/,src).replace(/%g/,bg) : fIndentImgTag.replace(/%s/,src));
}

function fTwistyImg(bExp, bg, num)
{
	var pm = (bExp?'plus':'minus');
	return fTwistyImgTag.replace(/%s/,pm).replace(/%n/,num).replace(/%b/,bExp).replace(/%g/,bg);
}

function fDoTwist(num, bExp)
{
	location.href = h_F_NoExpandCollapseURL
		+ h_F_ExpansionParms[bExp ? h_F_STATE_NEXPANDED : h_F_STATE_NCOLLAPSED]
		+ num;
}

function GenerateResponseIndent(lev, num, nC, hasP)
{ 
	var html = "";

	// record #children at this level
	aChOnLev[lev] = nC;

	if (lev > 1) {
		// One child down
		aChOnLev[lev-1]--;

		// write preceeding blanks
		html += fIndentImg('blank');
		for (var i=2; i < lev; i++) {
			if (aChOnLev[i-1] > 0)
				html += fIndentImg('blank', 'v');
			else
				html += fIndentImg('blank');
		}
	}

	if (nC > 0) {
		// doc has child(ren)

		// Select "+" or "-" for twisty
		var bExp = false;
		switch (h_F_ExpansionState)
		{
		case h_F_STATE_NEXPANDED:
			if (num != h_F_DocNumSelected &&
				 num != h_F_DocNumSelected.substr(0,num.length))
				 bExp = true;
			break;
		case h_F_STATE_NCOLLAPSED:
			if (num == h_F_DocNumSelected ||
				 num != h_F_DocNumSelected.substr(0,num.length))
				 bExp = true;
			break;
		case h_F_STATE_COLLAPSED:
			bExp = true;
			break;
		default:
			 ;
		}

		if (lev > 1)
			html += fTwistyImg(bExp, (aChOnLev[lev-1]>0 ? 't' : 'l'), num);
		else
			html += fTwistyImg(bExp, 'x', num);
	}
	else if (lev > 1) {
		// no children
		html += fIndentImg('blank', (aChOnLev[lev-1]>0 ? 't' : 'l'));
	}
	return html;
};


//------------------------------------------------------------------------------------
//
var aColInfo = new Array();
var iCol = 0;
var lastEdDN = authorDN = "";

function InitFolderColInfo(authDN, edDN)
{
	authorDN = authDN;
	lastEdDN = edDN;
	iCol = 0;
}

function FolderColInfo(item,val)
{
	this.item = item;
	this.val = val;
}

function AddFolderColInfo(item,val)
{
	aColInfo[iCol] = new FolderColInfo(item,val);
	iCol++;
}

function DisplayListViewItem(chkbx, type, name, unid, aName, form, hasP, nC, lev, revNum, docNum)
{
	// Don't allow dragging of folders
	if (type != "1")
		QP_DragAndDrop_writeSourceBegin("tbody", unid, nC, lev);
		 
	var html=
		'<tr class="h-folderItem-bg" valign=top>'

		// FIX ME: Unnecessary "response bar" - fix by removing this column from the table!!!!!
		+ '<td class="h-folderItem-text" valign="top"><br></td>'

		// Checkbox
		+ '<td class="h-folderItem-text" width="10" valign="top">' + chkbx + '</td>'

		// Icon
		+ '<td class="h-folderItem-text" valign="top">'
		+	GetDocTypeIconImgTag(type,form)
		+ '</td>'

		// Response indent(s), doc name, rev#
		+ '<td class="h-folderItem-text" valign="top">'
		+ GenerateResponseIndent(lev,docNum,nC,hasP)
		+ (typeof(aName) != "undefined" ? GenerateQPObjURLAnchor(type,aName,name) : name)
		+	((revNum && revNum != "") ? '&nbsp;(' + GenerateRevisionText(revNum) + ')': '')
		+ '</td>'
	;

	// Other (optional/custom) columns:
	for (var i=0; i<aColInfo.length; i++) {
		html += '<td class="h-folderItem-text" valign="top">'
			+ DisplayFolderColInfo(aColInfo[i].item, aColInfo[i].val)
			+ '</td>';
	}

	html += '</tr>';
	document.write(html);
}

//------------------------------------------------------------------------------------
// 
function DisplayFolderColInfo (item, val, aTag)
{ 
	var html = "";

	if (item == "h_Author")
	{
		html = GetMemberProfileName(authorDN,val);
	}
	else if (item == "h_LastEditorDisplayName")
	{
		html = GetMemberProfileName(lastEdDN,val);
	}
	else if (item == "h_DisplayModified" ||  item == "h_Created") 
	{
		var iSpace = val.indexOf (' ');
		if (iSpace != -1)
			html = val.substring(0, iSpace);
		else
			html = val;
	}
	else
	{
		html = (typeof(aTag) != "undefined") ? GenerateQPObjURLAnchor("0",aTag,val) : val;
	}
 
	return html;
};

var fLockedImgTag = '<img style="width:18px;height:18px;vertical-align:middle;'
	+ '" src="/qphtml/html/common/doc_locked.gif"/>';
var fBlankImgTag = '<img style="width:18px;height:18px;vertical-align:middle;'
	+ '" src="/qphtml/html/common/transparent.gif"/>';
function OLD_DisplayMyPlacesEntry(url,name,title,desc,size,accDate,modDate,isLocked)
{
		// Remove time of day from dates
		var aDate = accDate;
		var mDate = modDate;
		var iSpace = accDate.indexOf (' ');
		if (iSpace != -1)
			aDate = (accDate.substring (0, iSpace));
		iSpace = modDate.indexOf (' ');
		if (iSpace != -1)
			 mDate = (modDate.substring (0, iSpace));
		 
		document.write(
			'<dl class="h-abstractEntry">' +
			' <dt class="h-abstractEntryTitle boldTitle" >' +
			((isLocked == "1") ? fLockedImgTag : fBlankImgTag) +
 			'   <a class="h-abstractEntryTitleName" href="'+ url + name + '">' + title + '</a>' + 
			' </dt>' +
			' <dd>' +
			'  <div class="h-abstractEntry-text" >' + desc + '</div>' +
			'  <div class="h-abstractEntry-text">' +
			'     Last Accessed on ' + '<span class="h-abstractEntrydate">' + aDate + '</span>' +
			'     &nbsp;&nbsp;&nbsp;' +
			'     Last Modified on ' + '<span class="h-abstractEntrydate">' + mDate + '</span>' +
			'     &nbsp;&nbsp;&nbsp;' +
			'     <a href="'+url+name+'">'+name+'</a>' +
			'  </div>' +
			' </dd>' +
			'</dl>'
			);
}
function DisplayMyPlacesEntry(url,name,title,desc,size,accDate,modDate,isLocked)
{
	// Remove time of day from dates
	var aDate = accDate;
	var mDate = modDate;
	var iSpace = accDate.indexOf (' ');
	if (iSpace != -1)
		aDate = (accDate.substring (0, iSpace));
	iSpace = modDate.indexOf (' ');
	if (iSpace != -1)
		mDate = (modDate.substring (0, iSpace));
		 
	var html= '<div style="border: 1px solid rgb(255,255,255); background: rgb(255,255,255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"'
		 +' class="entry"'
		 +' onmouseover="this.style.background=\'#eaf2fe\'; this.style.border=\'1px solid #b8e0fe\';"'
		 +' onmouseout="this.style.background=\'#fff\'; this.style.border=\'1px solid #fff\';"'
		 +'>'
		 +' <a href="'+ url + name + '">'+title+'</a>'
		 +'  <div name="entryDetails">'
		 +'   <p>'+desc+'</p>'
		 +'  </div>'
		 +' </a>'
		 +' <div name="entryDetails">'
		 +'  <span class="outer">'
		 +'   <span class="person">'
		 +'    Last Accessed on&nbsp;'
		 +'   </span>'
		 +'   <span id="owner" class="vcard">'
		 +'    <span class="fn">'
		 +      aDate
		 +'    </span>'
		 +'   </span>'
		 +'  </span>'
		 +' </div>'
		 +'</div>';

	document.write(html);
}


//------------------------------------------------------------------------------------
//
function DisplaySortAction(title, posNum)
{ 
	var szResortImg;
	var szUrl = "";

	var newLoc;
	
	if ( typeof ( h_FolderNavBaseURL) != "undefined" && h_FolderNavBaseURL != "") {
		newLoc = getAbsoluteServerRootPath(self) + h_FolderNavBaseURL;
	} else  {
		newLoc = location.href;
	}
	var idx, idx1;
	// nCurColSort==-1 if there is no sorted column.  Otherwise it will be the number of the col that is sorted.
	var nCurColSort = -1;
	// nColSortType==0 for none, 1 for ascending, and 2 for descending
	var nColSortType = 0;
	var szAltText="";

	idx = newLoc.indexOf("&ResortAscending=");
	if (idx != -1)
	{
		nColSortType = 1;
		// get rid of the &ResortAscending= parm
		idx1 = newLoc.indexOf ("&", idx+1);
		if (idx1 != -1) 
		{
			nCurColSort = newLoc.substring(idx + 17, idx1);
			newLoc = newLoc.substring(0, idx) + newLoc.substring(idx1);
		}
		else
		{
			nCurColSort = newLoc.substring(idx + 17);
			newLoc = newLoc.substring(0, idx);
		}
	}

	idx = newLoc.indexOf("&ResortDescending=");
	if (idx != -1)
	{
		nColSortType = 2;
		// get rid of the &ResortDescending= parm
		idx1 = newLoc.indexOf ("&", idx+1);
		if (idx1 != -1) 
		{
			nCurColSort = newLoc.substring(idx + 18, idx1);
			newLoc = newLoc.substring(0, idx) + newLoc.substring(idx1);
		}
		else
		{
			nCurColSort = newLoc.substring(idx + 18);
			newLoc = newLoc.substring(0, idx);
		}
	}

	idx = newLoc.indexOf ("&Start=");
	if (idx != -1)
	{
		// lets remove &Start=xx and replace it with &Start=1
		idx1 = newLoc.indexOf ("&", idx+1);
		if (idx1 != -1)
		{
			newLoc = newLoc.substring(0, idx) + "&Start=1" + newLoc.substring(idx1);
		}
		else
			newLoc = newLoc.substring(0, idx) + "&Start=1";
	}

	// remove &StartAtLastPage if it exists
	idx = newLoc.indexOf ("&StartAtLastPage");
	if (idx != -1)
	{
		// lets remove &Start=xx and replace it with &Start=1
		idx1 = newLoc.indexOf ("&", idx+1);
		if (idx1 != -1)
		{
			newLoc = newLoc.substring(0, idx) + "&Start=1" + newLoc.substring(idx1);
		}
		else
			newLoc = newLoc.substring(0, idx) + "&Start=1";
	}

	//TODO - Localize these strings...
	var ALT_LINK_SORTBY = 'Sort by ';
	var ALT_LINK_SORTASCENDING = ' in ascending order';
	var ALT_LINK_SORTDESCENDING = ' in descending order';
	var ALT_LINK_SORTDEFAULT = 'Return to the folder\'s default sort order';
	var ALT_IMG_ISASCENDING = 'Sorted in ascending order';
	var ALT_IMG_ISDESCENDING = 'Sorted in descending order';

	var szClass="";

	// Check to see if sorted column
	// parameters for non-sorted columns
	if (nCurColSort != posNum)
	{
		szAltText = ALT_LINK_SORTBY + title + ALT_LINK_SORTASCENDING;
		szResortImg   =	genImageTag( "/qphtml/attachments/transparent.gif", 'ReSort'+posNum, ' border=0 align=middle', szAltText);
		newLoc  += '&ResortAscending=' + parseInt(posNum);
	}
	else
	{
		if (nColSortType == 1) {
			// current column is sorted Ascending so next sort type is Descending
			newLoc += '&ResortDescending=' + parseInt(posNum);
			szAltText=	ALT_LINK_SORTBY + title + ALT_LINK_SORTDESCENDING;
			szResortImg  =	genImageTag( "/qphtml/attachments/asc_arrow.gif", 'ReSort'+posNum, ' border=0 align=middle', ALT_IMG_ISASCENDING);
			szClass='class="button sortDescending"';
		}
		else {
			// current column is sorted Descending so next sort type is none
			szResortImg =	genImageTag( "/qphtml/attachments/desc_arrow.gif", 'ReSort'+posNum, ' border=0 align=middle', ALT_IMG_ISDESCENDING);
			szAltText=	ALT_LINK_SORTDEFAULT;
			szClass='class="button sortAscending"';
		}
	}

	document.write('<li '+szClass+'><a href="'+newLoc+'" alt="'+szAltText+'" title="'+title+'">'+ title+'</a></li>');
}


//------------------------------------------------------------------------------------
//
function DisplaySortBarBegin(szSortBy)
{
	var sEntry = "";
	sEntry += "<div class=\"actions sort\">";
	sEntry += "	<ul class=\"inlinelist\">";
	sEntry += "  <li class=\"first\">"+szSortBy+":</li>";
	// Other <li>s for sort items come after this...
	document.write(sEntry);
}


//------------------------------------------------------------------------------------
//
function DisplaySortBarEnd()
{
	var sEntry = "";
	sEntry += " </ul>";
	sEntry += "</div>";
	document.write(sEntry);
}


//------------------------------------------------------------------------------------
//
function DisplayAbstractViewSortBegin(chkbx,szSortBy/*add other strings*/) 
{
	var sEntry = "";
	sEntry += "<dl class=\"h-abstractEntry\"><table width=\"100%\" cellpadding=\"10\"><tr>";
	sEntry += "	<td width=\"10\">" + chkbx + "</td>";
	sEntry += "	<td width=\"*\">";
	document.write(sEntry);
	DisplaySortBarBegin(szSortBy);
}


//------------------------------------------------------------------------------------
//
function DisplayAbstractViewSortEnd()
{
	var sEntry = "";
	DisplaySortBarEnd();
	sEntry += "	</td>";
	sEntry += "</tr></table></dl>";
	document.write(sEntry);
}


//------------------------------------------------------------------------------------
//
function DisplayAbstractViewEntry(	chkbx, 
					type, 
					name, 
					unid, 
					aName, 
					auth, 
					authDN, 
					crDate, 
					lastEd, 
					lastEdDN, 
					modDate, 
					szAbstract, 
					form, 
					hasP, 
					nC, 
					lev, 
					revNum
				)
{

	//TODO - Localize these strings...
	var m_UPDATETEXT = "Updated by ";
	var m_DATETIMEPROCESS = " on {0} at {1}"; //{0} is the date, {1} is the time
	var m_DATEPROCESS = " on {0}"; //{0} is the date/time
	

	
	
	//format the dates appropriately
	var cDate = crDate;
	var mDate = modDate;

	var arr_cDate = new Array();
	var arr_mDate = new Array();
	var sProcess = "";
	
	
	//if there is a space, then separate the date from the time and format it...
	if (cDate.indexOf(" ") == -1) {
		arr_cDate[0] = cDate;
		sProcess = m_DATEPROCESS;
	} else {
		arr_cDate[0] = cDate.substring(0, cDate.indexOf(" ") );
		arr_cDate[1] = cDate.substring(cDate.indexOf(" ") + 1 );
		sProcess = m_DATETIMEPROCESS;
	}
	cDate = AbstractStringProcess(sProcess, arr_cDate );
	
	if (mDate.indexOf(" ") == -1) {
		arr_mDate[0] = mDate;
		sProcess = m_DATEPROCESS;
	} else {
		arr_mDate[0] = mDate.substring(0, mDate.indexOf(" ") );
		arr_mDate[1] = mDate.substring(mDate.indexOf(" ") + 1 );
		sProcess = m_DATETIMEPROCESS;
	}
	mDate = AbstractStringProcess(sProcess, arr_mDate );
	
	

	//don't allow dragging of folders
	if (type != "1") {
		QP_DragAndDrop_writeSourceBegin("div", unid, nC, lev);
	}
	
	var sEntry = "";
	sEntry += "<dl class=\"h-abstractEntry\"><table width=\"100%\" cellpadding=\"10\"><tr>";
	
	sEntry += "	<td width=\"10\">" + chkbx + "</td>";
	
	sEntry += "	<td width=\"35\"><img class=\"h-abstractEntryIcon\" src=\"" + GetDocTypeIconImgSrc(type, form, null, "LG") + "\"/></span></td>";
	
	sEntry += "	<td>";
		
 	sEntry += "		<div class=\"h-abstractEntryTitle\">" + (typeof(aName) != "undefined" ? GenerateQPObjURLAnchor(type,aName,name) : name) + "</div>";

	sEntry += "		<div class=\"h-abstractEntryText\">";
	sEntry += "			" + GetMemberProfileName(authDN,auth) + "<span class=\"h-abstractEntryDate\">" + cDate + "</span>";
	sEntry += "			 | ";
	sEntry += "			" + m_UPDATETEXT + GetMemberProfileName(lastEdDN,lastEd) + "<span class=\"h-abstractEntryDate\">" + mDate + "</span>";
	sEntry += "		</div>";

	if (typeof(h_TextAbstract) != "undefined" && h_TextAbstract == "0") {
		szAbstract = "";
	}
	sEntry += "		<div class=\"h-abstractEntryDetail\" >" + szAbstract + "</div>";
	
	sEntry += "	</td>";
	
	sEntry += "</tr></table></dl>";
	
	
	
	document.write(sEntry);

}

function AbstractStringProcess(sFormat, arrValues)
{
	var sReturn = sFormat;

	for (var i = 0; i < arrValues.length; i++) {
		var sTmp = "{" + i + "}";

		while (sReturn.indexOf(sTmp) > -1) {
			sReturn = sReturn.replace(sTmp, arrValues[i]);
		}
	}

	return sReturn;
}


//-----------------------------------------------------------------
// FUNCTIONS USED TO IMPLEMENT FOLDER SCENE SKIN COMPONENTS

function FolderItemsPerPageLink(n, szN, szTitle)
{
	var iCount = h_FolderNavBaseURL.indexOf("&Count="); 
	var showUrl = h_FolderNavBaseURL.substring(0, iCount+7);
	 
	var className = (n == h_FolderCount) ? "h-numberInFolderSelected-text" : "h-numberInFolder-text";
	document.write('<a class="' + className
						+ '" alt="' + szTitle + '" title="' + szTitle 
						+ '" href="' + showUrl + n
						+ '&PresetFields=h_SetReadScene;' + h_SetReadScene
						+ '">' + szN + '</a>');
}

var h_F_MyPlacesParms = new Array("&PresetFields=h_SetReadScene;h_MyPlacesList","&PresetFields=h_SetReadScene;h_MyPlacesDetails");

function FolderShowHideDetailsLink(szShow, szHide, szShowTitle, szHideTitle)
{
	var fS = getFolderStyle();
	if (fS == 'h_MyPlaces') {
		// My Places listing
		var loc = location.href;
		var l=m=n=-1;

		// Get which parm if any, and parm's length
		for (var i=0; i<h_F_MyPlacesParms.length; i++) {
			if ((m=loc.indexOf(h_F_MyPlacesParms[i])) != -1) {
				l=h_F_MyPlacesParms[i].length;
				break;
			}
		}

		if ((n=m+l)>0) {
			// Strip param from current URL
			loc = loc.substring(0, m) + loc.substring(n);
		}

		document.write('<a href="'
							+ loc + '&PresetFields=h_SetReadScene;'
							+ '&PresetFields=h_SetReadScene;'
							+ (h_SetReadScene == 'h_MyPlacesList' ? 'h_MyPlacesDetails' : 'h_MyPlacesList')
							+ '"'
							+ ' title="' + (h_SetReadScene == 'h_MyPlacesDetails' ? szHideTitle : szShowTitle) + '"'
							+ ' alt="'   + (h_SetReadScene == 'h_MyPlacesDetails' ? szHideTitle : szShowTitle) + '"'
							+ '>'
							+ (h_SetReadScene == 'h_MyPlacesDetails' ? szHide : szShow)
							+ '</a>');
	}
	else {
		// Folder listing
		document.write('<a href="'
							+ '../../h_Toc/' + h_FolderDoc.h_Unid + '/?OpenDocument&Start=' + h_FolderStart
							+ '&Count=' + (h_SetReadScene == 'h_AbstractsFolderRead' ? 20 : 10)
							+ '&PresetFields=h_SetReadScene;'
							+ (h_SetReadScene == 'h_AbstractsFolderRead' ? 'h_StdFolderRead' : 'h_AbstractsFolderRead')
							+ '"'
							+ ' title="' + (h_SetReadScene == 'h_AbstractsFolderRead' ? szHideTitle : szShowTitle) + '"'
							+ ' alt="'   + (h_SetReadScene == 'h_AbstractsFolderRead' ? szHideTitle : szShowTitle) + '"'
							+ '>'
							+ (h_SetReadScene == 'h_AbstractsFolderRead' ? szHide : szShow)
							+ '</a>');
	}
}

function FolderShowHideResponsesLink(szShow, szHide, szShowTitle, szHideTitle)
{
	var bShow = (h_F_ExpansionState == h_F_STATE_COLLAPSED);
	document.write('<a href="' + h_F_ShowHideResponsesURL + '"'
						+ ' title="' + (bShow ? szShowTitle : szHideTitle) + '"'
						+ ' alt="'   + (bShow ? szShowTitle : szHideTitle) + '"'
						+ '>'
						+ (bShow ? szShow : szHide)
						+ '</a>');
}

function FolderShowingItemsText(szFmt) 
{ 
	if (h_FolderDocCount > 0)
	{
		var s = szFmt;
			  
		var iEndIndex =  h_FolderStart.indexOf( ".");
		if	( iEndIndex == -1) {
			iEndIndex = h_FolderStart.length;
		}
		 
		// The thread start (1 in the above string
		var iThreadStart = h_FolderAbsoluteStartPosition;
		// The last thread in the list
		var rangeEnd = h_FolderAbsoluteStartPosition + iTotNumOfDocs - 1;
		 
		// replace the string which has the following syntax	
		s = s.replace( /\%d/, iThreadStart);
		s = s.replace( /\%d/, rangeEnd);
		s = s.replace( /\%d/, h_FolderDocCount);
		document.write(s);
	}
};

function FolderHideIdIfBlank(sId, fFunct) {
	var preloadid = document.getElementById(sId);
	if (preloadid) {
	
		var bHide = true;
		for (var i = 0; i < preloadid.childNodes.length; i++) {
			if (typeof(preloadid.childNodes[i].tagName) != "undefined" && typeof(preloadid.childNodes[i].innerHTML) != "undefined" && preloadid.childNodes[i].tagName != "SCRIPT") {
				bHide = false;
			}
			if (typeof(fFunct) != "undefined") {
				if (fFunct() == "") {
					bHide = true;
				}
			}
		}
		
		if (bHide) {
			preloadid.style.display = "none";
		}
	}
}

function FolderAlternateTableRowsBackground(sId, sClassName) {
	if (sClassName == null) sClassName = "h-folderitem-bg";
	var mydetailslist = document.getElementById(sId);
	if (mydetailslist) {
		var onoffswitch = false;
		var alltrs = mydetailslist.getElementsByTagName("tr");
		for (var idx = 0; idx < alltrs.length; idx++) {
			if (alltrs[idx].className.toLowerCase() == sClassName.toLowerCase()) {
				if (onoffswitch) {				
					alltrs[idx].className += " h-folderItem-bg-alt";
				}
				onoffswitch = !onoffswitch;
			}
		}
	}
}
