$(document).ready(function() {
	var host = location.href.split("/");

	var right = 0;
	var oldRight = 0;
	var key = 0;
	$('#arrRight').click(function() {
		removeborderImgBig();
		key = key+1;
		if($('div.lineAwards').find("a:eq("+key+")").hasClass("borderImgSmal")) { 
			if(document.all && !document.querySelector) { // IE 7
				right = right + 125;
			} else if(document.all && document.querySelector && !document.getElementsByClassName) { // IE 8
				right = right + 130;
			} else { // All
				right = right + 133;
			}
		} else {
			right = 0;
			key=0;
		}
		slider(key, right);
		return false;
	});

	$('#arrLeft').click(function() {
		removeborderImgBig();
		key = key-1;
		if(key != -1) {
			if(document.all && !document.querySelector) { // IE 7
				right = right - 128;
			} else if(document.all && document.querySelector && !document.getElementsByClassName) { // IE 8
				right = right - 133;
			} else { // All
				right = right - 133;
			}
		} else {
			if(document.all && !document.querySelector) { // IE 7
				right = $("div.lineAwards").find("a").length*101;
			} else if(document.all && document.querySelector && !document.getElementsByClassName) { // IE 8
				right = $("div.lineAwards").find("a").length*104;
			} else { // All
				right = $("div.lineAwards").find("a").length*106;
			}
			key = $("div.lineAwards").find("a").length - 1;
		}
		slider(key, right);
		return false;
	});

	$("div.lineAwards a.borderImgSmal").live("click", function() {
		removeborderImgBig();
		var postOffset = $(this).offset();
		key = $(this).index()-1;
		if(document.all && !document.querySelector) { // IE 7
			right = key*125;
		} else if(document.all && document.querySelector && !document.getElementsByClassName) { // IE 8
			right = key*130;
		} else { // All
			right = key*133;
		}
		slider(key, right);
		return false;
	});
	
	$("span.object").mouseover(function() {
		var items = $(this).find("a").length;
		var span = parseInt($(this).offset().top)+100;
		var spanLeft = parseInt($(this).offset().left)+180;
		var scroll = parseInt($(window).scrollTop())+parseInt($(window).height());
		if(span > scroll) {
			if(items == 1) var bottom = 84;
			if(items == 2) var bottom = 105;
			if(items == 3) var bottom = 126;
			$(this).find("span.objectCity").css({"position":"relative","bottom":bottom}).find("span").hide();
			$(this).find("a").css({"position":"relative","bottom":bottom});
		} else {
			$(this).find("span.objectCity").css({"position":"relative","bottom":0}).find("span").show();
			$(this).find("a").css({"position":"relative","bottom":0});
		}
		
		if(spanLeft > $(window).width()) {
			$(this).find("span.objectCity").css({"position":"relative","right":160}).find("span").css("left", 176);
			$(this).find("a").css({"position":"relative","right":160});		
		} else {
			$(this).find("span.objectCity").css({"position":"relative","right":0}).find("span").css("left", 16);
			$(this).find("a").css({"position":"relative","right":0});			
		}
	});
	
	if(location.href.indexOf("customers/map") > 0) {
		arrowTop = false;
		$(window).scroll(function() {
			if(!arrowTop) arrowTop = parseInt($("a#mapRight").offset().top)-50;
			if($(window).scrollTop() >= arrowTop) {
				$("a#mapRight").css("top", $(window).scrollTop()-150);
				$("a#mapLeft").css("top", $(window).scrollTop()-150);
			}
		});
	}
	
	$("a#mapRight").click(function() {
		$(this).hide();
		$("div.bigMapContent").animate({
			left: $("div.bigMap").width()-2000
		}, 500, function() {
			$("a#mapLeft").show();
			map();
		});
		$("a.mapLeft").animate({
			"left": 0
		}, 500);
		return false;
	});
	
	$("a#mapLeft").click(function() {
		$(this).hide();
		$("div.bigMapContent").animate({
			left: 0
		}, 500, function() {
			$("a#mapRight").show();
			map();
		});
		$("a.mapLeft").animate({
			"left": -49
		}, 500);
		return false;
	});
	
	noClick = false;
 	$("a.mapLeft").click(function() {
		if(!noClick) {
			if($(window).width() < 2000) {
				if($("a#mapRight").css("display") != "none") {
					$("a#mapRight").hide();
					$("div.bigMapContent").animate({
						left: $("div.bigMap").width()-2000
					}, 500, function() {
						map();
						$("a#mapLeft").show();
					});
					$("a.mapLeft").animate({
						"left": 0
					}, 500);
				} else if($("a#mapLeft").css("display") != "none") {
					$("a#mapLeft").hide();
					$("div.bigMapContent").animate({
						left: 0
					}, 500, function() {
						map();
						$("a#mapRight").show();
					});
					$("a.mapLeft").animate({
						"left": -49
					}, 500);	
				}
			}
		}
		noClick = false;
		return false;
	});
	
	if(location.href.indexOf("customers/map") > 0) {
		$(window).resize(function() {
			map();
		});
		
		map();
	}
	
	var showDoc = false;
	$("div.seeAll").find("a[rel!='all']").click(function() {
		$("a[rel='all']").removeClass("activeDoc");
		if($(this).attr("rel").indexOf("brand") == 0) {
			$(this).parent().parent().find("a[rel]").removeClass("activeDoc");
			$(this).addClass("activeDoc");
			$("div.containerBlock6 span[rel]").hide().attr("rb", "0").find("ul.docList").hide().prev().find("span.parArrow").find("span.parTxt").text("Развернуть").next().removeClass("parArrowUp").addClass("parArrowDown");;
			$("span[rel='"+$(this).attr("rel")+"']").show().attr("rb", "1").find("ul.docList").show().prev().find("span.parArrow").find("span.parTxt").text("Свернуть").next().removeClass("parArrowDown").addClass("parArrowUp");;
		}
		if($(this).attr("rel").indexOf("type") == 0) {
			var type = /[0-9]+/.exec($(this).attr("rel"));
			$(this).parent().parent().find("a[rel]").removeClass("activeDoc");
			$(this).addClass("activeDoc");
			$("li[rel]").hide().attr("rl","0");
			$("li[rel*='_"+type+"_']").show().attr("rl","1");
			var docs = $("div.containerBlock6 span[rel]").get();
			$.each(docs, function(key, name) {
				if($(this).find("li[rl=1]").length == 0) {
					$(this).hide()
				} else if($(this).attr("rb") == 1) {
					if(showDoc == false) {
						$(this).show().find("ul.docList").show();
						$(this).find("span.parArrow").find("span.parTxt").text("Свернуть").next().removeClass("parArrowDown").addClass("parArrowUp");
						showDoc = true;
					} else {
						$(this).show().find("ul.docList").hide();
						$(this).find("span.parArrow").find("span.parTxt").text("Развернуть").next().removeClass("parArrowUp").addClass("parArrowDown");
					}
				}
			});
			showDoc = false;
		}
		return false;
	});
	
	$("a[rel='all']").click(function() {
		$(this).addClass("activeDoc");
		$("ul.column").find("a.activeDoc").removeClass("activeDoc");
		$("div.containerBlock6 span[rel]").show().attr("rb", "1").find("ul").hide().prev().find("span.parArrow").find("span.parTxt").text("Развернуть").next().removeClass("parArrowUp").addClass("parArrowDown");
		$("div.containerBlock6").find("span:eq(1)").find("ul").show().prev().find("span.parArrow").find("span.parTxt").text("Свернуть").next().removeClass("parArrowDown").addClass("parArrowUp");
		$("li[rel]").show();
		return false;
	});
	
	$("a.lieSelect").live("click", function() {
		$(this).next().next().show();
		return false;
	});
	
	$("div.radioReq label").live("click", function() {
		$("div.radioReq label").removeClass("activeReq");
		$(this).addClass("activeReq");
	});
	
	$("form.requestForm").live("submit", function() {
		if ($(this).attr('dosubmit')) return true;
		var fields = $(this).find(":input[rel='check']").serializeArray();
		var pattern = new RegExp(/^[0-9 -]{1,20}$/);
		var hasError = false;
		$("div.test").hide();
		$.each(fields, function(key, field){
			if(field.value.length == 0) {
				$("form.requestForm").find(":input[name='"+field.name+"']").parent().parent().next().show().next().hide().addClass("errorField");
				hasError = true;
			} else if(!pattern.test(field.value)) {
				$("form.requestForm").find(":input[name='"+field.name+"']").parent().parent().next().hide().next().show().addClass("errorField");
				hasError = true;
			}
		});
		
		if(!hasError) {
			$.post('/users/kaptchatest', {'keystring':$('#codeReq').val()},function(data){
				if (data==1){
					$("form.requestForm").attr('dosubmit', "1").submit();
				}else{
					alert('Вы неверно ввели код!');
					$('.kaptcha_image').attr('src','/kcaptcha/index.php?rnd='+Math.random());
				}
			},'json');
		}
		return false;
	});
	
	$("a.expanded").live("click", function(){
		$(this).removeClass("expanded").addClass("collapsed").parent().find("ul").show();
		return false;
	});
	
	$("a.collapsed").live("click", function(){
		$(this).removeClass("collapsed").addClass("expanded").parent().find("ul").hide();
		return false;
	});
	
/* 	$("a.imageSlider").click(function() {
		var src = $(this).find("img").attr("src").replace("small/", "middle/");
		var info = $(this).next().text();
		var thumbId = $(this).next().next().attr("id");
		$("div.photoBlockMini").find("span").remove();
		$(this).append("<span></span>");
		$("div.cadreTxt").text(info);
		$("div.photoBlock").find("img").stop(true, true).fadeOut(0).fadeIn().attr("src", src);
		$("a#currentImage").unbind("click");
		$("a#currentImage").click(function() {
			return hs.expand(document.getElementById(thumbId), { slideshowGroup: 'first-group' });
		});
		return false;
	}); */
	
	$("ul.catalogMenuHeader a").click(function() {
		$(this).parent().parent().find("a").removeClass("activeInner");
		$(this).addClass("activeInner");
		if($(this).hasClass("brand")) {
			$("ul#brand").show();
			$("ul#category").hide();
		} else {
			$("ul#brand").hide();
			$("ul#category").show();
		}
		return false;
	});
	
	$("ul#mainTabs li").live("click", function() {
		var text = $("ul.typeCatalog li.activeTC span").text();
		$("ul.typeCatalog li.activeTC").removeClass("activeTC").html('<a href="#">'+text+'</a>');
		text = $(this).find("a").text();
		$(this).addClass("activeTC").html("<span>"+text+"</span>");
		$("table.catalogMenuIn").hide();
		$("table."+$(this).attr("id")).show();
		return false;
	});
	
	$("ul#categoryTabs").find("li[rel^='tab']").live("click", function(data) {
		categoryTabs($(this));
		return false;
	});
	/*if(location.href.indexOf("categories/category") > 0 && location.href.indexOf("page:") < 0) {
		categoryTabs($("ul#categoryTabs").find("li:eq(2)"));
	}*/
	
	$("a.parTitle").click(function() {
		if($(this).find("span.parArrowUp").hasClass("parArrowUp")) {
			$(this).find("span.parArrow").find("span.parTxt").text("Развернуть").next().removeClass("parArrowUp").addClass("parArrowDown");
		} else {
			$(this).find("span.parArrow").find("span.parTxt").text("Свернуть").next().removeClass("parArrowDown").addClass("parArrowUp");
		}
		$(this).next().find("div.listSection").toggle();
		if(location.href.indexOf("documents/support") > 0) {
			if($(this).next("ul.docList").css("display") == "block") {
				$(this).next("ul.docList").hide();
			} else {
				$("ul.docList").hide().prev().find("span.parArrow").find("span.parTxt").text("Развернуть").next().removeClass("parArrowUp").addClass("parArrowDown");
				$(this).next("ul.docList").show().prev().find("span.parArrow").find("span.parTxt").text("Свернуть").next().removeClass("parArrowDown").addClass("parArrowUp");
			}
		}
		return false;
	});

//	if(typeof(yearparam) != "undefined") {
		
//	}
//old main.js >> Lenta, Subscribe
	if ($('.tapeLineInner').width() > $('#tape').width()) {
		$('.tapeLineArrowRight').show();
		//$('.tapeLineArrowLeft').show();
	} else {
		$('.tapeLineArrowRight').hide();
		$('.tapeLineArrowLeft').hide();
	}
	var interval = '';
	var inter = '';
	
	$('.tapeLineArrowLeft').mouseover(function(){		
		interval = setInterval(moveRight,25);	
	}); 
	
	$('.tapeLineArrowLeft').mouseout(function() {	
		clearInterval(interval);
	}); 
	
	 $('.tapeLineArrowRight').mouseover(function(){		
		inter = setInterval(moveLeft,25);	
	}); 
	
	 $('.tapeLineArrowRight').mouseout(function() {	
		clearInterval(inter);
	}); 
	
	function moveLeft() {
		if  (Math.abs($('.tapeLineInner').width() - $('#tape').width()) > Math.abs($('.tapeLineInner').css('margin-left').split('px')[0]) - parseFloat($('.tapeLine').css('margin-left').split('px')[0])) {
			var mar = $('.tapeLineInner').css('margin-left');
			$('.tapeLineInner').css('margin-left',mar.split('px')[0] - 20);
			$('.companyLine').css('margin-left',mar.split('px')[0] - 20);
			$('.industryLine').css('margin-left',mar.split('px')[0] - 20);
			$('div.arrow_company, div.arrow_industry').css('margin-left',mar.split('px')[0] - 20);
			$('.tapeLineArrowRight').show();
			$('.tapeLineArrowLeft').show();
		}
		else {
			$('.tapeLineArrowRight').hide();
		}
	}
	
	function moveRight() {
		if ($('.tapeLineInner').css('margin-left').split('px')[0]<0) {
			var mar = $('.tapeLineInner').css('margin-left');
			var maradd = +mar.split('px')[0] +20;
			$('.tapeLineInner').css('margin-left',maradd+'px');
			$('.companyLine').css('margin-left',maradd+'px');
			$('.industryLine').css('margin-left',maradd+'px');
			$('div.arrow_company, div.arrow_industry').css('margin-left',maradd+30+'px');
			$('.tapeLineArrowLeft').show();
			$('.tapeLineArrowRight').show();
		}
		else {
			$('.tapeLineArrowLeft').hide();
		}
	}
	
	/* $('.clarificationLeft').hover(function(){		
		interval = setInterval(moveLeft,25);	
	}, function() {	
		clearInterval(interval);
	}); 
	var inter = '';
	$('.clarificationRight').hover(function(){		
		inter = setInterval(moveRight,25);	
	}, function() {	
		clearInterval(inter);
	}); 
 */
	$('span.borderImg').hover(function(){
		var x = $(this).offset().left - $('#tape').offset().left;
		var tapex = $('#tape').width();
		if (tapex-x < 300) {
			$(this).find('a').addClass('hoverRight');
			$(this).find('span:first').addClass('frameContentRight');
			$(this).find('.frameContentRight').show();
			
		} else {
			$(this).find('a').addClass('hoverLeft');
			$(this).find('span:first').addClass('frameContentLeft');
			$(this).find('.frameContentLeft').show();
		
		}
		
	}, function() {
		$(this).find('.frameContentLeft').hide();
		$(this).find('.frameContentRight').hide();
		$(this).find('span:first').removeClass('frameContentLeft');
		$(this).find('span:first').removeClass('frameContentRight');
		$(this).find('a').removeClass('hoverLeft');
		$(this).find('a').removeClass('hoverRight');
	});
	//end Lenta News
	
	$('#subscribe .bondBlock .txtInputStyle, #picknews1, #picknews2').blur( function(){
		email = $('#subscribe .bondBlock .txtInputStyle').val();
		if(email != 0) {
			if(isValidEmailAddress(email)) {
				$('.error div').hide();	
				if($('#picknews1').attr("checked") || $('#picknews2').attr("checked")){
					$('.submitInputStyle').removeAttr('disabled');
				}
				else {
					$('.submitInputStyle').attr('disabled','disabled');
				}
			}
			else {
				$('.error div').show();
			$('.submitInputStyle').attr('disabled','disabled');
			}
		}
		else {
			$('.error div').hide();
			$('.submitInputStyle').attr('disabled','disabled');
		}
	});
	
  	$('#subscribe .bondBlock .txtInputStyle').keyup(function(){
		$('.submitInputStyle').attr('disabled',false);
	});  
		function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,4}$/);
		/*var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/key);*/
		return pattern.test(emailAddress);
		}
		
		$("input#emailSubscribe").click(function() {
			$.post("/news/subscribe", $("form#subscribe").serialize());
			$("input.txtInputStyle").val("");
			$('.submitInputStyle').attr('disabled','disabled');
			$("span#checkEmail").html(email);
			return false;
		});
		
		$("ul.city li").click(function() {
			if(!$(this).hasClass("activeCity")) {
				var city1 = $(this).find("a").text();
				var city2 = $("ul.city").find("li.activeCity").find("span").text();
				$("div.footerContact").hide();
				$("div.footerContact#"+$(this).attr("class")).show();
				$("ul.city").find("li.activeCity").removeClass("activeCity").html('<a href="#">'+city2+'</a>');
				$(this).addClass("activeCity").html('<div class="choice"><div><span>'+city1+'</span></div></div>');
			}
			return false;
		});
		
		var excHeight=$("div.scroll").height();
		if($("div.scroll ul li").length > 10) {
			$("div.scroll").height("535");
		} else {
			$("div.moreOthers").hide();
		}
		
		$("a.moreNews").click(function() {
			if($("div.scroll").height() == "535") {
				$("div.moreOthers").find("span.moreTenDow").removeClass("moreTenDow").addClass("moreTenUp").next().text("Свернуть");
				$("div.scroll").animate({height:excHeight},500);
			} else {
				$("div.moreOthers").find("span.moreTenUp").removeClass("moreTenUp").addClass("moreTenDow").next().text("Все объекты в регионе");
				$("div.scroll").animate({height:535},500);
			}
			return false;
		});
		
		fulHeight = $("div.description").height();
		if(fulHeight <= 75) {
			$("div.shadow").hide();
			$("a.toggle_desc").hide();
		} else {
			$("div.description").height("75");
		}
		$("a.toggle_desc").click(function() {
			if($(this).hasClass("active")) {
				$("div.shadow").show();
				$(this).removeClass("active").html('&darr; <span>Показать полносьтю</span>');
				$(this).prev().animate({
					height: 75
				}, 250);
			} else {
				$(this).addClass("active").html('&uarr; <span>Скрыть</span>');
				$(this).prev().animate({
					height: fulHeight
				}, 250, function() {
					$("div.shadow").hide();
				});
			}
			return false;
		});
		
		$("a.close_open").click(function() {
			if($(this).attr("id") == "opisOpen") {
				$(this).hide();
				$("a#opisClose").show();
				$("div.contentBrand").slideDown(500);
			} else {
				setTimeout('$("a#opisOpen").show();$("a#opisClose").hide();', 500);
				$("div.contentBrand").slideUp(500);			
			}
			return false;
		});
		
		var sendSuccess = $("h3#sendSuccess").text();
		if(sendSuccess.length > 0) {
			$("h3#sendSuccess").next().hide().next().show();
		}
		
		$("a#sendRepeat").click(function() {
			$(this).parent().hide().prev().show().prev().hide();
			return false;
		});
		
		$("a.brandLink").live("click", function() {
			location.href = $(this).attr("href");
			return false;
		});
		
		$("div.show").click(function(){
			$("div.vis").toggle();
			return false;
		});
		
/* 		if(location.href.indexOf("/nouvels") > 0) {
			$(window).scroll(function(){
				var moreNews = parseInt($("a.moreNews").offset().top);
				var windowTop = $(window).scrollTop()+833;
				if(windowTop >= moreNews) {
					var rel = $("a.moreNews").attr("rel").split(",");
					getNewsAjax(rel[0], rel[1], rel[2]);
				}
			});
		} */
		
		if(location.href.indexOf("customers/map") > 0) {
			$("div.bigMapContent").draggable({
				axis:"x",
				containment: [drag,0,0,0],
				cursor: 'e-resize',
				drag: function(event, ui) {
					var miniMapLeft = -49;
					var a = $("div.bigMap").width()-2000;
					var param = miniMapLeft/a;
					var mapLeft = parseInt($("div.bigMapContent").css("left"))*param;
					$("a.mapLeft").css("left", miniMapLeft-mapLeft);
					map();
				}
			});
			
			var objectMap = parseInt($("div.objects_map").offset().left);
			x1 = objectMap-48;
			x2 = objectMap;			
			$("a.mapLeft").draggable({
				axis:"x",
				containment: [x1,0,x2,0],
				cursor: 'e-resize',
				drag: function(event, ui) {
					var miniMapLeft = -49;
					var a = $("div.bigMap").width()-2000;
					var param = a/miniMapLeft;
					var mapLeft = parseInt($("a.mapLeft").css("left"))*param;
					$("div.bigMapContent").css("left", a-mapLeft);
					map();
					noClick = true;
				}
			});
		}
		
		$("span.date, div.arrow_map_cont").live("click", function() {
			if($(this).hasClass("arrow_map_contleft")) {
				object = $("span.date_map_conteiner2");
			} else if($(this).hasClass("arrow_map_contright")) {
				object = $("span.date_map_conteiner4");
			}else {
				object = $(this);
			}
			
			if(!object.prev().hasClass("date")) {
				$("div.arrow_map_contleft").hide();
			}
			if(!object.next().hasClass("date")) {
				$("div.arrow_map_contright").hide();
			}
			
			var year = object.find('span').attr("rel");
			var items = object.attr("rel").split("_");
			$("span.objectSmal").find("a").hide();
			var objects = $("span.objectSmal").get();
			if (year!="Все объекты") {
				$.each(objects, function(key, field){
					if($(this).find("a[class*='"+year+"']").length > 0) {
						$(this).fadeIn(500).find("a[class*='"+year+"']").css("display","");
					} else {
						$(this).fadeOut(500).find("a").hide();
					}
				});
				$("p.yearTxt").text(year+" год");
			}
			else {
				$.each(objects, function(key, field){
					if($(this).find("a").length > 0) {
						$(this).fadeIn(500).find("a").css("display","");
					} else {
						$(this).fadeOut(500).find("a").hide();
					}
				});
				$("p.yearTxt").text(year);
			}
			
			$("a.cimenaTxt").text(items[0]);
			$("p.subMap").html(items[1]+"<br>"+items[2]+"<br>"+items[3]);
			
			if(object.hasClass("date_map_conteiner1")) {
				$("div.arrow_map_contright").show();
				dateMapSmallLeft();
			}else if(object.hasClass("date_map_conteiner2")) {
				$("div.arrow_map_contright").show();
				dateMapNormalLeft();
			} else if(object.hasClass("date_map_conteiner4")) {
				$("div.arrow_map_contleft").show();
				dateMapNormalRight();
			} else if(object.hasClass("date_map_conteiner5")) {
				$("div.arrow_map_contleft").show();
				dateMapSmallRight();
			}
			return false;
		});
		
		$("ul.question_answer a").click(function() {
			$("ul.question_answer a").removeClass("activeAnswer").next().hide();
			if($(this).hasClass("activeAnswer")) {
				$(this).removeClass("activeAnswer").next().hide();
			} else {
				$(this).addClass("activeAnswer").next().show();
			}
			return false;
		});
		
		$("ul.modelMenu a").live("click", function() {
			var text = $("ul.modelMenu li.activeModel").text();
			$("ul.modelMenu li.activeModel").removeClass("activeModel").html("<a href='#'>"+text+"</a>");
			$("div.modelContent").hide();
		
			text = $(this).text();
			var model = $(this).parent().attr("class").replace(" ", "");
			$(this).parent().addClass("activeModel").text(text);
			$("div#"+model).show();
			return false;
		});
		
		$("div.tech_params_css_block table tr td:first-child").wrapInner('<span></span>');
		$("div.tech_params_css_block table tr td:first-child").wrapInner('<div class="aboutCinema"></div>');
		//$("div.tech_params_css_block table tr td:odd").css("vertical-align","bottom");
		$("div.tech_params_css_block table tr td:first-child span").each(function() {
			if($(this).css("height")!="20px") $(this).css("display","inline").css("padding-bottom","2px");
		});
		
		$("#goodSearch").live("focus", function() {
			if ($(this).val()=='Введите название товара, фирму производителя') {
				$(this).val('');
				$(this).css('color','#000').css('font-style','normal');
			}
		}).live("blur",function() {
			if ($(this).val()=='') {
				$(this).val('Введите название товара, фирму производителя');
				$(this).css('color','#b9b9b9').css('font-style','italic');
			}
		});
	
});

function dateMapSmallLeft() {
	$(object)
	.removeClass("date_map_conteiner1").addClass("date_map_conteiner3").next("span[class*='date']")
	.removeClass("date_map_conteiner2").addClass("date_map_conteiner4").next("span[class*='date']")
	.removeClass("date_map_conteiner3").addClass("date_map_conteiner5").next("span[class*='date']")
	.removeAttr("class").addClass("date").hide().next("span[class*='date']")
	.removeAttr("class").addClass("date").hide();
	
	$(object).prev("span[class*='date']")
	.addClass("date_map_conteiner2").show().prev("span[class*='date']")
	.addClass("date_map_conteiner1").show();
}

function dateMapNormalLeft() {
	$(object)
	.removeClass("date_map_conteiner2").addClass("date_map_conteiner3").next("span[class*='date']")
	.removeClass("date_map_conteiner3").addClass("date_map_conteiner4").next("span[class*='date']")
	.removeClass("date_map_conteiner4").addClass("date_map_conteiner5").next("span[class*='date']")
	.removeAttr("class").addClass("date").hide();
	
	$(object).prev("span[class*='date']")
	.removeClass("date_map_conteiner1").addClass("date_map_conteiner2").prev("span[class*='date']")
	.addClass("date_map_conteiner1").show();
}

function dateMapNormalRight() {
	$(object)
	.removeClass("date_map_conteiner4").addClass("date_map_conteiner3").next("span[class*='date']")
	.removeClass("date_map_conteiner5").addClass("date_map_conteiner4").next("span[class*='date']")
	.addClass("date_map_conteiner5").show();
	
	$(object).prev("span[class*='date']")
	.removeClass("date_map_conteiner3").addClass("date_map_conteiner2").prev("span[class*='date']")
	.removeClass("date_map_conteiner2").addClass("date_map_conteiner1").prev("span[class*='date']")
	.removeAttr("class").addClass("date").hide();
}

function dateMapSmallRight() {	
	$(object)
	.removeClass("date_map_conteiner5").addClass("date_map_conteiner3").next("span[class*='date']")
	.addClass("date_map_conteiner4").show().next("span[class*='date']")
	.addClass("date_map_conteiner5").show();
	
	$(object).prev("span[class*='date']")
	.removeClass("date_map_conteiner4").addClass("date_map_conteiner2").prev("span[class*='date']")
	.removeClass("date_map_conteiner3").addClass("date_map_conteiner1").prev("span[class*='date']")
	.removeAttr("class").addClass("date").hide().prev("span[class*='date']")
	.removeAttr("class").addClass("date").hide();
}
		
/* 		$("span.date, div.arrow_map_cont").live("click", function() {
			if($(this).hasClass("arrow_map_contleft")) {
				object = $("span.date_map_conteiner2");
			} else if($(this).hasClass("arrow_map_contright")) {
				object = $("span.date_map_conteiner4");
			}else {
				object = $(this);
			}
			
			if(!object.prev().hasClass("date")) {
				$("div.arrow_map_contleft").hide();
			}
			if(!object.next().hasClass("date")) {
				$("div.arrow_map_contright").hide();
			}
			
			var year = object.find('span').attr("rel");
			var items = object.attr("rel").split("_");
			$("span.objectSmal").find("a").hide();
			var objects = $("span.objectSmal").get();
			$.each(objects, function(key, field){
				if($(this).find("a[class*='"+year+"']").length > 0) {
					$(this).fadeIn(500).find("a[class*='"+year+"']").css("display","");
				} else {
					$(this).fadeOut(500).find("a").hide();
				}
			});
			$("p.yearTxt").text(year+" год");
			$("a.cimenaTxt").text(items[0]);
			$("p.subMap").html(items[1]+"<br>"+items[2]+"<br>"+items[3]);
			
			if(object.hasClass("date_map_conteiner1")) {
				$("div.arrow_map_contright").show();
				dateMapSmallLeft();
			}else if(object.hasClass("date_map_conteiner2")) {
				$("div.arrow_map_contright").show();
				dateMapNormalLeft();
			} else if(object.hasClass("date_map_conteiner4")) {
				$("div.arrow_map_contleft").show();
				dateMapNormalRight();
			} else if(object.hasClass("date_map_conteiner5")) {
				$("div.arrow_map_contleft").show();
				number = $('span.date_map_conteiner5').find("a").text().length;
				if(number > 4) {
					left = 500;
				} else {
					left = 440;
				}
				dateMapSmallRight();
			}
			return false;
		});
});

function dateMapSmallLeft() {
	$("span.date_map_conteiner4").stop(true,true).animate({
		left: 750,
		bottom: 86
	},500).fadeOut(500, function(){$(this).css("left","").removeAttr("class").addClass("date")});
	
	$("span.date_map_conteiner5").fadeOut(500, function(){$(this).removeAttr("class").addClass("date")});

	$("span.date_map_conteiner1").stop(true,true).animate({
		left: 584,
		bottom: 43
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner1").addClass("date_map_conteiner3");
	});

	$("span.date_map_conteiner2").stop(true,true).animate({
		left: 715,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner2").addClass("date_map_conteiner4");
	});
	
	$("span.date_map_conteiner3").stop(true,true).animate({
		left: 930,
		bottom: 86
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner3").addClass("date_map_conteiner5");
	});
	
 	$("span.date_map_conteiner1").prev("span[class*='date']").addClass("date_map_conteiner1").show().stop(true,true).animate({
		left: 405,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner1").addClass("date_map_conteiner2");
	}).prev("span[class*='date']").addClass("date_map_conteiner1").fadeIn();
}

function dateMapNormalLeft() {
	$("span.date_map_conteiner1").stop(true,true).animate({
		left: 405,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner1").addClass("date_map_conteiner2");
	});

	$("span.date_map_conteiner2").stop(true,true).animate({
		left: 565,
		bottom: 43
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner2").addClass("date_map_conteiner3");
	});
	
	$("span.date_map_conteiner3").stop(true,true).animate({
		left: 750,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner3").addClass("date_map_conteiner4");
	});
	
	$("span.date_map_conteiner4").stop(true,true).animate({
		left: 750,
		bottom: 86
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner4").addClass("date_map_conteiner5");
	});
	
	$("span.date_map_conteiner1").prev("span[class*='date']").addClass("date_map_conteiner1").addClass("date").fadeIn();
	$("span.date_map_conteiner5").fadeOut(500, function(){$(this).removeAttr("class").addClass("date")});
}

function dateMapNormalRight() {
	$("span.date_map_conteiner2").stop(true,true).animate({
		left: 238,
		bottom: 86
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner2").addClass("date_map_conteiner1");
	});
	
	$("span.date_map_conteiner3").stop(true,true).animate({
		left: 430,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner3").addClass("date_map_conteiner2");
	});
	
	$("span.date_map_conteiner4").stop(true,true).animate({
		left: 480,
		bottom: 43
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner4").addClass("date_map_conteiner3");
	});
	
	$("span.date_map_conteiner5").stop(true,true).animate({
		left: 650,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner5").addClass("date_map_conteiner4");
	});
	
	$("span.date_map_conteiner5").next("span[class*='date']").addClass("date_map_conteiner5").fadeIn();
	$("span.date_map_conteiner1").fadeOut(500, function(){$(this).removeAttr("class").addClass("date").addClass("date")});
}

function dateMapSmallRight() {	
	$("span.date_map_conteiner1").fadeOut(500, function(){$(this).removeAttr("class").addClass("date")});

	$("span.date_map_conteiner2").stop(true,true).animate({
		left: 238,
		bottom: 86
	},500).fadeOut(500, function(){$(this).css("left","").removeAttr("class").addClass("date")});
	
	$("span.date_map_conteiner3").stop(true,true).animate({
		left: 300,
		bottom: 80
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner3").addClass("date_map_conteiner1");
	});

	$("span.date_map_conteiner4").stop(true,true).animate({
		left: 330,
		bottom: 57
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner4").addClass("date_map_conteiner2");
	});
	
 	$("span.date_map_conteiner5").stop(true,true).animate({
		left: left,
		bottom: 43
	}, 500, function(){
		$(this).css("left","").removeClass("date_map_conteiner5").addClass("date_map_conteiner3");
	});
	
	$("span.date_map_conteiner5").next("span[class*='date']").addClass("date_map_conteiner5").show().stop(true,true).animate({
		left: 680,
		bottom: 57
	},500, function() {
		$(this).css("left","").removeClass("date_map_conteiner5").addClass("date_map_conteiner4");
	}).next("span[class*='date']").addClass("date_map_conteiner5").fadeIn();
} */

function map() {
	drag = $("div.bigMap").width()-2000;
	if($(window).width() >= 2000) {
		$("a#mapRight").hide();
		return false;
	} else {
		$("a#mapRight").show();
	}
	var objects = $("div.bigMapContent").find("span.object").get();
	var mapLeft = parseInt($("div.bigMapContent").css("left"));
	var citiesRight = citiesLeft = 0;
	$.each(objects, function(key, name) {
		var left = parseInt($(this).css("left"));
		if($("div.bigMap").width()-left-mapLeft <= 0) {
			citiesRight = citiesRight + parseInt($(this).attr("rel"));
		}
		if(left+mapLeft <= 0) {
			citiesLeft = citiesLeft + parseInt($(this).attr("rel"));
		}
	});
	if(citiesRight == 0) $("a#mapRight").hide();
	if(citiesLeft == 0) $("a#mapLeft").hide(); else $("a#mapLeft").show();
	$("a#mapRight").html(citiesRight);
	$("a#mapLeft").html(citiesLeft);
}

function removeborderImgBig() {
	$("div.lineAwards").find("a.borderImgBig").find("img").stop().animate({
		width: 75,
		height: 75
	}, 500);
	$("div.lineAwards").find("a.borderImgBig").removeClass("borderImgBig").removeClass("imgThumb").unbind("click").addClass("borderImgSmal").find("span.loupeBig").remove();
}

function slider(key, right) {
	var text = $('div.lineAwards').find("a:eq("+key+")").find("div").html();
	$("div.awards").find("span:eq(0)").html(key+1);
	
		var src = $('div.lineAwards').find("a:eq("+key+")").find("img").attr("src").replace("mini/", "middle/");
		$('div.lineAwards').find("a:eq("+key+")").removeClass("borderImgSmal").addClass("borderImgBig").addClass("imgThumb").find("img").attr("src", src).parent().append('<span class="loupeBig"></span>');
	
	$('div.lineAwards').find("a:eq("+key+")").find("img").css("height","auto");
	$('div.lineAwards').find("a:eq("+key+")").find("img").stop().animate({
		width: 400
	}, 500);
	
	$("p#text").html(text);
	  $('div.lineAwards').stop().animate({
		right: right
	  }, 500);
}

function getNewsAjax(id, limit, year) {
if (id == undefined) {
	id=0;
}
if (limit == undefined) {
	limit=10;
}
if (year == undefined) {
	year=0;
}
	$.ajax({
		method: 'POST',
		url: '/news/index/' + id + '/' + limit + '/' + year + '/ajax',
		success: function(data){
			$('.containerBlock3').html(data);
		}
	});
	return false;
}


function categoryTabs(n) {

	var text = $("ul.typeCatalog li.activeTC span").text();
	$("ul.typeCatalog li.activeTC").removeClass("activeTC").html('<a href="#">'+text+'</a>');
	text = n.find("a").text();
	n.addClass("activeTC").html("<span>"+text+"</span>");
	
	var brand = n.attr("rel").split("_");
	if(parseInt(brand[1]) > 0) {
		$("*[rel^='brand']").hide();
		$("*[rel='brand_"+brand[1]+"']").show();
	} else {
		$("*[rel^='brand']").show();
	}
	
	if(location.href.indexOf("categories/category") > 0) {

		$("div#ajaxGoods").html("<b>Загрузка...</b>");
		$.post('/categories/category/'+brand[2]+'/'+brand[1], function(data) {
			$("div#ajaxGoods").html(data);
		});
		
	}
}
