var _tipTimer;
//局中函数
(function($){ 
    $.fn.center=function(settings){ 
        var style=$.extend({ 
                          position:'absolute',//absolute or fixed 
                          top:'50%',            //50%即居中，将应用负边距计算，溢出不予考虑了。 
                          left:'50%', 
                          zIndex:2009, 
                          relative:true        //相对于包含它的容器居中还是整个页面 
                          }, settings || {}); 
         
        return this.each(function(){ 
                  var $this=$(this); 
                   
                  if(style.top == '50%') style.marginTop=-$this.outerHeight()/2; 
                  if(style.left == '50%') style.marginLeft=-$this.outerWidth()/2; 
                  if(style.relative && !$this.parent().is('body') && $this.parent().css('position') == 'static') 
                      $this.parent().css('position','relative'); 
                  delete style.relative; 
                  //ie6 
                  if(style.position == 'fixed' && $.browser.version=='6.0'){ 
                      style.marginTop += $(window).scrollTop(); 
                      style.position = 'absolute'; 
                      $(window).scroll(function(){ 
                        $this.stop().animate({ 
                                          marginTop:$(window).scrollTop()-$this.outerHeight()/2 
                                          }); 
                        }); 
                  } 
                   
                  $this.css(style); 
                  }); 
    }; 
})(jQuery); 

function rand()
{
    return "&rand="+Math.random();
}

function bind(id,dict)
{
    if(dict!==undefined&&dict!=null&&dict!="")
    {
        $(id).html("");
        $(id).append("<option value=\"\">---请选择---</option>");
        for(var i=0;i<dict.length;i++)
        {
            $(id).append("<option value=\""+dict[i].Value+"\">"+dict[i].Label+"</option>");
        }
    }
}

function CountCheckBox(id)
{
    return $("input[name='"+id+"']:checked").length;
}

function showTip(msg)
{
    if(_tipTimer)
    {
        clearTimeout(_tipTimer);
    }
    if($("#tip").attr("tagName")=="undefined")
    {
        $("body").append("<div class=\"tip hide\" id=\"tip\"><span>"+msg+"</span></div>");
    }
    else
    {
        $("#tip").remove();
        $("body").append("<div class=\"tip hide\" id=\"tip\"><span>"+msg+"</span></div>");
    }
    $("#tip").center({position:'fixed',top:'50%'});
    $("#tip").fadeIn("slow");
	_tipTimer = setTimeout(function(){$("#tip").fadeOut("slow",function(){$("#tip").remove()});;},2000);
}

function closeTip(id)
{
	$(id).fadeOut("slow");
}

