// eHelp® Corporation Dynamic HTML JavaScript 
// Copyright© 1998-2003 eHelp® Corporation.All rights reserved.
// Version=4.82

// Warning:Do not modify this file.It is generated by RoboHELP® and changes will be overwritten.

//// Segment Begin -- (JavaScript 1.0)

/// Section Begin - General and relative topics(JavaScript 1.0)
/*
//{{HH_SYMBOL_SECTION
var HH_ChmFilename = "C:\\Program Files\\RoboHelp Office\\RoboHTML\\Testing2\\Testing2.chm";
var HH_WindowName = "NewWindow";
var HH_GlossaryFont = "";
var HH_Glossary = "1";
var HH_Avenue = "1";
var HH_ActiveX = true;
//}}HH_SYMBOL_SECTION
*/
//Begin to support previous generic parameters
//Get the information about the browser.
var gstrBsAgent 	= navigator.userAgent.toLowerCase();
var gnBsVer	   		= parseInt(navigator.appVersion);

var gbBsOpera		= (gstrBsAgent.indexOf('opera') != -1);
var gbBsKonqueror	= (gstrBsAgent.indexOf('konqueror') != -1);
var gbBsSafari		= (gstrBsAgent.indexOf('safari') != -1);
var gbBsIE  		= (gstrBsAgent.indexOf('msie') != -1) && !gbBsOpera && !gbBsKonqueror && !gbBsSafari;
var gbBsNS  		= (gstrBsAgent.indexOf('mozilla') != -1) && ((gstrBsAgent.indexOf('spoofer') == -1) && (gstrBsAgent.indexOf('compatible') == -1)) && !gbBsOpera && !gbBsKonqueror && !gbBsSafari;

var gbBsMac			= (gstrBsAgent.indexOf('mac') != -1);
var gbBsWindows		= ((gstrBsAgent.indexOf('win') != -1) || (gstrBsAgent.indexOf('16bit') != -1));
var gbBsSunOS		= (gstrBsAgent.indexOf("sunos") != -1);

var gbBsIE3Before 	= ((gbBsIE) && (gnBsVer <= 2));
var gbBsNS3Before 	= ((gbBsNS) && (gnBsVer <= 3));

var gbBsNS2			= ((gbBsNS) && (gnBsVer <= 2));
var gbBsNS3			= ((gbBsNS) && (gnBsVer == 3));
var gbBsIE300301	= ((gbBsIE) && (gnBsVer == 2) && ((gstrBsAgent.indexOf("3.00") != -1)||(gstrBsAgent.indexOf("3.0a") != -1)||(gstrBsAgent.indexOf("3.0b")!=-1)||(gstrBsAgent.indexOf("3.01")!=-1)));
var gbBsIE302		= ((gbBsIE) && (gnBsVer == 2) && (gstrBsAgent.indexOf("3.02") != -1));

var gbBsNS4			= ((gbBsNS) && (gnBsVer >= 4));
var gbBsNS6			= ((gbBsNS) && (gnBsVer >= 5));
var	gbBsNS7			= false;

var gbBsIE4			= ((gbBsIE) && (gnBsVer >= 4));
var gbBsIE5			= false;
var gbBsIE55		= false;

var gbBsOpera6		= false;
var gbBsOpera7		= false;

var gbBsKonqueror3	= false;

gbBsIE = (navigator.appName.indexOf("Microsoft") != -1) && !gbBsOpera && !gbBsKonqueror && !gbBsSafari;;
if (gbBsIE)
{
	if (parseInt(navigator.appVersion) >= 4) {
		gbBsIE4 = true;
		if (gbBsIE4) {
			var nPos = gstrBsAgent.indexOf("msie");
			var strIEversion = gstrBsAgent.substring(nPos + 5);
			var nVersion =  parseFloat(strIEversion);
			if (nVersion >= 5)
				gbBsIE5 = true;
			if (nVersion >= 5.5)
				gbBsIE55 = true;
		}
	}
}
if (gbBsNS6)
{
	var nPos=gstrBsAgent.indexOf("gecko");
	if(nPos!=-1)
	{
		var nPos2=gstrBsAgent.indexOf("/", nPos);
		if(nPos2!=-1)
		{
			var nVersion=parseFloat(gstrBsAgent.substring(nPos2+1));
			if (nVersion>=20020823)
				gbBsNS7=true;
		}
	}	
}
if (gbBsOpera)
{
	var nPos = gstrBsAgent.indexOf("opera");
	if(nPos!=-1)
	{
		var nVersion = parseFloat(gstrBsAgent.substring(nPos+6));
		if (nVersion >= 6)
		{
			gbBsOpera6=true;
			if (nVersion >=7)
				gbBsOpera7=true;	
		}
	}
}
if (gbBsKonqueror)
{
	var nPos = gstrBsAgent.indexOf("konqueror");
	if(nPos!=-1)
	{
		var nVersion = parseFloat(gstrBsAgent.substring(nPos+10));
		if (nVersion >= 3)
		{
			gbBsKonqueror3=true;
		}
	}
}

function insertAdjacentHTML(obj, where, htmlStr)
{
	if (gbBsIE || gbBsOpera7)
	{
		obj.insertAdjacentHTML(where, htmlStr);
	}
	else if (gbBsNS6 || gbBsSafari)
	{
		var r = obj.ownerDocument.createRange();
		r.setStartBefore(obj);
		var	parsedHTML = r.createContextualFragment(htmlStr);
		
		switch (where){
		case 'beforeBegin':
			obj.parentNode.insertBefore(parsedHTML,obj);
			break;
		case 'afterBegin':
			obj.insertBefore(parsedHTML,obj.firstChild);
			break;
		case 'beforeEnd':
			obj.appendChild(parsedHTML);
			break;
		case 'afterEnd':
			if (obj.nextSibling){
			obj.parentNode.insertBefore(parsedHTML,obj.nextSibling);
			} else {
			obj.parentNode.appendChild(parsedHTML);
			}
			break;
		}
	}
}

// Utilities functions.
function BsscHasExtJs()
{
	if( gbBsIE3Before || gbBsNS3Before)
		return false;
	return true;
}
/*
// Register event handler
var gBsOnLoads 			= new Array();	// An array holds all the onload event handler.
var gBsOnClicks 		= new Array();	// An array holds all the onClick event handler.
var gBsOnUnLoads 		= new Array();	// An array holds all the OnUnLoad event handler.
var gBsOnMouseOvers 	= new Array();	// An array holds all the OnMouseOver event handler.
var gBsOnMouseOuts 		= new Array();	// An array holds all the OnMouseOut event handler.
*/
var gbOrignalOnMouseDown = null;
/*
//Begin to support previous relative topics
//If webHelp needs Related Topics DHTMLcode, it's supposed to add it here
var gbPopupMenuTimeoutExpired = false;
var gbInPopupMenu = false;
var gbPopupMenuTopicList = null;
var gOlddocumentClick = null;

//////////////////////////////////////////////////////////////////////////////////////////
//
// Popup Menu code
//
//////////////////////////////////////////////////////////////////////////////////////////


//End to support previous relative topics

/// Section End - General and relative topics (JavaScript 1.0)
*/
/// Section Begin  - Popup (JavaScript 1.0)
//Begin to support previous popup functions

//variables used to isolate the browser type
var gBsStyVisShow	= null;
var gBsStyVisHide	= null;
var gBsClientWidth	= 640;
var gBsClientHeight = 480;

// here is the varible for judge popup windows size. these parameter is for IE5.0, it may need adjust for others.
var gBRateH_W		= 0.618; // 1.618 Golden cut.
var gBMaxXOfParent	= 0.8; 
var gBMaxYOfParent	= 0.8;
var gBscrollHeight   = 16;
var gBscrollWidth   =  16;
var gBpermitXDelta	= 3;
var gBpermitYDelta	= 3;


var arrayPopupURL = new Array();
var arrayAbsPopupURL = new Array();

var arrayDirty = new Array();

function setAbsPopupURL(nIndex, strURL)
{
	arrayAbsPopupURL[nIndex] = strURL;
}

function getAbsPopupURL(nIndex)
{
	if (nIndex == -1 || arrayAbsPopupURL.length <= nIndex) return null;
	else 
		return arrayAbsPopupURL[nIndex];
}

function getPopupURL(nIndex)
{
	if (nIndex == -1 || arrayPopupURL.length <= nIndex) return null;
	else 
		return arrayPopupURL[nIndex];
}

function getPopupID(nIndex)
{
	return gstrPopupID + nIndex;
}

function getPopupShadowID(nIndex)
{
	return gstrPopupShadowID + nIndex;
}

function getPopupTopicID(nIndex)
{
	return gstrPopupTopicID + nIndex;
}

function getPopupIFrameID(nIndex)
{
	return gstrPopupIFrameID + nIndex;
}

function getPopupIFrameName(nIndex)
{
	return gstrPopupIFrameName + nIndex;
}


function getPopupTopicStyle(nIndex)
{
	return getElement(getPopupTopicID(nIndex)).style;
}

function getPopupShadowStyle(nIndex)
{
	return getElement(getPopupShadowID(nIndex)).style;
}

function getPopupIFrame(nIndex)
{
	if (gbBsNS6)
		return eval("window.frames['" + getPopupIFrameName(nIndex) + "']");
	else
		return eval("document.frames['" + getPopupIFrameName(nIndex) + "']");
}

function getPopupDivStyle(nIndex)
{
	return getElement(getPopupID(nIndex)).style;
}

function getPopupIFrameStyle(nIndex)
{
	return getElement(getPopupIFrameID(nIndex)).style;
}


function findDiv(strURL)
{
	for (var i = 0; i < arrayPopupURL.length; i ++ ) {
		if (arrayPopupURL[i] == strURL) {
			return i;
		}
	}
	return -1;
}

var gnToken = -1;
function takeToken()
{
	gnToken ++;
	if (gnToken > 10000) gnToken = 0;
	return gnToken;
}

function IsValidToken(nToken)
{
	return (gnToken == nToken);
}

function addDiv(strURL)
{
	for (var i = 0; i < arrayPopupURL.length; i ++) {
		if (arrayPopupURL[i] == null) {
			arrayPopupURL[i] = strURL;
			return i;
		}
	}	
	arrayPopupURL[i] = strURL;
	arrayDirty[i] = true;
	return i;
}

function setDirty()
{
	for (var i = 0; i < arrayPopupURL.length; i ++ )
		arrayDirty[i] = true;
}

function IsDirty(nIndex)
{
	if (nIndex == -1)
		return true;
	else 
		if (arrayDirty.length > nIndex) 
			return arrayDirty[nIndex];
		else
			return true;
}

function hideAll()
{
	for (var i = 0; i < arrayPopupURL.length; i ++ )
	{
		getPopupDivStyle(i).visibility = gBsStyVisHide;
		getPopupIFrameStyle(i).visibility = gBsStyVisHide;
	}
}

function getCurrentPopupIFrame()
{
	for (var i = 0; i < arrayPopupURL.length; i ++)
		if (getPopupDivStyle(i).visibility == gBsStyVisShow)
			return getPopupIFrame(i);
	return null;
}

function setClear(nIndex)
{
	if (nIndex != -1)
		arrayDirty[nIndex] = false;
}

function _BSSCCreatePopupDiv(strURL)
{
	var nIndex = findDiv(strURL);
	if (nIndex == -1 ) {
		nIndex = addDiv(strURL);
		BsPopup_CreateDiv(nIndex);
	}
	else {
		if (IsDirty(nIndex)) {
			if("object" == typeof(getPopupIFrame(nIndex).document))
				getPopupIFrame(nIndex).document.location.href = strURL;
		}
	}
	return nIndex;
}

//Here is the browser type 
function _BSPSGetBrowserInfo()
{
	if (gbBsNS4&&!gbBsNS6)
	{
		gBsStyVisShow	= "show";
		gBsStyVisHide	= "hide";
	}
	else
	{
		gBsStyVisShow	= "visible";
		gBsStyVisHide	= "hidden";
	}
}

_BSPSGetBrowserInfo();

//Get client size info
function _BSPSGetClientSize()
{
	if (gbBsNS4||gbBsKonqueror3||gbBsSafari)
	{
		gBsClientWidth	= innerWidth;
		gBsClientHeight = innerHeight;
	}
	else if (gbBsIE4 || gbBsOpera7)
	{
		gBsClientWidth	= document.body.clientWidth;
		gBsClientHeight = document.body.clientHeight;
	}
}

var gstrPopupID = 'BSSCPopup';
var gstrPopupShadowID = 'BSSCPopupShadow';
var gstrPopupTopicID = 'BSSCPopupTopic';
var gstrPopupIFrameID = 'BSSCPopupIFrame';
var gstrPopupIFrameName = 'BSSCPopupIFrameName';

var gstrPopupSecondWindowName = 'BSSCPopup';

var gPopupWindow = null;
var gnPopupClickX = 0;
var gnPopupClickY = 0;

var gnPopupScreenClickX = 0;
var gnPopupScreenClickY = 0;

var gbPopupTimeoutExpired = false;

function DHTMLPopupSupport()
{
	if (((gbBsIE4) && (!gbBsMac))||gbBsOpera7|| gbBsNS7) {
		return true;
	}
	return false;
}
/*
function BSSCPopup_IsPopup()
{
	if (DHTMLPopupSupport() && (this.name.indexOf(gstrPopupIFrameName) != -1)) {
		return true;
	} else if ((gbBsNS4 || gbBsIE4 || gbBsOpera7) && (this.name.indexOf(gstrPopupID) != -1)) {
		return true;
	} else {
		return false;
	}
}

// If there is a hyperlink in a popup window, display the hyperlink in
// the original window. (bsscright)
if (BSSCPopup_IsPopup() && !gbBsIE4 && !gbBsOpera7) {
	document.write("<base target=\"bsscright\">");
}
*/
// Local functions.
function BsPopup_CreateDiv(nIndex)
{
	if(!DHTMLPopupSupport())
		return;
	// DO NOT SET Width and height for the div, otherwize it will make IE4 popup do not work when view the topic alone.
	var strPopupDiv = "<DIV ID='" + getPopupID(nIndex) + "' STYLE='position:absolute; top:-100; left:0; z-index:600; visibility:hidden;'>";
	strPopupDiv += "<DIV ID='" + getPopupShadowID(nIndex) + "' STYLE=\"position:absolute;top:0; left:0;  background-color:#C0C0C0;\"></DIV>";
	strPopupDiv += "<DIV ID='" + getPopupTopicID(nIndex) + "' STYLE=\"position:absolute;top:0; left:0;  background-color:#FFFFFF;border:1px #000000 outset;\">";
	strPopupDiv += "<IFRAME title=\"Popup Window\" ID='" + getPopupIFrameID(nIndex) + "' name='" + getPopupIFrameName(nIndex) + "' src = '" + getPopupURL(nIndex) + "' frameborder=0 scrolling=auto></IFRAME>";
	strPopupDiv += "</DIV></DIV>";

	var objBody = getElementsByTag(document, "BODY")[0];
	if( typeof(objBody) != "object" )
		return;

	insertAdjacentHTML(objBody, "beforeEnd", strPopupDiv);
}

function handleLoadNS()
{
	if (this.id)
	{
		var nIndex = parseInt(this.id.substring(gstrPopupIFrameID.length));
		BSSCPopup_PostWork(nIndex);
	}
}

function BSSCPopup_PostWork(nIndex)
{
	getPopupDivStyle(nIndex).visibility = gBsStyVisShow;
	getPopupIFrameStyle(nIndex).visibility =gBsStyVisShow;

	setClear(nIndex);
	window.gbPopupTimeoutExpired = true;

	BSSCPopup_ChangeTargettoParent(getPopupIFrame(nIndex).document);
	if (gbBsNS6)
		getPopupIFrame(nIndex).document.body.addEventListener("click",BSSCPopupClicked,false);
	else
		getPopupIFrame(nIndex).document.body.onclick = BSSCPopupClicked;

	if (!gbOrignalOnMouseDown && document.onmousedown)
		gbOrignalOnMouseDown = document.onmousedown;

	if (gbBsNS6)
		document.addEventListener("mousedown", BSSCPopupParentClicked,false);
	else
		document.onmousedown = BSSCPopupParentClicked;
}

function BSSCPopup_Timeout(nIndex, nToken)
{
    if (!IsValidToken(nToken)) return;

	if (gbBsNS6||((getPopupIFrame(nIndex).document.readyState == "complete") &&
		(getPopupIFrame(nIndex).document.body != null))) {
		BSSCPopup_PostWork(nIndex);
	} else {
		setTimeout("BSSCPopup_Timeout(" + nIndex + "," + nToken + ")", 100);
	}
}

// VH 08/10/00 
// do not change target to parent if the href is using javascript
function BSSCPopup_ChangeTargettoParent(tagsObject)
{
	var collA = getElementsByTag(tagsObject, "A");
	BSSCPopup_ChangeTargettoParent2(collA);

	var collIMG = getElementsByTag(tagsObject,"IMG");
	BSSCPopup_ChangeTargettoParent2(collIMG);
}

function BSSCPopup_ChangeTargettoParent2(colls)
{
	if (colls != null)  {
		for (var j = 0; j < colls.length; j ++ )
		{
			var strtemp = colls[j].href;
			if (strtemp)
			{
				strtemp = strtemp.toLowerCase();
				if (strtemp.indexOf("javascript:") == -1)
				if (colls[j].target == "")
					colls[j].target = "_parent";
			}
		}
	}
}
/*
function BSPSPopupTopicWinHelp(strURL)
{
	_BSSCPopup(strURL);
	return;
}
*/
function _BSSCPopup(strURL, width, height)
{
	var cuswidth = 0;
	var cusheight = 0;
	if ("undefined" != typeof(width) && "undefined" != typeof(height)) {
		cuswidth = width;
		cusheight= height;
	}
	
	if (DHTMLPopupSupport()) {
		var nToken = takeToken(); // take  token first.
		var nIndex = _BSSCCreatePopupDiv(strURL);
		window.gbPopupTimeoutExpired = false;
		var ntWidth = gBsClientWidth;
		var ntHeight = gBsClientHeight;
		_BSPSGetClientSize();
		if (ntWidth != gBsClientWidth || ntHeight != gBsClientHeight) {
			setDirty();
		}

		if (IsDirty(nIndex)) {
			if (gbBsMac) {
				setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight  +")", 400);
			} else {
				setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 100);
			}
		}
		else {
			MoveDivAndShow(nIndex ,nToken, cuswidth, cusheight);
		}
	} else {
		_BSSCPopup2(strURL, cuswidth, cusheight);
	}
	return;
}
/*
if (gbBsIE55)
{
	var ehlpdhtm_fOldBefureUnload = window.onbeforeunload;
	var gnBsUnload=0;
	window.onbeforeunload = window_BUnload;
}
	
function window_BUnload()
{
	gnBsUnload++;
	if (gnBsUnload>1)
		return;
	for (var i = 0; i < arrayPopupURL.length; i ++)
		removeThis(document.all(getPopupID(i)));
	arrayPopupURL.length = 0;	
	if (ehlpdhtm_fOldBefureUnload)
		ehlpdhtm_fOldBefureUnload();
}
*/
function _BSSCPopup2(strURL, width, height)
{
	if (gbBsOpera6&&gbBsMac)
	{
		var wmTemp = window.open(document.location.href, gstrPopupSecondWindowName);
		wmTemp.close();
		setTimeout("_BSSCPopup3(\""+strURL+"\","+width+","+height+");",100);
	}
	else
		_BSSCPopup3(strURL, width, height);
}

function _BSSCPopup3(strURL, width, height)
{
	if (window.name == gstrPopupSecondWindowName) {
		window.location = strURL;
	} else {
		if (!gbBsMac || !gbBsNS4) {
			BSSCHidePopupWindow();
		}
		var nX = 0;
		var nY = 0;
		var nHeight = 300;
		var nWidth = 400;
		if (width > 0 && height > 0) {
			nHeight = height;
			nWidth = width;
		}
		_BSPSGetClientSize();

		nX = window.gnPopupScreenClickX;
		nY = window.gnPopupScreenClickY;

		if (nY + nHeight + 40 > screen.availHeight) {
			nY = screen.availHeight - nHeight - 40;
		}
		if (nX + nWidth + 40 > screen.availWidth) {
			nX = screen.availWidth - nWidth - 40;
		}

		// Launch a separate window
		var strParam="titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes";
		if (gbBsNS) {
			if (gbBsNS6) {
				strParam += ",Height=" + nHeight + ",Width=" + nWidth;
				strParam += ",screenX=" + nX + ",screenY=" + nY;
				strParam += ",dependent=yes";
			}
			else {
				strParam += ",OuterHeight=" + nHeight + ",OuterWidth=" + nWidth;
				strParam += ",screenX=" + nX + ",screenY=" + nY;
				strParam += ",dependent=yes";
			}
		}
		else {
			strParam += ",height=" + nHeight + ",width=" + nWidth;
			strParam += ",left=" + nX + ",top=" + nY;
		}
		if (gbBsSafari)
		{
			if (window.gPopupWindow)
				window.gPopupWindow.close();		
			window.gPopupWindow = window.open(strURL, "", strParam);
			window.gPopupWindow.name = gstrPopupSecondWindowName;
			window.gPopupWindow.moveTo(nX, nY);
			widnow.gPopupWindow.document.location.reload();
		}	
		else
		{
			var wmTemp=null;
			if (gbBsKonqueror3)
			{
				if (window.gPopupWindow)
					window.gPopupWindow.close();
			}
			if (gbBsOpera&&gbBsMac)
			{
				wmTemp= window.open(document.location.href, "Temp", strParam);
			}
			window.gPopupWindow = window.open(strURL, gstrPopupSecondWindowName, strParam);
			if (!gbBsIE)
				window.gPopupWindow.focus();
				
			if (wmTemp)
				wmTemp.close();
		}

		if (gbBsNS4)
			setEventHandle();
		else if (gbBsIE4 || gbBsOpera7||gbBsKonqueror3)
			setTimeout("setPopupFocus();", 100);
	}
	return;
}

function setEventHandle()
{
	window.gPopupWindow.captureEvents(Event.CLICK | Event.BLUR);
	window.gPopupWindow.onclick = NonIEPopup_HandleClick;
	window.gPopupWindow.onblur = NonIEPopup_HandleBlur;
}

function setPopupFocus()
{
	window.gPopupWindow.focus();
}

function NonIEPopup_HandleBlur(e)
{
	window.gPopupWindow.focus();
}

function NonIEPopup_HandleClick(e)
{
	// Because navigator will give the event to the handler before the hyperlink, let's
	// first route the event to see if we are clicking on a Popup menu in a popup.
	document.routeEvent(e);

	// If a popup menu is active then don't do anything with the click
	if (window.gPopupWindow.gbInPopupMenu) {
		window.gPopupWindow.captureEvents(Event.CLICK);
		window.gPopupWindow.onclick = NonIEPopup_HandleClick;
		return false;
	}

	// Close the popup window
	if(e.target.href)
	{
		if(e.target.href.indexOf("javascript:")==-1) 
		{
			if (e.target.target=="")
				window.location.href = e.target.href;
			else
				window.open(e.target.href, e.target.target);
			this.close();
		}
	} 
	else
		this.close();
	return false;
}

function BSSCPopup_AfterLoad(nIndex, nToken, cuswidth, cusheight)
{	
	if (!window.getPopupIFrame(nIndex).document) {
		_BSSCPopup2(getPopupURL(nIndex), cuswidth, cusheight);
		return;
	}
	
    if (!IsValidToken(nToken)) return;

	if (gbBsNS6)
	{
		setAbsPopupURL(nIndex, window.getPopupIFrame(nIndex).document.location.href); // change URL to abs url.
		BSSCPopup_ResizeAfterLoad(nIndex, nToken, cuswidth, cusheight);
		return;
	}
	
	if ((window.getPopupIFrame(nIndex).document.readyState == "complete") &&
		(window.getPopupIFrame(nIndex).document.body != null)) {
			if (window.getPopupIFrame(nIndex).document.location.href.indexOf("about:blank") != -1) { // add this check. IE will use about:blank" as the default vaule for Iframe.
				window.getPopupIFrame(nIndex).document.location = getPopupURL(nIndex);
				setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
			}
			else
				{
					setAbsPopupURL(nIndex, window.getPopupIFrame(nIndex).document.location.href); // change URL to abs url.
					BSSCPopup_ResizeAfterLoad(nIndex, nToken, cuswidth, cusheight);
				}
	} else {
		setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
	}
}

function BSSCPopup_ResizeAfterLoad(nIndex, nToken, cuswidth, cusheight)
{
	if (window.gbPopupTimeoutExpired) return;

    if (!IsValidToken(nToken)) return;

	getPopupDivStyle(nIndex).visibility = gBsStyVisHide;
	getPopupIFrameStyle(nIndex).visibility = gBsStyVisHide;

	// Determine the width and height for the window
	_BSPSGetClientSize();

	var size = new BSSCSize(0, 0);

	if (cuswidth <= 0 || cusheight <= 0)
		BSSCGetContentSize(window.getPopupIFrame(nIndex), size);
	else {
		size.x = cuswidth;
		size.y = cusheight;
	}

	// Determine the width and height for the window
	var nWidth = size.x;
	var nHeight = size.y;

	// for small popup size, we should allow any size.
	// The popup size should be ok if bigger than 0
	if (nWidth < 0 || nHeight < 0) return; 	// there must be something terribly wrong.		

	getPopupDivStyle(nIndex).width = nWidth;
	getPopupDivStyle(nIndex).height = nHeight;

	getPopupShadowStyle(nIndex).width = nWidth;
	getPopupShadowStyle(nIndex).height = nHeight;
	getPopupTopicStyle(nIndex).width = nWidth;
	getPopupTopicStyle(nIndex).height = nHeight;
	if (gbBsIE55)
	{
		getPopupShadowStyle(nIndex).width = nWidth + 2;
		getPopupShadowStyle(nIndex).height = nHeight + 2;
		getPopupTopicStyle(nIndex).width = nWidth + 2;
		getPopupTopicStyle(nIndex).height = nHeight + 2;
	}

	getPopupIFrameStyle(nIndex).width = nWidth;
	getPopupIFrameStyle(nIndex).height = nHeight;
	if (gbBsIE55 || gbBsNS6)
	{
		getPopupIFrameStyle(nIndex).top = 0;
		getPopupIFrameStyle(nIndex).left = 0;
	}
	
	var strURL = getPopupURL(nIndex);
	if (strURL.indexOf("#") != -1&&gbBsNS6)
		getPopupIFrame(nIndex).location.reload();
	else if (strURL.indexOf("#") != -1||gbBsNS6)
		getPopupIFrame(nIndex).location.href = strURL;  // reload again, this will fix the bookmark misunderstand in IE5.
		
	MoveDivAndShow(nIndex, nToken, cuswidth, cusheight);
}

function getScrollLeft()
{
	if (document.body.scrollLeft)
		return document.body.scrollLeft;
	else if (window.pageXOffset)
		return window.pageXOffset;
	else
		return 0;
}

function getScrollTop()
{
	if (document.body.scrollTop)
		return document.body.scrollTop;
	else if (window.pageYOffset)
		return window.pageYOffset;
	else
		return 0;
}


function MoveDivAndShow(nIndex, nToken, cuswidth, cusheight)
{
	if (window.getPopupIFrame(nIndex).document.location.href != getAbsPopupURL(nIndex)) { // if redirect, reload again.
			window.getPopupIFrame(nIndex).document.location = getPopupURL(nIndex);
			setTimeout("BSSCPopup_AfterLoad(" + nIndex + "," + nToken + "," + cuswidth + "," + cusheight + ")", 200);
			return;
	}

	// Determine the position of the window
	var nClickX = window.gnPopupClickX;
	var nClickY = window.gnPopupClickY;
	var nTop = 0;
	var nLeft = 0;

	var nWidth = parseInt(getPopupDivStyle(nIndex).width);
	var nHeight = parseInt(getPopupDivStyle(nIndex).height);

	if (nClickY + nHeight + 20 < gBsClientHeight + getScrollTop()) {
		nTop = nClickY + 10;
	} else {
		nTop = (getScrollTop() + gBsClientHeight) - nHeight - 20;
	}
	if (nClickX + nWidth < gBsClientWidth + getScrollLeft()) {
		nLeft = nClickX;
	} else {
		nLeft = (getScrollLeft() + gBsClientWidth) - nWidth - 8;
	}

	if (nTop < getScrollTop()) nTop  = getScrollTop() + 1;
	if (nLeft< getScrollLeft())  nLeft = getScrollLeft() + 1;

	getPopupDivStyle(nIndex).left = nLeft;
	getPopupDivStyle(nIndex).top = nTop;

	// Set the location of the background blocks
	getPopupShadowStyle(nIndex).left = 6;
	getPopupShadowStyle(nIndex).top = 6;
	if (gbBsIE55)
	{
		getPopupShadowStyle(nIndex).left = 4;
		getPopupShadowStyle(nIndex).top = 4;
	}

	if (gbBsMac&&gbBsIE4) {
		// Total hack on the iMac to get the IFrame to position properly
		getPopupIFrameStyle(nIndex).pixelLeft = 100;
		getPopupIFrameStyle(nIndex).pixelLeft = 0;
		// Explicitly call BSSCOnLoad because the Mac doesn't seem to do it
		getPopupIFrame(nIndex).window.BSSCOnLoad();
	}

	if (gbBsNS6&&IsDirty(nIndex))
		getElement(getPopupIFrameID(nIndex)).addEventListener("load", handleLoadNS, false);
	else
		BSSCPopup_Timeout(nIndex , nToken );
	return;
}

function	BSSCSize(x, y)
{
	this.x = x;
	this.y = y;
}

function BSSCGetContentSize(thisWindow, size)
{
	if (!gbBsIE4 && !gbBsOpera7 && !gbBsNS4)
		return;

	if ((gbBsMac&&gbBsIE4)||gbBsNS4||gbBsOpera7) {
		size.x = 320;
		size.y = 180;
		return;
	}

	// Resize the width until it is wide enough to handle the content
	// The trick is to start wide and determine when the scrollHeight changes
	// because then we know a scrollbar is necessary. We can then go back
	// to the next widest size (for no scrollbar)

	var ClientRate = gBsClientHeight / gBsClientWidth;

	
	var GoldenSize = new BSSCSize(0,0);
	GoldenSize.x = gBsClientWidth * gBMaxXOfParent;
	GoldenSize.y = gBsClientHeight *gBMaxYOfParent ;

	if (ClientRate > gBRateH_W) {
		GoldenSize.y = GoldenSize.x * gBRateH_W;
	}
	else {
		GoldenSize.x = GoldenSize.y / gBRateH_W;
	}

	// Try to using parent specified max x.
	var x = 0;
	var maxgoldx = GoldenSize.x;
	var maxx = gBsClientWidth * gBMaxXOfParent;
	
	// This double resize causes the document to re-render (and we need it to)
	if (!gbBsIE5)
		thisWindow.moveTo(10000,10000); // this is used to fix the flash on IE4.
		
	thisWindow.resizeTo(1, 1);
	thisWindow.resizeTo(1, 1);
	thisWindow.resizeTo(maxgoldx, thisWindow.document.body.scrollHeight + gBscrollHeight);
	thisWindow.resizeTo(maxgoldx, thisWindow.document.body.scrollHeight + gBscrollHeight);
		
	var miny = thisWindow.document.body.scrollHeight + gBscrollHeight;
	
	if (miny > GoldenSize.y) // the popup does not fix in the parent wanted golden area. so try to expand itself as large as it can
	{
		thisWindow.resizeTo(maxx , thisWindow.document.body.scrollHeight + gBscrollHeight);
		thisWindow.resizeTo(maxx , thisWindow.document.body.scrollHeight + gBscrollHeight);
		
		miny = 	thisWindow.document.body.scrollHeight + gBscrollHeight;
		maxy = gBsClientHeight * gBMaxYOfParent;
		
		if (miny > maxy) { // the popup must have a scroll, OK let it be.
			miny = maxy;
			size.x = maxx;
			size.y = maxy;
			thisWindow.document.body.scroll = 'yes'; // At this time we do want to show scroll any more. so it will looks better a little.
		}
		else { // popup still can fit in the parent area by someway. now we choose the same h/w rate as parent.
			size.y = miny;
			
			//  downsize from maxx , now I try to using binary divide.
			x = maxx;
			deltax = -maxx/2;
			//j = 0;
			while (true) {
				x = x + deltax;
				thisWindow.resizeTo(x, miny);
				thisWindow.resizeTo(x, miny);
				diffy = thisWindow.document.body.scrollHeight + gBscrollHeight - x * ClientRate;
				if (diffy >  gBpermitYDelta ) // it is higher than wanted, so x need to be wide a little bitter
					deltax = Math.abs(deltax) /2;
				else if (diffy <  -gBpermitYDelta) // it is shorter than wanted, so x need to be narrow a little bitter
					deltax = -Math.abs(deltax) /2;
				else 
					// the y is close enough to wanted.
					break;
				if (Math.abs(deltax) < gBpermitXDelta) // the next change is too slight and it can be ignore.
					break;
			}
			size.x = thisWindow.document.body.scrollWidth; //+ gBscrollWidth;
			size.y = thisWindow.document.body.scrollHeight;// + gBscrollHeight;	
			thisWindow.document.body.scroll = 'no';
		}
	}
	else {
		if (thisWindow.document.body.scrollWidth > maxgoldx) {
			size.x = maxx; 
			size.y = miny;	
			thisWindow.document.body.scroll = 'yes';
		}
		else {
			//  downsize from maxgoldx , now I try to using binary divide.
			x = maxgoldx;
			deltax = -maxgoldx/2;
			while (true) {
				x = x + deltax;
				thisWindow.resizeTo(x, miny);
				thisWindow.resizeTo(x, miny);
				diffy = thisWindow.document.body.scrollHeight + gBscrollHeight - x * gBRateH_W;
				if (diffy >  gBpermitYDelta ) // it is higher than wanted, so x need to be wide a little bitter
					deltax = Math.abs(deltax) /2;
				else if (diffy <  -gBpermitYDelta) // it is shorter than wanted, so x need to be narrow a little bitter
					deltax = -Math.abs(deltax) /2;
				else 
					// the y is close enough to wanted.
					break;
				if (Math.abs(deltax) < gBpermitXDelta) // the next change is too slight and it can be ignore.
					break;
			}
			size.x = thisWindow.document.body.scrollWidth; //+ gBscrollWidth;
			size.y = thisWindow.document.body.scrollHeight ;
			thisWindow.document.body.scroll = 'no'; // At this time we do not want to show scroll any more. so it will looks better a little.
			thisWindow.resizeTo(size.x, size.y);
			if (thisWindow.document.body.scrollWidth > size.x)
			{
				size.x = thisWindow.document.body.scrollWidth;
			}
			if (thisWindow.document.body.scrollHeight > size.y)
			{
				size.y = thisWindow.document.body.scrollHeight;
			}
		}
	}
	thisWindow.resizeTo(size.x, size.y);
	thisWindow.resizeTo(size.x, size.y);
	return;
}

function BSSCPopupParentClicked()
{
	if (!window.gbPopupTimeoutExpired) {
		return false;
	}
	
	document.onmousedown = gbOrignalOnMouseDown;

	// Simply hide the popup
	hideAll();

	window.gbPopupTimeoutExpired = false;

	return true;
}

function isInsideHyperLink(obj)
{
	if (obj&&obj!=getParentNode(obj))
	{
		if (obj.tagName=="A"||obj.tagName=="IMG")
			return true;
		else
			return isInsideHyperLink(getParentNode(obj));
	}
	else
		return false;
}

function BSSCPopupClicked(e)
{
	if (!window.gbPopupTimeoutExpired) {
		return false;
	}

	var popupIFrame = getCurrentPopupIFrame();
	if (popupIFrame == null) {
		return true;
	}

	if (gbBsIE4 && (!((popupIFrame.window.event != null) &&
		(popupIFrame.window.event.srcElement != null) &&
		isInsideHyperLink(popupIFrame.window.event.srcElement)))) {
		document.onmousedown = gbOrignalOnMouseDown;
		
		// Simply hide the popup
		hideAll();
		window.gbPopupTimeoutExpired = false;
		return true;
	}
	else if (gbBsNS6 && (!((e != null) &&
			(e.target!= null) && isInsideHyperLink(e.target))))
	{
		document.addEventListener("mousedown", gbOrignalOnMouseDown,false);
		// Simply hide the popup
		hideAll();
		window.gbPopupTimeoutExpired = false;
		return true;		
	}
}

//trace the mouse over's position for hotspot
function  BSPSPopupOnMouseOver(event)
{
	if (gbBsIE4 || gbBsOpera7||gbBsKonqueror3) {
		window.gnPopupClickX = event.clientX + getScrollLeft();
		window.gnPopupClickY = event.clientY + getScrollTop();
		window.gnPopupScreenClickX = event.screenX;
		window.gnPopupScreenClickY = event.screenY;
	} else if (gbBsSafari) {
		window.gnPopupClickX = event.clientX + getScrollLeft();
		window.gnPopupClickY = event.clientY + getScrollTop();
		window.gnPopupScreenClickX = event.screenX + window.screenX;
		window.gnPopupScreenClickY = event.screenY + window.screenY;
	} else if (gbBsNS4) {
		window.gnPopupClickX = event.pageX - window.pageXOffset;
		window.gnPopupClickY = event.pageY - window.pageYOffset;
		window.gnPopupScreenClickX = event.screenX - window.pageXOffset;
		window.gnPopupScreenClickY = event.screenY - window.pageYOffset;
	}
}

function BSSCHidePopupWindow()
{
	if (window.gPopupWindow != null) {
		if (gbBsNS4) {
			if ((typeof window.gPopupWindow != "undefined") && (!window.gPopupWindow.closed)) {
				window.gPopupWindow.close();
				window.gPopupWindow = null;
			}
		}
	}
	return;
}
/*
// Add the PopupOnClick to the onclick array.
if (typeof(BsscRegisterOnClick) != "undefined")
{
	BsscRegisterOnClick(BsPopupOnClick);
}
//End to support previous popup functions

/// Section End  - Popup (JavaScript 1.0)

/// Section Begin - Embedded Stub (JavaScript 1.0)

function BSSCCreatePopupDiv()
{
	return;
}

function WritePopupMenuLayer()
{
	if (BsscHasExtJs()) {_WritePopupMenuLayer();}
}
*/
function BSSCPopup(strURL, width, height)
{
	var re = new RegExp("'", 'g');
	strURL = strURL.replace(re, "%27");

	if (BsscHasExtJs())	{ 
		_BSSCPopup(strURL, width, height);
	}else{
		//Create a temporary window first to ensure the real popup comes up on top
		var wndTemp = null;
		if (!gbBsNS3) {
			wndTemp = window.open("", "temp", "titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes,height=3,width=4");
		}
		// Create the real popup window
		var wndPopup = window.open(strURL, "BSSCPopup", "titlebar=no,toolbar=no,status=no,location=no,menubar=no,resizable=yes,scrollbars=yes,height=300,width=400");
		// Close the temporary
		if (!gbBsNS3) {
			wndTemp.close();
		} else {
			wndPopup.focus();
		}
	}
}

function getElementsByTag(obj,sTagName)
{
	if(obj.getElementsByTagName)
		return obj.getElementsByTagName(sTagName);
	else if(obj.all)
		return obj.all.tags(sTagName);
	return null;
}

function getElement(sID)
{
	if(document.getElementById)
		return document.getElementById(sID);
	else if(document.all)
		return document.all(sID);
	return null;
}

function getParentNode(obj)
{
	if(obj.parentNode)
		return obj.parentNode;
	else if(obj.parentElement)
		return obj.parentElement;
	return null;
}

