$(function(){
	function initH(){
		$('#holder').css('height', 'auto');
		var holder_h_norm = $('.page').outerHeight() - $('#container').outerHeight(true) - ($('#footer').outerHeight(true) - parseInt($('#footer').css('marginTop'))) -parseInt($('#main').css('paddingTop')) - parseInt($('#block').css('paddingTop')) -parseInt($('#holder').css('paddingBottom'));
		var holder_h = $('#holder').height();
		if(holder_h < holder_h_norm){
			holder_h = holder_h_norm;
		}
		$('#holder').css('height', holder_h)
	}
	initH();
	$(window).resize(function(){
		initH();
	});
});
jQuery.fn.gallSlide1 = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		duration: 700,
		autoSlide: 5000
	},_options);

	return this.each(function(){
		var _hold = $(this);
		var _speed = _options.duration;
		var _timer = _options.autoSlide;
		var _wrap = _hold.find('ul');
		var _el = _hold.find('ul > li');
		var _count = _el.index(_el.filter(':last'));
		var _w = _el.outerWidth();
		var _wrapHolderW = Math.ceil(_wrap.parent().width()/_w);
		var _t;
		var _active = 0;
		function scrollEl(){
			_wrap.eq(0).animate({
				marginLeft: -(_w * _active) + "px"
			}, {queue:false, duration: _speed});
		}
		function runTimer(){
			_t = setInterval(function(){
				_active++;
				if (_active > (_count - _wrapHolderW + 1)) _active = 0;
				scrollEl();
			}, _timer);
		}
		runTimer();
	});
}
$(document).ready(function(){
	$('div.gallery').gallSlide1({
		duration: 700,
		autoSlide: 5000
	});
});

