/* balloon.js v1.1 */
/* (C)t.hira ( http://thira.plavox.info/ ) */
/* Licensed under Creative Commons Attribution 2.1 Japan ( http://creativecommons.org/licenses/by/2.1/jp/ ) */
/* Licensed under MIT License http://www.opensource.org/licenses/mit-license.php */


// Constructor
function Balloon(){
 this.initMousePosition();
 this.mouseX=260;
 this.mouseY=197;
 this.clear();
 return false;
}
//Clear BalloonStyle
Balloon.prototype.clear=function(s){
 this.setBalloonRound(20);
 this.setBalloonWidth(320);
 this.setBalloonHeight(180);
 this.setBalloonLadder(35);
 this.setBalloonLadderStyle(0);
 this.setFontSize(12);
}
//Set BallonRound
Balloon.prototype.setBalloonRound=function(s){
 Balloon.round=s;
}
//Set BalloonWidth
Balloon.prototype.setBalloonWidth=function(s){
 Balloon.width=s;
}
//Set BalloonHeight
Balloon.prototype.setBalloonHeight=function(s){
 Balloon.height=s;
}
//Set BalloonLadder
Balloon.prototype.setBalloonLadder=function(s){
 Balloon.ladder=s;
}
//Set BalloonLadderStyle
Balloon.prototype.setBalloonLadderStyle=function(s){
 if(s==1){
  Balloon.ladderStyle=90-Math.ceil(Balloon.ladder/3);
  Balloon.ladderWidth=Math.ceil(Balloon.ladder/3*1.7);
  Balloon.ladderOffsetX=Math.ceil(Balloon.ladder/3);
  Balloon.ladderSpacerX=Math.ceil(Balloon.ladder/3)-2;
 }
 else if(s==2){
  Balloon.ladderStyle=120;
  Balloon.ladderWidth=120;
  Balloon.ladderOffsetX=Math.ceil(Balloon.ladder/1.4);
  Balloon.ladderSpacerX=0;
 }
 else{
  Balloon.ladderStyle=10;
  Balloon.ladderWidth=60;
  Balloon.ladderOffsetX=Math.ceil(Balloon.ladder/8);
  Balloon.ladderSpacerX=0;
 }
}
//Set BalloonLadder
Balloon.prototype.setFontSize=function(s){
 Balloon.fontSize=s;
}
//Balloon PopUp
Balloon.prototype.popup=function(id,msg){
 var objBalloon = document.createElement("div");
 var balloonHTML;
 balloonHTML="<div class=\"bl_t\" style=\"margin:0px;height:144px; width:285px;background:url('../images/balloon-trans.png') no-repeat ;\">\n";
 balloonHTML+="<p style=\"text-align:left;margin:0px;padding:20px 0 0 0;\">"+msg+"</p></div>\n";
objBalloon.setAttribute('id','Balloon_'+id);
 document.body.appendChild(objBalloon);
 document.getElementById('Balloon_'+id).style.position="absolute";
 document.getElementById('Balloon_'+id).style.left=Math.ceil(Balloon.mouseX+Balloon.width*1.7+Balloon.ladderOffsetX-Balloon.ladderSpacerX)+"px";
 document.getElementById('Balloon_'+id).style.top=Balloon.mouseY+Balloon.height*1.3-Balloon.ladder+"px";
 document.getElementById('Balloon_'+id).style.fontSize=Balloon.fontSize+"px";
 document.getElementById('Balloon_'+id).innerHTML=balloonHTML;
}
//Balloon Close
Balloon.prototype.close=function(id){
 document.getElementById('Balloon_'+id).innerHTML="";
}
//Bark
Balloon.prototype.bark=function(){
 this.popup('__bark','Wan!Wan!');
}
//Init Mouse Position
Balloon.prototype.initMousePosition=function(){
 window.document.onmousedown = function(e){
  Balloon.mouseX = balloon.getMousePosition(e).x;
  Balloon.mouseY = balloon.getMousePosition(e).y;
 }
}
//Get Mouse Position
Balloon.prototype.getMousePosition=function(e){
 var obj = new Object();
 if(e){
  obj.x = e.pageX;
  obj.y = e.pageY;
 }
 else{
  obj.x = event.x + document.body.scrollLeft;
  obj.y = event.y + document.body.scrollTop;
 }
 return obj;
}

balloon=new Balloon();


