// These functions are needed site-wide, include core.js on every page.

$(document).ready(function() {
	
// DROPDOWN MENU
$('#nav li').hover(
	function () {
		$(this).children('a:first').addClass("hover");	
		$('ul', this).stop(true,true).slideDown(200);
	}, 
	function () {
		$(this).find('a').removeClass("hover");
		$('ul', this).stop(true,true).slideUp(100);			
	}
);	

//  Highlight active sub-nav item.  Uncomment this to activate it
//  $('a','.sub-nav').each(function() {
// 		if ( window.location.href == this.href ) {
// 				$(this).addClass('active');
// 			}
//  });
	
// STIPED TABLES
$("table.striped tr:odd").addClass("alt-row");
	
	
// HTML5 Placeholder //
// Return if native support is available.	
if ("placeholder" in document.createElement("input")) return;
	$(':input[placeholder]').each(function() {
		setupPlaceholder($(this));
	}); 
	$('form').submit(function(e) {
		clearPlaceholdersBeforeSubmit($(this));
	});
function setupPlaceholder(input) {
	var placeholderText = input.attr('placeholder');
	if (input.val() === '') input.val(placeholderText);
	input.bind({
		focus: function(e) {
			if (input.val() === placeholderText) input.val('');
		},
		blur: function(e) {
			if (input.val() === '') input.val(placeholderText); 
		}
	});
}
function clearPlaceholdersBeforeSubmit(form) {
	form.find(':input[placeholder]').each(function() {
		var el = $(this);
		if (el.val() === el.attr('placeholder')) el.val('');
	});
}

});
