// JavaScript Document

var allDrops = ['aboutDrop','servicesDrop','advocacyDrop','collabDrop','newsDrop'];

$(document).ready(function() {
	$('#navAbout').hover(function() {
		closeAllDrops();
		$('.aboutDrop').show();
	});
	$('#navServices').hover(function() {
		closeAllDrops();
		$('.servicesDrop').show();
	});
	$('#navAdvocacy').hover(function() {
		closeAllDrops();
		$('.advocacyDrop').show();
	});
	$('#navCollab').hover(function() {
		closeAllDrops();
		$('.collabDrop').show();
	});
	$('#navNews').hover(function() {
		closeAllDrops();
		$('.newsDrop').show();
	});
	$('.navigation').hover(function() {
	}, function() {
		closeAllDrops();
	});
	$('.donateButton').hover(function() {
	}, function() {
		closeAllDrops();
	});
	$('#navHome').hover(function() {
	}, function() {
		closeAllDrops();
	});
	
	$('#searchTerm').keyup(function(e) {
		if(e.keyCode == 13) {
			submitSearch();
		}
	});

});

function closeAllDrops() {
	for (i =0; i < allDrops.length; i++) {
		$('.'+allDrops[i]).hide();
	}
}

function submitSearch() {
	var srch = $('#searchTerm').val();
	if (srch.length > 2) {
		window.location.href = "http://streetvirusdev.com/learningrights/?s="+srch;
	}
}
