jQuery(document).ready(function() {
	$(window).load(function() {
        $(window).on("resize", function () {
            $('.newsBody .item').css('height', 'auto');
            var maxHeight = Math.max.apply(null, $(".newsBody .item").map(function ()
            {
             	return $(this).height();
            }).get());
            if (maxHeight)
                $('.newsBody .item').height(maxHeight);
        }).resize();
    });
	$('.filter-news').on('change', function() {
		filter_month = $('.filter-news.month').val();
		filter_year = $('.filter-news.year').val();
		if (filter_month && filter_year) {
//			$('.')
		} else if (filter_month) {
			$('.news-container .news.filter-'+filter_month).show();
			$('.news-container .news:not(.filter-'+filter_month+')').hide();
		} else if (filter_year) {
			$('.news-container .news.filter-'+filter_year).show();
			$('.news-container .news:not(.filter-'+filter_year+')').hide();
		} else {
			$('.news-container .news').show();
		}
//		console.log(filter_month);
//		console.log(filter_year);
	});
	$('.news.load-more-btn').click(function() {
		$('.news.previewmode').each(function() {
			thisimg = $(this).find('img');
			thisimg.removeClass('lazy-img');
			if (typeof thisimg.attr('data-src') !== 'undefined' && thisimg.attr('data-src').length > 0) {
				thisimg.attr('src', thisimg.attr('data-src'));
				thisimg.attr('data-src', '');
			}
			$(this).removeClass('previewmode');
			$(this).show();
		});
		$('.news.load-more-btn').hide();
	});

    $('.addmorephotos').click(function() {
            cloneID = $(this).attr('data-clone');
            clonedPhoto = $('#'+cloneID).clone();
            incr = $(this).parents('.wrapper').find('.slides > div').length;
            clonedPhoto.find('input').val('').attr('id', 'slide_'+incr);
            clonedPhoto.appendTo($(this).parents('.wrapper').find('.slides'));
    })

	jQuery('.emptystar').hover( 
		function() {
			jQuery(this).attr('src', '/images/star_filled.png');
		},
		function() {
			jQuery(this).attr('src', '/images/star_clear.png');
		}
	);
	jQuery('.filledstar').hover( 
		function() {
			jQuery(this).attr('src', '/images/star_clear.png');
		},
		function() {
			jQuery(this).attr('src', '/images/star_filled.png');
		}
	);
});
