// jQUERY NUVIGIL //
// VERSION: 1.0.0 //

(function($)
{
	$.fn.nuvigil = function()
	{
		var height = "";
		var image = "";
		var state = "";
		var url = "";
		var zIndex = "";

		zIndex = Math.max.apply(null,$.map($("body > *"), function(obj)
		{
			if($(obj).css("position")=="relative" || $(obj).css("position")=="absolute" || $(obj).css("position")=="fixed")
			{
				return parseInt($(obj).css("z-index"))||1;
			}
		}));

		$("#right_column").css({"position" : "relative"});

		$("#jqForm").css({"z-index" : zIndex + 2});

		$("#button_sphere_anchor").css(
		{
			"z-index" : zIndex + 1
		}).click(function()
		{
			ga_track_event('Forms','Open Contact Form');

			$(this).fadeOut("fast", function()
			{
				$("img", this).fadeOut("fast");
			});

			$("#jqForm").animate({"height" : "314px", "width" : "650px"}, function()
			{
				$("form", this).stop().fadeIn();
			});

			return false;
		});

		$("a[rel=jqFormClose]").click(function()
		{
			ga_track_event('Forms','Close Contact Form');

			$("#jqForm").fadeOut("fast", function()
			{
				$(this).css({"height" : "0px", "width" : "0px"});

				$("form", this).hide();
			});

			$("#button_sphere_anchor").fadeIn("fast", function()
			{
				$("img", this).fadeIn("fast");
			});
		});
	};
})(jQuery);
