function scrollbarWidth() {
	if(jQuery.browser.version.substring(0,2) == "9."){
		return 18;
	}else{
		var div = _$('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');
		_$('body').append(div);
		var w1 = _$('div', div).innerWidth();
		div.css('overflow-y', 'scroll');
		var w2 = _$('div', div).innerWidth();
		_$(div).remove();
		return(w1 - w2);
	}
}
function scrollbar() {
	var difference = _$('#wrapper')[0].scrollHeight - _$('#wrapper').scrollTop()  - _$('#wrapper').outerHeight();
	if(difference < 10){
		_$('#fade').stop().hide();
	}else{
		_$('#fade').stop().show();
	}
}
function resize() {
	scrollbar();
	_$( '#bottom .bgimg' ).css("top", _$("#bottom .bgimg").position().top - _$(window).height() + 164);
	if((_$( '#wrapper .content' ).height() + 164) < _$( window ).height()){
		_$( '#wrapper .content' ).height(_$(window).height() - 189 );
	}
	var position = _$(".content").position();
	_$( '.logo' ).width(position.left);
	_$( '#signature' ).width(position.left);
	_$( '#sub-menu' ).css("left",position.left-251);
	_$( '#right' ).css("marginLeft",position.left+1);
	_$( '#right' ).css("width",_$(window).width()-position.left-1); // keep ie6 happy
	if((_$( '#wrapper .content' ).height() + 189) > _$( '#wrapper' ).height()){
		_$( '#bottom' ).css("width",_$('#wrapper').innerWidth()-scrollbarWidth());
	}else{
		_$( '#bottom' ).css("width",_$('#wrapper').innerWidth());
	}
	_$( '#fade' ).css("left",position.left);
}
/*
function textReplacement(input){
	var originalvalue = input.val();
	input.click( function(){
		if( _$.trim(input.val()) == originalvalue ){ input.val(''); }
	});
	input.blur( function(){
		if( _$.trim(input.val()) == '' ){ input.val(originalvalue); }
	});
}
*/
jQuery.fn.fullscreenr({width: 1200, height: 800, bgID: '.bgimg'});
jQuery(function(_$){
	resize();
	_$(window).resize( resize );
	_$('#wrapper').scroll(scrollbar);
	/*textReplacement(_$('input'));*/
});
