$(document).ready(function(){

	// clear inputs onclick
	var theTextInputs = $("input[type='text']");
	$.fn.clear = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	theTextInputs.clear();
	theTextInputs.focus(function(){ //Remove uppercase upon text entry to avoid usability issues
		$(this).css("text-transform","none");
	});

	// menu flyouts
	var navAnimDur = 200;
	$('#nav > ul > li').mouseover(function(){
		$(this).stop().animate({
			top: 0
		}, navAnimDur, function(){
			$(this).find('ul').slideDown(navAnimDur);
		});
	});
	$('#nav > ul > li').mouseout(function(){
		$(this).stop().animate({
			top: 0
		}, navAnimDur, function(){
			$(this).find('ul').fadeOut(navAnimDur);
		});
	});

	// share buttons
	var socialBtnContainer = $('#socialBtns');
	socialBtnContainer.hide();
	$('#shareBtn').click(function(event) {
		socialBtnContainer.show();
		event.stopPropagation();
		return false;
	});
	$('body').click(function() {
		socialBtnContainer.hide();
	});
	$('a.share-popup').click(function(){
		window.open(this.href, 'Sharing Popup', 'width=620,height=440,left=20,top=20').focus();
		return false;
	});

	// email form validation
	$("#dl_leadForm").validate();

});
