//商品列表页面购买按钮统一事件处理
window.addEvent('domready', function() {

    var elEnter = function(e){
        var productId = this.id;
	    var newurl = "../../member/AjaxRequest.aspx?Command=ProductType&PID="+productId+"&PNAME=";
	    var el = $(this);
	    new Request({
	        url: newurl, 
	        method: "get",
	        onRequest: function(){
	            el.setStyle("cursor","text");
	        },
            onSuccess : function(txt){
                if( txt.length ==0 ){
                    el.removeEvents();
                    el.setStyle("cursor","");
                }else{
                    var x = el.getOffsets().x;
                    var y = el.getOffsets().y;
                    var width = el.getSize().x;
                    if(Browser.Engine.trident){
                        x -= 2;
                        y += 4;
                    }
                    
                    var elNew = new Element("div").setStyles({
                        "position": "absolute",
                        "top": y,
                        "left": (x + width) - 200
                    }).set("html",txt).inject(el,"after"); 
                    
                    //如果成功获得数据，则重新邦事件
                    el.removeEvents().addEvents({
                        "click": function(e){e.stop();},
                        "mouseenter": function(){elNew.show();},
                        "mouseleave": function(){elNew.hide();}
                    });
                    elNew.removeEvents().addEvents({
                        "mouseenter": function(){$(this).show();},
                        "mouseleave": function(){$(this).hide();}
                    });                    
                }              
                
		    }
	    }).send();        
    }
    
    var elLeave = function(e){
        
    }
    
    $$(".product-buy-btn").addEvents({
    "mouseenter": elEnter,
    "mouseleave": elLeave
    });
    
});
