$(document).ready(function() {
	/* вкладки */
	$('ul.tabs').each(function() {
    $(this).find('li').each(function(i) {
      $(this).click(function(){
        $(this).addClass('current').siblings().removeClass('current')
          .parents('div.section').find('div.box').hide().end().find('div.box:eq('+i+')').show();
		});
	  });
	});
	/* форма поиска */
	$("#main-right form input[type=text]").focus(function() {
		if($(this).val()=="введите фразу для поиска") {
			$(this).val("");
		}
	});
	$("#main-right form input[type=text]").blur(function() {
		if($(this).val()=="") {
			$(this).val("введите фразу для поиска");
		}
	});	
	/* top-menu */
	$("#top-menu ul li a").each(function() {
		if($(this).parent().find("ul").length>0) {
			$(this).addClass("popup");
		}
	});
	$("#top-menu ul li").hover(function() {
		if($(this).find("ul").length>0) {
			$(this).find("a").addClass("popup-hover");
			$(this).find("ul").show();
		} else {
			$(this).addClass("hover");
		}
	}, function() {
		$(this).find("a").removeClass("popup-hover");
		$(this).find("ul").hide();	
	});
	
	/* правое меню */
	$("div.box-cont>ul>li>a").click(function() {
		$("div.box-cont>ul>li>span").css("display","none");
		$("div.box-cont>ul>li>a").removeClass("current");
		var cur = $(this);
		cur.parent().find(">span").css("display","block");
		cur.addClass("current");
		return false;
	});
	/* цитата (темно-зеленая с кавычками */
	$("p.quot").each(function() {
		$(this).prepend("<span class='q-before'></span><span class='q-after'></span>");
	});
	/* форматирование таблиц
	$("td:first-child").each(function() {
		$(this).css("text-align","left");
	});
	$("th:first-child").each(function() {
		$(this).css("text-align","left");
	});
	$("th:last-child").each(function() {
		$(this).css("border-right","#3e464c solid 1px");
	});  */
	/* стилизованные radio, checkbox */
	$("#main-left form input[type=checkbox]").each(function() {
		$(this).addClass("styled");
	});
	$("#main-left form input[type=radio]").each(function() {
		$(this).addClass("styled");
	});
	/* стилизованный select */
	var params = {
		changedEl: "#main-left select",
		visRows: 10
	}
	cuSel(params);	
	/* ie хаки */
	if ($.browser.msie) {
		$("#intro-bottom h3").each(function() {
			if($(this).find("a").length==0) {
				$(this).textShadow();
			}
		});
		$("#intro-bottom h3 a").textShadow();
		$("#intro-bottom h4").textShadow();
		$("div.gb-bottom").each(function() {
			var cur;
			if($(this).find("a").length>0) {
				cur = $(this).find("a");
			} else {
				cur = $(this);
			}
			cur.html("<span class='va-main'>"+cur.html()+"</span><span class='va-dummy'></span>");
		});
		$("a.hb-text").each(function() {
			var cur;
			cur = $(this);
			cur.html("<span class='va-main'>"+cur.html()+"</span><span class='va-dummy'></span>");
		});	
		$("#top-menu>ul>li>ul>li:last-child").addClass("last-child");
		$("#top-menu>ul>li>a").each(function() {
			$(this).html("<span class='tml'>&nbsp;</span><span class='tmr'>"+$(this).html()+"</span>");
		});
	}
	
	/* lightbox */
	$("a.ic-zoom").each(function() {
		$(this).lightBox();
	});
	$("a.lightbox").each(function() {
		$(this).lightBox();
	});
	$("a.ic-change").click(function() {
		if($("#ic-001").hasClass("current")) {
			$("#ic-001").removeClass("current");
			$("#ic-002").addClass("current");
		} else {
			$("#ic-001").addClass("current");
			$("#ic-002").removeClass("current");
		}
		return false;
	});
});
