// JavaScript Document
(function($) {
	$.fn.vharesize = function(options) {
		var opts = $.extend({}, $.fn.vharesize.defaults, options);
		return this.each(function() {
			var $this 				= $(this);
			$this.opts 				= $.extend({}, opts);
			$.fn.vharesize.reposition($this)
			$(window).bind('resize', function() {
				clearTimeout($this.opts.timeout);
				$this.opts.timeout = setTimeout(function(){ $.fn.vharesize.dothing($this); },100);
			});
		});
	};
	
	$.fn.vharesize.defaults = {
		topheightWithScroll: 48,
		topheightWithoutScroll: 48,
		timeout: null,
		minheightWithScroll: 330,
		minheightWithoutScroll: 525
	};
	$.fn.vharesize.dothing = function($this){
		$.fn.vharesize.reposition($this);
		$.fn.vhascroller.setstatusandposition(currentscroller);
	}
	$.fn.vharesize.reposition = function($this){
		if($('#scroller').html()){
			var varhoogte = Math.ceil(parseInt($this.opts.topheightWithScroll) / 100 * parseInt($(window).height()));
			if(varhoogte < $this.opts.minheightWithScroll) varhoogte = $this.opts.minheightWithScroll;
		}else{
			var varhoogte = Math.ceil(parseInt($this.opts.topheightWithoutScroll) / 100 * parseInt($(window).height()));
			if(varhoogte < $this.opts.minheightWithoutScroll) varhoogte = $this.opts.minheightWithoutScroll;
		}
		$("#top").attr('height',varhoogte).stop().animate({'height':varhoogte+'px'},400);
	};
	
})(jQuery);
