$(document).ready(
  function()
  {
	$(window).load(
		function() 
		{
var tmp1=($("#wrapper-2").height());
var tmp2=($(".center_content_inn_df").height());
var tmp2_1=($(".center_content").height());
var tmp2_2=($(".center_opacity_bg").height());
var tmp3=($(".right_opacity_bg").height());
var tmp3_1=($(".right_content").height());
var tmp4=($(window).height())-($("#branding").height())-($(".top_line").height());
var h_lfcolinner = $('.left_column_inner').height();
var paddTop = $('.left_column_inner').css('paddingTop').substr(0,2)*1;
var paddBot = $('.left_column_inner').css('paddingBottom').substr(0,2)*1;
var h_scroll = h_lfcolinner + paddTop + paddBot;
			maxH=Math.max(tmp1,tmp3);
			maxH=Math.max(tmp2,maxH);
			maxH=Math.max(tmp3_1,maxH);
			maxH=Math.max(tmp2_1,maxH);
			maxH=Math.max(tmp2_2,maxH);
			if (maxH  < tmp4)
			{
				$("#wrapper-2").height(tmp4);
				$(".right_opacity_bg").height(tmp4);
				$(".center_opacity_bg").height(tmp4);
				$(".right_content").height(tmp4);
				$(".center_content_inn_df").height(tmp4);
				$(".center_content").height(tmp4);
			}
			else
			{
				
				$("#wrapper-2").height(maxH);
				$(".right_opacity_bg").height(maxH);
				$(".center_opacity_bg").height(maxH);
				$(".right_content").height(maxH);
				$(".center_content_inn_df").height(maxH);
				$(".center_content").height(maxH);
			}
		if ($(".scroll").length) 
		{
			$(".scroll").css('height', h_lfcolinner + paddTop + paddBot-12);
			if ($(".scroll").height() < 398)
			{
				$(".scroll").height(398);
			}
			what = $('.scroll');
			scroll();

			}
		}
	
	);
	$(window).resize(
		function() 
		{
var tmp1=($("#wrapper-2").height());
var tmp2=($(".center_content_inn_df").height());
var tmp2_1=($(".center_content").height());
var tmp2_2=($(".center_opacity_bg").height());
var tmp3=($(".right_opacity_bg").height());
var tmp3_1=($(".right_content").height());
var tmp4=($(window).height())-($("#branding").height())-($(".top_line").height());
			maxH=Math.max(tmp1,tmp3);
			maxH=Math.max(tmp2,maxH);
			maxH=Math.max(tmp3_1,maxH);
			maxH=Math.max(tmp2_1,maxH);
			maxH=Math.max(tmp2_2,maxH);
			if (maxH  < tmp4)
			{
				$("#wrapper-2").height(tmp4);
				$(".right_opacity_bg").height(tmp4);
				$(".center_opacity_bg").height(tmp4);
				$(".right_content").height(tmp4);
				$(".center_content_inn_df").height(tmp4);
				$(".center_content").height(tmp4);
			}
			else
			{
				
				$("#wrapper-2").height(maxH);
				$(".right_opacity_bg").height(maxH);
				$(".center_opacity_bg").height(maxH);
				$(".right_content").height(maxH);
				$(".center_content_inn_df").height(maxH);
				$(".center_content").height(maxH);
			}
		}
	);

	// ######### 06.07.2010 #######
	// ########## ÏÎÏÀÏ ÎÊÍÎ ###########
  	$('.fancy').click(function()
	{
		var idpopup = $(this).attr('id');
		idpopup = idpopup+'popup';
		
		if ($('#'+idpopup).length)
		{
			$("#fancy_overlay").css({display: 'block'});
			$("#fancy_overlay").css({'width': $(window).width(), 'height': $(document).height()});
			$("#"+idpopup).show().centering(1,1);
			$("#"+idpopup).css({display: 'block'});
			$("#"+idpopup+' .close').click(function()
			{
				$("#"+idpopup).css({display: 'none'});
				$("#fancy_overlay").css({display: 'none'});
			}
			);
			$("#"+idpopup).find('img').css({left: $("#"+idpopup).find('.photo').width()/2-$("#"+idpopup).find('img').outerWidth(true)/2, top: $("#"+idpopup).find('.photo').height()/2-$("#"+idpopup).find('img').outerHeight(true)/2});
		}
		return false;
	}
	);

	$("#fancy_overlay").click(function()
	{
		$('.popup').hide();
		$("#fancy_overlay").css({display: 'none'});
	}
	);
	
	$(".popup .btn_close").click(function()
	{
		$('.popup').hide();
		$("#fancy_overlay").css({display: 'none'});
		return false;
	}
	);

	$(".popup .gallery_btn_prev").click(function() {
		$(this).parents('.popup').hide();
		$prev_pop = $(this).parents('.popup').prev('.popup');
		$prev_pop.show().centering(1,1);
		$prev_pop.find('img').css({left: $prev_pop.find('.photo').width()/2-$prev_pop.find('img').outerWidth(true)/2, top: $prev_pop.find('.photo').height()/2-$prev_pop.find('img').outerHeight(true)/2});
		return false;
	});
	
	$(".popup .gallery_btn_next, .popup .photo").click(function() {
		if ($(this).parents('.popup').next().is(".popup"))
		{
			$(this).parents('.popup').hide();
			$next_pop = $(this).parents('.popup').next('.popup');
			$next_pop.show().centering(1,1);
			$next_pop.find('img').css({left: $next_pop.find('.photo').width()/2-$next_pop.find('img').outerWidth(true)/2, top: $next_pop.find('.photo').height()/2-$next_pop.find('img').outerHeight(true)/2});
		}
		return false;
	});
  
  
});

function scroll(){
	what.jScrollPane({scrollbarWidth:17, scrollbarMargin:40, showArrows:true});
}


