function getCatalogAjax(url, main_holder_canvas, loading_canv, content_canv, next_button_id, prev_button_id, current_item){
	this._url = url;
	this._main_holder_canv = main_holder_canvas;
	this._load_canv = loading_canv;
	this._cont_canv = content_canv;
	this._current_page = 0;
	this._next_btn = next_button_id;
	this._next_btn_lock = false;
	this._prev_btn = prev_button_id;
	this._prev_btn_lock = true;
	this._catalog_current_item = current_item;
	this._cached_pages = 0;
	
	ua = navigator.userAgent;
	this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
	this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
	this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
	this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari
	this.isSafari = ua.indexOf('Safari') != -1;
	this.isOpera = window['opera'] && opera.buildNumber ? true : false;
	this.isMac = ua.indexOf('Mac') != -1;
	this.isNS7 = ua.indexOf('Netscape/7') != -1;
	this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
	
	/*this._move_right = $(this._main_holder_canv).offsetWidth * -1;
	this._move_left = $(this._main_holder_canv).offsetWidth;*/
	this._move_right = -270;
	this._move_left = 270;
	this._current_shift = 0;
	
	this._visible_blocks_cnt = 20;
	this._current_visible_block = -1;
	this._visible_blocks = new Array(this._visible_blocks_cnt);
	this._images_post_load = new Array(this._visible_blocks_cnt * 5);
	
	this._tpl_blc = '<a href="$4" class="ajax_korusel"><div onmouseover="return overlib(\'$3\', FGCOLOR, \'#009aca\', BGCOLOR, \'#009aca\', TEXTCOLOR, \'#ffffff\');" onmouseout="return nd();" id="kor_img_$1" class="image_slot" style="background-image: url(\'$2\'); border: 2px solid $selected_item_border;"><div class="slot_clear_content"><img id="loading_img_$1" src="/img/ajax-loader.gif" style="margin-bottom: -25px; display: none;"/></div><span class="$comments_cnt_class">$5</span></div></a>';
	
	this._items_list = null;

	var that=this;
	
	this.init = function () {
		for(var i = 0; i < this._visible_blocks.length; i++){
			this._visible_blocks[i] = 0;
		}
		
		//building internal divs
		if(!this.isMSIE){
			$(this._main_holder_canv).innerHTML = '<div id="' + this._load_canv + '" class="opaced kor_ajax_loading" style="display: none; width: 270px;"><img src="/img/ajax-loader2.gif" /></div>';
			$(this._main_holder_canv).innerHTML += '<div id="' + this._cont_canv + '" class="kor_korusel_hldr" style="overflow: hidden;"></div>';
		} else {
			var div_lod = document.createElement('div');
			div_lod.id = this._load_canv;
			div_lod.style.display = 'none';
			div_lod.style.width = '270px';
			div_lod.className = 'opaced kor_ajax_loading_iehack';
			div_lod.innerHTML = '<img src="/img/ajax-loader2.gif" />';
			$(this._main_holder_canv).appendChild(div_lod);
			
			var div_hldr = document.createElement('div');
			div_hldr.id = this._cont_canv;
			div_hldr.style.overflow = 'hidden';
			div_hldr.className = 'kor_korusel_hldr';
			$(this._main_holder_canv).appendChild(div_hldr);
		}
		//end
	}
	
	this.getInitialView = function(){
		new Effect.Appear(this._load_canv, {speed: 0.1, afterFinish: this._getInitialViewContinue});
	}
	
	this.showPrevBtn = function(){
		$(this._prev_btn).disabled = false;
		$(this._prev_btn).addClassName('kor_prev_btn');
		$(this._prev_btn).src = '/img/corusel_prev.jpg';
	}
	
	this.hidePrevBtn = function(){
		$(this._prev_btn).disabled = true;
		$(this._prev_btn).removeClassName('kor_prev_btn');
		$(this._prev_btn).src = '/img/corusel_dis.jpg';
	}
	
	this.showNextBtn = function(){
		$(this._next_btn).disabled = false;
		$(this._next_btn).src = '/img/corusel_next.jpg';
	}
	
	this.hideNextBtn = function(){
		$(this._next_btn).disabled = true;
		$(this._next_btn).src = '/img/corusel_dis.jpg';
	}
	
	this._getInitialViewContinue = function(){
		new Ajax.Request(that._url,
		{
			method: 'get',
	        parameters: {
	        	'item_id' : that._catalog_current_item,
	        	'width' : that._move_left,
	        	'ajax' : '1'
	        },
	        onSuccess: function(transport) {
	        	if(transport.responseJSON){
	        		that._items_list = $A(transport.responseJSON);
	        		
	        		if(isNaN(that._catalog_current_item) || that._catalog_current_item < 1){
	        			//start from first visible block
	        			that._current_visible_block = 0;
	        		} else {
	        			var cindex = -1;
	        			for(cindex = 0; cindex < that._items_list.length; cindex++){
	        				if(that._items_list[cindex][0] == that._catalog_current_item){
	        					break;
	        				}
	        			}
	        			
	        			if(cindex == that._items_list.length){
	        				cindex = -1;
	        			}
	        			
	        			if(cindex == -1){
	        				that._current_visible_block = 0;
	        			} else {
	        				that._current_visible_block = Math.floor( cindex / 5 );
	        				that.createFackeBlocks();
	        			}
	        		}
	        		
		        	new Effect.Fade(that._load_canv, {speed: 0.01});
	        	} else {
	        		new Effect.Fade(that._load_canv, {speed: 0.01});
	        	}
	        	
	        	that.view();
	        },
	        onFailure: function(transport) {
	           alert('Произошла Ошибка во время исполнения программы!');
	        }
	    });
	}
	
	this.createFackeBlocks = function(){
		var fc_blocks_cnt = this._current_visible_block;
		var total_html = '';
		var tpl_blc = this._tpl_blc;
		var vb = '';
		for(var i = 0; i < fc_blocks_cnt; i++){
			vb += this.createVisibleBlock(i, 5, true);
			this._visible_blocks[i] = -1;
		}

		$(this._cont_canv).update(vb);
		new Effect.Move(this._cont_canv, {mode: 'relative', x : this._move_right * fc_blocks_cnt, y : 0});
	}
	
	this.view = function(prev_view){
		if(this._current_visible_block <= 0){
			this.hidePrevBtn();
		} else {
			this.showPrevBtn();
		}
		
		if(this._current_visible_block >= this._visible_blocks_cnt - 1){
			this.hideNextBtn();
		} else {
			this.showNextBtn();
		}
		
		if(this._visible_blocks[this._current_visible_block] == 0){
			this._visible_blocks[this._current_visible_block] = 1;
			var vb = this.createVisibleBlock(this._current_visible_block, 5, true);
			$(this._cont_canv).update($(this._cont_canv).innerHTML + vb);
			this.postLoadImages();
		}
		else if(this._visible_blocks[this._current_visible_block] == -1){
			//this._images_post_load
			//alert('postloading');
			this.postLoadImages();
		} 
	}
	
	this.postLoadImages = function() {
		var from = this._current_visible_block * 5;
		var to = from + 5;
		for(var i = from; i < to; i++){
			if(this._images_post_load[i] == null){
				this._images_post_load[i] = new Image();
				this._images_post_load[i].item_id = i;
				
				//loading_img_$1
				$('loading_img_' + this._items_list[i][0]).show();
				this._images_post_load[i].onload = function() {
					var i = this.item_id;
					$('kor_img_' + that._items_list[i][0]).style.backgroundImage ="url('" + this.src + "')";
					$('loading_img_' + that._items_list[i][0]).hide();
				};
				
				this._images_post_load[i].onerror = function() {
					var i = this.item_id;
					$('loading_img_' + that._items_list[i][0]).src = '/img/jip/close.gif';
					//$('loading_img_' + that._items_list[i][0]).hide();
				};
				/**
				 * Setup src after Events assignments!!
				 */
				this._images_post_load[i].src = this._items_list[i][1];
			}
		}
	}
	
	this.createVisibleBlock = function(start_index, length, use_default_image){
		var ret_html = '';
		var tpl_blc = this._tpl_blc;
		var from = start_index * length;
		var to = from + length;
		for(var i = from; i < to; i++){
			html_blc = tpl_blc.replace(/\$1/g, this._items_list[i][0]);
			if(this._items_list[i][0] == this._catalog_current_item){
				html_blc = html_blc.replace(/\$selected\_item\_border/, '#0099cc');
			} else {
				html_blc = html_blc.replace(/\$selected\_item\_border/, 'white');
			}
			
			if(!use_default_image){
				html_blc = html_blc.replace(/\$2/, this._items_list[i][1]);
			} else {
				html_blc = html_blc.replace(/\$2/, '/img/print_default_th.png');
			}
			
			var desc = this.removequotes(this._items_list[i][2]);
			//alert(desc);
			//alert(desc);
			html_blc = html_blc.replace(/\$3/, desc);
			html_blc = html_blc.replace(/\$4/, this._items_list[i][3]);
			
			if(this._items_list[i][4] > 0){
				html_blc = html_blc.replace(/\$5/, this._items_list[i][4]);
				html_blc = html_blc.replace(/\$comments\_cnt\_class/, 'kor_comments_cnt');
			} else {
				html_blc = html_blc.replace(/\$5/, '&nbsp;');
				html_blc = html_blc.replace(/\$comments\_cnt\_class/, 'kor_comments_cnt_no');
			}
			//alert(html_blc);
			ret_html += html_blc;
		}
		return ret_html;
	}
	
	this.addslashes = function( str ){
		return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
	}
	
	this.removequotes = function( str ){
		return (str+'').replace(/([\\"'])/g, "").replace(/\0/g, "\\0");
	}
	
	this.getNextPage = function(){
		if(this._current_visible_block < this._visible_blocks_cnt - 1){
			this._current_visible_block++;
			this.view();
			new Effect.Move(this._cont_canv, {mode: 'relative', x : this._move_right, y : 0});
		}
	}
	
	this.getPrevPage = function () {
		if(this._current_visible_block > 0){
			this._current_visible_block--;
			this.view();
	    	//new Effect.Fade(that._load_canv, {speed: 0.01}); //, afterFinish: function() { $(canvas_name).update(transport.responseText) }
			new Effect.Move(that._cont_canv, {mode: 'relative', x : that._move_left, y : 0});
		}
	}
	
	/*this.getPrevPage = function(){
		new Effect.Appear(this._load_canv, {speed: 0.1, afterFinish: this._getPrevPage});
	}*/
}
