Event.observe(window,'load', function () {
	// HEADER LOGIN FORM CODE -------------------------------------------
	if ($('header_login')) {
		//when the login fields gain focus, hide the placeholder text.
		$$('#header_login label input').invoke('observe', 'focus', function (event) {
			this.up().down('span').hide();
		}).invoke('observe', 'blur', function (event) {
			if (this.value.strip() === '') {
				this.up().down('span').show();
			}
		});
		$$('#header_login label span').invoke('observe', 'click', function (event) {
			this.up().down('input').focus();
			event.stop();
		});

		//on page load, test to see if the browser autofilled the login fields.  if it has, hide the placeholders
			var keeptesting = 1;
			var testAutofill = function () {
				$$('#header_login label input').each(function (e) {
					if (e.value.strip() !== '') {
						e.up().down('span').hide();
						keeptesting = 0;
					}
				});
			
				if (keeptesting && keeptesting < 4) { //test for two seconds after page load
					keeptesting++;
					setTimeout(testAutofill, 500);
				}
			};
			testAutofill();
	}
	
	
	// GOOGLE ANALYTICS CODE -------------------------------------------
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-4683256-1']);
    _gaq.push(['_trackPageview']);

    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
	

});

Event.observe(document,'dom:loaded', function () {

	// FOOTER EXPANSION CODE -------------------------------------------	
	function idoc_expandfooter() {
		var contentHeight = $$('body>section').first().getHeight() + 133 + 45;
		var footer = $('footerwrap');
		if (contentHeight + 100 < document.viewport.getHeight()) {
			var h = document.viewport.getHeight() - contentHeight -1;
			footer.setStyle({height:h+'px'});
		} else {
			footer.setStyle({height:'100px'});
		}
	}
	
	idoc_expandfooter();
	Event.observe(window, 'resize', idoc_expandfooter);
	
});

