/*
* js Name     : floatIcon.js
* ObjectName  : floatIcon
* Athour      : xwl
* Create Date : 2010-10-19
* Usage       : float Icon of LM Cup Soft Design 
*/
var floatIcon={
      options:{
         left:"left",
         right:"right",
         top:"top",
         bottom:"bottom"
      },
      init:function(uri,img,w,h,l,t){
         this.uri=uri;
         this.img=img;
         this.width=w;
         this.height=h;
         this.left=l;
         this.top=t;
         
         this.cw=parseInt(document.body.offsetWidth);
         this.ch=parseInt(document.body.offsetHeight);
         
         this.dirX=this.options.right;
         this.dirY=this.options.bottom;
         this.div=this.createIcon();
         document.body.appendChild(this.div);
         this.start();
      },
      createIcon:function(){
         var div=document.createElement("DIV");
         div.id="LMCUP_Icon";
         div.style.left=this.left+"px";
         div.style.top=this.top+"px";
         div.style.width=this.width+"px";
         div.style.height=this.height+"px";
         div.style.position="absolute";
         div.style.zIndex=999;
         div.innerHTML='<a href="'+this.uri+'" target="_blank"><img src="'+this.img+'"  title="" width="'+this.width+'" height="'+this.height+'"/></a>';
         return div;
      },
      start:function(){
         this.timerId=window.setInterval("floatIcon.move()",1000);
      },
      move:function(){
         //X direct
         if(this.dirX==this.options.right){
             if((this.left+this.width)>=this.cw){
                this.dirX=this.options.left;
             }
             else{
                this.left=this.left+40;
                this.div.style.left=this.left+"px";
             }
         }
         else{
            if(this.left<=120){
               this.dirX=this.options.right;
            }
            else{
               this.left=this.left-40;
               this.div.style.left=this.left+"px";
            }
         }
         //Y direct
         if(this.dirY==this.options.bottom){
             if((this.top+this.height)>=this.ch){
                this.dirY=this.options.top;
             }
             else{
                this.top=this.top+40;
                this.div.style.top=this.top+"px";
             }
         }
         else{
            if(this.top<=340){
               this.dirY=this.options.bottom;
            }
            else{
               this.top=this.top-40;
               this.div.style.top=this.top+"px";
            }
         }
      }
}
