	var min_browser_padding = 80;
	var max_browser_padding = 217;
	var min_browser_height = 617;
	var max_browser_height = 754;
	var padding_timer;
	
	function adjust_browser_padding() {
		var browser_height = document.viewport.getHeight();
		if (browser_height < max_browser_height) {
			var padding = (browser_height > min_browser_height) ? browser_height - min_browser_height + min_browser_padding : min_browser_padding;
			$('main').setStyle({
				paddingTop: padding + 'px',
				backgroundPosition: '0 -' + (max_browser_padding - padding) + 'px'
			});
			$('container').setStyle({ backgroundPosition: '0 -' + (max_browser_padding - padding) + 'px' });
		}
	}
	
	Event.observe(document, "dom:loaded", function() {
		var default_search = 'Search by project, client, service, or keyword';
		if ($('search_text')) {
			$('search_text').onfocus = function() { if ($(this).value == default_search) $(this).value = ''; }
			$('search_text').onblur = function() { if ($(this).value == '') $(this).value = default_search; }
			$('search_text').next('a').onclick = function() {
				if ($('search_text').value != default_search) $(this).up('form').submit();
				return false;
			}
		}
		
		if ($('emma_member_email')) {
			$('emma_member_email').onfocus = function() { if (this.value == 'email') this.value = ''; }
			$('emma_member_email').onblur = function() { if (this.value == '') this.value = 'email'; }
		}
		
		// fix home page callout backgrounds
		$$('#home-callouts .callout').each(function(x) {
			x.down('.bg').setStyle({ height: $(x).getHeight() + 'px' });
			x.down('.callout-link').setStyle({ height: $(x).getHeight() + 'px' });
		});
		
		// if this is the home page, adjust padding with the browser
		if ($('container').className.startsWith('home-bg'))
			padding_timer = setInterval('adjust_browser_padding()', 1);
		
		$$('ul#nav li').each(function(li) {
			li.onmouseover = function() {
				if ($(this).down('ul')) {
					$('nav-overlay').show(); // at least two levels deep, show first overlay
					
					// two levels deep, show second overlay
					if ($(this).down('ul').hasClassName('tertiary')) {

						$('nav-overlay2').show();
					}
					
					$(this).addClassName('selected').down('ul').show();
				}
			}
			li.onmouseout = function() {
				$('nav-overlay').hide();
				$('nav-overlay2').hide();
				$(this).removeClassName('selected');
				if ($(this).down('ul')) $(this).down('ul').hide();
			}
		});
		
		// check #main height to ensure it doesn't extend past the image
		if ($$('.home-bg-1, .home-bg-2, .home-bg-3').length) {
			var main_height = $('main').getHeight();
			if (main_height > 1656) {
				var decrement = main_height - 1656;
				$('main').setStyle({
					paddingBottom: parseInt($('main').getStyle('paddingBottom')) - decrement + 'px'
				});
			}
		}
	});
	
	function get_window_height() {
		// retrieve the height of the document including scrollable area
		var document_height, window_height;
		
		if (window.innerHeight && window.scrollMaxY) document_height = window.innerHeight + window.scrollMaxY;
		else if (document.body.scrollHeight > document.body.offsetHeight) document_height = document.body.scrollHeight;
		else document_height = document.body.offsetHeight;
		
		if (self.innerHeight) window_height = self.innerHeight;
		else if (document.documentElement && document.documentElement.clientHeight) window_height = document.documentElement.clientHeight;
		else if (document.body) window_height = document.body.clientHeight;
		
		return (document_height < window_height) ? window_height : document_height;
	}