$(function() {

	$('a.target_blank').each(function() {
			$(this).click(function(){window.open(this.href);return false;});
		}
	);
	
	// Clear the default Text #name #email #phone #message
	function defaultText(field) {
		if ($('#'+field).val() == 'Enter your '+field) { $('#'+field).css('color', '#aaa'); }
		$('#'+field).focus(function() { $(this).css('background-color','#ff9'); if ($(this).val() == 'Enter your '+field) { $(this).val(''); $(this).css('color', '#000'); } });
		$('#'+field).blur(function() { $(this).css('background-color','#fff'); if ($(this).val() =='') { $(this).val('Enter your '+field); $(this).css('color', '#aaa'); } });
	}
	var fields = Array('name', 'email', 'phone', 'message', 'field', 'institution', 'url', 'specialty', 'position');
	for (var i=0; i<fields.length; i++)
		defaultText(fields[i]);

	// make the drop down menus work in ie6
	if ($.browser.msie && $.browser.version < 7) {
		$('#nav ul.top-level li').hover(
			function() {
				$('ul', this).css('left', '0');
				$('ul', this).css('bottom', '33px');
			},
			function() {
				$('ul', this).css('left', '-999em');
			}
		);

		$('#menu-main-1').hover(
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) 0 -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) 0 -36px no-repeat');
			}
		);

		$('#menu-main-2').hover(
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) -82px -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) -82px -36px no-repeat');
			}
		);
		
		$('#menu-main-3').hover( 
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) -179px -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) -179px -36px no-repeat');
			}
		);
		
		$('#menu-main-4').hover( 
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) -276px -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) -276px -36px no-repeat');
			}
		);
		
		$('#menu-main-5').hover( 
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) -381px -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) -381px -36px no-repeat');
			}
		);

		$('#menu-main-6').hover( 
			function() {
				$('a.base-link', this).css('background', 'url(/common/images/nav.gif) -476px -36px no-repeat');
			},
			function() {
				$('a.base-link', this).css('background', 'none');
				$('a.selected', this).css('background', 'url(/common/images/nav.gif) -476px -36px no-repeat');
			}
		);
	}
});