/*
 * jQuery tipbox plugin
 * Version 0.1.0  (12/21/2008)
 * @requires jQuery v1.1.4+
 * @requires Dimensions plugin (for jQuery versions < 1.2.5)
 * build by jijunjian
 */
;(function($) {
    /**
* @param    options 可选参数，参数包含如下：
*    showEventName:显示DIV的事件名(可选)
*    hideEventName:隐藏DIV的事件名(可选)
*    offsetX:下拉框的X坐标偏移量(可选)
*    offsetY:下拉框的Y坐标偏移量(可选)
*    loadingMsg:加载中的提示信息
* @example html: <a class="tipMsg" href="../msg.jsp?id=123">test</a>
*          javascript: $("a.tipMsg").tipbox({'showEventName':'click',,'hideEventName':'mouseout','offsetX':13,'offsetY':0});
*/
$.fn.tipbox = function(options) {
	options = options || {};
	//默认参数
	var defaults = {
	    showEventName: 'mouseover',
	    hideEventName: 'mouseout',
	    loadingMsg: ''
	};
	options = jQuery.extend(defaults, options);
	//数据容器


	if($("#tipContainer").size() == 0){
	    //数据容器
	    var $tipContainer = jQuery('<div id="tipContainer" style="display:none;position:absolute;z-index:999;"></div>');
	    $tipContainer.appendTo(jQuery('body')[0]);
	}
	else
	{
	    var $tipContainer =$("#tipContainer");
	}
	//var $tipContainer = jQuery('<div class="tipContainer" style="display:none;position:absolute;z-index:999;"></div>');
	//$tipContainer.appendTo(jQuery('body')[0]);
	$tipContainer.mouseleave(function(){
	    $tipContainer.hide();
	});
	$tipContainer.bind(options.showEventName,function(){
	    $tipContainer.show();
	});

	//添加显示和隐藏事件处理函数
	return this.each(function(){
	    var $this = jQuery(this);
	    var url = $this.attr('urn');
	    $this.bind(options.showEventName, function(){
		$tipContainer.empty().html(options.loadingMsg)
		var offset = $this.offset();
		$tipContainer.css("top",offset.top+13+(options['offsetY']?options['offsetY']:0));
		$tipContainer.css("left",offset.left+(options['offsetX']?options['offsetX']:0));
		$tipContainer.show();
		jQuery.get(url,{t:Math.random()},function(msg){ $tipContainer.empty().html(msg);});
		return false;
	    });

	    $this.bind(options.hideEventName,function(){
		$tipContainer.hide();
	    })

	    /*rzr-begin
	    $this.parent().bind(options.hideEventName, function(e){
		var offset = $tipContainer.offset();
		if(offset.top > e.pageY || offset.left>e.pageX) $tipContainer.hide();
		// alert(offset.top +','+offset.left+':'+e.pageX+' , '+e.pageY);
		return false;
	    });
	    //rzr-end*/
	});
    };
})(jQuery);




/*
$.fn.msgbox({'url':'./callback/demo.php','offsetId':'mydiv','offsetX':13,'offsetY':0});
 *
 */
;(function($) {
    $.fn.msgbox = function(options) {
	options = options || {};
	//默认参数
	var defaults = {
	    showEventName: 'mouseover',
	    hideEventName: 'mouseout',
	    loadingMsg: ''
	};
	options = jQuery.extend(defaults, options);

	if($("#msgContainer").size() == 0){
	    //数据容器
	    var $tipContainer = jQuery('<div id="msgContainer" style="display:none;position:absolute;z-index:999;"></div>');
	    $tipContainer.appendTo(jQuery('body')[0]);
	}
	else
	{
	    var $tipContainer =$("#msgContainer");
	}
	var url = options.url;
	var offset = $("#"+options.offsetId).offset();        
	$tipContainer.empty().html(options.loadingMsg)
	$tipContainer.css("top",offset.top+(options['offsetY']?options['offsetY']:0));
	$tipContainer.css("left",offset.left+(options['offsetX']?options['offsetX']:0));
	$tipContainer.show();
	jQuery.get(url,{
	    t:Math.random()
	},function(msg){
	    $tipContainer.empty().html(msg);
	});
	$(".win_close").livequery('click', function(){
	    $tipContainer.empty();

	});

    };
})(jQuery);