$(document).ready(function(){$pelena=$('.pelena');$loader=$('.loader');$popup=$('.popup');$popupCache=new Array();$effectTime=300;getPopup=function(options){if(options.type=='gallery')
{$galleryCurrentItem=options.itemIndex;}
$('.pelena').height($('.background').height());$pelena.fadeIn($effectTime,function(){loaderHeight=$(document).scrollTop()+(($(window).height()-$loader.height()-40)*0.5);loaderWidth=$(document).scrollLeft()+(($(window).width()-$loader.width())*0.5);$loader.css({"top":loaderHeight,"left":loaderWidth});$loader.show();if($popupCache[options.type]==null){$popup.load(document.location.href,options,function(){$popupCache[options.type]=$popup.html();showPopup();});}
else
{$popup.html($popupCache[options.type]);showPopup();}});}
showPopup=function(){$popup.css({minWidth:0,minHeight:0});popupHeight=$(document).scrollTop()+(($(window).height()-$popup.height()-25)*0.5);popupWidth=$(document).scrollLeft()+(($(window).width()-$popup.width())*0.5);if($.browser.opera)
{$("h1,.bg,.bg-2").addClass('remove-outline');}
if(popupHeight<5){popupHeight=5;}
$popup.css({"top":popupHeight,"left":popupWidth});$popup.find('a.close').click(function(){closePelena();return false;});if($popup.find('div.slider').length>0)
{$popup.addClass('popup-slider');showGallery();}
else
{showSend();}
$popup.fadeIn($effectTime);$loader.hide();}
closePelena=function(){if($pelena.css('display')!='none'){$loader.hide();$popup.fadeOut($effectTime,function(){$popup.html('').removeClass('popup-slider');$pelena.fadeOut($effectTime);});}}
$(document).keyup(function(e){if(e.keyCode==27){closePelena();}});$pelena.click(function(){closePelena();return false;});$loader.click(function(){closePelena();return false;});});;$(document).ready(function(){$gallerySlider=null;$galleryAllItems=0;$galleryCurrentItem=1;$galleryAnimateBig=false;$galleryAnimateSmall=false;$galleryWidthBig=612;$galleryWidthSmall=156;$galleryOnLineSmall=4;showGallery=function(){$gallerySlider=$('.slider');$galleryAllItems=$gallerySlider.find('.small-imgs a').size();$galleryAnimate=false;$gallerySlider.find('.big-imgs img').preload({placeholder:'/images/preloaders/gallery-popup-big-placeholder.png',notFound:'/images/preloaders/gallery-popup-big-notfound.png'});$gallerySlider.find('.small-imgs img').preload({placeholder:'/images/preloaders/gallery-popup-list-placeholder.png',notFound:'/images/preloaders/gallery-popup-list-notfound.png'});$gallerySlider.find('.big-imgs').width($galleryAllItems*$galleryWidthBig);$gallerySlider.find('.small-imgs').width($galleryAllItems*$galleryWidthSmall);$gallerySlider.find('a.arrow-left').click(function(){if(!$galleryAnimateBig&&!$galleryAnimateSmall)
{$galleryAnimateBig=true;$galleryAnimateSmall=true;if($galleryCurrentItem==1)
{$galleryCurrentItem=$galleryAllItems;}
else
{$galleryCurrentItem=$galleryCurrentItem-1;}
animateGallery();}
return false;});$gallerySlider.find('a.arrow-right, .big-imgs').click(function(){if(!$galleryAnimateBig&&!$galleryAnimateSmall)
{$galleryAnimateBig=true;$galleryAnimateSmall=true;if($galleryCurrentItem==$galleryAllItems)
{$galleryCurrentItem=1;}
else
{$galleryCurrentItem=$galleryCurrentItem+1;}
animateGallery();}
return false;});$gallerySlider.find('.small-imgs a').click(function(){if(!$galleryAnimateBig&&!$galleryAnimateSmall)
{$galleryAnimateBig=true;$galleryAnimateSmall=true;$galleryCurrentItem=$gallerySlider.find('.small-imgs a').index(this)+1;animateGallery();}
return false;});animateGallery();}
animateGallery=function(){bigAnimate=($galleryCurrentItem-1)*$galleryWidthBig;$gallerySlider.find('.big-imgs').animate({marginLeft:'-'+bigAnimate+'px'},600,function(){$galleryAnimateBig=false;});$gallerySlider.find('h2').fadeOut(300,function(){$(this).html($gallerySlider.find('.small-imgs img:eq('+($galleryCurrentItem-1)+')').attr('alt')).fadeIn(300);})
$gallerySlider.find('.small-imgs img.active').removeClass('active');if(($galleryAllItems-$galleryCurrentItem)<($galleryOnLineSmall)&&($galleryAllItems>$galleryOnLineSmall))
{smallAnimate=($galleryAllItems-$galleryOnLineSmall)*$galleryWidthSmall;}
else if($galleryAllItems>$galleryOnLineSmall)
{smallAnimate=($galleryCurrentItem-1)*$galleryWidthSmall;}
else
{smallAnimate=null;}
if(smallAnimate!=null)
{$gallerySlider.find('.small-imgs').animate({marginLeft:'-'+smallAnimate+'px'},600,function(){$gallerySlider.find('.small-imgs img:eq('+($galleryCurrentItem-1)+')').addClass('active');$galleryAnimateSmall=false;});}
else
{$gallerySlider.find('.small-imgs img:eq('+($galleryCurrentItem-1)+')').addClass('active');$galleryAnimateSmall=false;}}});;$(document).ready(function(){showSend=function(){$('div.post-msg form input').first().before('<input type="hidden" value="1" name="contactsPopup">')};showErrors=function($message){if($('div.post-msg > label').length==0)
{$('div.post-msg form').before('<label></label>');}
$('#txt_captcha').val('');$('div.l-capcha img').attr("src","/captcha.php?time='.time().'");$('div.post-msg > label').attr('class','error').html($message);};showSuccess=function($message){if($('div.post-msg > label').length==0)
{$('div.post-msg form').before('<label></label>');}
$('#txt_name').val('');$('#txt_email').val('');$('#txt_message').val('');$('#txt_captcha').val('');$('div.l-capcha img').attr("src","/captcha.php?time='.time().'");$('div.post-msg > label').attr('class','info').html($message);};});;;(function($){var $preload=$.preload=function(original,settings){if(original.split)
original=$(original);settings=$.extend({},$preload.defaults,settings);var sources=$.map(original,function(source){if(!source)
return;if(source.split)
return settings.base+source+settings.ext;var url=source.src||source.href;if(typeof settings.placeholder=='string'&&source.src)
source.src=settings.placeholder;if(url&&settings.find)
url=url.replace(settings.find,settings.replace);return url||null;});var data={loaded:0,failed:0,next:0,done:0,total:sources.length};if(!data.total)
return finish();var imgs=$(Array(settings.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var orig=data.original=original[this.index];data[data.found?'loaded':'failed']++;data.done++;if(settings.enforceCache)
$preload.cache.push($('<img/>').attr('src',data.image)[0]);if(settings.placeholder&&orig.src){$(orig).hide();orig.src=data.found?data.image:settings.notFound||orig.src;$(orig).fadeIn(500);}
if(settings.onComplete)
settings.onComplete(data);if(data.done<data.total)
fetch(0,this);else{if(imgs&&imgs.unbind)
imgs.unbind('load').unbind('error').unbind('abort');imgs=null;finish();}};function fetch(i,img,retry){if(img.attachEvent&&data.next&&data.next%$preload.gap==0&&!retry){setTimeout(function(){fetch(i,img,true);},0);return false;}
if(data.next==data.total)return false;img.index=data.next;img.src=sources[data.next++];if(settings.onRequest){data.index=img.index;data.element=img;data.image=img.src;data.original=original[data.next-1];settings.onRequest(data);}};function finish(){if(settings.onFinish)
settings.onFinish(data);};};$preload.gap=14;$preload.cache=[];$preload.defaults={threshold:2,base:'',ext:'',replace:'',enforceCache:true};$.fn.preload=function(settings){$preload(this,settings);return this;};})(jQuery);
