//$().JDock
(function($){
	$.fn.extend({
		JDock:function(l){
			var l=(l?l:'bottom').toLowerCase();
			var $this=this;
			//非IE：isNaN(IEVer)==true，否则为IE版本号(数值型)
			var IEVer=Number(navigator.userAgent.replace(/(msie[^;]+).*/ig,'$1').replace(/.*msie([^;]*)/i,'$1'));
			
			//物件定位
			var lc=function(){
				if(l=='top' || l=='bottom'){
					$this.css({width:$(window).width()})
				}else{
					$this.css({height:$(window).height()})
				}
				var st=document.documentElement.scrollTop;
				var sl=document.documentElement.scrollLeft;
				if(IEVer>6){st=0;sl=0}
				switch(l){
					case 'top':		$this.css({top:st,left:0});break;
					case 'right':	$this.css({top:st,left:(sl+$(window).width()-$this.width())});break;
					case 'bottom':	$this.css({top:(st+$(window).height()-$this.outerHeight()),left:0});break;
					case 'left':	$this.css({top:st,left:sl});break;
				}
			}
			
			//IE6及非div元素使用js方法
			if($this[0].nodeName.toLowerCase()!='div' || IEVer<7){
				$this.css({zIndex:'40',position:'absolute',padding:0,margin:0,top:0});
				$(window).bind('scroll',lc);
			}else{
				$this[0].style.cssText+=';position:fixed !important;position:absolute;';
			}
			
			$(window).bind('resize',function(){setTimeout(lc,20)});
			setTimeout(lc,20);
		}
	});
})(jQuery);


//$().JInputBoxTip
(function($){
	$.fn.extend({
		JInputBoxTip:function(cls){
			var cls=cls?cls:'JInputBox_TipVal';
			this.each(function(){
					var $this=$(this);
					if($this.val()!=$this.attr('tipval') && $this.val()!=''){
						$this.removeClass(cls)
					}else{
						$this.addClass(cls);$this.val($this.attr('tipval'));
					}
					$this.bind('blur',function(){if($this.val()==''){$this.addClass(cls).val($this.attr('tipval'))}});
					$this.bind('focus',function(){if($this.val()==$this.attr('tipval'))$this.removeClass(cls).val('');});
					$this.bind('change',function(){if($this.val()!=$this.attr('tipval') && $this.val()!=''){$this.removeClass(cls)}});
				});
		}
	});
})(jQuery);
