/*
 * Author: Mamaevsky Vasily
 */
/*---------------*/ 

function Abracadabra() {
	var min_item_w = 150;
	var stretch = 1.01;
if (($.browser.msie) && ($.browser.version == '6.0')) {stretch = 1.1;}
	var s_teaser 			= $('.block_tovar');
	var s_teasers 			= $('#catalog_index_holder').css('width', stretch * 100 + '%');
	var s_teasers_holder 	= $('#catalog_index_holder');
	var _window 			= $('#catalog_index_holder');	
	var window_w = _window.width();
	var window_w_tmp = 0;	
	var items = 0;
	var items_tmp = 0;	
//var delimiter = $('<div class="clr"></div>');	
	function _init() {
		$(window).bind("resize", function(){
			window_w = _window.width();
			items_tmp = Math.floor(window_w / min_item_w);
			
			if (items_tmp != items) {				
				if (items_tmp > 0) items = items_tmp;
				new_w = 100 / items / stretch; 
				new_w = new_w.toFixed(2);
			
				s_teaser.css('width', new_w + '%');				
				//delimiter.insertBefore(s_teaser.eq(items));
				
				/*s_teaser.each(function(index) {
					if (index > items * 2 - 1) $(this).hide();
					else $(this).show();
				});*/
			}
		});
		
		$(window).resize();
	}

	return {
		init: _init
	}
}

$(function(){
	if($('.block_tovar').size() > 0){
		var ruberTeasers = new Abracadabra();
		ruberTeasers.init();
	}
});

/*function Abracadabra() {
	var min_item_w = 150;
	var window_w = $('#catalog_index').width();
	var s_teasers 			= $('#index_portfolio').css('width', window_w  + 'px');
	var items = 0;
	var items_tmp = 0;	
	function _init() {
		$(window).bind("resize", function(){
			window_w = $('#catalog_index').width();
			items_tmp = Math.floor(window_w / min_item_w);
		qnt = $(".shk").length; //СЃС‡РёС‚Р°РµРј СЃРєРѕР»СЊРєРѕ РёРЅРїСѓС‚РѕРІ РЅР° СЃС‚СЂР°РЅРёС†Рµ
			if (items_tmp != items) {				
				if (items_tmp > 0) items = items_tmp;
				new_w = window_w / items ; 
				new_w = new_w.toFixed(0);
			s_teasers= $('#index_portfolio').css('width', new_w*items  + 'px');
				$('.block_tovar').css('width', new_w + 'px');
				$('.qnty').html(window_w);
			}	
		});
		
		$(window).resize();
	}

	return {
		init: _init
	}
}

$(function(){
	if($('.block_tovar').size() > 0){
		Abracadabra().init();
	}
});*/

