src_txt = 'Поиск по блогу';
$(document).ready(function(){
	top_scrol = function (s) {
		if ($.browser.safari) {
			$("body").animate({ scrollTop: s* -1}, 300);
		}else{
			$("html").animate({ scrollTop: s* -1}, 300);
		}
	}
	$("input[name='s']").focus(function () {
		if($(this).val() == src_txt)
			$(this).val('');
	});
	$("input[name='s']").blur(function () {
		if($(this).val() == '')
			$(this).val(src_txt);
	});
	if($("#txt").length){
		if ( $("#dscr_l").is(":not(.act)") ){
			$("#txt").height($("#prcs").height());
		}else{
			$("#txt").height($("#dscr").height());
		}
	}
	if($(".faq").length){
		$(".faq h3 a").parent().next("p").slideToggle(300);
	}
	$("#dt a").click(function () {
		$("#dt a").removeClass("act");
		$(this).addClass("act");
		if ( $("#dscr_l").is(":not(.act)") ){
			$("#txt").animate({ height: $("#prcs").height()+'px' }, 500);
			$("#txt div").animate({ left: '-544px' }, 300);
	}else{
			$("#txt").animate({ height: $("#dscr").height()+'px' }, 500);
			$("#txt div").animate({ left: 0 }, 300);
		}
		return(false);
	});
	$("#prt ul li").hover(
		function () {
			$(this).addClass("hvr");
		},
		function () {
			$(this).removeClass("hvr");
		}
	);
	$("#p_c li").hover(
		function () {
			$(this).addClass("hvr");
		},
		function () {
			$(this).removeClass("hvr");
		}
	);
	$(".bt").hover(
		function () {
			$(this).addClass("hvr");
		},
		function () {
			$(this).removeClass("hvr");
		}
	);
	$(".srv li").hover(
		function () {
			$(this).addClass("hvr");
		},
		function () {
			$(this).removeClass("hvr");
		}
	);
	$("#frn li").hover(
		function () {
			$(this).addClass("hvr");
		},
		function () {
			$(this).removeClass("hvr");
		}
	);
	$(".bt a").click(function () {
		pz = $("#p_c table").offset().left - $("#p_c").offset().left;
		st = ($("#p_c table").width() - 864) * -1;
		if ( $(this).parent().is(":not(.pr)") ){
			if(pz > st ){
				$(this).addClass("hd");
				$("#p_c table").animate({ left: (pz-864)+'px' }, 300, function(){
					if(pz-864 != st){
						$(".nx a").removeClass("hd");
					}
					if( $(".pr a").is(".hd") ){
						$(".pr a").removeClass("hd");
					}
				});
			}
		}else{
			if(pz < 0){
				$(this).addClass("hd");
				$("#p_c table").animate({ left: (pz+864)+'px' }, 300, function(){
					if(pz != -864){
						$(".pr a").removeClass("hd");
					}
					if( $(".nx a").is(".hd") ){
						$(".nx a").removeClass("hd");
					}
				});
			}
		}
		return(false);
	});
	$(".faq h3 a").click(function(){
		$(this).parent().next("p").slideToggle(300);
			return false;
	});
	$(".prsg th").click(function () {
		$(this).parent().parent().parent().parent().toggleClass("opn");
    });
	$(".prsg td").hover(
		function () {
			$(this).parent().addClass("hv");
		},
		function () {
			$(this).parent().removeClass("hv");
		}
	);
	$("#prt > li > a").click(function(){
		cr = $(this).parent();
		if(cr.is(".hd")){
			top_scrol($(this).offset().top);
			$("#prt > li:not(.hd)").find("ul").slideToggle('normal',function(){
				cr.insertBefore("#prt > li:not(.hd)");
				$("#prt > li:not(.hd)").addClass("hd");
				cr.find("ul").slideToggle('normal',function(){
					cr.removeClass("hd");
				});
			});
		}
		return false;
	});
/*	$(".mlm").click(function(){
		top_scrol($(this).offset().top);
		if($("#hdr .mlm").html() == 'Контакты'){
			if($("#t_f").html() == '&nbsp;'){
				$.ajax({
					url:"/kontakty.html",
					data: "topform",
					cache: true,
					dataType:"html",
					success:function(d){
						$("#t_f").html(d);
						$("#t_f").animate({ 'margin-top' : 0 }, 300, function(){
							$("#hdr .mlm").text('Свернуть');
						});
					}
				});
			}else{
				$("#t_f").animate({ 'margin-top' : 0 }, 300, function(){
					$("#hdr .mlm").html('Свернуть');
				});
			}
		}else{
			if ($(this).parent().parent().parent().attr("id") == 'hdr' ){
				$("#t_f").animate({ 'margin-top' : '-273px' }, 300, function(){
					$("#hdr .mlm").html('Контакты');
				});
			}
		}
		return false;
	});
*/	if($("#frn").length){
		$("#frn a").attr('target', '_blank');
	}
	$("#umi a").attr('target', '_blank');
	$(".tp a").click(function(){
		top_scrol($(this).offset().top);
		return false;
	});
});