var stock = {
  box:null,
  parent:null,
  isInBox:null,
  isInLink:null,
  createBox:function() {
    document.write('<div id="Box" class="hidden">')         
    document.write('<div id="BoxForm"></div>')    
    document.write('</div>')          
  },
  init:function(){  
    this.box=document.getElementById("Box")                          
  },        
  show:function(parent,id) {
       
    this.isInLink = true              
    if(this.parent != parent) {       
             //alert('ok')
          stock.parent  = parent          
                              
          var f = function(txt) {
          
                var form = gOI("BoxForm")
                var box  = $('Box') 
                //gOI("Box") 
                var pos  = findPos(stock.parent,box.offsetParent)
                
                                
                form.innerHTML = txt
                                                                                                                                 
                box.onmouseover = function(e) {
                  stock.isInLink = false
                  stock.isInBox = true                   
                }
                
                box.addEvent("mouseleave", function(e){                            
                  stock.isInBox = false                                       
                  stock.hide()                                                                                         
                }) 
                /*
                box.onmouseout = function(e){                            
                  stock.isInBox = false                                       
                  stock.hide()                                                                                         
                } */
                
                
                $(stock.parent).addEvent("mouseleave", function(e){
                stock.isInLink = false
                stock.hide()          
                })
                /*
                stock.parent.onmouseout = function(e) {
                   stock.isInLink = false
                   stock.hide()                                                                  
                } */                                      
                
                pos[1] += stock.parent.height +2       
                box.style.left =  pos[0] + "px"
                box.style.top =  pos[1] + "px" 
                
                box.style.display='block'
                box.fade('in');                                     
          }                           
          try{                  
              var url = '/ajax/stock.php?p='+id;        
              ajaxRequest(url,f);            
          }catch(err){}                                           
      }  
                 
      return false        
  },
   hide2:function() {
         if(!this.isInBox && !this.isInLink) {             
            this.box.fade('out'); 
            this.parent = null                   
            return false    
          }               
          return false;
   },
  hide:function() { 
      setTimeout("stock.hide2()",100)
  }
}

stock.createBox()               
dotask(window, function(){stock.init()}, "load")
