
jQuery.imageZoom=function(conf){var config=jQuery.extend({speed:200,dontFadeIn:1,hideClicked:1,imageMargin:30,showCloseButton:0,exactPlace:false,className:'jquery-image-zoom',loading:'Загружается...',selector:'a.imagezoom'},conf);config.doubleSpeed=config.speed/4;return $(config.selector).live('click',function(e){if(e.shiftKey||e.ctrlKey||e.altKey)return true;var clickedElement=jQuery(e.target);var clickedLink=clickedElement.is('a')?clickedElement:clickedElement.parents('a');clickedLink=(clickedLink&&clickedLink.is('a')&&clickedLink.attr('href').search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)$/gi)!=-1)?clickedLink:false;var clickedImg=(clickedLink&&clickedLink.find('img').length)?clickedLink.find('img'):false;if(clickedLink){clickedLink.oldText=clickedLink.html();clickedLink.setLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'0.5'}).parents('.imagezoom:eq(0)').addClass('loading');}
else{clickedLink.text(config.loading);}};clickedLink.setNotLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'1'}).parents('.imagezoom:eq(0)').removeClass('loading');}
else{clickedLink.html(clickedLink.oldText);}};var displayImgSrc=clickedLink.attr('href');if($('div.'+config.className+' img[src="'+displayImgSrc+'"]').length){}
$('#imgzoom').click();var preloadOnload=function(){clickedLink.setNotLoadingImg();var dimElement=clickedImg?clickedImg:clickedLink;var hideClicked=clickedImg?config.hideClicked:0;var offset=dimElement.offset();var imgzoomBefore={width:dimElement.outerWidth(),height:dimElement.outerHeight(),left:offset.left,top:offset.top};var imgzoom=jQuery('<div id="imgzoom"><img src="'+displayImgSrc+'" alt="" /></div>').css('position','absolute').appendTo(document.body);var caption=clickedImg?clickedImg.attr('title'):'';var caption_height=0;if(caption){$('<div/>').addClass('fotos_caption').append(caption).appendTo(imgzoom);}
var imgzoomAfter={width:imgzoom.outerWidth(),height:imgzoom.outerHeight()};var windowDim={width:jQuery(window).width(),height:jQuery(window).height()};if(imgzoomAfter.width>(windowDim.width-config.imageMargin*2)){var nWidth=windowDim.width-config.imageMargin*2;imgzoomAfter.height=(nWidth/imgzoomAfter.width)*imgzoomAfter.height;imgzoomAfter.width=nWidth;}
if(imgzoomAfter.height>(windowDim.height-config.imageMargin*2)){var nHeight=windowDim.height-config.imageMargin*2;imgzoomAfter.width=(nHeight/imgzoomAfter.height)*imgzoomAfter.width;imgzoomAfter.height=nHeight;}
if(config.exactPlace){var clickedLinkPos=clickedLink.offset();imgzoomAfter.left=clickedLinkPos.left;imgzoomAfter.top=clickedLinkPos.top;}else{imgzoomAfter.left=(windowDim.width-imgzoomAfter.width)/2+jQuery(window).scrollLeft();imgzoomAfter.top=(windowDim.height-imgzoomAfter.height)/2+jQuery(window).scrollTop();}
if(config.showCloseButton){var closeButton=jQuery('<a href="#">Закрыть</a>').appendTo(imgzoom).hide();}
if(hideClicked){clickedLink.css('visibility','hidden');}
imgzoom.addClass(config.className).css(imgzoomBefore).animate(imgzoomAfter,config.speed,function(){if(config.showCloseButton)closeButton.fadeIn(config.doubleSpeed);});var hideImgzoom=function(){imgzoom.animate(imgzoomBefore,config.speed,function(){clickedLink.css('visibility','visible');imgzoom.remove();$(document).unbind('click.imgzoom');});return false;};imgzoom.click(hideImgzoom);if(config.showCloseButton)closeButton.click(hideImgzoom);};var preload=new Image();preload.src=displayImgSrc;if(preload.complete){preloadOnload();}
else{clickedLink.setLoadingImg();preload.onload=preloadOnload;}
return false;}});};

$(function(){if(typeof $.imageZoom!='undefined'){$.imageZoom();}
$(".makelink").each(function(){var obj=$(this);var title=obj.text();var url=this.title||text;if(url.split(':')[0]!='http')url='http://'+url;obj.html('<a href="'+url+'" target=_blank>'+title+'</a>');});$("#leftcol_content .navigation:eq(0) .level_0").each(function(){var ul=$(this);ul.children('li').each(function(){if(!$(this).hasClass('selected')){$(this).find('.items').slideUp(0);}});ul.children('li').children('a').bind('click',function(){$(this).next('.items').slideToggle('normal');return false;});});var w=$(".main_content:eq(0) img:eq(0)");if(w.length){var k=parseInt(w.attr('width'));if(k){var l=$("#language_checker");l.animate({left:left=167+k-l.outerWidth()+2},400);}}});

