_={	opacity:
	{	set:-[1,]?
			function(e,a){e.style.opacity=a/100}:
			function(e,a){e.filters.alpha?e.filters.alpha.opacity=a:e.style.filter='alpha(opacity='+a+')'},
		get:-[1,]?
			function(e){return window.getComputedStyle(e,null).opacity*100}:
			function(e){return e.filters.alpha?e.filters.alpha.opacity:100},
		fade:function(e,b,t,f)
		{	var o=this,a=o.get(e);
			if(a!=b&&t)
			{	var x=(b-a)*40/t,
					y=setInterval(function()
					{	a+=x;
						if((x<0&&a>b)||(x>0&&a<b))o.set(e,a);
						else
						{	o.set(e,b);
							clearInterval(y);
							if(f)f()
						}
					},40)
			}
			else if(f)f()
		}
	}
}

function sledernews(id,arr,param)
{	var o=
	{	w:625,				//Длина слайдера
		h:405,				//Ширина слайдера
		text_w:436,			//Длина текстового поля
		text_h:78,			//Ширина текстового поля
		head_w:68,			//Длина картинки-загаловка
		z:660,				//Увеличивать до такой длины картинки
		i:0,j:0,k:0,		//Счетчики циклов
		time_img:500,		//Время анимации смены картинок
		time_text:700,		//Время смены текста
		time_zoom:3000,		//Время увеличения картинки
		time_line:1000,		//Время обнавления загаловка
		time_arr:500,		//Время смены слайда при нажатии на кнопки промотки
		css:'sledernews',	//Приставка для класса объекта

		key:0,key1:0,				//Ключ, запрещающий или разрешеющий анимацию
		p:document.getElementById(id),

		newelem:function(e,p,c)
		{	e=document.createElement(e);
			p.appendChild(e);
			if(c)e.className=c;
			return e;
		},

		animate:function(e,s,a,b,t,f)
		{	if(a!=b&&t)
			{	var x=(b-a)*40/t,
					y=setInterval(function()
					{	a+=x;
						if(o.key&&!o.key1)
						{	o.key1=1;
							o.i+=o.key;
							if(o.i<0)o.i=arr.length-1;
							else if(o.i>=arr.length)o.i=0;
							o.key=o.j=o.k=0;
							_.opacity.fade(o.p,0,o.time_arr,function()
								{	o.creat();
									_.opacity.set(o.p,0);
									_.opacity.fade(o.p,100,o.time_arr,function(){o.key1=0})
								});
							clearInterval(y);
							return;
						}
						if((x<0&&a>b)||(x>0&&a<b))e.style[s]=a+'px';
						else
						{	e.style[s]=b+'px';
							clearInterval(y);
							if(f)f()
						}
					},40)
			}
			else if(f)f()
		},

		next_img:function()
		{	if((++o.k)<arr[o.i][1][o.j][1].length)
			{	o.img1.src=o.img2.src;
				o.img2.src=arr[o.i][1][o.j][1][o.k];
				o.img2.style.width=o.w+'px';
				o.div.style.left=0;
				o.animate(o.div,'left',0,-o.w,o.time_img,o.zoom);
			}
			else o.next_text();
		},

		next_text:function()
		{	o.k=-1;
			if((++o.j)<arr[o.i][1].length)
			{	o.animate(o.text,'marginLeft',0,-o.text_w,o.time_text,function()
					{	o.text.innerHTML=arr[o.i][1][o.j][0];
						o.animate(o.text,'marginLeft',-o.text_w,0,o.time_text)
					});
				o.next_img();
			}
			else o.next_head();
		},

		next_head:function()
		{	o.j=0;
			if((++o.i)==arr.length)o.i=0;
			_.opacity.fade(o.line,0,o.time_line,function()
				{	o.text.innerHTML=arr[o.i][1][o.j][0];
					_.opacity.fade(o.line,100,o.time_line)
				});
			o.name.innerHTML=arr[o.i][0];
			o.next_img();
		},

		zoom:function()
		{	o.animate(o.img2,'width',o.w,o.z,o.time_zoom,o.next_img);
		},

		creat:function()
		{	o.p.innerHTML='';	//Очищаем элемент. Внутри этого элемента может находиться HTML, который видно если JS выключен.
			o.p.style.cssText='position:relative;overflow:hidden;width:'+o.w+'px;height:'+o.h+'px;';

			o.div=o.newelem('div',o.p);
			o.div.style.cssText='position:relative;left:-'+o.w+'px;top:0;';

			o.img1=o.newelem('img',o.div);
			o.img1.src=arr[o.i][1][o.j][1][o.k];
			o.img1.style.width=o.z+'px';

			o.img2=o.newelem('img',o.div);
			o.img2.src=o.img1.src;
			o.img2.style.cssText='position:absolute;top:0;left:'+o.w+'px;width:'+o.w+'px;';

			o.line=o.newelem('div',o.p,o.css+'_line');
			o.line.style.height=o.text_h+'px';

			o.door=o.newelem('div',o.line,o.css+'_door');

			o.text=o.newelem('div',o.door,o.css+'_text');
			o.text.innerHTML=arr[o.i][1][o.j][0];

			o.head=o.newelem('div',o.line,o.css+'_head');

			o.name=o.newelem('div',o.p,o.css+'_name');
			o.name.innerHTML=arr[o.i][0];

			o.next=o.newelem('a',o.p,o.css+'_next');
			o.next.onclick=function(){o.key=1};
			o.prev=o.newelem('a',o.p,o.css+'_prev');
			o.prev.onclick=function(){o.key=-1};

			o.animate(o.text,'marginLeft',-o.text_w,0,o.time_text);
			o.zoom()
		}
	};
	if (param)
	{	o.w=param.w||o.w;
		o.h=param.h||o.h;
		o.text_w=param.text_w||o.text_w;
		o.text_h=param.text_h||o.text_h;
		o.head_w=param.head_w||o.head_w;
		o.z=param.z||o.z;
		o.time_img=param.time_img||o.time_img;
		o.time_text=param.time_text||o.time_text;
		o.time_zoom=param.time_zoom||o.time_zoom;
		o.time_line=param.time_line||o.time_line;
		o.time_arr=param.time_arr||o.time_arr;
		o.css=param.css||o.css;
	}

	o.creat();
}
