/*debug.js*/
			$(document).ready(function(){
	$(document)
	.on('mouseenter', '#debugwin', function(event){
		$("#debugwin").css('height', '50%');
		$("#debugwin").fadeTo('fast', 1);
	}).on('mouseleave', '#debugwin', function(event){
		$("#debugwin").css('height', '2%');
		$("#debugwin").fadeTo('fast', .5);
	}).on('dblclick', '#debugwin', function(event){
		$("#debugwin").css('height', '50%');
	});
});
/*number-slider.js*/
			$(document).ready(function(){

	$(".i-summ-overlay").live("click", function(event){
		event.preventDefault();
		$(this).siblings(".use-number-slider").focus();
	});
	
	$(".use-number-slider").each(function(){
		var elt = $(this);
		if ($(elt)[0].tagName == "SELECT") {
			var select = $(elt);
			var slider_id = $(elt).attr("id") + '-slider';
			var min_value_text = $(select).find("option:first").text();
			var max_value_text = $(select).find("option:last").text();
			var min_value = 1;
			var max_value = $(select).find("option").length;
			$(elt).parents(".input-wrap").css("position", 'relative');
			$(elt).parents(".input-wrap").parents(".form-item").addClass("with-number-slider");
			$(elt).parents(".input-wrap").append('<div class="number-slider-container"><div class="number-slider" id="' + slider_id + '"></div></div>');
			var ns_wrap = $(elt).parents(".input-wrap").find(".number-slider-container");
			$(ns_wrap).append('<span class="marker-min-value">' + min_value_text + '</span>');
			$(ns_wrap).append('<span class="marker-max-value">' + max_value_text + '</span>');
			$('#' + slider_id).slider({
				min: parseInt(min_value),
				max: parseInt(max_value),
				value: select[0].selectedIndex + 1,
				range: "min",
				slide: function(event, ui){
					var inx = ui.value;
					var val = $(select).find("option:nth-child(" + inx + ")").val();
					$(select).selectBox("value", val).change();
				}
			});
			$(this).selectBox().change(function(event){
				$('#' + slider_id).slider("value", this.selectedIndex + 1);
			});
		}
		else {
			$(elt).parents(".input-wrap:first").append('<i class="i-summ-overlay"></i>');
			$(elt).change(function(event){
				$(this).siblings(".i-summ-overlay").text(number_format($(this).val(), 0, ',', ' '));
			}).focusout(function(){
				$(elt).change();
				$(this).css("color", "#FFF");
				$(this).siblings(".i-summ-overlay").show();
			}).focusin(function(){
				$(this).siblings(".i-summ-overlay").text(number_format($(this).val(), 0, ',', ' '));
				$(this).siblings(".i-summ-overlay").hide();
				$(this).css("color", "#303030");
			}).focusin().blur();
			
			var slider_id = $(elt).attr("id") + '-slider';
			var min_value = $(elt).attr("minvalue");
			var max_value = $(elt).attr("maxvalue");
			var current_value = $(elt).val();
			if (current_value == "") {
				current_value = 10000;
			}
			$(elt).parents(".input-wrap").css("position", 'relative');
			$(elt).parents(".input-wrap").parents(".form-item").addClass("with-number-slider");
			$(elt).parents(".input-wrap").append('<div class="number-slider-container"><div class="number-slider" id="' + slider_id + '"></div></div>');
			var step = 1;
			if (max_value > 1000) {
				step = 500;
			}
			if (parseInt(min_value) > 500000) {
				step = parseInt(10000);
				current_value = parseInt(5000000);
			}
			var ns_wrap = $(elt).parents(".input-wrap").find(".number-slider-container");
			$(ns_wrap).append('<span class="marker-min-value">' + number_format(min_value, 0, ',', ' ') + '</span>');
			$(ns_wrap).append('<span class="marker-max-value">' + number_format(max_value, 0, ',', ' ') + '</span>');
			
			$('#' + slider_id).slider({
				min: parseInt(min_value),
				max: parseInt(max_value),
				step: parseInt(step),
				range: "min",
				value: parseInt(current_value),
				slide: function(event, ui){
					var self_id = $(this).attr('id');
					var slider_id = self_id.replace("-slider", '');
					$("#" + slider_id).val(ui.value);
					$("#" + slider_id).change();
				}
			});
			
			$(this).change(function(event){
				$('#' + slider_id).slider("value", $(this).val());
			});
			
			$(this).numeric({
				negative: false
			});
		}
	});
});

/*zebra.js*/
			function resetZebra(){
	prev = 0;
	$(".zebra").each(function(){
		$(this).wrap('<div class="zebra-wrap"></div>');
		$(this).parents(".zebra-wrap:first").append('<i class="corner tl"></i><i class="corner tr"></i><i class="corner bl"></i><i class="corner br"></i>');
		$(this).find("th").each(function(){
			$(this).html('<span>' + $(this).html() + '</span>');
		});
	});
	
	$(".zebra tr, .zebra-tiny tr").each(function(){
		$(this).find("td:first").addClass("first-in-row");
		$(this).find("th:first").addClass("first-in-row");
		$(this).find("td:last").addClass("last-in-row");
		$(this).find("th:last").addClass("last-in-row");
		$(this).hover(function(event){
			$(this).addClass("tr-hover");
		}, function(){
			$(this).removeClass("tr-hover");
		});
		$(this).click(function(){
			$(this).toggleClass("tr-click");
		});
		
		if (prev == 1) {
			$(this).addClass("tr-dark");
			prev = 0;
		}
		else {
			$(this).addClass("tr-light");
			prev = 1;
		}
	});
}

$(document).ready(function(){
	resetZebra();
});

/*old-browser-notify.js*/
			$(document).ready(function(){
	if ($.browser.msie && parseFloat($.browser.version) < 7) {
	
		$("body").append('<div id="ibrowser-old-notify">Вы используете устаревшую версию браузера, некоторые возможности сайта недоступны, возможно сайт будет отображаться некорректно, пожалуйста, <a href="http://ie.microsoft.com/" target="_blank">обновите браузер</a>');
		
		$("#ibrowser-old-notify").css("display", 'none');
		$("#ibrowser-old-notify").css("position", 'absolute');
		$("#ibrowser-old-notify").css("left", '0');
		$("#ibrowser-old-notify").css("top", '35px');
		$("#ibrowser-old-notify").css("border-top", '1px solid #cc9966');
		$("#ibrowser-old-notify").css("border-bottom", '1px solid #cc9966');
		$("#ibrowser-old-notify").css("width", '100%');
		$("#ibrowser-old-notify").css("padding", '20px');
		$("#ibrowser-old-notify").css("line-height", '17px');
		$("#ibrowser-old-notify").css("text-align", 'center');
		$("#ibrowser-old-notify").css("background-color", '#FFFFDD');
		$("#ibrowser-old-notify").css("color", 'black');
		$("#ibrowser-old-notify").css("z-index", '99999');
		$("#ibrowser-old-notify").css("font-size", '13px');
		$("#ibrowser-old-notify").slideDown();
		
		$(window).scroll(function(event){
			$("#ibrowser-old-notify").css("top", $(window).scrollTop() + 5 + 'px');
		});
	}
});

/*overlay.js*/
			var isOverlayInstalled = false;
var windowReposTimeout = 0;

function resetEltPosition(elt, use_animate) {
	if (elt == "") {
		elt = $(".window-wrap:first");
	}
	var elt_top = (Math.round($(window).height() / 2) - Math.round($(elt).height() / 2)) + $(window).scrollTop();
	var elt_left = (Math.round($(window).width() / 2) - Math.round($(elt).width()) / 2) + $(window).scrollLeft();
	if (use_animate) {
		$(elt).animate({
			top: elt_top,
			left: elt_left
		}, 250);
	}
	else {
		$(elt).css("top", elt_top + 'px');
		$(elt).css("left", elt_left + 'px');
	}
}

function installOverlay() {
	if (isOverlayInstalled) { return true; }
	isOverlayInstalled = true;
	$("body").append('<div class="page-overlay"></div>');
	$(".page-overlay").height($(document).height());
}

function installWindow(eltId) {
	if ($("#" + eltId).length > 0) { return true; }
	$("body").append(
		['<div id="', eltId, '" class="window-wrap">',
		 '<span class="x-close" title="Закрыть">×</span>',
		 '<div class="window-content"><span class="loader">',
		 '</span></div></div>'].join(''));
	resetEltPosition($("#" + eltId), false);
}

function showWindow(elt) {
	if (elt == "") {
		elt = $(".window-wrap:first");
	}
	$(".page-overlay").fadeTo("fast", .8, function() {
		$(elt).show();
	});
}

function hideWindow(elt) {
	if (elt == "") {
		elt = $(".window-wrap:first");
	}
	$(elt).hide();
	$(".page-overlay").css("display", 'none');
}

function resizeWindow(elt, elt_width, elt_height) {
	if (elt == "") {
		elt = $(".window-wrap:first");
	}
	var elt_top = (Math.round($(window).height() / 2) -
	Math.round(elt_height / 2)) +
	$(window).scrollTop();
	var elt_left = (Math.round($(window).width() / 2) -
	Math.round(elt_width / 2)) +
	$(window).scrollLeft();
	$(elt).animate({
		top: elt_top,
		left: elt_left,
		width: elt_width,
		height: elt_height
	});
}

$(document).ready(function() {
	$(window).scroll(function(event) {
		clearTimeout(windowReposTimeout);
		windowReposTimeout = setTimeout(function() {
			$(".window-wrap").each(function() {
				resetEltPosition($(this), true);
				$(".page-overlay").height($(document).height());
			});
		}, 250);
	});
	
	$(window).resize(function() {
		clearTimeout(windowReposTimeout);
		windowReposTimeout = setTimeout(function() {
			$(".window-wrap").each(function() {
				resetEltPosition($(this), true);
				$(".page-overlay").height($(document).height());
			});
		}, 250);
	});
	
	$(".window-wrap .x-close").live("click", function(event) {
		event.preventDefault();
		var window_id = $(this).parents(".window-wrap:first").attr("id");
		hideWindow('#' + window_id);
	});
});

/*common.js*/
			$(document).ready(function(){
	$(".menu-top-dd-link").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		var expand = true;
		if ($(this).parents(".menu-top-dd-wrap:first").hasClass("menu-top-dd-wrap-clicked")) {
			expand = false;
		}
		$(".menu-top-dd-wrap").removeClass("menu-top-dd-wrap-clicked");
		if (expand) {
			$(this).parents(".menu-top-dd-wrap:first").addClass("menu-top-dd-wrap-clicked");
		}
	});
	
	$(".menu-top-dd-wrap").click(function(event){
		event.stopPropagation();
	});
	
	$(document).click(function(event){
		$(".menu-top-dd-wrap").removeClass("menu-top-dd-wrap-clicked");
	});
	
	$(".collapsible-block .ititle").click(function(event){
		event.preventDefault();
		var elt = $(this).parents(".collapsible-block:first");
		if ($(elt).hasClass("collapsible-block-expanded")) {
			$(elt).find(".icontent").slideUp("fast", function(){
				$(elt).removeClass("collapsible-block-expanded");
			});
		} else {
			$(elt).addClass("collapsible-block-expanded");
			$(elt).find(".icontent").slideDown("fast");
		}
	}).hover(function(){
		$(this).addClass("ihover");
	}, function(){
		$(this).removeClass("ihover");
	});
	
	$(".servicenet-listview .expandable h2").click(function(event){
		event.preventDefault();
		var elt = $(this).parents(".listitem:first");
		if ($(elt).hasClass("expanded")) {
			$(elt).removeClass('expanded');
		}
		else {
			$(elt).addClass('expanded');
		}
	});
	
/*	var intervalID = setInterval(function(){
		if ($('iframe#twitter-widget-0').contents().find('#twitter-widget-0').length > 0) {
			clearInterval(intervalID);
			$('iframe#twitter-widget-0').contents()
				.find('#twitter-widget-0')
				.css('background-color', '#5b5b5b');
		}
	}, 150);
	*/
});
/*region-select.js*/
			$(document).ready(function(){
	$(".widget-region-select .select-title").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		var select_region = $(this).parents(".widget-region-select:first");
		if ($(select_region).hasClass("clicked")) {
			$(select_region).removeClass("clicked");
		}
		else {
			$(select_region).addClass("clicked");
		}
	});
	
	$(document).click(function(){
		$('.widget-region-select').removeClass("clicked");
	});
});

/*controls.js*/
			$(document).ready(function(){

	$(".form-extended-controls select").each(function(){
		if (!($(this).hasClass("disable-select-box"))) {
			$(this).selectBox({
				"menuTransition": "fade",
				"menuSpeed": 150
			});
		}
	});
	/*
	$(".form-extended-controls button").each(function(){
		$(this).parent().append('<a href="/" class="button"><span class="button-content">' + $(this).html() + '</span></a>');
		var btn = $(this).parent().find(".button");
		$(this).remove();
		$(btn).click(function(event){
			event.preventDefault();
			$(this).parents("form:first").submit();
		});
	});
	*/
	$(".form-extended-controls .input").each(function(){
		if ($(this).val() != "") {
			$(this).parents(".input-wrap").find(".input-example").hide();
		}
	});
	
	$(".form-extended-controls .has-error").live("change", function(){
		$(this).removeClass('has-error');
		$(this).parents('.form-item').removeClass('has-error');
		$(this).parents('.form-item-fourth').removeClass('has-error');
		$(this).parents('.form-item').find(".error-hint").remove();
		$(this).parents('.form-item-fourth').find(".error-hint").remove();
	});
	
	
	$(".form-extended-controls input").focusin(function(){
		if ($(this).parents(".form-item").hasClass("form-item-plain")) {
			return true;
		}
		$(this).parents(".input-wrap").find(".input-example").hide();
	}).focusout(function(){
		if ($(this).parents(".form-item").hasClass("form-item-plain")) {
			return true;
		}
		if ($(this).val() == "") {
			$(this).parents(".input-wrap").find(".input-example").show();
		}
	}).change(function(){
		if ($(this).parents(".form-item").hasClass("form-item-plain")) {
			return true;
		}
		if ($(this).val() != "") {
			$(this).parents(".input-wrap").find(".input-example").hide();
		}
	});
	
	$(".form-extended-controls .input-example").click(function(){
		$(this).parents(".input-wrap").find(":input").focus();
	});
	
});

/*form-pages.js*/
			$(document).ready(function(){
	if ($('.form-use-pages').length > 0) {
		
		$('.form-use-pages .form-buttons').show();
		$('.btn-prev, .btn-submit, .btn-next').hide();
		
		$('.menu-form-pages .menu-form-pages-item').click(function(){
			if (! $('.form-use-pages .allow-collec-user-data').is(':checked')) {
				return true;
			}
			var pageNumber = $(this).find('.menu-form-pages-item-page-number').text();
			$('.menu-form-pages .menu-form-pages-item.active').removeClass('active');
			$(this).addClass('active');
			$('.form-use-pages .form-page').hide();
			$('.form-use-pages .form-page-' + (pageNumber)).show();
			$('.btn-prev, .btn-next').show();
			$('.btn-submit').hide();
			if (pageNumber == 1) {
				$('.btn-prev, .btn-submit').hide();
				$('.btn-next').show();
			}
			if (pageNumber == $('.menu-form-pages .menu-form-pages-item').length) {
				$('.btn-prev, .btn-submit').show();
				$('.btn-next').hide();
			}
		});

		if ($('.form-use-pages .allow-collec-user-data').length > 0) {
			$('.form-use-pages .allow-collec-user-data').change(function(event){
				if ($(this).is(':checked')) {
					$('.btn-prev, .btn-submit, .btn-next').attr('disabled', false);
				} else {
					$('.btn-prev, .btn-submit, .btn-next').attr('disabled', true);
				}
			}).change();
		}
		
		$('.btn-next').click(function(){
			$('.menu-form-pages .menu-form-pages-item.active').next().click();
		});
		
		$('.btn-prev').click(function(){
			$('.menu-form-pages .menu-form-pages-item.active').prev().click();
		});

		$('.form-use-pages form').submit(function(event){
			event.preventDefault();
			var form = $('.form-use-pages form');
			$.post(form.attr('action') + '&aj=1', form.serialize(), function(data){
				if (data.result == 'fail') {
					for (var i=0; i<data.errors.length; i++) {
						var e = data.errors[i];
						var inp = form.find('[name="' + e.name + '"]');
						if (inp.length == 0)
							inp = form.find('[name="' + e.name + '_dd"]');
						inp.attr('data-error-description', e.description);
						inp.parents('.form-item').addClass('has-error');
					}
					
					var firstInputWithError = form.find('.has-error:first');
					var page = firstInputWithError.parents('.form-page:first');
					var pageNumber = parseInt(page.attr('class').replace('form-page form-page-', ''))
					$('.menu-form-pages .menu-form-pages-item-'+(pageNumber-1)).click();
					setTimeout(function(){
						$('.has-error:first :input').focus();
					}, 150);
				} else {
					location = data.redirect;
				}
			}, 'json');
		});
		
		$('.has-error :input').live('focusin', function(){
			var wrap = $(this).parents('.input-wrap:first');
			if (wrap.find('.error-hint').length == 0) {
				wrap.append([
				             '<div class="error-hint">', 
				             '<span class="top-arrow"></span>',
				             '<span class="error-content">',
				             $(this).attr('data-error-description'),
				             '</span>',
				             '</div>'].join(''));
			}
			wrap.find('.error-hint').show();
		}).live('focusout', function(){
			var wrap = $(this).parents('.input-wrap:first');
			wrap.find('.error-hint').hide();
		}).live('keypress', function(){
			var wrap = $(this).parents('.input-wrap:first');
			wrap.find('.error-hint').remove();
			wrap.removeClass('has-error');
		});

		$('a.selectBox').live('click', function(event){
			var wrap = $(this).parents('.input-wrap:first');
			wrap.find('.error-hint').remove();
			wrap.removeClass('has-error');
		});
		
		$('.form-use-pages .allow-collec-user-data').attr('checked', true).change();
		$('.menu-form-pages .menu-form-pages-item:first').click();
		$('.form-use-pages .allow-collec-user-data').attr('checked', false).change();
	}
});
/*js.js*/
			$(document).ready(function(){
	
	$('.helper-widget h2').click(function(event){
		event.preventDefault();
		var parent_list = $(this).parents(".helper-listitem:first");
		if ($(parent_list).hasClass("active")) {
			$(this).parents(".helper-listitem:first").removeClass("active");
			$(parent_list).removeClass("active");
			$(parent_list).find(".helper-products-listview").slideUp("fast");
			return false;
		}
		$(this).parents(".helper-widget:first").find(".active .helper-products-listview").slideUp("fast", function(){
			$(this).parents(".helper-listitem:first").removeClass("active");
		});
		$(parent_list).find(".helper-products-listview").slideDown("fast", function(){
			$(parent_list).addClass("active");
		});
	});
	
	$('.helper-widget h2').hover(function(event){
		if ($(this).parents(".helper-listitem:first").hasClass("active")) { 
			return; 
		}
		$(this).parents(".helper-listitem:first").addClass("hover");
	}, function(event){
		$(this).parents(".helper-listitem:first").removeClass("hover");
	});
	
	var selected = $('.helper-widget .selected');
	$(selected).parents(".helper-listitem:first").find("h2:first").click();
	
	if ($(".helper-widget").find(".is-single").length == 1) {
		$(".helper-listitem:first").show();
		$(".helper-listitem:first").find(".helper-products-listview").show();
		$(".helper-listitem:first").find(".helper-products-listview").addClass("active");
	}
});

/*common.js*/
			var tid = [];
var check_loaded_id = 0;
var use_flash = false;

function receive(mess){
}

function getMovie(elt_id){
	var M$ = navigator.appName.indexOf("Microsoft") != -1;
	return (M$ ? window : document)[elt_id];
}

$(document).ready(function(){

	var playerVersion = swfobject.getFlashPlayerVersion();
	use_flash = false;
	if (playerVersion.major > 9) {
		use_flash = true;
	}
	
	$(".banner").each(function(){
		var item_width = $(this).find(".list-wrap").find(".listitem").width();
		var item_count = $(this).find(".selector .listitem").length;
		$(this).find(".list").css("width", (item_count * item_width) + 'px');
		var banner_width = $(this).width();
		var iseletor_width = $(this).find(".selector").width();
		$(this).find(".selector").append('<div class="spinner"></div>');
		$(this).find(".selector .spinner").css("left", Math.round((iseletor_width - 42) / 2));
		$(this).find(".selector").css("left", Math.round(banner_width / 2) - Math.round(iseletor_width / 2) + 'px');
	});
	
	$(".banner .list-wrap .listitem").each(function(){
		var image_url = $(this).find("span:first").css("background-image");
		var elt = $(this);
		$(elt).find(".isready").text(0);
		image_url = image_url.replace('url("', '');
		image_url = image_url.replace('url(', '');
		image_url = image_url.replace('")', '');
		image_url = image_url.replace(')', '');
		$("<img />").load(function(event){
			$(elt).find(".isready").text("1");
		}).attr("src", image_url);
	});
	
	function fadeInOne(elt, do_first){
		if ($(elt).find(".o0").length > 0) {
			if (do_first) {
				var l = $(elt).find(".o0").length - 1;
				$(elt).find(".o0").eq(l).animate({
					opacity: .2,
					marginTop: 5
				}, 50, function(){
					$(this).removeClass("o0");
					$(this).animate({
						opacity: 1,
						marginTop: 0
					}, 200);
					fadeInOne(elt, do_first);
				});
			}
			else {
				var l = $(elt).find(".o0").length - 1;
				$(elt).find(".o0").eq(0).animate({
					opacity: .2,
					marginTop: 5
				}, 50, function(){
					$(this).removeClass("o0");
					$(this).animate({
						opacity: 1,
						marginTop: 0
					}, 200);
					fadeInOne(elt, do_first);
				});
			}
			if ($(elt).parents(".listitem:first").hasClass("use-custom-animation")) {
				$(elt).parents(".listitem:first").startCustomAnimation();
			}
			$(elt).parents(".listitem:first").find('.custom-animation-elt-target-link').css('display', 'none');
		} else {
			$(elt).parents(".listitem:first").addClass("show-play-btn");
			if ($(elt).parents(".listitem:first").hasClass("use-custom-animation")) {
				$(elt).parents(".listitem:first").find('.custom-animation-elt-target-link').css('display', 'block');
				$(elt).parents(".listitem:first").startCustomAnimation();
			}
			if ($(elt).parents(".listitem:first").hasClass("use-advanced-bg")) {
				var bgUrl = $(elt).parents('.listitem:first').find('.bg-url').text();
				$(elt).parents('.banner:first').css('background-image', 'url(' + bgUrl + ')');
			}
			if (
				(use_flash) 
				&& ($(elt).parents(".listitem:first").hasClass("use-flash"))
			) {
				$(elt).parents(".listitem:first").addClass("show-flash");
				var movie_id = $(elt).parents(".listitem:first").find("object").attr("id");
				getMovie(movie_id).sendRestartMovie();
				return true;
			}
		}
	}
	
	function checkIsMovieLoaded(elt){
		if ($(elt).parents(".listitem:first").find("object").length == 0) { 
			return false; 
		}
		var obj = $(elt).parents(".listitem:first").find("object");
		var movie_id = $(obj).attr("id");
		var movie = getMovie(movie_id);
		if (!((typeof movie == 'object') || (typeof movie == 'function'))) { return false; }
		return true;
	}
	
	$(".banner .selector .listitem").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		var bannerId = $(this).parents('.banner:first').attr('id');
		resetInterval(bannerId);
		if ($(this).hasClass("first-start")) {
			$(this).removeClass("first-start");
			$(this).addClass("active");
			var item_number = $(this).find(".itemnumber").text() - 1;
			var a_item = $(this).parents(".banner:first").find(".list").find(".i-" + (item_number + 1));
			var a_listitem = $(a_item).parents(".listitem:first");
			if ($(a_listitem).hasClass("use-flash")) {
				$(a_listitem).addClass("show-flash");
			}
			if ($(a_listitem).hasClass("use-video")) {
				$(a_listitem).addClass("show-play-btn");
			}
			if ($(a_listitem).hasClass("use-custom-animation")) {
				$(a_listitem).startCustomAnimation();
			}
			if ($(a_listitem).hasClass("use-advanced-bg")) {
				var bgUrl = $(a_listitem).find('.bg-url').text();
				$(a_listitem).parents('.banner:first').css('background-image', 'url(' + bgUrl + ')');
			}
		}
		if ($(this).hasClass("active")) { return true; }
		var slideshow = $(this).parents(".banner:first");
		var slide_item_width = $(slideshow).find(".list-wrap .listitem").width();
		var active_number = $(slideshow).find(".selector:first").find(".active").find(".itemnumber").text();
		$(slideshow).find(".selector:first").find(".active").removeClass("active");
		var elt = $(this);
		var item_number = $(this).find(".itemnumber").text() - 1;
		var do_first = false;
		if ((item_number + 1) < active_number) {
			do_first = true;
		}
		$(slideshow).find(".list-wrap:first").find(".prev").fadeTo(1, 1);
		$(slideshow).find(".list-wrap:first").find(".prev")
			.css(
				'background-image', 
				$(slideshow).find(".i-" + active_number).find("span:first").css("background-image"));
		$(slideshow).find(".show-flash").removeClass("show-flash");
		$(slideshow).find(".show-play-btn").removeClass("show-play-btn");
		$(slideshow).find(".list:first").fadeTo(1, 0, function(){
			$(slideshow).find(".list:first").css("margin-left", -(item_number * slide_item_width));
			var a_item = $(slideshow).find(".list:first").find(".i-" + (item_number + 1));
			$(a_item).find("span")
				.css("opacity", 0)
				.css("margin-top", '20px')
				.addClass("o0");
			$(slideshow).find(".list").fadeTo(1, 1, function(){
				fadeInOne($(slideshow).find(".list").find(".i-" + (item_number + 1)), do_first);
				$(elt).addClass("active");
			});
		});
	});
	
	$(".banner .use-video").each(function(){
		$(this).append('<span class="btn-start-video"></span>');
	});
	
	$('.banner .btn-next, .banner .btn-prev').hover(function(){
		$(this).fadeTo('fast', 1);
	}, function(){
		$(this).fadeTo('fast', .5);
	}).fadeTo('fast', .5);
	
	$('.banner .btn-next').click(function(event){
		event.preventDefault();
		var slideshow = $(this).parents(".banner:first"),
			selector = $(slideshow).find(".selector:first");

		if ($(selector).find('.active').next().hasClass('listitem')) {
			$(selector).find('.active').next().click();
		} else {
			$(selector).find('.listitem').first().click();
		}
	});
	
	$('.banner .btn-prev').click(function(event){
		event.preventDefault();
		var slideshow = $(this).parents(".banner:first"),
			selector = $(slideshow).find(".selector:first");

		if (
				$(selector).find('.active').prev().length > 0 
				&& $(selector).find('.active').prev().hasClass('listitem')
		) {
			$(selector).find('.active').prev().click();
		} else {
			$(selector).find('.listitem').last().click();
		}
	});

	
	$(".banner .btn-start-video").hover(function(event){
		$(this).addClass("btn-start-video-hover");
	}, function(event){
		$(this).removeClass("btn-start-video-hover");
	});
	
	function resetInterval(bannerId){
		clearInterval(tid[bannerId]);
		tid[bannerId] = setInterval(function(){
			if ($('#' + bannerId).hasClass("disable-slideshow")) { 
				return true; 
			}
			if ($('#' + bannerId + " .selector .listitem.active").index() + 1 
					== $('#' + bannerId + " .selector .listitem").length) {
				$('#' + bannerId + " .selector .listitem:first").click();
			} else {
				$('#' + bannerId + " .selector .listitem.active").next().click();
			}
		}, 7000);
	}
	
	function checkLoaded(){
		check_loaded_id = setInterval(function(){
			var is_loaded = true;
			$(".banner .list-wrap .listitem").each(function(){
				if ($(this).find(".isready").text() != 1) {
					is_loaded = false;
				}
			});
			if (use_flash) {
				$(".banner .use-flash").each(function(){
					if (!checkIsMovieLoaded($(this).find("a"))) {
						is_loaded = false;
					}
				});
			}
			if (is_loaded) {
				clearInterval(check_loaded_id);
				$(".banner").removeClass("is-loading");
				$(".banner .selector .listitem:first").addClass("first-start");
				$('.banner').each(function(){
					$(this).find('.selector .listitem:first').click();
				});
			}
		}, 100);
	}
	
	checkLoaded();
	
	
	$(".banner .btn-start-video").live('click', function(event){
		event.preventDefault();
		event.stopPropagation();
		installOverlay();
		var ibanner = $(this).parents(".ibanner:first");
		$(ibanner).addClass("disable-slideshow");
		
		if ($("#window-video").length == 0) {
			installWindow("window-video");
			resizeWindow("#window-video", 680, 620);
			$("#window-video .window-content").html('<div class="title"></div><div class="player"></div><div class="description"></div>');
			$("#window-video .x-close").click(function(event){
				$("#window-video").find(".window-content .player iframe").hide();
				$("#window-video").find(".window-content .player").html("");
				$(ibanner).removeClass("disable-slideshow");
			});
		}
		var pl_item = $(this).parents(".listitem:first");
		var pl_iframe = '<iframe width="640" height="480" src="' + $(pl_item).find(".video-url").text() + '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
		$("#window-video .window-content .title").html($(pl_item).find(".title").html());
		$("#window-video .window-content .description").html("");
		var btn_product = '<a class="button" href="' + $(pl_item).find("a").attr("href") + '"><span class="button-content">' + $(pl_item).find(".title-product").html() + '</span></a>';
		$("#window-video .window-content .description").append(btn_product);
		if ($(pl_item).find(".url-group").text() != '') {
			var btn_product_group = '<a class="button" href="' + $(pl_item).find(".url-group").text() + '"><span class="button-left"></span><span class="button-content">' + $(pl_item).find(".title-group").text() + '<span class="button-shadow"><img src="/i/public/btn-grey-cool-shadow.png" alt="" /></span></span><span class="button-right"></span></a>';
			$("#window-video .window-content .description").append(btn_product_group);
		}
		$("#window-video .window-content").find(".player").html(pl_iframe);
		showWindow("#window-video");
		resetEltPosition("#window-video", false);
	});
	
	$('.banner .btn-apply').hover(function(){
		$(this).addClass('btn-apply-hover');
	}, function(){
		$(this).removeClass('btn-apply-hover');
	}).click(function(event){
		event.preventDefault();
		location = $(this).attr('data-url');
	});
});
/*js.js*/
			$(document).ready(function() {
	
	$(".globaltabs .globaltabs-tabs-list .listitem a").click(function(event) {
		event.preventDefault();
		$(".globaltabs .globaltabs-tabs-list .active").removeClass("active");
		$(".globaltabs .page-active").removeClass("page-active");
		$(".globaltabs .globaltabs-tabs-list .listitem-active").removeClass("listitem-active");
		$(this).addClass("active");
		$(this).parents('div:first').addClass('listitem-active');
		var thisId = $(this).parents('div:first').attr("id").split("-");
		var htmlId = 'globaltabs-tab-content-' + thisId[1];
		$(".globaltabs-content").addClass('globaltabs-content-active');
		$('#' + htmlId).addClass("page-active");
	});
	
	$(".globaltabs .close").click(function(event){
		event.preventDefault();
		$(".globaltabs .globaltabs-tabs-list .active").removeClass("active");
		$(".globaltabs .page-active").removeClass("page-active");
		$(".globaltabs-content").removeClass('globaltabs-content-active');
	});
	
	$('.globaltabs').click(function(event){
		event.stopPropagation();
	});
	
	$('body').click(function(){
		$(".globaltabs .close").click();
	});
//	$(".globaltabs-tabs-list .listitem:first").find('a').click();
});

/*js.js*/
			$(document).ready(function() {
	$("#icurrency-converter-toggle").click(function(event) {
		event.preventDefault();
		event.stopPropagation();
		$("#icurrency_converter").toggleClass("expanded");
	});
	
	$("#icurrency_converter input, #icurrency_converter select").change(function(event) {
		event.preventDefault();
		event.stopPropagation();
		var c_value = $(".vfrm input").val();
		var c_type = $(".vfrm select").val();
		
		$("#icurrency_converter .vresults div").each(function() {
			if ($(this).hasClass('i' + c_type)) {
				$(this).hide();
			} else {
				$(this).show();
				var current_curr = $(this).find("span.ct").text();
				var target_curr = c_type;
				var indx = "";
				if (current_curr == "rur") {
					indx = $("div.currency ." + c_type + " .we_buy").text();
					indx = indx.replace(",", ".");
				} else {
					if (c_type == 'rur') {
						i1 = 1;
					}
					else {
						i1 = $("div.currency ." + c_type + " .we_buy").text();
						i1 = i1.replace(",", ".");
					}
					i2 = $("div.currency ." + current_curr + " .we_buy").text();
					i2 = i2.replace(",", ".");
					indx = i1 / i2;
				}
				var x = c_value * indx;
				var str = x.toFixed(2);
				$(this).find("span.result").text(str.replace(".", ","));
			}
		});
	}).change();
	
	$('#icurrency_converter input').keyup(function(){
		$(this).change();
	});
});

/*js.js*/
			var p_repos_timeout = 0;
var p_isVideoShowInstalled = false;

$(document).ready(function(){
	$(".ibanner .btn-start-video").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		installOverlay();
		var ibanner = $(this).parents(".ibanner:first");
		$(ibanner).addClass("disable-slideshow");
		
		if ($("#window-video").length == 0) {
			installWindow("window-video");
			resizeWindow("#window-video", 680, 620);
			$("#window-video .window-content").html('<div class="title"></div><div class="player"></div><div class="description"></div>');
			$("#window-video .x-close").click(function(event){
				$("#window-video").find(".window-content .player iframe").hide();
				$("#window-video").find(".window-content .player").html("");
				$(ibanner).removeClass("disable-slideshow");
			});
		}
		var pl_item = $(this).parents(".listitem:first");
		var pl_iframe = '<iframe width="640" height="480" src="' + $(pl_item).find(".video-url").text() + '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
		$("#window-video .window-content .title").html($(pl_item).find(".title").html());
		$("#window-video .window-content .description").html("");
		var btn_product = '<a class="button" href="' + $(pl_item).find("a").attr("href") + '"><span class="button-left"></span><span class="button-content">' + $(pl_item).find(".title-product").html() + '<span class="button-shadow"><img src="/i/public/btn-cool-shadow.png" alt="" /></span></span><span class="button-right"></span></a>';
		$("#window-video .window-content .description").append(btn_product);
		var btn_product_group = '<a class="button btn-grey" href="' + $(pl_item).find(".url-group").text() + '"><span class="button-left"></span><span class="button-content">' + $(pl_item).find(".title-group").text() + '<span class="button-shadow"><img src="/i/public/btn-grey-cool-shadow.png" alt="" /></span></span><span class="button-right"></span></a>';
		$("#window-video .window-content .description").append(btn_product_group);
		$("#window-video .window-content").find(".player").html(pl_iframe);
		showWindow("#window-video");
		resetEltPosition("#window-video", false);
	});
	
	$(".listview-video .listitem").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		installOverlay();
		var elt = $(this);
		if ($("#window-video").length == 0) {
			installWindow("window-video");
			resizeWindow("#window-video", 680, 620);
			$("#window-video .window-content").html('<div class="title"></div><div class="player" id="window-player"></div><div class="description"></div>');
			$("#window-video .x-close").click(function(event){
				$("#window-video").find(".window-content .player iframe").hide();
				$("#window-video").find(".window-content .player").html("");
			});
		}
		
		if ($(elt).find(".use-internal-player").text() == 1) {
			$f("window-player", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
				clip: {
					url: $(elt).find(".video-url").text(),
					autoPlay: true
				}
			});
			$("#window-video .window-content .title").html($(elt).find("h2").text());
			$("#window-video .window-content .description").html($(elt).find(".description").html());
		}
		else {
			var pl_iframe = '<iframe width="640" height="480" src="' + $(elt).find(".video-url").text() + '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
			$("#window-video .window-content .title").html($(elt).find("h2").text());
			$("#window-video .window-content .description").html($(elt).find(".description").html());
			$("#window-video .window-content").find("#window-player").html(pl_iframe);
		}
		showWindow("#window-video");
		resetEltPosition("#window-video", false);
	}).hover(function(event){
		$(this).addClass("listitem-hover");
	}, function(event){
		$(this).removeClass("listitem-hover");
	});
	

	$(".video-custom-player").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		installOverlay();
		var elt = $(this);
		if ($("#window-video").length == 0) {
			installWindow("window-video");
			resizeWindow("#window-video", 680, 620);
			$("#window-video .window-content").html('<div class="title"></div><div class="player" id="window-player"></div><div class="description"></div>');
			$("#window-video .x-close").click(function(event){
				$("#window-video").find(".window-content .player iframe").hide();
				$("#window-video").find(".window-content .player").html("");
			});
		}
		
		if ($(elt).find(".use-internal-player").text() == 1) {
			$f("window-player", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
				clip: {
					url: $(elt).find(".video-url").text(),
					autoPlay: true
				}
			});
			$("#window-video .window-content .title").html($(elt).find("h2").text());
			$("#window-video .window-content .description").html($(elt).find(".description").html());
		}
		else {
			var pl_iframe = '<iframe width="640" height="480" src="' + $(elt).find(".video-url").text() + '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
			$("#window-video .window-content .title").html($(elt).find("h2").text());
			$("#window-video .window-content .description").html($(elt).find(".description").html());
			$("#window-video .window-content").find("#window-player").html(pl_iframe);
		}
		showWindow("#window-video");
		resetEltPosition("#window-video", false);
	}).hover(function(event){
		$(this).addClass("listitem-hover");
	}, function(event){
		$(this).removeClass("listitem-hover");
	});
	
});

/*js.js*/
			$(document).ready(function(){

	$('.faq-listview h2').addClass("clickable");
	
	function hideActive(){
		$(".faq-listview .expanded .answer").hide();
		$(".faq-listview .expanded").removeClass("expanded");
	}
	
	$('.faq-listview h2 a').click(function(event){
		event.preventDefault();
		var parent_li = $(this).parents("li");
		if ($(parent_li).hasClass("expanded")) {
			$(parent_li).find(".answer").slideUp("fast");
			$(parent_li).removeClass("expanded");
		}
		else {
			var loadto = $(this).parents("li").find(".answer");
			var elt = $(this);
			if ($(loadto).text() == "") {
				$(parent_li).addClass("preload");
				$(loadto).load($(this).attr("href") + "&aj=1", function(){
					$(parent_li).removeClass("preload");
					$(parent_li).find(".answer").slideDown("fast");
					$(parent_li).addClass("expanded");
				});
			}
			else {
				$(parent_li).removeClass("preload");
				$(parent_li).find(".answer").slideDown("fast");
				$(parent_li).addClass("expanded");
				return false;
			}
		}
	});
	
	if ($('.faq-listview h2 a').length > 0) {
		var first_a = $('.faq-listview h2 a:first');
		if (!($(first_a).parent().parent().hasClass('expanded'))) {
			$(first_a).click();
		}
	}
});

$(document).ready(function(){
	$('.show-faq-form').click(function(event){
		event.preventDefault();
		var parentul = $('.show-faq-form').parents("ul:first");
		$(parentul).find("li").removeClass('selected');
		if ($(this).hasClass("selected")) {
			$(this).removeClass("selected");
			$(".faq-form-wrap").slideUp("fast");
		}
		else {
			$(this).addClass("selected");
			$(".faq-form-wrap").slideDown("fast");
		}
	});
	
	$("#btn-cancel").click(function(event){
		event.preventDefault();
		document.location = $(this).parents('form:first').find(".cancel-url").text();
	});
});

/*js.js*/
			$(document).ready(function() {
	$('.persons-listview .listitem').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});
});

/*calc.js*/
			function number_format(number, decimals, dec_point, thousands_sep) {
	var i, j, kw, kd, km;
	if (isNaN( decimals = Math.abs(decimals))) {
		decimals = 2;
	}
	if (dec_point == undefined) {
		dec_point = ",";
	}
	if (thousands_sep == undefined) {
		thousands_sep = ".";
	}
	i = parseInt( number = (+number || 0).toFixed(decimals)) + "";
	if (( j = i.length) > 3) {
		j = j % 3;
	} else {
		j = 0;
	}
	km = ( j ? i.substr(0, j) + thousands_sep : "");
	kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
	kd = ( decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
	return km + kw + kd;
}

/*calc-inline.js*/
			$(document).ready(function() {
	var input_changed_timeout_id = 0;
	var send_request_timeout_id = 0;

	function reloadCalcData() {
		clearTimeout(input_changed_timeout_id);
		clearTimeout(send_request_timeout_id);
		send_request_timeout_id = setTimeout(function() {
			$("#icalc-data-wrap").addClass("is-loading");
			var send_url = $("#icalc-form").attr("action") + '&aj=1';
			var post_data = $("#icalc-form").serialize();
			$.post(send_url, post_data, function(data) {
				$("#icalc-data-wrap").removeClass("is-loading");
				$("#icalc-data-wrap").html(data);
				$("#icalc-data-wrap").append('<span class="spinner"></span>');
				resetZebra();
			});
		}, 500);
	}


	$("#icalc-data-wrap .product-link").live("click", function(event) {
		event.preventDefault();
	});

	$("#icalc-data-wrap .sub a").live("click", function(event) {
		event.stopPropagation();
	});

	$("#icalc-form :input").change(function() {
		if ($(this).val() != $(this).attr("lv")) {
			reloadCalcData();
			$(this).attr("lv", $(this).val());
		}
	});

	function setChanged(elt) {
		if ($(elt).attr("pv") != $(elt).val()) {
			$(elt).change();
		}
	}


	$("#icalc-form :input").keydown(function() {
		clearTimeout(input_changed_timeout_id);
		clearTimeout(send_request_timeout_id);
		var elt = $(this);
		$(elt).attr("pv", $(elt).val());
		input_changed_timeout_id = setTimeout(function() {
			setChanged(elt);
		}, 500);
	});

	$("#icalc-form").submit(function(event) {
		event.preventDefault();
		reloadCalcData();
	});
});

/*calc-inline-deposit.js*/
			$(document).ready(function(){

	function resetMinMaxValues(params){
		var ns_wrap = $("#" + params["slider_container"]).parents(".number-slider-container");
		$(ns_wrap).find(".marker-min-value").html(number_format(params["min_value"], 0, ',', ' ') + ' ' + params["currency"] + '<span class="data-field">' + params["min_value"] + '</span>');
		$(ns_wrap).find(".marker-max-value").html(number_format(params["max_value"], 0, ',', ' ') + ' ' + params["currency"] + '<span class="data-field">' + params["max_value"] + '</span>');
		
		$("#" + params["slider_container"]).slider("option", "min", parseInt(params["min_value"]));
		var slider_step = 1;
		if (params["min_value"] > 499) {
			slider_step = 500;
		}
		if (params["min_value"] > 1000) {
			slider_step = 1000;
		}
		if (params["min_value"] > 5000) {
			slider_step = 5000;
		}
		if (params["min_value"] > 50000) {
			slider_step = 10000;
		}
		if (params["min_value"] > 500000) {
			slider_step = 100000;
		}
		$("#" + params["slider_container"]).slider("option", "step", parseInt(slider_step));
		$("#" + params["slider_container"]).slider("option", "max", parseInt(params["max_value"]));
		if (parseInt($("#isumm").val()) > parseInt(params["max_value"])) {
			$("#isumm").val(parseInt(params["max_value"]));
			$("#isumm").change().blur();
		}
		if (parseInt($("#isumm").val()) < parseInt(params["min_value"])) {
			$("#isumm").val(parseInt(params["min_value"]));
			$("#isumm").change().blur();
		}
		$("#" + params["slider_container"]).slider("option", "value", parseInt($("#isumm").val()));
	}
	
	function reloadMinMaxValues(elt){
		var target_url = $(elt).parents("form:first").attr("action") + '&get_min_max_for_valute=1&vid=' + $("#ivalute").val() + '&period=' + $("#iperiod").val();
		var slider_container = $(elt).parents(".form-item").find(".number-slider").attr("id");
		$.getJSON(target_url, function(data){
			data["currency"] = $("#ivalute").find("option:selected").text();
			data["slider_container"] = slider_container;
			resetMinMaxValues(data);
		});
	}
	
	$("#ivalute").change(function(event){
		var elt = $(this).parents(".form-item").find(".use-number-slider");
		reloadMinMaxValues(elt);
	}).change().blur();
});

/*js.js*/
			/**
 * Map show
 */
$(document).ready(function(){
	$(".mapholder .dots").css("display", 'block');
	
	$(".mapholder .dots span.icon").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		document.location = $(this).siblings("span.url").text();
	});
	
	$(".mapholder .dots span.icon").hover(function(event){
		$(this).css("background-position", 'left bottom');
		$(this).parent(".dot").css("z-index", '10000');
		if (false == ($(this).parent(".dot").hasClass("dot_always_show_label"))) {
			$(this).parent(".dot").find(".label").css("display", 'block');
		}
	}, function(event){
		$(this).parent(".dot").css("z-index", '1000');
		if (false == ($(this).parent(".dot").hasClass("dot_always_show_label"))) {
			$(this).parent(".dot").find(".label").css("display", 'none');
		}
		$(this).css("background-position", 'left top');
	});
	
	$(".mapholder .dots span.icon").each(function(){
		$(this).css("cursor", 'pointer');
		$(this).attr("title", $(this).siblings("span.ialt").text());
	});
});

/*callback.js*/
			$(document).ready(function(){

	$("#head-misc .callback").click(function(event){
		event.preventDefault();
		event.stopPropagation();
		
		installOverlay();
		if ($("#window-callback").length == 0) {
			installWindow("window-callback");
			resizeWindow("#window-callback", 600, 340);
			
			$("#window-callback .window-content").load("/about/callback/?aj=1", function(data){
				$("#window-callback .window-content input:first").focus();
				$("#window-callback .window-content select").selectBox({
					"menuTransition": "fade",
					"menuSpeed": 150
				});
				
			});
		}
		showWindow("#window-callback");
		resetEltPosition("#window-callback", false);
	});

	$("#window-callback .window-content .error-wrap").live("click", function(event){
		$(this).fadeTo("fast", 0, function(){
			$(this).hide();
		});
	});
	
	var hide_time_out = 0;
	var is_sending = false;
	$("#window-callback .btn-submit").live("click", function(event){
		event.preventDefault();
		event.stopPropagation();
		var form = $("#window-callback .window-content form");
		if (is_sending) { return true; }
		is_sending = true;
		$(form).append('<input type="hidden" name="doc_url" value="' + document.location + '" /> ');
		var form_data = $(form).serialize();
		var form_url = $(form).attr("action");
		$.post(form_url, form_data, function(data){
			if (data[0] == '{') {
				data = $.parseJSON(data);
				if (data["result"] == 1) {
					var load_url = data["redirect"];
					$("#window-callback .window-content").load(load_url, function(data){
						is_sending = false;
					});
				}
				else {
					is_sending = false;
					clearTimeout(hide_time_out);
					var err = data["error_text"];
					if (err != "undefined") {
						$("#window-callback .window-content .error-wrap").html(data["error_text"]);
						$("#window-callback .window-content .error-wrap").fadeTo("fast", 1);
						hide_time_out = setTimeout(function(){
							$("#window-callback .window-content .error-wrap").click();
						}, 5000);
					}
					var err = data["errors"];
					if (err != "undefined") {
						var err = data["errors"];
						for (var i = 0; i < err.length; i++) {
							$('#form-item-wrap-for-' + err[i]["id"]).addClass("has-error");
						}
					}
				}
			}
			else {
				is_sending = false;
				$("#window-callback .window-content").html(data);
				$("#window-callback .window-content input").focus();
			}
		});
	});
});
