/*
	Developer: Antwaan Harrison
	Language:  Javascript / jQuery
*/
function placeholder() {
	//clear default placeholder value
	$('input.placeholder').focus(function() {
		if(this.value === this.defaultValue) {
			this.value = "";
			//dispable spellcheck
			this.setAttribute("spellcheck", "false");
		}
	});
	//restore default placeholder value
	$('input.placeholder').blur(function() {
		if(this.value === "") {
			this.value = this.defaultValue;
		}
	});
}
function enable_directions(bool) {
	if(bool === true) {
		//var form = "<form id=\"form\" action=\"#\" name=\"direction_form\" class=\"form\" method=\"post\"><label for=\"from\">Directions from <input type=\"text\" id=\"from\" class=\"placeholder\" name=\"from_"ress\" value=\"your "ress or location\" /><input type=\"text\" class=\"hide\" /> to Mid Georgia Nursery</label><input id=\"map_it\" type=\"submit\" value=\"Go\" /></form>",
			//new_direction_mssg = "<span>Click here to get personalized directions!</span>";

		if($('#directions-prompt')) {
			$('#form').hide();
			$('#directions-prompt').append(new_direction_mssg);
			$('#directions-prompt span').click(function () {
				$('#directions-prompt').hide();
				$('#directions-prompt').after(form);
				placeholder();
				directions_map();
				//Remove personnel div
				$('#map_it').click(function() {
					$('#personnel').remove();
				});
			});
		}
	}
}
function add_description(img) {
	var modal_box = "<div id=\"modal-box\"><img src=\""+img+"\" /><a href=\"javascript: void(0)\" id=\"close\">Close</a></div>";
	$( "body" ).prepend( modal_box );
}
function create_overlay(img) {
	$( "body" ).prepend( "<div id=\"overlay\"></div>" );
	$( "#overlay" ).css({ opacity: 0.9 });
	$( "#overlay" ).fadeIn( 300, function() {
		add_description(img);
		$( "#modal-box" ).fadeIn( 400 );
		destroy_overlay();
	});
}
function destroy_overlay() {
	$( "#close" ).click(function() {
		$( "#modal-box" ).fadeOut(400, function() {
			$( "modal-box").remove();
			$( "#overlay" ).fadeOut(300, function() {
				$( "div#overlay" ).remove();
			});
		});
	});
}
window.onload = function() {
	placeholder();
	location_map();
}
