/* ----------------------------------------------------------------------------------------------------------------- */
//      param

        var imgs			= getChild('img'); 	// нужно ставить условие на нежность этого параметра
	var start			= null;
	var func_event			= null;


//	каллендарь
	var cal_w = cal_w_tmp		= 246;
	var cal_h = cal_h_tmp		= 100;
	var cal_w_max			= 980;
	var cal_h_max			= 740;
	var cal_w_step			= 20;
	var cal_h_step			= 20;
	var cal_time			= 10;
	var cal_event			= null;

//      блок каллендарь
        var img_w			= 62;			// должно соответствовать ширине картинки в cal.css
        var img_h			= 33;			// должно соответствовать высоте картинки в cal.css
        var img_w_max			= 200;
        var img_h_max			= 100;
        var img_w_step			= 10;
        var img_h_step			= 6;
        var img_time			= 10;
        var img_start			= [];
        var img_event			= [];

//      блок more
        var more_w			= 28;			// должно соответствовать width видимой части блока "a href" в more.css
        var more_m			= 833;			// должно соответствовать margin для #more в index.css 
	var more_w_min			= 153;			// должно соответствовать width для #more в index.css 
        var more_w_max			= 985;
        var more_w_div_max		= 170;
        var more_w_step			= 10;
        var more_time			= 50;
        var more_event			= null;
        var more_start			= [];

//	анимация ссылки
	var arr_pos = arr_pos_tmp	= 100;
	var href_pos = href_pos_tmp	= 0;
	var arr_pos_min			= -5;
	var arr_pos_end			= 105;
	var href_pos_end		= 20;
	var arr_step			= 1;
	var href_step			= 2;
	var href_event			= 0;

//	анимация ссылки 2
//var start	= null;
	var count	= c		= 5;
	var step_href			= 2;
	var step_arrow			= 4;
	var padCurL	= padL		= 10;
	var padCurR	= padR		= 10;
	var bgCurR	= padBgR	= 100;
	var bgCurL	= padBgL	= -2;



//	анимация падания новостей на первой странице
//	скорее всего нужны start и func_event
	var blocks_m_step		= 114;
	var blocks_m = blocks_m_max	= -(20*blocks_m_step);
	var blocks_start		=null;


//	востановление пароля
	var mail_h = mail_h_tmp		= 0;
	var mail_step			= 10;
	var start_mail			= null;

//	падение первых 2-х видео
	fall_start			= null;
	fall_margin			= -100;
	fall_step			= 10;
	fall_time			= 50;


/* ------------------------------------------------------------------------------------------------------ */



        function $(id)
        {
                return document.getElementById(id);
        }

        function $$(id)
        {
                return window.top.document.getElementById(id);
        }

        function _(str)
	{
		alert(str);
	}
					
					
        function getChild(tag, id)
        {
                if (tag)
		{
                        return elems = !id ? document.getElementsByTagName(tag) : $(id).getElementsByTagName(tag);
		}else{
		        return false;
		}
        }


//	searchId	- то что ищим
//	cnt		- просматривать количество уровней вверх
	function searchParent(t, searchId, cnt)
	{
		var p = t;
		var id = false;

		while (cnt)
		{
			if (p.parentNode)
			{
				p = p.parentNode;

				if (p.id && p.id == searchId)
				{
					id = p.id;
					break;
				}
			}else{
				break;
			}

			cnt--;
		}

		return id;
	}



//	определяем наличие в массиве  arr значения val
//	одномерный массив
        function index_of(arr, val)
        {
		for (i=0; i<arr.length; i++)
                {
		        if (arr[i] == val)
			{
		                return val;
			}
		}

                return false;
        }

//	получаем цифровую составляющую из строки
	function parseNum(str)
	{
                return str.replace(/\D+/g, '', str);
	}



//	получаем параметры из url или строки
	function parseUrl(part, param, level, str)
	{
                var result = '';
                var url = level == 'top' ? window.top.location : (str ? str : window.location);

                switch (part)
                {
                        case 'get':
                                var srch = url.search.replace('?', '');
                                srch = srch.split("&");

                                for (i in srch)
                                {
                                        if (srch[i].replace(param+'=', '').length != srch[i].length)
                                        {
                                                result = srch[i].replace(param+'=', '');
                                        }
                                }
    				break;
	
	                case 'hash':
			        result = url.hash == param ? 1 : 0;
			        break;
                }

                return result;
        }

//	изменение высоты фрейма (iframe) - родителя, в зависимомти от контента содержащегося в нем (src)
	function autoIframeParent(frameId)
	{
	        try
		{
			if ($$(frameId))
			{
		        	frame			= $$(frameId);
				innerDoc		= (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
	            		objToResize		= (frame.style) ? frame.style : frame;
				frame.style.height	= innerDoc.body.scrollHeight < 500 ? 500 : innerDoc.body.scrollHeight + 10;
				frame.style.height 	= objToResize.height+'px';
			}

		}catch(err){
                	window.status = err.message;
		}
	}

/* ------------------------------------------------------------------------------------------------------ */


        function Class()
        {
                var obj = this;

// ---------------------------------------------------------------------------------------------------------

//		очистить плейлист

		this.clearPlaylist = function()
		{
			if ($('clear_pl'))
			{
				$('clear_pl').onclick = function()
				{
					this.parentNode.submit();
				}
			}
		}


//		удалить из плейлиста 1 ролик

		this.delFromPlaylist = function()
		{
			if($('playlist'))
			{
				var elems = getChild('li', 'playlist');

				if (elems)
				{

					for(var i=0; i<elems.length; i++)
					{
						elems[i].onmouseover = function()
						{
							for (var ii=0; ii<elems.length; ii++)
							{
								var del	= elems[ii].getElementsByTagName('form')[0];
								if(del)
								{
									del.className	= 'unvis';
								}
							}

							del		= this.getElementsByTagName('form')[0];
							if(del)
							{
								del.className	= '';
							}
						}
					}
				}

				if ($('list_playlist'))
				{
					$('list_playlist').onmouseover = function()
					{
						for (var i=0; i<elems.length; i++)
						{
							var del	= elems[i].getElementsByTagName('form')[0];
							if(del)
							{
								del.className	= 'unvis';
							}
						}
					}
				}

				elemsA = getChild('a', 'playlist');

				if (elemsA)
				{
					for(var i=0; i<elemsA.length; i++)
					{
						elemsA[i].onclick = function()
						{
							var parent = this.parentNode;

							if(parent.tagName.toLowerCase() == 'form')
							{
								parent.submit();
							}
						}
					}
				}
			}
		}


//		добавление в плейлист

		this.addPlaylist = function()
		{
			if($('ifr_do') && $('list_playlist'))
			{

				var elems = getChild('a', 'list_playlist');

				if(elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							var parent			= this.parentNode;
							var li				= parent.parentNode;

							if(parent.tagName.toLowerCase() == 'form' && li.id)
							{
								this.style.display	= 'none';
								parent.submit();

								var images		= getChild('img', li.id);
								var image		= images[1];

								var texts		= getChild('span', li.id);
								var t			= texts[0].innerHTML;
								var u			= texts[1].innerHTML;

								var inp			= getChild('input', li.id);
								var id			= inp[0].value;
								var s			= inp[1].value;

								if($('info'))
								{
									$('info').className	= 'unvis';
									$('playlist').className	= 'list';
								}

								var newClipToPlaylist	= '<li><a href="/clip.php?clip='+id+'" class="v_img" target="_top"><img src="'+image.src+'">'+t+'<span>@ '+u+'</span></a><form method="post" action="playlist.php?clip='+id+'&kind=delete"" class="unvis"><input type="hidden" name="id" value="'+id+'"><input type="hidden" name="secure" value="'+s+'"><a href="#">удалить из плейлиста</a></form></li>';
								$('playlist').innerHTML	= newClipToPlaylist+$('playlist').innerHTML;

								if($('view_pl'))
								{
									$('view_pl').href = '/clip.php?clip='+id+'&pl=1';
								}
								parent.innerHTML	= 'в плейлисте';
							}
						}
					}
				}
			}
		}


//		изменение размера вывода фотки при наведении на нее в блоге
		this.chgImgSizeBlog = function()
		{
			if($('list_blog'))
			{
				var elems = getChild('img', 'list_blog');

				if (elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onmouseover = function()
						{
							var parent = this.parentNode.parentNode;

							parent.style.width	= this.style.width =	'125px';
							parent.style.height	= this.style.height =	'80px';
						}

						elems[i].onmouseout = function()
						{
							var parent = this.parentNode.parentNode;

							parent.style.width	= this.style.width =	'75px';
							parent.style.height	= this.style.height =	'52px';
						}
					}
				}
			}
		}

//		удаление ролика пользователем
		this.delClips = function()
		{
			if($('full_list'))
			{
				var elems = getChild('a', 'full_list');

				if(elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							var parent = this.parentNode;
							if(parent.tagName.toLowerCase() == 'form')
							{
								if(confirm('Вы уверены, что хотите удалить это видео?'))
								{
									parent.submit();
								}else{
									return false;
								}
							}
						}
					}
				}
			}
		}


//		изменение pr_block всвязи с кликом на дату
		this.chgDate = function()
		{

			if ($$('pr_block'))
			{
				var elems = getChild('a', 'blocks');

				if (elems)
				{
					var parent	= elems[0].parentNode;
					var img		= parent.getElementsByTagName('span');

					var pr_href	= $$('pr_block').getElementsByTagName('a');
					var pr_imgs	= $$('pr_block').getElementsByTagName('img');
					var pr_title	= $$('pr_block').getElementsByTagName('span');

					if (pr_href)
					{
						pr_href[0].href		= elems[0].href;
					}

					if (pr_imgs && img)
					{
						pr_imgs[1].src		= img[1].innerHTML;
					}

					if (pr_title)
					{
						pr_title[0].innerHTML		= elems[0].innerHTML;
					}
				}
			}
		}


//		изменение контента в рейтинге по комментариям при наведение на видео
		this.chgVideo = function()
		{
			var elems = getChild('li', 'rate');

			for(var i=1; i<elems.length; i++)
			{
				elems[i].onmouseover = function()
				{
					var v = getChild('a', this.id);
					var p1 = v[0].href;

					var v = getChild('img', this.id);
					var p2 = v[0].src;

					var v = getChild('span', this.id);
					if(v[0]) var p3			= v[0].innerHTML;
					if(v[1]) var p4			= v[1].innerHTML;
					if(v[2]) var p5			= v[2].innerHTML;
					if(v[3]) var p6			= v[3].innerHTML;
					if(v[4]) var p7			= v[4].innerHTML;
					if(v[5]) var p8			= v[5].innerHTML;

					if ($('p1')) $('p1').href	= p1;
					if ($('p2')) $('p2').src	= p2;
					if ($('p3')) $('p3').innerHTML	= p3;
					if ($('p4')) $('p4').innerHTML	= p4;
					if ($('p5')) $('p5').innerHTML	= p5;
					if ($('p6')) $('p6').innerHTML	= p6;
					if ($('p7')) $('p7').innerHTML	= p7;
					if ($('p8')) $('p8').innerHTML	= p8;
				}
			}
		}


//		выпадение последней новости на первой странице
		this.fall = function()
		{
			if($('p1'))
			{
				if ($$('pr_block'))
				{
					var pr_img	= $$('pr_block').getElementsByTagName('img');
					var pr_title	= $$('pr_block').getElementsByTagName('span');
					var li		= getChild('li', 'p1');
					if (li)
					{
						var img	= li[0].getElementsByTagName('img');
						var t	= li[0].getElementsByTagName('a');

						if(img && img[0].src != pr_img[1].src)
						{
							pr_img[1].src		= img[0].src;
							pr_title[0].innerHTML	= t[1].innerHTML;
						}
					}
				}

				if (fall_start)
				{
					clearInterval(fall_start);
					fall_start = null;
				}
				setTimeout("fall_start = setInterval(\"fall_do('p1', \"+fall_step+\")\", fall_time);", 2000);
			}
		}



//		последние 7 дней

		this.week = function()
		{
			if ($('week'))
			{
				var elems = getChild('a', 'week');

				if (elems)
				{
					for (var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							for(var ii=0; ii<elems.length; ii++)
							{
								elems[ii].className = '';
							}
							this.className = 'sel';
						}
					}
				}
			}
		}();


//		callendar & more

                this.animCal = function()
		{
			if ($$('bg_white') && $$('callendar') && $('clips_title'))
			{
				$('clips_title').onclick = function()
				{
					window.top.location.href	= 'http://www.times.ru/playlist.php';

/*
//					window.top.location.href	= 'http://www.times.ru/category.php?kind=lastClips&new=2';

					$$('callendar').style.position	= 'absolute';
					$$('callendar').style.zIndex	= 100;

					if (!window.top.cal_event)
					{
						$('clips_title').style.display		= 'none';

						$$('bg_white').className		= '';

						window.top.cal_start = setInterval("anim_cal_over()", window.top.cal_time);

						obj.upCalImg(0);
					}
*/				}
			}
		}


                this.animCal2 = function()
		{
			if ($('bg_white') && $('callendar') && ifr_c1.$('clips_title') && $('callendar_description') && $('all_video'))
			{
				$('all_video').onclick = function()
				{
					$('callendar').style.position	= 'absolute';
					$('callendar').style.zIndex	= 100;
				
					if (!window.top.cal_event)
					{
						ifr_c1.$('clips_title').style.display	= 'none';

						$('bg_white').className			= '';

						window.top.cal_start = setInterval("anim_cal_over2()", window.cal_time);

						obj.upCalImg(1);
					}

					return false;
				}
			}
		}


                this.animMore = function()
		{
			if ($$('more'))
			{
				var elems = imgs;

				if (elems)
				{
					for (var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							if (!window.top.more_event)
							{
								$$('more').style.width 		= more_w_max+'px';
								$$('more').style.marginLeft	= 0+'px';
								$$('callendar').className	= 'unvis';
								$$('col1').className		= 'unvis';
								$$('col2').className		= 'unvis';

								for (var ii=0; ii<elems.length; ii++)
								{
									$(elems[ii].id).more_w		= more_w;
									more_start[elems[ii].id]	= setInterval("anim_more_over('"+elems[ii].id+"')", more_time);
								}
								return false;
							}else{
								window.top.location.href = this.parentNode.parentNode.href;
							}
						}
					}
				}
			}
		}


                this.animMore2 = function()
		{
			if ($('more'))
			{
				var elems = ifr_c3.imgs;

				if (elems && $('actions'))
				{
					$('actions').onclick = function()
					{
						if (!window.more_event)
						{
							$('more').style.width 		= more_w_max+'px';
							$('more').style.marginLeft	= 0+'px';
							$('callendar').className	= 'unvis';
							$('col1').className		= 'unvis';
							$('col2').className		= 'unvis';
							for (var ii=0; ii<elems.length; ii++)
							{
								ifr_c3.$(elems[ii].id).more_w	= more_w;
								more_start[elems[ii].id]	= setInterval("anim_more_over('"+elems[ii].id+"', 1)", ifr_c3.more_time);
							}
							return false;
						}else{
							window.location.href = this.parentNode.parentNode.href;
						}
					}
				}
			}
		}


                this.closeAnim1 = function()
		{
			var body = window.top.document.getElementsByTagName('body')[0];

                        body.onmouseover = function()
                        {
                                if ($$('ifr_c1') && $('clips_title') && $('clips_title').style.display == 'block')
                                {
                                        $('clips_title').style.display = 'none';
                                }
                        }

			if ($('cal_close'))
			{
				$('cal_close').onclick = function()
				{
					if (window.top.cal_event)
					{
						window.top.cal_event	= null;

						window.top.start = setInterval("anim_cal_out()", cal_time);
					}
				}
			}

		}


                this.upCalImg = function(lvl)
		{
			var elems = !lvl ? imgs : ifr_c1.imgs;

			if(elems)
			{
				for (var i=0; i<elems.length; i++)
				{
					if(!img_event[elems[i].id])
					{
						if (!lvl)
						{
							elems[i].img_w			= img_w;
							elems[i].img_h			= img_h;
							img_start[elems[i].id]		= setInterval("anim_img_over('"+elems[i].id+"')", img_time);;
							img_event[elems[i].id]		= 1;
						}else{
							ifr_c1.elems[i].img_w		= img_w
							ifr_c1.elems[i].img_h		= img_h
							ifr_c1.img_start[elems[i].id]	= setInterval("anim_img_over('"+elems[i].id+"', 1)", img_time);;
							ifr_c1.img_event[elems[i].id]	= 1;
						}
					}
				}
			}
		}


		this.closeMore = function()
		{
			if ($('more_close') && $$('more'))
			{
				$('more_close').onclick = function()
				{
					if (window.top.more_event)
					{
						window.top.more_event				= null;

						$$('more').style.height			= '135px';

						if ($$('col3'))
						{
							$$('col3').style.display		= 'block';
						}

						if ($$('pr_block'))
						{
							$$('pr_block').style.display	= 'block';
						}

						obj.downMoreImg();
					}
				}
			}
		}

		this.downMoreImg = function()
		{
			if(imgs)
			{
				var elems = imgs;

				$('clips').className	= '';

				for (var i=0; i<elems.length; i++)
				{
					if (elems[i].id)
					{
						more_start[elems[i].id]	= setInterval("anim_more_out('"+elems[i].id+"')", more_time);
					}
				}

				$('more_title').style.display	= 'none';

				return false;
			}
		}

//**********************************************************************************************************************************
//		страницы pager

		this.animNext = function(f, s, p, cnt, id)
		{

			var elems = getChild('span', id);

			for (var i = 0; i < elems.length; i++)
			{
				elems[i].onclick = function()
				{
					for(var ii = 0; ii < elems.length; ii++)
					{
						elems[ii].className = '';
					}

					var page 		= parseNum(this.id);
					this.className		= 'sel';
					$('p'+p).className	= 'unvis';

					p			= page;
					$('p'+p).className	= '';

					if (page == cnt)
					{
						$(f).style.color = 'aaa';
						$(s).style.color = '';
					}else{
						$(f).style.color = '';
					}

					if (page == 1)
					{
						$(f).style.color = '';
						$(s).style.color = 'aaa';
					}else{
						$(s).style.color = '';
					}
				}
			}

			$(f).onclick = function()
			{
				if(p < cnt && $('p'+p))
				{
					if (elems)
					{
						for(var i = 0; i < elems.length; i++)
						{
							elems[i].className = '';
						}
					}

					$('p'+p).className		= 'unvis';

					p = p*1 + 1;

					$(s).style.color		= '';

					if (p == cnt)
					{
						$(f).style.color	= '#aaa';
					}

					if ($('p'+p) && $('pp'+p))
					{
						$('p'+p).className	= '';
						$('pp'+p).className	= 'sel';
					}
				}

				return false;
			}

			$(s).onclick = function()
			{
				if(p > 1 && $('p'+p))
				{
					if (elems)
					{
						for(var i = 0; i < elems.length; i++)
						{
							elems[i].className = '';
						}
					}

					$('p'+p).className		= 'unvis';

					p = p*1 - 1;

					$(f).style.color		= '';

					if (p == 1)
					{
						$(s).style.color	= '#aaa';
					}

					if ($('p'+p) && $('pp'+p))
					{
						$('p'+p).className	= '';
						$('pp'+p).className	= 'sel';
					}
				}

				return false;
			}
		}


// ---------------------------------------------------------------------------------------------------------

//		при наведении на каллендарь появляется полупрозрачное окно с кнопкой
        	this.calTitle = function()
		{
		        if ($('clips') && $('clips_title'))
		        {
		                $('clips').onmouseover = function()
		                {
		                        if ($$('callendar') && $$('callendar').style.position != 'absolute')
					{
					        $('clips_title').style.display = 'block';
					}
				}
			}
		}


//		анимация заголовка новости на первой стр
		this.overTitle = function()
		{
			var elems =  getChild('a');
			
                        if (elems.length)
                        {
				for(var i=0; i<elems.length; i++)
				{
					if (elems[i].className == 'v_title')
					{
						elems[i].onmouseover = function()
						{
							arr_pos = arr_pos_min;
						
							if (href_event && href_event != this.id)
							{
								for(var ii=0; ii<elems.length; ii++)
								{
									if (elems[ii].className == 'v_title')
									{
										anim_title_drop(elems[ii].id);
									}
								}
							}
							
							href_event = this.id;

							if (start)
							{
								clearInterval(start);
								start = null;
							}

							this.style.backgroundPosition = '-5% 50%';

							start = setInterval("title_href('"+this.id+"')", 1);
						}


						elems[i].onmouseout = function()
						{
							if (this.className == 'v_title')
							{
								if (start)
								{
									clearInterval(start);
									start = null;
								}
								start = setInterval("title_href_out('"+this.id+"')", 1);
							}
						}
					}
				}
			}
		}

//		анимация ссылки
                this.overHref = function()
                {
			var elems =  getChild('a');

                        if (elems.length)
                        {
				for(var i=0; i<elems.length; i++)
				{
					elems[i].onmouseover = function()
					{
						if (this.className == 'anim')
						{
							if (href_event && href_event != this.id)
							{
								for(var ii=0; ii<elems.length; ii++)
								{
									if (elems[ii].className == 'anim')
									{
										anim_href_drop(elems[ii].id);
									}
								}
							}
							
							href_event = this.id;
						
							if (start)
							{
								clearInterval(start);
								start = null;
							}

							this.style.backgroundPosition = '100% 50%';

							start = setInterval("anim_href('"+this.id+"')", 1);
						}
					}

					elems[i].onmouseout = function()
					{
						if (this.className == 'anim')
						{
							if (start)
							{
								clearInterval(start);
								start = null;
							}
							start = setInterval("anim_href_out('"+this.id+"')", 1);
						}
					}
				}
			}
		}


//		анмация ссылки 2
		this.animHref = function()
		{
			var elems = getChild('a');

			if (elems.length)
			{
				for (var i=0;i<elems.length;i++)
				{
					if (elems[i].id && elems[i].className=='anim')
					{
						elems[i].onmouseover = function()
						{
//							_(cnt+' '+c);
							if (count == c)
							{
								if (start)
								{
									clearInterval(start);
									start = null;
								}

								start = setInterval("funcOver('"+this.id+"')", 1);
							}
						}

						elems[i].onmouseout = function()
						{
							if (start)
							{
								clearInterval(start);
								start = null;
							}

							start = setInterval("funcOut('"+this.id+"')", 1);
						}
					}
				}
			}
		}


//		запуск ролика на первой стр. для IE
		this.prPlay = function()
		{
			$('pr_play').onclick = function()
			{
				window.location.href	= this.parentNode.parentNode.href;
			}
		}


//		все что ниже относится только к пользователю, регистрации и т.п.
		this.signin = function()
		{
			if($('signin') && $('frm_pass'))
			{
				$('signin').onclick = function()
				{
					$('frm_pass').submit();
				}
			}
		}


		this.signout = function()
		{
			if($('signout') && $('frm_signout'))
			{
				$('signout').onclick = function()
				{
					$('frm_signout').submit();
				}
			}
		}

		this.reg = function()
		{
			if($('registration') && $('frm_reg'))
			{
				$('registration').onclick = function()
				{
					if ($('pass1') && $('pass2') && $('pass1').value == $('pass2').value)
					{
						$('frm_reg').submit();
					}else{
						_('Пароли не совпадают, введите их заново!');
						$('pass1').value = $('pass2').value = '';
					}
				}
			}
		}
		
		this.pass_forgot = function()
		{
			if($('forgot_pass') && $('frm_pass') && $('frm_repair_pass') && $('repair_cancel') && $('repair'))
			{
				$('forgot_pass').onclick = function()
				{
					$('frm_pass').className		= 'unvis';
					$('frm_repair_pass').className	= '';
				}

				$('repair_cancel').onclick = function()
				{
					$('frm_pass').className		= '';
					$('frm_repair_pass').className	= 'unvis';
				}

				$('repair').onclick = function()
				{
					$('frm_repair_pass').submit();
				}
			}
		}

		this.email_send = function()
		{
			if($('mail_from') && $('mail_to') && $('mail_captcha') && $('mail_send') && $('send_email') && $('mail_cancel'))
			{
				$('mail_from').onfocus = $('mail_from').onclick = function()
				{
					if($('mail_from').value == 'От кого (имя, ник)')
					{
						$('mail_from').value	= '';
					}
				}

				$('mail_to').onfocus = $('mail_to').onclick = function()
				{
					if($('mail_to').value == 'На какой E-mail')
					{
						$('mail_to').value	= '';
					}
				}

				$('mail_captcha').onfocus = $('mail_captcha').onclick = function()
				{
					if($('mail_captcha').value == 'Код подтверждения')
					{
						$('mail_captcha').value	= '';
					}
				}

				$('mail_send').onclick = function()
				{
					$('send_email').submit();
					return false;
				}

				$('mail_cancel').onclick = function()
				{
					$('mail_from').value	= 'От кого (имя, ник)';
					$('mail_to').value	= 'На какой E-mail';
					$('mail_captcha').value	= 'Код подтверждения';
					return false;
				}
			}
		}();

		this.email_form_open = function()
		{
			if($('send_email') && $('c14') && $('mail_cancel'))
			{
				$('c14').onclick = function()
				{
					$('send_email').style.display		=  '';

					if (start_mail)
					{
						clearInterval(start_mail);
						start_mail = null;
					}

					start_mail = setInterval("anim_mail_over('send_email')", 20);
					return false;
				}

				$('mail_cancel').onclick = function()
				{
					if (start_mail)
					{
						clearInterval(start_mail);
						start_mail = null;
					}

					start_mail = setInterval("anim_mail_out('send_email')", 20);

					return false;
				}
			}

		}();


		this.history_clear = function()
		{
			if($('history_clear') && ifr_c2.$('frm_history_clear'))
			{
				$('history_clear').onclick = function()
				{
					$('clip_func').style.display = 'none';
					ifr_c2.$('frm_history_clear').submit();
					return false;
				}
			}
		}


		this.playlist_clear = function()
		{
			if ($('playlist_clear') && ifr_c2.$('frm_pl'))
			{
				$('playlist_clear').onclick = function()
				{	
					$('clip_func').style.display = 'none';
					ifr_c2.$('frm_pl').submit();
					return false;
				}
			}
		}

		this.playlist = function()
		{
			if ($('frm_pl'))
			{
				var block		= $('blocks') ? $('blocks') : ($('frm_pl') ? $('frm_pl') : '');
				var kind		= $('blocks') ? 'add' : ($('frm_pl') ? 'delete' : '');
				var alert_string	= kind == 'add' ? 'добавлено в плейлист' : 'удалено из плейлиста';

				if (block && kind)
				{
					var elems = getChild('img', block.id);
					
					if(elems.length)
					{
						for(var i=0; i<elems.length; i++)
						{
							elems[i].onclick = function()
							{
								var parent = this.parentNode;
							
								if (parent.className == 'pl')
								{
									var id = parseNum(this.id);

									if (id)
									{
										parent.style.display	= 'none';
										$('frm_pl').action	= '/playlist.php?clip='+id+'&kind='+kind+'&simple=1';
										$('frm_pl').submit();
									}
									_('Видео '+alert_string);
									return false;
								}
							}
						}
					}
					else if ($('f4'))
					{
						var elem = getChild('img', 'f4');
				
						el = elem[0];

						el.onclick = function()
						{
							var id = parseNum(this.id);
					
				    			if (id)
							{
								$('f4').style.display	= 'none';
								$('frm_pl').action	= '/playlist.php?clip='+id+'&kind=add&simple=1';
								$('frm_pl').submit();
								_('Видео добавлено в плейлист');
								return false;
							}
						}
					}
				}
			}
		}
		
		this.chgProfile = function()
		{

			if($('chg') && $('frm_chg'))
			{
				$('chg').onclick = function()
				{
					$('frm_chg').submit();
				}
			}

			if($('del') && $('frm_del'))
			{
				$('del').onclick = function()
				{
					$('frm_del').submit();
				}
			}

			if($('reg') && $('frm_reg'))
			{
				$('reg').onclick = function()
				{
					$('frm_reg').submit();
				}
			}

		}

		this.clip_add = function()
		{
			if($('clip_add') && $('frm_clip_add'))
			{
                                $('clip_add').onclick = function()
				{
				        $('frm_clip_add').submit();
				}
			}
		}

		this.clip_description = function()
		{
			if($('clip_del') && $('frm_clip_del'))
			{
				$('clip_del').onclick = function()
				{
					$('frm_clip_del').submit();
				}
			}

			if($('clip_add') && $('frm_clip_add'))
			{
				$('clip_add').onclick = function()
				{
					$('frm_clip_add').submit();
				}
			}
		}
		
		this.blog_save = function()
		{
			if($('blog_save') && $('frm_blog_save'))
			{
				$('blog_save').onclick = function()
				{
					$('frm_blog_save').submit();
				}
			}
		}
		
		this.fullscreen = function(clipUrl, clipImgUrl)
		{
			if($('f1_div') && $('f2_div') && $('f3_div') && $('f1') && $('f2') && $('f3') && $('f1_close') && $('f2_close') && $('f3_close') && $('clip_fullscreen') && ($('clip_place_fullscreen') || $('clipPlace'))&& $('bg_white'))
			{

				$('f1').onclick = function()
				{
					$('f1_div').className	= '';
					$('bg_white').className	= '';
					$('f2_div').className	= 'unvis';
					$('f3_div').className	= 'unvis';
                                        $('anim').style.opacity	= 0.1;
                                        $('anim').style.filter	= 'alpha(opacity=10)';
					func_event		= 1;

					return false;
				}

				$('f3').onclick = function()
				{
					$('f3_div').className	= '';
					$('bg_white').className	= '';
					$('f1_div').className 	= 'unvis';
					$('f2_div').className 	= 'unvis';
                                        $('anim').style.opacity	= 0.1;
                                        $('anim').style.filter	= 'alpha(opacity=10)';
					func_event		= 1;
					return false;
				}

				$('f2').onclick = function()
				{
					$('clip').innerHTML	= '<div id="clipPlace"></div>';
					$('f2_div').className	= '';
					$('bg_white').className	= '';
					$('f1_div').className 	= 'unvis';
					$('f3_div').className 	= 'unvis';
                                        $('anim').style.opacity	= 0.1;
                                        $('anim').style.filter	= 'alpha(opacity=10)';
					func_event		= 1;

					createPlayer ('single', 800, 600, clipUrl, clipImgUrl, '/img/skin.swf', true, false, false, 'uniform', 'clip_place_fullscreen');

					return false;
				}

				$('f1_close').onclick = $('f3_close').onclick = $('f2_close').onclick = document.onkeydown = function(event)
				{
                    			var e = event || window.event;

			                code = e.keyCode ? e.keyCode : e.charCode;

		                        if ((!$('f1_div').className || !$('f2_div').className || !$('f3_div').className) && (code == 27 || !code))
		                        {
						$('clip_fullscreen').innerHTML	= '<div id="clip_place_fullscreen"></div>';
						$('f1_div').className	= 'unvis';
						$('f2_div').className	= 'unvis';
						$('f3_div').className	= 'unvis';
						$('bg_white').className	= 'unvis';
                                    		$('anim').style.opacity	= 1;
                                    		$('anim').style.filter	= 'alpha(opacity=100)';
						func_event		= 0;

						setTimeout("createPlayer ('single', 580, 345, '"+clipUrl+"', '"+clipImgUrl+"', '/img/skin.swf', true, false, false, 'uniform', 'clipPlace')", 1);
		                        }
				}
			}
		}
	}
	


/* ------------------------------------------------------------------------------------------------------ */

//	анимация заголовка новости на первой стр
	title_href = function(id)
	{
		var obj		= $(id);

		if (arr_pos < 0)
		{
			arr_pos 	+= arr_step;
			href_pos	+= href_step;

			obj.style.backgroundPosition	= arr_pos+'% 50%';
			obj.style.paddingLeft		= href_pos+'px';

		}else{
			clearInterval(start);
			start 		= null;
		}
	}


	title_href_out = function(id)
	{
		var obj = $(id);
		
		if (arr_pos <= 0 && arr_pos >= arr_pos_min)
		{
			arr_pos 	-= arr_step;
			href_pos	-= href_step;

			obj.style.backgroundPosition	= '-5% 50%';
			obj.style.paddingLeft		= '0px';

		}else{
			clearInterval(start);
			start		= null;
			href_event	= null;
			arr_pos		= arr_pos_tmp;
			href_pos	= href_pos_tmp;
		}
	}


	anim_title_drop = function(id)
	{
		if(id)
		{
			var elem = $(id);
			
			elem.style.paddingLeft		= '0px';
			elem.style.backgroundPosition	= '-5% 50%';
		}
	}

//      more
//	lvl - определяет из ifr_c3(0) или из window.top(1) пришло событие
        anim_more_over = function(id, lvl)
        {
                var obj		= !lvl ? $(id) : ifr_c3.$(id);
		var pObj	= obj.parentNode;
		var ppObj	= pObj.parentNode;

		if ($$('col3') && $$('col3').style.display != 'none')
		{
			if ($$('col3'))
			{
				$$('col3').style.display	= 'none';
			}
			if ($$('pr_block'))
			{
				$$('pr_block').style.display	= 'none';
			}
		}

                if (obj.more_w < more_w_div_max)
                {
                        obj.more_w		+= more_w_step;
			pObj.style.width	= ppObj.style.width	= obj.more_w+'px';

                }else{
                        clearTimeout(more_start[id]);

                        window.top.more_event		= 1;

                        if(!lvl)
                        {
                		more_start[id] 				= null;
                		$('clips').className			= 'div_sel';
                		$('more_title').style.display		= 'block';
				$('next').focus();
                        }else{
                		ifr_c3.more_start[id]			= null;
                		ifr_c3.$('clips').className		= 'div_sel';
                		ifr_c3.$('more_title').style.display	= 'block';
				ifr_c3.$('next').focus();
                        }

			$$('more').style.height		= '650px';

                }
	}

	anim_more_out = function(id)
	{

		var obj		= $(id);
		var pObj	= obj.parentNode;
		var ppObj	= pObj.parentNode;

		if (obj.more_w > more_w)
		{
			obj.more_w				-= more_w_step;
			pObj.style.width = ppObj.style.width	= obj.more_w+'px';
		}else{
			clearTimeout(more_start[id]);
			more_start[id]				= null;

			obj.more_w				= more_w;
			pObj.style.width = ppObj.style.width	= obj.more_w+'px';
			$$('more').style.width			= more_w_min+'px';
			$$('more').style.marginLeft		= more_m+'px';

			$$('col1').className			= '';
			$$('col2').className			= 'top';
			$$('callendar').className		= '';
			window.top.location.hash		= 'top';
		}
	}

//      каллендарь
        anim_img_over = function(id, lvl)
        {
                var obj = !lvl ? $(id) : ifr_c1.$(id);

                if (obj.img_w < img_w_max)
                {

                        obj.img_w			+= img_w_max;
			obj.img_h			+= img_h_max;

                        obj.style.width			= obj.img_w+'px';
                        obj.style.height		= obj.img_h+'px';
                }else{
                        if (!lvl)
                        {
                		clearTimeout(img_start[id]);
                		img_start[id]		= null;
                        }else{
                		clearTimeout(ifr_c1.img_start[id]);
                		ifr_c1.img_start[id]	= null;
                        }

			obj.img_w			= img_w_max;
			obj.img_h			= img_h_max;

                        obj.style.width			= obj.img_w+'px';
                        obj.style.height		= obj.img_h+'px';
		}
	}


        anim_cal_over = function()
        {
		if ($$('callendar') && $('search') && $('clips'))
		{
			$('search').className		= '';
			$$('callendar').style.marginTop	= '-150px';

			var elems = $('clips').getElementsByTagName('a');

			for (var i=0; i<elems.length; i++)
			{
				elems[i].style.height	= '27%';
			}

        		if (window.top.cal_w < cal_w_max)
        		{
                		window.top.cal_w	+= cal_w_step;

				if (window.top.cal_h < cal_h_max)
				{
                			window.top.cal_h	+= cal_h_step;
				}else{
                			window.top.cal_h	= cal_h_max;
				}

                		$$('callendar').style.width	= window.top.cal_w+'px';
                		$$('callendar').style.height	= window.top.cal_h+'px';

        		}else{
                		clearTimeout(window.top.cal_start);
                		window.top.cal_start		= null;
                		window.top.cal_event		= 1;

				$('clips').className		= 'div_sel';
			}
		}
	}


        anim_cal_over2 = function()
        {
		if ($('callendar') && ifr_c1.$('search') && ifr_c1.$('clips'))
		{
			ifr_c1.$('search').className 		= '';
			$('callendar').style.marginTop		= '-150px';

			var elems = ifr_c1.$('clips').getElementsByTagName('a');
		
			for (var i=0; i<elems.length; i++)
			{
				ifr_c1.elems[i].style.height	= '27%';
			}

            		if (window.cal_w < cal_w_max)
            		{
                		window.cal_w			+= cal_w_step;

				if (window.cal_h < cal_h_max)
				{
                			window.cal_h		+= cal_h_step;
				}else{
                			window.cal_h		= cal_h_max;
				}

                		$('callendar').style.width	= window.cal_w+'px';
                		$('callendar').style.height	= window.cal_h+'px';

        		}else{
                    		clearTimeout(window.cal_start);
                    		window.cal_start		= null;
                    		window.cal_event		= 1;

				ifr_c1.$('clips').className	= 'div_sel';
			}
		}
	}


	anim_cal_out = function()
	{
		$$('callendar').style.marginTop		= '0px';
		$('search').className			= 'unvis';

		var elems = $('clips').getElementsByTagName('a');
		
		for (var i=0; i<elems.length; i++)
		{
			elems[i].style.height		= '33%';
		}

		if (window.top.cal_w > cal_w_tmp)
		{
			window.top.cal_w		-= cal_w_step;

			if (window.top.cal_h > cal_h_tmp)
			{
				window.top.cal_h	-= cal_h_step;
			}else{
				window.top.cal_h	= cal_h_tmp;
			}

			$$('callendar').style.width	= window.top.cal_w+'px';
			$$('callendar').style.height	= window.top.cal_h+'px';
		}else{
			clearTimeout(window.top.start);
			window.top.start		= null;
			window.top.cal_w		= cal_w_tmp;
			window.top.cal_h		= cal_h_tmp;
			$$('callendar').style.position	= '';
			$$('callendar').style.zIndex	= 0;
			$$('bg_white').className	= 'unvis';

			if(imgs)
			{
				var elems = imgs;

				for (var i=0; i<elems.length; i++)
				{
					if(img_event[elems[i].id])
					{
						var obj				= $(elems[i].id);

						obj.img_w			= img_w;
						obj.img_h			= img_h;

						obj.style.width			= img_w+'px';
						obj.style.height 		= img_h+'px';

						img_event[elems[i].id]	= 0;

						$('clips').className	= '';
					}
				}
			}
		}
	}



//      почта
        anim_mail_over = function(id)
        {
                var obj = $(id);

                if (mail_h < 200)
                {
			mail_h = mail_h*1+mail_step;
                        obj.style.height		= mail_h+'px';
                }else{
        		clearInterval(start_mail);
        		img_start[id]		= null;
			mail_h			= 215;

                        obj.style.height	= mail_h+'px';
		}
	}

        anim_mail_out = function(id)
        {
                var obj = $(id);

                if (mail_h > mail_h_tmp)
                {
			mail_h = mail_h - mail_step;
                        obj.style.height		= mail_h+'px';
                }else{
        		clearInterval(start_mail);
        		img_start[id]			= null;
			mail_h				= 0;

                        obj.style.height		= obj.style._height = mail_h+'px';
			$('send_email').style.display	= 'none';
		}
	}



//	падение новостей
	function fall_do(id, step)
	{
		var obj		= $(id);

		if (fall_margin < 0)
		{
			fall_margin		+=  fall_step;
			obj.style.marginTop	= fall_margin+'px';
		}else{
			obj.style.marginTop	= '0px';
			clearInterval(fall_start);
			fall_start		= null;

			var elems = getChild('li', id);
			fall_start = setTimeout('elems[0].style.visibility = "visible";', 100);
		}
	}



/* ------------------------------------------------------------------------------------------------------ */
//	анимация ссылки
	funcOver = function(id)
	{
		var obj = $(id);

		if (c > 0)
		{
			padR -= step_href;
			padL += step_href;

			obj.style.paddingRight	= padR+'px';
			obj.style.paddingLeft	= padL+'px';

			if (c > 3)
			{
				padBgR += step_arrow;
				obj.style.backgroundPosition	= padBgR+'% 50%';
			}else{
				padBgL += step_arrow;
				obj.style.backgroundPosition	= padBgL+'px 50%';
			}

			c -= 1;
		}else{
			clearInterval(start);
			start = null;
		}
	}


	funcOut = function(id)
	{
		var obj = $(id);

		if (c < count)
		{
			padR += step_href;
			padL -= step_href;

			obj.style.paddingRight	= padR+'px';
			obj.style.paddingLeft	= padL+'px';

			if (c < 3)
			{
				padBgL -= step_arrow;
				obj.style.backgroundPosition = padBgL+'px 50%';
			}else{
				padBgR -= step_arrow;
				obj.style.backgroundPosition = padBgR+'% 50%';
			}

			c += 1;
		}else{
			clearInterval(start);
			start = null;
			obj.style.backgroundPosition = '100% 50%';
		}
	}
