/*
//**************************************
//查找控件对象strongcw
//（最多查找7层窗口对象，包括父窗口和打开该窗口的父窗口）
function findOBJECT(win)
{
   var API = null;
   var findOBJECTTries = 0;
   
   while ((win.API == null) && (((win.parent != null) && (win.parent != win))||((win.opener != null) && (win.opener != win ))))
   {
      findOBJECTTries++;
      // Note: 7 is an arbitrary number, but should be more than sufficient
      if (findOBJECTTries > 7) 
      {
         alert("对象strongcw查找失败！错误：查找的层次太深。");
         return null;
      }
      if ((win.parent != null) && (win.parent != win))//查找父窗口
      {
         win = win.parent;
      }
      else	//查找打开该窗口的父窗口
      {
      	 win=win.opener;
      }
   }
   if (win.API == null) 
   {
      alert("对象strongcw查找失败！"); 
   }
   return win.API;		
}

//****************************************************

//**************************************
//创建strongcw全局对象（应保证课件打开是最先执行）
var strongAPI = findOBJECT(window);

if ( strongAPI == null )
{
	//创建XMLDOM对象的xml字符串为空或控件对象找不到
	objectError("m","alert");
}
//*******************************************************
*/

// local variable definitions
var apiHandle = null;
var API = null;
var findAPITries = 0;

/******************************************************************************
**
** Function getAPIHandle()
** Inputs:  None
** Return:  value contained by APIHandle
**
** Description:
** Returns the handle to API object if it was previously set,
** otherwise it returns null
**
*******************************************************************************/
function getAPIHandle()
{
   if (apiHandle == null)
   {
      apiHandle = getAPI();
   }

   return apiHandle;
}


/*******************************************************************************
**
** Function findAPI(win)
** Inputs:  win - a Window Object
** Return:  If an API object is found, it's returned, otherwise null is returned
**
** Description:
** This function looks for an object named API in parent and opener windows
**
*******************************************************************************/
function findAPI(win)
{
   while ((win.API == null) && (win.parent != null) && (win.parent != win))
   {
      findAPITries++;
      // Note: 7 is an arbitrary number, but should be more than sufficient
      if (findAPITries > 7) 
      {
         alert("Error finding API -- too deeply nested.");
         return null;
      }
      
      win = win.parent;

   }
   return win.API;
}



/*******************************************************************************
**
** Function getAPI()
** Inputs:  none
** Return:  If an API object is found, it's returned, otherwise null is returned
**
** Description:
** This function looks for an object named API, first in the current window's 
** frame hierarchy and then, if necessary, in the current window's opener window
** hierarchy (if there is an opener window).
**
*******************************************************************************/
function getAPI()
{
   var theAPI = findAPI(window);
   if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined"))
   {
      theAPI = findAPI(window.opener);
   }
   if (theAPI == null)
   {
      alert("Unable to find an API adapter");
   }
   return theAPI
}







