	
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	var is_safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
	var is_ie6 = false;
	var is_ie7 = false;
	var is_ie8 = false;
	jQuery.each(jQuery.browser, function(i, val){
		if(i=="msie" && jQuery.browser.version.substr(0,3)=="6.0"){is_ie6 = true;}
		if(i=="msie" && jQuery.browser.version.substr(0,3)=="7.0"){is_ie7 = true;}
		if(i=="msie" && jQuery.browser.version.substr(0,3)=="8.0"){is_ie8 = true;}
	});
	
	var scr, scrbar, block, content, block_height, content_height, content_delta, scroller_theight, scroller_height, scroller_delta, delta, canDrag, shift_y, scrup, scrdown;
	var animation_completed = true;
	
	
	// HTML 5 Support for IE
	if ($.browser.msie){
		document.createElement('header');
		document.createElement('footer');
		document.createElement('nav');
		document.createElement('section');
	}
	// -
	
	
	// Body Onload
	$(window).load(function(){
		fixHeader();
		fixFooter();
		addScroll('scrollable-1', 'overflow-1', 'scrollbar-1');
	});
	// -
	
	
	// Window Onscroll
	$(window).scroll(function(){
		fixHeader();
	});
	// -
	
	
	// Window Onresize
	$(window).resize(function(){
		fixHeader();
	});
	
	
	// Miracles :)
	$(document).ready(function(){
		fixHeader();
		fixFooter();
		if ($.browser.webkit) { $('div.table').addClass('webkit'); }
		if (is_ie7) { $('table.screen').attr('cellspacing','0'); $('ul.awards table.logo').attr('cellspacing','0'); $('ul.partners table.logo').attr('cellspacing','0'); }
	});
	// -
	
	
	// Fix Header
	function fixHeader(){
		document_height = $(document).height();
		window_height = $(window).height();
		if (window_height < document_height) {
			scroll_top = $(window).scrollTop() / -1;
			$('header').css({'top':scroll_top});
		} else {
			$('header').css({'top':'0px'});
		}
	}
	// -
	
	
	// Fix Footer
	function fixFooter(){
		window_width = $(window).width();
		stream_width = $('div.stream').width();
		if (stream_width > window_width) {
			$('footer').width(stream_width);
		}
	}
	// -
	
	
	// Auto hide/show label on text field
	$(document).ready(function() {
		$('.autolabel').focus(function () {
			if ($(this).attr('defaultValue') && $(this).attr('defaultValue') == $(this).val()) {
				$(this).val('')
			}
		});
		$('.autolabel').blur(function () {
			if ($(this).attr('defaultValue') && $(this).val() == '') {
				$(this).val($(this).attr('defaultValue'));
			}
		});
	});
	// -
	
	
	// Pager
	$(document).ready(function(){
		$('div.pager ul li').hover(function(){
			if (!$(this).hasClass('selected')) { $(this).addClass('hovered'); }
		}, function(){
			$(this).removeClass('hovered');
		});
		$('div.pager ul li').click(function(){
			$(this).parent().find('li').removeClass('selected');
			$(this).removeClass('hovered');
			$(this).addClass('selected');
		});
	});
	// -
	
	
	// Awards Slider & Pager
	$(document).ready(function(){
		$('section.awards div.next').click(function(){ awardsNext(); });
		$('section.awards div.prev').click(function(){ awardsPrev(); });
		$('section.awards div.pager ul li').click(function(i){
			page_index = $(this).index();
			awardsPage(page_index);
		});
	});
	function awardsNext(){
		if (animation_completed) {
			overflow = $('div.slider1 div.overflow');
			table = $('div.slider1 table.screen');
			pages = table.find('td.screen').length;
			overflow_width = overflow.width();
			table_width = table.width();
			table_margin = parseInt(table.css('margin-left'));
			margin = table_margin - overflow_width;
			max_margin = (table_width - overflow_width) * -1;
			if (margin >= max_margin){
				animation_completed = false;
				new_page = (margin / overflow_width) * -1;
				$('section.awards div.pager ul li').removeClass('selected');
				$('section.awards div.pager ul li').each(function(i){
					if (new_page == i) {
						$(this).addClass('selected');
					}
				});
				table.stop().animate({'margin-left':margin}, 500, function(){
					animation_completed = true;
				});
			} else {
				animation_completed = false;
				margin = 0;
				new_page = 0;
				$('section.awards div.pager ul li').removeClass('selected');
				$('section.awards div.pager ul li:first').addClass('selected');
				table.stop().animate({'margin-left':margin}, 500, function(){
					animation_completed = true;
				});
			}
		}
	}
	function awardsPrev(){
		if (animation_completed) {
			overflow = $('div.slider1 div.overflow');
			table = $('div.slider1 table.screen');
			pages = table.find('td.screen').length;
			overflow_width = overflow.width();
			table_width = table.width();
			table_margin = parseInt(table.css('margin-left'));
			margin = table_margin + overflow_width;
			max_margin = 0;
			if (margin <= max_margin){
				animation_completed = false;
				new_page = (margin / overflow_width) * -1;
				$('section.awards div.pager ul li').removeClass('selected');
				$('section.awards div.pager ul li').each(function(i){
					if (new_page == i) {
						$(this).addClass('selected');
					}
				});
				table.stop().animate({'margin-left':margin}, 500, function(){
					animation_completed = true;
				});
			} else {
				animation_completed = false;
				margin = (table_width - overflow_width) * -1;
				new_page = pages;
				$('section.awards div.pager ul li').removeClass('selected');
				$('section.awards div.pager ul li:last').addClass('selected');
				table.stop().animate({'margin-left':margin}, 500, function(){
					animation_completed = true;
				});
			}
		}
	}
	function awardsPage(page){
		overflow = $('div.slider1 div.overflow');
		table = $('div.slider1 table.screen');
		overflow_width = overflow.width();
		table_width = table.width();
		table_margin = parseInt(table.css('margin-left'));
		margin = (page * overflow_width) * -1;
		animation_completed = false;
		table.stop().animate({'margin-left':margin}, 500, function(){
			animation_completed = true;
		});
	}
	// -
	
	
	// Initiatives Pager
	$(document).ready(function(){
		$('section.initiatives div.next').click(function(){ initiativesNext(); });
		$('section.initiatives div.prev').click(function(){ initiativesPrev(); });
		$('section.initiatives div.pager ul li').click(function(i){
			page_index = $(this).index();
			initiativesPage(page_index);
		});
	});
	function initiativesPage(page){
		overflow = $('section.initiatives div.overflow');
		table = $('section.initiatives div.overflow div.table');
		overflow_width = overflow.width();
		table_width = table.width();
		table_margin = parseInt(table.css('margin-left'));
		margin = (page * overflow_width) * -1;
		animation_completed = false;
		table.stop().animate({'margin-left':margin}, 500, function(){
			animation_completed = true;
		});
	}
	// -
	
	
	// Portfolio
	$(document).ready(function(){
	
		/*// Onload
		$('section.portfolio ul.presentation a:first').addClass('hovered');
		$('section.portfolio div.img img:first').addClass('active');
		
		// Hover
		$('section.portfolio ul.presentation a').each(function(i){
			$(this).mouseover(function(){
				if (!$(this).hasClass('hovered')) {
					link_index = i;
					$('section.portfolio ul.presentation a').removeClass('hovered');
					$(this).addClass('hovered');
					$('section.portfolio div.img img.active').fadeOut(200, function(){
						$('section.portfolio div.img img').removeClass('active');
						$('section.portfolio div.img img').each(function(i){
							if (i == link_index) {
								$(this).fadeIn(200, function(){
									$(this).addClass('active');
								});
							}
						});
					});
				}
			});
		});*/
	
	});
	// -
	
	
	// People Hover
	$(document).ready(function(){
		$('ul.people li').hover(function(){
			if (!$(this).hasClass('selected')) {
				$('ul.people li').removeClass('selected');
				$(this).find('img.color').stop().fadeIn(0).fadeTo(0, 0).fadeTo(500, 1);
				if (!$.browser.msie) {
					$('ul.people div.info').fadeOut(0);
					$(this).find('div.info').fadeIn(250, function(){
						$(this).addClass('selected');
					});
				} else {
					$('ul.people div.info').css({'display':'none'});
					$(this).find('div.info').css({'display':'block'});
					$(this).addClass('selected');
				}
			}
		}, function(){
			$(this).find('img.color').stop().fadeOut(0);
			if (!$.browser.msie) {
				$(this).find('div.info').fadeOut(0);
			} else {
				$(this).find('div.info').css({'display':'none'});
			}
			$(this).removeClass('selected');
		});
		$('ul.people div.info').mouseover(function(){
			if (!$.browser.msie) {
				$(this).fadeOut(0);
			} else {
				$(this).css({'display':'none'});
			}
		});
	});
	// -
	
	
	// Add Scroll
	function addScroll(scrollable, overflow, scrollbar){

		// Проверочка на наличия всех трех состоавляющих
		if ($('#'+scrollable).length > 0 && $('#'+overflow).length > 0 && $('#'+scrollbar).length > 0) {
		
			// Решаем, отображать ли скроллбар
			if ($('#'+scrollable).height() > $('#'+overflow).height()) {
				$('#'+scrollbar).css({'display':'block'});
			}
			
			// Собираем размеры и прочие параметры
			scr = $('#'+scrollbar);
			scrbar = scr.find('div.scroll')
			block = $('#'+overflow);
			content = $('#'+scrollable);
			block_height = block.height();
			content_height = content.height();
			content_delta = (content_height - block_height) * -1;
			scroller_theight = scr.height();
			scroller_height = Math.round( (block_height * scroller_theight) / content_height );
			scroller_delta = scroller_theight - scroller_height;
			delta = (content_delta / scroller_delta) * -1;
			scrbar.css({'top':'0px','height':scroller_height});
			content.css({'margin-top':'0px'});
			canDrag = false;
			shift_y = 0;
			
			// Вешаем события, чтобы скроллом можно было пользоваться
			$('#'+scrollbar).find('div.scroll').mousedown(function(e){
				if (!e){
					e = window.event;
				}
				
				scr = $(this).parent();
				scrbar = $(this);
				block = $(this).parent().parent().find('div.overflow');
				content = $(this).parent().parent().find('div.scrollable');
				block_height = block.height();
				content_height = content.height();
				content_delta = (content_height - block_height) * -1;
				scroller_theight = scr.height();
				scroller_height = Math.round( (block_height * scroller_theight) / content_height );
				scroller_delta = scroller_theight - scroller_height;
				delta = (content_delta / scroller_delta) * -1;
				canDrag = true;
				shift_y = e.clientY - parseInt($(this).css('top'));
				
				blockEvent(e);
				return false;
			});
			
			$(document).mousemove(function(e){
				if (!e){
					e = window.event;
				}
				if (canDrag){
					var aaa = e.clientY - shift_y;
					setPosition(aaa);
					blockEvent(e);
				}
				return false;
			});
			
			$(document).mouseup(function(e){
				canDrag = false;
			});
			
			if (document.getElementById(scrollable).addEventListener)
			{
				document.getElementById(scrollable).addEventListener('DOMMouseScroll', wheel, false);
			}
			document.getElementById(scrollable).onmousewheel = function(e){
				wheel(e, this.id);
			};
			
		}
		
	}
	function blockEvent(event) {
		if (!event) {
			event = window.event;
		}
		if(event.stopPropagation) event.stopPropagation();
		else event.cancelBubble = true;
		if(event.preventDefault) event.preventDefault();
		else event.returnValue = false;
	}
	function setPosition(newPosition)
	{
		if ( (newPosition <= scroller_theight - scroller_height) && (newPosition >= 0) )
		{
			pos = newPosition + "px";
			scrbar.css({'top':pos});
		}
		else if (newPosition > scroller_theight - scroller_height)
		{
			pos = (scroller_theight - scroller_height) + "px";
			scrbar.css({'top':pos});
		}
		else
		{
			scrbar.css({'top':'0px', 'left':'0px'});
		}
		
		var mtop = Math.round( parseInt(scrbar.css('top'))  * delta * (-1) );
		
		if (mtop < content_delta)
		{
			pos = content_delta + "px";
			content.css({'margin-top':pos});
		}
		else
		{
			pos = mtop + "px";
			content.css({'margin-top':pos});
		}
		return false;
	}
	function wheel(event, wheel_id)
	{
		// Переменная, в которой будем хранить сдвиг
		var wheelDelta = 0;

		// Шаг меню при прокрутке
		var step = 30;
		if (!event)
		{
			event = window.event;
		}
		if (event.wheelDelta)
		{
			// В IE и Opera при сдвиге колеса на один шаг event.wheelDelta принимает значение 120
			// Значения сдвига в этих двух браузерах совпадают по знаку.
			wheelDelta = -event.wheelDelta/120;
		} 
		else if (event.detail)
		{
			// В Mozilla, значение wheelDelta отличается по знаку от значения в IE.
			// Сдвиг колеса на один шаг соответствует значению 3 параметра event.detail
			wheelDelta = event.detail/3;
		}
		// При скроллинге вверх wheelDelta > 0
		// При скролинге вниз - wheelDelta < 0
		if (wheelDelta)
		{
			if ($.browser.mozilla) {
				scr = $(this).parent().parent().find('div.scroll').parent();
				scrbar = $(this).parent().parent().find('div.scroll');
				block = $(this).parent();
				content = $(this);
				scroll_up = scr.find('span.top');
				scroll_down = scr.find('span.bottom');
				block_height = block.height();
				content_height = content.height();
				content_delta = (content_height - block_height) * -1;
				scroller_theight = scr.height();
				scroller_height = Math.round( (block_height * scroller_theight) / content_height );
				scroller_delta = scroller_theight - scroller_height;
				delta = (content_delta / scroller_delta) * -1;
				var currentPosition = parseInt(scrbar.css('top'));
				var newPosition = wheelDelta * step + currentPosition;
				setPosition(newPosition);
			} else {
				wheel_id = '#'+wheel_id;
				scrbar = $(wheel_id).parent().parent().find('div.scroll');
				scr = $(wheel_id).parent().parent().find('div.scroll').parent();
				block = $(wheel_id).parent();
				content = $(wheel_id);
				scroll_up = scr.find('span.top');
				scroll_down = scr.find('span.bottom');
				block_height = block.height();
				content_height = content.height();
				content_delta = (content_height - block_height) * -1;
				scroller_theight = scr.height();
				scroller_height = Math.round( (block_height * scroller_theight) / content_height );
				scroller_delta = scroller_theight - scroller_height;
				delta = (content_delta / scroller_delta) * -1;
				var currentPosition = parseInt(scrbar.css('top'));
				var newPosition = wheelDelta * step + currentPosition;
				setPosition(newPosition);
			}
		}

		if (event.preventDefault)
		{
			event.preventDefault();
		}
		event.returnValue = false;
		blockEvent(event);
	}
	// -
