
function bannerProp(){
  this.sideFloatBnrOnOff=1;
  this.randomFloatBnrOnOff=1;
  this.onScrollonOff=1;
  this.moveingTimer=60; 
  this.moveingdx=1;
}
var bnrInit=new bannerProp();

var ScreenHeight = window.screen.availHeight;
var ScreenWidth = window.screen.availWidth;
var scroll_position=0;
var widthb;
var heightb;
var bWidth=0,bHeight=0;
var top=-banner_height1;
var top2=-banner_height2;
var dx=bnrInit.moveingdx;
var dx2=bnrInit.moveingdx;
var direct_bnr="down";
var direct_bnr2="down";
var bner_timer_1=null;
var bner_timer_2=null;

if(banner_width2=="")
    banner_width2=0;
if(banner_width1=="")
    banner_width1=0;
if(banner_height2=="")
    banner_height2=0;
if(banner_height1=="")
    banner_height1=0;

function time_out_to_removing(){
	if(bnrInit.onScrollonOff==1)
	    {
      window.clearTimeout(bner_timer_1);
      window.clearTimeout(bner_timer_2);
      bner_timer_1=setTimeout('dx='+bnrInit.moveingdx,3000);
      bner_timer_2=setTimeout('dx2='+bnrInit.moveingdx,3000);
      
      //clearInteval(bner_timer_1);
      //bner_timer_1=setInterval('dx='+bnrInit.moveingdx,3000);
      //clearInteval(bner_timer_2);
      //bner_timer_2=setInterval('dx2='+bnrInit.moveingdx,3000);
      }
}
function centerNEWSScroll(){
	var cnfObj=dwPgDoc.getElementById('centerNewsFrame');
  if(cnfObj)
      {
      var centerMovValue=dwPgDoc.body.scrollTop+80;
      cnfObj.style.top=centerMovValue;	
      }
}
function on_scroll(){

  
  var move_centerNewsTimeout;
	window.clearTimeout(move_centerNewsTimeout);
	var scrollvalue=dwPgDoc.body.scrollTop+80;
  move_centerNewsTimeout=setTimeout("centerNEWSScroll()",800);
   
  
  dx=0;
  dx2=0;
  if(dwPgDoc.getElementById('onweb_flotbanr'))
      dwPgDoc.getElementById('onweb_flotbanr').style.top=(top+dwPgDoc.body.scrollTop)+"px";
  if(dwPgDoc.getElementById('onweb_flotbanr1_big'))
      dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(top+dwPgDoc.body.scrollTop)+"px";
  if(dwPgDoc.getElementById('onweb_flotbanr2'))
      dwPgDoc.getElementById('onweb_flotbanr2').style.top=(top+dwPgDoc.body.scrollTop)+"px";
  if(dwPgDoc.getElementById('onweb_flotbanr2_big'))
      dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(top+dwPgDoc.body.scrollTop)+"px";
  time_out_to_removing();
}

function bner_position(){
	bHeight=dwPgDoc.body.clientHeight;
  bWidth= dwPgDoc.body.clientWidth;
  //offsetX= "dwPgDoc.body.scrollLeft";

	widthb=parseInt(bWidth)-parseInt(banner_width1)-5;
	heightb=parseInt(bHeight)-parseInt(banner_height1);
	dwPgDoc.getElementById('onweb_flotbanr').style.left=(widthb)+"px";
	dwPgDoc.getElementById('onweb_flotbanr').style.top=(heightb)+"px";

  dwPgDoc.getElementById('onweb_flotbanr1_big').style.right=(banner_width1)+"px";
  dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(heightb)+"px";
  
  dwPgDoc.getElementById('onweb_flotbanr2').style.left=(5)+"px";
  dwPgDoc.getElementById('onweb_flotbanr2').style.top=(heightb)+"px";

  dwPgDoc.getElementById('onweb_flotbanr2_big').style.left=(parseInt(banner_width2)+5)+"px";
  dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(heightb)+"px";
}

function move_banr_pic(){
	if(top<=(dwPgDoc.body.clientHeight)&&direct_bnr=="down")
	  {
	  dwPgDoc.getElementById('onweb_flotbanr').style.top=(top+dwPgDoc.body.scrollTop)+"px";
	  dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(top+dwPgDoc.body.scrollTop)+"px";
	  
	  if(top>=(dwPgDoc.body.clientHeight-banner_height_mover1))
	      dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(dwPgDoc.body.clientHeight+dwPgDoc.body.scrollTop-banner_height_mover1-1)+"px";
	  top+=dx;
	  }
	if(top>=(dwPgDoc.body.clientHeight)-banner_height1)
	  {
	  direct_bnr="up";
	  }
	if(top==0)
	  {
	  direct_bnr="down";
	  }
	if(top<=(dwPgDoc.body.clientHeight)&&direct_bnr=="up")
	  {
	  dwPgDoc.getElementById('onweb_flotbanr').style.top=(top+dwPgDoc.body.scrollTop)+"px";
	  dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(top+dwPgDoc.body.scrollTop)+"px";
		
		if(top>=(dwPgDoc.body.clientHeight-banner_height_mover1))
		    dwPgDoc.getElementById('onweb_flotbanr1_big').style.top=(dwPgDoc.body.clientHeight+dwPgDoc.body.scrollTop-banner_height_mover1-1)+"px";
		top=top-dx;
	  }
	  
  if(top2<=(dwPgDoc.body.clientHeight)&&direct_bnr2=="down")
	  {
	  dwPgDoc.getElementById('onweb_flotbanr2').style.top=(top2+dwPgDoc.body.scrollTop)+"px";
	  dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(top2+dwPgDoc.body.scrollTop)+"px";
		if(top2>=(dwPgDoc.body.clientHeight-banner_height_mover2))
		    dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(dwPgDoc.body.clientHeight+dwPgDoc.body.scrollTop-banner_height_mover2-1)+"px";
		top2+=dx2;
	  }
	if(top2>=(dwPgDoc.body.clientHeight)-banner_height2)
	  {
	  direct_bnr2="up";
	  }
	if(top2==0)
	  {
	  direct_bnr2="down";
	  }
  if(top2<=(dwPgDoc.body.clientHeight)&&direct_bnr2=="up")
	  {
	  dwPgDoc.getElementById('onweb_flotbanr2').style.top=(top2+dwPgDoc.body.scrollTop)+"px";
	  dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(top2+dwPgDoc.body.scrollTop)+"px";
	  if(top2>=(dwPgDoc.body.clientHeight-banner_height_mover2))
	      dwPgDoc.getElementById('onweb_flotbanr2_big').style.top=(dwPgDoc.body.clientHeight+dwPgDoc.body.scrollTop-banner_height_mover2-1)+"px";
	  top2=top2-dx2;
	  }
	var move_banr_picTimeout;
	window.clearTimeout(move_banr_picTimeout);
  move_banr_picTimeout=setTimeout('move_banr_pic()',bnrInit.moveingTimer);
  //clearInteval(move_banr_picTimeout);
  //move_banr_picTimeout=setInterval('move_banr_pic()',bnrInit.moveingTimer);


}
function resiz_reposition(){
  bner_position();
}

//=============
ypos=-banner_height3;
xpos=200;
degree = 60;
set_x_moth=1;
set_y_moth=2;


function Curve(){
  abc=new Array(0,1,1,2,2,3,4,0,6,-1,-1,-2,-2,-3,-4,0,-6)
  for (i=0; i < abc.length; i++)
      {
      var C=Math.round(Math.random()*[i])
      }
  howbend=abc[C];
  var CurveTimeout;
  window.clearTimeout(CurveTimeout);
  CurveTimeout=setTimeout('Curve()',bnrInit.moveingTimer);
  
  //clearInteval(CurveTimeout);
  //CurveTimeout=setInterval('Curve()',bnrInit.moveingTimer);
  return howbend;
}


function MoveRandom(){
  PathBend=degree+=howbend;
  y = set_x_moth*Math.sin(PathBend*Math.PI/180);
  x = set_y_moth*Math.cos(PathBend*Math.PI/180);
  if (document.layers)
      {
      ypos+=y;
      xpos+=x;
      dwPgDoc.onweb_flotbanr3.top=ypos+window.pageYOffset;
      dwPgDoc.onweb_flotbanr3.left=xpos+window.pageXOffset;
      }
  else 
      {
      ypos+=y;
      xpos+=x;
      dwPgDoc.getElementById('onweb_flotbanr3').style.top=ypos+dwPgDoc.body.scrollTop;
      dwPgDoc.getElementById('onweb_flotbanr3').style.left=xpos+dwPgDoc.body.scrollLeft;
      dwPgDoc.getElementById('onweb_flotbanr3_big').style.top=ypos+dwPgDoc.body.scrollTop-(-banner_height3);
      dwPgDoc.getElementById('onweb_flotbanr3_big').style.left=xpos+dwPgDoc.body.scrollLeft;
      }
  var MoveRandomTimeout;
  window.clearTimeout(MoveRandomTimeout);
  MoveRandomTimeout=setTimeout('MoveRandom()',bnrInit.moveingTimer);
  //clearInteval(MoveRandomTimeout);
  //MoveRandomTimeout=setInterval('MoveRandom()',bnrInit.moveingTimer);
  
}

function edges(){
  if (document.layers)
    {
    if (dwPgDoc.onweb_flotbanr3.left >= window.innerWidth-40+window.pageXOffset)
        degree=Math.round(Math.random()*45+157.5);
    if (dwPgDoc.onweb_flotbanr3.top >= window.innerHeight-30+window.pageYOffset)
        degree=Math.round(Math.random()*45-112.5);
    if (dwPgDoc.onweb_flotbanr3.top <= 2+window.pageYOffset)
        degree = Math.round(Math.random()*45+67.5);
    if (dwPgDoc.onweb_flotbanr3.left <= 2+window.pageXOffset)
        degree = Math.round(Math.random()*45-22.5);
    }
  else 
    {
    if (dwPgDoc.getElementById('onweb_flotbanr3').style.pixelLeft >= dwPgDoc.body.offsetWidth-banner_width3+dwPgDoc.body.scrollLeft)
        degree=Math.round(Math.random()*45+157.5);
    if (dwPgDoc.getElementById('onweb_flotbanr3').style.pixelTop >= dwPgDoc.body.offsetHeight-banner_height3+dwPgDoc.body.scrollTop)
        degree=Math.round(Math.random()*45-112.5);
    if (dwPgDoc.getElementById('onweb_flotbanr3').style.pixelTop <= 2+dwPgDoc.body.scrollTop)
        degree = Math.round(Math.random()*45+67.5);
    if (dwPgDoc.getElementById('onweb_flotbanr3').style.pixelLeft <= 2+dwPgDoc.body.scrollLeft)
        degree = Math.round(Math.random()*45-22.5);
    }
  var edgesTimeout;
  window.clearTimeout(edgesTimeout);
  edgesTimeout=setTimeout('edges()',bnrInit.moveingTimer);
  //clearInteval(edgesTimeout);
  //edgesTimeout=setInterval('edges()',bnrInit.moveingTimer);
}
function starteffect(){
    Curve();
    MoveRandom();
    edges();
}


function centerNewsFrameControl(){
	 var cnfObj=dwPgDoc.getElementById('centerNewsFrame');
	 if(cnfObj.style.display==""||cnfObj.style.display=="none")
	     {
	     // first time load  // show
	     cnfObj.style.display="block";
	     cnfObj.style.left=0-cnfObj.offsetWidth;
	     }
	 else if(cnfObj.offsetLeft!=0)  
	 	   {// show
	 	   var cnfIframeObj=dwPgDoc.getElementById('center_news_conten_frame');
	 	   //if(cnfIframeObj)
	 	       //cnfIframeObj.src=cnfIframeObj.src;
	     cnfObj.style.left=0;
	     }
	 else
	 	   { // hidden
	 	   cnfObj.style.left=0-cnfObj.offsetWidth;
	 	   }
    
}



function onwebOnloadFunction(){
	if(bnrInit.sideFloatBnrOnOff==1)
	    {
	    bner_position();
	    move_banr_pic();
	    }
	if(bnrInit.randomFloatBnrOnOff==1)
	    {    
	    starteffect();
	    }
	    
	if(dwPgDoc.getElementById('centerNewsFrame'))
      {
      centerNewsFrameControl();	
      }
}

/* ================================= */
/* Original Information Co.,LTD.     */
/* http://www.original.com.tw        */
/* email:service@original.com.tw     */
/* ================================= */    
