﻿$(document).bind("ready", function() {

    $(":input[placeholder]").placeholder();

	if ($('.b-head-contact').length > 0) {
		$('.city-tab .l-city-tab').click(function(event){
			$('.city-phone li').hide().filter(':eq('+$(this).index('.l-city-tab')+')').show();
			$('.b-head-contact-bottom .iskype').hide().filter(':eq('+$(this).index('.l-city-tab')+')').show();
			$('.city-tab .l-city-tab').removeClass('l-city-tab-active');
			$(this).addClass('l-city-tab-active');
			return false;
		});
	}
	
    moneyChecker();

	/*Phone Select*/
	if('.curr-city') {
	
		var	city = ['Москва','Иркутск','Улан-Удэ']; 
		var	vcity = ['Москве','Иркутске','Улан-Удэ']; 
		var	phone = ['(495) 287-40-17','(3952) 500-689','(3012) 297-300']; 
		
		var citynum = $('#current-city-num');
		var lcur = $('#current-city');
		var cityLi = $('.cities-list li');	
		var curTitle = $('.curr-city span');
	
		$('.curr-city span').html($('#current-city').val());
		$('.Rphone').html(phone[$(citynum).val()]);
		
		$('.curr-city span').bind('click', function() {	
			list= $(this).parent().find('.cities-list');			
			index = $(citynum).val();		
			cur = $(lcur).val();
			$(this).addClass('showLink');
			if	($(list).css('display')=='block') {
				$(this).removeClass('showLink');	
			}		
			$(list).toggle();
			
			return false;			
		});	
	
		$('.cities-list li a').bind('click', function() {
			
			n = parseInt($(this).attr('rel'));				
			$(cityLi).show();		
			$('.cities-list'+n).hide();
				
			index = $(citynum).val();		
			cur = $(lcur).val();			
			
			$(lcur).val(vcity[n]);
			$(citynum).val(n);
			$(curTitle).html(vcity[n]).removeClass('showLink');						
			
			$('.cities-list').hide();
			$('.Rphone').html(phone[n]);
						
			return false;
		});			
	}	
	/*Phone Select*/

	$('a.gallery').colorbox({opacity:0.6, rel:'nofollow'});
	$('.box-images  a.gallery').attr('rel','gallery').colorbox({opacity:0.6, rel:'gallery'});
	$('a.cboxElement').attr('rel','gallery').colorbox({opacity:0.6, rel:'gallery'});
	$("#recall-me-link").colorbox({inline:true, href:"#recall-me", rel:'nofollow',opacity:0.6});	 
	$("#recall-me-link2").colorbox({inline:true, href:"#recall-me", rel:'nofollow',opacity:0.6});

	$("#aftertest").colorbox({inline:true, href:"#aftertest_form", rel:'nofollow',opacity:0.6});	
	
	
	if($.browser.opera) {
		/*
		if($('.text img'))  {
			$('.text img').wrap('<div class="rounds-middle rbox-text"></div>');		
			$('.text img').before('<i class="roundcorners"><i class="rc-lt"></i><i class="rc-rt"></i><i class="rc-lb"></i><i class="rc-rb"></i></i>');
		}	
		if($('.b-foto-gallery img'))  {
			$('.b-foto-gallery img').wrap('<div class="rounds-middle rbox-text"></div>');		
			$('.b-foto-gallery img').before('<i class="roundcorners"><i class="rc-lt"></i><i class="rc-rt"></i><i class="rc-lb"></i><i class="rc-rb"></i></i>');
		}	*/
		var imgs = $('.content img');
		if (imgs.length > 0){
			imgs.wrap('<div class="rounds-middle rbox-text"></div>');		
			imgs.before('<i class="roundcorners"><i class="rc-lt"></i><i class="rc-rt"></i><i class="rc-lb"></i><i class="rc-rb"></i></i>');
		}
	};
	
	
	
	
	$('.big_slider').each(makeSeasonSlider);
	
	function makeSeasonSlider(){
		var container = $('.tours-slider-ul', this);
		var prevBtn = $('.prev', this);
		var nextBtn = $('.next', this);
		
		container.carouFredSel({
			curcular: true,
			infinite: true,
			auto: 8000,
			//height: 'variable',
			width: '1150px',
			items: 1,
			scroll: {		
				fx : 'fade',		
				duration : 600,				
				pauseOnHover : true
			},
			prev : {   
				button  : prevBtn,
				key     : "left"
			},
			next : {
				button  : nextBtn,
				key     : "right"
			}	
		});
	};
	

	if ($('#season-menu .item').size()) {
		var splash = $('#season-zone .spalsh');
		
		$('#season-menu .item').bind('click',function(event){
			var num = $(this).attr('id').split('-')[1];		
			
			$('.tours-slider-ul', '#seasons-tabs .tab-block.active').trigger('pause');
			$('#season-menu .item').removeClass('active');
			$('#item-'+num).addClass('active');
			
			var tab = $('#item-'+num+'-tab');
			
			if (tab.children().length ==0){
				splash.show();
				
				tab.load('/main/ajaxtab/'+num, {}, function(responseText, textStatus, XMLHttpRequest){					
					splash.hide();
					$('.big_slider', this).each(makeSeasonSlider);
					selectSeasonTab(num);
					$('.tours-scroller', this).tinyscrollbar({axis: 'x'});
				});
			} else {
				selectSeasonTab(num);
				$('.tours-slider-ul', tab).trigger('play', true);
			}
						
            return false;
		});
	}
	
	function selectSeasonTab(num){
		$('#seasons-tabs .tab-block').removeClass('active');
		$('#item-'+num+'-tab').addClass('active');
		slideUpdate('#item-'+num+'-tab');
	}
	
	
	$("#check_map_all").each(function(){
		if($('#check_map_all').attr('checked')){ // проверяем его значение
			$('.map-baikal input').attr('checked', true).parent().addClass('checked'); // если чекбокс отмечен, отмечаем все чекбоксы
		} 
	}).click(function (){
		if($('#check_map_all').attr('checked')){ // проверяем его значение
			$('.map-baikal input').attr('checked', true).parent().addClass('checked'); // если чекбокс отмечен, отмечаем все чекбоксы
		} else {
			$('.map-baikal input').attr('checked', false).parent().removeClass('checked'); // если чекбокс не отмечен, снимаем отметку со всех чекбоксов
		}
	});


	$("input[type='checkbox'],input[type='radio'],input[type='submit']:not(.no-uniform),.button,.rselect select,a.button,.styled").uniform();	   
	//$("input[type='checkbox'],input[type='radio'],input[type='submit'],.button,a.button,.styled").uniform();	   
	
	if ($('#tours-scroller-1').length)
		$('#tours-scroller-1').tinyscrollbar({axis: 'x'});
	if ($('#tours-scroller-2').length)
		$('#tours-scroller-2').tinyscrollbar({axis: 'x'});
	if ($('#tours-scroller-3').length)
		$('#tours-scroller-3').tinyscrollbar({axis: 'x'});

	if ( $('#compare-scroller').length)
	$('#compare-scroller').tinyscrollbar({axis: 'x'});
	
	if ( $('#collective-scroller').length)	
	$('#collective-scroller').tinyscrollbar({axis: 'x'});	 

	$('#globalCity-select').bind("click", function(e) {		
		$(this).hide();
		$('#globalCityForm').show();
	});
		
    $(".b-roll .rolling").bind("click", function(e) {
		var check = $(this).parent();
		if (check.is(".expanded")) {
			check.toggleClass("expanded");
			check.find(".roll").slideUp();
			return false;

		}
		else {
			check.toggleClass("expanded");
			check.find(".roll").slideDown().addClass("expanded");
 			return false;
		}
    });

	var slider = $( "#slider-range" );
	if (slider.length > 0){
		var min = $('#TourSearchRmonth0');
		var max = $('#TourSearchRmonth1');
		
		var initVals = [min.val(), max.val()];
		
		slider.slider({
			range: true,
			min: 0,
			max: 12,
	        values: initVals,
	        stop: function( event, ui ) {
	         	var vals = ui.values;
	         	min.val(vals[0]);
	         	max.val(vals[1]);
			} 
		});
	}
	

	if ($('.button-menu .item').size()) {
		$('.button-menu .item').click(function(event){
			var id =$(this).attr('id');
			var tab = $('.'+id+'-tab');
			$('.button-menu .item').removeClass('active');
			$('.tab-block').removeClass('active');
			$(this).addClass('active');
			$(tab).addClass('active');
			
			return false;
		});
	}

	//Табы на турах	
	if( $('#tour-menu .item').size()) {	
		$('#tour-menu .item').click(function(event){	
			var id =$(this).attr('id');
			$('.tab-block.reverce').addClass('active');
			$('.none-'+id).removeClass('active');	
			$('div.order-tour').toggleClass('round-yellow', ($(this).attr('id')!='item_order'));
				
			$('.order-form-box').show();
			$('.order-text-box').hide();
			
			return false;	
		});	
	
		
		var loc = location.href;
		var tab = loc.match(/\#[\w]+/);
		
		
		if (tab!=null && tab.length>0){
			tab = tab[0].slice(1);
			var tabElem = $('#item_'+tab);
			
			if (tabElem.length > 0){
				tabElem.click();
			}
		}
		
			
		$('.tab_link').live('click', function(){
			var tab_name = $(this).attr('href');
			var tab = $('#item_'+ tab_name.substr(1));
			
			tab.click();
			$.scrollTo(tab);
			return false;
		});
			
	}
		

	

	
	
	/*
	
	if ($('.button-menu.multy .item').size()) {
		$('.button-menu.multy .item').click(function(event){
		    var id =$(this).attr('id');
			
		    $('.button-menu.multy .item').removeClass('active');
			$(this).addClass('active');
			
            $('.tab-block').removeClass('active');
            $('.'+id+'-tab').addClass('active');
            
            $('.tab-block.reverce').addClass('active');
            //$('.none-'+id).removeClass('active');
            

            //return false;
		});
	}
	
	$('.button-menu .item').live('click',function(event){return false});
	*/
	

	
	var f_money1_min = parseInt($('#f-money1_min').val());
	var f_money1_max = parseInt($('#f-money1_max').val());
	var f_money2_min = parseInt($('#f-money2_min').val());
	var f_money2_max = parseInt($('#f-money2_max').val());
	
	slide_range('#f-money1',f_money1_min,f_money1_max);
	slide_range('#f-money2',f_money2_min,f_money2_max);
	
	$('#link-short-search').bind("click", function(e) {
		$.scrollTo('.container',600,{axis:"y"});		
		$('#ext-search').slideUp(300);
		$('#short-search-block').slideDown(300);
		return false;		
	});
	$('#link-ext-search').bind("click", function(e) {	
		$.scrollTo('.container',600,{axis:"y"});		
		$('#short-search-block').slideUp(300);
		$('#ext-search').slideDown(300);
		return false;		
	});	
	
	tooltip_href('.btooltip');
    tabs ('.tabs-menu');
	
	//slideImg('.item1-tab',0);
	//slideImg('.item2-tab',0);
	//slideImg('.item3-tab',0);

	$('textarea').elastic();
});


$(window).bind("resize", function(){
	
	slideUpdate('.item1-tab');
	slideUpdate('.item2-tab');
	slideUpdate('.item3-tab');	
	
	if ($('#compare-scroller').length)
		$('#compare-scroller').tinyscrollbar_update();	

	if ( $('#collective-scroller').length)
		$('#collective-scroller').tinyscrollbar_update();
	
});


function fixmenu() {
    var mainmenu=$('.mainmenu');
    count = $('.mainmenu .level0').size();
    $('.mainmenu .level0').width(mainmenu.width()/count);
    return false;
}

function moneyChecker() {
    var count=$('#money-checker .bl_noreload').size();
    var current=$('#money-checker-num').val();
    $('#money-checker-val-'+current).stop(true,true).show().siblings().not(this).hide();

    $("#money-checker .bl_noreload").bind("click", function() {
	    current++;
        if (current>count) {current=1;}
        $('#money-checker .bl_noreload').hide();
        $('#money-checker-val-'+current).show();
        $('#money-checker-num').val(current);

	return false;
});

};

function slide_range (obj,min1,max1) {
	$(obj+'_slider').slider({
		range: "max",
		min: min1,
		max: max1,
		slide: function( event, ui ) {
			$(obj).val( ui.value );
		}
	});
	
	$(obj+'_slider').bind("mouseover", function(e) {
		$(obj).addClass('hover');
	});		
	$(obj+'_slider').bind("mouseout", function(e) {
		$(obj).removeClass('hover');
	});		
		
	var curTextVal = $(obj).val();
	
	if (!isNaN(curTextVal)){
		if (curTextVal > max1){
			curTextVal = max1;			
		} else if (curTextVal < min1){
			curTextVal = min1;
		} 		
	} else {
		curTextVal = min1;
	}
	
	$(obj+'_slider').slider( "value",  curTextVal);
	$(obj).val( curTextVal);

	$(obj).keypress(function(e) {
		switch(e.keyCode) {
			case 38: {

				break;
			}
			case 40: {

				break;
			}
			default: {
				if(e.keyCode != 8) {
					var value = parseInt($(this).val() + String.fromCharCode(e.which));
				} else {
					//нажали backspace
					var value = $(this).val();
					value = value.substr(0, value.length-1);
				}
			}
		}
	});

    return false;
};

function tooltip_href (link) {
	$(link).tooltip({
		track:true,
		bodyHandler: function() {
			return $($(this).attr("href")).html();
		},
		showURL: false,
		bottom:0,
		left:0
	});
}

function tabs (tabs) {
	$(tabs+ ' li').click(function(event){
	    tab_id =$(this).find('a').attr('href');
        $(tab_id).addClass('active').siblings().not(this).removeClass('active');
        $(this).addClass('active').siblings().not(this).removeClass('active');
        return false;
	});

}

function slideImg(id,update) {
	var container = $(id + ' .slider');
	var slider = $(id + ' .tours-slider-ul');
	var li = $(slider).children('li');
    var count = li.size()-1;
    var current=0;		
	
	cul_li = $('.slider-li'+current, slider);
	$(li).hide().removeClass('active');	
	$(cul_li).show().addClass('active');
	
	sliderResize(current,slider,container,0);
	

	$('.prev', id).click( function() {
	    current--;
	    if (current<0) {current=count;}
			$(li).hide().removeClass('active');	 	
			cul_li = $('.slider-li'+current, slider);
			$(cul_li).fadeIn(400).addClass('active');
	
			sliderResize(current,slider,container,1);		
			
	    return false;
	
	});
	
	$('.next', id).click("click", function() {
	    current++;
		//alert(current);
		if (current>count) {current=0;}
		
			$(li).hide().removeClass('active');
			cul_li = $('.slider-li'+current, slider);
			$(cul_li).fadeIn(400).addClass('active');
			sliderResize(current,slider,container,1);
			
	    return false;
	});

	if(count==0) {
		$('.next',container).hide();
		$('.prev',container).hide();
	};
	
};

function slideUpdate(id) {
	var container = $(id + ' .slider');
	var slider = $(id + ' .tours-slider-ul');
	var li = $(slider).children('li');
    var count = li.size()-1;
	var current=0;
	current=$(id+' .active').index();	
	//alert(current);
	
	sliderResize(current,slider,container,0);
	
	if ($('#tours-scroller1').length)
		$('#tours-scroller1').tinyscrollbar_update();
	if ($('#tours-scroller2').length)
		$('#tours-scroller2').tinyscrollbar_update();
	if ($('#tours-scroller3').length)
		$('#tours-scroller3').tinyscrollbar_update();	
	
};

function sliderResize(current,slider,container,slide) {
	var cul_li = $('.slider-li'+current, slider);
	var h = $(cul_li).height();		
	$(slider).height(h);			
	
	if(slide==1) { 
		$(container).stop(true).animate({height:h}, 200);}
	else {
		$(container).height(h);
	}	
	
}

/*Placeholder */
(function(a){a.extend({placeholder:{settings:{focusClass:"placeholderFocus",activeClass:"placeholder",overrideSupport:false,preventRefreshIssues:true},debug:false,log:function(b){if(!a.placeholder.debug){return}b="[Placeholder] "+b;a.placeholder.hasFirebug?console.log(b):a.placeholder.hasConsoleLog?window.console.log(b):alert(b)},hasFirebug:"console" in window&&"firebug" in window.console,hasConsoleLog:"console" in window&&"log" in window.console}});a.support.placeholder="placeholder" in document.createElement("input");a.fn.plVal=a.fn.val;a.fn.val=function(e){a.placeholder.log("in val");if(this[0]){a.placeholder.log("have found an element");var d=a(this[0]);if(e!=undefined){a.placeholder.log("in setter");var c=d.plVal();var b=a(this).plVal(e);if(d.hasClass(a.placeholder.settings.activeClass)&&c==d.attr("placeholder")){d.removeClass(a.placeholder.settings.activeClass)}return b}if(d.hasClass(a.placeholder.settings.activeClass)&&d.plVal()==d.attr("placeholder")){a.placeholder.log("returning empty because it's a placeholder");return""}else{a.placeholder.log("returning original val");return d.plVal()}}a.placeholder.log("returning undefined");return undefined};a(window).bind("beforeunload.placeholder",function(){var b=a("input."+a.placeholder.settings.activeClass);if(b.length>0){b.val("").attr("autocomplete","off")}});a.fn.placeholder=function(b){b=a.extend({},a.placeholder.settings,b);if(!b.overrideSupport&&a.support.placeholder){return this}return this.each(function(){var c=a(this);if(!c.is("[placeholder]")){return}if(c.is(":password")){return}if(b.preventRefreshIssues){c.attr("autocomplete","off")}c.bind("focus.placeholder",function(){var d=a(this);if(this.value==d.attr("placeholder")&&d.hasClass(b.activeClass)){d.val("").removeClass(b.activeClass).addClass(b.focusClass)}});c.bind("blur.placeholder",function(){var d=a(this);d.removeClass(b.focusClass);if(this.value==""){d.val(d.attr("placeholder")).addClass(b.activeClass)}});c.triggerHandler("blur");c.parents("form").submit(function(){c.triggerHandler("focus.placeholder")})})}})(jQuery);

/*Elastic*/
(function(jQuery){jQuery.fn.extend({elastic:function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight','border-top-width','border-right-width','border-bottom-width','border-left-width','borderTopStyle','borderTopColor','borderRightStyle','borderRightColor','borderBottomStyle','borderBottomColor','borderLeftStyle','borderLeftColor'];return this.each(function(){if(this.type!=='textarea'){return false}var $textarea=jQuery(this),$twin=jQuery('<div />').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0;if(maxheight<0){maxheight=Number.MAX_VALUE}$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()))}function setTwinWidth(){curatedWidth=Math.floor(parseInt($textarea.width(),10));if($twin.width!==curatedWidth){$twin.css({'width':curatedWidth+'px'});update(true)}}function setHeightAndOverflow(height,overflow){var curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!==curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});$textarea.trigger('resize')}}function update(forced){var textareaContent=$textarea.val().replace(/&/g,'&amp;').replace(/ {2}/g,'&nbsp;').replace(/<|>/g,'&gt;').replace(/\n/g,'<br />');var twinContent=$twin.html().replace(/<br>/ig,'<br />');if(forced||textareaContent+'&nbsp;'!==twinContent){$twin.html(textareaContent+'&nbsp;');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto')}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden')}else{setHeightAndOverflow(goalheight,'hidden')}}}}$textarea.css({'overflow':'hidden'});$textarea.bind('keyup change cut paste',function(){update()});$(window).bind('resize',setTwinWidth);$textarea.bind('resize',setTwinWidth);$textarea.bind('update',update);$textarea.bind('blur',function(){if($twin.height()<maxheight){if($twin.height()>minheight){$textarea.height($twin.height())}else{$textarea.height(minheight)}}});$textarea.bind('input paste',function(e){setTimeout(update,250)});update()})}})})(jQuery);

/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jorn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);

// ColorBox v1.3.17.2 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(a,b,c){function bc(b){if(!U){P=b,_(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1));if(!S){S=T=!0,r.show();if(K.returnFocus)try{P.blur(),a(P).one(l,function(){try{this.focus()}catch(a){}})}catch(c){}q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=Z(K.initialWidth,"x"),K.h=Z(K.initialHeight,"y"),X.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),ba(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()}X.load(!0)}}function bb(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(Q<y.length-1||K.loop)a=setTimeout(X.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(X.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,d),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function ba(b,c){c&&c.call(P),a.event.trigger(b)}function _(b){K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.substring(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function $(a){return K.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(a)}function Z(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function Y(c,d,e){e=b.createElement("div"),c&&(e.id=f+c),e.style.cssText=d||"";return a(e)}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"Картинка {current} из {total}",previous:"Пред.",next:"След.",close:"Закрыть",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:!1},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=a.browser.msie&&!a.support.opacity,o=n&&a.browser.version<7,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X;X=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{};if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b)),a(this).addClass(g)}),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&bc(f[0]);return f},X.init=function(){z=a(c),r=Y().attr({id:e,"class":n?f+(o?"IE6":"IE"):""}),q=Y("Overlay",o?"position:absolute":"").hide(),s=Y("Wrapper"),t=Y("Content").append(A=Y("LoadedContent","width:0; height:0; overflow:hidden"),C=Y("LoadingOverlay").add(Y("LoadingGraphic")),D=Y("Title"),E=Y("Current"),G=Y("Next"),H=Y("Previous"),F=Y("Slideshow").bind(h,bb),I=Y("Close")),s.append(Y().append(Y("TopLeft"),u=Y("TopCenter"),Y("TopRight")),Y(!1,"clear:left").append(v=Y("MiddleLeft"),t,w=Y("MiddleRight")),Y(!1,"clear:left").append(Y("BottomLeft"),x=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"}),B=Y(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),a("body").prepend(q,r.append(s,B)),t.children().hover(function(){a(this).addClass("hover")},function(){a(this).removeClass("hover")}).addClass("hover"),L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}).hide(),G.click(function(){X.next()}),H.click(function(){X.prev()}),I.click(function(){X.close()}),J=G.add(H).add(E).add(F),t.children().removeClass("hover"),q.click(function(){K.overlayClose&&X.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),X.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))})},X.remove=function(){r.add(q).remove(),a("."+g).removeData(e).removeClass(g)},X.position=function(a,c){function g(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,C[0].style.height=C[1].style.height=t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var d=0,e=0;z.unbind("resize."+f),r.hide(),K.fixed&&!o?r.css({position:"fixed"}):(d=z.scrollTop(),e=z.scrollLeft(),r.css({position:"absolute"})),K.right!==!1?e+=Math.max(z.width()-K.w-O-M-Z(K.right,"x"),0):K.left!==!1?e+=Z(K.left,"x"):e+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?d+=Math.max(b.documentElement.clientHeight-K.h-N-L-Z(K.bottom,"y"),0):K.top!==!1?d+=Z(K.top,"y"):d+=Math.round(Math.max(b.documentElement.clientHeight-K.h-N-L,0)/2),r.show(),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:d,left:e},{duration:a,complete:function(){g(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",c&&c(),setTimeout(function(){z.bind("resize."+f,X.position)},1)},step:function(){g(this)}})},X.resize=function(a){if(S){a=a||{},a.width&&(K.w=Z(a.width,"x")-O-M),a.innerWidth&&(K.w=Z(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=Z(a.height,"y")-N-L),a.innerHeight&&(K.h=Z(a.innerHeight,"y"));if(!a.innerHeight&&!a.height){var b=A.wrapInner("<div style='overflow:auto'></div>").children();K.h=b.height(),b.replaceWith(b.children())}A.css({height:K.h}),X.position(K.transition==="none"?0:K.speed)}},X.prep=function(b){function h(){K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h;return K.h}function g(){K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w;return K.w}if(!!S){var c,d=K.transition==="none"?0:K.speed;A.remove(),A=Y("LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function o(){n&&r[0].style.removeAttribute("filter")}var b,c,g,h,i=y.length,k,l;!S||(l=function(){clearTimeout(W),C.hide(),ba(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show(),i>1?(typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",i)).show(),G[K.loop||Q<i-1?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),b=Q?y[Q-1]:y[i-1],g=Q<i-1?y[Q+1]:y[0],K.slideshow&&F.show(),K.preloading&&(h=a.data(g,e).href||g.href,c=a.data(b,e).href||b.href,h=a.isFunction(h)?h.call(g):h,c=a.isFunction(c)?c.call(b):c,$(h)&&(a("<img/>")[0].src=h),$(c)&&(a("<img/>")[0].src=c))):J.hide(),K.iframe?(k=a("<iframe/>").addClass(f+"Iframe")[0],K.fastIframe?l():a(k).one("load",l),k.name=f+ +(new Date),k.src=K.href,K.scrolling||(k.scrolling="no"),n&&(k.frameBorder=0,k.allowTransparency="true"),a(k).appendTo(A).one(m,function(){k.src="//about:blank"})):l(),K.transition==="fade"?r.fadeTo(d,1,o):o())},K.transition==="fade"?r.fadeTo(d,0,function(){X.position(0,c)}):X.position(d,c)}},X.load=function(b){var c,d,e=X.prep;T=!0,R=!1,P=y[Q],b||_(),ba(m),ba(i,K.onLoad),K.h=K.height?Z(K.height,"y")-N-L:K.innerHeight&&Z(K.innerHeight,"y"),K.w=K.width?Z(K.width,"x")-O-M:K.innerWidth&&Z(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=Z(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=Z(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,W=setTimeout(function(){C.show()},100),K.inline?(Y().hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):$(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Y("Error").text("This image could not be loaded"))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(Q<y.length-1||K.loop)&&(R.style.cursor="pointer",R.onclick=function(){X.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Y("Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},X.next=function(){!T&&y[1]&&(Q<y.length-1||K.loop)&&(Q=Q<y.length-1?Q+1:0,X.load())},X.prev=function(){!T&&y[1]&&(Q||K.loop)&&(Q=Q?Q-1:y.length-1,X.load())},X.close=function(){S&&!U&&(U=!0,S=!1,ba(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),ba(m),A.remove(),setTimeout(function(){U=!1,ba(l,K.onClosed)},1)}))},X.element=function(){return a(P)},X.settings=d,V=function(a){a.button!==0&&typeof a.button!="undefined"||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),bc(this))},a.fn.delegate?a(b).delegate("."+g,"click",V):a("."+g).live("click",V),a(X.init)})(jQuery,document,this);
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
