//スクロールバー有無、サイズ取得
var isDisplayScrollBar=function(target,key){
	var val=target.css('overflow-'+key)
	if(val=='scroll')return true;
	if(val=='hidden')return false;
	if(val=='auto'||target.attr('tagName')=='HTML'){
		var method=(key=='y'?'Height':'Width');
		return target['exClient'+method]()< target['exScroll'+method]()
	}
	return false
}
$.fn.isDisplayScrollBar=function(key){
	return isDisplayScrollBar(this,key)
}
var scrollBarWidth=function(target){
	var w=jQuery.browser.msie?16:jQuery.browser.safari?15:17;
	return {
		x : target.isDisplayScrollBar('x')?w:0,
		y : target.isDisplayScrollBar('y')?w:0
	}
}
$.fn.scrollBarWidth=function(){
	return scrollBarWidth(this)
}
//非表示要素-採寸
$.fn.measur=function(f){
	var o=this,ret;
	var hide=o.is(":hidden");
	if(hide)o.show();
	ret=f();	
	if(hide)this.hide();
	return ret;
}
//メイン
$.fn.exClientHeight = function(){
	var o=(this[0]==window?$('html'):this)
	return o.attr('clientHeight');
}
$.fn.exClientWidth = function(){
	var o=(this[0]==window?$('html'):this)
	var s=o.measur(function(){return o.attr('clientWidth')});
	if(o.attr('tagName')!='HTML')return s;
	if(jQuery.browser.msie && jQuery.browser.version==7)
		return o.width();
	return s;
}
$.fn.exScrollHeight = function(){
	var o=this;
	var s=Math.max(
		o.measur(function(){return o.attr('scrollHeight')}),
		o.exClientHeight());
	if(o.attr('tagName')!='HTML')return s;
	if(jQuery.browser.msie && jQuery.browser.version==6)
		return $(document).height();
	return s;
}
$.fn.exScrollWidth = function(){
	var o=this;
	return Math.max(
		o.measur(function(){return o.attr('scrollWidth')}),
		o.exClientWidth());
}
$.fn.exOffsetHeight = function(){
	var o=this;
	var s=o.measur(function(){return o.attr('offsetHeight')});
	if(o.attr('tagName')!='HTML')return s;
	if(jQuery.browser.msie && jQuery.browser.version==6)
		return s;
	return o.exClientHeight()+o.scrollBarWidth().x

}
$.fn.exOffsetWidth = function(){
	var o=this;
	var s=o.measur(function(){return o.attr('offsetWidth')});
	if(o.attr('tagName')!='HTML')return s;
	if(jQuery.browser.msie && jQuery.browser.version==6)
		return s;
	return o.exClientWidth()+o.scrollBarWidth().y
}
