$(document).ready(function() {
	
	$("ul.top_menu li:eq(0)").wrap('<td class="studio"></td>');
	$("ul.top_menu li:eq(1)").wrap('<td class="data"></td>');
	$("ul.top_menu li:eq(2)").wrap('<td class="system"></td>');
	$("ul.top_menu td").wrapAll('<tr></tr>').parent().wrap('<table></table>');
	$("ul.top_menu .active").append('<div class="shadow"></div>').parent().addClass('active_td');
	
	$(".header_links li:last-child").addClass('last');
	
	$(".social li:last-child").after('<br clear="all" />');
	
	$(".map_small_block").has('.map_big_block').css('zIndex','900');
	$(".map_big_block").append('<div class="map_big_block_lt"></div><div class="map_big_block_rt"></div><div class="map_big_block_lb"></div><div class="map_big_block_rb"></div><div class="map_big_block_t"></div><div class="map_big_block_b"></div><div class="map_big_block_l"></div><div class="map_big_block_r"></div><div class="close"></div>');
	
	$(".map_big_block .close").click(function(){$(this).parent().fadeOut(300); return false;});
	
	$(window).resize(function(){
		do_rearrange();
	});
	$(window).load(function(){
		do_rearrange();
	});
	
	//Вставляем телефоны в шапку
	$(".studio").children("li").append("<div class='phone_in_menu'>+7(495) 988-30-40</div>");
	$(".data").children("li").append("<div class='phone_in_menu'>+7(495) 988-30-41</div>");
	$(".system").children("li").append("<div class='phone_in_menu'>+7(495) 988-30-42</div>");
	
	
	//Увеличивание карты на странице "Дата-центр"
	var codeMap;
	var scrollTop;
	var heightWindow;
	var heightMap = 416;
	var topPos;
	
	var clickZoomMap = function() {
		$('.zoom_map, .map_small').unbind('click');
		$('.close').unbind('click');
		
		$('.code_map_pos').remove();
		
		codeMap = $(this).parent().next('div').html();
		scrollTop = $(window).scrollTop();
		heightWindow = $(window).height();
		topPos = ((heightWindow - heightMap) / 2) + scrollTop;
		
		$('body').append('<div style="top:' + topPos + 'px;" class="code_map_pos">' + codeMap + '<div class="map_big_block_lt"></div><div class="map_big_block_rt"></div><div class="map_big_block_lb"></div><div class="map_big_block_rb"></div><div class="map_big_block_t"></div><div class="map_big_block_b"></div><div class="map_big_block_l"></div><div class="map_big_block_r"></div><div class="close"></div></div>');
		
		$('.zoom_map, .map_small').bind('click', clickZoomMap);
		$('.close').bind('click', closeClickZoomMap);
		return false;
	}
	
	var closeClickZoomMap = function() {
		$('.close').unbind('click');
		$('.zoom_map, .map_small').unbind('click');
		
		$(this).parent().remove();
		
		$('.zoom_map, .map_small').bind('click', clickZoomMap);
		return false;
	}
	
	$('.zoom_map, .map_small').bind('click', clickZoomMap);
	//Конец (Увеличивание карты на странице "Дата-центр")
	
	
	
	
	
	function do_rearrange (){
		$("ul.reasons li.closer").remove();
		$("ul.reasons").removeClass('reasons_col3, reasons_col4');
		$("ul.portfolio").removeClass('portfolio_col4, portfolio_col5');
		var colsNum=Math.floor($("ul.reasons").width()/(226));
		var colsNum2=Math.floor($("body").width()/(237));
		if (colsNum<4) {$("ul.reasons").addClass('reasons_col3'); $("ul.reasons li:nth-child(3n)").after('<li class="closer"></li>')}
		else {$("ul.reasons").addClass('reasons_col4'); $("ul.reasons li:nth-child(4n)").after('<li class="closer"></li>')}
		if (colsNum2<5) {$("ul.portfolio").addClass('portfolio_col4')}
		else {$("ul.portfolio").addClass('portfolio_col5')}
	}
	
	
	//Открыть и закрыть скрытый раздел в разделе "веб-студия"
	$('#web_open').click(function() {
		$(this).remove();
		$('#span_hide').show();
		return false;
	});
	
	//Открываем список всех клиентов в разделе "О компании"
	var clientsTmp = 1;
	$('#all_clients').click(function() {
		if (clientsTmp == 1) {
			$('#clients_brief').hide();
			$('#clients_full').show();
			$('#all_clients').children('span').html('Скрыть список');
			$(this).css('background', 'url(/images/about/arrow_2.jpg) no-repeat 0px 4px');
			clientsTmp = 0;
		}
		else {
			$('#clients_brief').show();
			$('#clients_full').hide();
			$('#all_clients').children('span').html('Весь список');
			$(this).css('background', 'url(/images/about/arrow.jpg) no-repeat 0px 4px');
			clientsTmp = 1;
		}
	});
	
	
	//Страница "colocation" наведение на значок справки
	$('.colo_info_2_img').mouseover(function() {
		$('#colo_plashka').show();
	});
	$('.colo_info_2_img').mouseout(function() {
		$('#colo_plashka').hide();
	});
	
	
	//Растягиваем блоки в партнерах
	var widthWindow = $(window).width();
	if (widthWindow > 1200) {
		$('.partners_icon_block').css('width', '30%');
		$('.partners_icon_block2').css('width', '24%');
	}
	else {
		$('.partners_icon_block1').css('width', '255px');
		$('.partners_icon_block2').css('width', '175px');
		$('.partners_icon_block3').css('width', '240px');
	}
	
	$(window).resize(function() {
		widthWindow = $(window).width();
		if (widthWindow > 1200) {
			$('.partners_icon_block').css('width', '30%');
			$('.partners_icon_block2').css('width', '24%');
		}
		else {
			$('.partners_icon_block1').css('width', '255px');
			$('.partners_icon_block2').css('width', '175px');
			$('.partners_icon_block3').css('width', '240px');
		}
	});
	
	//активная вкладка второго главного меню
	var widthVkl2 = $('#menu_top_active').width();
	var heightVkl2 = $('#menu_top_active').height();
	$('#menu_top_active_plashka').css({'width': (widthVkl2 + 10) + 'px', 'height': (heightVkl2 + 10) + 'px'});
	
	//активная вкладка первого второстепенного меню
	var widthVklVtor1 = $('#menu_top_active_vtor').width();
	var heightVklVtor1 = $('#menu_top_active_vtor').height();
	if ($.browser.msie && $.browser.version <= '7.0') {
		$('#menu_top_active_vtor_plashka').css({'width': (widthVklVtor1 + 10) + 'px', 'height': (heightVklVtor1 + 10) + 'px', 'top': '-2px'});
	}
	else {
		$('#menu_top_active_vtor_plashka').css({'width': (widthVklVtor1 + 10) + 'px', 'height': (heightVklVtor1 + 10) + 'px'});
	}
	
	//активная вкладка второго второстепенного меню
	var widthVklVtor2 = $('#menu_top_active_vtor2').width();
	var heightVklVtor2 = $('#menu_top_active_vtor2').height();
	if ($.browser.msie && $.browser.version <= '7.0') {
		$('#menu_top_active_vtor2_plashka').css({'width': (widthVklVtor2 + 10) + 'px', 'height': (heightVklVtor2 + 10) + 'px', 'top': '-2px'});
	}
	else {
		$('#menu_top_active_vtor2_plashka').css({'width': (widthVklVtor2 + 10) + 'px', 'height': (heightVklVtor2 + 10) + 'px'});
	}
	
	//Разделитель между верхними меню для ие 6 и 7
	if ($.browser.msie && $.browser.version <= '7.0') {
		$('#menu_top_razdelitel').css('height', '0px');
	}
	
	
	//Для всех таблиц для первых ячеек делаем выравниваем по топу
	$('.colo_table').children('tbody').children('tr').each(function() {
		$(this).children('td:eq(0)').css('vertical-align', 'top');
	});
	
	
	//Страница feedback, Карты
	var idMap;
	var mapCode;
	
	clickMaps = function() {
		$('.maps_span').unbind('click');
		$('.maps_span').bind('click', clickMaps);
		$(this).unbind('click');
		idMap = $(this).attr('id');
		idMap = idMap.substr(10, 1);		
		mapCode = $('.maps_span_' + idMap).html();
		$('#map').html(mapCode);
		$('.span_block').removeClass('maps_span_active');
		$(this).parent().addClass('maps_span_active');
		$('.maps_span').css({'color': '#285da2', 'border-bottom': '1px dashed #285da2'});
		$(this).css({'color': '#000', 'border-bottom': 'none'});
	}
	
	
	$('.maps_span').bind('click', clickMaps);
	//Конец (Страница feedback, Карты)
	
	
	//Появление формы обратной связи на странице feedback
	$('#feedback_open_form').click(function() {
		$('#feedback_form').show();
	});
	$('#feedback_form_close').click(function() {
		$('#feedback_form').hide();
		return false;
	});
	//Конец (Появление формы обратной связи на странице feedback)
	
	
	//Показать и скрыть телефоны на фидбеке
	var peremFeedback = 1;
	$('#show_phone_feedback').click(function() {
		if (peremFeedback == 1) {
			$('#phones_block').show();
			$('#show_phone_feedback').html('Скрыть телефоны');
			peremFeedback = 0;
		}
		else {
			$('#phones_block').hide();
			$('#show_phone_feedback').html('Показать телефоны');
			peremFeedback = 1;
		}
	});
	//Закрыть (Показать и скрыть телефоны на фидбеке)
	
	//КАЛЬКУЛЯТОР
	var idCalc;
	$('.calc_top_plashka').click(function() {
		var elemTop = $('#calc').offset().top;
		var winTop = $(window).scrollTop();
		elemTop = elemTop - winTop - 30;
		$('html, body').animate({
			scrollTop: '+=' + elemTop + 'px'
		}, 600);
		
		$('.calc_top_plashka').removeClass('calc_top_active');
		$('.calc_bottom_plashka').removeClass('calc_bottom_active');
		idCalc = $(this).attr('id');
		idCalc = idCalc.substr(5, 1);
		$(this).addClass('calc_top_active');
		$('#bott_' + idCalc).addClass('calc_bottom_active');
		$('#calc_middle_1, #calc_middle_2, #calc_middle_3, #calc_middle_4').hide();
		$('#calc_middle_' + idCalc).show();
		calcPriceColor();
	});
	
	var idCalcBottom;
	$('.calc_bottom_plashka').click(function() {
		var elemTop = $('#calc').offset().top;
		var winTop = $(window).scrollTop();
		elemTop = elemTop - winTop - 30;
		$('html, body').animate({
			scrollTop: '+=' + elemTop + 'px'
		}, 600);
		
		$('.calc_top_plashka').removeClass('calc_top_active');
		$('.calc_bottom_plashka').removeClass('calc_bottom_active');
		idCalcBottom = $(this).attr('id');
		idCalcBottom = idCalcBottom.substr(5, 1);
		$(this).addClass('calc_bottom_active');
		$('#calc_' + idCalcBottom).addClass('calc_top_active');
		$('#calc_middle_1, #calc_middle_2, #calc_middle_3, #calc_middle_4').hide();
		$('#calc_middle_' + idCalcBottom).show();
		calcPriceColor();
	});
	
	$('.calc_more').click(function() {
		if ($(this).html() == 'Подробнее...') {
			$(this).html('Свернуть');
			$(this).prev().show();
			$(this).css('background', 'url(/images/calc/arrow_top.png) no-repeat 0px 13px');
		}
		else {
			$(this).html('Подробнее...');
			$(this).prev().hide();
			$(this).css('background', 'url(/images/calc/arrow_bottom.png) no-repeat 0px 13px');
		}
	});
	
	function calcPriceColor() {
		$('.price_calc').each(function() {
			var classArray = $(this).parent().parent().attr('class').split(" ");
			if (classArray[2] == 'calc_bottom_active') {
				$(this).parent().css('color', '#285DA2');
			}
			else if (parseInt($(this).html()) == 0) {
				$(this).parent().css('color', '#7798c2');
			}
			else {
				$(this).parent().css('color', '#fff');
			}
		});
	}
	
	function price_calc() {
		var allSumm = 0;
		$('.price_calc').each(function() {
			allSumm += parseInt($(this).html());
		});
		
		$('#calc_summ_form_padding').children('span').html(allSumm);
	}
	
	clickPoleDesign = function() {
		var summDesign = 0;
		$('.calc_summ_design').each(function() {
			if ($(this).attr('checked') == 'checked') {
				summDesign += parseInt($(this).parent().parent().children('.calc_price').html());
			}
		});
		
		$('#bott_1').children('.calc_bottom_plashka_padding').children('span').html(summDesign);
		price_calc();
		calcPriceColor();
	}
	
	clickPoleVerstka = function() {
		var summVerstka = 0;
		$('.calc_summ_verstka').each(function() {
			if ($(this).attr('checked') == 'checked') {
				summVerstka += parseInt($(this).parent().parent().children('.calc_price').html());
			}
		});
		
		$('#bott_2').children('.calc_bottom_plashka_padding').children('span').html(summVerstka);
		price_calc();
		calcPriceColor();
	}
	
	clickPoleProgramm = function() {
		var summProgramm = 0;
        
        if ($(this).parent().parent().parent().parent().attr('class') == 'calc_parent_div')
            $(this).parent().parent().parent().parent().prev().children('.calc_block_padding').children('.calc_block_left').children().attr('checked', 'checked');
        
        if ($(this).parent().parent().parent().next().attr('class') == 'calc_parent_div')
            $(this).parent().parent().parent().next().children().children().children().children().removeAttr('checked');
        
		$('.calc_summ_programm').each(function() {
			if ($(this).attr('checked') == 'checked') {
				summProgramm += parseInt($(this).parent().parent().children('.calc_price').html());
			}
		});
		
		$('#bott_3').children('.calc_bottom_plashka_padding').children('span').html(summProgramm);
		price_calc();
		calcPriceColor();
	}
	
	clickPolePromo = function() {
		var summPromo = 0;
		$('.calc_summ_promo').each(function() {
			if ($(this).attr('checked') == 'checked') {
				summPromo += parseInt($(this).parent().parent().children('.calc_price').html());
			}
		});
		
		$('#bott_4').children('.calc_bottom_plashka_padding').children('span').html(summPromo);
		price_calc();
		calcPriceColor();
	}
	
	$('.calc_summ_design').click(clickPoleDesign);
	$('.calc_summ_verstka').click(clickPoleVerstka);
	$('.calc_summ_programm').click(clickPoleProgramm);
	$('.calc_summ_promo').click(clickPolePromo);
	
	clickPoleDesign();
	clickPoleVerstka();
	clickPoleProgramm();
	clickPolePromo();
	
	
	/* Собираем все значения в одно и отправляем форму */
	
	$('#calc_site_create').click(function() {
		var results = '',
			count = 0;
			
		$('.calc_block :input').each(function() {
			if ($(this).attr('id') == 'minbeds')
			{
				var page = '';
				$(this).children('option').each(function() {
					if ($(this).attr('selected')) page = $(this).html();
				});
				
				if (page != 0)
				{
					results += 'Страниц для наполнения: ' + page;
					results += ' - ';
					results += page * 500 + ' руб.';
					results += '\n';
					count += page * 500;
				}
			}
			else
			{
				if ($(this).attr('checked') && $(this).attr('id') != 'verstka_3')
				{
					results += $(this).parent().parent().children('.calc_block_middle').children('label').children('p').text();
					results += ' - ';
					results += $(this).parent().parent().children('.calc_block_right').text();
					results += '\n';
					count += parseInt($(this).parent().parent().children('.calc_price').html());
				}
			}
		});
		
		count += ' руб.';
		results += '\n\nОбщая стоимость: ' + count;		
		$('#hidden_text').remove();
		$('#send_calc').prepend('<input id="hidden_text" type="hidden" value="' + results + '" name="order" />');
		$('#send_calc').submit();
		return false;
	});
	
	/* Вставляем выбранные пункты в скрытое поле при отправке заявки */
	var results = $('#order').html();
	$('#order_form form').prepend('<input id="hidden_text" type="hidden" value="' + results + '" name="content" />');
	
	
	//КОНЕЦ (КАЛЬКУЛЯТОР)
	
    
    //События для страницы price
    $('.price_hide_show').mouseover(function() {
        $(this).children('span').css('border-bottom', 'none');
    });
    
    $('.price_hide_show').mouseout(function() {
        $(this).children('span').css('border-bottom', '1px dashed #235ba5');
    });
    
    $('.price_hide_show').click(function() {
        if ($(this).children('span').html() == 'Развернуть') {
            $(this).css('background', 'url(/images/price/minus.jpg) no-repeat 0px 11px');
            $(this).children('span').html('Свернуть');
            $(this).parent().next().show();
        }
        else {
            $(this).css('background', 'url(/images/price/plus.jpg) no-repeat 0px 11px');
            $(this).children('span').html('Развернуть');
            $(this).parent().next().hide();
        }
    });
    
    $('.price_hide_block_2').each(function() {
        $(this).children('.price_block:first').css('padding-top', '0px');
        $(this).children('.price_block:last').css({'padding-bottom': '0px', 'border-bottom': 'none'});
    });
    
    //Конец (События для страницы price)
    
    
    //Клик по меня в портфолио
    $("#portfolio_full_menu li").click(function() {
        $("#portfolio_full_menu li").removeClass();
        $(this).addClass("portfolio_full_menu_active");
        
        var id = $(this).attr("id");
        id = id.substr(15, 1);
        $("#portfolio_full_block_1").hide();
        $("#portfolio_full_block_2").hide();
        $("#portfolio_full_block_" + id).show();
        
        return false;
    });
    //Конец (Клик по меня в портфолио)
    
    
    
    
    //ПОРТФОЛИО =============================================================================================================================
    //Наводим мышкой на удава в портфолио вжу
    $("#vju_snake_and_text").mouseover(function() {
        $("#vju_text").show();
        $(this).css("margin-bottom", "-103px");
    });
    
    $("#vju_snake_and_text").mouseout(function() {
        $("#vju_text").hide();
        $(this).css("margin-bottom", "-50px");
    });
    //Конец (Наводим мышкой на удава в портфолио вжу)
    
    
    //Листалка диетресса
    var position = 1;
    var speed = 300;
    
    dietressaRight = function() {
        $("#dietressa_left").unbind("click");
        $("#dietressa_right").unbind("click");
        
        position++;
        $("#dietressa_slider_big").animate({
            "left": "-=711px"
        }, speed, function() {
            if (position != 1 && position != 4) {
                $("#dietressa_left").bind("click", dietressaLeft);
                $("#dietressa_right").bind("click", dietressaRight);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left_active.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right_active.png");
            }
            else if (position == 1) {
                $("#dietressa_right").bind("click", dietressaRight);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right_active.png");
            }
            else if (position == 4) {
                $("#dietressa_left").bind("click", dietressaLeft);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left_active.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right.png");
            }
        });
    }
    
    dietressaLeft = function() {
        $("#dietressa_left").unbind("click");
        $("#dietressa_right").unbind("click");
        
        position--;
        $("#dietressa_slider_big").animate({
            "left": "+=711px"
        }, speed, function() {
            if (position != 1 && position != 4) {
                $("#dietressa_left").bind("click", dietressaLeft);
                $("#dietressa_right").bind("click", dietressaRight);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left_active.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right_active.png");
            }
            else if (position == 1) {
                $("#dietressa_right").bind("click", dietressaRight);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right_active.png");
            }
            else if (position == 4) {
                $("#dietressa_left").bind("click", dietressaLeft);
                $("#dietressa_left").attr("src", "/images/portfolio/site/dietressa/left_active.png");
                $("#dietressa_right").attr("src", "/images/portfolio/site/dietressa/right.png");
            }
        });
    }
    
    $("#dietressa_right").bind("click", dietressaRight);
    //Конец (Листалка диетресса)
    
    
    //МУЛЬТИФОРТ
    $("#multifort_text_2").click(function() {
        $("#multifort_img_1").hide();
        $("#multifort_img_2").show();
        
        $("#multifort_text_2").removeClass();
        $("#multifort_text_3").addClass("multifort_collage");
    });
    
    $("#multifort_text_3").click(function() {
        $("#multifort_img_2").hide();
        $("#multifort_img_1").show();
        
        $("#multifort_text_3").removeClass();
        $("#multifort_text_2").addClass("multifort_collage");
    });
    
    
    
    //ШИПЕНИЕ
	function rand(min, max) {
		if (max) {
			return Math.floor(Math.random() * (max - min + 1)) + min;
		}
		else {
			return Math.floor(Math.random() * (min + 1));
		}
	}
	
	var arrShipenieSrc = new Array();
	var arrShipenieWidth = new Array();
	var arrShipenieHeight = new Array();
	var arrGenerate = new Array();
	var arrGenerateLeft = new Array();
	var timer;
	var generateNumber = 1;
	var randNumber;
	var randNumber2;
	var randNumberFunction;
	var del;
	var perTmp;
	
	arrShipenieSrc = ['/images/portfolio/site/multifort/sh/img1.png', '/images/portfolio/site/multifort/sh/img2.png', 
                      '/images/portfolio/site/multifort/sh/img3.png', '/images/portfolio/site/multifort/sh/img4.png', 
                      '/images/portfolio/site/multifort/sh/img5.png'];
	arrShipenieWidth = [75, 45, 58, 66, 35];
	arrShipenieHeight = [70, 44, 56, 62, 34];
	arrGenerate = [0, 1, 2, 3, 4];
	arrGenerateLeft = [0, 20, 40, 60, 80];
	
	var overShipenie = function() {
		$('#multifort_event span').unbind('mouseover');
		$('#main').prepend('<div id="music" style="position:absolute; top:0px; left:0px;"><object wmode="transparent" type="application/x-shockwave-flash" data="http://new3.itsoft.ru/web-studio/portfolio/create_site/multifort/ump3player_500x70.swf" height="70" width="470"><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="movie" value="http://new3.itsoft.ru/web-studio/portfolio/create_site/multifort/ump3player_500x70.swf" /><param name="FlashVars" value="way=http://new3.itsoft.ru/web-studio/portfolio/create_site/multifort/music.mp3&amp;swf=http://new3.itsoft.ru/web-studio/portfolio/create_site/multifort/ump3player_500x70.swf&amp;w=470&amp;h=70&amp;time_seconds=164&amp;autoplay=1&amp;q=1&amp;skin=white&amp;volume=100&amp;comment=" /><param name="wmode" value="opaque" /></object></div>');
		timer = setInterval(shipi, 400);
		$('#multifort_event span').bind('mouseout', outShipenie);
	}
	
	var outShipenie = function() {
		$('#multifort_event span').unbind('mouseout');
		$('#music').remove();
		clearInterval(timer);
		$('#multifort_event span').bind('mouseover', overShipenie);
	}
	
	
	function shipi () {
		generateNumber++;
		randNumber = rand(0, (arrShipenieSrc.length - 1));
		randNumber2 = rand(0, (arrShipenieSrc.length - 1));
		$('#multifort_shipi').append('<img id="shipi_img_' + generateNumber + '" class="shipi_img" src="' + arrShipenieSrc[randNumber] + '" style="width:' + arrShipenieWidth[randNumber] + 'px; height:' + arrShipenieHeight[randNumber] + 'px; left:' + arrGenerateLeft[randNumber2] + 'px;">');
		
        if ($.browser.msie && $.browser.version <= '8.0') {
			$('#shipi_img_' + generateNumber).animate({
				'top' : '-=600px'
			}, 3500, function() {
				$(this).remove();
			});
		}
		else {
			$('#shipi_img_' + generateNumber).animate({
				'top' : '-=700px',
				'opacity' : '0'
			}, 3500, function() {
				$(this).remove();
			});
		}
	}
	
	$('#multifort_event span').bind('mouseover', overShipenie);
	//КОНЕЦ (ШИПЕНИЕ)
    //КОНЕЦ (МУЛЬТИФОРТ)
    
    
    
    
    //Открыть и закрыть информацию по регистрации домена
    var flagReg = 1;
    $("#domen_reg_stat").click(function() {
        if (flagReg == 1) {
            $("#domen_reg_stat_open").show();
            flagReg = 0;
        }
        else {
            $("#domen_reg_stat_open").hide();
            flagReg = 1;
        }
    });
    //Конец (Открыть и закрыть информацию по регистрации домена)
    
    
	//Вкладки и листалка на странице продвижение
	$(".promotion_results_block_navigation > div").click(function() {
		$(this).parent().children("div:eq(0)").removeClass("promotion_active");
		$(this).parent().children("div:eq(1)").removeClass("promotion_active");
		$(this).addClass("promotion_active");
	});
	
	var widthBlock = 696;
	var speed = 300;
	
	clickPromotionRight = function() {
		$(this).parent().children(".promotion_left_arrow").unbind("click");
		$(this).parent().children(".promotion_right_arrow").unbind("click");
		
		//Настройки для анимации
		var wrapBig = $(this).parent().children(".promotion_wrap").children(".promotion_wrap_big");
		if (!wrapBig.attr("name")) wrapBig.attr("name", 1);
		var position = wrapBig.attr("name");
		var numberOf = wrapBig.children(".promotion_wrap_img_block").length;
		if (numberOf <= 1) return false;
		
		//Двигаем плашку в списке
		var ulList = $(this).parent().parent().children("ul");
		var thisObj;
		ulList.children("li").each(function() {
			if ($(this).attr("class") == "promotion_results_block_active") {
				thisObj = $(this);
			}
		});
		thisObj.removeClass("promotion_results_block_active").next().addClass("promotion_results_block_active");
		
		position++;
		wrapBig.attr("name", position);
		
		wrapBig.animate({
			left : "-=" + widthBlock + "px"
		}, speed, function() {
			if (position > 1 && position < numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == 1) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
			}
		});
	}
	
	clickPromotionLeft = function() {
		$(this).parent().children(".promotion_left_arrow").unbind("click");
		$(this).parent().children(".promotion_right_arrow").unbind("click");
		
		//Настройки для анимации
		var wrapBig = $(this).parent().children(".promotion_wrap").children(".promotion_wrap_big");
		if (!wrapBig.attr("name")) wrapBig.attr("name", 1);
		var position = wrapBig.attr("name");
		var numberOf = wrapBig.children(".promotion_wrap_img_block").length;
		if (numberOf <= 1) return false;
		
		//Двигаем плашку в списке
		var ulList = $(this).parent().parent().children("ul");
		var thisObj;
		ulList.children("li").each(function() {
			if ($(this).attr("class") == "promotion_results_block_active") {
				thisObj = $(this);
			}
		});
		thisObj.removeClass("promotion_results_block_active").prev().addClass("promotion_results_block_active");
		
		position--;
		wrapBig.attr("name", position);
		
		wrapBig.animate({
			left : "+=" + widthBlock + "px"
		}, speed, function() {
			if (position > 1 && position < numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == 1) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
			}
		});
	}
	
	$(".promotion_right_arrow").bind("click", clickPromotionRight);
	
	//Клик по плашке с запросом
	$(".promotion_results_block > ul").children("li").click(function() {
		$(this).parent().parent().children(".promotion_results_block_plashka").children(".promotion_left_arrow").unbind("click");
		$(this).parent().parent().children(".promotion_results_block_plashka").children(".promotion_right_arrow").unbind("click");
		
		var peremTmp = 1;
		var eq;
		$(this).attr("name", "click");
		
		$(this).parent().children("li").each(function() {
			if ($(this).attr("name") == "click") {
				eq = peremTmp;
				$(this).attr("name", '');
			}
			else peremTmp++;
		});
		
		$(this).parent().children("li").removeClass("promotion_results_block_active").eq(eq - 1).addClass("promotion_results_block_active");
		
		//Настройки для анимации
		var wrapBig = $(this).parent().parent().children(".promotion_results_block_plashka").children(".promotion_wrap").children(".promotion_wrap_big");
		if (!wrapBig.attr("name")) wrapBig.attr("name", 1);
		var position = wrapBig.attr("name");
		var numberOf = wrapBig.children(".promotion_wrap_img_block").length;
		if (numberOf <= 1) return false;
		
		/*var storona = position - eq;
		if (storona < 0) storona = "-=";
		else storona = "+=";*/
		
		position = parseInt(position);
		
		if (position > eq) {
			var newWidthAnimate = (position - eq) * widthBlock;
			var storona = "+=";
		}
		else {
			var newWidthAnimate = Math.abs((position - eq) * widthBlock);
			var storona = "-=";
		}
		
		var newSpeed = Math.abs((position - eq) * speed);
		
		position = eq;
		wrapBig.attr("name", position);
		
		wrapBig.animate({
			left : storona + newWidthAnimate + "px"
		}, newSpeed, function() {
			if (position > 1 && position < numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == 1) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").bind("click", clickPromotionRight);
			}
			else if (position == numberOf) {
				$(this).parent().parent().children(".promotion_left_arrow").css("background", "url(/images/promotion/arrow_left.png) no-repeat");
				$(this).parent().parent().children(".promotion_right_arrow").css("background", "url(/images/promotion/arrow_right_noactive.png) no-repeat");
				$(this).parent().parent().children(".promotion_left_arrow").bind("click", clickPromotionLeft);
			}
		});
	});
	
	//Клик по вкладке яндекс
	$(".promotion_results_block_pl1").click(function() {
		//Ставим класс
		$(this).removeClass("promotion_active").next().removeClass("promotion_active");
		$(this).addClass("promotion_active");
		
		//Меняем картинки
		$(this).parent().parent().find(".promotion_wrap_img_2").css("display", "none");
		$(this).parent().parent().find(".promotion_wrap_img_1").css("display", "block");
	});
	
	//Клик по вкладке гугл
	$(".promotion_results_block_pl2").click(function() {
		//Ставим класс
		$(this).removeClass("promotion_active").prev().removeClass("promotion_active");
		$(this).addClass("promotion_active");
		
		//Меняем картинки
		$(this).parent().parent().find(".promotion_wrap_img_1").css("display", "none");
		$(this).parent().parent().find(".promotion_wrap_img_2").css("display", "block");
	});
	
	//Конец (Вкладки и листалка на странице продвижение)
	
	//События с блоком "звонок менеджеру"
	$("#call_close").click(function() {
		$(this).parent().parent().hide();
	});
	
	$(".call_manager_link").click(function() {
		$("#call_manager").show();
		return false;
	});
	//Конец (События с блоком "звонок менеджеру")
	
	
	
	/**
	*
	* Функции для фикса верстки в ITForms
	*
	*/
	
	/* Функция для удаления всех атрибутов size у форм */
	var removeAttrSize = function()
	{
		$(':input').each(function() {
			$(this).removeAttr('size');
			$(this).removeAttr('cols');
		});
	}
	
	removeAttrSize();
	$('#input-captcha_code').next().css('display', 'block');
	
	
	$('.support_arrow_brief').click(function() {
		$('.support_block_padding_full').show();
		$('.support_arrow_full').show();
		$('.support_block_padding_brief').hide();
		$('.support_arrow_brief').hide();
	});
	
	$('.support_arrow_full').click(function() {
		$('.support_block_padding_full').hide();
		$('.support_arrow_full').hide();
		$('.support_block_padding_brief').show();
		$('.support_arrow_brief').show();
	});
	
	
	/* Табы соц сетей */
	var heightComments = 0,
		idCommentsBlock = 0,
		commentsFlag = true;
		
	$('.comments_tab ul li').click(function() {
		$('.comments_tab ul li').removeClass('comments_active');
		$(this).addClass('comments_active');
		$('.comments_block').hide();
		
		idCommentsBlock = $(this).attr('id').substr(10);
		$('#comments_block_' + idCommentsBlock).show();
		
		if (commentsFlag)
		{
			if (idCommentsBlock == 1) heightComments = 87;
			else heightComments = 125;
			$('.comments_block_padding').css('height', heightComments + 'px');
		}
	});
	
	
	/* Открыть и закрыть комментарии из соцсетей */
	//Если commentsFlag == true - при нажатии на элемент комментарии открываются
	$('.comments_open').click(function() {
		if (commentsFlag == true)
		{
			$('.comments_block').css({'height' : 'auto', 'overflow' : 'none'});
			$('.comments_block_padding').css({'height' : 'auto', 'overflow' : 'none'});
			$(this).css('background', 'url(/images/comments/arrow_top.jpg) no-repeat 0px 5px');
			$(this).children('span').html('Скрыть оставленные комментарии');
			commentsFlag = false;
		}
		else
		{
			if (idCommentsBlock && idCommentsBlock == 1) heightComments = 87;
			else heightComments = 125;
			
			$('.comments_block').css({'height' : '125px', 'overflow' : 'hidden'});
			$('.comments_block_padding').css({'height' : heightComments + 'px', 'overflow' : 'hidden'});
			$(this).css('background', 'url(/images/comments/arrow_bottom.jpg) no-repeat 0px 5px');
			$(this).children('span').html('Показать оставленные комментарии');
			commentsFlag = true;
		}
	});
	
});



function do_rearrange_noload (){
	$("ul.reasons li.closer").remove();
	$("ul.reasons").removeClass('reasons_col3, reasons_col4');
	$("ul.portfolio").removeClass('portfolio_col4, portfolio_col5');
	var colsNum=Math.floor($("ul.reasons").width()/(226));
	var colsNum2=Math.floor($("body").width()/(237));
	if (colsNum<4) {$("ul.reasons").addClass('reasons_col3'); $("ul.reasons li:nth-child(3n)").after('<li class="closer"></li>')}
	else {$("ul.reasons").addClass('reasons_col4'); $("ul.reasons li:nth-child(4n)").after('<li class="closer"></li>')}
	if (colsNum2<5) {$("ul.portfolio").addClass('portfolio_col4')}
	else {$("ul.portfolio").addClass('portfolio_col5')}
}

