//■■共通パラメータ
DVEX2_todayQ = new Array();
//日付計算
function computeDate(year, month, day, addDays) {
    var dt = new Date(year, month - 1, day);
    var baseSec = dt.getTime();
    var addSec = addDays * 86400000;//日数 * 1日のミリ秒数
    var targetSec = baseSec + addSec;
    dt.setTime(targetSec);
    return dt;
}
var nowdate = new Date();
var m  = nowdate.getMonth() + 1; // 月
var d = nowdate.getDate(); // 日
var date = computeDate(nowdate.getFullYear(), m, d, 1);
var m2 = date.getMonth() + 1;
var d2 = date.getDate();
d2=(d2<10) ? "0"+d2 :  ""+d2;
m2=(m2<10) ? "0"+m2 :  ""+m2;
if ( typeof DVEX2_todayQ[m2+d2] != 'undefined' ) {
 DVEX2_mes=new Array(
            new Array("明日は「"+DVEX2_todayQ[m2+d2][0]+"」<br>"
                      +DVEX2_todayQ[m2+d2][1]+"<br>（クリックで続き）",
                      "http://dekirujan.sakura.ne.jp/365/"+DVEX2_todayQ[m2+d2][2]));
} else {
 DVEX2_mes=false;
}

DVEX2_shadow=0.8;//影の大きさ（０〜１）
DVEX2_attenuation=1;//重力モードのときにvzが0に近いときのvx,vyの減衰率[倍/sec]
var DVEX2_root="http://djn.x0.to/star/";//★画像の入っているURL

function DVEX2_FW_init() {
 var id=DVEX2_base.length;
 DVEX2_base[id]=new DVEX2_BaseFW(id);
 //★使用する画像の登録
// DVEX2_ImageUrl.push(DVEX2_root+"XXX.gif");


 DVEX2_start(id,DVEX2_ImageUrl);
}

//■■SAMPLEクラス　Baseクラスのサブクラス
function DVEX2_BaseFW(_uid) {

 this.DVEX2_newActorIntervalMin=1000;//★新規出現判定の間隔[msec]
 this.DVEX2_newActorIntervalMax=2000;//★新規出現判定の間隔[msec]
 this.maxCount=10;//★最大で何個出現するか

 this.DVEX2_interval=50;//更新間隔[msec]
 this.DVEX2_zIndexBase=15000;//レイヤーのzindexの基底。ここから積み上げ
 this.uid=_uid;
 this.interval=this.DVEX2_interval;//msec
 this.zIndexBase=this.DVEX2_zIndexBase;//zIndexの基底。ここから上積みされていく
 this.timer=1000;//次の出現までのカウントダウン
 this.count=0;//現在の出現数
 this.actor=new Array();//出現物を格納する配列

 this.hideAllLayers=function()
 {
  for (var i in this.actor) {
   if (!(isNaN(Number(i)))) {
    this.actor[i].hide();
   }
  }
 }

 this.showAllLayers=function()
 {
  for (var i in this.actor) {
   if (!(isNaN(Number(i)))) {
    this.actor[i].locate(this.actor[i].x,this.actor[i].y);
   }
  }
 }

 this.main=function()
 {
  var sleepTimeBegin=new Date();
  var err=false;
  DVEX2_calcScreen();
  try {
   //すべてのactorを動かす
   for (var i in this.actor) {
    if (!(isNaN(Number(i)))) {
     this.actor[i].action(this.interval);
     //徘徊終了なら消す
     if (this.actor[i].status=="dead") {
      this.actor[i].finalize();
      delete this.actor[i];
      this.count--;
     }
    }
   }
   //新規のactor
   this.timer-=this.interval;
   if ((this.timer<0)&&(this.count<this.maxCount)) {
    this.timer= Math.random()
               *(this.DVEX2_newActorIntervalMax-this.DVEX2_newActorIntervalMin)
               +this.DVEX2_newActorIntervalMin;
    var id=this.actor.length;

    //★★ここに呼び出し行を入れる
    var tmp=Math.floor(Math.random()*14+20);
    this.actor[id]=new DVEX2_ActorFW2D(
    id,
    this,
    Math.random()*120+210,
    tmp*2,
    0,
    0,
    0,
    0,
    new Array(
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#FFFFFF;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#FFFF99;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#FFFF33;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#FFCC99;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#FF99FF;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#CCCCFF;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#99FFFF;\">★</span>",0.2),
     new Array("text","<span style=\"font-family:'MS PGothic','MS Pゴシック';font-size:"+tmp+"px;color:#CCFFFF;\">★</span>",0.2)
    ),
    true,
    ((DVEX2_mes) ?
     DVEX2_mes[id % DVEX2_mes.length][0] : null),
    ((DVEX2_mes) ?
     DVEX2_mes[id % DVEX2_mes.length][1] : null)
     );//この行のパラメータですべてを制御する。


    this.count++;
   }
  } catch(e) {
   alert("."+e.description);
   err=true;
  }
  var sleepTimeEnd=new Date();
  var sleepTime= this.interval
                -(sleepTimeEnd.getTime()-sleepTimeBegin.getTime());
  if ( sleepTime < 10 ) {
   sleepTime=10;
  }
  if (err==false) {
   setTimeout('DVEX2_base['+this.uid+'].main();',sleepTime);
  }
 }
 
 this.initActor=function()
 {
  DVEX2_calcScreen();
  //広告枠だけは先に作っておく（ロードを1回にするため）
  var id=this.actor.length;
  this.actor[id]=new DVEX2_ActorFW2D_AD(id,this);
  //最初に1回だけ呼ばれる。

 }
}

//■■共通的な関数
function DVEX2_calcScreen() {
 DVEX2_screenWidth  = DVEX2_canvas.clientWidth;
 DVEX2_screenHeight = DVEX2_canvas.clientHeight;
 DVEX2_screenLeft   = DVEX2_canvas.scrollLeft;
 DVEX2_screenTop    = DVEX2_canvas.scrollTop;
 DVEX2_screenRight  = DVEX2_screenLeft + DVEX2_screenWidth;
 DVEX2_screenBottom = DVEX2_screenTop + DVEX2_screenHeight;
}

function DVEX2_checkArgInt(_arg,_df) {
 if (typeof(_arg)=="number") {
  var r=parseInt(_arg);
  if ((r<0)||(9<r)) r=_df;
 } else {
  r=_df;
 }
 return r;
}

function DVEX2_start(_uid,_url) {
 //共通的な部分
 DVEX2_shareLayer.style.position="absolute";
 DVEX2_shareLayer.style.visibility="hidden";
 DVEX2_shareLayer.style.margin="0px";
 DVEX2_shareLayer.style.padding="0px";
 DVEX2_shareLayer.style.width="auto";
 DVEX2_shareLayer.style.height="auto";
 DVEX2_shareLayer.style.whiteSpace="nowrap";
 DVEX2_shareLayer.style.left="-100px";
 DVEX2_shareLayer.style.top="-100px";
 document.body.appendChild(DVEX2_shareLayer);
 DVEX2_calcScreen();

 var tmp=document.getElementById('DVEX2_0');
 if (tmp.getAttribute('href')!="http://dekirujan.sakura.ne.jp/dekiru/") {
  alert("_"+tmp);
 } else {
  for (var i=0;i<_url.length;i++) {
   DVEX2_image[i]=new Image();
   DVEX2_image[i].src=_url[i];
  }
  DVEX2_loadImage(_uid);
 }
}

function DVEX2_loadImage(_uid) {
 //キャッシュ対策に画像を全部表示
 for (var i=0;i<DVEX2_image;i++) {
  var d=DVEX2_image[i];
  d.style.position="absolute";
  d.style.visibility="hidden";
  d.style.left="-100px";
  d.style.top="-100px";
  document.body.appendChild(d);
 }
 var flag=false;
 for (var i=0;i<DVEX2_image;i++) {
  if ( DVEX2_image[i].complete==false ) {
   flag=true;
   break;
  }
 }
 if (flag) {
  setTimeout('DVEX2_loadImage('+_uid+');',100);
 } else {
  DVEX2_base[_uid].initActor();
  setTimeout('DVEX2_base['+_uid+'].main();',1);
 }
}

//■■共通的な変数
var DVEX2_screenLeft;
var DVEX2_screenTop;
var DVEX2_screenRight;
var DVEX2_screenBottom;
var DVEX2_screenWidth;
var DVEX2_screenHeight;
var DVEX2_base=new Array();//本体
var DVEX2_image=new Array();//画像のロードに使う一時的なもの
var DVEX2_shareLayer=document.createElement('div');//getSizeに使う
var DVEX2_ImageUrl=new Array(DVEX2_root+"baloon_up.gif",
                             DVEX2_root+"baloon_lo.gif",
                             DVEX2_root+"baloon_up_1.gif",
                             DVEX2_root+"baloon_lo_1.gif",
                             DVEX2_root+"shadow.gif");
var DVEX2_canvas=(document.compatMode == 'CSS1Compat') ?
                 document.documentElement : document.body;

//■■■Thingクラス
function DVEX2_Thing(_parent) {
 this.parent=_parent;
 this.layer=document.createElement('div');
 this.layer.style.position="absolute";
 this.layer.style.overflow="hidden";
 this.layer.style.margin="0px";
 this.layer.style.padding="0px";
 this.layer.style.width="auto";
 this.layer.style.height="auto";
 this.layer.style.whiteSpace="nowrap";
 this.layer.parent=this;
 this.image;
 this.orgWidth;
 this.orgHeight;
 this.color="";
 this.opacity=100;
 this.width;
 this.height;
 this.fontSize="";
 this.type;//text または image
 this.animationType=new Array();
 this.animationItem=new Array();
 this.animationThreshold=new Array();
 this.animationIndex=0;
 this.animationValue=0;
 this.isChanged=false;
 this.isMoved=false;
 this.isOnscreen;

 this.hide=function()
 {
  try {
   document.body.removeChild(this.layer);
  } catch(e) {}
 }

 this.clearLayer=function()
 {
  this.hide();
  if (this.type=="image") {//Body or Shadow
   delete this.image;
  }
  this.layer.innerHTML="";
 }

 this.locate=function(_x,_y,_zIndex,_bottom)
 {
  var zIndex= _zIndex || this.parent.parent.zIndexBase;
  var bottom= _bottom || DVEX2_screenBottom;
  if (bottom > DVEX2_screenBottom) bottom=DVEX2_screenBottom;
  var cl=DVEX2_screenRight -_x;
  var ct=bottom -_y;
  if (this.isChanged) {
   this.hide();
  }
  if (  (cl>0)
      &&(ct>0)
      &&(_x>DVEX2_screenLeft-this.width)
      &&(_y>DVEX2_screenTop-this.height)) {
   this.layer.style.width=(cl<this.width) ? cl+"px" : this.width+"px";
   this.layer.style.height=(ct<this.height) ? ct+"px" : this.height+"px";
   this.layer.style.left=_x+"px";
   this.layer.style.top=_y+"px";
   this.layer.style.zIndex=zIndex;
   if ((this.isOnScreen==false)||(this.isChanged)) {
    document.body.appendChild(this.layer);
   }
   this.isOnScreen=true;
  } else {
   this.isOnScreen=false;
  }
  this.isChanged=false;
  this.isMoved=false;
  return this.isOnScreen;
 }

 this.getSize=function()
 {
  this.layer.style.width="auto";
  this.layer.style.height="auto";
  this.layer.style.position="static";
  DVEX2_shareLayer.appendChild(this.layer);
  this.width=DVEX2_shareLayer.offsetWidth;
  this.height=DVEX2_shareLayer.offsetHeight;
  this.orgWidth=this.width;
  this.orgHeight=this.height;
  DVEX2_shareLayer.removeChild(this.layer);
  this.layer.style.position="absolute";
 }

 this.setText=function(_str)
 {
  this.clearLayer();
  if (this.linkURL != null) {
   var ln=document.createElement("a");
   ln.style.textDecoration="none";
   ln.style.color="#000000";
   ln.style.border="none";
   ln.href=this.linkURL;
   ln.target="DVEX2";
   ln.innerHTML=_str;
   this.layer.appendChild(ln);
  } else {
   this.layer.innerHTML=_str;
  }
  this.getSize();
  this.type="text";
  this.isChanged=true;
 }

 this.setImage=function(_url)
 {
  this.clearLayer();
  this.image=document.createElement("img");
  this.image.src=DVEX2_root + _url;
  if (this.linkURL != null) {
   this.image.style.border="none";
   var ln=document.createElement("a");
   ln.href=this.linkURL;
   ln.target="DVEX2";
   ln.appendChild(this.image);
   this.layer.appendChild(ln);
  } else {
   this.layer.appendChild(this.image);
  }
  this.getSize(this.layer);
  this.type="image";
  this.isChanged=true;
 }

 this.setSize=function(_width,_height)
 {
//  this.hide();
  if (this.type=="image") {
   this.image.style.width=_width+"px";
   this.image.style.height=_height+"px";
   this.width=_width;
   this.height=_height;
   this.isMoved=true;
  } else {
   this.fontSize=_width;
   this.layer.style.fontSize=this.fontSize+"pt";
   this.getSize(this.layer);
   this.isChanged=true;
  }
 }

 this.setColor=function(_col)
 {
  this.layer.style.color=_col;
//  this.isChanged=true;
 }

 this.setOpacity=function(_opa)
 {
  this.layer.style.visibility=(_opa<=0) ? "hidden" : "visible";
  if (navigator.userAgent.indexOf('Safari') !=-1 ) {
   //safariは何もしない
  } else if (document.all) {  //IE
   this.layer.style.filter=(_opa>=100) ? '' : 'alpha(opacity='+_opa+')';
  } else if(navigator.userAgent.indexOf('Gecko')!=-1) { //FF
   this.layer.style.MozOpacity=(_opa>=100) ? "" : _opa/100;
  }
  this.opacity=_opa;
 }

 this.setAnimation=function(_array)
 {
  for (var i=0;i<_array.length;i++) {
   this.animationType.push(_array[i][0]);
   this.animationItem.push(_array[i][1]);
   this.animationThreshold.push(_array[i][2]);
  }
 }

 this.initAnimation=function()
 {
  this.animationIndex=0;
  if (this.animationType[this.animationIndex]=="image") {
   this.setImage(this.animationItem[this.animationIndex]);
  } else {
   this.setText(this.animationItem[this.animationIndex]);
  }
 }

 this.clearAnimation=function()
 {
  this.animationType.length=0;
  this.animationItem.length=0;
  this.animationThreshold.length=0;
 }

 this.animation=function(_value)
 {
  if (this.animationType.length>0) {
   this.animationValue+=_value;
   if (this.animationValue > this.animationThreshold[this.animationIndex]) {
    while (this.animationValue > this.animationThreshold[this.animationIndex]) {
     this.animationValue-=this.animationThreshold[this.animationIndex];
     this.animationIndex++;
     if (this.animationIndex>=this.animationItem.length) {
      this.animationIndex=0;
     }
    }
    if (this.animationType[this.animationIndex]=="image") {
     var w=this.width;
     var h=this.height;
     this.setImage(this.animationItem[this.animationIndex]);
//     this.setSize(w,h);
    } else {
     this.setText(this.animationItem[this.animationIndex]);
    }
   }
  }
 }
}

//■■■Actorクラス
function DVEX2_Actor(_uid,_parent) {
 this.uid=_uid;
 this.parent=_parent;
 this.x=-100;//bodyの中央
 this.y=-100;//2Dならbodyの中央、3Dならbodyの下
 this.isOnScreen;
 this.status;

 //イベント処理用の関数
 this.onMouseOver=function()
 {
  if (this.status="go") {
   this.status="wait";
   if (this.message!=null) {
    this.setBaloonText(this.message);
    this.showBaloon();
    this.refreshBaloon();
   }
  }
 }

 this.onMouseOut=function()
 {
  this.status="go";
  this.hideBaloon();
  this.refreshBaloon();
  this.onClick();//クリックをキャンセルしたかわりに処理追加
 }
 
 this.onClick=function()
 {}

 this.appendEvent=function(ev)
 {
  var ev=new Array();
  ev[0]=new Array("onmouseover",
                 "onMouseOver()");
  ev[1]=new Array("onmouseout",
                 "onMouseOut()");
//  ev[2]=new Array("onclick",
//                 "onClick()");
  var func;
  if (document.all) {
   for (var i=0;i<ev.length;i++) {
    func="DVEX2_base["+this.parent.uid+"].actor["+this.uid+"]."+ev[i][1];
    this.body.layer.setAttribute( ev[i][0] , new Function( func ));
   }
  } else {
   for (var i=0;i<ev.length;i++) {
    func="DVEX2_base["+this.parent.uid+"].actor["+this.uid+"]."+ev[i][1];
    this.body.layer.setAttribute( ev[i][0] , func );
   }
  }
 }
}

//■■■Actor2Dクラス Actorのサブクラス
function DVEX2_Actor2D(_uid,_parent) {
 this.base=DVEX2_Actor;
 this.base(_uid,_parent);
 this.body=new DVEX2_Body(this);
 this.baloon=new DVEX2_Baloon(this);
 this.baloonVisible=false;
 this.baloonPositionUpper;

 this.locate=function(_x,_y)
 {
  this.x=_x;
  this.y=_y;
  this.body.isMoved=true;
 }

 this.refresh=function()
 {
  if (this.body.isMoved || this.body.isChanged) {
   this.baloon.isMoved=this.baloonVisible;
   var bodyL=Math.floor(this.x-this.body.width/2);
   var bodyT=Math.floor(this.y-this.body.height/2);
   this.isOnScreen=this.body.locate(bodyL,bodyT);
  }
  this.refreshBaloon();
 }

 this.refreshBaloon=function()
 {
  var bodyT=Math.floor(this.y-this.body.height/2);
  this.baloon.isMoved=this.baloonVisible ? true : this.baloon.isMoved;
  if (this.baloon.isMoved || this.baloon.isChanged) {
   var baloonL=this.x-Math.floor(this.baloon.width/2);
   var baloonT=bodyT-this.baloon.height;
   if ((baloonL+this.baloon.width) > DVEX2_screenRight) {
    baloonL=DVEX2_screenRight-this.baloon.width;
   } else if (baloonL < DVEX2_screenLeft ) {
    baloonL=DVEX2_screenLeft;
   }
   if (baloonT < DVEX2_screenTop ) {//下にバルーン
    baloonT=bodyT+this.body.height;
    if (this.baloonPositionUpper) {//反転
     this.baloon.layer.innerHTML=this.baloon.baloonHtmlLower;
     this.baloonPositionUpper=false;
    }
   } else {
    if (! this.baloonPositionUpper) {//反転
     this.baloon.layer.innerHTML=this.baloon.baloonHtmlUpper;
     this.baloonPositionUpper=true;
    }
   }
   //このorは順番逆にすると動かないので注意！
   this.isOnScreen=this.baloon.locate(baloonL,baloonT) || this.isOnScreen;
  }
 }

 this.hide=function()
 {
  this.body.hide();
  this.baloon.hide();
 }

 this.setText=function(_txt)
 {
  this.body.setText(_txt);
 }

 this.setBaloonText=function(_txt,_size)
 {
  this.baloon.setText(_txt,_size);
  this.baloonPositionUpper=true;
  this.baloon.layer.innerHTML=this.baloon.baloonHtmlUpper;
  this.baloon.isChanged=true;
 }

 this.showBaloon=function()
 {
  this.baloonVisible=true;
  this.baloon.isChanged=true;
 }

 this.hideBaloon=function()
 {
  this.baloonVisible=false;
  this.baloon.hide();
 }

 this.setImage=function(_url)
 {
  this.body.setImage(_url);
 }

 this.setSize=function(_size1,_siez2)
 {
  this.body.setSize(_size1,_siez2);
 }

 this.setColor=function(_col)
 {
  this.body.setColor(_col);
 }

 this.setOpacity=function(_opa)
 {
  this.body.setOpacity(_opa);
  this.baloon.setOpacity(_opa);
 }

 this.finalize=function()
 {
  this.body.clearLayer();
  delete this.body.layer;
  delete this.body;
  if (this.baloon) {
   this.baloon.clearLayer();
   delete this.baloon.layer;
   delete this.baloon;
  }
 }
}
DVEX2_Actor2D.prototype=new DVEX2_Actor;

//■■■Actor3Dクラス Actorのサブクラス
function DVEX2_Actor3D(_uid,_parent) {
 this.base=DVEX2_Actor;
 this.base(_uid,_parent);
 this.body=new DVEX2_Body(this);
 this.shadow=new DVEX2_Shadow(this);
 this.shadowVisible=false;
 this.baloon=new DVEX2_Baloon(this);
 this.baloonVisible=false;
 this.baloonPositionUpper;
 this.z=0;//高さ

 this.locate=function(_x,_y,_z)
 {
  this.x=_x;
  this.y=_y;
  this.z=_z;
  this.body.isMoved=true;
 }

 this.refresh=function()
 {
  var ZIndex=this.parent.zIndexBase+Math.floor(this.y)+1;
  if (this.body.isMoved || this.body.isChanged) {
   this.shadow.isMoved=this.shadowVisible;
   this.baloon.isMoved=this.baloonVisible;
   var bodyL=Math.floor(this.x-this.body.width/2);
   var bodyB=Math.floor(this.y);
   var bodyT=bodyB-this.body.height-Math.floor(this.z);
   this.isOnScreen=this.body.locate(bodyL,bodyT,ZIndex,bodyB);
  }
  if (this.shadow.isMoved || this.shadow.isChanged) {
   var shadowL=Math.floor(this.x-this.shadow.width/2);
   var shadowT=Math.floor(this.y-this.shadow.height/2);
   //このorは順番逆にすると動かないので注意！
   this.isOnScreen=  this.shadow.locate(shadowL,shadowT,this.parent.zIndexBase)
                  || this.isOnScreen;
  }
  this.refreshBaloon();
 }

 this.refreshBaloon=function()
 {
  var ZIndex=this.parent.zIndexBase+Math.floor(this.y)+1;
  var bodyB=Math.floor(this.y);
  var bodyT=bodyB-this.body.height-Math.floor(this.z);
  this.baloon.isMoved=this.baloonVisible ? true : this.baloon.isMoved;
  if (this.baloon.isMoved || this.baloon.isChanged) {
   var baloonL=this.x-Math.floor(this.baloon.width/2);
   var baloonT=bodyT-this.baloon.height;
   if ((baloonL+this.baloon.width) > DVEX2_screenRight) {
    baloonL=DVEX2_screenRight-this.baloon.width;
   } else if (baloonL < DVEX2_screenLeft ) {
    baloonL=DVEX2_screenLeft;
   }
   if (baloonT < DVEX2_screenTop ) {//下にバルーン
    baloonT=bodyT+this.body.height;
    if (this.baloonPositionUpper) {//反転
     this.baloon.layer.innerHTML=this.baloon.baloonHtmlLower;
     this.baloonPositionUpper=false;
    }
   } else {
    if (! this.baloonPositionUpper) {//反転
     this.baloon.layer.innerHTML=this.baloon.baloonHtmlUpper;
     this.baloonPositionUpper=true;
    }
   }
   this.baloon.locate(baloonL,baloonT,ZIndex);
  }
 }

 this.hide=function()
 {
  //この関数は一時的に隠すために使用。
  //shadow,baloonを消す場合は別途hideShadow,hideBaloonを呼ぶこと
  this.body.hide();
  this.shadow.hide();
  this.baloon.hide();
 }

 this.setText=function(_txt)
 {
  this.body.setText(_txt);
 }

 this.showShadow=function()
 {
  this.shadowVisible=true;
  this.shadow.isChanged=true;
 }

 this.hideShadow=function()
 {
  this.shadowVisible=false;
  this.shadow.hide();
 }

 this.setBaloonText=function(_txt,_size)
 {
  this.baloon.setText(_txt,_size);
  this.baloonPositionUpper=true;
  this.baloon.layer.innerHTML=this.baloon.baloonHtmlUpper;
 }

 this.showBaloon=function()
 {
  this.baloonVisible=true;
  this.baloon.isChanged=true;
 }

 this.hideBaloon=function()
 {
  this.baloonVisible=false;
  this.baloon.hide();
 }

 this.setImage=function(_url)
 {
  this.body.setImage(_url);
 }

 this.setSize=function(_size1,_siez2)
 {
  this.body.setSize(_size1,_siez2);
  this.shadow.setSize(_size1);
 }

 this.setColor=function(_col)
 {
  this.body.setColor(_col);
 }

 this.setOpacity=function(_opa)
 {
  this.body.setOpacity(_opa);
  this.shadow.setOpacity(_opa);
  this.baloon.setOpacity(_opa);
 }

 this.finalize=function()
 {
  this.body.clearLayer();
  delete this.body.layer;
  delete this.body;
  if (this.shadow) {
   this.shadow.clearLayer();
   delete this.shadow.layer;
   delete this.shadow;
  }
  if (this.baloon) {
   this.baloon.clearLayer();
   delete this.baloon.layer;
   delete this.baloon;
  }
 }
}
DVEX2_Actor3D.prototype=new DVEX2_Actor;

//■■Bodyクラス　Thingのサブクラス
function DVEX2_Body(_parent) {
 this.base=DVEX2_Thing;
 this.base(_parent);
}
DVEX2_Body.prototype=new DVEX2_Thing;

//■■Shadowクラス　Thingのサブクラス
function DVEX2_Shadow(_parent) {
 this.base=DVEX2_Thing;
 this.base(_parent);
 this.rate=0.5;//影の縦横比
 this.setImage("shadow.gif");//影のデフォルト
 this.setSize=function(_size1,_size2)//オーバーライド
 {
  var size2= _size2 || _size1*this.rate;
  this.base=DVEX2_Shadow.prototype.setSize;
  this.base(_size1,size2);
 }
}
DVEX2_Shadow.prototype=new DVEX2_Thing;

//■■Baloonクラス　Thingのサブクラス
function DVEX2_Baloon(_parent) {
 this.base=DVEX2_Thing;
 this.base(_parent);
 this.baloonHtmlUpper;
 this.baloonHtmlLower;

 this.setImage=function(_url) //オーバーライド
 {
  //何もしない
 }

 this.setText=function(_str,_size) //オーバーライド
 {
  this.fontSize=(typeof(_size)=="number") ? _size+"px" : "12px";
  //文字のサイズを計測
  var str=
    '<div style="background:#FFFFFF;'
   +'padding:6px 10px 6px 10px;'
   +'color:#000000;'
   +'font-size:'+this.fontSize+';">'
   +_str
   +'</div>';

  this.baloonHtmlUpper=
'<TABLE cellpadding="0" cellspacing="0">'
+'<tr><td height="1" colspan="3" style="background:#000000;"></td></tr>'
+'<tr><td width="1" style="background:#000000;"></td>'
+'<td style="background:#FFFFFF;">'+str+'</td>'
+'<td width="1" style="background:#000000;"></td></tr>'
+'<tr><td height="13" colspan="3" align="center" '
+'style="background-image:url('+DVEX2_root+'baloon_up_1.gif);">'
+'<img src="'+DVEX2_root+'baloon_up.gif"></td></tr></TABLE>';

  this.baloonHtmlLower=
'<TABLE cellpadding="0" cellspacing="0">'
+'<tr><td height="13" colspan="3" align="center" '
+'style="background-image:url('+DVEX2_root+'baloon_lo_1.gif);">'
+'<img src="'+DVEX2_root+'baloon_lo.gif"></td></tr>'
+'<tr><td width="1" style="background:#000000;"></td>'
+'<td style="background:#FFFFFF;">'+str+'</td>'
+'<td width="1" style="background:#000000;"></td></tr>'
+'<tr><td height="1" colspan="3" style="background:#000000;"></td></tr>'
+'</TABLE>';

  DVEX2_shareLayer.innerHTML=this.baloonHtmlUpper;
  this.width=DVEX2_shareLayer.offsetWidth;
  this.height=DVEX2_shareLayer.offsetHeight;
  DVEX2_shareLayer.innerHTML="";
  this.clearLayer();
  this.type="text";
  this.isChanged=true;
 }
}
DVEX2_Baloon.prototype=new DVEX2_Thing;

//■■■2D型の基本クラス
function DVEX2_ActorFW2D(
 _uid,
 _parent,
 _direction,//進行方向：direction [deg], マイナスならランダム
 _velocity,//速度：velocity [px/sec]
 _d_velocity,//速度誤差：d_velocity [px/sec]
 _angular,//角速度：angular [deg/sec]
 _amplitude_x,//振幅x：amplitude_x [px]
 _amplitude_y,//振幅y：amplitude_y [px]
 _animation,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation_flag,//アニメするかしないかフラグ：animation_flag true/false
 _message,//言わせるべきセリフ：_message nullならバルーンが出ない
 _linkURL//リンク先：nullなら無視
 ) {//Actorクラスのサブクラス

 this.base=DVEX2_Actor2D;
 this.base(_uid,_parent);
 this.message=_message;
 this.wt=0;
 this.angular=_angular*2*Math.PI/360;
 this.amplitude_x=_amplitude_x;
 this.amplitude_y=_amplitude_y;
 this.body.linkURL=_linkURL;
 
//_animationをアニメに入れる
 this.body.setAnimation(_animation);
 this.body.initAnimation();
 this.animationFlag=_animation_flag;

//初期位置とx,yの移動量を決める
 this.ori=(_direction<0) ? Math.random()*2*Math.PI : _direction*2*Math.PI/360;
 var v=_velocity+(1-2*Math.random())*_d_velocity;
 this.vx= v*Math.cos(this.ori);//x移動量
 this.vy=-v*Math.sin(this.ori);//y移動量

 if (Math.abs(this.vx)>Math.abs(this.vy)) {
  this.by=Math.random()*DVEX2_screenHeight+DVEX2_screenTop;
  if (this.vx<0) {
   this.bx=DVEX2_screenRight+this.body.width/2-1;
   this.wt= (this.angular<0) ? 1.5*Math.PI : 0.5*Math.PI ;
  } else {
   this.bx=DVEX2_screenLeft-this.body.width/2+1;
   this.wt= (this.angular<0) ? 0.5*Math.PI : 1.5*Math.PI ;
  }
 } else {
  this.bx=Math.random()*DVEX2_screenWidth+DVEX2_screenLeft;
  if (this.vy<0) {
   this.by=DVEX2_screenBottom+this.body.height/2-1;
   this.wt= (this.angular<0) ? Math.PI : 0 ;
  } else {
   this.by=DVEX2_screenTop-this.body.height/2+1;
   this.wt= (this.angular<0) ? 0 : Math.PI;
  }
 }

 this.locate(this.bx,this.by);
 this.status="go";
 this.appendEvent(this.ev);

 this.action=function(_interval)
 {//intervalはミリ秒
  var interval=_interval/1000;
  if (this.status=="go") {
   if (this.animationFlag==true) {
    this.body.animation(interval);
   }
   this.bx+=this.vx*interval;
   this.by+=this.vy*interval;
   this.wt+=this.angular*interval;
   this.locate(this.bx+ this.amplitude_x*Math.cos(this.wt),
               this.by- this.amplitude_y*Math.sin(this.wt));
   this.refresh();
   if (this.isOnScreen==false) {
    this.status="dead";
   }
  }
 }
}
DVEX2_ActorFW2D.prototype=new DVEX2_Actor2D;

//■■■2D型の応用クラス　所定の位置に行って、一定時間経ったら去っていく
function DVEX2_ActorFW2D2(
 _uid,
 _parent,
 _direction,//進行方向：direction [deg], マイナスならランダム
 _gx,//目標地点x,マイナスならランダム
 _gy,//目標地点y,マイナスならランダム
 _velocity,//速度：velocity [px/sec]
 _d_velocity,//速度誤差：d_velocity [px/sec]
 _animation1,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation1_flag,//アニメするかしないかフラグ：animation_flag true/false
 _animation2,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation2_flag,//アニメするかしないかフラグ：animation_flag true/false
 _stoptime,//静止する時間
 _animation3,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation3_flag,//アニメするかしないかフラグ：animation_flag true/false
 _message,//言わせるべきセリフ：_message nullならバルーンが出ない
 _linkURL//リンク先：nullなら無視
 ) {//Actorクラスのサブクラス

 this.base=DVEX2_Actor2D;
 this.base(_uid,_parent);
 this.message=_message;
 this.body.linkURL=_linkURL;
 
//出現時点の_animationをアニメに入れる
 this.body.setAnimation(_animation1);
 this.body.initAnimation();
 this.animationFlag=_animation1_flag;

//静止時点のアニメを保存
 this.stopAnimation=_animation2;
 this.stopAnimationFlag=_animation2_flag;
 this.stopTime=_stoptime;

//去っていくときののアニメを保存
 this.awayAnimation=_animation3;
 this.awayAnimationFlag=_animation3_flag;

//初期位置とx,yの移動量を決める
 this.ori=(_direction<0) ? Math.random()*2*Math.PI : _direction*2*Math.PI/360;
 var v=_velocity+(1-2*Math.random())*_d_velocity;
 this.vx= v*Math.cos(this.ori);//x移動量
 this.vy=-v*Math.sin(this.ori);//y移動量

 this.gx=(_gx<0) ? Math.random()*DVEX2_screenWidth+DVEX2_screenLeft : _gx ;
 this.gy=(_gy<0) ? Math.random()*DVEX2_screenHeight+DVEX2_screenTop : _gy ;

 this.gt=0;//目標位置まで到達するのに要する時間

 var x0=(this.vx>0) ? DVEX2_screenLeft-this.body.width/2+1 : DVEX2_screenRight+this.body.width/2-1;
 var y0=(this.vy>0) ? DVEX2_screenTop-this.body.height/2+1 : DVEX2_screenBottom+this.body.width/2-1;
 var tx=(this.gx - x0)/this.vx;
 var ty=(this.gy - y0)/this.vy;
 if (tx<ty) {
  this.bx=x0;
  this.by=this.gy-this.vy*tx;
  this.gt=tx;
 } else {
  this.bx=this.gx-this.vx*ty;
  this.by=y0;
  this.gt=ty;
 }
 
 this.locate(this.bx,this.by);
 this.status="go";
 this.mode="come";
 this.appendEvent(this.ev);

 this.action=function(_interval)
 {//intervalはミリ秒
  var interval=_interval/1000;
  if (this.status=="go") {
   switch (this.mode) {
    case "come" :
     if (this.animationFlag==true) {
      this.body.animation(interval);
     }
     this.gt-=interval;
     if (this.gt<=0) {//到着
      this.mode="stay";
      this.bx=this.gx;
      this.by=this.gy;
      this.body.clearAnimation();
      this.body.setAnimation(this.stopAnimation);
      this.body.initAnimation();
      this.animationFlag=this.stopAnimationFlag;
     } else {
      this.bx+=this.vx*interval;
      this.by+=this.vy*interval;
     }
     this.locate(this.bx , this.by );
     this.refresh();
    break;
    case "away" :
     if (this.animationFlag==true) {
      this.body.animation(interval);
     }
     this.bx+=this.vx*interval;
     this.by+=this.vy*interval;
     this.locate(this.bx , this.by );
     this.refresh();
     if (this.isOnScreen==false) {
      this.status="dead";
     }
    break;
    case "stay" :
     if (this.animationFlag==true) {
      this.body.animation(interval);
     }
     this.stopTime-=interval;
     if (this.stopTime<=0) {//移動再開
      this.mode="away";
      this.body.clearAnimation();
      this.body.setAnimation(this.awayAnimation);
      this.body.initAnimation();
      this.animationFlag=this.awayAnimationFlag;
     }
     this.refresh();
    break;
    default :
   }
  }
 }
 this.onClick=function()
 {
  if (this.mode!="away") {
   this.mode="away";
   this.body.clearAnimation();
   this.body.setAnimation(this.awayAnimation);
   this.body.initAnimation();
   this.animationFlag=this.awayAnimationFlag;
   this.refresh();
  }
 }
}
DVEX2_ActorFW2D.prototype=new DVEX2_Actor2D;

//■■■2D型の基本クラス 広告表示版
function DVEX2_ActorFW2D_AD(_uid,_parent) {

 this.base=DVEX2_Actor2D;
 this.base(_uid,_parent);
 this.message=null;//バルーンなし

var tmp="";
switch (Math.floor(Math.random()*1000) % 6) {
 case 0:
 case 1:
 case 2:
tmp="<iframe src=\"http://rcm-jp.amazon.co.jp/e/cm?t=dankajr08-22&o=9&p=6&l=ez&f=ifr&f=ifr\" width=\"120\" height=\"150\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" border=\"0\" frameborder=\"0\" style=\"border:none;\"></iframe>";
DVEX2_Ad_height=150;
break;
 default:
tmp="<div id=\"DVEX2_AD\"> </div>";
DVEX2_Ad_height=1;
break;
}

 this.body.layer=document.createElement('div');
 this.body.layer.parent=this.body;
 this.body.type="text";
 this.body.width=120;
 this.body.height=DVEX2_Ad_height || 240;
 this.body.layer.style.position="absolute";
 this.body.layer.style.visibility="visible";
 this.body.layer.style.margin="0px";
 this.body.layer.style.padding="0px";
 this.body.layer.style.width=this.body.width+"px";
 this.body.layer.style.height=this.body.height+"px";
 this.body.layer.style.whiteSpace="nowrap";
 this.body.layer.style.left=(DVEX2_screenRight-this.body.width)+"px";
 this.body.layer.style.top=(DVEX2_screenBottom-this.body.height)+"px";
 document.body.appendChild(this.body.layer);
 this.body.layer.innerHTML=tmp;
 this.body.isChanged=false;
 this.animationFlag=false;

//初期位置とx,yの移動
 this.direction=new Array(2,6);//方向はテンキーの4682
 this.directionIndex=0;
 this.velocity=20;
 this.x=DVEX2_screenRight-this.body.width;
 this.y=DVEX2_screenBottom-this.body.height;
 this.locate(this.x,this.y);//初期位置は指定済み
 this.status="go";
 this.appendEvent(this.ev);
 this.refresh();

 this.action=function(_interval)
 {//intervalはミリ秒
  var interval=_interval/1000;
  //通常の移動
  if (this.status=="go") {
   if (this.animationFlag==true) {
    this.body.animation(interval);
   }
   switch (this.direction[this.directionIndex]) {
    case 4:
     this.x-=this.velocity*interval;
    break;
    case 6:
     this.x+=this.velocity*interval;
    break;
    case 8:
     this.y-=this.velocity*interval;
    break;
    case 2:
     this.y+=this.velocity*interval;
    break;
    default:
    break;
   }
   //位置補正
   if (this.x<DVEX2_screenLeft) {
    this.x=DVEX2_screenLeft;
    this.directionIndex++;
   } else if (this.x>(DVEX2_screenRight-this.body.width)) {
    this.x=DVEX2_screenRight-this.body.width;
    this.directionIndex++;
   }
   if (this.y<DVEX2_screenTop) {
    this.y=DVEX2_screenTop;
    this.directionIndex++;
   } else if (this.y>(DVEX2_screenBottom-this.body.height)) {
    this.y=DVEX2_screenBottom-this.body.height;
    this.directionIndex++;
   }
   if (this.directionIndex >= this.direction.length) {
    this.directionIndex=0;
   }
//   this.locate(this.x, this.y);
//   this.refresh();refreshをかけるとiframe内リロードになるので使わない
   this.body.layer.style.left=this.x+"px";
   this.body.layer.style.top=this.y+"px";
  }
 }
}
DVEX2_ActorFW2D_AD.prototype=new DVEX2_Actor2D;

//■■■3D型の基本クラス
function DVEX2_ActorFW3D(
 _uid,
 _parent,
 _xy_direction,//xy平面での進行方向：xy_direction [deg], マイナスならランダム
 _z_direction,//xy-z平面での進行方向：z_direction [deg], マイナスならランダム
 _x_fix,//nullは無視
 _y_fix,//nullは無視
 _z_fix,//z座標固定フラグ：z_fix マイナスなら地上ぎりぎりに補正,nullは無視
 _velocity,//速度：velocity [px/sec]
 _d_velocity,//ランダムに加減される速度誤差：d_velocity [px/sec]
 _xy_angular,//xy平面での角速度：xy_angular [deg]
 _z_angular,//xy-z平面での角速度：z_angular [deg]
 _amplitude_x,//振幅x：amplitude_x [px]
 _amplitude_y,//振幅y：amplitude_y [px]
 _amplitude_z,//振幅z：amplitude_z [px]
 _animation,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation_flag,//アニメするかしないかフラグ：animation_flag true/false
 _message,//言わせるべきセリフ：_message nullならバルーンを出さない
 _linkURL,//リンク先：nullなら無視
 _g,//重力：_g [px/sec/sec] マイナスなら無効
 _reflection//反発係数：_reflection [倍] マイナスなら無効（めり込む）
 ) {//Actorクラスのサブクラス

 this.base=DVEX2_Actor3D;
 this.base(_uid,_parent);
 this.message=_message;
 this.xy_angular=_xy_angular*2*Math.PI/360;
 this.z_angular=_z_angular*2*Math.PI/360;
 this.amplitude_x=_amplitude_x;
 this.amplitude_y=_amplitude_y;
 this.amplitude_z=_amplitude_z;
 this.xy_wt=0;
 this.z_wt=0;
 this.g=_g;
 this.reflection=_reflection;
 this.body.linkURL=_linkURL;

//_animationをアニメに入れる
 this.body.setAnimation(_animation);
 this.body.initAnimation();
 this.animationFlag=_animation_flag;

//初期位置とx,y,zの移動量を決める
 this.xy_ori=(_xy_direction<0) ?
             Math.random()*2*Math.PI :_xy_direction*2*Math.PI/360;
 this.z_ori=(_z_direction<0) ?
            Math.random()*2*Math.PI : _z_direction*2*Math.PI/360;
 this.vx= (_velocity+(1-2*Math.random())*_d_velocity)
         *Math.cos(this.z_ori)*Math.cos(this.xy_ori);//x移動量
 this.vy=-(_velocity+(1-2*Math.random())*_d_velocity)
         *Math.cos(this.z_ori)*Math.sin(this.xy_ori);//y移動量
 this.vz= (_velocity+(1-2*Math.random())*_d_velocity)
         *Math.sin(this.z_ori);//z移動量

 if (_z_fix==null) {
  if (  (Math.abs(this.vx)>Math.abs(this.vy))
      &&(Math.abs(this.vx)>Math.abs(this.vz))) {
   this.by=(_y_fix!=null) ?
           _y_fix : Math.sqrt(Math.sqrt(Math.random()))*DVEX2_screenHeight+DVEX2_screenTop;
   this.bz=Math.random()*DVEX2_screenHeight;
   if (this.vx<0) {
    this.bx=DVEX2_screenRight+this.body.width/2-1;
    this.xy_wt= (this.xy_angular<0) ? 1.5*Math.PI : 0.5*Math.PI ;
   } else {
    this.bx=DVEX2_screenLeft-this.body.width/2+1;
    this.xy_wt= (this.xy_angular<0) ? 0.5*Math.PI : 1.5*Math.PI ;
   }
  } else if (Math.abs(this.vy)>Math.abs(this.vz)) {
   this.bx=(_x_fix!=null) ?
           _x_fix : Math.random()*DVEX2_screenWidth+DVEX2_screenLeft;
   this.bz=Math.random()*DVEX2_screenHeight;
   if (this.vy<0) {
    this.by=DVEX2_screenBottom+this.body.height/2-1;
    this.xy_wt= (this.xy_angular<0) ? Math.PI : 0 ;
   } else {
    this.by=DVEX2_screenTop-this.body.height/2+1;
    this.xy_wt= (this.xy_angular<0) ? 0 : Math.PI;
   }
  } else {
   this.bx=(_x_fix!=null) ?
           _x_fix : Math.random()*DVEX2_screenWidth+DVEX2_screenLeft;
   this.by=(_y_fix!=null) ?
           _y_fix : Math.sqrt(Math.sqrt(Math.random()))*DVEX2_screenHeight+DVEX2_screenTop;
   this.bz=(this.vz<0) ? DVEX2_screenHeight-1 : -this.body.height+1;
  }
 } else {
  this.bz=(_z_fix>=0) ? _z_fix : -this.body.height+1;
  if ((Math.abs(this.vx)>Math.abs(this.vy))) {
   this.by=(_y_fix!=null) ?
           _y_fix : Math.sqrt(Math.sqrt(Math.random()))*DVEX2_screenHeight+DVEX2_screenTop;
   if (this.vx<0) {
    this.bx=DVEX2_screenRight+this.body.width/2-1;
    this.xy_wt= (this.xy_angular<0) ? 1.5*Math.PI : 0.5*Math.PI ;
   } else {
    this.bx=DVEX2_screenLeft-this.body.width/2+1;
    this.xy_wt= (this.xy_angular<0) ? 0.5*Math.PI : 1.5*Math.PI ;
   }
  } else {
   this.bx=(_x_fix!=null) ?
           _x_fix : Math.random()*DVEX2_screenWidth+DVEX2_screenLeft;
   if (this.vy<0) {
    this.by=DVEX2_screenBottom+this.body.height/2-1;
    this.xy_wt= (this.xy_angular<0) ? Math.PI : 0 ;
   } else {
    this.by=DVEX2_screenTop-this.body.height/2+1;
    this.xy_wt= (this.xy_angular<0) ? 0 : Math.PI;
   }
  }
 }

 this.locate(this.bx,this.by,this.bz);
 this.shadow.setSize(this.body.width/2);
 this.shadow.setOpacity(50);
 this.showShadow();
 this.status="go";
 this.appendEvent(this.ev);

 this.action=function(_interval)
 {//intervalはミリ秒
  var interval=_interval/1000;
  if (this.status=="go") {
   if (this.animationFlag==true) {
    this.body.animation(interval);
   }
   this.bx+=this.vx*interval;
   this.by+=this.vy*interval;
   this.vz-= this.g*interval;
   this.bz+=this.vz*interval;
   if ((this.reflection>=0)&&(this.bz<=0)) {//めり込んだら反射
    this.vz*=-this.reflection;
    this.bz=0;
    if (Math.abs(this.vz)<1) {
    this.vx*=Math.pow(DVEX2_attenuation,interval);
    this.vy*=Math.pow(DVEX2_attenuation,interval);
    }
   }

   this.xy_wt+=this.xy_angular*interval;
   if (this.reflection<0) {//反射モードではないときだけz軸回転を行う
    this.z_wt+=this.z_angular*interval;
    this.z=this.bz+ this.amplitude_z*Math.sin(this.z_wt);
   } else {
    this.z=this.bz;
   }
   var jh= ((DVEX2_screenHeight-this.z)>0) ? (DVEX2_screenHeight-this.z) : 0 ;
   this.shadow.setSize(DVEX2_shadow*this.body.width*jh/DVEX2_screenHeight);
   this.locate( this.bx+ this.amplitude_x
               *Math.cos(this.z_wt)*Math.cos(this.xy_wt) ,
                this.by- this.amplitude_y*Math.cos(this.z_wt)
               *Math.sin(this.xy_wt) ,
               this.z);
   this.refresh();
   if (  (this.isOnScreen==false)
       ||(DVEX2_screenHeight<this.bz)
       ||(this.bz<-this.body.height)) {
    this.status="dead";
   }
  }
 }

 this.onClick=function()
 {
  if (this.reflection>=0) {//反射モードだけ加速を行う
   var v=Math.random()*50+50;
   var t=Math.random()*2*Math.PI;
   this.vx+=v*Math.sin(t);
   this.vy+=v*Math.cos(t);
   this.vz+=100;
  }
 }
}
DVEX2_ActorFW3D.prototype=new DVEX2_Actor3D;

//■■■3D型の応用クラス　地面から出てくる
function DVEX2_ActorFW3D2(
 _uid,
 _parent,
 _z_top,//z座標目標位置：nullは無視
 _velocity,//速度：velocity [px/sec]
 _d_velocity,//ランダムに加減される速度誤差：d_velocity [px/sec]
 _z_angular,//xy-z平面での角速度：z_angular [deg]
 _amplitude_z,//振幅z：amplitude_z [px]
 _animation,//表示物配列：animation[type(image/text)],[URL/HTML],[閾値sec]
 _animation_flag,//アニメするかしないかフラグ：animation_flag true/false
 _message,//言わせるべきセリフ：_message nullならバルーンを出さない
 _linkURL,//リンク先：nullなら無視
 _keepTimer,//出てきてから引っ込むまでの時間[sec] nullなら無効
 _fadein,//フェードイン初期値を設定。マイナスもＯＫ、１００なら常に表示
 _fadeout,//フェードアウト最終値を設定。マイナスもＯＫ、１００なら常に表示
 _z0,//Zの初期値、最終値　nullは無視
 _op_rate//opの変化率%/sec
 ) {//Actorクラスのサブクラス

 this.base=DVEX2_Actor3D;
 this.base(_uid,_parent);
 this.message=_message;
 this.keepTimer=_keepTimer;
 this.z_angular=_z_angular*2*Math.PI/360;
 this.amplitude_z=_amplitude_z;
 this.z_wt=0;
 this.zTop=_z_top;
 this.z0=_z0;
 this.mode="come";//status=goのときに動くか止まるかを示す
 this.opRate=_op_rate;
 this.body.linkURL=_linkURL;

//_animationをアニメに入れる
 this.body.setAnimation(_animation);
 this.body.initAnimation();
 this.animationFlag=_animation_flag;

//初期位置とx,y,zの移動量を決める
 this.vz= (_velocity+(1-2*Math.random())*_d_velocity);

 this.bx=Math.random()*DVEX2_screenWidth+DVEX2_screenLeft;
 this.by=Math.sqrt(Math.sqrt(Math.random()))*DVEX2_screenHeight
         +DVEX2_screenTop;//画面下の方に偏向
 this.bz=(_z0 == null) ?
           ((this.vz<0) ? DVEX2_screenHeight-1 : -this.body.height+1)
          :(_z0);
 this.z_wt=(this.vz<0) ? Math.PI : 0;

 this.locate(this.bx,this.by,this.bz);
 this.shadow.setSize(this.body.width/2);
 this.shadow.setOpacity(50);
 this.showShadow();
 this.status="go";
 this.appendEvent(this.ev);
 this.fadeIn=_fadein;
 this.fadeOut=_fadeout;
 this.op=this.fadeIn;
 
 this.action=function(_interval)
 {//intervalはミリ秒
  var interval=_interval/1000;
  if (this.status=="go") {
   if (this.animationFlag==true) {
    this.body.animation(interval);
   }
   if (this.mode!="keep") {
    this.bz+=this.vz*interval;
    if (this.mode=="come") {
     this.op+=this.opRate*interval;
     this.setOpacity(this.op);
     if ((this.vz<0)?(this.zTop>=this.bz):(this.zTop<=this.bz)) {//目標地点到達
      this.bz=this.zTop;
      if (this.op>=100) {
       this.mode="keep";
      }
     }
    } else {
     this.op-=this.opRate*interval;
     this.setOpacity(this.op);
     this.bz=(this.op<=0) ? -this.body.height-2 : this.bz;
    }
   } else {
    if (this.keepTimer!=null) {
     this.keepTimer-=interval;
     if (this.keepTimer<0) {
      this.onClick();
     }
    }
   }
   this.z_wt+=this.z_angular*interval;
   this.z=this.bz+ this.amplitude_z*Math.sin(this.z_wt);
   var jh= ((DVEX2_screenHeight-this.z)>0) ? (DVEX2_screenHeight-this.z) : 0 ;
   this.shadow.setSize(DVEX2_shadow*this.body.width*jh/DVEX2_screenHeight);
   this.locate( this.bx, this.by, this.z);
   this.refresh();
   if (  (this.isOnScreen==false)
       ||(DVEX2_screenHeight<this.bz)
       ||(this.bz<-this.body.height)) {
    this.status="dead";
   }
  }
 }

 this.onClick=function()
 {
  if (this.mode!="away") {
   this.mode="away";
   this.vz=-this.vz;
   this.op=100;
  }
 }
}
DVEX2_ActorFW3D2.prototype=new DVEX2_Actor3D;

//onLoadイベント
if (document.all) {
 window.attachEvent('onload',DVEX2_FW_init);
} else {
 window.addEventListener('load',DVEX2_FW_init, false);
}
