$(document).ready(function() {

$("#inline").colorbox({width:"700px", inline:true, href:"#htmled"});

$('a[rel="gall"]').colorbox({
	current:'{current} из {total}',
	transition:'elastic'
	//~ onComplete:function(){		
		//~ $('#cboxWrapper').css({'height': $('#cboxWrapper').height()-(40-$('#cboxTitle').height()) + 'px' });
		//~ $('#cboxContent').css({'height': $('#cboxContent').height()-(40-$('#cboxTitle').height()) + 'px' });
		//~ $('#cboxMiddleLeft').css({'height': $('#cboxContent').height()-(40-$('#cboxTitle').height())+8 + 'px' });
		//~ $('#cboxMiddleRight').css({'height': $('#cboxContent').height()-(40-$('#cboxTitle').height())+8 + 'px' });
		//~ $('#cboxLoadedContent').css({'margin-bottom':$('#cboxTitle').height()});
		//~ }
	});

$(".forum-post-entry").each(function() {
	var group_id = $(this).children(".forum-post-text").attr("id");
	$(this).find('.img_zoom a').each (function () {
		if ($(this).hasClass("img_tn"))
		{
			$(this).colorbox({rel:'group'+ group_id});
		}
		else
		{
			// Навесим обработчик на событие загрузки картинки, проверяющий ее ширину
			var anchor = $(this);
			anchor.addClass ("maybe_img_tn");
			
			$(anchor.children ("img").first()).load (function ()
			{
				if ($(this).width() > 320)
				{
					anchor.addClass("img_tn").append('<span class="izoom" title="Увеличить"></span>');
					new_h = $(this).height() * 320 / $(this).width();
					anchor.height (new_h + 2);
					$(this).height (new_h);
					anchor.width (320 + 2);
					$(this).width (320);
					anchor.colorbox({rel:'group'+ group_id});
				}
			}).each (function () {
				if(this.complete) $(this).trigger("load");
			});
		}
	});
});
$('.img_tn').append('<span class="izoom" title="Увеличить"></span>');


$(".review_message").each (function () {
		var group_id = $(this).attr ("id");
		$(this).find('.img_zoom a').each (function () {
		if ($(this).hasClass("img_tn"))
		{
			$(this).colorbox({rel:'group'+ group_id});
		}
		else
		{
			// Навесим обработчик на событие загрузки картинки, проверяющий ее ширину
			var anchor = $(this);
			anchor.addClass ("maybe_img_tn");
			
			$(anchor.children ("img").first()).load (function ()
			{
				if ($(this).width() > 320)
				{
					anchor.addClass("img_tn").append('<span class="izoom" title="Увеличить"></span>');
					new_h = $(this).height() * 320 / $(this).width();
					anchor.height (new_h + 2);
					$(this).height (new_h);
					anchor.width (320 + 2);
					$(this).width (320);
					anchor.colorbox({rel:'group'+ group_id});
				}
			}).each (function () {
				if(this.complete) $(this).trigger("load");
			});
		}
	});
	});
});

$('.content_container a:not(.advert a, .img_tn, .maybe_img_tn, a[href*="javascript"])').filter(function() {

    return this.hostname
    && this.hostname !== location.hostname
    && this.hostname !== 'javascript'
    && this.hostname !== 'www.greencard.by'
    && this.hostname !== 'www.green-card.by'
	&& this.hostname !== 'www.green-card.ru'
	&& this.hostname !== 'www.green-card.ua'
	&& this.hostname !== 'www.greencard.ua'
	&& this.hostname !== 'www.greencard.com.ua'
	&& this.hostname !== 'www.greencard.kz'
	&& this.hostname !== 'www.green-card.kz'
	&& this.hostname !== 'www.green-card.md'
	&& this.hostname !== 'www.usa-green-card-lottery.com'
    && this.hostname !== 'greencard.by'
    && this.hostname !== 'green-card.by'
	&& this.hostname !== 'green-card.ru'
	&& this.hostname !== 'green-card.ua'
	&& this.hostname !== 'greencard.ua'
	&& this.hostname !== 'greencard.com.ua'
	&& this.hostname !== 'greencard.kz'
	&& this.hostname !== 'green-card.kz'
	&& this.hostname !== 'green-card.md'
	&& this.hostname !== 'usa-green-card-lottery.com';

  }).addClass('ext_link');
