<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../viewerfiles/viewer.css" type="text/css">
<style type="text/css">
    td.Info
    {
        font-family: __#@font#__;
        font-size: 10pt;
        font-weight: bold;
        color: #d0d0d0;
    }
    .Header
    {
        font-family: __#@font#__;
        font-size: __#@fontsize#__;
        height: 16px;
    }
    td.Name
    {
        border-bottom: 1px solid #a0a0a0;
        border-right: 1px solid #b0b0b0;
        color: gray;
        background-color: #e8e8e8;
    }
    td.CellSplitter
    {
        cursor: w-resize;
    }
    td.Value
    {
        border-bottom: 1px solid #a0a0a0;
        color: gray;
        background-color: #e8e8e8;
    }
    tr.RegTxt
    {
        font-family: __#@font#__;
        font-size: __#@fontsize#__;
    }
    .GridCell
    {
        height: 14px;
    }
</style>

<script language="javascript" src="../viewerfiles/browserdetect.js"></script>
<script language=javascript>

var resizing = false;
var mapFrame = %s;

// public functions -----------------------------------------------
//
function SetProperties(count, properties)
{
    var code;
    propCount = count;
    if(count != 1)
    {
        var text;
        if(count == 0)
        {
            text = "__#PROPERTIESNONE#__";
            GetMapFrame().SetPropertyPaneToolbarVisibility(false);
        }
        else
        {
            text = GetMainFrame().FormatMessage("__#PROPERTIESITEMSEL#__", new Array(count, "unused"));
            GetMapFrame().SetPropertyPaneToolbarVisibility(true);
        }
        code = '<table id="Grid" cellspacing=0 cellpadding=0 border=0><tr><td class="Info" align="center">' + text + '</td></tr></table>';
    }
    else
    {
        code = '<table id="Grid" cellspacing=0 cellpadding=0 border=0><tr class="Header"><td id="Name" class="Name" width=65><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">&nbsp;__#PROPERTIESNAME#__</span></td><td class="CellSplitter" width=1 onmousedown="StartResizing()"></td><td class="Value"><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">&nbsp;__#PROPERTIESVALUE#__</span></td></tr>';
        for(var i=0; i < properties.length; i++)
            code += '<tr class="GridCell"><td><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">&nbsp;' + properties[i].name + '</span></td><td></td><td><span style="font-family: __#@font#__; font-size: __#@fontsize#__;">' + HtmlDecode(properties[i].value) + '</span></td></tr>';
        code += '</table>';
        GetMapFrame().SetPropertyPaneToolbarVisibility(true);
    }

    SetContent(code);
}

// private functions -----------------------------------------------
//
function Clear()
{
    SetContent("");
}

function SetContent(html)
{
    var content = document.getElementById("Content");
    content.innerHTML = html; //SAFARI
    OnResizeGrid();
}

var _el = null; //Our "parser" element

function HtmlDecode(input)
{
    if (input == null || input == "")
        return input;

    if (_el == null)
        _el = document.createElement('div');

    _el.innerHTML = input;
    return _el.childNodes[0].nodeValue;
}

function InitDocument()
{
    document.onmousedown = OnMouseDown;
    document.onmousemove = OnMouseMove;
    document.onmouseup = OnMouseUp;
}

function OnMouseDown(e)
{
    GetMainFrame().ForwardMouseDown(document, e);
}

function OnMouseMove(e)
{
    try
    {
        GetMapFrame().OnMouseMove(e);
    }
    catch(e) {}
    if(resizing)
    {
        ResizeTo(msie?event.clientX: e.pageX);
        return false;
    }
}

function OnMouseUp(e)
{
    if(resizing)
    {
        resizing = false;
        ResizeTo(msie?event.clientX: e.pageX);
    }
}

function OnResizeGrid(e)
{
    grid = document.getElementById("Grid");
    if(grid)
    {
        width = msie? document.body.clientWidth: window.innerWidth - 2;
        if(propCount != 1)
            height = msie? document.body.clientHeight: window.innerHeight - 2;
        else
            height = 14 * propCount;
        grid.style.width = width + "px";
        grid.style.height = height + "px";
    }
    return true;
}

function GetMapFrame()
{
    return mapFrame;
}

function GetMainFrame()
{
    return GetMapFrame().parent;
}

function StartResizing()
{
    if(resizing)
    {
        resizing = false;
        return false;
    }
    resizing = true;
}

function ResizeTo(width)
{
    var ww = msie? document.body.clientWidth: window.innerWidth - 2;
    if(width > ww - 20)
        width = ww -20;
    if(width < 20)
        width = 20;
    document.getElementById("Name").style.width = width;
}

</script>

</head>
<body onload="InitDocument()" marginwidth=0 marginheight=0 leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 onresize="OnResizeGrid()">
    <div class="Content" id="Content"></div>
</body>
</html>