
var _interface = null;

/*
 * Find the "is user teacher" variable which is placed somewhere in the window hierarchy.
 * The variable is called "isTeacher" and probably in the same level with the SCORM API.
 * 
 */
var isUserTeacher = null;

function getIsTeacher()
{ 
   if (isUserTeacher == null)
   {
      isUserTeacher = getTeacher();
   }

   return isUserTeacher;
}

function getTeacher()
{
   // start at the topmost window - findAPI will recurse down through
   // all of the child frames
   var theTeacher = findTeacher(this.top);

   if (theTeacher == null)
   {
      // the isTeacher variable wasn't found in the current window's hierarchy.  If the
      // current window has an opener (was launched by another window),
      // check the opener's window hierarchy.

      if (typeof(this.opener) != "undefined")
      {
         if (this.opener != null)
         {
            theTeacher = findTeacher(this.opener.top);
         }
         else
         {
			// not found
         }
      }
   }

   return theTeacher;
}

function findTeacher(win)
{
   // Search the window hierarchy for an object named "isTeacher"
   // Look in the current window (win) and recursively look in any child frames

   if (win.isTeacher != null)
   {
      return win.isTeacher;
   }

   if (win.length > 0)  // does the window have frames?
   {
      for (var i=0;i<win.length;i++)
      {
         var theTeacher = findTeacher(win.frames[i]);
         if (theTeacher != null)
         {
            return theTeacher;
         }
      }
   }
   
	// couldn't find
   return null;

}

function getDataPNames() {

    var pnames = 'url' + '@#!' + 'sid' + '@#!' + 'uid';

    return pnames;

}

function getDataPValues() {
	var location = escape(window.location);
	//var sid = getCookie(cookieName);
	var sid = getSessionId();
	var uid = getUserId();
	
    var pvals = location + '@#!' + sid + '@#!' + uid;
	
    return pvals;

}
 
function getDataPath(type) {

	var url = "";
	if(type == undefined || type == 1 || type == "1")
		url = "data.jsp";
	else if(type == 2 || type == "2")
		url = "main.jsp";
	else if(type == 3 || type == "3")
		url = "kp.jsp";
	
	return url;
}














