$(document).ready(function(){
	More_description.init();

    $('#logo').click(function() {
		window.location = "/";
    });

    $('#banner').livequery(function() {
		if($(this).children().size() > 2) {
			$(this).css("display","block");
		}
    });

	$('#606_80').livequery(function() {
		if($(this).children().size() > 2) {
		   $(this).css("margin-bottom","18px");
		   $(this).css("display","block");
		}
	});

	if($(".header4:eq(0)").html() == "Ипотека") {
		$(".header4:eq(0)").css("background", "url('/img/lowell_bg.gif') no-repeat");
	}

	if($(".header4:eq(1)").html() == "Ипотека") {
		$(".header4:eq(1)").css("background", "url('/img/lowell_bg.gif') no-repeat");
	}

	if($(".header4:eq(2)").html() == "Ипотека") {
		$(".header4:eq(2)").css("background", "url('/img/lowell_bg.gif') no-repeat");
	}
});


$(document).ready(function(){

	if ( $.cookie('view') == "table" )
	{
		$("a.switch_thumb").toggle(
			function(){
				$.cookie('view', 'line', { expires: 7, path: '/'});
				$(this).removeClass("swap");
				$("ul.display").fadeOut("fast", function() {
					$(this).fadeIn("fast").removeClass("thumb_view");
				});
			},

			function () {
				$.cookie('view', 'table', { expires: 7, path: '/'});
				$(this).addClass("swap");
				$("ul.display").fadeOut("fast", function() {
					$(this).fadeIn("fast").addClass("thumb_view");
				});
			});

	
    } else {
		$("a.switch_thumb").toggle(
			function(){
				$.cookie('view', 'table', { expires: 7, path: '/'});
				$(this).addClass("swap");
				$("ul.display").fadeOut("fast", function() {
					$(this).fadeIn("fast").addClass("thumb_view");
			});

			},

			function () {
				$.cookie('view', 'line', { expires: 7, path: '/'});
				$(this).removeClass("swap");
				$("ul.display").fadeOut("fast", function() {
					$(this).fadeIn("fast").removeClass("thumb_view");
				});
			});

    }

});

/* More Description
------------------------------------------------------------------ */
var More_description = {
  init: function() {
    this.setDescription();
  },
  
  setDescription: function() {
    show_height = 150;
    speed = 200;
    desc = jQuery('#text_content');
    
    if (desc.height() > show_height+50) {
      desc.orig_height = desc.height() + 20;
      desc.css({'overflow': 'hidden', 'height': show_height+'px'});
      desc.after('<div class="more_description"><a href="#">Развернуть</a></div>');

      jQuery('.more_description a').bind('click', function(e) {
        e.preventDefault();
        if (desc.orig_height > desc.height()) {
          desc.animate({'height': desc.orig_height+'px'}, speed);
//	      desc.css({'cssText': 'overflow: visible !important'});
          jQuery(this).html('Свернуть');
        }
        else {
	      desc.css({'overflow': 'hidden'});
          desc.animate({'height': show_height+'px'}, speed);
          jQuery(this).html('Развернуть');
        }
      });
    }
  }
};

