//
//	Copyright (c) 2001 General Electric Company
//
//	Version control:
//		$Archive: /releases/FreeViewer_2.0/src/WebViewer/FreeViewer/HTML/dcmdrfrm.js $
//		$Revision: 15 $
//		$Date: 3/05/03 6:47p $
//		$Author: Marceld $
//
//	Helper comment to enable syntax coloring in InterDev: <script>


//
// onload
//
function window.onload()
{
	if (!HasErrors())
	{
		try
		{
			var Index = location.href.lastIndexOf("/");
			var strApplicationDataURL = unescape(location.href.slice(0, Index));
	
			activexDicomTreeView.strApplicationDataURL = strApplicationDataURL;
			activexDicomTreeView.SetLocaleDbAndId(GetApp().localedb.GetXMLDb(), GetApp().config.LocaleId())
		}
		catch(e)
		{
		}
	}
}


//
// HasErrors
//
function HasErrors()
{
	try
	{
		return ((typeof(activexDicomTreeView) != 'object') ||
			    (activexDicomTreeView.object == null) ||
				(activexDicomTreeView.readyState != 4));
	}
	catch (e)
	{
		return true;
	}
}


//
// GetErrorText
//
// Purpose: Return the error description or an empty string when there is no error.
//
function GetErrorText()
{
	if (HasErrors())
	{
		return GetApp().GetLocaleString('msgCannotLoadDicomDirTreeView');
	}
	else
	{
		return '';
	}
}


//
// ShowAboutDialog
//
function ShowAboutDialog()
{
	parent.ShowAboutDialog();
}


//
// GetImagePath
//
function GetImagePath(index)
{
	return activexDicomTreeView.ImagePath(index);
}


//
// FireOnSelectionChanged();
//
function FireOnSelectionChanged()
{
	if (window.onselectionchanged != null) 
		onselectionchanged();
}


//
// FireOnBrowseMode
//
function FireOnBrowseMode()
{
	if (window.onbrowsemode != null) 
		onbrowsemode();
}


//
// FireOnNewDicomFileSetLoaded
//
function FireOnNewDicomFileSetLoaded()
{
	if (window.onnewdicomfilesetloaded != null) 
		onnewdicomfilesetloaded();
}


//
// FireOnStudyChanged
//
function FireOnStudyChanged()
{
	if (window.onstudychanged != null) 
		onstudychanged();
}


//
// FireOnSeriesChanged
//
function FireOnSeriesChanged()
{
	if (window.onserieschanged != null) 
		onserieschanged();
}


//
// OnButtonBrowseClick
//
function OnButtonBrowseClick()
{
	// Notify clients that that the user enters the browse dialog.
	FireOnBrowseMode();

	activexDicomTreeView.Browse();
}


//
// OnNewDicomFileSetLoaded
//
// Purpose: use the event that a new dicom file-set is loaded to select the first
//          image in this file-set.
//
function OnNewDicomFileSetLoaded()
{
	FireOnNewDicomFileSetLoaded();
	activexDicomTreeView.SelectFirstImageInDicomDir();
}


//
// SetImagesToHighlight
//
function SetImagesToHighlight(cImage)
{
	activexDicomTreeView.ImagesToHighlight = cImage;
}


//
// SetDicomDirPath
//
function SetDicomDirPath(strPath)
{
	activexDicomTreeView.DicomDirPath = strPath;
	activexDicomTreeView.SelectFirstImageInDicomDir();
}


//
// SelectNextImagesInSeries
//
function SelectNextImagesInSeries(nCount)
{
	activexDicomTreeView.SelectNextImagesInSeries(nCount);
}


//
// SelectPreviousImagesInSeries
//
function SelectPreviousImagesInSeries(nCount)
{
	activexDicomTreeView.SelectPreviousImagesInSeries(nCount);
}

//
// IsImageSelected
//
function IsImageSelected()
{
	return activexDicomTreeView.IsImageSelected;
}


//
// HasNextImageInSeries
//
function HasNextImageInSeries()
{
	return activexDicomTreeView.HasNextImageInSeries;
}


//
// HasPreviousImageInSeries
//
function HasPreviousImageInSeries()
{
	return activexDicomTreeView.HasPreviousImageInSeries;
}


//
// SelectFirstImageInSeries
//
function SelectFirstImageInSeries()
{
	return activexDicomTreeView.SelectFirstImageInSeries();
}


//
// GetSeriesCount
//
function GetSeriesCount()
{
	return activexDicomTreeView.SeriesCount;
}


//
// GetActiveSeriesIndex
//
function GetActiveSeriesIndex()
{
	return activexDicomTreeView.ActiveSeriesIndex;
}


//
// GetPresentationStateCount
//
function GetPresentationStateCount()
{
	return (activexDicomTreeView.PresentationStateCount);
}


//
// GetPresentationStateLabel
//
function GetPresentationStateLabel(index)
{
	return (activexDicomTreeView.GetPresentationStateLabel(index));
}


//
// GetPresentationStateDescription
//
function GetPresentationStateDescription(index)
{
	return (activexDicomTreeView.GetPresentationStateDescription(index));
}


//
// GetPresentationStateFilename
//
function GetPresentationStateFilename(index, uid)
{
	return index ? activexDicomTreeView.GetPresentationStateFilename(index - 1, uid) : "";
}

//
// GetImageInstanceUID
//
function GetImageInstanceUID(index)
{
	return activexDicomTreeView.ImageInstanceUID(index);
}

//
// SetActiveImages
//
function SetActiveImages(nSeriesIndex, nViewportIndex, nViewports)
{
	if (nSeriesIndex != -1)
	{
		activexDicomTreeView.SetActiveImages(nSeriesIndex, nViewportIndex, nViewports);
	}
}

//
// GetActiveImageIndex
//
function GetActiveImageIndex()
{
	return activexDicomTreeView.ActiveImageIndex;
}

//
// GetActiveModality
//
function GetActiveModality()
{
	return activexDicomTreeView.ActiveModality;
}

//
// SelectPreviousSeries
//
function SelectPreviousSeries()
{
	activexDicomTreeView.SelectPreviousSeriesInStudy();
}

//
// SelectNextSeries
//
function SelectNextSeries()
{
	activexDicomTreeView.SelectNextSeriesInStudy();
}

//
// HasPreviousSeries
//
function HasPreviousSeries()
{
	return activexDicomTreeView.HasPreviousSeriesInStudy;
}

//
// HasNextSeries
//
function HasNextSeries()
{
	return activexDicomTreeView.HasNextSeriesInStudy;
}
