$(document).ready(function(){
	$('#l_selected a').hover(function() {
		$('#languages ul').slideDown();
	});
	$('#languages').mouseleave(function(){
		$('#languages ul').slideUp();
	});
	$('#languages ul li a').click(function(){
		$('#languages ul').slideUp();
		return false;
	});
	$('#order_top a').hover(function(){
		$(this).children('span').stop().fadeTo(500, 1);
	}, function(){
		$(this).children('span').stop().fadeTo(500, 0);
	}).children('span').empty().css('opacity', 0);
	$('img.remember').click(function(){
		if($(this).attr("src") == '/images/design/remember.png') {
			$(this).attr("src", '/images/design/remember_checked.png');
		}
		else {
			$(this).attr("src", '/images/design/remember.png');
		}
	});
	$('#login_panel .link1').click(function(){
		if ($(this).html() == 'свернуть') {
			$('#log_reg_form').slideToggle();
			$(this).html('развернуть');
			$(this).css('left', '151px');
		}
		else {
			$('#log_reg_form').slideToggle();
			$(this).html('свернуть');
			$(this).css('left', '165px');
		}
		return false;
	});
	$('.top_rating ul li:odd').addClass('bg_grey');
	$('#obj_table').find('td:nth-child(2)').addClass('fontBold');
	$('#obj_table').find('td:nth-child(1)').addClass('textCenter');
	$('#obj_table tr:even').addClass('bg_grey');
	$('a[href^="http://"]').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	$(".middle_content.catalogue > ul > li > a").click(function() {
		$(this).parent().toggleClass("active");
		return false;
	});
	$('#log_reg_form form').submit(function() {
		var login = $(this.login).val();
		var password = $(this.password).val();
		$.ajax({
			url : '/auth/login/format/html',
			type : 'POST',
			data : {
				login : login,
				password : password
			},
			dataType : 'html',
			success : function(data) {
				$('#log_reg_form').html(data);
			}
		});
		return false;
	});
	$('#log_reg_form a.logout').live('click', function() {
		if (!confirm('Вы уверены, что хотите выйти?')) {
			return false;
		}
	});
});
