$(document).ready(function(){
	
	if ($('#middle').height() < '550' ) {$('#middle').height(550)}
	
	$('#sneg_wr').pngFix( );

	$(".vertical .jCarouselLite").jCarouselLite({
		btnNext: ".vertical .next",
		btnPrev: ".vertical .prev",
		visible: 3
	});

	$("a.zoom1").fancybox();

	var middle_height = $('#middle').height();
	$('.some_aromats').height(middle_height);
	var middle_height1 = middle_height + 14;
	if ($('#middle').height() > $('.sidebar').height() ) {$('.sidebar').height(middle_height1);}

	$('#to_blog').click(function(){
		$('#to_blog_wrap').toggle();
		$(this).toggleClass('to_blog_class');
	});
	$('#how').click(function(){
		$('#how_look').toggle();
		return false;
	});
	
	$("#textarea_to_blog").focus(function () {
        $(this).select();
    }).mouseup(function(e){
        e.preventDefault();
    });


	$('.lines #first').click(function(){
		$('.act').removeClass('act');
		$(this).addClass('act');
		$('.first').show();
		$('.second').hide();
	});
	$('.lines #second').click(function(){
		$('.act').removeClass('act');
		$(this).addClass('act');
		$('.first').hide();
		$('.second').show();
	});

	$('.first_price').click(function(){
		$('.second').hide();
		$('.third').hide();
		$('.fourth').hide();
		$('.first').show();

		$('.first_price').addClass('active_price');
		$('.second_price').removeClass('active_price');
		$('.third_price').removeClass('active_price');
		$('.fourth_price').removeClass('active_price');
	});

	$('.second_price').click(function(){
		$('.first').hide();
		$('.third').hide();
		$('.fourth').hide();
		$('.second').show();

		$('.second_price').addClass('active_price');
		$('.first_price').removeClass('active_price');
		$('.third_price').removeClass('active_price');
		$('.fourth_price').removeClass('active_price');
	});

	$('.third_price').click(function(){
		$('.second').hide();
		$('.first').hide();
		$('.fourth').hide();
		$('.third').show();

		$('.third_price').addClass('active_price');
		$('.second_price').removeClass('active_price');
		$('.first_price').removeClass('active_price');
		$('.fourth_price').removeClass('active_price');
	});

	$('.fourth_price').click(function(){
		$('.second').hide();
		$('.third').hide();
		$('.first').hide();
		$('.fourth').show();

		$('.fourth_price').addClass('active_price');
		$('.second_price').removeClass('active_price');
		$('.third_price').removeClass('active_price');
		$('.first_price').removeClass('active_price');
	});












	$("#other_aromats").click(function() {
		$('#other_aromats_wr').show();
		$('#com_wr').hide();
		$('#sh_price_wr').hide();

		$('#other_aromats').addClass('act1');
		$('#otzivi').removeClass('act1');
		$('#sh_price').removeClass('act1');
		var kart_height = $('#content').height();
		var kart_height1 = kart_height - 193;

		var content = $('#content').height();
		var content_height1 = content + 14;
		var sb = $('.sidebar').height();
		var sb_height1 = sb + 14;
		if (content_height1 > sb_height1) {$('.sidebar').height(content_height1);}
	});
	$("#otzivi").click(function() {
		$('#com_wr').show();
		$('#other_aromats_wr').hide();
		$('#sh_price_wr').hide();

		$('#otzivi').addClass('act1');
		$('#other_aromats').removeClass('act1');
		$('#sh_price').removeClass('act1');
		var kart_height = $('#content').height();
		var kart_height1 = kart_height - 193;
		$('.r_menu').height(kart_height1);
		var content = $('#content').height();
		var content_height1 = content + 14;
		var sb = $('.sidebar').height();
		var sb_height1 = sb + 14;
		if (content_height1 > sb_height1) {$('.sidebar').height(content_height1);}

	});
	$("#sh_price").click(function() {
		$('#sh_price_wr').show();
		$('#com_wr').hide();
		$('#other_aromats_wr').hide();

		$('#sh_price').addClass('act1');
		$('#otzivi').removeClass('act1');
		$('#other_aromats').removeClass('act1');
		var kart_height = $('#content').height();
		var kart_height1 = kart_height - 193;
		var content = $('#content').height();
		var content_height1 = content + 14;
		var sb = $('.sidebar').height();
		var sb_height1 = sb + 14;
		if (content_height1 > sb_height1) {$('.sidebar').height(content_height1);}

	});





	// обработки для корзины
	$(".korzina").click(function(){

		var id = $(this).attr('id');
		var korzina = '#' + id;
		var korzina_loader = '.korzina_loader_' + id;

		$( korzina ).hide();
		$( korzina_loader ).show();

		$.post("/protect/price.php",{
			type: 'add',
			id: id
		}, function(xml){
			$("message",xml).each(function(id){
				message = $("message",xml).get(id);
				$("#korzina_kol").html( $("kol",message).text() );
				$("#korzina_sum").html( $("sum",message).text() );
				$( korzina_loader ).hide();
				$( korzina ).animate({ opacity: "show" }, "slow");
				window.location = '/orders/';
			});
		});
	});

	$(".korzina_delete").click(function(){
		var uid = $(this).attr('id');
		var sum = $( '#sum_' + uid ).text();
		var kol = $( '#kol_' + uid ).val();

		$("#tr_" + uid ).animate({ opacity: "hide" }, "slow");

		$.post("/protect/price.php",{
			type: 'delete',
			uid: uid,
			sum: sum,
			kol: kol
		}, function(xml){
			$("message",xml).each(function(id){
				message = $("message",xml).get(id);
				$("#tr_" + uid ).remove();
				$("#korzinaS_sum").html( $("sum",message).text() + ' руб.' );
				$("#korzina_kol").html( $("kol",message).text() );
				$("#korzina_sum").html( $("sum",message).text() );
			});
		});

		return false;
	});


	$("#acc_but_find").click( function () {
		var sel_brend = $("#acc_sel_brend option:selected");
		var sel_type = $("#acc_sel_type option:selected");

		if( sel_type.val() == 0 && sel_brend.val() == 0 ){
			window.location = '/accessories/';
		}else{
			window.location = '/accessories/filter/type/' + sel_type.val() + '/brend/' + sel_brend.val() + '/';
		}
	});
	
	$("a.galarey").fancybox(); 

});
$(function()
{
	//$('.r_menu1').jScrollPane({showArrows:true, scrollbarWidth:19, dragMaxHeight:43});
	//$('.jScrollPaneContainer').width(198);

});