// --- Parameters ---
// ImgRotate
bdelay = 2;
imgcnt = 9;
path = 'ban/';
ext = '.gif';

// BgMove
iWd     = 2710;
offLeft  = 560;
offRight = 750;
iMaxDx =    15;

// --- Init ---
// ImgRotate
pos = 1;
img = new Image(); 
img.src = path + 'i1' + ext;
// BgMove
iState = 0;    
iObj   = null;
iX     = 0;
aCenter = '';


IE6 = ( navigator.userAgent.indexOf("MSIE") >= 0 ) && (! (window.XMLHttpRequest && document.epando) );

function onLoad(){
 iObj = document.getElementById('bgrd');
 //alert(iObj);
 sObj = document.getElementById('simg');
 iX   = 0;
 setInterval('scrollBackground()',30);
// setTimeout("imgRotate()",bdelay*1000);
}

/*function imgRotate(){
 if( r = document.getElementById('imgr') ){
  pos = ( pos + 1 < imgcnt ) ? pos + 1 : 0;
  r.src = img.src;
  img.src = path + 'i' + pos + ext; 
  setTimeout("imgRotate()",bdelay*1000);
 }
}*/

function dx(d,cond){
 if( d <= 0 ) { if(cond) { return 1000;}; d *= -1; }
 if( d < iMaxDx ) return iMaxDx / 5;
 if( d < iMaxDx * 2 ) return iMaxDx / 3;
 if( d < iMaxDx * 5 ) return iMaxDx / 2;
 if( d < iMaxDx * 10 ) return iMaxDx * 2 / 3;
 return iMaxDx;
}

function scrollBackground(){
 if( (iState != 1) && (iState != -1) && (iState != 20) ){ return; }
 w = iObj.clientWidth;
 if( iState == 20 ){
  c = 0;
  d = dx( iX - c, 0 );
  if( iX < c ) {
   if( (iX += d) >= c ){ iX = c; iState = 0; }
  } else {
   if( (iX -= d) <= c ){ iX = c; iState = 0; }
  }
 } else {
  if( iState < 0 ){
   if( iX >= -offLeft ){
    iX -= dx( iX + offLeft, 1 );
    if( iX <= -offLeft ){
     // leftmost position
     iState = -2;
     iX = - offLeft;
    }                         
   }
  } else {
   if( iX <= (w - offRight) ){
    iX += dx( (w - offRight) - iX, 1 );
    if( iX >= (w - offRight) ){
     // rightmost position
     iState = 2;
     iX = w - offRight;
    }
   }
  }
 }
 if(IE6){
  sObj.style.left =  iX + "px";
 } else {
  iObj.style.backgroundPosition =  iX + "px 0px";
 }
}

function doOver(par){
 if(iObj != null){
  obj = document.getElementById((par)?'inter':'stand').style;
  if( par ){
   iState = -1;
   obj.left = (iObj.clientWidth - 270) + 'px';
  } else {
   iState = +1;
   obj.left = "20px";
  }
  obj.top  = "350px";
  obj.visibility = "visible";
 }
}

function doOutStand(par){
 obj = document.getElementById('stand').style.visibility = "hidden";
}

function doOutInter(par){
 obj = document.getElementById('inter').style.visibility = "hidden";
}

function doMove(ievent){
 e = ievent || window.event;
 if(e.clientY){ offsetY = e.clientY; } else { offsetY = e.layerY; }
 if( (offsetY>490) || (offsetY<158) ){
  iState = 20;
 }
}
// --- Menu ---

var Open = ""
var Closed = ""

function showhide(what,what2){
 if (what.style.display=='none'){
  what.style.display='';
  what2.src=Open.src
 }
 else{
  what.style.display='none'
  what2.src=Closed.src
 }
}

function showHideLayers() {
 var i,p,v,obj,args=showHideLayers.arguments;
 
 for (i=0; i<(args.length-2); i+=3) if ((obj=document.getElementById(args[i]))!=null) {
  v=args[i+2];
  if (obj.style) {
   obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v;
  }
  obj.visibility=v;
 }
}


