			function fg_vkl(){$("#fg_v").show();}
			function fg_vk(){$("#fg_v").hide();}

			var now_playing;
			video_count =0;

			$(document).ready(function() {
					$("#bt_lastvideo").bind("click", function(){

   	   			 			$(this).removeClass("noact").addClass("act");
   	   			 			$("#bt_myvideo").removeClass("act").addClass("noact");
   	   			 			$("#last_video").show();
   	   			 			$("#my_video").hide();
   				});

   				$("#bt_myvideo").bind("click", function(){
   	   			 			$(this).removeClass("noact").addClass("act");
   	   			 			$("#bt_lastvideo").removeClass("act").addClass("noact");
   	   			 			$("#last_video").hide();
   	   			 			$("#my_video").show();
   				});


   				$(".vTabs").children().bind("click", function(){
					$(".vTabs").children("ins").removeClass("tbact");
				    $(".vTabs").children("ins").addClass("tbnoact");
						$(this).addClass("tbact");
						$(this).removeClass("tbnoact");
						$.ajax({
									type: "GET",
									url: "/video",
									dataType:"json",
									data: 	"catalogId=" + $(this).attr("catalog_id"),
									success: function(data){
										$("#video_list").html(data.html);
										$("#pages").html(data.pages);
										if (data.all == 0) data.all = 1
										$("#page_is").text("Страница " + data.correct+" из "+data.all);
									},
					              	beforeSend: function(){
										$("#video_list").html('<h3><img src="/images/loading.gif">Идет загрузка...</h3>');
					              	},
					              	complete: function()
					              	{
					              		 $("a.lnk-add-f").unbind("click");
										$("a.lnk-add-f").bind("click", addToPlHandler);
										$("a.playThisVideo").unbind("click");
										$("a.playThisVideo").bind("click", playVideoHandler);
										$("#video_list").show();
					              	}
								});
				});


				$("a.lnk-add-f").bind("click", addToPlHandler);
				$("a.playThisVideo").bind("click", playVideoHandler);


			});

			function go_page(rub,page){
				$.ajax({
									type: "GET",
									url: "/video",
									dataType:"json",
									data: 	"catalogId=" + rub+"&page="+page,
									success: function(data){
										$("#video_list").html(data.html);
										$("#pages").html(data.pages);
										$("#page_is").text("Страница " + data.correct+" из "+data.all);
									},
					              	beforeSend: function(){
										$("#video_list").hide();
										$("#loading").show();
					              	},
					              	complete: function()
					              	{
					              		 $("a.lnk-add-f").unbind("click");
										$("a.lnk-add-f").bind("click", addToPlHandler);
										$("a.playThisVideo").unbind("click");
										$("a.playThisVideo").bind("click", playVideoHandler);
										$("#loading").hide();
										$("#video_list").show();
					              	}
								});
			}



			function playVideoHandler(){
				//$.post("/count/count_news.php", {type:"video",id:$(this).attr("video_id") });
				if ($("#firstTabs").is(":visible"))
					$("#current_category").attr("value", $("#firstTabs").children().children("li.vTabsAct").attr("catalog_id"));
				else
					$("#current_category").attr("value", $("#lastTabs").children().children("li.vTabsAct").attr("catalog_id"));

				$("#playVideoForm").attr("action", "/video/" + $(this).attr("video_id"));

				if ($(this).parent().parent().attr("id") != "videoScrollList")
					$("#playVideoForm").submit();
				else {
					now_playing = $(this).attr("id");
					goXML($(this).attr("src"));
				}

			}

			function addToPlHandler(){
					var copy = $(this).parent().clone(true);

					var cont =copy.find("img");
					var img=cont.attr("src");
					var xml=cont.attr("xml");
					var subtitle=cont.attr("alt");
					var title=cont.attr("title");
					var dt=cont.attr("date");
					var id=cont.attr("video_id");

					$("#bt_myvideo").removeClass("noact").addClass("act");
   	   			 	$("#bt_lastvideo").removeClass("act").addClass("noact");
   		 			$("#last_video").hide();
		 			$("#my_video").show();
   	   			 	video_count++;
					var div ="<div class='tLine' id='my_video_"+id+"'><a  class='fl sr5' href='javascript:goXML("+id+");'><img src='"+img+"' alt='"+subtitle+"' title='"+title+"' date='"+dt+"' xml='"+xml+"'/></a><p class='nom tbold'>"+title+"</p><p class='nom'>"+dt+"</p><a href='javascript:goXML("+id+");' class='lnk-wch'>Смотреть</a></div><div class='cl'></div>";
					$("#my_video").append(div).fadeIn("slow");
					$("#video_count").text(video_count);

	 				$("#v_"+id).parent().fadeOut("slow");
					$("#lv_"+id).hide();

				}


			function playNext() {
				if ($("#autoPlay").attr("checked")){
					now_playing = $("#" + now_playing).parent().next().children("a.playThisVideo").attr("id");
					if ($("#" + now_playing).attr("class") != "playThisVideo")
						return 0;
					goXML($("#" + now_playing).attr("src"));
				}
				return 0;
			}

			function thisMovie(movieName) {
				if (navigator.appName.indexOf("Microsoft") != -1) {
					return window[movieName];
				} else {
					return document[movieName];
				}
			}
			function goXML(id) {
				//setVideoText();
				var div = $("#my_video_"+id).clone(true);
				var xml=div.find("img").attr("xml");
				$("#video_title").html(div.find("img").attr("title"));
				$("#video_subtitle").html(div.find("img").attr("alt"));
				$("#video_date").html(div.find("img").attr("date"));
				thisMovie("f1").goXML(xml);
			}

			function clearPL(){
				$("#videoScrollList").children().remove();
				$("a.addToPl").show("slow");
				$("#autoPlay").attr("checked", false);
				setPlaylistCount();
			}
