$(document).ready(function() {
	//Определение порядка
		$(".important .news div:first , .result .r_box:first").addClass("first")
		$(".important .vakansi div:last , .result .r_box:last").addClass("last")
		
		$(".banners td:first").addClass("first")
		$(".banners td:last").addClass("last")
		$(".projects .p_box:first").addClass("first")
		
	//PNG
		$(document).pngFix();

	
	//fancybox
		$("a.fancybox").fancybox().attr('onclick','');
		$(".persona a.fancybox").fancybox({
			'overlayShow': true
		});

	//Подбор ширины
		a=0
		b=0
		a = $(".result .first .big").width()
		b = $(".result .last .big").width()

		if (a>b) {
			$(".result .last .num").width(""+a+"px")
		}else{
			$(".result .first .num").width(""+b+"px")
		}

	//СуперПроекты
		id = 0
		$(".p_box").hover(
			function() {
				id = $(this).attr("id")
				//$(".projects .first").removeClass("first")
				$(".p_box").removeClass("active")
				$(this).addClass("active")

				$("#"+id+" .image").click(
					function() {
						$("#"+id+"").addClass("active_big").removeClass("active").attr("style","z-index: 4;")
						$("#"+id+" .back_g").addClass("big_back_g").removeClass("back_g")
						$("#"+id+" .small").addClass("big").removeClass("small")
						$("#"+id+" .image img").attr("width","260")
						$("#"+id+" .text_small").hide()
						$("#"+id+" .text_big").show()
					}
				)
			},
			function() {
				endClass = $(this).attr("class")
				endClass = endClass.replace('p_box','').replace('first','')

				if (endClass = 'active_big') {
					$("#"+id+"").removeClass("active_big").addClass("active").attr("style","")
					$("#"+id+" .big_back_g").removeClass("big_back_g").addClass("back_g")
					$("#"+id+" .small").addClass("small").removeClass("big")
					$("#"+id+" .image img").attr("width","155")
					$("#"+id+" .text_small").show()
					$("#"+id+" .text_big").hide()
				}
				
				if (endClass != "first") {
					$(this).removeClass("active")				
					$('.first').addClass('active')	
				}			
			}
		)

	//Текст
		$(".content ul , .content ol").addClass("light_grey")
		$(".content h1 , .content h2 , .content h3").addClass("dark_grey")

	//Карусель картинок
		$("#viewer").imageScroller({
			next:"next",
			prev:"prev",
			frame:"viewerFrame",
			width:170,
			child:"a",
			auto:false
		});
		$(".imager #next, .imager #prev").click(function() {$("a.fancybox").fancybox();return false;})
	
	//search
		$(".go_search").toggle(
			function() {
				if ($.browser.msie) {
					$(".search_form").show()
				}else{
					$(".search_form").fadeIn()
				}
				return false;
			},
			function() {
				if ($.browser.msie) {
					$(".search_form").hide()
				}else{
					$(".search_form").fadeOut()
				}
				return false;
			}
		)
	
		$(".what_search").attr("value","Поиск по сайту")
		$(".what_search").click(function() {
			if ( $(this).attr("value") == "Поиск по сайту" ) {
				$(this).attr("value","")
				a = $(this).attr("value")
			}
		})
		$(".what_search").blur(function() {			
			if ( $(this).attr("value") == a ) {
				$(this).attr("value","Поиск по сайту")
			}
		})
});

