$(document).ready(function(){
	$("#contentblock a").each(function(){
		if($(this).children("img").length && $(this).attr("href").match(/\.jpg$/i)){
			$(this).attr("rel", "prettyPhoto[auto]");
		}
	});
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: "facebook"});
	$('#userdata').load('/userdata/?ajax=1&rnf=' + Math.random());
        $('#topblock').innerfade({ speed: 'slow', timeout: 10000, type: 'sequence' , containerheight: '370px'});
        $('#form-search input').focus(function(){
        	if($(this).val() == 'найти'){
			$(this).removeClass('italic');
			$(this).removeClass('gray');
			$(this).val('');
        	}
        });
        $('#form-search input').blur(function(){
        	if($(this).val() == ''){
			$(this).val('найти');
			$(this).addClass('italic');
			$(this).addClass('gray');
        	}
        });
        $("a.jopenchildren").click(function(){
        	$(this).parent("li").children("ul").toggleClass("hidden");
        	return false;
        });
        $("a.jopenchildren").removeClass("jopenchildren");

	$("a.tab").click(function(){
		$("a.tab").each(function(){
			$($(this).attr("href")).hide();
			$(this).removeClass("bold");
		});
		$($(this).attr("href")).show();
		$(this).addClass("bold");
		return false;
	});
	var tab = 1;
	$("a.tab").each(function(){
		if(window.location.hash && window.location.hash == $(this).attr("href")){
			$($(this).attr("href")).show();
			$(this).addClass("bold");
			tab = 0;
			return;
		}
		$($(this).attr("href")).hide();
		$(this).removeClass("bold");
	});
	if(tab && $("a.tab:first").length){
		$($("a.tab:first").attr("href")).show();
		$("a.tab:first").addClass("bold");
	}
});

