function initKLayers(){
  isDOM=(document.getElementById)?true:false
  isOpera=(window.opera)?true:false
  isOpera5=isOpera && isDOM
  isOpera6=(isOpera5 && window.print)?true:false
  isMSIE=isIE=(document.all && document.all.item && !isOpera)?true:false
  isNC4=(document.layers)?true:false
  isNC6=isMozilla=isDOM && navigator.appName=="Netscape"
  isNC=isNC4 || isNC6

  if(!isDOM && !isNC && !isMSIE && !isOpera5){
    KLayers=false
    return false
  }

  pageLeft=0
  pageTop=0

  KL_imagePreloaderCount=0
  KL_imagePreloaderArray=new Array()

  KL_imageRef="document.images[\""
  KL_imagePostfix="\"]"
  KL_styleSwitch=".style"
  KL_layerPostfix="\"]"

  if(isNC4){
    KL_layerRef="document.layers[\""
    KL_styleSwitch=""
  }

  if(isMSIE){
    KL_layerRef="document.all[\""
  }

  if(isDOM){
    KL_layerRef="document.getElementById(\""
    KL_layerPostfix="\")"
  }

  KLayers=true
  return true
}

initKLayers()

// document and window functions:

function getWindowLeft(){
  if(isMSIE) return top.screenLeft
  if(isNC || isOpera) return top.screenX
}

function getWindowTop(){
  if(isMSIE) return top.screenTop
  if(isNC || isOpera) return top.screenY
}

function setWindowLeft(x){
  top.moveBy(x-getWindowLeft(),0)
}

function setWindowTop(y){
  top.moveBy(0,y-getWindowTop())
}

function getWindowWidth(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.clientWidth
  if(isNC || isOpera) return w.innerWidth
}

function getWindowHeight(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.clientHeight
  if(isNC || isOpera) return w.innerHeight
}

function setWindowWidth(x){
  if(isMSIE) top.resizeBy(x-getWindowWidth(),0); else
  if(isNC || isOpera) top.innerWidth=x
}

function setWindowHeight(y){
  if(isMSIE) top.resizeBy(0,y-getWindowHeight()); else
  if(isNC || isOpera) top.innerHeight=y
}

function getDocumentWidth(w){
  if(!w) w=self
  var d=w.document
  if(isMSIE) return d.body.scrollWidth
  if(isNC) return d.width
  if(isOpera) return d.body.style.pixelWidth
}

function getDocumentHeight(w){
  if(!w) w=self
  var d=w.document
  if(isMSIE) return d.body.scrollHeight
  if(isNC) return d.height
  if(isOpera) return d.body.style.pixelHeight
}

function getScrollX(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.scrollLeft
  if(isNC || isOpera) return w.pageXOffset
}

function getScrollY(w){
  if(!w) w=self
  if(isMSIE) return w.document.body.scrollTop
  if(isNC || isOpera) return w.pageYOffset
}

var KL_LAYER=0
var KL_IMAGE=1

function KL_findObject(what,where,type){
  var i,j,l,s
  var len=eval(where+".length")
  for(j=0;j<len;j++){
    s=where+"["+j+"].document.layers"
    if(type==KL_LAYER){
      l=s+"[\""+what+"\"]"
    }
    if(type==KL_IMAGE){
      i=where+"["+j+"].document.images"
      l=i+"[\""+what+"\"]"
    }
    if(eval(l)) return l
    l=KL_findObject(what,s,type)
    if(l!="false") return l
  }
  return "false"
}

function KL_getObjectPath(name,parent,type){
  var l=((parent && isNC4)?(parent+"."):(""))+((type==KL_LAYER)?KL_layerRef:KL_imageRef)+name+((type==KL_LAYER)?KL_layerPostfix:KL_imagePostfix)
  if(eval(l))return l
  if(!isNC4){
    return l
  }else{
    return KL_findObject(name,"document.layers",type)
  }
}

function layer(name){
  return new KLayer(name,false)
}

function layerFrom(name,parent){
  return new KLayer(name,layer(parent).path)
}

function image(name){
  return new KImage(name,false)
}

function imageFrom(name,layerName){
  return new KImage(name,layer(layerName).path)
}

// class "KLayer":

function KLayer(name,parent){
  this.id=name
  this.path=KL_getObjectPath(name,parent,KL_LAYER)
  this.object=eval(this.path)
  if(!this.object)return
  this.css=eval(this.path+KL_styleSwitch)
}

KLP=KLayer.prototype

KLP.isExist=KLP.exists=function(){
  return (this.object)?true:false
}

KLP.getLeft=function(){ // for not nested layers and objects only
  var o=this.object
  if(isMSIE || isNC6 || isOpera5) return o.offsetLeft-pageLeft
  if(isNC4) return o.pageX-pageLeft
}

KLP.getTop=function(){
  var o=this.object
  if(isMSIE || isNC6 || isOpera5) return o.offsetTop-pageTop
  if(isNC4) return o.pageY-pageTop
}

KLP.getWidth=function(){
  var o=this.object
  if(isOpera5) return this.css.pixelWidth
  if(isMSIE || isNC6) return o.offsetWidth
  if(isNC4) return o.document.width
}

KLP.getHeight=function(){
  var o=this.object
  if(isOpera5) return this.css.pixelHeight
  if(isMSIE || isNC6) return o.offsetHeight
  if(isNC4) return o.document.height
}

KLP.getZIndex=function(){
  return this.css.zIndex
}

KLP.setLeft=KLP.moveX=function(x){
  if(isOpera){
    this.css.pixelLeft=x+pageLeft
  }else{
    this.css.left=x+pageLeft
  }
}

KLP.setTop=KLP.moveY=function(y){
  if(isOpera){
    this.css.pixelTop=y+pageTop
  }else{
    this.css.top=y+pageTop
  }
}

KLP.moveTo=KLP.move=function(x,y){
  this.setLeft(x)
  this.setTop(y)
}

KLP.moveBy=function(x,y){
  this.moveTo(this.getLeft()+x,this.getTop()+y)
}

KLP.setZIndex=KLP.moveZ=function(z){
  this.css.zIndex=z
}

KLP.setVisibility=function(v){
  this.css.visibility=(v)?(isNC4?"show":"visible"):(isNC4?"hide":"hidden")
}

KLP.show=function(){
  this.setVisibility(true)
}

KLP.hide=function(){
  this.setVisibility(false)
}

KLP.isVisible=KLP.getVisibility=function(){
  return (this.css.visibility.toLowerCase().charAt(0)=='h')?false:true
}

KLP.setBgColor=function(c){
  if(isOpera5){
    this.css.background=c
  }else
    if(isMSIE || isNC6){
      this.css.backgroundColor=c
    }else
      if(isNC4){
        this.css.bgColor=c
      }
}

KLP.setBgImage=function(url){
  if(isMSIE || isNC6 || isOpera6){
    this.css.backgroundImage="url("+url+")" // doesn't work at Opera 5. Works at Opera 6.
  }else
    if(isNC4){
      this.css.background.src=url
    }
}

KLP.clip=KLP.setClip=function(top,right,bottom,left){
  if(isMSIE || isNC6){
    this.css.clip="rect("+top+"px "+right+"px "+bottom+"px "+left+"px)"
  }else
  if(isNC4){
    this.css.clip.top=top
    this.css.clip.right=right
    this.css.clip.bottom=bottom
    this.css.clip.left=left
  }
}

KLP.scroll=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  if(scrollX>this.getWidth()-windowWidth) scrollX=this.getWidth()-windowWidth
  if(scrollY>this.getHeight()-windowHeight) scrollY=this.getHeight()-windowHeight
  if(scrollX<0)scrollX=0
  if(scrollY<0)scrollY=0
  var top=0
  var right=windowWidth
  var bottom=windowHeight
  var left=0
  left=left+scrollX
  right=right+scrollX
  top=top+scrollY
  bottom=bottom+scrollY
  this.move(windowLeft-scrollX,windowTop-scrollY)
  this.clip(top,right,bottom,left)
}

KLP.scrollByOffset=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  var X=-parseInt(this.css.left)+windowLeft+scrollX
  var Y=-parseInt(this.css.top)+windowTop+scrollY
  this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)
}

KLP.scrollByPercentage=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){
  var X=(this.getWidth()-windowWidth)*scrollX/100
  var Y=(this.getHeight()-windowHeight)*scrollY/100
  this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)
}

KLP.write=function(str){
  if(isOpera5) return // not implemented for Opera
  var o=this.object
  if(isMSIE || isNC6){
    o.innerHTML=str
  }else
  if(isNC4){
    var a=o.document
    a.open()
    a.write(str)
    a.close()
  }
}

KLP.add=function(str){
  if(isOpera5) return // not implemented for Opera
  var o=this.object
  if(isMSIE || isNC6){
    o.innerHTML+=str
  }else
  if(isNC4){
    var a=o.document
    a.write(str)
  }
}

// class "KImage":

KIP=KImage.prototype

function KImage(name){
  this.path=KL_getObjectPath(name,false,KL_IMAGE)
  this.object=eval(this.path)
}

KIP.exists=KIP.isExist=function(){
  return (this.object)?true:false
}

KIP.getSrc=KIP.src=function(){
  return this.object.src
}

KIP.setSrc=KIP.load=function(url){
  this.object.src=url
}

function preloadImage(imageFile){
  KL_imagePreloaderArray[KL_imagePreloaderCount]=new Image()
  KL_imagePreloaderArray[KL_imagePreloaderCount++].src=imageFile
}









































st=200; movingrate=10; maxy=105;

function sl(sloyname)
  {
  eval("if (!sloy"+sloyname+") { var sloy"+sloyname+"=layer('"+sloyname+"'); };");
  eval("var lw=sloy"+sloyname+".getWidth();");
  eval("sloy"+sloyname+".move(-"+lw+","+maxy+");");
  eval("sloy"+sloyname+".show();");
  idTimer=setInterval("moveInEvent('"+sloyname+"');",movingrate);
  }

function moveInEvent(sloyname)
  {
  eval("if (!sloy"+sloyname+") { var sloy"+sloyname+"=layer('"+sloyname+"'); };");
  eval("var posx=sloy"+sloyname+".getLeft();");
  if (posx+st<=0) { posx+=st; eval("sloy"+sloyname+".moveX("+posx+");"); }
    else { clearInterval(idTimer); eval("sloy"+sloyname+".moveX(0);"); }
  }

function hl(sloyname)
  { idTimer2=setInterval("moveOutEvent('"+sloyname+"')",movingrate); }

function moveOutEvent(sloyname)
  {
  eval("if (!sloy"+sloyname+") { var sloy"+sloyname+"=layer('"+sloyname+"'); };");
  eval("var posx=sloy"+sloyname+".getLeft();");
  eval("var lw=sloy"+sloyname+".getWidth();");
  if (posx>=-lw) { posx-=st; eval("sloy"+sloyname+".moveX("+posx+");"); }
    else { clearInterval(idTimer2); eval("sloy"+sloyname+".hide();"); }
  }

function openindex(winhd,winid,url,sizex,sizey,px)
{ 
//var newWin=window.open("","win"+winid,"height="+sizey+",width="+sizex+",left="+(screen.width-sizex)/2+",top="+(screen.height-sizey)/2+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no");
var newWin=window.open("","win"+winid,"height="+screen.height+",width="+(screen.width-8)+",left=0,top=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no");
newWin.document.write("<html>\n");
newWin.document.write("<head><title>"+winhd+"</title></head>\n");
newWin.document.write("<body bgcolor=#bbbb99 leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>\n");
newWin.document.write("<table border=0 cellspacing=0 cellpadding=0 height=100% width=100%><tr><td align=center valign=middle>\n");
newWin.document.write("<table border=0 cellspacing=0 cellpadding=1 bgcolor=black><tr><td><a href=# onclick='self.close()' onmouseover='this.style.cursor="+'"'+"hand"+'"'+"'><img src="+url+" border=0></a></td></tr></table>\n");
newWin.document.write("</td></tr></table>\n");
newWin.document.write("</body></html>\n");
}

function findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
