//kk01.3.js

function init() { 
      var i;
      if (document.layers) {n=1;ie=0}
      if (document.all) {n=0;ie=1}

      for(i=1;i<=maxdivs;i++){
       eval( 'if (n){ d' + i + '=document.div' + i + ';}' );
       eval(' if (n) {d'+i+'.x=d'+i+'.left;  d'+i+'.y=d'+i+'.top;  }   ');
       eval(' if (ie) {d' + i + '=div' + i + '.style;}' );
       eval(' if (ie) {d'+i+'.x=d'+i+'.pixelLeft;  d'+i+'.y=d'+i+'.pixelTop;  }   ');
       hidediv(i);
      }

      scrollChecker(630);  //the 630 is for bird movement

      if (n) document.captureEvents(Event.MOUSEMOVE)
      document.onmousemove = mouseMove

     moveshow(49,295,105); //kcrc animated div
     moveshow(29,530,60); //white sidebar div
     moveshow(30,700,60); //sidebar div #2

     moveshow(60,0,700); //TDC copyright
 
    var cb=265;
    for(var i=6; i<=12; i++)movediv(i,cb,95); ///setup callouts 

    moveshow(37,70,0); //kcrc title banner
   // moveshow(38,0,0); //kcrc title banner
   ////////// movediv(56,0,0); //homemade background
  //////  moveshow(39,0,650 ); //textclub gif
//////     movediv(42,0,650); //larger textclub gif
    moveshow(17,10,425); //bar menu
     movediv(18,10,460); //popup menubar1
      movediv(19,10,490); // popup text1 is this needed?
    moveshow(5,40,60); //image map, menu

    //moveAbout(13,13,0); //move planet gif around
    animMenu(25);  //scroll underbars of hyperlilnk items
    movediv(43,0,0); //add  your group form




} //end init

function hidediv(i) { eval(' if (n) d' + i + '.visibility = "hide";  '); eval(' if (ie) d' + i + '.visibility = "hidden";  ');}
function showdiv(j){ eval(' if (n) d' +j+ '.visibility = "show";  '); eval(' if (ie) d' +j+ '.visibility = "visible";  ');}
function movediv(i,xx,yy){ eval(' d'+i+'.x=xx;  d'+i+'.y=yy;  '); eval(' d'+i+'.left=xx;  d'+i+'.top=yy;  ');     }
function moveby(i,x,y){  var xx; var yy;  eval('xx=d'+i+'.x'); eval('yy=d'+i+'.y');  movediv(i,x+xx,y+yy); }
function moveshow(d,x,y){ movediv(d,x,y);showdiv(d);}
function swapdivs(i,j){  showdiv(i); hidediv(j);}
function divX(d){var xx; eval('xx=d'+d+'.x'); return xx;}
function divY(d){var yy; eval('yy=d'+d+'.y'); return yy;}
function nothing(){var dum=0; }

function showclip(d,x1,y1,x2,y2,l,t){  
//paramters:  div number (d),  leftside of clip (x1)... left
///NOTE:::::  my 'clip' uses a LEFT TOP, RIGHT BOTTOM  system, NOT micrsoft's f'd up top right,bot left cross-browser. (pain in ass)
 if (n) {
  //var a='d'+d+'.clip.top=y1'; alert(a);
  eval('d'+d+'.clip.top=y1');
  eval('d'+d+'.clip.bottom='+y2);
  eval('d'+d+'.clip.left='+x1);
  eval('d'+d+'.clip.right='+x2);
  eval('d'+d+'.left='+l);
  eval('d'+d+'.top='+t);
 } else {
  eval('d'+d+'.clip="rect('+y1+'px '+x2+'px '+y2+'px '+x1+'px)"'); 
  eval('d'+d+'.pixelLeft='+l);
  eval('d'+d+'.pixelTop='+t);
 }
}  //end showclip


var win1=null;
var win2=null;
var win3=null;
var win4=null;
var win5=null;
function xOpen(url){
   //alert('Page will open in new window');
 if(url==1) win1 = window.open('kcrc01.html',"w1","width=550, height=400, x=0, y=0, menubar=no,status=no,toolbar=no resizable=no,titlebar=no,alwaysRaised=no,scrollbars=yes");
 if(url==2) win2 = window.open('kcrc00.html',"w2","width=550, height=400, x=0, y=0, menubar=no,status=no,toolbar=no resizable=no,titlebar=no,alwaysRaised=no,scrollbars=yes");
 if(url==3) win3 = window.open(url,"w3","width=550, height=400, x=0, y=0, menubar=no,status=no,toolbar=no resizable=no,titlebar=no,alwaysRaised=no,scrollbars=yes");
 if(url==4) win4 = window.open(url,"w4","width=550, height=400, x=0, y=0, menubar=no,status=no,toolbar=no resizable=no,titlebar=no,alwaysRaised=no,scrollbars=yes");
 if(url==5) win5 = window.open(url,"w5","width=550, height=400, x=0, y=0, menubar=no,status=no,toolbar=no resizable=no,titlebar=no,alwaysRaised=no,scrollbars=yes");

  self.name="main";
}


var globalX=0; var globalY=0;
function mouseMove(e) {
         globalX = (n)? e.pageX : event.x+document.body.scrollLeft
         globalY = (n)? e.pageY : event.y+document.body.scrollTop
 //        window.status= globalX+ ',' +globalY;
          return true;
}

var linkActive=0;
var alt_hide=true;
function altTic3(a,d,xx,yy, inc){
 showdiv(a); //showclip(a, 0,0,  350,inc+10, xx,yy);
 //inc+=10;
 //if(!alt_hide) setTimeout("altTic3("+a+","+d+","+xx+","+yy+","+inc+")",5); 
}

function altTic2(a,d,count){  //the count down (count-1) is to let the mouse come to a rest before mouseMove erases it immediately
 var xx=globalX-350; var yy=globalY;  
 ////if(xx>320)xx=globalX-375;else 
 ////if(yy>260)yy=globalY-50;else
 yy=globalY+20;  if(ie)yy=150;  //why does ie suck so bad?
 xx=globalX-350;  if(ie)xx=globalX-550;
 movediv(a, xx, yy);
 if (count>0) setTimeout("altTic2("+a+","+d+","+(count-1)+")",50); 
  else{altTic3(a,d,xx,yy,0);} 
}

function altTic(a,d, activate){  //the shell 
 if(activate){alt_hide=false; altTic2(a,d,4);} else {altTicErase(a,5);} 
}

function altTicErase(a,t){  //this Erase routine is on a timer so as to 'debounce' the mouse.
 hidediv(a); alt_hide=true;  t-=1;
 if(t>0) setTimeout("altTicErase("+a+","+t+")",50) 
}



 var gofaster=0;

 var fnwidth=300; var fntotalWidth=360; 
 var fnheight1=52; var fnheight2=152;
 if(ie) {fnheight1-=6; fnheight2-=7; } //oh god i hate ie
 fnheight=fnheight1;
 var fnscrollHeight=600;
 var fnx=140;  var fny=260;
 var fnnewsSpeed=180-gofaster; var pad=5;

 var fnnewsExpand=0; fnNewsToggled=0;
function toggleNewsExpand(){ 
 fnnewsExpand=!fnnewsExpand;
 fnNewsToggled=1;
 hidediv(53); 
}

function fancyNews(fnnewsTop){ ///initialize
 showdiv(51); 
 showclip(51,0,0,200,200,0,0);
 moveshow(53,fnx+9,fny+4); //control panel
 movediv(51,fnx+29,fny); 
 moveshow(54,fnx,fny);  movediv(52,fnx,fny);
 fancyNews2(fnnewsTop);
}

function fancyNews2(fnnewsTop){
 showclip(51, 0,fnnewsTop+8, fnwidth,fnheight+fnnewsTop+pad,  fnx+29,fny-fnnewsTop+pad); 
 fnnewsTop+=3; if (fnnewsTop>fnscrollHeight)fnnewsTop=0;
 showdiv(53,fnx+2,fny+5); //repaint the control panel to avoid the 'hanging hourglass'
 if(fnNewsToggled){
  if(fnnewsExpand){fnheight=fnheight2;swapdivs(52,54); moveshow(55,fnx+10,fny+70); }  //55 is the hide-the-garbage panel
  if(!fnnewsExpand){fnheight=fnheight1;swapdivs(54,52); hidediv(55);}
  fnNewsToggled=0;
 } 
 setTimeout("fancyNews2("+fnnewsTop+")",fnnewsSpeed);
}


function changeNewsSpeed(x){
 fnnewsSpeed+=x
 if(fnnewsSpeed<20)fnnewsSpeed=20;
 hidediv(53);
}

 var toggleGraphics_=1;
function toggleGraphics(){ ///turns animated graphics off/on
 toggleGraphics_*=-1;
}



titlediv1=37;  titlediv2=38; var st_inc=0; var st_timeout=20; var st_maxX=520;
st_startX=100; st_delay=0;

function slideTitle(a){ /////////////////////////////////////
 if(a==0){moveshow(titlediv1,0,0); moveshow(titlediv2,0,0);st_inc=st_startX;a=1;}
 if(st_delay==0){
  st_inc+=12;
 //old.. showclip(titlediv2,  st_inc,0,  st_inc+20,40,  0,0);
  showclip(titlediv2,  0,0,  st_inc+20,40,  0,0);
  showclip(titlediv1,  st_inc+20,0,  600,40,  0,0);
  if (st_inc>st_maxX) {st_inc=st_startX; st_delay=40;}
 } else {st_delay--; };
 setTimeout("slideTitle("+a+")",st_timeout); 
}


function slideBg(a){ /////////////////////////////////////
 if(ie)return; //because ie S U C K S!!!!	 too slow
 showdiv(56); showclip(56, 0,0,  1000,1000, 0,-a);
 a++; if(a>250)a=0;
setTimeout("slideBg("+a+")",300); 
}


function line(y,d){  //underline that is
 if(y<0){linkActive=0; showdiv(49); hidediv(3);hidediv(d); hidediv(1);//arrow gif
  } else{ 
 linkActive=1; moveshow(1,15,y+37); moveshow(3,40,y+43); // arrow and black underline
 showdiv(d); hidediv(49); //kcrc gif  
 }
}

 
 var currentPopupDiv=1;
 var popupCurrentY=new Array(); 
 var popupWidth=250; var popupHeight=100;
 var popupYpos=490;
 var popupMenuBarDiv=18;
 var scrollPopup=0;  //should timer be making something scroll?

function popup(){
 var d=currentPopupDiv;
  showdiv(d); showclip(d,0,0,  popupWidth,popupHeight,  divX(d), divY(d));
  popupCurrentY[d]=popupHeight;
}

function cleanPopups(){ //you must know the div's for each
 for(var i=19; i<=24; i++)hidediv(i);
}

function startPopup(textDiv,mx,my){
 //first, close any currently open popups
 cleanPopups();
 currentPopupDiv=textDiv; moveshow(popupMenuBarDiv,mx,my);
 var cpd=textDiv; //the box of text
 popupCurrentY[cpd]=0;
 moveshow(cpd,mx,my+30); showclip(cpd, 0,0, popupWidth,popupHeight, mx, my+30 );
}

function closePopup(){
 hidediv(currentPopupDiv); hidediv(popupMenuBarDiv); 
}


function scroll(direc,amount){
 var d=currentPopupDiv
 if(direc>0){  
  if(popupCurrentY[d]<600){
   popupCurrentY[d]+=amount; 
   showclip(d, 0,popupCurrentY[d],  popupWidth,popupCurrentY[d]+popupHeight,  divX(d), popupYpos-popupCurrentY[d]+1);
  }
 }else{
    popupCurrentY[d]-=amount; if(popupCurrentY[d]<0)popupCurrentY[d]=0;
    showclip(d, 0,popupCurrentY[d],  popupWidth,popupCurrentY[d]+popupHeight,  divX(d), popupYpos-popupCurrentY[d]+1);
 }
}

var masterTick=0;
function scrollChecker (a){  //scrollPopup gets set by mouseOver's in div18
 if(scrollPopup>0)scroll(1,scrollPopup);
 if(scrollPopup<0)scroll(-1,-scrollPopup);
 //masterTick++; if(masterTick>10)masterTick=0; 
 //if(linkActive){ 
 // if (masterTick>2 && masterTick<6) hidediv(1); else showdiv(1);
 //} else { hidediv(1); }
  a<800?a+=5:a=0;  // ;moveshow(35,a,15);
  if(a==500)animMenu(25);
 setTimeout("scrollChecker("+a+")",100); 
}

function constr(a){  ///for a couple sec's
 showdiv(25); 
if(a!=1234)setTimeout("constr("+1234+")",1500); else hidediv(25);
}


  ydiff=0; var direct=1; var ydirect=1
function moveAbout(d,x,y){  
// if(ie){moveshow(d,10,10); return;} //because ie sucks.  z-index is ass backweards
 //var r1=Math.ceil(Math.random()*(11)-3) //integers from ..
 var r2=Math.ceil(Math.random()*(4)-1) //integers from 
 var r3=Math.ceil(Math.random()*(25 - 1)+1) //integers from 1..25
 if(r3>21){ydiff=r2; ydirect*=-1; }
 if(x>620||x<10)direct*=-1; 
 if(y<10)ydirect=1; if(y>450)ydirect=-1;
 x+=2*direct; y+=ydiff*ydirect;
 moveshow(d,x,y);
 setTimeout("moveAbout(" + d + "," + x+ "," +y + ")",200);
}

function animMenu(y){
 if (linkActive){hidediv(15); return;}
  moveshow(1,15,y+37); moveshow(15,40,y+43); // arrow and white underline
  y+=25;
 if(y<=(200)) setTimeout("animMenu("+y+")",200); else {animMenu2(175); }
}
function animMenu2(y){  //scroll back up.. i got lazy. not elegant
 if (linkActive){hidediv(15);return;}
  moveshow(1,15,y+37); moveshow(15,40,y+43); // arrow and white underline
  y-=25;
 if(y>=0) setTimeout("animMenu2("+y+")",200); else {hidediv(1);hidediv(15); }
}




//try : <font size=6 color=white face="Arial Rounded MT Bold..sometime

