$(document).ready(function() {
	// Show/Hide the drop downs
	$('#globalNav li').hover(function() {
		$(this).children('ul').css('display','block');
	},function() {
		$(this).children('ul').css('display','none');
	});
		
	// Same page links highlight the 
	$('a.samePage').click(function() {
		var id = $(this).attr('href');
		$(id).css('background-color','#fea620');
		$(id).animate({backgroundColor:'#fff'},1000);
	});
	
	// Links to external sites will open in a new window
	$('a.newWin').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	// Clear or replace default value inside input field
	$('#search-box input.search')
		.focus(function() {
			if (this.value == this.defaultValue) this.value = '';
		})
		.blur(function() {
			if (!this.value.length) this.value = this.defaultValue;
		});
	
	// Toggle directions on the locations page
	$('.locationInfo div.directions').css('display','none');
	$('a.toggleDirs').click(function() {
		var dirs = $(this).parent('p').siblings('div.directions');
		if ($(dirs).css('display') == 'block') {
			$(dirs).css('display','none'); $(this).text('show directions');
		} else {
			$(dirs).css('display','block'); $(this).text('hide directions');
		}
		return false;
	});
	
	// Assign callback to onclick event for demo links
	$('a.demoLink').click(function() {
		window.open($(this).attr('href'),'_blank','height=450,width=575,toolbar=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no');
		return false;
	});
 });
