jQuery.fn.carouselTestimonialLogo = function(options){
    var logotypes=this;
    var mycarousel_itemList = [];
    var options = jQuery.extend({
        how: '10',
        websites:null,
		url:''
    },options);
	this.empty();
    return this.each(function() {
        jQuery.post(options.url+'carusel/controllers/Testimonial.php', {
            'action': "getLogotypes",
            'how':options.how,
            'websites':options.websites
        }, function(dataL){

            if (dataL.result==true){
                len=dataL.logotypes.length;
                    logotypes.jcarousel({
                        size:len,
                        auto: 1,
                        scroll: 1,
						
						animation: 'slow',
                        wrap: 'circular',

						itemFallbackDimension:200,
						setupCallback:function(cr){
							var indexLogo=1;
							jQuery.each(dataL.logotypes, function(index,value){
								var theImage     = new Image();
								theImage.src     = value.logotype;
								j(theImage).load(function(){
									imgHtml=mycarousel_getItemHTML(value);		
									cr.add(indexLogo, imgHtml);
									indexLogo++;
							});	
							});
							j(".jcarousel-container").prepend('<div><h4 style="font-family: Arial;">Наши клиенты:</h4></div>');
							 return true;
						}
                    });
            }      
        }, "json");  
    });
	
	
    function mycarousel_getItemHTML(item){
		if(item.fileName!='') file=item.fileName;
		else file=item.id;
		url=options.url+'showTestimonial/'+file+'.php';
		bl='';
		if(item.is_show==2){
			if(item.company_url){
				url=item.company_url;
				bl='target="blanck"';
			}
			else url='#';
		}
		
		return '<li><a '+bl+' class="logoImg" href="'+url+'"><img src="' + item.logotype + '"  height="75"   alt="' + item.company + '" /></a></li>';
        //return '<a href="'+url+'"><img src="' + item.logotype + '" width="75" height="75" alt="' + item.company + '" /></a>';
    }; 
};
