
var gContentAdjustment = 100;
var gInitDesktopDone = false;

function initDesktop(strPageTitle, contentAdjustment)
{
	// try
	// {
	// 	leftTitle.innerText = strPageTitle;
	// 	setUpDesktopLinks();
	// 	document.all.systemNotification.innerHTML = parent.displayNotification();
	// 	showMainMenu();
	// 	parent.update();
	// 	if (contentAdjustment != null)
	// 		gContentAdjustment = contentAdjustment;
	// 	change();
  // 
	// 	if (parent.fnGCacheTimeStamp() != fnCPCacheTimeStamp())
	// 	{
	// 		parent.reloadCachedItems();
	// 		parent.fnSCacheTimeStamp(fnCPCacheTimeStamp());
	// 	}	
	// 	gInitDesktopDone = true;
	// } catch(e) {};
}

function getSessionContext()
{
	return SContext.documentElement.firstChild;
}

function fnGetSessionAttribute(sAttr)
{
	var oSessionContext = getSessionContext();
	return oSessionContext.getAttribute(sAttr);
}

function fnCPCacheTimeStamp()
{
	return fnGetSessionAttribute("giTimeStamp");
}

function showMainMenu()
{
	// document.all.MenuBar1.innerHTML = parent.displayMenu();
	// checkMenuTableDisplay(document.all.chartMenuItem);
	// checkMenuTableDisplay(document.all.newChartMenuItem);
}

function checkMenuTableDisplay(oMenuItem)
{
	// if (oMenuItem == undefined)
	// 	return;
	// var bShowMenu = false;
	// for (var i = 0; i < oMenuItem.children(0).rows.length; i++)
	// 	if (oMenuItem.children(0).rows[i].className != "mkInvisible")
	// 		{
	// 		bShowMenu = true;
	// 		break;
	// 		}
	// if (!bShowMenu)
	// 	oMenuItem.className = "mkInvisible";
}

function setUpDesktopLinks()
{
	// if (userType.toLowerCase() != "transcriptionist")
	//	{
	//	setScheduler();
	//	setMessaging();
	//	}
	// setMyDeskLink();
}

function setScheduler()
{
	//	for the scheduler icon to appear
	//		the practice needs to have scheduling
	//		and it needs to have a calendar set up
	
	//if ((isPracticeBasicScheduling(giPracticeSchedulingLevel)) && (gCalendarID != -1))
	//	document.all.oTdSchedulerIcon.style.display = "";
	//else
	//	document.all.oTdSchedulerIcon.style.display = "none";
}

function setMessaging()
{
	
	//if(isPracticeMessagingEnabled())
	//	document.all.oTdMessagingIcon.style.display = "";
	//else
	//	document.all.oTdMessagingIcon.style.display = "none";
}

function setMyDeskLink()
{
	//document.all.aMyDesk.href = parent.fnGetDesktopPage();
}

function change()
{
	if ((typeof fnPageChange != "undefined") && (fnPageChange != null))
		fnPageChange();
	else
		if (document.body.clientWidth > 1 && document.body.clientHeight > 1)
		{
			type=typeof oDiv;
			if (type!="undefined".valueOf())
			{
				var theheight = document.body.clientHeight - (gContentAdjustment - 15);
				if (theheight > 0)
					oDiv.style.height = theheight;
			}
		}
}

//window.onresize=change;
function logError(strPageName, e)
{
	alert("An error occurred on the page: " + strPageName + "\nError: " + e.description + "\n\nYou will be redirected to your desktop page.\n\nIf the problem persists, please contact technical support.");
	//parent.location.href(parent.webURL + "paxIndex.asp");
}

function fnInit()
{
	// do any global general things first
	
	// call the local init function
	if (typeof(init1) == "function")
		init1();
}

function fnWindowBeforeUnload(e)
{
	// now do the general clean up
	
	// call the local unload function
	if (typeof(window_onbeforeunload) == "function")
		window_onbeforeunload(e);
}

function fnWindowUnload()
{
	// call the local unload function first
	if (typeof(window_onunload) == "function")
		window_onunload();
	// now do the general clean up
	oSessionState = null;		// dispose of the session state object
}

function linkFW(sRelURL)
{
	location.href = parent.sASPNetURL + sRelURL;
}