$(document).ready(function() {
						   
	$('#contact-form input').focus(function() {
		$(this).val("");											
	});
	$('#contact-form textarea').focus(function() {
		$(this).val("");											
	});
	
	function showOrderNowList() {
		$('#order-now-list').slideDown(300);	
	};
	function hideOrderNowList() {
		$('#order-now-list').delay(100).fadeOut(200);	
	};
	function showLocationsList() {
		$('#locations-list').slideDown(300);	
	};
	function hideLocationsList() {
		$('#locations-list').delay(100).fadeOut(200);	
	};
	function showTeamList() {
		$('#team-list').slideDown(300);	
	};
	function hideTeamList() {
		$('#team-list').delay(100).fadeOut(200);	
	};

	$('#order-now').mouseenter(showOrderNowList);
	$('#order-now-wrapper').mouseleave(hideOrderNowList);
	$('#top-nav-locations').mouseenter(showLocationsList);
	$('#locations-wrapper').mouseleave(hideLocationsList);	
	$('#top-nav-team').mouseenter(showTeamList);
	$('#team-wrapper').mouseleave(hideTeamList);
	
	
	function hideForm () {
		$('#form-background').fadeOut(500);
	}
	function showForm () {
		$('#form-background').fadeIn(500);
		var formID = this.id.replace('email-','');
		document.getElementById('form-'+formID).selected = 'selected';
		return false
	}
	function loadName () {
		var personID = $(this).attr('id');
		return false
	}
	
	$('#close').click(hideForm);
	
	$('.invoke-form').click(showForm);

	function loadSelectedLink() {
		var linkId = $(this).attr('id');
		$('#loadarea-wrapper').children('div').hide(0);
		$('#'+linkId+"-loadarea").show(0); // #loadarea-link-number
		return false
	};
	
	function moveCarrot() {
		var $topPos = ($(this).position().top);
		$('#carrot').animate({top: $topPos + 13}, 500);
	};
	function clearClass() {
		$('#sidebar ul li a').removeClass('active');
	};
	function makeActive() {
		$(this).addClass('active');
	};	
	$('#sidebar ul li a').click(moveCarrot);
	$('.loadlink').click(loadSelectedLink);
	
	$('#sidebar ul li a').click(clearClass);
	$('#sidebar ul li a').click(makeActive);
	
	
	
	$('.jq-hide').hide(0);
	
	if (window.location == "http://208.79.239.28/~lakeside/settlement-officers-in-maryland.php#founders") {
	var $foundersPos = ($('#founders').position().top);
    $('#loadarea-wrapper').children('div').hide(0,clearClass);
		$('#founders').addClass('active');
		$('#carrot').css({'top' : $foundersPos + 13});
		$('#founders-loadarea').show(0);
	}
	else if (window.location == "http://208.79.239.28/~lakeside/settlement-officers-in-maryland.php#attorneys") {
	var $attorneysPos = ($('#attorneys').position().top);
    $('#loadarea-wrapper').children('div').hide(0,clearClass);
		$('#attorneys').addClass('active');
		$('#carrot').css({'top' : $attorneysPos + 13});
		$('#attorneys-loadarea').show(0);
	}
	else if (window.location == "http://208.79.239.28/~lakeside/settlement-officers-in-maryland.php#settlement-officers") {
	var $settlementOfficersPos = ($('#settlement-officers').position().top);
    $('#loadarea-wrapper').children('div').hide(0,clearClass);
		$('#settlement-officers').addClass('active');
		$('#carrot').css({'top' : $settlementOfficersPos + 13});
		$('#settlement-officers-loadarea').show(0);
	}
	else if (window.location == "http://208.79.239.28/~lakeside/settlement-officers-in-maryland.php#processors") {
	var $directorsPos = ($('#processors').position().top);
    $('#loadarea-wrapper').children('div').hide(0,clearClass);
		$('#processors').addClass('active');
		$('#carrot').css({'top' : $directorsPos + 13});
		$('#processors-loadarea').show(0);
	}
	else if (window.location == "http://208.79.239.28/~lakeside/settlement-officers-in-maryland.php#directors") {
	var $directorsPos = ($('#directors').position().top);
    $('#loadarea-wrapper').children('div').hide(0,clearClass);
		$('#directors').addClass('active');
		$('#carrot').css({'top' : $directorsPos + 13});
		$('#directors-loadarea').show(0);
	}
});
