var lSt
var lPost
var lRef
var pagePos
var distCoord


//cookie
function GetCookie (name)
{
    var arg  = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i    = 0;

    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return 90;
}


function getCookieVal( offset )
{
    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}


function SetCookie( name, value )
{
    var argv    = SetCookie.arguments;
    var argc    = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path    = (argc > 3) ? argv[3] : null;
    var domain  = (argc > 4) ? argv[4] : null;
    var secure  = (argc > 5) ? argv[5] : false;

    document.cookie =
        name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{
    var exp  = new Date();
    var cval = GetCookie (name);

    exp.setTime (exp.getTime() - 1);  // This cookie is history
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//

function checkBrowser()
{	
  var navnm=navigator.appName
  this.isDOM=(document.getElementById)?1:0
  this.isNC4=(document.layers && !this.dom)?1:0
  this.isIE=(document.all && document.all.item)?1:0
  this.isOpera=(navnm.toLowerCase().indexOf("opera") > -1)?1:0
  this.isNC6=this.isDOM && !this.isIE && !this.isOpera
  this.isMozilla=this.isNC6
  this.isNC=this.isNC4 || this.isNC6 || this.isMozilla
  this.isW3=this.isIE || this.isNC6 || this.isMozilla

  lSt=".style"
  lPost="\"]"

  if(this.isNC4) {
    lRef="document.layers[\""
    lSt=""
  }

  if(this.isIE) {
    lRef="document.all[\""
  }

  if(this.isDOM) {
    lRef="document.getElementById(\""
    lPost="\")"
  }

	return this
}

function CurWinSize() {
this.otherBrow=1
	if(BW.isNC && !BW.isOpera) {
		this.curWidth=innerWidth
		this.curHeight=innerHeight
		this.otherBrow=0
	} else if (BW.isIE && !BW.isOpera) {
		this.curWidth=document.body.offsetWidth
		this.curHeight=document.body.offsetHeight
		this.otherBrow=0
	} 
	return this
}

function clip(top, right, bottom, left) {
  if(BW.isIE || BW.isNC6){
		mytxt.style.clip="rect("+top+"px "+right+"px "+bottom+"px "+left+"px)"
  }
  if (BW.isNC4) {
    mytxt.clip.top=top
    mytxt.clip.right=right
    mytxt.clip.bottom=bottom
    mytxt.clip.left=left
  }
}

function laywidth() {
  var curobj=mytxt
  if(BW.isW3) return curobj.offsetWidth
  if(BW.isNC4) return curobj.document.width
}

function layheight(){
  var curobj=mytxt
  if(BW.isW3) return curobj.offsetHeight
  if(BW.isNC4) return curobj.document.height
}

function scroll(winLeft,winTop,winWidth,winHeight,scrX,scrY){
  if(scrX<0)scrX=0
  if(scrY<0)scrY=0
//  if(scrX>laywidth()-winWidth) scrY=laywidth()-winWidth
  if(scrY>layheight()-winHeight) {
    scrY=(layheight()<winHeight)?0:layheight()-winHeight
  }
  var top=0
  var right=winWidth
  var bottom=winHeight
  var left=0
  var tx=winLeft-scrX
  var ty=winTop-scrY
  left=left+scrX
  right=right+scrX
  top=top+scrY
  bottom=bottom+scrY
  eval(lRef + "bgtxt" + lPost + lSt + ".left = " + tx)
  eval(lRef + "bgtxt" + lPost + lSt + ".top = " + ty)
  clip(top, right, bottom, left)
}

function scrOffset(winLeft, winTop, winWidth, winHeight, scrX, scrY){
  var X=-parseInt(eval(lRef + "bgtxt" + lPost + lSt + ".left"))+winLeft+scrX
  var Y=-parseInt(eval(lRef + "bgtxt" + lPost + lSt + ".top"))+winTop+scrY
  scroll(winLeft, winTop, winWidth, winHeight, X, Y)
}

function cookNm(){
  var mynam=window.location.href
  var a=mynam.lastIndexOf("/")
  var b=mynam.lastIndexOf(".")
  mynam=mynam.substr(a+1,b-a-1)
  return mynam
}

function pgPos() {
  var mv=parseInt(eval(lRef + "bgtxt" + lPost + lSt + ".top"))
  var mn=window.location.href
  var a=mn.lastIndexOf("/")
  var b=mn.lastIndexOf(".")
  mn=mn.substr(a+1,b-a-1)
  SetCookie(mn, mv)
}

function branchPos() {
var mv="" 
for (i=0; i<54; i++) 
  mv+=mapbr[i]
  mv+=parseInt(eval(lRef + "bgtxt" + lPost + lSt + ".top"))
  var mn=window.location.href
  var a=mn.lastIndexOf("/")
  var b=mn.lastIndexOf(".")
  mn=mn.substr(a+1,b-a-1)
  SetCookie(mn, mv)
}


function scrUp() {
  lmoving=true
  direct=-1
  scrollLayer()
}

function scrDown() {
  lmoving=true
  direct=1
  scrollLayer()
}

function scrollLayer() {
  if(!lmoving)return
  scrOffset(myX, 90, myWidth, myHeight-distCoord, 0, step*direct) //
  setTimeout("scrollLayer()",timeout)
}

function init() {
  mytxt=eval(lRef + "bgtxt" + lPost)
  scroll(myX, myY, myWidth, myHeight, 0, 0)
  eval(lRef + "bgtxt" +lPost + lSt +".visibility=\"visible\"")
}
