'*-----* ｸﾞﾛｰﾊﾞﾙ変数定義 *----------------------------------------------------*
Dim strMainUrl  'ﾒｲﾝﾌﾚｰﾑURL
Dim dblErrorFlg 'ｴﾗｰ判定ﾌﾗｸﾞ
Dim strzoom  'zoomｻｲｽﾞ
Dim ZoomSize  'ﾌｫﾝﾄｻｲｽﾞ
Dim g_strsubframeName
Dim g_strOpenerName
Dim g_strSelfDirectory
Dim g_intTimer

Dim g_palettesource         ' パレットのフィル名
Dim g_paletteoheight        ' パレット初期データ(開いている時の高さ)
Dim g_palettecheight        ' パレット初期データ(閉じている時の高さ)

g_palettesource  = "palette3.html"
g_paletteoheight = "116"    ' パレット初期データ(開いている時の高さ)
g_palettecheight = "25"     ' パレット初期データ(閉じている時の高さ)

Function FClose()
  For intCounter = 0 To window.parent.document.all.length - 1
    If window.parent.document.all(intCounter).tagName ="FRAMESET" _
    Then
      window.parent.document.all(intCounter).rows = strRows
      Exit For
    End If
  Next
End Function

'******************************************************************************
'** Cookie設定処理                                                            *
'******************************************************************************
Sub SetCookie(pKey,pValue)

  '*-----* ﾌﾟﾗｲﾍﾞｰﾄ変数定義 *---------------------------------------------------*
  Dim strExpires  '有効期限情報
  Dim intDate     '有効期限日
  Dim strWeekDay  '曜日
  Dim strMonth    '月名
  Dim intCounter  'ｶｳﾝﾀ

  '*-----* 有効期限情報 作成 *--------------------------------------------------*
  intDate    = DateAdd("yyyy",1,Date)              '有効期限 1年

  SetLocale("en-us")

  strWeekDay = WeekDayName(WeekDay(intDate),False) '曜日
  strMonth   = MonthName(Month(intDate),True)      '月名

  SetLocale("ja")

  strExpires = ";expires=" & strWeekDay    & ", " & _
                             Day(intDate)  & "-"  & _
                             strMonth      & "-"  & _
                             Year(intDate) & " "  & _
                             Time          & " GMT;"

  '*-----* Cookie 登録 *--------------------------------------------------------*
  document.cookie = pKey & "=" & pValue & strExpires

End Sub

'******************************************************************************
'** Cookie取得処理                                                            *
'******************************************************************************
Function GetCookie(pkey)
  On Error Resume Next

  '*-----* ﾌﾟﾗｲﾍﾞｰﾄ変数定義 *---------------------------------------------------*
  Dim aryCookie  'Cookie値
  Dim intCounter 'ｶｳﾝﾀ

  '*-----* ﾘｸｴｽﾄ値 取得 *-------------------------------------------------------*
  GetCookie = ""

  For intCounter = 0 To UBound(Split(document.cookie,";"))
    aryCookie  = Split(document.cookie,";")(intCounter)
    If Trim(Split(aryCookie,"=")(0)) = pKey Then
      GetCookie = Split(aryCookie,"=")(1)
      Exit For
    End If
  Next

End Function

'******************************************************************************
'** Cookie削除処理                                                            *
'******************************************************************************
Function ClrCookie(arg1)

  intDate = DateAdd("yyyy",-1,Date)             '有効期限 -1年(過去設定によりCookie削除)

  SetLocale("en-us")

  strWeekDay = WeekDayName(WeekDay(intDate),False) '曜日
  strMonth   = MonthName(Month(intDate),True)      '月名

  SetLocale("ja")

  strExpires = ";expires=" & strWeekDay    & ", " & _
                             Day(intDate)  & "-"  & _
                             strMonth      & "-"  & _
                             Year(intDate) & " "  & _
                             Time          & " GMT;"

  '*-----* Cookie 削除 *--------------------------------------------------------*
  document.cookie = arg1 & "="   & "0"   & strExpires '

End Function

'******************************************************************************
'** 表示/非表示処理                                                           *
'******************************************************************************
Function UDOpen(arg)

  Call Reopen(arg)

End Function

Function Reopen(arg)

  '*-----* ﾌﾟﾗｲﾍﾞｰﾄ変数定義 *---------------------------------------------------*
  Dim strRows    'ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳの高さ
  Dim intCounter 'ｶｳﾝﾀｰ

  '*-----* ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳ 表示有無判定 *------------------------------------------*
  For intCounter = 0 To window.top.document.all.length - 1
    If window.top.document.all(intCounter).tagName ="META" Then
      Select Case window.top.document.all(intCounter).name
      Case "MainFrameName"
        g_strMainName = window.top.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
      Case "PaletteOHeight"
        g_paletteoheight = window.parent.document.all(intCounter).content
      End Select
    End If
  Next

  If LEN(g_strMainName) = 0 Then
    Call window.open(arg,"_top")
    Call SetCookie("buttonflg",1)     'Cookie設定処理
  Else
    Dim href
'    href = window.parent.frames("Window_Palette").location.href
'    window.parent.frames("Window_Palette").location.href = href
    window.parent.frames("Window_Palette").location.reload
    strRows = "*," + g_paletteoheight +"px"
    '*-----* ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳ 高さ設定 *----------------------------------------------*
    For intCounter = 0 To window.parent.document.all.length - 1
      If window.top.document.all(intCounter).tagName ="FRAMESET" Then
        window.top.document.all(intCounter).rows = strRows
        Exit For
      End If
    Next

  End If

  '*-----* ﾃﾞﾌｫﾙﾄ ｱｸｼｮﾝ ｷｬﾝｾﾙ *-------------------------------------------------*
'  window.event.returnValue = False 'Aﾀｸﾞ ﾅﾋﾞｹﾞｰﾄ ｱｸｼｮﾝ ｷｬﾝｾﾙ

End Function

'******************************************************************************
'** 表示/非表示処理                                                           *
'******************************************************************************
Function Reopen2()

  '*-----* ﾌﾟﾗｲﾍﾞｰﾄ変数定義 *---------------------------------------------------*
  Dim strRows    'ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳの高さ
  Dim intCounter 'ｶｳﾝﾀｰ

  '*-----* ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳ 表示有無判定 *------------------------------------------*
  For intCounter = 0 To window.parent.document.all.length - 1
    If window.parent.document.all(intCounter).tagName ="META" Then
      Select Case window.parent.document.all(intCounter).name
      Case "MainFrameName"
        g_strMainName = window.parent.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
      Case "Openerfilename"
        g_strOpenerName = window.parent.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
        IF g_strOpenerName = "" Then
          g_strOpenerName = "framemake.html"
        End If
      End Select
    End If
  Next

  arg = Mid(lcase(window.location.search),6)
  Call window.open(g_strOpenerName + "?URL=" + arg,"_top")
  Call SetCookie("buttonflg",1)     'Cookie設定処理

  '*-----* ﾃﾞﾌｫﾙﾄ ｱｸｼｮﾝ ｷｬﾝｾﾙ *-------------------------------------------------*
' setTimeout "reopen3()",500 '0.1秒後 再帰

End Function

'******************************************************************************
'** 表示/非表示処理                                                           *
'******************************************************************************
Function reopen3()

  '*-----* ﾌﾟﾗｲﾍﾞｰﾄ変数定義 *---------------------------------------------------*
  Dim strRows    'ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳの高さ
  Dim intCounter 'ｶｳﾝﾀｰ

  '*-----* ﾊﾟﾚｯﾄ ｳｨﾝﾄﾞｳ 表示有無判定 *------------------------------------------*
  For intCounter = 0 To window.parent.document.all.length - 1
    If window.parent.document.all(intCounter).tagName ="META" Then
      Select Case window.parent.document.all(intCounter).name
      Case "MainFrameName"
        g_strMainName = window.parent.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
      Case "Openerfilename"
        g_strOpenerName = window.parent.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
        IF g_strOpenerName = "" Then
          g_strOpenerName = "framemake.html"
        End If
      End Select
    End If
  Next

  arg = Mid(lcase(window.location.search),6)
  alert(g_strOpenerName + "?URL=" + arg)
  Call window.open(g_strOpenerName + "?URL=" + arg,"_self")

  '*-----* ﾃﾞﾌｫﾙﾄ ｱｸｼｮﾝ ｷｬﾝｾﾙ *-------------------------------------------------*
' window.event.returnValue = False 'Aﾀｸﾞ ﾅﾋﾞｹﾞｰﾄ ｱｸｼｮﾝ ｷｬﾝｾﾙ

End Function

'******************************************************************************
'** フレーム生成して表示する処理                                              *
'******************************************************************************
Function view(arg)

  Dim MetaTag1()
  Dim MetaTag2()
  Dim MetaTag3()
  Dim MetaTagCount
  Dim palette_height

  MetaTagCount = 0
  For intCounter = 0 To window.parent.document.all.length - 1
    If window.parent.document.all(intCounter).tagName ="META" Then
      ReDim Preserve MetaTag1(MetaTagCount + 1)
      ReDim Preserve MetaTag2(MetaTagCount + 1)
      ReDim Preserve MetaTag3(MetaTagCount + 1)
      If window.parent.document.all(intCounter).name <> "" Then
        MetaTag1(MetaTagCount) = "name"
        MetaTag2(MetaTagCount) = window.parent.document.all(intCounter).name
        If window.parent.document.all(intCounter).content <> "" Then
          MetaTag3(MetaTagCount) = window.parent.document.all(intCounter).content
        Else
          MetaTag3(MetaTagCount) = ""
        End If
        MetaTagCount = MetaTagCount + 1
      ElseIf window.parent.document.all(intCounter).httpEquiv <> "" Then
        MetaTag1(MetaTagCount) = "http-equiv"
        MetaTag2(MetaTagCount) = window.parent.document.all(intCounter).httpEquiv
        If window.parent.document.all(intCounter).content <> "" Then
          MetaTag3(MetaTagCount) = window.parent.document.all(intCounter).content
        Else
          MetaTag3(MetaTagCount) = ""
        End If
        MetaTagCount = MetaTagCount + 1
      End If
      Select Case window.parent.document.all(intCounter).name
      Case "MainFrameName"
        g_strMainName = window.parent.document.all(intCounter).content 'ﾒｲﾝﾌﾚｰﾑ名
      Case "UDFolder"
        g_strSelfDirectory = window.parent.document.all(intCounter).content
      Case "PaletteSource"
        g_palettesource = window.parent.document.all(intCounter).content
      Case "PaletteOHeight"
        g_paletteoheight = window.parent.document.all(intCounter).content
      Case "PaletteCHeight"
        g_palettecheight = window.parent.document.all(intCounter).content
      End Select
    End If
  Next

  g_strsubframeName = "  <frame src='" + Mid(window.location.search,6) + "' name='" + g_strMainName + "'>"
  g_strpaletteName  = "  <frame src='" + g_strSelfDirectory + g_palettesource + "' name='Window_Palette'>"

  document.open()
  document.writeln("<?xml version='1.0' encoding='shift_jis'?>")
  document.writeln("<!DOCTYPE HTML PUBLIC '-' W3C' DTD HTML 4.01 Transitional' EN'>")
  document.writeln("<html lang='ja'>")
  document.writeln("<head>")

  For intCounter = 0 To MetaTagCount - 1
    If MetaTag3(intCounter) <> "" Then
      document.writeln("<meta " + MetaTag1(intCounter) + " = '" + MetaTag2(intCounter) + "' content = '" + MetaTag3(intCounter) + "' />")
    Else
      document.writeln("<meta " + MetaTag1(intCounter) + " = '" + MetaTag2(intCounter) + "' />")
    End If
  Next

  document.writeln("<title></title>")
  document.writeln("<xml id='xmlDoc'></xml>")
  document.writeln("</head>")

  If lcase(arg) = "open" Then
    palette_height = g_paletteoheight
  Else
    palette_height = g_palettecheight
  End If

  temp = "<frameset rows='*," + palette_height + "px'>"
  document.writeln(temp)

  document.writeln(g_strsubframeName)
  document.writeln(g_strpaletteName)
  document.writeln("  <noframes>")
  document.writeln("    <body>")
  document.writeln("      <p>フレーム対応ブラウザを使用して下さい。</p>")
  document.writeln("    </body>")
  document.writeln("  </noframes>")
  document.writeln("</frameset>")
  document.writeln("</html>")
  document.close()

'   Else
'   alert("back")
'   History.Back()
'   End If

End Function

'******************************************************************************
'** ｲﾆｼｬﾗｲｽﾞ処理                                                              *
'******************************************************************************
Sub subInit()

  '*-----* 各種設定 *-----------------------------------------------------------*
  setTimeout "subInit()",100 '0.1秒後 再帰

End Sub
