	/*
	* YourSlideShow - jQuery Plugin
	* Simple SlideShow
	*
	* Examples and documentation at: http://neon.ws
	* 
	* Copyright (c) 2005-2010 Alexandr Kozlov (NEon)
	*
	* Version: 1.0 (01/04/2010)
	* Requires: jQuery v1.3+
	*
	* Доделать корректную обработку ошибок загрузки картинок и т.п.
	*
	* Dual licensed under the MIT and GPL licenses:
	* http://www.opensource.org/licenses/mit-license.php
	* http://www.gnu.org/licenses/gpl.html
	*/
jQuery.fn.YourSlideShow = function(options){
var options = jQuery.extend({
	speed:1000, // speed change frames
	interval:5000, // speed beetwen frames
	waitLoad:60000, // wait load all images
	loading:'Loading...',
	complete:'Complete!'
},options);
return this.each(function(){
	if (options.speed>=options.interval) options.speed=options.speed-(options.speed-options.interval)-555;
	var ii=0,i=0,i1=0,imgs_src=[],iloading=[],iloaded,img=document.createElement('img'),YourSlideShowContainer=jQuery(this),Images=YourSlideShowContainer.find('img');
	if (Images.length>1)
	{
		YourSlideShowContainer.css({'position':'relative'}).append("<div id='YourSlideShowSlideShowId' style='position:absolute;left:10px;top:10px;z-index:10;color:black;background:white;padding:2px 5px;'>"+options.loading+"</div>");
		Images.each(function(e){
			jQuery(this).css({'position':'absolute','display':'none','opacity':0});
			if (e==0) jQuery(this).css({'display':'block','opacity':1});
			imgs_src[i++]=jQuery(this).attr("src");
		});
		
		jQuery(img).bind('load', function(){
			
			if (imgs_src[0]) // Loading...
			{
				this.src=imgs_src.shift();
				iloading[i1++]=this.src;
			}
			else // Complete!
			{
				YourSlideShowContainer.find('div#YourSlideShowSlideShowId').html(options.complete).fadeOut(1500);
				var num_imgs_last,num_imgs=0;
				setInterval(function(){
					num_imgs_last=num_imgs;
					num_imgs++;
					if (num_imgs>Images.length-1) num_imgs=0;
					Images.eq(num_imgs).css({'display':'block'}).fadeTo(options.speed,1,function(){
						Images.eq(num_imgs_last).css({'opacity':0,'z-index':1});
						Images.eq(num_imgs).css({'z-index':0});
					});
				},
				options.interval);
				clearInterval(iloaded);
			}
			YourSlideShowContainer.css({'width':this.width, 'height':this.height});
		}).trigger('load');
		
		iloaded=setTimeout(function(){
			YourSlideShowContainer.find('div#YourSlideShowSlideShowId').css({'white-space':'nowrap'}).html('Trabla with image <b>'+iloading[i1-1]+'</b>');
		},options.waitLoad);
	}
	else if (Images.length==1)
	{
		Images.eq(0).css({"display":"block"});
	}
});
};
