		function mycarousel_itemLoadCallback(carousel, state)
		{
		    // Check if the requested items already exist
		    if (carousel.has(carousel.first, carousel.last)) {
		        return;
		    }
		
		    jQuery.get(
		        '/dynamic_ajax_php.php',
		        {
		            first: carousel.first,
		            last: carousel.last
		        },
		        function(xml) {
		            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
		        },
		        'xml'
		    );
		};
		
		function mycarousel_itemAddCallback(carousel, first, last, xml)
		{
		    // Set the size of the carousel
		    carousel.size(parseInt(jQuery('total', xml).text()));
		
		    jQuery('comment', xml).each(function(i) {
		        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this)));
		    });
		};
		
		/**
		 * Item html creation helper.
		 */
		var ider = 0;
		function mycarousel_getItemHTML(url)
		{
			ider++;
			var descr;
			comText = url.text();
      if(comText.length > 130)
        comText = comText.substr(0, 130) + '[<a href="#">...</a>]';

			descr = "<table border='0' width='300' height='165' cellspacing=0 cellpadding=0>";			
			descr += "<tr><td rowspan='5' width='20'>&nbsp;</td><td rowspan='5' align='right' valign='top' width='100'><div class='imgHolder'><img src='"+url.attr('image')+"' alt=''></div></td>";
			descr += "<td class='nameCom' height='30' align='right' valign=center>"+url.attr('author')+"</td><td width='50'><div class='dateCom'>"+url.attr('date')+"</div></td></tr>";
			descr += "<tr><td colspan='2' class='textCom' valign='top' onmouseover='showFullText("+ider+")'>"+comText+"</td></tr>";
			descr += "<tr><td colspan='2'><a href='#' class='arrowdown' onmouseover='showFullText("+ider+")'>&nbsp;</a></td></tr></table>";
			descr += '<input type="hidden" id="ft'+ider+'" value="'+url.attr("id")+'">';
      
		    return descr;
		};
    var icqShowed = false;
    var shShowed = false;
    var phoneShowed = false;
    
    var icqTimer = 5000, phoneTimer = 5000, shTimer = 5000;
			jQuery(document).ready(function() {
			    jQuery('#mycarousel').jcarousel({
			        // Uncomment the following option if you want items
			        // which are outside the visible range to be removed
			        // from the DOM.
			        // Useful for carousels with MANY items.
					scroll : 3,
			        //itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
			        itemLoadCallback: mycarousel_itemLoadCallback
		    });
		    
			$('#icq').mouseover(function(){
				hideAll(3);
	          if(!icqShowed){
	            $('#icqId').show('slow');
	            icqShowed = true;
	            setTimeout(
	              function() {
	                $('#icqId').hide('slow');
	                icqShowed = false;
	                clearTimeout();
	              },
	              icqTimer
	            );
	          }
			});
			
			$('#chat_online').mouseover(function(){
				hideAll(2);
				if (!shShowed){
					$('#siteHeart').show(500);
					shShowed = true;
					setTimeout(function(){
							$('#siteHeart').hide('slow');
			                shShowed = false;
			                clearTimeout();							
						}, shTimer
					);
				}
			});
			$('#phoneNumber').mouseover(function(){
				hideAll(1);
				if (!phoneShowed){
					$('#phoneShow').show(500);
					phoneShowed = true;
					setTimeout(function(){
						$('#phoneShow').hide('slow');
		                phoneShowed = false;
		                clearTimeout();							
					}, phoneTimer
					);
			}
				
			});
			function hideAll(p){
				switch (p){
					case 1: 
						$('#siteHeart').hide(); shShowed = false;
						$('#icqId').hide(); icqShowed = false;
					break;
					case 2: 
						$('#phoneShow').hide();	phoneShowed = false;
						$('#icqId').hide();	icqShowed = false;
					break;
					case 3: 
						$('#phoneShow').hide();	phoneShowed = false;
						$('#siteHeart').hide(); shShowed = false;
					break;
				}
			}
			$('.jcarousel-prev-horizontal').html('<a href="#" onclick="return false;">&larr; новые</a>');
			$('.jcarousel-next-horizontal').html('<a href="#" onclick="return false;">старые &rarr;</a>');
			$('.jcarousel-prev-horizontal').click(function(){$('#mess').hide();});
			$('.jcarousel-next-horizontal').click(function(){$('#mess').hide();});
		});
		function showFullText(ider){
			//$('#mess').hide();
			hv = $('#ft'+ider).attr("value");
			topV = "72";
			switch (ider % 3) {
				case 1: leftV = "113"; break;
				case 2: leftV = "442"; break;
				case 0: leftV = "773"; break;
			}
			jQuery.get(
					'/get_comment.php', 
					{ id : hv }, 
					function(xml){
						$('#messText').html($('comment', xml).text());
						$('#mess').css({left : leftV+"px", top : topV + "px"});
						$('#mess').show(500);
						//clearTimeout();
						setTimeout(function() {
							$('#mess').hide(500);
							clearTimeout();
						}, timer); 
					}, 'xml'
			);
			$('#ft'+ider).addClass('fullComment');
			$('#ft'+ider).removeClass('hide');
			$('#ft'+ider).fadeIn();
		}
		function hideme(ider){
			$('#ft'+ider).fadeOut();	
		}
