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

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

//      блок more
        var more_w			= 27;			// должно соответствовать width видимой части блока "a href" в more.css
        var more_m			= 833;			// должно соответствовать margin для #more в index.css 
	var more_w_min			= 133;			// должно соответствовать 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.openTags = function()
		{
			if($('open_tags') && $('list_tags_c1') && $('close_tags'))
			{
				$('open_tags').onclick = function()
				{
					$('open_tags').className	= 'unvis';
					$('list_tags_c1').className	= '';
					return false;
				}

				$('close_tags').onclick = function()
				{
					$('open_tags').className	= '';
					$('list_tags_c1').className	= 'unvis';
					return false;
				}
			}
		}


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

//		открытие полного описания
		this.upDesc = function()
		{
			if($('open_full_desc') && $('full_desc') && $('span_open_full_desc'))
			{
				$('open_full_desc').onclick = function()
				{
					$('span_open_full_desc').className	= 'unvis';
					$('full_desc').className		= 'descr';
					if($('span_clip_review'))
					{
						$('span_clip_review').className	= 'unvis';
					}
				}
			}
		}

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

//		изменение заголовка во второй колонке при нажатии на тэг или дату в календаре или пользователя
/*		this.chgRatingTitle = function()
		{
			if ($('rating_title'))
			{
				var elems	= '';

				if($('list_tags_c1'))
				{
					elems		= getChild('a', 'list_tags_c1');
					if(elems)
					{
						for(var i=0; i<elems.length; i++)
						{
							elems[i].onclick = function()
							{
								$('rating_title').innerHTML = '<span>tags :: </span> '+this.innerHTML+'<span> - новые ролики</span>';
							}
						}
					}
				}

				if($('week'))
				{
					elems		= getChild('a', 'week');
					if(elems)
					{
						for(var i=0; i<elems.length; i++)
						{
						}
					}
				}
			}


			return false;
		}();
*/
		this.chgRatingTitle = function()
		{
			if($('rating_title') && $('list_tags_c1'))
			{
				var elems	= '';
				elems		= getChild('a', 'list_tags_c1');
				if(elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							$('rating_title').innerHTML = '<span>tags :: </span> '+this.innerHTML+'<span> - новые ролики</span>';
						}
					}
				}
			}
			return false;
		}();


		this.backRatingTitle = function()
		{
			if($('back') && $$('rating_title'))
			{
				$('back').onclick = function()
				{
					$$('rating_title').innerHTML = 'Топ сюжетов <span>times.ru</span>';
				}
			}
		}

//		получение списка пользователей на определенную букву
		this.getUsers = function()
		{
			if($('list_users_c1') && $('alphabet'))
			{
				var elems	= '';
				elems		= getChild('a', 'alphabet');
				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';
							$('list_users_c1').className	= '';
							getContentAjax(this.href, 'get', '', 'list_users_c1', '');
							return false;
						}
					}
				}
			}
			return false;
		}


//		изменение размера картинок в левом ухе

		this.chgSizeImgCal = function()
		{
			if($('callendar'))
			{
				var elems = getChild('a', 'callendar');
				if(elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onmouseover = function()
						{
							for(var ii=0; ii<elems.length; ii++)
							{
								elems[ii].className	= '';
							}
							this.className			= 'sel';
						}
					}
				}
			}
		}


//		передвижение иконок в левой колонке

		this.moveIcons = function(course)
		{
			if($('icons') && $('more_ico') && $('before_ico') && $('first_page_icons') && $('second_page_icons'))
			{
				$('more_ico').onclick = function()
				{
					$('more_ico').className			= 'unvis';
					$('first_page_icons').className		= 'unvis';
					$('before_ico').className		= '';
					$('second_page_icons').className	= '';
					return false;
				}

				$('before_ico').onclick = function()
				{
					$('more_ico').className			= '';
					$('first_page_icons').className		= '';
					$('before_ico').className		= 'unvis';
					$('second_page_icons').className	= 'unvis';
					return false;
				}
			}
		}();


//		открытие/закрытие строки с иконками

		this.iconsOpen = function()
		{
			if($('icons') && $('copy_open') && $('copy_close'))
			{
				$('copy_open').onclick = function()
				{
					$('copy_open').className	= 'unvis';
					$('icons').className		= '';
					$('copy_close').className	= '';
					return false;
				}

				$('copy_close').onclick = function()
				{
					$('copy_open').className	= '';
					$('icons').className		= 'unvis';
					$('copy_close').className	= 'unvis';
					return false;
				}
			}
		}();


//		gallery // галерея

		this.gallery = function()
		{
			if($('gallery') && $('next') && $('prev'))
			{
				var elems = getChild('img', 'gallery');
				var n	= -1;

				if (elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onmouseover = $('next').onmouseover = $('prev').onmouseover = function()
						{
							$('next').className	= '';
							$('prev').className	= '';
						}

						elems[i].onmouseout = function()
						{
							$('next').className	= 'unvis';
							$('prev').className	= 'unvis';
						}
					}

					$('next').onclick = function()
					{

						for(var i=0; i<elems.length; i++)
						{
							if (!elems[i].className)
							{
								n		= i*1+1;
							}

							elems[i].className	= 'unvis';
						}

						if (n == elems.length)
						{
							elems[0].className		= '';
						}else{
							elems[n].className		= '';
						}

						return false;
					}

					$('prev').onclick = function()
					{

						for(var i=0; i<elems.length; i++)
						{
							if (!elems[i].className)
							{
								n		= i-1;
							}

							elems[i].className	= 'unvis';
						}

						if (n < 0)
						{
							elems[elems.length-1].className		= '';
						}else{
							elems[n].className		= '';
						}

						return false;
					}

				}
			}
		}


//		открытие/закрытие рейтинга третий вариант

		this.ratingAnimOver2 = function()
		{
//				var elems	= imgs;
				var arr		= $('more_arr') ? $('more_arr') : '';
				var more	= $$('more') ? $$('more') : '';
				var layer	= $('r_layer') ? $('r_layer') : '';
				var elems		= getChild('a', 'lst');

			if(arr && more)
			{
				more.onmouseover = function()
				{
						more.style.width		= layer.style.width	= '194px';
						more.style.height		= '400px';
						more.style.marginLeft		= '773px';
						arr.className			= 'unvis';
						layer.className			= 'unvis';
						more.style.zIndex		= 10000;
						var elems			= getChild('a', 'lst');
						elems[4].style.width		= '100px';
						$('clips').className		= 'div_sel';
						$('clip_title').className	= '';
				}

				more.onmouseout = function()
				{
						more.style.width		= layer.style.width	= '133px';
						more.style.height		= '140px';
						more.style.marginLeft		= '833px';
						arr.className			= 'more_arr';
						more.style.zIndex		= 1;
						$('clips').className		= '';
						$('clip_title').className	= 'unvis';

						for(var i=0; i<elems.length; i++)
						{
							if(elems[i].className != 'more_arr')
							{
								elems[i].style.width	= '27px';
							}else{
								elems[i].style.width	= '';
							}
						}
				}
			}
		}

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

				if (elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onmouseover = function()
						{
							for(var ii=0; ii<elems.length; ii++)
							{
								if(elems[ii].className != 'more_arr')
								{
									elems[ii].style.width	= '27px';
								}
							}
							this.style.width	= '100px';

							var elem_span	= this.getElementsByTagName('span')[0];

							if(elem_span)
							{
								$('clip_title').getElementsByTagName('span')[0].innerHTML	= elem_span.innerHTML;
							}
						}
					}
				}
			}
		}

		this.ratingAnimOver = function(lvl)
		{
			if (lvl == 1)
			{
				var elems	= imgs;
				var layer	= $('r_layer') ? $('r_layer') : '';
				var button	= $('r_button') ? $('r_button') : '';
				var arr		= $('more_arr') ? $('more_arr') : '';
				var m		= $$('more') ? $$('more') : '';
				var cln		= $$('callendar') ? $$('callendar') : '';
				var cl1		= $$('col1') ? $$('col1') : '';
				var cl2		= $$('col2') ? $$('col2') : '';
				var slogan	= $$('slogan') ? $$('slogan') : '';
				var more	= $$('more') ? $$('more') : '';

			}else{
				var elems	= ifr_c3.imgs;
				var layer	= ifr_c3.$('r_layer') ? $('r_layer') : '';
				var button	= ifr_c3.$('r_button') ? $('r_button') : '';
				var arr		= ifr_c3.$('more_arr') ? $('more_arr') : '';
				var m		= $('more') ? $('more') : '';
				var cln		= $('callendar') ? $('callendar') : '';
				var cl1		= $('col1') ? $('col1') : '';
				var cl2		= $('col2') ? $('col2') : '';
				var slogan	= $('slogan') ? $('slogan') : '';
				var more	= $('more') ? $('more') : '';
			}

			if(layer && button && arr && m)
			{
				layer.onmouseover = function()
				{
					if (!window.top.more_event)
					{

						m.style.width		= more_w_max+'px';
						m.style.marginLeft	= 0+'px';
						cl2.className		= 'unvis';
						slogan.className	= 'top';

						layer.className		= 'unvis';
						button.className	= 'unvis';
						arr.className		= 'unvis';
						if($$('back'))
						{
							$$('back').className	= 'user_div';
						}

						if($$('back_c'))
						{
							$$('back_c').className	= '';
						}

						for (var i=0; i<elems.length; i++)
						{
							if (elems[i].parentNode.parentNode.id != 'more_arr')
							{
								var ppObj = elems[i].parentNode.parentNode;
								if(ppObj.tagName.toLowerCase() == 'a')
								{
									if (ppObj.className == 'unvis')
									{
										elems[i].parentNode.parentNode.className	= 'hide';
									}
									$(elems[i].id).more_w	= more_w;
									more_start[elems[i].id]	= setInterval("anim_more_over('"+elems[i].id+"')", more_time);
								}
							}
						}
					}
					return false;
				}
			}
		}


		this.ratingAnimClose = function()
		{
			if ($('r_layer') && $('r_button') && $('more_arr') && $('back') && $$('more'))
			{
				$('back').onclick = function()
				{
					if (window.top.more_event)
					{
						window.top.more_event			= null;

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

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

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

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

						obj.downMoreImg();

						return false;
					}
				}
			}
		}


		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';

				if($('r_layer') && $('r_button') && $('more_arr') && $('more_arr').className == 'unvis')
				{
					$('more_arr').className	= 'more_arr';
					$('r_layer').className	= '';
					$('r_button').className	= 'unvis';
				}

//				obj.chgHrefCalendar();
				return false;
			}
		}



//		открыть/закрыть информацию о ролике

		this.clipInfoFull = function()
		{
			if ($('clip_info_full'))
			{
				$('clip_info_full').onclick = function()
				{
					var elems = getChild('b', 'rating_title');

					if (elems)
					{
						for(var i=0; i<elems.length; i++)
						{
							var p = elems[i].parentNode;
							if (p.tagName.toLowerCase() == 'div')
							{
								p.className = clip_full_info == 1 ? 'unvis' : '';
							}
						}
						clip_full_info = clip_full_info == 1 ? 0 : 1;
					}

					if($('clip_func_comments'))
					{
						$('clip_func_comments').className = $('clip_func_comments').className == 'unvis' ? '' : 'unvis';
					}

					return false;
				}
			}
		}



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

		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('button', 'list_playlist');

				if(elems)
				{
					for(var i=0; i<elems.length; i++)
					{
						elems[i].onclick = function()
						{
							$('list_playlist').className	= 'fill';
							$('clear_pl_form').className	= '';
							var parent			= this.parentNode;
							var li				= parent.parentNode;

							if(parent.tagName.toLowerCase() == 'form' && li.id)
							{

								parent.submit();

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

								var text		= getChild('span', li.id);
								var t			= text[0].innerHTML;
								var user_name		= getChild('i', li.id);
								var u			= user_name[0].innerHTML;

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

//								var add_b		= getChild('b', li.id);
//								var b			= add_b[0];

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

//								var newClipToPlaylist	= '<li><a href="'+a+'" 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>';
								var newClipToPlaylist	= '<li><a href="'+a+'" class="v_img" target="_top"><img src="'+image.src+'"></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 = a+'&pl=1';
								}

//								b.innerHTML		= '<b>в плейлисте</b>';
								parent.innerHTML		= '<b>в плейлисте</b>';
							}
							return false;
						}
					}
				}
			}
		}

//		запуск плейлиста

		this.startPlaylist = function()
		{
			if($('view_pl'))
			{
				$('view_pl').onclick = function()
				{
					if($('view_pl').href == window.location.href+'#' || $('view_pl').href == window.location.href)
					{
						_('Ваш плейлис пуст.\nЧтобы добавить видео в плейлист нажмите кнопку рядом с видео: + добавить в плейлист');
					}
				}
			}
		}


//		удаление ролика пользователем
		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') && $('p1'))
			{
				var elems = getChild('li', 'p1');

				if (elems)
				{
					var elem	= elems[0];
					var img		= elem.getElementsByTagName('img')[0].src;
					var href	= elem.getElementsByTagName('a')[1].href;
					var title	= elem.getElementsByTagName('a')[1].innerHTML;

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

					if (pr_href)
					{
						for(var i=0; i<pr_href.length; i++)
						{
							pr_href[i].href	= href;
						}
					}

					if (pr_imgs && img)
					{
						pr_imgs.src		= img;
					}

					if (pr_title)
					{
						pr_title.innerHTML	= title;
					}

					if ($$('col2').className == 'unvis')
					{
						$$('col2').className			= 'top';
						$$('more').style.width			= more_w_min+'px';
						$$('more').style.marginLeft		= more_m+'px';
						var obj_ifr				= window.top.ifr_c3;
						obj_ifr.location.href			= '/rating.php?simple=11&sort=view&period=60';

						if (window.top.more_event)
						{
							window.top.more_event		= null;
						}
					}


				}
			}
		}


//		изменение контента в рейтинге по комментариям при наведение на видео
		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';

							$('rating_title').innerHTML = this.innerHTML+'<span> - новые ролики</span>';
						}
					}
				}
			}
		}();


//**********************************************************************************************************************************
//		страницы 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') && $('icons'))
			{
				$('c14').onclick = function()
				{
					$('send_email').style.display		=  '';

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

					$('icons').className = '';
					start_mail = setInterval("anim_mail_over('send_email')", 20);

					return false;
				}

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

					$('icons').className == 'unvis';

					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;
			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';
				$('more_head').style.paddingTop		= '5px';
                        }else{
                		ifr_c3.more_start[id]			= null;
                		ifr_c3.$('clips').className		= 'div_sel';
//                		ifr_c3.$('more_title').style.display	= 'block';
				ifr_c3.$('more_head').style.paddingTop	= '5px';
                        }

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

                }
	}

	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;
			if (ppObj.id != 'more_arr')
			{
				ppObj.style.width	= obj.more_w+'px';
			}
		}else{

			clearTimeout(more_start[id]);
			more_start[id]				= null;

			obj.more_w				= more_w;
			if (ppObj.id != 'more_arr')
			{
				ppObj.style.width		= obj.more_w+'px';
			}

			if(ppObj.className == 'hide')
			{
				ppObj.className 		= 'unvis';
			}

			$$('more').style.width			= more_w_min+'px';
			$$('more').style.marginLeft		= more_m+'px';

			$$('slogan').className			= '';
			$$('col1').className			= '';
			$$('col2').className			= 'top';
			$$('callendar').className		= '';
//			$$('move_c1_menu').className		= 'unvis';
//			$$('more').style.height			= '210px';
			$('more_head').style.paddingTop		= '0px';
		}
	}


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

                if (mail_h < 220)
                {
			mail_h = mail_h*1+mail_step;
                        obj.style.height		= mail_h+'px';
                }else{
        		clearInterval(start_mail);
        		start_mail		= null;
			mail_h			= 235;

                        obj.style.height	= mail_h+'px';
			if ($('icons'))
			{
				$('icons').className = '';
			}
		}
	}

        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);
        		start_mail			= null;
			mail_h				= 0;

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



//	падение новостей
	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%';
		}
	}

