/**
**	SCCSID : %W% - %E%:%U%  
**
**	Description	:	Content cover related functions
**	Functions	:	writeDirPlay(prtId)
						getContentDetail(hid, itemid)
						getPart(label, val)
						getPage(val, cnt)
						backHitLst(hid, cur, ss, hits)
						newWindows(val)
						writePages(pageLnk, hitPart, access)
						writeImg(val)
						writeNews(pageLnk, hitPart, access)
						microPath(val)
						getLine(label, val, lnk, param)
						search(s_value, keyword, param)
						writePreviewLnk(LnkSrc, nHeight, nWidth, hasCtrl)
						writePrelistenLnk(LnkSrc, nHeight, nWidth, hasCtrl)
						resizeImg(src);
						showImg(img_obj);
						getUrl(uslId);
**	
** @version 	%W% - %E%:%U%
**	
*/

function DisplayImage(res)
{
	parent.rightFrame.location.href = res;
}


//Global variable for swtiching row color
var m_swt = null;

//
//this function used to write links to direct play
//
/*

function writeDirPlay(prtId)
{
	var chifont ="";

	if (l_CurrLang == c_ChsLang)
	{
		chifont = "文鼎中明簡,";
	}
	else if (l_CurrLang == c_ChtLang)
	{
		chifont = "MingLiu,";
	}

	var res;
	//Modified by Tony Tse on 28.02.2001
	//var foAril1 = "<font face='Arial, Helvetica, sans-serif' size='1'>";
	var foAril1 = "<font face='"+chifont+" Arial, Helvetica, sans-serif' size='1'>";
	var en_font	= "</font>";
	var op_aTag	= "<a href=";
	var en_gt	=">";
	var cl_aTag	= "</a>";
	var op_tagLink	= "javascript:dirPlay('";
	var cl_tagLink	= "')";

	res = foAril1 + op_aTag + op_tagLink + prtId + cl_tagLink + en_gt + "Play" +
			cl_aTag + en_font;

	document.writeln(res);
}
*/


//
//This js file mainly for detail content cover use
//

function getContentDetail(hid, itemid)
{
	var qryStr;
	var svc		= c_DtlCvr;
	var ss		= c_SSCDetail;
	
	qryStr = c_DominName + c_Service + c_DefGateWay + "?" +
				"svc=" + svc + "&hid=" + hid + "&itemid=" + itemid +
				"&ss=" + ss + "&magicno=" + Math.random();

//	alert(qryStr);
	return qryStr;

//	top.mainFrame.location.href = qryStr;
}

//
//This js file mainly for detail content cover use (for rst*head.html only)
//

function setContentDetail(hid, itemid)
{
	var qryStr;
	var svc		= c_DtlCvr;
	var ss		= c_SSCDetail;
	
	qryStr = c_DominName + c_Service + c_DefGateWay + "?" +
				"svc=" + svc + "&hid=" + hid + "&itemid=" + itemid +
				"&ss=" + ss + "&magicno=" + Math.random();

//	alert(qryStr);
//	return qryStr;

	top.mainFrame.location.href = qryStr;
}

function setBookDetail(hid, itemid)
{
	var qryStr;
	var svc		= c_DtlCvr;
	var ss		= c_SSCBkDtl;
	
	qryStr = c_DominName + c_Service + c_DefGateWay + "?" +
				"svc=" + svc + "&hid=" + hid + "&itemid=" + itemid +
				"&ss=" + ss + "&magicno=" + Math.random();

	top.mainFrame.location.href = qryStr;
}
//
//Function for content cover write each row of part information
//	label:	is the label of the attribute
//	val:		is the array value of the attribute
//
//
function getPart(label, val)
{
	var chifont = "";

	if (l_CurrLang == c_ChsLang)
	{
		chifont = "文鼎中明簡,";
	}
	else if (l_CurrLang == c_ChtLang)
	{
		chifont = "MingLiu,";
	}

	val = val.replace("<","&lt;");
	val = val.replace(">","&gt;");

	var optr		= "<tr valign='top'>";

	//Modified by Tony Tse on 28.02.2001
	//var optd		= "<td nowrap width='60'><font face='Verdana' size='1'>";
	var optd		= "<td nowrap width='60'><font face='"+chifont+"Verdana' size='1'>";
	//var optdb	= "<td nowrap bgcolor='#F9EFE8' width='60'><font face='Verdana' size='1'>";
	var optdb	= "<td nowrap bgcolor='#F9EFE8' width='60'><font face='"+chifont+"Verdana' size='1'>";

	//var optdw	= "<td><font face='Verdana' size='1'>";
	var optdw	= "<td><font face='"+chifont+"Verdana' size='1'>";
	//var optdwb	= "<td bgcolor='#F9EFE8'><font face='Verdana' size='1'>";
	var optdwb	= "<td bgcolor='#F9EFE8'><font face='"+chifont+"Verdana' size='1'>";

	var cltd		= "</font></td>";
	var cltr		= "</tr>";

// Problem log 5130 fixed by Chung 20110302
	if (m_swt == null)
	{
		//initial
		m_swt = 1;
		//res = optr + optd + label + cltd + optdw + val; 
		res = optr + optdw + val; 
	}
	else if (m_swt == 0)
	{
		//event row not background colour
		//set m_swt to odd
		m_swt = 1;
		//res = optr + optd + label + cltd + optdw + val; 
		res = optr + optdw + val; 
	}
	else if (m_swt == 1)
	{
		//odd row have background colour
		//set m_swt to odd
		m_swt = 0;
		//res = optr + optdb + label + cltd + optdwb + val; 
		res = optr + optdwb + val; 
	}
	else
	{
		alert("javascript error CotentCover::getPart()");
		return;
	}
// end problem log	

	res += cltd + cltr;

	document.writeln(res);
}


//
//Function for content cover leftFrame (House Program, Microfilm, etc)
//write each row of page information
//	label:	is the label of the attribute
//	val:		is the array value of the attribute
//
//
function getPage(val, cnt)
{
	var chifont = "";

	if (l_CurrLang == c_ChsLang)
	{
		chifont = "文鼎中明簡,";
	}
	else if (l_CurrLang == c_ChtLang)
	{
		chifont = "MingLiu,";
	}

	var optr		= "<tr>";
	var optrb	= "<tr bgcolor='#F9EFE8'>";
	var optd		= "<td nowrap>";
	var optdw	= "<td nowrap width='100%'>";
	
	//Modified by Tony Tse on 28.02.2001
	//var opfnt	= "<font face='Verdana' size='2'>";
	var opfnt	= "<font face='"+chifont+"Verdana' size='2'>";
	var divr		= "<div align='left'>";
	var img		= "<img src='../../images/shim.gif' border=0 " +
						"name='cur"+cnt+"' width='15' heght='15'>";
	var cldiv	= "</div>";
	var cltd		= "</td>";
	var clfnt	= "";
	var clfnt	= "</font>";
	var cltr		= "</tr>";
	var clal		= clfnt + cldiv + cltd + cltr;

	if (m_swt == null)
	{
		//initial
		m_swt = 1;
		res = optr + optd + img + cltd + optdw + divr + opfnt + val + clal;
	}
	else if (m_swt == 0)
	{
		//event row not background colour
		//set m_swt to odd
		m_swt = 1;
		res = optr + optd + img + cltd + optdw + opfnt + divr + val + clal;
	}
	else if (m_swt == 1)
	{
		//odd row have background colour
		//set m_swt to odd
		m_swt = 0;
		res = optrb + optd + img + cltd + optdw + opfnt + divr + val + clal;
	}
	else
	{
		alert("javascript error CotentCover::getLine()");
		return;
	}
	
	document.writeln(res);
}

/*	
 *	function enable to direct back to hit list and the previous page
 *	this function mostly used by multi-page content covers
 * param hid	hit id
 *	param cur	the current items number in the list
 *	param	ss		the style sheet
 *	param hits	hits per page
 */

function backHitLst(hid, cur, ss, hits)
{

	var svc = c_HitNavig;
	var res;
	var val;

	if (isNaN(cur))
		cur = parseInt(cur);

	if (isNaN(hits))
		cur = parseInt(hits);

	rem = (cur - 1) % hits;
	res = (cur - rem - 1) / hits;

	if (res < 1)
	{
		frm = 1;
		to = hits;
	}
	else
	{
		frm = (res * 10) + 1;
		to = (res + 1) * 10;
	}

	val = "frm=" + frm + "&to=" + to;

	qryStr = c_DominName + c_Service + c_DefGateWay + "?" +
				"svc=" + svc +  "&hid=" + hid + "&" + val + 
				"&hitperpage=" + hits + "&ss=" + ss + 
				"&magicno=" + Math.random();

//	parent.location.href = qryStr;
	top.mainFrame.location.href = qryStr;
}

//
//function to open a new window with the link
function newWindow(val)
{
	window.open(val);
}



//
//this function used to update the image on right frame
//
function writeImg(val)
{
	var rst;

	rst = val;

	if (rst.indexOf("image/tiff") > 0)
		parent.rightFrame.location.href = rst;
	else
	{
		parent.leftFrame.curImgWithToken = rst;
		parent.rightFrame.location.reload();
	}
}


//
//this function used to write for each page of CM objects
//
function writePages(pageLnk, hitPart, access)
{

	var hlen = hitPart.length;
	var hit	= false;
	var hitcon = 0;
	var m_swt = 0;

	for (var i=0; i<pageLnk.length; i++)
	{
		//Hit parts by content search matching the hit pages by using
		//hitPart and pageLnk
		if (hitcon == hlen)
		{
			if (access == true)
			{

				getPage('<a href="' +  
							"javascript:writeImg(c_ObjRevWithToken(pageLnk[" +
							i + "][1]));" + 
							'" onMouseDown="setCurImg(' +
							"'" + c_ObjRev(pageLnk[i][1]) + "'" + ');' + 
							"MM_nbGroup('down','group1'," + "'cur" + i + 
							"','../../images/Arrow-circle.gif',1);" + '">' + (i+1) + 
							"</a>",i);

				/* Old remarked by Andy
				getPage('<a href="' +  "javascript:writeImg('" +
							c_ObjRevWithToken(pageLnk[i][1]) + 
							"');" + 
							'" onMouseDown="setCurImg(' +
							"'" + c_ObjRev(pageLnk[i][1]) + "'" + ');' + 
							"MM_nbGroup('down','group1'," + "'cur" + i + 
							"','../../images/Arrow-circle.gif',1);" + '">' + (i+1) + 
							"</a>",i);
				*/
			}
			else
			{
				getPage('<a href="' + "javascript:writeImg('" +
							"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
							"MM_nbGroup('down','group1'," + "'cur" + i +
							"','../../images/Arrow-circle.gif',1);" + '">' + 
							(i+1) + "</a>",i);

				/* Old remarked by Andy
				getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
							"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
							"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
							(i+1) + "</a>",i);
				*/
			}
		}
		else
		{
			for (var j=0; j<hlen; j++)
			{
				if (hitPart[j] == pageLnk[i][0])
				{
					//match hit part and the part

					if (access == true)
					{
						getPage('<font color="red">*&nbsp;</font><b><a href="' + 
							"javascript:writeImg(c_ObjRevWithToken(pageLnk[" +
							i + "][1]));" + 
							'" onMouseDown="setCurImg(' +
							"'" + c_ObjRev(pageLnk[i][1]) + "'" + ');' + 
							"MM_nbGroup('down','group1'," + "'cur" + i + 
							"','../../images/Arrow-circle.gif',1);" + '">' + (i+1) + 
							"</a></i></b>",i);

						/* Old remarked by Andy
						getPage('<font color="red">*&nbsp;</font><b><a href="' + 
							"javascript:MM_nbGroup('down','group1'," + "'cur" + i + 
							"','../../images/Arrow-circle.gif',1);" +
							"writeImg('" + c_ObjRevWithToken(pageLnk[i][1]) + 
							"');" +
							'" onMouseDown="setCurImg(' + "'" +
							c_ObjRev(pageLnk[i][1]) + "');" + '">' + (i+1) + 
							"</a></i></b>",i);
						*/
					}
					else
					{
						getPage('<a href="' + "javascript:writeImg('" +
									"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
									"MM_nbGroup('down','group1'," + "'cur" + i +
									"','../../images/Arrow-circle.gif',1);" + '">' + 
									(i+1) + "</a>",i);


						/* Old remarked by Andy
						getPage('<font color="red"*&nbsp;</font><b><i><a href="' + "javascript:parent.rightFrame.location.href=" + 
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + "'cur" + i + 
									"','../../images/Arrow-circle.gif',1);" + '">' + (i+1) + 
									"</a></i></b>",i);
						*/
					}

					//set hit to true to escape the next if statement
					hit = true;
					hitcon ++;
					break;
				}
			} //End for loop

			//Normal search without match which page is hited!
			if (!hit)
			{
				if (access == true)
				{
					getPage('<a href="' +  
								"javascript:writeImg(c_ObjRevWithToken(pageLnk[" +
								i + "][1]));" + 
								'" onMouseDown="setCurImg(' +
								"'" + c_ObjRev(pageLnk[i][1]) + "'" + ');' + 
								"MM_nbGroup('down','group1'," + "'cur" + i + 
								"','../../images/Arrow-circle.gif',1);" + '">'+(i+1) + 
								"</a>",i);

					/*
					getPage('<a href="' +  "javascript:MM_nbGroup(" +
								"'down','group1','cur" + i + 
								"','../../images/Arrow-circle.gif',1);" +
								"writeImg('" + c_ObjRevWithToken(pageLnk[i][1]) + "');" +
								'" onMouseDown="setCurImg(' + "'" +
								c_ObjRev(pageLnk[i][1]) + "');" + '">' + (i+1) + 
								"</a>",i);
					*/
				}	
				else
				{
					getPage('<a href="' + "javascript:writeImg('" +
								"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
								"MM_nbGroup('down','group1'," + "'cur" + i +
								"','../../images/Arrow-circle.gif',1);" + '">' + 
								(i+1) + "</a>",i);

					/* Old remarked by Andy
					getPage('<a href="' + "javascript:parent.rightFrame.location.href=" + 
								"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + "'cur" + i + 
								"','../../images/Arrow-circle.gif',1);" + '">' + (i+1) + 
								"</a>",i);
					*/
				}
			}

			//reset the hit marker
			hit = false;
		}
	}

	if (len > 0)
		MM_nbGroup('down','group1','cur0','../../images/Arrow-circle.gif',1);
}


//
//this function used to write for each page of CM objects
//
function writePDF(pageLnk, hitPart, desc, access)
{
	var hlen = hitPart.length;
	var desclen = desc.length;
	var hit	= false;
	var hitcon = 0;
	var m_swt = 0;
	var res;

	if (pageLnk.length == 1 && pageLnk[0][1] == '')
	{
		return "TOC Error!";
	}

	for (var i=0; i<pageLnk.length; i++)
	{
		res = pageLnk[i][1];
		var cnt = res.length;

		res = microPath(res);

		if (hitcon == hlen)
		{
			if (access == true)
			{
				if (desclen == 0)
				{
					getPage('<a href=javascript:writeImg("'+res+'") onMouseDown="' + 
							  "setCurImg('" + res + "');MM_nbGroup('down','group1'," +
							  "'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
							  '">' + (i+1) + '</a>',i);
				}
				else
				{
					getPage('<a href=javascript:writeImg("'+res+'") onMouseDown="' + 
							  "setCurImg('" + res + "');MM_nbGroup('down','group1'," +
							  "'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
							  '">' + desc[i+1] + '</a>',i);
				}
			}		
			else
			{
				if (desclen == 0)
				{
					getPage('<a href="' + "javascript:writeImg('" +
								"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
								"MM_nbGroup('down','group1'," + "'cur" + i +
								"','../../images/Arrow-circle.gif',1);" + '">' + 
								(i+1) + "</a>",i);
				}
				else	
				{
					getPage('<a href="' + "javascript:writeImg('" +
								"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
								"MM_nbGroup('down','group1'," + "'cur" + i +
								"','../../images/Arrow-circle.gif',1);" + '">' + 
								desc[i+1] + "</a>",i);
				}
			}
		}
		else
		{
			for (var j=0; j<hlen; j++)
			{
				if (hitPart[j] == pageLnk[i][0])
				{
					if (access == true)
					{
						//match hit part and the part
						if (desclen == 0)
						{
							getPage('<font color=red>*&nbsp;</font><b><a href=javascript:writeImg("'+res+'") onMouseDown="' + 
									"setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + (i+1) + '</a></b>',i);
						}
						else
						{
							getPage('<font color=red>*&nbsp;</font><b><a href=javascript:writeImg("'+res+'") onMouseDown="' + 
                                    "setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + desc[i+1] + '</a></b>',i);
						}
					}
					else
					{
						if (desclen == 0)
						{
							getPage('<a href="' + "javascript:writeImg('" +
										"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
										"MM_nbGroup('down','group1'," + "'cur" + i +
										"','../../images/Arrow-circle.gif',1);" + '">' + 
										(i+1) + "</a>",i);
						}
						else
						{
							getPage('<a href="' + "javascript:writeImg('" +
										"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
										"MM_nbGroup('down','group1'," + "'cur" + i +
										"','../../images/Arrow-circle.gif',1);" + '">' + 
										desc[i+1] + "</a>",i);
						}
					}

					//set hit to true to escape the next if statement
					hit = true;
					hitcon ++;
					break;
				}
			}
			if (!hit)
			{
				if (access == true)
				{
					if (desclen == 0)
					{
						getPage('<a href=javascript:writeImg("'+res+'") onMouseDown="' + 
									"setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + (i+1) + '</a>',i);
					}
					else	
					{
						getPage('<a href=javascript:writeImg("'+res+'") onMouseDown="' + 
									"setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + desc[i+1] + '</a>',i);
					}
				}
				else
				{
					if (desclen == 0)
					{
						getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
									(i+1) + "</a>",i);
					}
					else
					{
						getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
									desc[i+1] + "</a>",i);
					}
				}
			}

			//reset the hit marker
			hit = false;
		}
	}

	if (len > 0)
		MM_nbGroup('down','group1','cur0','../../images/Arrow-circle.gif',1);
}


//
//this function used to write for each page of CM objects
//
function writeNews(pageLnk, hitPart, desc, access)
{

	var hlen = hitPart.length;
	var desclen = desc.length;
	var hit	= false;
	var hitcon = 0;
	var m_swt = 0;
	var res;

	if (pageLnk.length == 1 && pageLnk[0][1] == '')
	{
		return "TOC Error!";
	}

	for (var i=0; i<pageLnk.length; i++)
	{
		res = pageLnk[i][1];
		var cnt = res.length;

/*
		for (var j=0; j<cnt; j++)
		{
			//Remarked by tony
			//res = res.replace("\\", "/");
			
			//Netscape4.76
			if (c_bw.ie)
				res = res.replace("\\", "/");
			else if (c_bw.ns)
				res = res.replace(/\/\/\//, "/");
		}
*/
		res = microPath(res);

		if (hitcon == hlen)
		{
			if (access == true)
			{
				if (desclen == 0)
				{
					getPage('<a href="' + res + '" target="rightFrame" onMouseDown="' + 
							  "setCurImg('" + res + "');MM_nbGroup('down','group1'," +
							  "'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
							  '">' + (i+1) + '</a>',i);
				}
				else
				{
					getPage('<a href="' + res + '" target="rightFrame" onMouseDown="' + 
							  "setCurImg('" + res + "');MM_nbGroup('down','group1'," +
							  "'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
							  '">' + desc[i+1] + '</a>',i);
				}
			}		
			else
			{
				if (desclen == 0)
				{
					getPage('<a href="' + "javascript:writeImg('" +
								"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
								"MM_nbGroup('down','group1'," + "'cur" + i +
								"','../../images/Arrow-circle.gif',1);" + '">' + 
								(i+1) + "</a>",i);
				}
				else	
				{
					getPage('<a href="' + "javascript:writeImg('" +
								"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
								"MM_nbGroup('down','group1'," + "'cur" + i +
								"','../../images/Arrow-circle.gif',1);" + '">' + 
								desc[i+1] + "</a>",i);
				}


				/* Old remarked by Andy
				getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
							"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
							"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
							(i+1) + "</a>",i);
				*/
			}
		}
		else
		{
			for (var j=0; j<hlen; j++)
			{
				if (hitPart[j] == pageLnk[i][0])
				{
					if (access == true)
					{
						//match hit part and the part
						if (desclen == 0)
						{
							getPage('<font color="red">*&nbsp;</font><b><a href="' +  
								res + '" target="rightFrame" onMouseDown="' + 
								"setCurImg('" + res + "');MM_nbGroup('down','group1'," + 
								"'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
								'">' + (i+1) + "</a></b>",i);
						}
						else
						{
							getPage('<font color="red">*&nbsp;</font><b><a href="' +  
								res + '" target="rightFrame" onMouseDown="' + 
								"setCurImg('" + res + "');MM_nbGroup('down','group1'," + 
								"'cur" + i + "','../../images/Arrow-circle.gif',1);" + 
								'">' + desc[i+1] + "</a></b>",i);
						}
					}
					else
					{
						if (desclen == 0)
						{
							getPage('<a href="' + "javascript:writeImg('" +
										"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
										"MM_nbGroup('down','group1'," + "'cur" + i +
										"','../../images/Arrow-circle.gif',1);" + '">' + 
										(i+1) + "</a>",i);
						}
						else
						{
							getPage('<a href="' + "javascript:writeImg('" +
										"rst-cnt_acs_denied.html');" + '" onMouseDown="' +
										"MM_nbGroup('down','group1'," + "'cur" + i +
										"','../../images/Arrow-circle.gif',1);" + '">' + 
										desc[i+1] + "</a>",i);
						}

						/* Old remarked by Andy
						getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
									(i+1) + "</a>",i);
						*/
					}

					//set hit to true to escape the next if statement
					hit = true;
					hitcon ++;
					break;
				}
			}
			if (!hit)
			{
				if (access == true)
				{
					if (desclen == 0)
					{
						getPage('<a href=javascript:DisplayImage("'+res+'") onMouseDown="' + 
									"setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + (i+1) + '</a>',i);
					}
					else	
					{
						getPage('<a href=javascript:DisplayImage("'+res+'") onMouseDown="' + 
									"setCurImg('" + res + "');MM_nbGroup('down','group1'," +
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" +
									'">' + desc[i+1] + '</a>',i);
					}
				}
				else
				{
					if (desclen == 0)
					{
						getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
									(i+1) + "</a>",i);
					}
					else
					{
						getPage('<a href="' + "javascript:parent.rightFrame.location.href=" +
									"'rst-cnt_acs_denied.html';MM_nbGroup('down','group1'," + 
									"'cur" + i + "','../../images/Arrow-circle.gif',1);" + '">' + 
									desc[i+1] + "</a>",i);
					}
				}
			}

			//reset the hit marker
			hit = false;
		}
	}

	if (len > 0)
		MM_nbGroup('down','group1','cur0','../../images/Arrow-circle.gif',1);
}

//Function used to format microfilm sever path for different batch
//val:		is the file location with batch
//return res:	add the microfilm server at front
function microPath(val)
{
	if (val == null || val == '')
		return;

	var res = "";

	if (val.toUpperCase() >= "BATCH01" && val.toUpperCase() < "BATCH05")
	{
		res = c_MSVirPath + c_MSDrvG + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH05" && val.toUpperCase() < "BATCH09")
	{
		res = c_MSVirPath + c_MSDrvH + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH09" && val.toUpperCase() < "BATCH13")
	{
		res = c_MSVirPath + c_MSDrvI + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH13" && val.toUpperCase() < "BATCH15")
	{
		res = c_MSVirPath + c_MSDrvJ + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH15" && val.toUpperCase() < "BATCH18")
	{
		res = c_MSVirPath + c_MSDrvK + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH18" && val.toUpperCase() < "BATCH27") 
	{
		res = c_MSVirPath + c_MSDrvQ + "/" + val;
		return res;
	}
	else if (val.toUpperCase() >= "BATCH27" && val.toUpperCase() < "BATCH33") 
	{
		res = c_MSVirPath + c_MSDrvL + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH33" && val.toUpperCase() < "BATCH34") 
	{
		res = c_MSVirPath + c_MSDrvM + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH34" && val.toUpperCase() < "BATCH38") 
	{
		res = c_MSVirPath + c_MSDrvR + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH38" && val.toUpperCase() < "BATCH42") 
	{
		res = c_MSVirPath + c_MSDrvS + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH42" && val.toUpperCase() < "BATCH46") 
	{
		res = c_MSVirPath + c_MSDrvT + "/" + val;	
		return res;
	}
	else if (val.toUpperCase() >= "BATCH46")
	{
		res = c_MSVirPath + c_MSDrvU + "/" + val;
		return res;
	}
	else
		alert("Format Microfilm Server Path Fail! Batch Output Of Range");
}



//Function for content cover write each row of meta information for subject
//creator and contributor will make a link to do a attribute search on the
//content.
//	label:	is the label of the attribute
//	val:		is the array value of the attribute
//	lnk:		true or false to make a search link
//
function getLine(label, val, lnk, param)
{
	var chifont = "";

	if (l_CurrLang == c_ChsLang)
	{
		chifont = "文鼎中明簡,";
	}
	else if (l_CurrLang == c_ChtLang)
	{
		chifont = "MingLiu,";
  	}

	var res;
	var len	=	val.length;
	var i		= 	0;
	var subform = document.subform;

	var optr		= "<tr valign='top'>";
	
	//Modified by Tony Tse on 28.02.2001
	//var optd		= "<td nowrap width='200'><font face='Verdana' size='2'>";
	var optd		= "<td nowrap width='200'><font face='"+chifont+"Verdana' size='2'>";
	//var optdb	= "<td nowrap bgcolor='#F9EFE8' width='200'><font face='Verdana' size='2'>";
	var optdb	= "<td nowrap bgcolor='#F9EFE8' width='200'><font face='"+chifont+"Verdana' size='2'>";

	//var optdw	= "<td width='100%' align='left'><font face='Verdana' size='2'>";
	var optdw	= "<td width='100%' align='left'><font face='"+chifont+"Verdana' size='2'>";
	//var optdwb	= "<td width='100%' align='left' bgcolor='#F9EFE8'><font face='Verdana' size='2'>";
	var optdwb	= "<td width='100%' align='left' bgcolor='#F9EFE8'><font face='"+chifont+"Verdana' size='2'>";

	var cltd		= "</font></td>";
	var cltr		= "</tr>";

	//var qut		= "<td width='5'><font face='Verdana' size='2'>:" + cltd;
	var qut		= "<td width='5'><font face='"+chifont+"Verdana' size='2'>:" + cltd;
	//var qutb		= "<td width='5' bgcolor='#F9EFE8'><font face='Verdana' size='2'>:" + cltd;
	var qutb		= "<td width='5' bgcolor='#F9EFE8'><font face='"+chifont+"Verdana' size='2'>:" + cltd;
	
	if (len <= 1 )
		return

	if (m_swt == null)
	{
		//initial
		m_swt = 1;
		res = optr + optd + label + cltd + qut + optdw; 
	}
	else if (m_swt == 0)
	{
		//event row not background colour
		//set m_swt to odd
		m_swt = 1;
		res = optr + optd + label + cltd + qut + optdw; 
	}
	else if (m_swt == 1)
	{
		//odd row have background colour
		//set m_swt to odd
		m_swt = 0;
		res = optr + optdb + label + cltd + qutb + optdwb; 
	}
	else
	{
		alert("javascript error CotentCover::getLine()");
		return;
	}
	
	var sVal="";
	for (i = 0; i<len-1; i++)
	{
		if (lnk)
		{
			sVal = val[i].replace(/'/g,"\\'");
			//sVal = unescape(sVal);
			res += '<a href="javascript:search(' + "'" + val[i+1] + "', '" + sVal + "', '" + param + "', document.subform" + ')";>' + val[i] + "</a>";
			i++;
		}
		else if ((!lnk) && param != null)
		{
			res += '<a href="' + val[i] + '">' + val[i] + '</a>';
		}
		else
			res += val[i];

		res += "<br>";
	}
	

	res += cltd + cltr;

	document.writeln(res);

}


//
//function used to assign the value to the form and submit it
//
function search(s_value, keyword, param, subform)
{
	var id;

	id = s_value.replace(" " ,"");

	subform.action = c_DominName + c_Service + c_DefGateWay;
	subform.svc.value		=	c_BasSvc;
	subform.stype.value	=	"attr";
	subform.param.value	=	param;
	subform.ctrlid.value	=	id;
	subform.schtxt.value	=	keyword;
	subform.max.value		=	c_HLMax;
	subform.frm.value		=	1;
	subform.to.value		=	c_FHLHitPerPage;
	subform.ss.value		=	c_SSFulDtl;
	subform.hitperpage.value	=	c_FHLHitPerPage;

/*
	qryStr = c_DominName + c_Service + c_DefGateWay + "?" +
				"svc=" + subform.svc.value + "&col=" + subform.col.value + 
				"&stype=" + subform.stype.value + "&param=" + subform.param.value + 
				"&schtxt=" + subform.schtxt.value + "&max=" + subform.max.value + 
				"&frm=" + subform.frm.value + "&to=" + subform.to.value +
				"&ss=" + subform.ss.value + 
				"&hitperpage=" + subform.hitperpage.value; 
	alert(qryStr);
*/

	subform.submit();
}

/**
 * Write the embedded preview link
 * @param   LnkSrc   Location of the movie file
 * @param   nHeight  Height of the control
 * @param   nWidth   Width of the control
 * @param   hasCtrl  true if want to include the control interface
 */
function writePreviewLnk(LnkSrc, nHeight, nWidth, hasCtrl)
{
	c_WriteQTLnk(LnkSrc, nHeight, nWidth, hasCtrl);
}

/**
 * Write the embedded prelisten link
 * @param   LnkSrc   Location of the movie file
 * @param   nHeight  Height of the control
 * @param   nWidth   Width of the control
 * @param   hasCtrl  true if want to include the control interface
 */
function writePrelistenLnk(LnkSrc, nHeight, nWidth, hasCtrl)
{
	c_WriteDLMPLnk(LnkSrc, nHeight, nWidth, 'true');
}

function resizeImg(src, img)
{
	var width=screen.width-150;
	var height=screen.height-370;

	var newWidth;
	var Height;

	img.src = src;
	
	// fit to width
	if (img.width <= width)
	{
		newWidth = img.width;
		newHeight = img.height;
	}
	else 
	{
		newWidth = width;
		newHeight = img.height * (width / img.width);
	}

	// fit to width/height
	/*
	if (img.width < width && img.height < height)
	{
		newWidth  = img.width;
		newHeight  = img.height;
	}
	else if (img.width > width || img.height > height)
	{
		if (img.width >= img.height)
		{
			newWidth = width;
			newHeight = img.height * (width / img.width);
		}
		else if (img.height > img.width)
		{
			newHeight = height;
			newWidth = img.width * (height / img.height);
		}
	}
	*/

	img.width = newWidth;	
	img.height = newHeight;	
	
//	parent.rightFrame.imgform.img_obj.src=img;
//	parent.rightFrame.location.reload();
}
	
function showImg(img_obj)
{
	var img = new Image();
	img = parent.leftFrame.img;

	if (img != null)
	{
		img_obj.src=img.src;
		img_obj.width=img.width;
		img_obj.height=img.height;
	}
}

function getUrl(urlId)
{
	var res;
	var id = "urlId="+urlId;
	res = c_DominName + c_Service + c_DefGateWay + "?svc=" + c_UrlSvc + "&" + id ;
//	parent.location.href = res;
	window.open(res);
}

function  setImg(src)
{
	var img = new Image();
	var src = parent.leftFrame.curImgWithToken;
	if (src != null && src!="")
	{
		resizeImg(src, img);
		document.img_obj.src = img.src;
		document.img_obj.width = img.width;
		document.img_obj.height = img.height;
	}
	else
		document.location.reload();
}

function  setResizedImg()
{
	var width = 0;
	var height = 0;

	var ns = (document.layers) ? 1 : 0;
	var ie = (document.all) ? 1 : 0;
	var dom = (document.getElementById) ? 1 : 0;

	if (ie)
	{
		width = document.body.clientWidth-55;
		height = document.body.clientHeight;
	}
	else if (ns)
	{
		width = window.innerWidth-55;
		height = window.innerHeight;
	}
	else if (dom)
	{
		width = document.documentElement.clientWidth-55;
		height = document.documentElement.clientHeight;
	}

	var img = new Image();
	var src = parent.leftFrame.curImgWithToken;

	if (src != null && src != "")
	{
		img.src = src;
	
		//var currHeight = (img.width > width ? img.height * (width/img.width) : img.height);
		//var currWidth = (img.width > width ? width : img.width);

		if (ns)
		{
			//document.imgLayer.document.open();
			//document.imgLayer.document.write('<IMG WIDTH="' + currWidth + + 'HEIGHT="' + currHeight + '" SRC="' + img.src + '">');
			//document.imgLayer.document.write('<IMG WIDTH="' + width + '" SRC="' + img.src + '">');
			//document.imgLayer.document.close();
			document.open();
			document.write('<body bgcolor="#F2E3D6">');
			document.write('<IMG WIDTH="' + width + '" SRC="' + img.src + '">');
			document.write('</body>');
			document.close();
		}
		else
		{
			document.img_obj.src = img.src;
			document.img_obj.width = width;
		}
	}

}

/* COU Enhancement by Thomas 07/01/2011 */

/*
The parameters of the function getCookie hold the name of the cookie, 
the value of the cookie, and the number of days until the cookie expires.

The function first converts the number of days to a valid date, 
then add the number of days until the cookie should expire. 
After that, the cookie name, cookie value and the expiration date 
is stored in the document.cookie object.
*/

function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
		    { 
			    c_start=c_start + c_name.length+1 ;
			    c_end=document.cookie.indexOf(";",c_start);
			    if (c_end==-1) c_end=document.cookie.length
			    return unescape(document.cookie.substring(c_start,c_end));
		    } 
	  }
	return ""
}

/*
The function setCookie checks if a cookie is stored at all in the document.cookie object. 
If the document.cookie object holds some cookies, 
then check to see if the specific cookie is stored. 
If the cookie is found, then return the value, if not - return an empty string.
*/

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

/*
getParentCookie and setParentCookie do the same functions as getCookie and setCookie
except on the parent document.
*/

function getParentCookie(c_name)
{
	if (window.parent.document.cookie.length>0)
	  {
		  c_start=window.parent.document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
		    { 
			    c_start=c_start + c_name.length+1 ;
			    c_end=window.parent.document.cookie.indexOf(";",c_start);
			    if (c_end==-1) c_end=window.parent.document.cookie.length
			    return unescape(window.parent.document.cookie.substring(c_start,c_end));
		    } 
	  }
	return ""
}

function setParentCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	window.parent.document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

/* When the COU is agreed, the COU page becomes disappeared. */

function COUAgreed() {
	setCookie('CouAgreement','COUAgreed',null);
	document.getElementById('popCOU').style.display='none';
	document.getElementById('ContentCoverDiv').style.display='block';
}

/* COUAgreed do the same function as COUAgreed_RFrame except it is for right frame HTML pages. */

function COUAgreed_RFrame() {
	setParentCookie('CouAgreement','COUAgreed',null);
	window.parent.location.reload();
}

/* 
COU_DIV displays the COU page for ContentPhoto.xsl, ContentMap.xsl, ContentPoster.xsl,
ContentAudio.xsl, ContentVideo.xsl 
*/

function COU_DIV(LangPara){	

	document.write(" <div id='popCOU' style='display:none;'>");
	document.write("	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='left'>");
	document.write("    	<tr height='100'> ");
	document.write("      		<td width='95'>&nbsp;</td>");
	document.write("      		<td>&nbsp;</td>");
	document.write("    	</tr>");
	document.write("    	<tr> ");
	document.write("      		<td>&nbsp;</td>");
	document.write("      		<td> ");

	if (LangPara == 'cht') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_cht.html'></iframe>");
	else if (LangPara == 'eng') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_eng.html'></iframe>");
	else if (LangPara == 'chs') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_chs.html'></iframe>");

	document.write("	  		</td>");
	document.write("    	</tr>");
	document.write("    	<tr> ");
	document.write("      		<td>&nbsp;</td>");
	document.write("    	</tr>");
	document.write("    	<tr> ");
	document.write("      		<td>&nbsp;</td>");
	document.write("      		<td align='center'> ");

	if (LangPara == 'cht') { 		
		document.write("		<input type='submit' name='Submit' value='　 接 受　 ' onclick='COUAgreed()'> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<input type='submit' name='Submit' value='　 拒 絕　 ' onclick='javascript:history.back();'> ");
		document.write("		</input> ");		
	} else if (LangPara == 'eng') {	
		document.write("		<input type='submit' name='Submit' value='　 Accept　' onclick='COUAgreed()'> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<input type='submit' name='Submit' value='　 Reject　' onclick='javascript:history.back();'> ");
		document.write("		</input> ");
	} else if (LangPara == 'chs') {
		document.write("		<font face='文鼎中明簡'><input type='submit' name='Submit' value='　 接 受　 ' onclick='COUAgreed()'></font> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<font face='文鼎中明簡'><input type='submit' name='Submit' value='　 拒 絕　 ' onclick='javascript:history.back();'></font> ");
		document.write("		</input> ");
	}

	document.write("	  		</td>");
	document.write("    	</tr>");
	document.write("	</table>");
	document.write(" </div>");

	CouAgreement=getCookie('CouAgreement');

	if (CouAgreement=="COUAgreed") {
		document.getElementById('popCOU').style.display='none';
		document.getElementById('ContentCoverDiv').style.display='block';		
	} else {
		document.getElementById('ContentCoverDiv').style.display='none';
		document.getElementById('popCOU').style.display='block';
	}

}

/* 
COU_DIV displays the COU page for rst-cnt_art_right.html, rst-cnt_bk_right.html, 
rst-cnt_hp_right.html, rst-cnt_lit_right.html, rst-cnt_manu_right.html, 
rst-cnt_micnew_right.html, rst-cnt_min_right.html 
*/

function COU_DIV_RFrame(LangPara){		

	document.write(" <div id='popCOU' style='display:none;'>");
	document.write("	<table width='100%' border='0' cellspacing='0' cellpadding='0' align='left'>");
	document.write("    	<tr> ");
	document.write("      		<td> ");

	if (LangPara == 'cht') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_cht.html'></iframe>");
	else if (LangPara == 'eng') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_eng.html'></iframe>");
	else if (LangPara == 'chs') 
		document.write("            <iframe width='100%' height='700' frameborder='0' src='../../html/coucc_chs.html'></iframe>");

	document.write("	  		</td>");
	document.write("    	</tr>");
	document.write("    	<tr> ");
	document.write("      		<td>&nbsp;</td>");
	document.write("    	</tr>");
	document.write("    	<tr> ");
	document.write("      		<td align='center'> ");
		
	if (LangPara == 'cht') { 		
		document.write("		<input type='submit' name='Submit' value='　 接 受　 ' onclick='COUAgreed_RFrame()'> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<input type='submit' name='Submit' value='　 拒 絕　 ' onclick='javascript:history.back();'> ");
		document.write("		</input> ");		
	} else if (LangPara == 'eng') {	
		document.write("		<input type='submit' name='Submit' value='　 Accept　' onclick='COUAgreed_RFrame()'> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<input type='submit' name='Submit' value='　 Reject　' onclick='javascript:history.back();'> ");
		document.write("		</input> ");
	} else if (LangPara == 'chs') {
		document.write("		<font face='文鼎中明簡'><input type='submit' name='Submit' value='　 接 受　 ' onclick='COUAgreed_RFrame()'></font> ");
		document.write("		</input> ");
		document.write("      &nbsp;");
		document.write("		<font face='文鼎中明簡'><input type='submit' name='Submit' value='　 拒 絕　 ' onclick='javascript:history.back();'></font> ");
		document.write("		</input> ");
	}
	
	document.write("	  		</td>");
	document.write("    	</tr>");
	document.write("	</table>");
	document.write(" </div>");

	CouAgreement=getParentCookie('CouAgreement');

	if (CouAgreement=="COUAgreed") {
		document.getElementById('popCOU').style.display='none';
		document.getElementById('ContentCoverDiv').style.display='block';		
	} else {
		document.getElementById('ContentCoverDiv').style.display='none';
		document.getElementById('popCOU').style.display='block';
	}    

}

/* 
COUCheckAgreement is used to check whether the COU is agreed or not.
It is used in rst-cnt_art_head.html, rst-cnt_art_left.html, rst-cnt_bk_head.html,
rst-cnt_bk_left.html, rst-cnt_hp_head.html, rst-cnt_hp_left.html,
rst-cnt_lit_head.html, rst-cnt_lit_left.html, rst-cnt_manu_head.html,
rst-cnt_manu_left.html, rst-cnt_micnew_head.html, rst-cnt_micnew_left.html,
rst-cnt_min_head.html, rst-cnt_min_left.html
*/

function COUCheckAgreement(){	

	CouAgreement=getParentCookie('CouAgreement');

	if (CouAgreement=="COUAgreed") {
		document.getElementById('ContentCoverDiv').style.display='block';		
	} else {
		document.getElementById('ContentCoverDiv').style.display='none';
	}
    
}

/* COU Enhancement End */

