$(document).ready(function(){
	if ($.browser.msie && $.browser.version == 6) {
		//код только для ИЕ шестой версии!
		minwidth_for_ie6();
		$(window).resize(function(){
			minwidth_for_ie6();
		})
	}
		
	if ($('.carousel').length){
		$(".carousel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			vertical: true,
            circular: false,
			visible: 3
		});
		$(".carousel img").click(function(){
			var src_img = $(this).parent().attr('href')
			$('.img-2 img').attr('src', src_img);
            
            var title = $(this).parent().attr('title')
            if(title.length > 0 && title != "0") {
                $('.img-2-descr').html(title)
            } else {
                $('.img-2-descr').html($('.img-2-descr-default').html())
            }
            set_carousel_height()
            setTimeout(set_carousel_height, 500) //waiting for picture uploading
            setTimeout(set_carousel_height, 1000) //waiting for picture uploading
            setTimeout(set_carousel_height, 2000) //waiting for picture uploading
			return false;
		})

        $('.carousel-cont .next, .carousel-cont .prev').click(function(){
            return false;
        })
/*        $('.carousel img').click(function(){*/
            //set_carousel_height()
        /*})*/
    }

    $('.for_print').click(function() {
        popupWindow()
        return false
    })

})
$(window).load(function() {
    set_carousel_height()
})

function popupWindow() {
    var href = $('a.for_print').attr('href')
    window.open(href, "","status = 1, height = 800, width = 600, resizable = 1, scrollbars = yes" )
    return false
}
/*
подгоняет размер "карусели" под высоты большого изображения
*/
function set_carousel_height() {
    var CAROUSEL_PADDING = 68
    var carousel_height = $('.img-2 img').height() - CAROUSEL_PADDING
    if($('.carousel').css('height') != carousel_height + "px") {
        $('.carousel').css('height', carousel_height + "px")	
        $('.carousel-cont').css('height', carousel_height + "px")	
    }
}
function minwidth_for_ie6(){
	if ($('html').width() <= 1022){
		$('body').width(1000);
	}
	else {
		$('body').width('auto');
	}
}
