$(function() {
	// поиск
	$(".searchlist li").click(function() {
		$(this).siblings(".active").removeClass("active")
		$(this).addClass("active")

		$(this).parents("form").attr("action", $(this).attr("stype"))
	})

	// табы хотов
	$("#hots_tabs > li").click(function() {
		$("#hots_tabs .select").removeClass("select")
		$(this).addClass("select")

		$(".tabContent").hide()
		$("#" + $(this).attr("tab") + "_hots").show()
	})

	// клики по хотам ньюса
	$("#news_hots .sh_else_hots").click(function() {
		var o = this
		$("#news_hots #n_hot_img img").attr({
			"src": $(o).attr("pic"),
			"alt": $(o).attr("etitle"),
			"title": $(o).attr("etitle"),
		})
		$("#news_hots .fl a, #news_hots a.bl-lnk").attr("href", $(o).attr("elink"))
		$("#news_hots h3").text($(o).attr("etitle"))
		$("#news_hots a.bl-lnk").text($(o).attr("estitle"))

		$("#news_hots .sh_else_hots").show()
		$(o).hide()
	})

	// клики по хотам шоубиза
	$("#showbiz_hots .sh_else_hots").click(function() {
		var o = this
		$("#showbiz_hots #sh_hot_img a img").attr({
			"src": $(o).attr("pic"),
			"alt": $(o).attr("etitle"),
			"title": $(o).attr("etitle"),
		})
		$("#showbiz_hots #sh_hot_img a, #showbiz_hots a.bl-lnk").attr("href", $(o).attr("elink"))
		$("#showbiz_hots h3").text($(o).attr("etitle"))
		$("#showbiz_hots p.defText").text($(o).attr("estitle"))

		$("#showbiz_hots .sh_else_hots").show()
		$(o).hide()
	})

	// блок галерей
	$(".PlBt").live("click", function() {
		$(".PlBtAct").removeClass("PlBtAct").addClass("PlBt")
		$(this).removeClass("PlBt").addClass("PlBtAct")

		$("#galleries_block a img").attr({
			"src": $(this).attr("img"),
			"alt": $("a", this).text(),
			"title": $("a", this).text(),
		})
		$("#galleries_block a").attr("href", $("a", this).attr("href"))
		$("#galleries_block h3").text($("a", this).text())
		$("#galleries_block p").text($(this).attr("subtitle"))
	})
	$(".PlBtAct a, .PlBt a").click(function() {
		$(this).parents(".PlBtBg").click()
		return false
	})
	$(".PlBtAct").live("click", function() {
		window.location = $("a", this).attr("href")
	})

	// блок видео
	$(".PlBtT2").live("click", function() {
		$(".PlBtActT2").removeClass("PlBtActT2").addClass("PlBtT2")
		$(this).removeClass("PlBtT2").addClass("PlBtActT2")

		$("#top_video_block a img").attr({
			"src": $(this).attr("img"),
			"alt": $("a:eq(1)", this).text(),
			"title": $("a:eq(1)", this).text(),
		})
		$("#top_video_block a").attr("href", $("a", this).attr("href"))
		$("#top_video_block h3").text($("a:eq(1)", this).text())
		$("#top_video_block p").text($(this).attr("subtitle"))

		thisMovie("top_video_player").reloadVideo($(this).attr("flv"), $(this).attr("pic"))
	})
	$(".PlBtActT2 a, .PlBtT2 a").click(function() {
		$(this).parents(".PlBtBg").click()
		return false
	})
	$(".PlBtActT2").live("click", function() {
		window.location = $("a", this).attr("href")
	})

	// выбор города для погодного информера
	$("#city_select").click(function() {
		$("#city_dropdown").toggle();
	});
	$(".li_city").click(function(event) {
		$("#city_select span").text($(this).text());
		$("div.active").hide().removeClass("active");
		$("#"+$(this).attr("city_id")).show().addClass("active");
		$("#city_dropdown").hide();
	});



})

function thisMovie(movieName) {
	if (navigator.appName.indexOf ("Microsoft") != -1) {
		return window[movieName]
	} else {
		return document[movieName]
	}
}

function top_news_wrap(t) {
	t = 250
//	$("#top_news").parent().css({"height": "150px"})
	$("#top_news").parent().animate({"height": "150px"}, t)
}

function top_news_unwrap(t) {
	t = 500
//	$("#top_news").parent().css({"height": "270px"})
	$("#top_news").parent().animate({"height": "270px"}, t)
}
