<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 6.0//pi">
<!-- tag:*, attrname:OAWidgetID, priority:5, selection:exact, hideclass -->

<html xmlns:mmstring="http://www.macromedia.com/schemes/data/string/">
<head>
<!-- Copyright 2009 Adobe Systems Incorporated.  All rights reserved. -->
<title>
</title>
<!-- common includes -->

<script type="text/javascript" src="../Shared/OAWidget/OAWidgetManager.js"></script>
<script type="text/javascript" src="_pi_common.js"></script>

<script type="text/javascript">

var gWidgetID = null;
var gDefaultIcon = { src: "oa_widget.png", width: 32, height: 32 };
var gHelpLink = "";

//--------------------------------------------------------------------
// FUNCTION:
//   canInspectSelection
//
// DESCRIPTION:
//   This is a Property Inspector API function that gets called
//   whenever the selection in the document changes to decide whether
//   or not this property inspector should be displayed.
//
// ARGUMENTS:
//  None
//
// RETURNS:
//   true if the currently selected node is a TabbedPanels element,
//   false if it is not.
//--------------------------------------------------------------------
function canInspectSelection()
{
    var bCanInspectSelection = false;
    var dom = dw.getDocumentDOM();
    if (dom)
    {
        var selectedNode = dom.getSelectedNode(true, false, true);
        if (selectedNode && selectedNode.getTranslatedAttribute)
        {
            gWidgetID = selectedNode.getTranslatedAttribute("OAWidgetID");
            if (gWidgetID)
                bCanInspectSelection = true;
        }
    }
    return bCanInspectSelection; //comments in html file limit us to just one tag
}

//--------------------------------------------------------------------
// FUNCTION:
//   initializeUI
//
// DESCRIPTION:
//   This is an internal utility function that searches through the
//   Property Inspector document to find all of the UI controls we
//   will programatically manipulate, and stores handles to them in
//   global variables which are used in some of the other functions
//   for this Property Inspector.
//
// ARGUMENTS:
//  None
//
// RETURNS:
//   N/A
//--------------------------------------------------------------------
function initializeUI()
{
}

//--------------------------------------------------------------------
// FUNCTION:
//   inspectSelection
//
// DESCRIPTION:
//   This is a Property Inspector API function that gets called
//   whenever the selection in the document has changed and it has
//   been decided that this Property Inspector should be displayed.
//   This function syncs up the Property Inspector UI with the
//   widget's design-time object so that it accurately reflects
//   what is in the widget HTML markup and its JS constructor.
//
// ARGUMENTS:
//  None
//
// RETURNS:
//   N/A
//--------------------------------------------------------------------
function inspectSelection()
{
    // Call initializeUI() here; it's how the global variables get
    // initialized. The onLoad event on the body tag is never triggered
    // in inspectors.
    initializeUI();
    var dom = dw.getDocumentDOM();
    var selectedNode = dom.getSelectedNode(true, false, true);
    if (!canInspectSelection())
        return;

    var widgetMgr = OAWidgetManager.getManagerForDoc(dom);
    var widgetID = selectedNode.getTranslatedAttribute("OAWidgetID");
    var widgetBinding = selectedNode.getTranslatedAttribute("OAWidgetBinding");
    var wmd = widgetMgr.getWidgetMetaData(widgetID);

    var icon = widgetMgr.getIconForDisplay(widgetID, gDefaultIcon.width, gDefaultIcon.height);
    if (!icon)
        icon = gDefaultIcon;
    
    var img = document.getElementById("piImage");
    if (img)
    {
        img.src = icon.src;
        img.width = icon.width;
        img.height = icon.height;
    }

    var link = document.getElementById("helpLink");
    if (link)
    {
        var help = widgetMgr.getWidgetHelpLink(widgetID);
        if (help)
        {
            link.innerHTML = help.label ? help.label : "Widget Help";
            gHelpLink = help.src;
        }
        else
            link.innerHTML = "";
    }

    var widgetName = document.getElementById("widgetName");
    if (widgetName)
        widgetName.innerHTML = (wmd && wmd.name) ? wmd.name : "OAWidget";

    var idEditBox = document.getElementById("idEditBox");
    if (idEditBox)
        idEditBox.value = widgetBinding ? widgetBinding : "";
}

function displayHelp()
{
    if (gHelpLink)
        dw.browseDocument(gHelpLink);
}

function updateTag(cmd)
{
}

</script>
<!-- pi styles -->
<link href="_pi_common.css" rel="stylesheet" type="text/css" />
</style>
</head>
<body class="piBody">
<!-- standard image & id fields -->
<div id="piId"> 
	<img id="piImage" src="generic_widget.png" MMString:alt="OAWidget" />
	<div id="idBoxLayer">
		<table border="0">
			<tr>
				<td id="widgetName" nowrap>OAWidget</td>
			</tr>
			<tr><td><input disabled id="idEditBox" type="text" onBlur="updateTag('widgetBinding')" style="width: auto;"/></td></tr>
		</table>
		<div id="piTitle"></div>
		<div id="piElementId">
		</div>
	</div>
</div>
<div id="topLayer">
	<p style="float: right;"><a id="helpLink" href="#" onMouseDown="displayHelp();"></a></p>
</div>
</body>
</html>
