
        // THIS SCRIPT IS COMMON FOR ALL CUSTOM WEB VIEWS

        var L_Prompt_Text         = "アイコンを選択すると、その説明が表示されます。";
        var L_Empty_Text          = "このフォルダには表示できるものはありません。";
        var L_Multiple_Text       = " 個のオブジェクトを選択";
        var L_Size_Text           = "サイズ:";
        var L_FileSize_Text       = "合計ファイル サイズ:";
        var L_Delimiter_Text      = ",";
        var L_Bytes_Text          = "&nbsp;バイト";
        var L_Properties_Text     = "プロパティ(&R)";
        var L_Today_Text          = "今日 /";
        var L_Yesterday_Text      = "昨日 /";
        var L_Preview_Text        = "プレビューの作成中...";
        var L_TotalSize_Text      = "合計サイズ:";
        var L_UsedSpace_Text      = "使用領域:";
        var L_FreeSpace_Text      = "空き領域";
        var L_Attributes_Text     = "属性";
        var L_Codes_Text          = "RHSaCE"; // suppress the Archive flag
        var L_ReadOnly_Text       = "読み取り専用";
        var L_Hidden_Text         = "隠しファイル";
        var L_System_Text         = "システム";
        var L_Archive_Text        = "アーカイブ";
        var L_Compressed_Text     = "圧縮";
        var L_Encrypted_Text      = "暗号化";
        var L_NoAttributes_Text   = "(標準)";
        var gAttributeNames       = new Array(L_ReadOnly_Text, L_Hidden_Text, L_System_Text, L_Archive_Text, L_Compressed_Text, L_Encrypted_Text);
        var gIntroText            = "";
        var gTimer                = 0;
        var gWantMedia            = false; // cool, but may hinder media file manipulation
        var gDoBlends             = false && (navigator.cpuClass != "Alpha" && screen.colorDepth > 8);
        var gToday;
        var gYesterday;
        var gFolder;
        var gFolderPath           = "";
        var gFoundAuthor          = false;

        function FormatDetail(label, data) {
            var s;
            if (label.length + data.length > 32)
                s = "<p>" + label + ":<br>" + data;
            else
                s = "<p>" + label + ": " + data;
            return s;
        }

        function SanatizeString(data) {
          var re = /\</g;
          var s = data.replace( re, "&lt;");
          re = />/g;
          s = s.replace( re, "&gt;");

          return s;
        }

        function ShowInfo() {
            // updates the left info panel when you select icons
            var item;
            var name;
            var data;
            var text;
            var title;
            var size = 0;
            var i;

            if (gDoBlends) {
                Panel.filters.blendTrans.Stop();
                Panel.filters.blendTrans.Apply();
            }

            // kill any preview
            Preview.innerHTML = "";
            Preview.style.display = "none";
            Thumbnail.style.height = 120;
            Thumbnail.style.display = "none";

            data = FileList.SelectedItems().Count;
            if (data == 0)
                text = NoneSelected();
            else if (data > 1)
                text = ManySelected(data);
            else {
                item = FileList.SelectedItems().Item(0);

                // name
                name = FileList.Folder.GetDetailsOf(item, 0);
                if (!name)
                    name = item.Name;
                text = "<b>" + SanatizeString(name) + "</b>";
                if (false && IsFileLocked(FileList.Folder.GetDetailsOf(item, 4)))
                    text += "&nbsp;&nbsp;<img id=Locked src='res://webview.dll/Locked.gif'>";

                // type
                data = FileList.Folder.GetDetailsOf(item, 2);
                if (data)
                    text += "<br>" + SanatizeString(data);

                // date
                text += HandleDate(item);

                // size
                text += HandleSize(item);

                // extra details?
                gFoundAuthor = false;
                for (i = 4; i < 10; i++) {
                    title = FileList.Folder.GetDetailsOf(null, i);
                    if (!title)
                        break;
                    title = SanatizeString(title);
                    data = FileList.Folder.GetDetailsOf(item, i);
                    if (title == L_Attributes_Text)
                        text += "<p>" + title + ": " + FormatAttributes(data);
                    else if (data) {
                        var safeData = SanatizeString(data);
                        if (title == "Author") {
                            gFoundAuthor = true;
                            text += "<p>" + title + ": <a href='mailto:" + safeData + "'>" + safeData + "</a>";
                        } else
                            text += FormatDetail(title, safeData);
                    }
                }

                // comment?
                text += HandleComment(item);

                // try to generate a new thumbnail or media preview
                if (item.Size)
                    if (Thumbnail.displayFile(item.Path))
                        gTimer = window.setTimeout('Preview.innerHTML = "<br>" + L_Preview_Text; Preview.style.display = ""', 1000);
                    else if (gWantMedia) {
                        ext = GetFileExtension(name);
                        if (IsMovieFile(ext))
                        {
                            Preview.innerHTML = '<p>' +
                                '<object ID=MediaPlayer class=Movie classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">' +
                                    '<param name="ShowDisplay" value=false>'+
                                    '<param name="AutoPlay" value="false">' +
                                '</object>';
                            MediaPlayer.EnableContextMenu = false;
                            MediaPlayer.Open(item.Path);
                        }
                        else if (IsSoundFile(ext))
                        {
                            Preview.innerHTML = '<p>' +
                                '<object  ID=MediaPlayer class=Sound classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">' +
                                    '<param name="ShowDisplay" value="false">'+
                                    '<param name="AutoPlay" value="false">' +
                                '</object>';
                            MediaPlayer.EnableContextMenu = false;
                            MediaPlayer.Open(item.Path);
                        }

                        if (Preview.innerHTML != "")
                            Preview.style.display = "";
                    }
            }
            // replace Info with the new text
            Info.innerHTML = text;
            if (gDoBlends)
                Panel.filters.blendTrans.Play();
        }

        function FormatNumber(n) {
            var s = "";
            var i, j = 0;
            for (i = n.length - 1; i >= 0; i--) {
                s = n.charAt(i) + s;
                if (i && ((++j % 3) == 0))
                    s = L_Delimiter_Text + s;
            }
            return s;
        }

        function HandleSize(item) {
            var s = "";
            var size = item.Size;
            if (size && size < 1000)
                s = "<p>" + L_Size_Text + size + L_Bytes_Text;
            else {
                var data = FileList.Folder.GetDetailsOf(item, 1);
                var title = FileList.Folder.GetDetailsOf(null, 1);
                if (data)
                    s = "<p>" + SanatizeString(title) + ": " + SanatizeString(data);
                else if (size)
                    s = "<p>" + L_Size_Text + FormatNumber(size.toString()) + L_Bytes_Text;
            }
            return s;
        }

        function HandleDate(item) {
            var s = "";
            var data = FileList.Folder.GetDetailsOf(item, 3);
            var title = FileList.Folder.GetDetailsOf(null, 3);
            if (data)
                s = "<p>" + SanatizeString(title) + ": " + SanatizeString(data);
            return s;
        }

        function FormatAttributes(data) {
            var s = "";
            var code;
            for (i = 0; i < L_Codes_Text.length; i++) {
                code = L_Codes_Text.charAt(i);
                if (data.indexOf(code) > -1) {
                    if (s)
                        s += ", ";
                    s += gAttributeNames[i];
                }
            }
            if (!s)
                s = L_NoAttributes_Text;
            return s;
        }

        function FormatComment(data) {
            var s = "";
            if (data) {
                data = SanatizeString( data );
                var start;
                var end;
                var theLink;
                var a = data.split("\n");
                var L_Author_Text = "作成者:";

                // look for a contact
                for (var i in a) {
                    start = a[i].indexOf(L_Author_Text);
                    if (start < 0)
                        continue;
                    if (gFoundAuthor) // already in Details column
                        a[i] = "";
                    else {
                        start += L_Author_Text.length;
                        end = a[i].length;
                        theLink = data.substring(start, end);
                        a[i] = L_Author_Text + "<a href='mailto:" + theLink + "'>" + theLink + "</a>";
                    }
                }

                // parse lines for Office files without breaking links below
                data = a.join("<br>\n");
                // look for embedded links
                start = data.indexOf("http://");
                if (start < 0)
                    start = data.indexOf("file://");
                if (start < 0)
                    s += data;
                else {
                    end = data.indexOf(" ", start);
                    if (end < 0)
                        end = data.length;
                    if (start > 0)
                        s += data.substring(0, start - 1);
                    theLink = data.substring(start, end);
                    s += theLink.link(theLink);
                    if (end < data.length)
                        s += data.substring(end + 1, data.length);
                }
            }
            return s;
        }

        function HandleComment(item) {
                var s = "";
                var data = FileList.Folder.GetDetailsOf(item, -1);
                if (data && data != item.Name)
                    s = "<p>" + FormatComment( data );
                return s;
        }

        function Properties() {
            FileList.SelectedItems().Item(0).InvokeVerb(L_Properties_Text);
        }

        function GetFileExtension(name) {
            var ext = name.substring(name.lastIndexOf(".") + 1, name.length);
            return ext.toLowerCase();        
        }

        function IsMovieFile(ext) {
            var types = ",avi,mov,qt,mpe,mpeg,mpg,";
            var temp = ","+ext+",";
            return types.indexOf(temp) > -1;
        }

        function IsSoundFile(ext) {
            var types = ",aif,aiff,au,mid,rmi,snd,wav,";
            var temp = ","+ext+",";
            return types.indexOf(temp) > -1;
        }

        function IsFileLocked(name) {
            return (name.indexOf(L_Codes_Text.charAt(0)) > -1);
        }

        function NoneSelected() {
            //var s = gIntroText + (FileList.Folder.Items().Count ? L_Prompt_Text : L_Empty_Text);
            var s = gIntroText + L_Prompt_Text;

            if (false || gFolderPath.length == 4) { // true allows all subfolders to show the pie chart
                drive = gFolderPath.substring(0, 3);
                if (Thumbnail.displayFile(drive)) {
                    if (gFolderPath.length == 4)
                        s += "<p><br>" + L_TotalSize_Text + Thumbnail.totalSpace + "<p>";
                    else
                        s += "<p><br>" + drive.link(drive) + "<p><p>" + L_TotalSize_Text + Thumbnail.totalSpace;
                    s += "<p><table class=Legend width=12 height=12 border=1 align=left bgcolor=threedface bordercolordark=black bordercolorlight=black><tr><td></td></tr></table>&nbsp;" + L_UsedSpace_Text + Thumbnail.usedSpace;
                    s += "<p><table class=Legend width=12 height=12 border=1 align=left bgcolor=threedhighlight width=12 height=12 border=1 align=left bordercolordark=black bordercolorlight=black><tr><td></td></tr></table>&nbsp;" + L_FreeSpace_Text + Thumbnail.freeSpace;
                    //Thumbnail.style.height = 60; bug 195578
                    Thumbnail.style.display = "";
                }
            }
            return s;
        }

        function ManySelected(items) {
            var s = items + L_Multiple_Text + "<p>";
            var size = 0;
            if (items <= 100) {
                for (var i = 0; i < items; i++)
                    size += FileList.SelectedItems().Item(i).Size;
                if (size)
                    s += L_FileSize_Text + FormatNumber(size.toString()) + L_Bytes_Text + "<p>";
                if (items <= 16)
                    for (i = 0; i < items; i++)
                        s += SanatizeString(FileList.SelectedItems().Item(i).Name) + "<br>";
            }
            return s;
        }

        // EVENTS

        function Resize() {
            if (document.body.clientWidth < Panel.style.pixelWidth * 2) {
                Panel.style.visibility = "hidden";
            } else {
                Panel.style.visibility = "visible";
            }
        }

        function ThumbnailReady() {
            window.clearTimeout(gTimer);
            Preview.innerHTML = "";
            Preview.style.display = "none";
            if (Thumbnail.haveThumbnail())
                Thumbnail.style.display = "";
        }

        // INITIALIZATION

        function Initialize(introText) {
            gIntroText = introText;
            gFolder = FileList.Folder;
            gFolderPath = Info.innerHTML;
            Thumbnail.style.display = "none";
            Info.innerHTML = NoneSelected();

            // fix styles
            var L_SystemFont1_Text = "MS UI Gothic";
            var L_SystemFont2_Text = "ＭＳ Ｐゴシック";
            var L_SystemFont_Text = "MS UI Gothic, ＭＳ Ｐゴシック";
            var tr = document.body.createTextRange();
            if (navigator.cpuClass != "Alpha") {
                tr.collapse();
                var actualFont = tr.queryCommandValue("FontName");
                if (actualFont == L_SystemFont1_Text || actualFont == L_SystemFont2_Text)
                    document.body.style.fontFamily = L_SystemFont_Text;
            } else
                document.body.style.fontFamily = L_SystemFont_Text;

            // init relative dates
            gToday = new Date();
            gToday = gToday.toLocaleString();
            gToday = gToday.substring(0, gToday.indexOf(' '));
            gYesterday = new Date(Date.parse(gToday) - (1000 * 60 * 60 * 24));
            gYesterday = gYesterday.toLocaleString();
            gYesterday = gYesterday.substring(0, gYesterday.indexOf(' '));

            // call our Resize() function whenever the window gets resized
            window.onresize = Resize;
            Resize();
        }
