
var G_HOMEPAGE = 'http://nationaljewish.org/education/pro-ed/cme-ce.aspx';

var G_TABBAR;

function init_tabbar(imgs_dir, type, id)
{
  alert ('initing tabbar');

  try {
    G_TABBAR = new dhtmlXTabBar ("theTabbarDiv", "top");
    G_TABBAR.setImagePath (imgs_dir);
    G_TABBAR.setAlign ("left");
    G_TABBAR.setHrefMode ("iframes");

    if (type == 'reports')
    {
       G_TABBAR.addTab ("dashboard_tab", "Dashboard");
       G_TABBAR.setContentHref ("dashboard_tab","index_drm.php");

       G_TABBAR.addTab ("reports_tab", "Reports");
       G_TABBAR.setContentHref ("reports_tab","index_rat.php"); 

       G_TABBAR.setTabActive ("dashboard_tab"); 
       G_TABBAR.forceLoad ("dashboard_tab"); 

       return;
    }
    else if (type == 'course')
    {
       G_TABBAR.addTab ("activities_tab", "Activities");
       G_TABBAR.setContentHref ("activities_tab","activities.php?cid="+id); 

       G_TABBAR.addTab ("overview_tab", "Overview");
       G_TABBAR.setContentHref ("overview_tab","about.php?cid="+id);

       G_TABBAR.addTab ("sims_tab", "Waiting Room");
       G_TABBAR.setContentHref ("sims_tab","simulations.php?cid="+id); 

       G_TABBAR.addTab ("reqs_tab", "Competencies");
       G_TABBAR.setContentHref ("reqs_tab","competencies.php?cid="+id); 

       G_TABBAR.setTabActive ("activities_tab"); 
       G_TABBAR.forceLoad ("activities_tab"); 
    }
    else if (type == 'topic')
    {
       G_TABBAR.addTab ("overview_tab", "Overview");
       G_TABBAR.setContentHref ("overview_tab","activities.php?cid="+id);

       G_TABBAR.setTabActive ("overview_tab"); 
       G_TABBAR.forceLoad ("overview_tab"); 
    }

    G_TABBAR.addTab ("forum_tab", "Discussions");
    G_TABBAR.setContentHref ("forum_tab","forum/list.php?cid="+id); 

    G_TABBAR.setStyle ("modern"); 
    G_TABBAR.enableAutoReSize (true);   

  } catch (e) {
    alert ('init_tabbar error: '+e);
  }
}

function update_viewer_content(type, id)
{
  window.location.replace("viewer.php?type="+type+"&idx="+id);
  return;

  try {
    var tabs = top.G_TABBAR;
    tabs.enableTab ("viewer_tab");
    tabs.setContentHref ("viewer_tab", 
			     "viewer.php?type="+type+"&idx="+id);
    tabs.setTabActive ("viewer_tab"); 
    tabs.forceLoad ("viewer_tab"); 

  } catch (e) {
    alert ('error updating viewer: '+e);
  }
}

function enable_admin_tab(type, id)
{
  try {
  if (type == 'topic')
    G_TABBAR.addTab ("admin_tab", "Topic Administration");
  else
    G_TABBAR.addTab ("admin_tab", "Course Administration");

    G_TABBAR.normalize (0, true); 
    
    G_TABBAR.setContentHref ("admin_tab", "navigator.php?cid="+id);
    G_TABBAR.forceLoad ("admin_tab"); 

  } catch (e) {
    alert ('enable_admin_tab error: '+e);
  }
}


function get_breadcrumbs()
{
   var crumbs = top.document.getElementById ('_breadcrumbs');
   try {
        return (crumbs.innerHTML);
   } catch (e) {
      alert ('ERR: bad get crumbs');
   }
}

function set_course_breadcrumbs(course, path)
{
  var crumbs = top.document.getElementById ('_breadcrumbs');
  
  try {
      var tmp = 'Courses <font color="white"><strong> > ';
      tmp += course + " > ";
      tmp += path+"</strong><font>";
      crumbs.innerHTML = tmp;
   } catch (e) {
      alert ('ERR: bad course crumbs: '+e);
   }
}

function set_topic_breadcrumbs(topic, path)
{
  var crumbs = top.document.getElementById ('_breadcrumbs');
  
  if (crumbs)
  {
  try {
      var tmp = 'Topics <font color="white"><strong> > ';
      tmp += topic + " > ";
      tmp += path+"</strong><font>";
      crumbs.innerHTML = tmp;
   } catch (e) {
      alert ('ERR: bad topic crumbs: '+e);
   }
  }
}

var toc_view=1;
function hide_toc()
{
   var toc_pane  = document.getElementById ("toc");
   var toc_arrow_pane = document.getElementById ("hide");
   var toc_arrow = document.getElementById ("toc_arrow");

   if (toc_pane)
   {
   if (toc_view)
   {
      toc_pane.style.display="none";
      if (toc_arrow) toc_arrow.src="/media/arrow_left.png";
      toc_arrow_pane.style.right="15px";
      toc_view = 0;
   }
   else
   {
      toc_pane.style.display="block";
      if (toc_arrow) toc_arrow.src="/media/arrow_right.png";
      toc_arrow_pane.style.right="200px";
      toc_view = 1;
   }
   }
}

function set_breadcrumbs(path)
{
  var crumbs = document.getElementById ('_breadcrumbs_text');
  if ( ! crumbs)
    crumbs = top.document.getElementById ('_breadcrumbs_text');

  try {
    crumbs.innerHTML = path;
  } catch (e) {
    alert ('ERR: bad set crumbs: '+e);
  }
}

function set_system_msg(msg)
{
   var msg_view = top.document.getElementById ('_system_msgs');
   try {
        msg_view.innerHTML = '<b><font color="yellow">'+msg+'</font></b>&nbsp;';
   } catch (e) {
     alert ('ERR: bad system_msg: '+e);
   }
}

var main_tabs_arr = new Array('home','courses/cme','meetings/cme',
			      'topics','forums',
                              'tracker','reporting','lmx authoring');


function init_breadcrumbs(basis, path_prefix, mode, sTitle)
{

  if (basis.indexOf ('/fs/v2') > 0)
  { 
    set_breadcrumbs ('Authoring/Administration');
  }
  else if (basis.indexOf ('/reports/') > 0)
  {
    set_breadcrumbs ('Reporting');
  }
  else if (basis.indexOf ('/meeting_catalog.php') > 0)
  {
    set_breadcrumbs ('Meeting Catalog');
  }
  else if (basis.indexOf ('/topic_catalog.php') > 0)
  {
    set_breadcrumbs ('Topic Catalog');
  }
  else if (basis.indexOf ('/course_catalog.php') > 0)
  {
    set_breadcrumbs ('Course Catalog');
  }
  else if (basis.indexOf ('/course/index.php') > 0)
  {
    set_breadcrumbs (sTitle);
  }
  else
  {
    //set_breadcrumbs (basis);
    set_breadcrumbs ('Home');
  }

  return;

/**
  else if (basis.substr (0, 12) == '/course/')
  { 
    if ((mode == 'live') || (mode == 'meeting'))
    {
      set_breadcrumbs ('Meetings/CME');
    }
    else if (mode == 'topic')
    {
      set_breadcrumbs ('Topics');
    }
    else
    {
      set_breadcrumbs ('Courses/CME');
    }
  }
  else if (basis == '/course_catalog.php')
  {
    set_breadcrumbs ('Courses/CME');
  }
  else if (basis == '/meeting_catalog.php')
  {
    set_breadcrumbs ('Meetings/CME');
  }
  else if ((basis == '/topic_catalog.php') ||
	   (basis.substr (0, 11) == '/topic/'))
  {
    set_breadcrumbs ('Topics');
  }
  else if (basis.substr (0, 13) == '/reports/')
  {
    set_breadcrumbs ('Reporting');
  }
  else if (basis.substr (0, 8) == '/fs/')
  {
    set_breadcrumbs ('Administration');
  }
  else if (basis.substr (0, 19) == '/modules/forums')
  {
    set_breadcrumbs ('Discussions');
  }
  else if (basis.substr (0, 10) == '/chat/')
  {
    set_breadcrumbs ('Chat');
  }
  else if (basis.substr (0, 14) == '/profiles/')
  {
    set_breadcrumbs ('Profile');
  }
  else if (basis.substr (0, 9) == '/faq/')
  {
    set_breadcrumbs ('Help/FAQs');
  }
  else if (basis.substr (0, 11) == '/inbox/')
  {
    set_breadcrumbs ('Inbox');
  }
  else if (basis.substr (0, 11) == '/admin/')
  {
    set_breadcrumbs ('ADMIN');
  }
  else if (basis == '/utils/preferences.php')
  {
    set_breadcrumbs ('Preferences');
  }
**/
}

function enable_active_tab(target, path_prefix)
{
  return;
}

function GoNow(sUrl, oParams) 
{ 
	$.post(sUrl + '.php', oParams, function(data) { }, 'html');
}

function update_main_content(target)
{
	 var dochange = 1;

	GoNow('/setnohdr', { nohdr: 0 });

   try 
   {
      switch (target) {
        case 'home':
	  window.location.replace('/index.php');
          break;
        case 'search':
	  window.location.replace('/utils/search.php');
          break;
        case 'logout':
	  window.location.replace('/logout.php');
          break;
        case 'courses':
        case 'courses/cme':
        case 'ecourses/cme':
	  window.location.replace('/course_catalog.php');
          break;
        case 'meetings/cme':
        case 'emeetings/cme':
	  window.location.replace('/meeting_catalog.php');
	  break;
        case 'topics':
        case 'egroups':
	  window.location.replace('/topic_catalog.php');
          break;
        case 'discussions':
        case 'eforums':
        case 'forums':
	  window.location.replace('/modules/forums/index.php');
          break;
        case 'chat':
	  window.location.replace('/chat/index.php');
          break;
          break;
        case 'tracker':
        case 'reports':
        case 'reporting':
        case 'myreports':
	  window.location.replace('/reports/index.php');

           break;
      case 'files':
      case 'mylmx manager':
      case 'mylmx':
      case 'authoring':
      case 'administration':
	  window.location.replace('/fs/v2/index.php');
           break;
        case 'inbox':
	  window.location.replace('/inbox/index.php');
           break;
		case 'preferences':
	  window.location.replace('/utils/preferences.php');
           break;
        case 'faqs':
	  window.location.replace('/faq/index.php');
           break;
        case 'admin_system':
	  window.location.replace('/admin/index.php');
           break;
        case 'admin_users':
	  window.location.replace('/admin/users.php');
           break;
        case 'admin_courses':
	  window.location.replace('/admin/courses.php');
           break;
        case 'admin_meetings':
	  window.location.replace('/admin/meetings.php');
	  break;
        case 'admin_topics':
	  window.location.replace('/admin/topics.php');
	  break;
	    case 'admin_categories':
	  window.location.replace('/admin/categories.php');
	  break;
        case 'admin_enrollment':
           break;
        case 'profile':
	  		window.location.replace('/profiles/index.php');
           break;
      }
   } 
   catch (e) {
      alert ('exception in update_main: '+e);
   }

	if(dochange) {
	}

   return false;
}

function update_course_content(page)
{
	 var path = "images/examples/";
	 var course_btn_left = "url("+path+"lmx1_nav_left_end_off.png)"; 
	 var course_btn_middle = "url("+path+"lmx1_nav_middle_off.png)"; 
	 var course_btn_right = "url("+path+"lmx1_nav_right_end_off.png)"; 
	 var course_btn_left_on = "url("+path+"lmx1_nav_left_end_on.png)";
	 var course_btn_middle_on = "url("+path+"lmx1_nav_middle_on.png)";
	 var course_btn_right_on = "url("+path+"lmx1_nav_right_end_on.png)";

   var tabs = new Array('activities','requirements','overview',
			'discussions','viewer');

   for(var tab in tabs) {
     btn_img = document.getElementById ('course_btn_'+main_tabs_arr[tab]+'_left');
     if(btn_img) btn_img.style.backgroundImage=course_btn_left;
     btn_img = document.getElementById ('course_btn_'+main_tabs_arr[tab]+'_middle');
     if(btn_img) btn_img.style.backgroundImage=course_btn_middle;
     btn_img = document.getElementById ('course_btn_'+main_tabs_arr[tab]+'_right');
     if(btn_img) btn_img.style.backgroundImage=course_btn_right;
   }
   
   var dochange = 1;

   try 
   {
     var ccframe = document.getElementById ('_course_content');
     //'_content_f' <== target

      switch (page) {
        case 'activities':
	  //alert ("/course/activities.php");
           ccframe.src="/course/activities.php";
           break;
        case 'requirements':
           ccframe.src="/course/competencies.php";
           break;
        case 'about':
        case 'about this course':
        case 'course info':     
           ccframe.src="/course/about.php";
           break;
        case 'elearning':
           ccframe.src="/course/lessons.php";
           break;
        case 'viewer':
           ccframe.src="/course/viewer.php";
           break;
        case 'course discussions':
        case 'discussions':
           ccframe.src="/course/forum/list.php";
           break;
        case 'overview':
           ccframe.src="/course/about.php";
           break;
        default:
					 dochange = 0;
           alert ('unhandled tab: '+page);
           break;
      }
   } 
   catch (e) {
      alert ('exception in update_course: '+e);
   }

	if(dochange) {
   btn_img = document.getElementById ('course_btn_'+page+'_left');
   if(btn_img) btn_img.style.backgroundImage=course_btn_left_on;
   btn_img = document.getElementById ('course_btn_'+page+'_middle');
   if(btn_img) btn_img.style.backgroundImage=course_btn_middle_on;
   btn_img = document.getElementById ('course_btn_'+page+'_right');
   if(btn_img) btn_img.style.backgroundImage=course_btn_right_on;
	}
}

function verifyQuickAdd(type){
	addItem = eval('document.add_'+type+'.widget_add_name');
	//alert(addItem.value);
	//addItem.disabled="false";
	if ((addItem.value != null) && (addItem.value != '')) return true;
	else return false;
	//alert(addItem.value);
	//return false;
}


function showHide(item)
{
  var theItem = document.getElementById (item);
  if (theItem)
  {
    isOn = theItem.style.visibility;
    theDisplay = theItem.style.display;
    if (isOn == 'hidden')
      theItem.style.visibility = 'visible';
    else if (theDisplay == 'none')
      theItem.style.display = 'block';
  }
}

var item_view_arr = new Array ();
function slide_view(item_id, iDelay)
{	
  	try 
	{
		if (iDelay == null)
			iDelay = 500;
			
		if (!$('#' + item_id).is(":visible"))
		{
			if (iDelay == 0)
			   $('#' + item_id).show();
		    else
		       $('#' + item_id).show('blind', 
		                  { direction: 'vertical' }, iDelay);
		}
		else
		{
			if (iDelay == 0)
			   $('#' + item_id).hide();
			else
		  	   $('#' + item_id).hide('blind', 
		                      { direction: 'vertical' }, iDelay);
		}
  	} 
	catch (e) 
	{
		//alert ('slide_view err: '+e);
  	}
	return false;
}

function edit_description(ctype, object_id)
{
  try {
    var edit_item_str = object_id+'_edit_div';
    var view_item_str = object_id+'_view_div';
    edit_item = document.getElementById (edit_item_str);
    edit_item.style.display="block";
    view_item = document.getElementById (view_item_str);
    view_item.style.display="none";
  } catch (e) {
    alert ('edit-err:'+e);
  }
}

function edit_field(object)
{
   var view_item, edit_item;
   try 
   {
      //alert (object.id);
	  setupMCE('overview_edit');
      switch (object)
      {
         case 'course_objectives':
            view_item = document.getElementById ('objectives_view_div');
            view_item.style.display="none";
            edit_item = document.getElementById ('objectives_edit_div');
            edit_item.style.display="block";
            break;
        case 'course_target_audience':
            view_item = document.getElementById ('target_audience_view_div');
            view_item.style.display="none";
            edit_item = document.getElementById ('target_audience_edit_div');
            edit_item.style.display="block";
            break;
        case 'course_accreditation':
            view_item = document.getElementById ('accreditation_view_div');
            view_item.style.display="none";
            edit_item = document.getElementById ('accreditation_edit_div');
            edit_item.style.display="block";
            break;
        case 'course_faculty_disclosure':
            view_item = document.getElementById ('faculty_disclosure_view_div');
            view_item.style.display="none";
            edit_item = document.getElementById ('faculty_disclosure_edit_div');
            edit_item.style.display="block";
            break;
        case 'course_description':
            edit_item = document.getElementById ('description_edit_div');
            edit_item.style.display="block";
            view_item = document.getElementById ('description_view_div');
            view_item.style.display="none";
            break;
         default:
            alert ('unhandled edit field: '+object);
            break;
      }
   } catch (e) {
        alert ('edit_field ERR: '+e);
   }
}

function setupMCE(sectionName) {
	switch(sectionName) {
		case 'header':
			tinyMCE.init({
				mode : "exact",
				theme : "advanced",
				elements : "mce_header_ta",
plugins : 'table,fullscreen,paste,searchreplace',
theme_advanced_toolbar_location : 'top',
		theme_advanced_buttons1 : 'bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,link,unlink,|,tablecontrols',
		theme_advanced_buttons2 : 'cleanup,help,code,|,forecolor,backcolor,|,formatselect,fontselect,fontsizeselect',
		theme_advanced_buttons3 : 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,fullscreen,|,anchor,image,insertfile,insertimage',
		theme_advanced_statusbar_location : 'none',
		theme_advanced_resizing : true,
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : true,
		extended_valid_elements : 'iframe[src|width|height|name|align|id|border|frameborder|style]'
			});
		break;
		
		case 'overview_edit':
			tinyMCE.init({
				mode : "textareas",
				theme : "advanced",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : true,
				extended_valid_elements : "iframe[src|width|height|name|align|id|border|frameborder|style]"
			});
		break;
		
		default:
			tinyMCE.init({
				mode : "exact",
				theme : "advanced",
				elements : "mce_"+sectionName+"_ta",
plugins : 'table,fullscreen,paste,searchreplace',
theme_advanced_toolbar_location : 'top',
		theme_advanced_buttons1 : 'bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,link,unlink,|,tablecontrols',
		theme_advanced_buttons2 : 'cleanup,help,code,|,forecolor,backcolor,|,formatselect,fontselect,fontsizeselect',
		theme_advanced_buttons3 : 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,fullscreen,|,anchor,image,insertfile,insertimage',
		theme_advanced_statusbar_location : 'none',
		theme_advanced_resizing : true,
		extended_valid_elements : 'iframe[src|width|height|name|align|id|border|frameborder|style]'
			});
		break;
	}	
}

function unsetupMCE(sectionName) {
	tinyMCE.execCommand('mceRemoveControl', false, 'mce_'+sectionName+'_ta');
	edit_link = '<button onclick="edit_section(\''+sectionName+'\');">edit</button>';
	document.getElementById(sectionName+'_button').innerHTML = edit_link;
	
	document.getElementById('mce_'+sectionName).style.display = 'block';
	document.getElementById('mce_'+sectionName+'_ta').style.display = 'none';
}

function edit_section(sectionName) {
	//var old_content = tinyMCE.get('mce_'+sectionName+'_ta').getContent();
	//alert(old_content);
	save_link = '<center><button onclick="document.form_'+sectionName+'.submit();">save changes</button>  <button onclick="unsetupMCE(\''+sectionName+'\')">cancel</button><div align="center" style="margin-top:20px;"><img border=0 width="15" height="13" id="_x0000_i1030" src="/media/sel.gif" alt="select background color" onclick="showColorGrid3(\'input_field\',\'input_field\');" title="select background color"> <div style="margin-top:10px;"><INPUT TYPE="text" SIZE="6" id="input_field" name="color" value="#ffffff"></div></div></center>';
	document.getElementById(sectionName+'_button').innerHTML = save_link;
	
	document.getElementById('mce_'+sectionName).style.display = 'none';
	document.getElementById('mce_'+sectionName+'_ta').style.display = 'block';
	// replace text with tinyMCE
	setupMCE(sectionName);
}

function enable_wikilet_wysiwyg(sectionName) {
	save_link = '<button onclick="document.form_'+sectionName+'.submit();">save changes</button>  <button onclick="unsetupMCE(\''+sectionName+'\')">cancel</button>';
	setTimeout ('activateTMCE()', 200);
}

function getScreenDimensions(e) { 
	var dim = new Array ();
	var dimW = 0;
	var dimH = 0;
	dimW = screen.width;
	dimH = screen.height;
	dim = { 'w': dimW, 'h': dimH };
	return dim;	
}

function setWindowCenter(id, width, height) {
	var window = document.getElementById ( id );
	window.style.width = width+'px';
	window.style.height = height+'px';
	window.style.left = getScreenDimensions().w/2-parseInt( window.style.width )/2+'px';
	window.style.top = getScreenDimensions().h/3-parseInt( window.style.height )/2+'px';
}

/** begin functions for the simulations page **/
function display_popup_info(pidx, pcnt, iwidth, thediv, num, ccnt, which) 
{
  var info_str = "";
  var popup_id = "p"+pidx+"info";
  var i=document.getElementById(popup_id);

  if(i) 
  {
    i.style.visibility="hidden";
			document.getElementById(popup_id+'name').innerHTML = names[pcnt];
			document.getElementById(popup_id+'img').src = IMGLIB_DIR+imgs[pcnt];
			document.getElementById(popup_id+'age').innerHTML = ages[pcnt];
			document.getElementById(popup_id+'gender').innerHTML = sexes[pcnt];
			document.getElementById(popup_id+'desc').innerHTML = descs[pcnt];
			if(comps[pcnt]) {
				document.getElementById(popup_id+'comps').innerHTML = comps[pcnt];
			}
			//document.getElementById('buttonhref'+popup_id).innerHTML = buttons[pcnt];
			//var btd = document.getElementById('buttontd'+popup_id);
			//btd.onclick = function(){var mainsel=document.forms[0];mainsel.patient.value=patids[pcnt];var s=sessids[pcnt];if(s!=""){mainsel.session_id.value=s;mainsel.lastpage.value=lastpages[pcnt];};mainsel.submit();};
			i.style.visibility="visible";
  }
  
}

function close_popup_info(pidx) {
  var popup_id = "p"+pidx+"info";
  var i=document.getElementById(popup_id);

  if(i) 
	{
    i.style.visibility="hidden";
	}
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function show_tooltip(thediv,reldiv,str,evt) {
	var d = document.getElementById(thediv);
	var dinfo = document.getElementById(thediv+'Info');
	dinfo.innerHTML = str;
	var x = mouseX(evt)-document.getElementById(reldiv).offsetLeft+10;
	var y = mouseY(evt)-document.getElementById(reldiv).offsetTop;
	d.style.left = dinfo.style.left = x+'px';
	d.style.top = dinfo.style.top = y+'px';
  d.style.visibility = dinfo.style.visibility = "visible";
}

function hide_tooltip(thediv) {
	document.getElementById(thediv).style.visibility = 'hidden';
	document.getElementById(thediv+'Info').style.visibility = 'hidden';
}

var xmlhttp;
function loadXMLDoc(url, callback)
{
   xmlhttp=null;
   if (window.XMLHttpRequest)
   {
      xmlhttp=new XMLHttpRequest();
   }
   else if (window.ActiveXObject)
   {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   if (xmlhttp!=null)
   {
      xmlhttp.onreadystatechange=state_Change;
      xmlhttp.callback = callback;
      xmlhttp.open ("GET", url, true);
      xmlhttp.send (null);
   }
   else
   {
      alert("Your browser does not support XMLHTTP.");
   }
}

function ajax_update(url, callback)
{
   return (loadXMLDoc (url, callback));
}

function state_Change()
{
  if (xmlhttp.readyState==4)
  {
    if (xmlhttp.status==200)
    {
      xmlhttp.callback (xmlhttp.responseText);
    }
    else
    {
      alert("Problem retrieving XML data");
    }
  }
}


function setBoxBgColor (layerID, bgColor)
{
 document.getElementById( layerID ).style.backgroundColor = bgColor;
}

function tooltip_trigger(word_id) {
	container = document.getElementById('tooltip_'+word_id+'_container');
	if(container.style.display == 'none')
		container.style.display = 'block';
	else	
		container.style.display = 'none';
}

function is_safari_browser()
{
    var rv = -1; // Return value assumes failure.

    //alert (navigator.appName);
    //alert (navigator.userAgent);

    if (navigator.appName == 'Netscape') {

        var ua = navigator.userAgent;
        var re = new RegExp("Safari");

        if (re.exec(ua) != null)
        {
           //alert (true);
           return true;
        }
    }

    return false;
}

function getInternetExplorerVersion() 
{
    var rv = -1; // Return value assumes failure.

    if (navigator.appName == 'Microsoft Internet Explorer') {

        var ua = navigator.userAgent;

        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null)

            rv = parseFloat(RegExp.$1);

    }

    return rv;
}

function align_menubar()
{
  try {
    var xpix = 0; 
    var mainMenuDiv = 0;

    mainMenuDiv = document.getElementById ("mainMenuDiv");
    if (mainMenuDiv)
    {
      //alert ("IE version="+getInternetExplorerVersion ());

      var width = 0;
      var newWidth = 0;

      if (getInternetExplorerVersion () > -1)
      {
        xpix = document.getElementById ('toc').scrollWidth;
        //alert ('xpix='+xpix);
        //width = document.documentElement.clientWidth;
        width = document.body.scrollWidth;   

        newWidth = (xpix+width);   
        newWidth += 12;   
      }
      else
      {
        xpix = window.scrollMaxX;
        width = window.innerWidth;

        newWidth = (width + xpix);      
        //newWidth -= 14;
      }
      
      var factor = 0;
      if (xpix > 0) factor = (width/xpix);

      //alert ('X='+xpix+' W='+width+' Q='+factor);

      // Determine how much of the client width is used by mainMenuDiv.
      if (factor > 0)
      {
         //newWidth += 10; // to align inclusive of padded items
         mainMenuDiv.style.width = newWidth + "px";
      }
    }
  } catch (e) {
    alert ("gw-ah_ERR:"+e);
  }
}

function align_heights()
{
  //alert ('align');


  try {
    var ypix = 0; 
    var mainBodyDiv = 0;

    mainBodyDiv = document.getElementById ("main_body");
    if (mainBodyDiv)
    {
      //alert ("IE version="+getInternetExplorerVersion ());

      var adj_height = 0;

           var locn = window.location;
           locn += '';

           var isAdministration = locn.indexOf ('LMX/fs/v2/');
           var isReporting = locn.indexOf ('LMX/reports/');

      if (getInternetExplorerVersion () > -1)
      {
        ypix = document.body.scrollHeight;
        height = document.documentElement.clientHeight;
        adj_height = (height*0.82);
      }
      else if (is_safari_browser ())
      {  
        //alert ('safari');
        ypix = 0; //window.scrollMaxY;
        height = window.innerHeight;

        if ((isAdministration) || (isReporting))     
           adj_height = (height-125);
        else
           adj_height = (height + ypix);
      }
      else
      {
         ypix = window.scrollMaxY;
         height = window.innerHeight;

         if ((isAdministration) || (isReporting))     
            adj_height = (height-125);
         else
            adj_height = (height + ypix);
      }
      
      mainBodyDiv.style.height = adj_height + "px";

    }
  } 
  catch (e) {
    alert ("gw-ah_ERR:"+e);
  }


  // fix the menu bar width if necessary...
  align_menubar ();

}

function reload_page()
{
   document.location.reload ();
   //alert ('reload');
}

function reload_timer()
{
   if (getInternetExplorerVersion() == -1)
      window.setTimeout ('reload_page();', 1000);    
   //alert ('reload');
}

function print_certificate(cid, aid, relpath)
{
   window.open (relpath + 'print_cert.php?cid='+cid+'&aid='+aid, 
                '_lmx_print_cert');
}

function non_admin_course_view()
{
   hide_toc ();
}

function validate_view()
{
   //alert ('validating view...');
   if (top.window != this.window)
   {
      //alert ('oops!');
      top.location.reload ();
   }
}

var active_tab = '';
function set_lhs_starter(actor)
{
   active_tab = actor;
}

function AddOnloadEvent(f, arg1)
{
   var cache = window.onload;
   if(typeof window.onload != "function") { window.onload = f; }
   else
   {
      window.onload = function()
      {
         if(cache) { cache(); }
         f(arg1);
      };
   }
}

function slide_lhs_tab(actor)
{
   //alert (actor);

      slide_view (actor, 10);
/**
      if (actor != active_tab)
      {
         active_tab = actor;
         slide_view (active_tab, 10);
      }
**/
}