var vmin=2;

var vmax=5;

var timer1;



function iecompattest(){

   return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body

}



function Chip(chipname,width,height,xx,yy){

  //#me alignment

    this.named=chipname;

    this.vx=vmin+vmax;

    this.vy=vmin+vmax;

    this.w=width+20;

    this.h=height;

    this.xx=xx;

    this.yy=yy;

    //this.xx=852;     //first position

    //this.yy=150;     //first position

    this.timer1=null;

}



function movechip(chipname){

  if (document.getElementById){

    eval("chip="+chipname);

    if (window.innerWidth || window.opera){

      pageX=window.pageXOffset;

      pageW=window.innerWidth-40;

      pageY=window.pageYOffset;

      pageH=window.innerHeight-120;

    }else if (document.body){

      pageX=iecompattest().scrollLeft;

      pageW=iecompattest().offsetWidth-40;

      pageY=iecompattest().scrollTop;

      pageH=iecompattest().offsetHeight-120;

    }

    chip.vx=pageX;

    chip.vy=pageY;    

    if(chip.yy<=pageY+pageH-chip.h){

      //follow on up

      chip.yy+=pageY;

    }

    if(chip.yy>=pageY+pageH-chip.h){

      //follow on down

      chip.yy=pageY+pageH-chip.h;

    }

    document.getElementById(chip.named).style.left=chip.xx+"px";

    document.getElementById(chip.named).style.top=chip.yy+"px";

    chip.timer1=setTimeout("movechip('"+chip.named+"')",20);

  }

}

// popUpBanner, expand, and collapse
function popUpBanner(urlTarget, windowTarget, widowTitle,
windowProperties){
var remote = null;
remote = window.open('', widowTitle, windowProperties);
if (remote != null) {
        if (remote.opener == null) remote.opener = windowTarget;
        remote.location.href = urlTarget;
}
}

var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById); 
var ie5 = (document.all && document.getElementById); 
var ns6 = (!document.all && document.getElementById); 

function attach(id) { 
var obj 
if(ns4) obj = document.layers[id]; 
else if(ie4) obj = document.all[id]; 
else if(ie5 || ns6) obj = document.getElementById(id); 
return obj 
} 

function expandBanner(parentId, childId){
parentlayer = attach(parentId); 
childlayer = attach(childId); 
parentlayer.style.visibility = "hidden"; 
childlayer.style.visibility = "visible";
}

function collapseBanner(parentId, childId){
parentlayer = attach(parentId); 
childlayer = attach(childId); 
parentlayer.style.visibility = "visible"; 
childlayer.style.visibility = "hidden"; 
}



   function ieTest(){
     return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
   }
   
   var tmpPageW = ieTest().offsetWidth;
 
   if (window.innerWidth || window.opera){
     tmpPageW=window.innerWidth;
   }else if (document.body){
     tmpPageW=ieTest().offsetWidth + 20;
   }
   
   var floater,floaterkiri;
   var winWidth = tmpPageW;
   var detikContentWidth = 955;  //get main detik content width
   var winCenter = winWidth / 2;  //get window center
   var halfDetikContentWidth = detikContentWidth / 2 ;  //get main half detik content width
   var scrollWidth = 35; //get scroll width
   var scrollHeight = 300;
   var firstScrollY = 80;
   
   function pagestart(){
      
      //me new
      // xx = scroll postion, must be relative to window screen...
      var firstScrollPosX1;
      var firstScrollPosX2;
      
      if (window.innerWidth || window.opera){
        firstScrollPosX1 = winCenter + halfDetikContentWidth + 5;
        firstScrollPosX2 = winCenter - halfDetikContentWidth - scrollWidth - 120;
      }else if (document.body){
        firstScrollPosX1 = winCenter + halfDetikContentWidth;
        firstScrollPosX2 = winCenter - halfDetikContentWidth - scrollWidth - 120;
      }
      
      //Chip(chipname,width,height,xx,yy)  
      floater=new Chip("floater",scrollWidth,scrollHeight,firstScrollPosX1,firstScrollY);
      movechip("floater");
      //floaterkiri=new Chip("floaterkiri",scrollWidth,200,85,12);
      floaterkiri=new Chip("floaterkiri",scrollWidth,scrollHeight,firstScrollPosX2,firstScrollY);
      movechip("floaterkiri");
   }
   
   if (window.addEventListener) {
      window.addEventListener("load", pagestart, false);
   }else if (window.attachEvent){
      window.attachEvent("onload", pagestart);
   }else if (document.getElementById){
      window.onload=pagestart;
   }