	
	function AddButtonToActionBar(szTitle, szAction, nWidth, szParams){
		if (top.fraMainArea.fraRight.fraActionButtons.document.readyState=='complete') {
			if (!top.fraMainArea.fraRight.fraActionButtons.document.all.divActionButtons) return;
		
			var divAction = top.fraMainArea.fraRight.fraActionButtons.document.all.divActionButtons;
			var szAddString = "";
            szParams = (szParams) ? szParams : "";
			
			if (divAction.innerHTML != "") {
				szAddString = "&nbsp;";
			}
		
			var szStyle='';
			if (nWidth != 0) {
				szStyle = "style='width:" + nWidth + "'";
			}
				
			szAddString = szAddString + "<input type='button' class='mButtonReg' " + 
				" onMouseOut='lowlightButton(this);' onMouseOver='highlightButton(this);' " + 
				szStyle + " value=\"" + szTitle + "\" onClick=\"" + szAction + "\"  " + szParams + "  >";
		
			divAction.innerHTML = divAction.innerHTML + szAddString;
		}
		else {
			setTimeout("AddButtonToActionBar(\"" + szTitle + "\",\"" + szAction + "\"," + nWidth + ")",400);
		}
	}
		
	function ClearActionBar(){
		if (!top.fraMainArea.fraRight.fraActionButtons.document.all.divActionButtons) return;
		top.fraMainArea.fraRight.fraActionButtons.document.all.divActionButtons.innerHTML = "";
	}

	function HideActionBar(){
		
		if(!top.fraMainArea )
			return;
		if(!top.fraMainArea.fraRight)
			 return;
		top.fraMainArea.fraRight.document.body.rows = "*,0,0,0";
	}

	function ShowActionBar(){
		if (!top.fraMainArea.fraRight.document) return;
		top.fraMainArea.fraRight.document.body.rows = "*,30,0,0";
	}

	function ShowRefreshButton(szFrame, szLocation){
		top.fraTopMenu.document.all.btnRefresh.style.visibility = "visible";
		top.fraTopMenu.document.all.btnRefresh.szFrame = szFrame;
		top.fraTopMenu.document.all.btnRefresh.szLocation = szLocation;
	}

	function HideRefreshButton(){
		if (!top.fraTopMenu.document) return;
		top.fraTopMenu.document.all.btnRefresh.style.visibility = "hidden";
		top.fraTopMenu.document.all.btnRefresh.szFrame = "";
		top.fraTopMenu.document.all.btnRefresh.szLocation = "";
	}

	function clickRefreshButton() {
		var szFrame = top.fraTopMenu.document.all.btnRefresh.szFrame;
		var szLocation = top.fraTopMenu.document.all.btnRefresh.szLocation;
		
		if (szFrame != "" && szLocation != "") {
			eval(szFrame + ".document.location='" + szLocation + "'");
		}
	}
	
	function AddButtonToActivityBar(szTitle, szAction, nWidth, szDisabled){
		
		if(top.fraTopMenu.document.readyState=='complete'){
			if (!top.fraTopMenu.document.all.divActivityButtons) return;


			var divActivity = top.fraTopMenu.document.all.divActivityButtons;

			var szAddString = "";

			if (divActivity.innerHTML != "") {
				szAddString = "&nbsp;";
			}
			
			var szStyle='';
			if (nWidth != 0) {
				szStyle = "style='width:" + nWidth + "'";
			}
	
			szAddString = szAddString + "<input type='button' class='mButtonReg' " + 
				szDisabled + " onMouseOut='lowlightButton(this);' onMouseOver='highlightButton(this);' " + 
				szStyle + " value=\"" + szTitle + "\" onClick=\"" + szAction + "\">";
		
			divActivity.innerHTML = divActivity.innerHTML + szAddString;
		}else{
			setTimeout("AddButtonToActivityBar(\"" + szTitle + "\",\"" + szAction + "\"," + nWidth + ",\"" + szDisabled + "\")",400);
		}

	}
	
	function ClearActivityBar(){
		if (!top.fraTopMenu.document.all.divActivityButtons) return;
		top.fraTopMenu.document.all.divActivityButtons.innerHTML = "";
	}

	function ClearPatientName(){
		if (!top.fraTopMenu.document.all.divPatient) return;
		top.fraTopMenu.document.all.divPatient.innerHTML = "";
	}

	function SetPatientName(szLast, szFirst, szMiddle, nSex, szDOB){
		if (!top.fraTopMenu.document.all.divPatient) return;
		
		var divPatient = top.fraTopMenu.document.all.divPatient;

		var szSexAge = WriteAgeSex(nSex, szDOB);

		divPatient.innerHTML = "<b>" + szFirst + " " + szLast + szSexAge + "</b>";
	}

	function highlightButton(obj){
		obj.style.cursor='hand';
		obj.style.backgroundColor='darkgray';
	}
	
	function lowlightButton(obj){
		obj.style.backgroundColor='#d7d7d7';
	}
	function lowlightLongButton(obj)
	{
		obj.style.backgroundColor='white';
	
	}	
	function highlightRefresh(obj){
		document.form1.btnRefresh.style.cursor = 'hand'
		obj.style.cursor='hand';
		obj.src= "images/refresh_highlight.bmp";
	}
	
	function lowlightRefresh(obj){
		obj.src="images/refresh.bmp";
	}

	function WriteAgeSex(nSex, szDOB) {
		var szReturn = " (";
		var bReturn = false;

		switch (nSex) {
			case 1:
				szReturn += "M";
				bReturn = true;
				break;
			case 2:
				szReturn += "M";
				bReturn = true;
				break;
			default:
				break;
		}
		
		if (szDOB != "") 
		{
			if (bReturn == true) 
			{
				szDOB = ", " + szDOB;
			}
			szReturn += szDOB;
		}
		szReturn += ")";

		if (bReturn == true) {
			return szReturn;
		}
		else {
			return "";
		}
	}
	    
	function HideActivityMenu()
	{
		if (!top.fraTopMenu) return;
		if (!top.fraTopMenu.divActivityMenu) return;
		top.fraTopMenu.divActivityMenu.style.visibility='hidden'
	}
