<PUBLIC:HTC URN="document_view">
<PUBLIC:PROPERTY NAME="unique_id" />
<PUBLIC:PROPERTY NAME="type" />
<PUBLIC:PROPERTY NAME="title" />
<PUBLIC:PROPERTY NAME="path" />
<PUBLIC:PROPERTY NAME="url" />
<PUBLIC:PROPERTY NAME="width" />
<PUBLIC:PROPERTY NAME="height" />
<PUBLIC:PROPERTY NAME="active" />

<PUBLIC:METHOD NAME="Select" />
<PUBLIC:METHOD NAME="Deselect" />
<PUBLIC:METHOD NAME="IsSelected" />

<PUBLIC:METHOD NAME="OnDocSelect" />
<PUBLIC:METHOD NAME="OnDocDeselect" />
<PUBLIC:METHOD NAME="OnDocClick" />
<PUBLIC:METHOD NAME="OnDocDblClick" />
<PUBLIC:METHOD NAME="OnDocDragStart" />
<PUBLIC:METHOD NAME="OnDocContextMenu" />

<PUBLIC:EVENT ID="DocSelect" NAME="onselect" />
<PUBLIC:EVENT ID="DocDeselect" NAME="onclear" />
<PUBLIC:EVENT ID="DocClick" NAME="onclick" />
<PUBLIC:EVENT ID="DocDblClick" NAME="ondblclick" />
<PUBLIC:EVENT ID="DocDragStart" NAME="ondragstart" />
<PUBLIC:EVENT ID="DocContextMenu" NAME="oncontextmenu" />

<PUBLIC:ATTACH EVENT="ondocumentready" HANDLER="DoInit" />

<script language="JavaScript" src="io_utils.js"></script>
<script language="JavaScript">
// global constants and variables
var DEFAULT_TYPE = "thumbnail";
var DEFAULT_WIDTH = 100;
var DEFAULT_HEIGHT = 100;

// initialize the entire document view control
function DoInit()
{
  SetDefaults();
  SetSourceLocation();
  BuildDocView();
}

function Select()
{
  if(active != "true")
    return;
  view_area.Select();
}

function Deselect()
{
  if(active != "true")
    return;
  view_area.Deselect();
}

function IsSelected()
{
  if(active != "true")
    return;
  return view_area.IsSelected();
}

function OnDocSelect()
{
  if(active != "true")
    return;
  DocSelect.fire();
}

function OnDocDeselect()
{
  if(active != "true")
    return;
  DocDeselect.fire();
}

function OnDocClick()
{
  if(active != "true")
    return;
  DocClick.fire();
}

function OnDocDblClick()
{
  if(active != "true")
    return;
  DocDblClick.fire();
}

function OnDocDragStart()
{
  if(active != "true")
    return;
  DocDragStart.fire();
}

function OnDocContextMenu()
{
  if(active != "true")
    return;
  DocContextMenu.fire();
}

function SetDefaults()
{
  if(unique_id == null)
    unique_id = uniqueID;
  if(type == null)
    type = DEFAULT_TYPE;
  if(title == null)
    title = "";
  if(path == null)
    path = "";
  if(url == null)
    url = "";
  if(width == null)
    width = DEFAULT_WIDTH;
  if(height == null)
    height = DEFAULT_HEIGHT;
  if(active == null)
    active = "true";
}

function SetSourceLocation()
{
  if(url == "")
    url = GetURLFromFilePath(path);
  if(title == "")
    title = GetFileNameFromURL(url);
	
  switch(type)
  {
    case "thumbnail":
	  source_location = "thumbnail_area.htm";
	  break;
	case "icon":
	  source_location = "icon_area.htm";
	  break;
	default:
	  source_location = "";
	  //alert("SetOptions: Invalid type specified.");
	  break;
  }

  var search_str = "?" +
    "id=" + escape(id) + "&" +
	"unique_id=" + escape(unique_id) + "&" +
    "title=" + escape(title) + "&" +
    "url=" + escape(url) + "&" +
	"width=" + escape(width) + "&" +
	"height=" + escape(height);

  source_location += search_str;   
}

// construct the entire control and attach necessary events
function BuildDocView()
{
  if(active == "true")
  {
    innerHTML =
      '<iframe name="' + unique_id + '" ' +
	    'src="' + source_location + '" ' +
		' scrolling = "no" ' +
	    'frameborder="no" width="' + width + '" height="' + height + '">' +
	  '</iframe>';

    view_area = frames[unique_id];
  }
  else
  {  
    innerHTML =
      '<img name="' + unique_id + '" ' +
	    'src="Images\\null.gif" ' +
	    'width="' + width + '" height="' + height + '" path="">' +
	  '</img>';

    view_area = all[unique_id];
  }
}
</script>

</PUBLIC:HTC>