 /******************************************************
 * Javascript / jQuery Custom Functionality
 * 			
 * @author			Martin Ogden
 * @email				martin.ogden@gmail.com
 * 
 * @file				custom.jquery.js
 * @version			1.0
 * @date				08/06/2009
 * 
 * Copyright (c) 2009
 *****************************************************/

$(document).ready(function()
{

 /*****************************************************
		Bubble Bounce Function
 *****************************************************/

/*
	function endless_up(the_object, speed, move_x, move_y)
	{
		var x = "-=" + move_x + "px";
		var y = "-=" + move_y + "px";
		
	    $(the_object).animate({ top: y, left: x }, speed, "linear", function(){ endless_down(the_object, speed, move_x, move_y); });
	}
	
	function endless_down(the_object, speed, move_x, move_y)
	{
		var x = "+=" + move_x + "px";
		var y = "+=" + move_y + "px";
		
	    $(the_object).animate({ top: y, left: x }, speed, "linear", function(){ endless_up(the_object, speed, move_x, move_y); });
	}
	
	endless_up('#bubble_bg', 500, 0, 4);
	endless_up('#bubble_1', 500, 5, 0);
	endless_up('#bubble_2', 700, 0, 4);
	endless_up('#bubble_3', 800, 7, 0);
*/
	
	
	/****************************************************
		Event Slider
	****************************************************/
		$('.event').click(function ()
		{

			var $div = $(this);
			var $details = $div.children('.details');
			var height = $div.height() + $details.height();

		  if ( $details.is(':visible') )
			{
		    $(this).animate({ height: "35px" }, { duration: 400, complete: function () { $details.hide(); } });
		  }
			else 
			{
				$('.event').not($div).animate({ height: "35px", "line-height" : "35px" }, { duration: 400, complete: function () { $('.details').not($details).hide(); } });
		    $(this).animate({ height : height }, { duration: 400 });
				$details.show();
		  }

		  return false;
		});

		
		/****************************************************
			Event Mouseovers
		****************************************************/
		
		// TO DO - Replace with ligher color
		//
		// $('.event').hover(function()
		// {
		// 		$(this).addClass('event_hover');
		// 	}, function() {
		// 		$(this).removeClass('event_hover');
		// });
		
		/****************************************************
			Mailing List input focus stuff - iPhone Stylee
		****************************************************/
		
		$('#mailing_list input[type="text"]').focus(function()
		{
			var name = $(this).attr("id");
			if($(this).attr("value") == name)
			{
				$(this).attr("value","");
			}
		});
		
		$('#mailing_list input[type="text"]').blur(function()
		{
			var name = $(this).attr("id");
			if($(this).attr("value") == null)
			{
				$(this).attr("value",name)
			}

		});
		
		/****************************************************
			Unobtrusive Date / Time
		****************************************************/

			var months=new Array(13);
			months[1]="January";
			months[2]="February";
			months[3]="March";
			months[4]="April";
			months[5]="May";
			months[6]="June";
			months[7]="July";
			months[8]="August";
			months[9]="September";
			months[10]="October";
			months[11]="November";
			months[12]="December";
			var time=new Date();
			var lmonth=months[time.getMonth() + 1];
			var date=time.getDate();
			var year=time.getYear();
			if (year < 2000)
			{
				year = year + 1900;
			}
			var suffix = "th";
			if(date == 1 || date == 21 || date == 31)
			{
				suffix = "st";
			}
			if(date == 2 || date == 22)
			{
				suffix = "nd";
			}
			if(date == 3 || date == 23)
			{
				suffix = "rd";
			}
			
			$('#date').html(date + suffix + " " + lmonth + ", " + year);

});


